hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
404ea18d160f164e2a05770037c30a6785f1bb18
10,624
h
C
archive/CPPHelloSpeech/packages/Microsoft.CognitiveServices.Speech.0.2.12733/build/native/include/cxx_api/speechapi_cxx_translation_recognizer.h
akashdeepbansal/eBookNavigator
429204fb2d1e69b2918c7be9084c57ecf676975f
[ "MIT" ]
null
null
null
archive/CPPHelloSpeech/packages/Microsoft.CognitiveServices.Speech.0.2.12733/build/native/include/cxx_api/speechapi_cxx_translation_recognizer.h
akashdeepbansal/eBookNavigator
429204fb2d1e69b2918c7be9084c57ecf676975f
[ "MIT" ]
null
null
null
archive/CPPHelloSpeech/packages/Microsoft.CognitiveServices.Speech.0.2.12733/build/native/include/cxx_api/speechapi_cxx_translation_recognizer.h
akashdeepbansal/eBookNavigator
429204fb2d1e69b2918c7be9084c57ecf676975f
[ "MIT" ]
1
2020-12-29T09:02:56.000Z
2020-12-29T09:02:56.000Z
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.md file in the project root for full license information. // // speechapi_cxx_translation_recognizer.h: Public API declarations for translation recognizer in C++. // #pragma once #include <exception> #include <future> #include <memory> #include <string> #include <map> #include <speechapi_cxx_common.h> #include <speechapi_c.h> #include <speechapi_cxx_recognition_async_recognizer.h> #include <speechapi_cxx_translation_result.h> #include <speechapi_cxx_translation_eventargs.h> namespace Microsoft { namespace CognitiveServices { namespace Speech { namespace Translation { /* Defines scopes for language resources. Clients use the scope define which sets of languages they are interested in. TRANSLATION_LANGUAGE_RESOURCE_SCOPE_SPEECH: Languages available to transcribe speech into text. TRANSLATION_LANGUAGE_RESOURCE_SCOPE_TEXT: languages available to translate transcribed text. TRANSLATION_LANGUAGE_RESOURCE_SCOPE_TTS: languages and voices available to synthesize translated text back into speech. Scopes can be combined via bit-or. */ typedef unsigned int LanguageResourceScope; #define TRANSLATION_LANGUAGE_RESOURCE_SCOPE_SPEECH 0x01 #define TRANSLATION_LANGUAGE_RESOURCE_SCOPE_TEXT 0x02 #define TRANSLATION_LANGUAGE_RESOURCE_SCOPE_TTS 0x04 /// <summary> /// Resource value defined for the TRANSLATION_LANGUAGE_RESOURCE_SCOPE_SPEECH scope. /// </summary> class SpeechScopeResourceValue { public: /// <summary> name represents display name of the language.</summary> std::wstring name; /// <summary> language is the language tag in BCP-47 format of the associated written language.</summary> std::wstring language; }; /// <summary> /// Resource value defined for the TRANSLATION_LANGUAGE_RESOURCE_SCOPE_TEXT scope. /// </summary> class TextScopeResourceValue { public: /// <summary> name is the display name of the written language.</summary> std::wstring name; /// <summary> dir represents the irectionality which is "rtl" for right-to-left languages, or "ltr" for left-to-right languages.</summary> std::wstring dir; }; /// <summary> /// Resource value defined for the TRANSLATION_LANGUAGE_RESOURCE_SCOPE_TTS scope. /// </summary> class SynthesisScopeResourceValue { public: /// <summary>displayName is the display name of the voice.</summary> std::wstring displayName; /// <summary>gender describes gender of the voice(male or female).</summary> std::wstring gender; /// <summary>locale is the language tag of the voice with primary language subtag and region subtag. </summary> std::wstring locale; /// <summary>languageName is the display name of the language.</summary> std::wstring languageName; /// <summary>regionName is the display name of the region for this language.</summary> std::wstring regionName; /// <summary>language represents the language tag of the associated written language.</summary> std::wstring language; }; /// <summary> /// Language resources that are supported by the translation service. /// See https://docs.microsofttranslator.com/speech-translate.html for details. /// </summary> class TranslationLanguageResource { public: TranslationLanguageResource() { // Todo: get resource from service. } /// <summary> /// speechResources contains languages supported by speech-to-text. It is a dictionary of (key, value) pairs. /// Each key identifies a language supported by speech-to-text. The value associated with the key is of type <see cref="SpeechScopeResourceValue"/>. /// </summary> std::map<std::wstring, SpeechScopeResourceValue> speechResources; /// <summary> /// textResoruces contains languages supported by text translation. It is also a dictionary where each key identifies a language /// supported by text translation. The value associated with the key is of type <see cref="TextScopeResourceValue"/>. /// </summary> std::map<std::wstring, TextScopeResourceValue> textResources; /// <summary> /// voiceResources contains languages supported by text-to-speech. It is a dictionary where key is the lagnuage tag that supports voice output. /// The value associated with each key is of type <see cref="SynthesisScopeResourceValue"/>. /// </summary> std::map<std::wstring, SynthesisScopeResourceValue> voiceResources; }; /// <summary> /// Performs translation on the speech input. /// </summary> class TranslationRecognizer final : public AsyncRecognizer<TranslationTextResult, TranslationTextResultEventArgs> { public: // The AsyncRecognizer only deals with events for translation text result. The audio output event // is managed by OnTranslationSynthesisResult. using BaseType = AsyncRecognizer<TranslationTextResult, TranslationTextResultEventArgs>; /// <summary> /// It is intended for internal use only. It creates an instance of <see cref="TranslationRecognizer"/>. /// </summary> /// <remarks> /// It is recommended to use SpeechFactory to create an instance of <see cref="TranslationRecognizer"/>. This method is mainly /// used in case where a recognizer handle has been created by methods via C-API like RecognizerFactory_CreateTranslationRecognizer(). /// </remarks> /// <param name="hreco">The handle of the recognizer that is returned by RecognizerFactory_CreateTranslationRecognizer().</param> explicit TranslationRecognizer(SPXRECOHANDLE hreco) : BaseType(hreco), // Todo: OnTranslationError(m_onTranslationError), Parameters(hreco), TranslationSynthesisResultEvent(GetTranslationAudioEventConnectionsChangedCallback(), GetTranslationAudioEventConnectionsChangedCallback()) { SPX_DBG_TRACE_SCOPE(__FUNCTION__, __FUNCTION__); } /// <summary> /// Deconstructs the instance. /// </summary> ~TranslationRecognizer() { SPX_DBG_TRACE_SCOPE(__FUNCTION__, __FUNCTION__); TermRecognizer(); } /// <summary> /// Starts translation recognition as an asynchronous operation, and stops after the first utterance is recognized. The asynchronous operation returns <see creaf="TranslationTextResult"/> as result. /// </summary> /// <returns>An asynchronous operation representing the recognition. It returns a value of <see cref="TranslationTextResult"/> as result.</returns> std::future<std::shared_ptr<TranslationTextResult>> RecognizeAsync() override { return BaseType::RecognizeAsyncInternal(); } /// <summary> /// Starts translation on a continous audio stream, until StopContinuousRecognitionAsync() is called. /// User must subscribe to events to receive recognition results. /// </summary> /// <returns>An asynchronous operation that starts the translation.</returns> std::future<void> StartContinuousRecognitionAsync() override { return BaseType::StartContinuousRecognitionAsyncInternal(); } /// <summary> /// Stops continuous translation. /// </summary> /// <returns>A task representing the asynchronous operation that stops the translation.</returns> std::future<void> StopContinuousRecognitionAsync() override { return BaseType::StopContinuousRecognitionAsyncInternal(); } /// <summary> /// Note: NOT implemented. Starts keyword recognition on a continuous audio stream, until StopKeywordRecognitionAsync() is called. /// </summary> /// Note: Key word spotting functionality is only available on the Cognitive Services Device SDK.This functionality is currently not included in the SDK itself. /// <param name="model">Specifies the keyword model to be used.</param> /// <returns>An asynchronous operation that starts the keyword recognition.</returns> std::future<void> StartKeywordRecognitionAsync(std::shared_ptr<KeywordRecognitionModel> model) override { UNUSED(model); auto future = std::async(std::launch::async, [=]() -> void { SPX_THROW_ON_FAIL(SPXERR_NOT_IMPL); }); return future; }; /// <summary> /// Note: NOT implemented. Stops continuous keyword recognition. /// </summary> /// Note: Key word spotting functionality is only available on the Cognitive Services Device SDK.This functionality is currently not included in the SDK itself. /// <returns>A task representing the asynchronous operation that stops the keyword recognition.</returns> std::future<void> StopKeywordRecognitionAsync() override { auto future = std::async(std::launch::async, [=]() -> void { SPX_THROW_ON_FAIL(SPXERR_NOT_IMPL); }); return future; }; /// <summary> /// The collection of parameters and their values defined for this <see cref="TranslationRecognizer"/>. /// </summary> RecognizerParameterValueCollection Parameters; /// <summary> /// The event signals that a translation synthesis result is received. /// </summary> EventSignal<const TranslationSynthesisResultEventArgs&> TranslationSynthesisResultEvent; private: DISABLE_DEFAULT_CTORS(TranslationRecognizer); friend class Microsoft::CognitiveServices::Speech::Session; std::function<void(const EventSignal<const TranslationSynthesisResultEventArgs&>&)> GetTranslationAudioEventConnectionsChangedCallback() { return [=](const EventSignal<const TranslationSynthesisResultEventArgs&>& audioEvent) { if (&audioEvent == &TranslationSynthesisResultEvent) { TranslationRecognizer_TranslationSynthesis_SetEventCallback(m_hreco, TranslationSynthesisResultEvent.IsConnected() ? FireEvent_TranslationSynthesisResult : nullptr, this); } }; } static void FireEvent_TranslationSynthesisResult(SPXRECOHANDLE hreco, SPXEVENTHANDLE hevent, void* pvContext) { UNUSED(hreco); std::unique_ptr<TranslationSynthesisResultEventArgs> recoEvent{ new TranslationSynthesisResultEventArgs(hevent) }; auto pThis = static_cast<TranslationRecognizer*>(pvContext); auto keepAlive = pThis->shared_from_this(); pThis->TranslationSynthesisResultEvent.Signal(*recoEvent.get()); } }; } } } } // Microsoft::CognitiveServices::Speech::Translation
43.363265
203
0.715456
[ "model" ]
405d41b86bd6415bbb901da228d1b25144ddb4b2
5,140
h
C
ell_SPMM/test_spmm.h
KhalidTheeb/SpMM
46cbab84dc769ed8c4bfac8a073bc7a2e437c57f
[ "MIT" ]
2
2019-12-25T08:53:23.000Z
2020-02-16T05:10:47.000Z
ell_SPMM/test_spmm.h
KhalidTheeb/SpMM
46cbab84dc769ed8c4bfac8a073bc7a2e437c57f
[ "MIT" ]
null
null
null
ell_SPMM/test_spmm.h
KhalidTheeb/SpMM
46cbab84dc769ed8c4bfac8a073bc7a2e437c57f
[ "MIT" ]
null
null
null
/* * Copyright NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once // Functions to test spmm kernels #include <algorithm> #include <limits> #include <cmath> #include "mem.h" #include "spmm_host.h" #include "spmm_ell_device.cu.h" template <typename T> T maximum_relative_error(const T * A, const T * B, const size_t N) { T max_error = 0; float max_absolute_error; int number_of_errors=0; int vector=0; int location=0; T eps = std::sqrt( std::numeric_limits<T>::epsilon() ); for (size_t j=0; j<NUMVECTORS ; j++){ for(size_t i = 0; i < N; i++) { const T a = A[j*N+i]; const T b = B[j*N+i]; const T error = std::abs(a - b); if (error != 0){ if ( error/(std::abs(a) + std::abs(b) + eps) > 5 * std::sqrt( std::numeric_limits<T>::epsilon() ) )number_of_errors++; max_error = std::max(max_error, error/(std::abs(a) + std::abs(b) + eps) ); if (error/(std::abs(a) + std::abs(b) + eps) == max_error) {max_absolute_error=std::abs(a - b) ; vector=j; location=i;} } } } printf("number of errors = %d\n", number_of_errors); printf("location of maximum error= %d in vector %d error %f\n", location, vector, max_absolute_error); return max_error; } template <typename IndexType, typename ValueType> void test_spmm_ell_kernel(const csr_matrix<IndexType,ValueType>& csr) { printf("\n#### Testing ELL SpMM Kernel ####\n"); const IndexType num_rows = csr.num_rows; const IndexType num_cols = csr.num_cols; // Initialize host vectors ValueType * x_host = new_host_array<ValueType>(num_cols* NUMVECTORS ); ValueType * y_host = new_host_array<ValueType>(num_rows* NUMVECTORS ); for(IndexType j = 0; j < NUMVECTORS ; j++) for(IndexType i = 0; i < num_cols; i++) x_host[j*num_cols+i] = rand() / (RAND_MAX + 1.0); for(IndexType j = 0; j < NUMVECTORS ; j++) for(IndexType i = 0; i < num_rows; i++) y_host[j*num_rows+i] = rand() / (RAND_MAX + 1.0); printf("Creating ELL_matrix.....\n"); IndexType max_cols_per_row = static_cast<IndexType>( (3 * csr.num_nonzeros) / csr.num_rows + 1 );//khalid: equation is for dia ell_matrix<IndexType,ValueType> ell = csr_to_ell<IndexType,ValueType>(csr, max_cols_per_row); if (ell.num_nonzeros == 0 && csr.num_nonzeros != 0){ printf(" num_cols_per_row (%d) excedes limit (%d)\n", ell.num_cols_per_row, max_cols_per_row); return; } printf(" found %d num_cols_per_row\n", ell.num_cols_per_row); printf("done\n"); printf("### Checking the correctness of ELL kernel ###\n"); // transfer matrices from host to destination location ell_matrix<IndexType,ValueType> sm2_loc2 = copy_matrix_to_device(ell); printf("Finished copying the matrix to device memory...\n"); // create vectors in appropriate locations ValueType * x_loc1 = copy_array(x_host, num_cols*NUMVECTORS , HOST_MEMORY, HOST_MEMORY); ValueType * x_loc2 = copy_array(x_host, num_cols*NUMVECTORS , HOST_MEMORY, DEVICE_MEMORY); ValueType * y_loc1 = copy_array(y_host, num_rows*NUMVECTORS , HOST_MEMORY, HOST_MEMORY); ValueType * y_loc2 = copy_array(y_host, num_rows*NUMVECTORS , HOST_MEMORY, DEVICE_MEMORY); // compute y = A*x printf("Calling CSR kernel on host....\n"); for(IndexType j = 0; j < NUMVECTORS ; j++) spmv_csr_serial_host<IndexType,ValueType>(csr, x_loc1 + j*num_cols, y_loc1 + j*num_rows); printf("done...\n"); printf("Calling ELL kernel on device.....\n"); //spmm_ell_device(sm2_loc2, x_loc2, y_loc2); spmm_ell_tex_device(sm2_loc2, x_loc2, y_loc2); printf("done...\n "); // transfer results to host ValueType * y_sm1_result = copy_array(y_loc1, num_rows*NUMVECTORS , HOST_MEMORY, HOST_MEMORY); ValueType * y_sm2_result = copy_array(y_loc2, num_rows*NUMVECTORS , DEVICE_MEMORY, HOST_MEMORY); ValueType max_error = maximum_relative_error(y_sm1_result, y_sm2_result, num_rows); printf("[max error %9f]", max_error); if ( max_error > 5 * std::sqrt( std::numeric_limits<ValueType>::epsilon() ) ) printf(" POSSIBLE FAILURE"); printf("\n"); // cleanup delete_device_matrix(sm2_loc2); delete_host_matrix(ell); delete_host_array(x_host); delete_host_array(y_host); delete_array(x_loc1, HOST_MEMORY); delete_array(x_loc2, DEVICE_MEMORY); delete_array(y_loc1, HOST_MEMORY); delete_array(y_loc2, DEVICE_MEMORY); delete_host_array(y_sm1_result); delete_host_array(y_sm2_result); }
37.794118
139
0.666926
[ "vector" ]
40637a7df9ef75637b06aada69ec3b6a35ddeab0
1,140
h
C
Simple 2D/src/curor.h
JulesG10/MutliGame
e6a193aa8b07b4930d9edf9824fda42e1cd1fc77
[ "MIT" ]
2
2021-01-09T14:24:54.000Z
2021-04-21T11:53:11.000Z
Simple 2D/src/curor.h
JulesG10/MutliGame
e6a193aa8b07b4930d9edf9824fda42e1cd1fc77
[ "MIT" ]
null
null
null
Simple 2D/src/curor.h
JulesG10/MutliGame
e6a193aa8b07b4930d9edf9824fda42e1cd1fc77
[ "MIT" ]
null
null
null
#pragma once #ifndef GAME_CURSOR #define GAME_CURSOR #include<SDL.h> #include "utils.h" #include "draw.h" static int CURSOR_SIZE = 8; static RGB CURSOR_COLOR = {255,255,255}; void InitCursor(SDL_Cursor *cursor,int size,RGB rgb) { CURSOR_COLOR = rgb; CURSOR_SIZE = size; int32_t cursorData[2] = {0, 0}; cursor = SDL_CreateCursor((Uint8 *)cursorData, (Uint8 *)cursorData, 8, 8, 4, 4); SDL_SetCursor(cursor); SDL_ShowCursor(SDL_DISABLE); } void MoveCursor(SDL_Renderer *render,Point pos) { SetRGB(render,CURSOR_COLOR,true); int size = CURSOR_SIZE; Point tb = {pos.x,pos.y-size}; Point tb_end = {pos.x,pos.y+size}; Point rl = {pos.x-size,pos.y}; Point rl_end = {pos.x+size,pos.y}; DrawLine(render,tb,tb_end); DrawLine(render,rl,rl_end); } void CursorTracer(SDL_Renderer *render,Point pos_cursor){ SetRGB(render,(RGB){255, 42, 0},true); DrawLine(render,(Point){0,pos_cursor.y},(Point){pos_cursor.x,pos_cursor.y}); SetRGB(render,(RGB){0, 255, 34},true); DrawLine(render,(Point){pos_cursor.x,0},(Point){pos_cursor.x,pos_cursor.y}); } #endif // !GAME_CURSOR
23.265306
84
0.674561
[ "render" ]
4069715ae0fa3006b5ad1bd81a91327ee736dbe7
3,120
h
C
Sources/Elastos/Frameworks/Droid/Base/Packages/SystemUI/inc/elastos/droid/systemui/statusbar/phone/CStatusBarWindowView.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
7
2017-07-13T10:34:54.000Z
2021-04-16T05:40:35.000Z
Sources/Elastos/Frameworks/Droid/Base/Packages/SystemUI/inc/elastos/droid/systemui/statusbar/phone/CStatusBarWindowView.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
null
null
null
Sources/Elastos/Frameworks/Droid/Base/Packages/SystemUI/inc/elastos/droid/systemui/statusbar/phone/CStatusBarWindowView.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
9
2017-07-13T12:33:20.000Z
2021-06-19T02:46:48.000Z
//========================================================================= // Copyright (C) 2012 The Elastos Open Source Project // // 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 __ELASTOS_DROID_SYSTEMUI_STATUSBAR_PHONE_CSTATUSBARWINDOWVIEW_H__ #define __ELASTOS_DROID_SYSTEMUI_STATUSBAR_PHONE_CSTATUSBARWINDOWVIEW_H__ #include "_Elastos_Droid_SystemUI_StatusBar_Phone_CStatusBarWindowView.h" #include "elastos/droid/systemui/statusbar/DragDownHelper.h" #include <elastos/droid/widget/FrameLayout.h> #include <elastos/core/Object.h> using Elastos::Droid::SystemUI::StatusBar::Stack::INotificationStackScrollLayout; using Elastos::Droid::SystemUI::StatusBar::DragDownHelper; using Elastos::Droid::View::IKeyEvent; using Elastos::Droid::View::IMotionEvent; using Elastos::Droid::Widget::FrameLayout; using Elastos::Core::Object; namespace Elastos { namespace Droid { namespace SystemUI { namespace StatusBar { namespace Phone { CarClass(CStatusBarWindowView) , public FrameLayout , public IStatusBarWindowView { public: CAR_OBJECT_DECL() CAR_INTERFACE_DECL() CARAPI constructor( /* [in] */ IContext* context, /* [in] */ IAttributeSet* attrs); // @Override CARAPI DispatchKeyEvent( /* [in] */ IKeyEvent* event, /* [out] */ Boolean* result); // @Override CARAPI DispatchTouchEvent( /* [in] */ IMotionEvent* ev, /* [out] */ Boolean* result); // @Override CARAPI OnInterceptTouchEvent( /* [in] */ IMotionEvent* ev, /* [out] */ Boolean* result); // @Override CARAPI OnTouchEvent( /* [in] */ IMotionEvent* ev, /* [out] */ Boolean* result); // @Override CARAPI_(void) OnDraw( /* [in] */ ICanvas* canvas); CARAPI CancelExpandHelper(); protected: // @Override CARAPI FitSystemWindows( /* [in] */ IRect* insets, /* [out] */ Boolean* result); // @Override CARAPI OnAttachedToWindow (); public: static const String TAG; static const Boolean DEBUG; IPhoneStatusBar* mService; private: AutoPtr<DragDownHelper> mDragDownHelper; AutoPtr<INotificationStackScrollLayout> mStackScrollLayout; AutoPtr<INotificationPanelView> mNotificationPanel; AutoPtr<IView> mBrightnessMirror; AutoPtr<IPaint> mTransparentSrcPaint; }; } // namespace Phone } // namespace StatusBar } // namespace SystemUI } // namespace Droid } // namespace Elastos #endif // __ELASTOS_DROID_SYSTEMUI_STATUSBAR_PHONE_CSTATUSBARWINDOWVIEW_H__
29.158879
81
0.673718
[ "object" ]
4072c49a2b3b4c9213fc428f7a3a999c4ec0b4fb
16,657
h
C
src/XmlParser.h
markjulmar/jtiutils
7e3b2bd7ee8c8099e5daf50fd0ab366d8b2c63dd
[ "MIT" ]
null
null
null
src/XmlParser.h
markjulmar/jtiutils
7e3b2bd7ee8c8099e5daf50fd0ab366d8b2c63dd
[ "MIT" ]
null
null
null
src/XmlParser.h
markjulmar/jtiutils
7e3b2bd7ee8c8099e5daf50fd0ab366d8b2c63dd
[ "MIT" ]
null
null
null
/****************************************************************************/ // // XmlParser.h // // This header defines the simple Xml parser used by the configuration class. // This is not designed or intended to be used as a full XML implementation. // It does not treat comments or PIs as node types; but instead is designed to // be element-oriented for configuration purporses. // // Copyright (C) 2002-2003 JulMar Technology, Inc. All rights reserved // This is private property of JulMar Technology, Inc. It may not be // distributed or released without express written permission of // JulMar Technology, Inc. // // You must not remove this notice, or any other, from this software. // // Revision History // -------------------------------------------------------------- // 09/11/2002 MCS Initial revision // /****************************************************************************/ #ifndef __JTI_XML_PARSER_H_INCL__ #define __JTI_XML_PARSER_H_INCL__ /*---------------------------------------------------------------------------- INCLUDE FILES -----------------------------------------------------------------------------*/ #include <string> #include <map> #include <vector> #include <algorithm> #include <Lock.h> #include <RefCount.h> using namespace std; namespace JTI_Util { /*---------------------------------------------------------------------------- FORWARD DEFINITIONS -----------------------------------------------------------------------------*/ class XmlCommentArray; class XmlNodeArray; class XmlAttributeMap; /******************************************************************************/ // XmlNodeImpl // // This internal class provides support for a single parser node; this // class is then wrapped in a wrapper class for ref counting. // /******************************************************************************/ class XmlNodeImpl : public RefCountedObject<>, public LockableObject<> { // Class data private: std::string name_; // Name of the node std::string value_; // Value of the node std::map<std::string, std::string> attribs_;// Attributes std::vector<XmlNodeImpl*> children_; // Children std::vector<std::string> comments_; // Comments // Constructor private: friend class XmlNode; friend class XmlNodeArray; friend class XmlCommentArray; XmlNodeImpl(const char* pszName="", const char* pszValue = ""); public: ~XmlNodeImpl(); // Methods private: std::string RenderXml(int level) const; // Unavailable methods private: XmlNodeImpl(const XmlNodeImpl&); XmlNodeImpl& operator=(const XmlNodeImpl&); }; /******************************************************************************/ // XmlNode // // This class provides support for a single parser node. // /******************************************************************************/ class XmlNode { // Class data private: XmlNodeImpl* pImpl_; // Constructor public: XmlNode() : pImpl_(JTI_NEW XmlNodeImpl) {/* */} XmlNode(const char* pszName, const char* pszValue = "") : pImpl_(JTI_NEW XmlNodeImpl(pszName, pszValue)) {/* */} XmlNode(const XmlNode& rhs) : pImpl_(rhs.pImpl_) { pImpl_->AddRef(); } ~XmlNode() { pImpl_->Release(); } // Operators public: XmlNode& operator=(const XmlNode& rhs) { if (this != &rhs) { pImpl_->Release(); pImpl_ = rhs.pImpl_; pImpl_->AddRef(); } return *this; } bool operator==(const XmlNode& rhs) const { return pImpl_ == rhs.pImpl_; } bool operator!=(const XmlNode& rhs) const { return !operator==(rhs); } bool operator!() { return !get_IsValid(); } // Properties public: __declspec(property(get=get_Name, put=set_Name)) const std::string Name; __declspec(property(get=get_Value, put=set_Value)) const std::string Value; __declspec(property(get=get_hasValue)) bool HasValue; __declspec(property(get=get_hasAttributes)) bool HasAttributes; __declspec(property(get=get_Attributes)) XmlAttributeMap& Attributes; __declspec(property(get=get_hasChildren)) bool HasChildren; __declspec(property(get=get_Children)) XmlNodeArray& Children; __declspec(property(get=get_IsValid)) bool IsValid; __declspec(property(get=get_hasComments)) bool HasComments; __declspec(property(get=get_Comments)) XmlCommentArray& Comments; // Accessors public: bool get_IsValid() const { return !pImpl_->name_.empty(); } const std::string& get_Name() const { return pImpl_->name_; } void set_Name(const char* pszName) { pImpl_->name_ = pszName; } void set_Value(const char* pszValue) { pImpl_->value_ = pszValue; } const std::string& get_Value() const { return pImpl_->value_; } bool get_hasValue() const { return !pImpl_->value_.empty(); } bool get_hasChildren() const { return !pImpl_->children_.empty(); } bool get_hasComments() const { return !pImpl_->comments_.empty(); } bool get_hasAttributes() const { return !pImpl_->attribs_.empty(); } XmlCommentArray get_Comments() const; XmlAttributeMap get_Attributes() const; XmlNodeArray get_Children() const; // Methods public: XmlNode find(const char* pszPath) const; std::string RenderXml(int level=0) const { return pImpl_->RenderXml(level); } // Private methods private: friend class XmlNodeArray; friend class XmlAttributeMap; friend class XmlNodeArrayIterator; friend class XmlCommentArray; XmlNode(XmlNodeImpl* pNode) : pImpl_(pNode) { pImpl_->AddRef(); } }; /******************************************************************************/ // XmlAttributeMapIterator // // This class provides iterator support for the attribute map // /******************************************************************************/ class XmlAttributeMapIterator { // Class data private: typedef std::map<std::string, std::string> AttributeMap; AttributeMap map_; public: typedef AttributeMap::iterator iterator ; typedef AttributeMap::const_iterator const_iterator; // Constructor private: friend class XmlAttributeMap; XmlAttributeMapIterator(const AttributeMap& mapIn) : map_(mapIn) {/* */} // Methods public: bool empty() const { return map_.empty(); } int size() const { return static_cast<int>(map_.size()); } std::string operator[](const char* pszKey) const { const_iterator it = map_.find(pszKey); if (it == map_.end()) return ""; return it->second; } iterator begin() { return map_.begin(); } iterator end() { return map_.end(); } const_iterator begin() const { return map_.begin(); } const_iterator end() const { return map_.end(); } }; /******************************************************************************/ // XmlAttributeMap // // This class provides support for attributes // /******************************************************************************/ class XmlAttributeMap { // Class data private: typedef std::map<std::string, std::string> AttributeMap; XmlNode node_; AttributeMap& mapRef_; // Constructor private: friend class XmlNode; XmlAttributeMap(const XmlNode& node, AttributeMap& mapIn) : node_(node), mapRef_(mapIn) {/* */} public: XmlAttributeMap(const XmlAttributeMap& rhs) : node_(rhs.node_), mapRef_(rhs.mapRef_) {/* */} ~XmlAttributeMap() {/* */} // Operators public: XmlAttributeMap& operator=(const XmlAttributeMap& rhs) { if (this != &rhs) { node_ = rhs.node_; mapRef_ = rhs.mapRef_; } return *this; } // Properties public: __declspec(property(get=empty)) bool IsEmpty; __declspec(property(get=size)) int Count; __declspec(property(get=get_Iterator)) XmlAttributeMapIterator Iterator; // Accessors public: bool empty() const { return mapRef_.empty(); } int size() const { return static_cast<int>(mapRef_.size()); } XmlAttributeMapIterator get_Iterator() const { return XmlAttributeMapIterator(mapRef_); } std::string operator[](const char* pszKey) const { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); return mapRef_[pszKey]; } void add(const char* pszKey, const char* pszValue) { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); mapRef_.insert(std::make_pair(pszKey, pszValue)); } void add(const char* pszKey, int value) { char chBuff[50]; itoa(value, chBuff, 10); CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); mapRef_.insert(std::make_pair(pszKey, chBuff)); } void add(const char* pszKey, long value) { char chBuff[50]; ltoa(value, chBuff, 10); CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); mapRef_.insert(std::make_pair(pszKey, chBuff)); } void remove(const char* pszKey) { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); mapRef_.erase(pszKey); } std::string find(const char* pszKey) const { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); AttributeMap::const_iterator it = mapRef_.find(pszKey); if (it == mapRef_.end()) return std::string(""); return it->second; } }; /******************************************************************************/ // XmlCommentArrayIterator // // This class provides a safe way to iterate the collection of comments // /******************************************************************************/ class XmlCommentArrayIterator { // Class data private: typedef std::vector<std::string> CommentArray; CommentArray arrComments_; public: typedef CommentArray::iterator iterator; typedef CommentArray::const_iterator const_iterator; // Constructor private: friend class XmlCommentArray; XmlCommentArrayIterator(const CommentArray& arrIn) { arrComments_ = arrIn; } // Methods public: bool empty() const { return arrComments_.empty(); } int size() const { return static_cast<int>(arrComments_.size()); } std::string operator[](int index) const { return arrComments_[index]; } iterator begin() { return arrComments_.begin(); } iterator end() { return arrComments_.end(); } const_iterator begin() const { return arrComments_.begin(); } const_iterator end() const { return arrComments_.end(); } }; /******************************************************************************/ // XmlCommentArray // // This class provides support for comments // /******************************************************************************/ class XmlCommentArray { // Class data private: typedef std::vector<std::string> CommentArray; XmlNode node_; CommentArray& arrRef_; // Constructor private: friend class XmlNode; XmlCommentArray(const XmlNode& node, CommentArray& arrIn) : node_(node), arrRef_(arrIn) {/* */} public: XmlCommentArray(const XmlCommentArray& rhs) : node_(rhs.node_), arrRef_(rhs.arrRef_) {/* */} ~XmlCommentArray() {/* */} // Operators public: XmlCommentArray& operator=(const XmlCommentArray& rhs) { if (this != &rhs) { node_ = rhs.node_; arrRef_ = rhs.arrRef_; } return *this; } // Properties public: __declspec(property(get=empty)) bool IsEmpty; __declspec(property(get=size)) int Count; __declspec(property(get=get_Iterator)) XmlCommentArrayIterator Iterator; // Accessors public: bool empty() const { return arrRef_.empty(); } int size() const { return static_cast<int>(arrRef_.size()); } XmlCommentArrayIterator get_Iterator() const { return XmlCommentArrayIterator(arrRef_); } std::string operator[](int key) const { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); return arrRef_[key]; } void add(const char* pszComment) { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); arrRef_.push_back(pszComment); } void remove(int key) { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); arrRef_.erase(arrRef_.begin()+key); } }; /******************************************************************************/ // XmlNodeArrayIterator // // This class provides a safe way to iterate the collection // /******************************************************************************/ class XmlNodeArrayIterator { // Class data private: typedef std::vector<XmlNode> NodeArray; NodeArray arrNodes_; public: typedef NodeArray::iterator iterator; typedef NodeArray::const_iterator const_iterator; // Constructor private: friend class XmlNodeArray; XmlNodeArrayIterator(XmlNode node, std::vector<XmlNodeImpl*>& arrNodes) { arrNodes_.reserve(arrNodes.size()); for(std::vector<XmlNodeImpl*>::iterator it = arrNodes.begin(); it != arrNodes.end(); ++it) arrNodes_.push_back(XmlNode(*it)); } // Methods public: bool empty() const { return arrNodes_.empty(); } int size() const { return static_cast<int>(arrNodes_.size()); } XmlNode operator[](int index) const { return arrNodes_[index]; } iterator begin() { return arrNodes_.begin(); } iterator end() { return arrNodes_.end(); } const_iterator begin() const { return arrNodes_.begin(); } const_iterator end() const { return arrNodes_.end(); } }; /******************************************************************************/ // XmlNodeArray // // This class provides a node array // /******************************************************************************/ class XmlNodeArray { // Class data private: typedef std::vector<XmlNodeImpl*> NodeArray; XmlNode node_; NodeArray& arrNodes_; // Constructor private: friend class XmlNode; XmlNodeArray(const XmlNode& node, NodeArray& arrNodes) : node_(node), arrNodes_(arrNodes) {/* */} public: XmlNodeArray(const XmlNodeArray& rhs) : node_(rhs.node_), arrNodes_(rhs.arrNodes_) {/* */} ~XmlNodeArray() {/* */} // Operators public: XmlNodeArray& operator=(XmlNodeArray& rhs) { if (this != &rhs) { node_ = rhs.node_; arrNodes_ = rhs.arrNodes_; } return *this; } // Properties public: __declspec(property(get=empty)) bool IsEmpty; __declspec(property(get=size)) int Count; __declspec(property(get=get_Iterator)) XmlNodeArrayIterator Iterator; // Accessors public: bool empty() const { return arrNodes_.empty(); } int size() const { return static_cast<int>(arrNodes_.size()); } void add(const XmlNode& xmlNode) { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); if (xmlNode == node_) throw(std::runtime_error("Cannot insert self into child array!")); XmlNodeImpl* pImpl = xmlNode.pImpl_; NodeArray::iterator it = std::find(arrNodes_.begin(), arrNodes_.end(), pImpl); if (it != arrNodes_.end()) throw(std::runtime_error("Multiple insertion of same node within array not allowed!")); pImpl->AddRef(); arrNodes_.push_back(pImpl); } bool remove(const XmlNode& xmlNode) { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); XmlNodeImpl* pImpl = xmlNode.pImpl_; NodeArray::iterator it = std::find(arrNodes_.begin(), arrNodes_.end(), pImpl); if (it != arrNodes_.end()) { (*it)->Release(); arrNodes_.erase(it); return true; } return false; } XmlNode find(const char* pszName) const { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); for (NodeArray::iterator it = arrNodes_.begin(); it != arrNodes_.end(); ++it) { if ((*it)->name_ == pszName) return XmlNode(*it); } return XmlNode(); } XmlNode Index(int index) const { CCSLock<XmlNodeImpl> _lockGuard(node_.pImpl_); if (index < 0 || index >= static_cast<int>(arrNodes_.size())) throw std::out_of_range("index out of range"); return XmlNode(arrNodes_[index]); } XmlNode operator[](int index) const { return Index(index); } XmlNodeArrayIterator get_Iterator() const { return XmlNodeArrayIterator(node_, arrNodes_); } }; /******************************************************************************/ // XmlDocument // // This class provides the document owner which holds the root node. // /******************************************************************************/ class XmlDocument { // Class data private: XmlNode root_; // Root node of the document. // Constructor public: XmlDocument(const char* pszRootName=NULL); ~XmlDocument() {/* */} // Properties public: __declspec(property(get=get_Root)) XmlNode& RootNode; __declspec(property(get=get_Xml)) std::string XmlText; // Accessors public: XmlNode get_Root() { return root_; } std::string get_Xml() const { return root_.RenderXml(); } // Methods public: bool load(const char* pszFile); bool save(const char* pszFile); void parse(const std::string& xmlBuffer); XmlNode find(const char* pszPath) const; XmlNode create(const char* pszPath, bool* pfCreated=NULL); }; }// namespace JTI_Util #endif // __JTI_XML_PARSER_H_INCL__
30.012613
114
0.612295
[ "vector" ]
408160158a9c1a4107bda59224dd919c8fca724a
3,442
h
C
Source/LSystems/LSystemActor.h
NickVeselov/L-Systems
4610ac02604c95070394dfe96c6ed65ddd24fa48
[ "MIT" ]
null
null
null
Source/LSystems/LSystemActor.h
NickVeselov/L-Systems
4610ac02604c95070394dfe96c6ed65ddd24fa48
[ "MIT" ]
null
null
null
Source/LSystems/LSystemActor.h
NickVeselov/L-Systems
4610ac02604c95070394dfe96c6ed65ddd24fa48
[ "MIT" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "TreeStructure.h" #include "GameFramework/Actor.h" #include "LSystemActor.generated.h" UCLASS() class LSYSTEMS_API ALSystemActor : public AActor { GENERATED_BODY() virtual void OnConstruction(const FTransform& Transform) override; TreeStructure Tree; TArray<FTransform> TreeBranches; void PerformTransformation(TCHAR symbol); FVector TurtlePosition; FVector TurtleDirection; void Clear(); public: //Number of iterations UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystem) int Generations = 3; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = LSystem) FString EvolvedLSystem; //Letter for the first variable UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemVocabulary) FString FirstVariable = "X"; //Letter for the second variable UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemVocabulary) FString SecondVariable = "F"; //"Right" rotation UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemVocabulary) FString CWRotationSymbol = "+"; //"Left" rotation UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemVocabulary) FString CCWRotationSymbol = "-"; //New branch symbol UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemVocabulary) FString NewBranchSymbol = "["; //New branch symbol UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemVocabulary) FString EndBranchSymbol = "]"; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemRules) FString Start = "X"; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemRules) FString First_Rule = "F-[[X]+X]+F[+FX]-X"; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemRules) FString Second_Rule = "FF"; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemRules) bool FirstVariableRespondsForDrawing = false; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemRules) bool SecondVariableRespondsForDrawing = true; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemGraphics) float Angle = 25; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemGraphics) float Length = 40; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemGraphics) float InitialScale = 1.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LSystemGraphics) float ScaleStep = 0.2f; // Sets default values for this actor's properties ALSystemActor(); // Called when the game starts or when spawned virtual void BeginPlay() override; // Called every frame virtual void Tick(float DeltaSeconds) override; UFUNCTION(BlueprintCallable, Category = LSystem) void CreateTreeStructure(); //UFUNCTION(BlueprintCallable, Category = LSystem) UFUNCTION(BlueprintCallable, Category = LSystem) int GetNumberOfBranches(); UFUNCTION(BlueprintCallable, Category = LSystem) TArray<FVector> GetBranchCoordinates(int i); UFUNCTION(BlueprintCallable, Category = LSystem) float GetStartScale(int i); UFUNCTION(BlueprintCallable, Category = LSystem) float GetEndScale(int i); UFUNCTION(BlueprintCallable, Category = LSystem) FVector GetBranchDirection(int i); UFUNCTION(BlueprintCallable, Category = LSystem) void Init(); };
28.92437
80
0.754213
[ "transform" ]
40878c242a7e1c1669559592b13e0fead508aca6
582
h
C
enternamescreen.h
Ostrea/SDL-2D-Game
ba3ea027817901e2fa1fd60bddbb7464c163f7df
[ "MIT" ]
null
null
null
enternamescreen.h
Ostrea/SDL-2D-Game
ba3ea027817901e2fa1fd60bddbb7464c163f7df
[ "MIT" ]
1
2021-04-03T12:21:47.000Z
2021-06-05T16:19:28.000Z
enternamescreen.h
Ostrea/SDL-2D-Game
ba3ea027817901e2fa1fd60bddbb7464c163f7df
[ "MIT" ]
null
null
null
#ifndef ENTERNAMESCREEN_H #define ENTERNAMESCREEN_H #include "gamescreen.h" #include <vector> class EnterNameScreen : public GameScreen { public: EnterNameScreen(); virtual void loadContent(); virtual void unloadContent(); virtual void handleInput(const SDL_Event &event); virtual void draw(); private: unsigned long currentLength = 0ul; std::vector<Uint16> text; SDL_Surface *textSurface; SDL_Surface *promptSurface; SDL_Color textColor = {255, 255, 255}; SDL_Color nameColor = {0x9A, 0xCD, 0x32}; }; #endif // ENTERNAMESCREEN_H
20.068966
53
0.713058
[ "vector" ]
408b727a6537fedb0d4fe1fc869e9cf9ab037b93
668
h
C
Bango/Pages/Personal/Views/ZCPersonalOrderCell.h
LemonChao/Bango
5374051df57aa8d3e30d7c5e40b28562a8b8f489
[ "Apache-2.0" ]
null
null
null
Bango/Pages/Personal/Views/ZCPersonalOrderCell.h
LemonChao/Bango
5374051df57aa8d3e30d7c5e40b28562a8b8f489
[ "Apache-2.0" ]
null
null
null
Bango/Pages/Personal/Views/ZCPersonalOrderCell.h
LemonChao/Bango
5374051df57aa8d3e30d7c5e40b28562a8b8f489
[ "Apache-2.0" ]
null
null
null
// // ZCPersonalOrderCell.h // Bango // // Created by zchao on 2019/4/8. // Copyright © 2019 zchao. All rights reserved. // #import <UIKit/UIKit.h> #import "ZCPersonalCenterModel.h" NS_ASSUME_NONNULL_BEGIN @interface ZCPersonalOrderCell : UITableViewCell @property(nonatomic, strong) ZCPersonalCenterModel *model; @end @interface ZCBadgeButton : UIControl @property(nonatomic, strong) UIImage *image; @property(nonatomic, copy) NSString *title; @property(nullable, nonatomic, copy) NSString *badgeValue; // default is nil - (instancetype)initWithImage:(UIImage *)image title:(NSString *)title badge:(NSString *)badge; @end NS_ASSUME_NONNULL_END
18.054054
95
0.75
[ "model" ]
7b3a5ac47ca378307c2b2ec65c89b19c46872541
1,933
h
C
Gems/StartingPointCamera/Code/Include/StartingPointCamera/StartingPointCameraConstants.h
aaarsene/o3de
37e3b0226958974defd14dd6d808e8557dcd7345
[ "Apache-2.0", "MIT" ]
1
2021-09-13T00:01:12.000Z
2021-09-13T00:01:12.000Z
Gems/StartingPointCamera/Code/Include/StartingPointCamera/StartingPointCameraConstants.h
aaarsene/o3de
37e3b0226958974defd14dd6d808e8557dcd7345
[ "Apache-2.0", "MIT" ]
null
null
null
Gems/StartingPointCamera/Code/Include/StartingPointCamera/StartingPointCameraConstants.h
aaarsene/o3de
37e3b0226958974defd14dd6d808e8557dcd7345
[ "Apache-2.0", "MIT" ]
1
2021-07-20T11:07:25.000Z
2021-07-20T11:07:25.000Z
/* * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once namespace Camera { ////////////////////////////////////////////////////////////////////////// /// Pass this as the second argument when constructing an AZ::Crc32 to force /// it to use the lower cased version of your string static const bool s_forceCrcLowerCase = true; ////////////////////////////////////////////////////////////////////////// /// These are intended to be used as an index and needs to be implicitly /// convertible to int. See StartingPointCameraUtilities.h for examples enum AxisOfRotation : int { X_Axis = 0, Y_Axis = 1, Z_Axis = 2 }; ////////////////////////////////////////////////////////////////////////// /// These are intended to be used as an index and needs to be implicitly /// convertible to int. See StartingPointCameraUtilities.h for examples enum VectorComponentType : int { X_Component = 0, Y_Component = 1, Z_Component = 2, None = 3, }; ////////////////////////////////////////////////////////////////////////// /// These are intended to be used as an index and needs to be implicitly /// convertible to int. See StartingPointCameraUtilities.h for examples enum RelativeAxisType : int { LeftRight = 0, ForwardBackward = 1, UpDown = 2, }; ////////////////////////////////////////////////////////////////////////// /// These are intended to be used as an index and needs to be implicitly /// convertible to int. See StartingPointCameraUtilities.h for examples enum EulerAngleType : int { Pitch = 0, Roll = 1, Yaw = 2, }; } //namespace Camera
33.912281
158
0.514227
[ "3d" ]
7b4bd418613e836fff160dd388dd59c02fa13758
2,509
c
C
base/crts/crtw32/exec/spawnv.c
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
base/crts/crtw32/exec/spawnv.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
base/crts/crtw32/exec/spawnv.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*** *spawnv.c - spawn a child process * * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved. * *Purpose: * defines _spawnv() - spawn a child process * *Revision History: * 04-15-84 DFW written * 12-11-87 JCR Added "_LOAD_DS" to declaration * 11-20-89 GJF Fixed copyright, alignment. Added const to arg types * for pathname and argv. * 03-08-90 GJF Replace _LOAD_DS with _CALLTYPE1 and added #include * <cruntime.h>. * 07-24-90 SBM Removed redundant includes, replaced <assertm.h> by * <assert.h> * 09-27-90 GJF New-style function declarator. * 01-17-91 GJF ANSI naming. * 02-14-90 SRW Use NULL instead of _environ to get default. * 04-06-93 SKS Replace _CRTAPI* with __cdecl * 12-07-93 CFW Wide char enable. * 02-06-95 CFW assert -> _ASSERTE. * 02-06-98 GJF Changes for Win64: changed return type to intptr_t. * *******************************************************************************/ #include <cruntime.h> #include <stdlib.h> #include <process.h> #include <tchar.h> #include <dbgint.h> /*** *int _spawnv(modeflag, pathname, argv) - spawn a child process * *Purpose: * Spawns a child process. * formats the parameters and calls _spawnve to do the actual work. The * NULL environment pointer indicates that the new process will inherit * the parents process's environment. NOTE - at least one argument must * be present. This argument is always, by convention, the name of the * file being spawned. * *Entry: * int modeflag - mode to spawn (WAIT, NOWAIT, or OVERLAY) * only WAIT and OVERLAY currently implemented * _TSCHAR *pathname - file to spawn * _TSCHAR **argv - vector of arguments * *Exit: * returns exit code of child process * if fails, returns -1 * *Exceptions: * *******************************************************************************/ intptr_t __cdecl _tspawnv ( int modeflag, const _TSCHAR *pathname, const _TSCHAR * const *argv ) { _ASSERTE(pathname != NULL); _ASSERTE(*pathname != _T('\0')); _ASSERTE(argv != NULL); _ASSERTE(*argv != NULL); _ASSERTE(**argv != _T('\0')); return(_tspawnve(modeflag,pathname,argv,NULL)); }
34.369863
81
0.552411
[ "vector" ]
7b55f7b377561851c881fe9ca313f9a9c7374671
10,554
h
C
lib/plugins/x86/x86_obj.h
pwrapi/cray_pwrapi
e303a841a7fcc9217a144a48e44cca05990ae066
[ "BSD-3-Clause" ]
1
2018-05-03T23:01:27.000Z
2018-05-03T23:01:27.000Z
lib/plugins/x86/x86_obj.h
pwrapi/cray_pwrapi
e303a841a7fcc9217a144a48e44cca05990ae066
[ "BSD-3-Clause" ]
null
null
null
lib/plugins/x86/x86_obj.h
pwrapi/cray_pwrapi
e303a841a7fcc9217a144a48e44cca05990ae066
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2017-2018, Cray Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * This file contains the structure definitions and prototypes for internal * use of power objects and object hieararchies. */ #ifndef _X86_OBJ_H #define _X86_OBJ_H #include <cray-powerapi/types.h> #include "pwr_list.h" #include "object.h" //----------------------------------------------------------------------// // Common Types and Prototypes // //----------------------------------------------------------------------// #define MSR_PKG_POWER_SKU_UNIT 0x606 #define MSR_PKG_RAPL_PERF_STATUS 0x613 #define MSR_DDR_RAPL_PERF_STATUS 0x61b #ifdef USE_RDMSR #define RDMSR_COMMAND "rdmsr --processor %ld --c-language 0x%x" #endif #define MSR_FIELD_TIME_UNIT_MASK 0xf #define MSR_FIELD_TIME_UNIT_SHIFT 16 #define MSR_FIELD_PKG_THROTTLE_CNTR_MASK 0xffffffff #define MSR_FIELD_PKG_THROTTLE_CNTR_SHIFT 0 #define MSR_FIELD_DDR_THROTTLE_CNTR_MASK 0xffffffff #define MSR_FIELD_DDR_THROTTLE_CNTR_SHIFT 0 // The maximum number of time window multiples allowed for a time window // metadata setting. The time window will be based on a multiple of the time // between updates for the pm_counters values. #define MD_TIME_WINDOW_MULTIPLE_MAX 10 typedef struct x86_metadata_s { // Metadata to describe the frequency and time window that // pm_counters values are updated double pm_counters_update_rate; // pm_counters raw_scan_hz PWR_Time pm_counters_time_window; // time between updates in nsec // Hardware Thread cstate metadata pwr_list_uint64_t ht_cstate; // Hardware Thread frequency metadata // Used for all frequency related attributes. pwr_list_double_t ht_freq; // Hardware Thread governor metadata pwr_list_string_t ht_gov; // Node vendor data // Used for nodes and power planes. char *node_vendor_info; // Socket vendor data // Used for sockets, mems, cores, and hardware threads. char *socket_vendor_info; } x86_metadata_t; extern x86_metadata_t x86_metadata; int x86_get_time_unit(uint64_t ht_id, uint64_t *value, struct timespec *ts); int x86_find_rapl_id(uint64_t socket_id, uint64_t *rapl_pkg_id, uint64_t *rapl_mem_id); double x86_cpu_power_factor(void); int x86_get_power(const char *path, PWR_Time window, double *value, struct timespec *ts); int x86_get_throttled_time(int msr, uint64_t ht_id, uint64_t *value, struct timespec *ts); int x86_obj_get_meta(obj_t *obj, PWR_AttrName attr, PWR_MetaName meta, void *value); int x86_obj_get_meta_at_index(obj_t *obj, PWR_AttrName attr, unsigned int index, void *value, char *value_str); //----------------------------------------------------------------------// // Plugin Node Object Types and Prototypes // //----------------------------------------------------------------------// typedef struct { uint8_t dummy; } x86_node_t; int x86_new_node(node_t *node); void x86_del_node(node_t *node); // Attribute Functions int x86_node_get_power(node_t *node, double *value, struct timespec *ts); int x86_node_get_power_limit_max(node_t *node, double *value, struct timespec *ts); int x86_node_get_energy(node_t *node, double *value, struct timespec *ts); // Metadata Functions int x86_node_get_meta(node_t *node, PWR_AttrName attr, PWR_MetaName meta, void *value); int x86_node_set_meta(node_t *node, ipc_t *ipc, PWR_AttrName attr, PWR_MetaName meta, const void *value); int x86_node_get_meta_at_index(node_t *node, PWR_AttrName attr, unsigned int index, void *value, char *value_str); //----------------------------------------------------------------------// // Plugin Socket Object Types and Prototypes // //----------------------------------------------------------------------// typedef struct { uint64_t rapl_pkg_id; uint64_t temp_id; char *temp_input; char *temp_max; PWR_Time power_time_window_meta; } x86_socket_t; int x86_new_socket(socket_t *socket); void x86_del_socket(socket_t *socket); // Attribute Functions int x86_socket_get_power(socket_t *socket, double *value, struct timespec *ts); int x86_socket_get_power_limit_max(socket_t *socket, double *value, struct timespec *ts); int x86_socket_set_power_limit_max(socket_t *socket, ipc_t *ipc, const double *value); int x86_socket_get_energy(socket_t *socket, double *value, struct timespec *ts); int x86_socket_get_temp(socket_t *socket, double *value, struct timespec *ts); int x86_socket_get_throttled_time(socket_t *socket, uint64_t *value, struct timespec *ts); // Metadata Functions int x86_socket_get_meta(socket_t *socket, PWR_AttrName attr, PWR_MetaName meta, void *value); int x86_socket_set_meta(socket_t *socket, ipc_t *ipc, PWR_AttrName attr, PWR_MetaName meta, const void *value); int x86_socket_get_meta_at_index(socket_t *socket, PWR_AttrName attr, unsigned int index, void *value, char *value_str); //----------------------------------------------------------------------// // Plugin Memory Object Types and Prototypes // //----------------------------------------------------------------------// typedef struct { uint64_t rapl_pkg_id; uint64_t rapl_mem_id; PWR_Time power_time_window_meta; } x86_mem_t; int x86_new_mem(mem_t *mem); void x86_del_mem(mem_t *mem); // Attribute Functions int x86_mem_get_throttled_time(mem_t *mem, uint64_t *value, struct timespec *ts); int x86_mem_get_power(mem_t *mem, double *value, struct timespec *ts); int x86_mem_get_power_limit_max(mem_t *mem, double *value, struct timespec *ts); int x86_mem_set_power_limit_max(mem_t *mem, ipc_t *ipc, const double *value); int x86_mem_get_energy(mem_t *mem, double *value, struct timespec *ts); // Metadata Functions int x86_mem_get_meta(mem_t *mem, PWR_AttrName attr, PWR_MetaName meta, void *value); int x86_mem_set_meta(mem_t *mem, ipc_t *ipc, PWR_AttrName attr, PWR_MetaName meta, const void *value); int x86_mem_get_meta_at_index(mem_t *mem, PWR_AttrName attr, unsigned int index, void *value, char *value_str); //----------------------------------------------------------------------// // Plugin Power Plane Object Types and Prototypes // //----------------------------------------------------------------------// typedef struct { uint8_t dummy; } x86_pplane_t; int x86_new_pplane(pplane_t *pplane); void x86_del_pplane(pplane_t *pplane); // Attribute Functions int x86_pplane_get_power(pplane_t *pplane, double *value, struct timespec *ts); int x86_pplane_get_energy(pplane_t *pplane, double *value, struct timespec *ts); // Metadata Functions int x86_pplane_get_meta(pplane_t *pplane, PWR_AttrName attr, PWR_MetaName meta, void *value); int x86_pplane_set_meta(pplane_t *pplane, ipc_t *ipc, PWR_AttrName attr, PWR_MetaName meta, const void *value); int x86_pplane_get_meta_at_index(pplane_t *pplane, PWR_AttrName attr, unsigned int index, void *value, char *value_str); //----------------------------------------------------------------------// // Plugin Core Object Types and Prototypes // //----------------------------------------------------------------------// typedef struct { uint64_t temp_id; char *temp_input; char *temp_max; } x86_core_t; int x86_new_core(core_t *core); void x86_del_core(core_t *core); // Attribute Functions int x86_core_get_temp(core_t *core, double *value, struct timespec *ts); // Metadata Functions int x86_core_get_meta(core_t *core, PWR_AttrName attr, PWR_MetaName meta, void *value); int x86_core_set_meta(core_t *core, ipc_t *ipc, PWR_AttrName attr, PWR_MetaName meta, const void *value); int x86_core_get_meta_at_index(core_t *core, PWR_AttrName attr, unsigned int index, void *value, char *value_str); //----------------------------------------------------------------------// // Plugin Hardware Thread Object Types and Prototypes // //----------------------------------------------------------------------// typedef struct { uint8_t dummy; } x86_ht_t; int x86_new_ht(ht_t *ht); void x86_del_ht(ht_t *ht); // Attribute Functions int x86_ht_get_cstate_limit(ht_t *ht, uint64_t *value, struct timespec *ts); int x86_ht_set_cstate_limit(ht_t *ht, ipc_t *ipc, const uint64_t *value); int x86_ht_get_freq(ht_t *ht, double *value, struct timespec *ts); int x86_ht_get_freq_req(ht_t *ht, double *value, struct timespec *ts); int x86_ht_set_freq_req(ht_t *ht, ipc_t *ipc, const double *value); int x86_ht_get_freq_limit_min(ht_t *ht, double *value, struct timespec *ts); int x86_ht_set_freq_limit_min(ht_t *ht, ipc_t *ipc, const double *value); int x86_ht_get_freq_limit_max(ht_t *ht, double *value, struct timespec *ts); int x86_ht_set_freq_limit_max(ht_t *ht, ipc_t *ipc, const double *value); int x86_ht_get_governor(ht_t *ht, uint64_t *value, struct timespec *ts); int x86_ht_set_governor(ht_t *ht, ipc_t *ipc, const uint64_t *value); // Metadata Functions int x86_ht_get_meta(ht_t *ht, PWR_AttrName attr, PWR_MetaName meta, void *value); int x86_ht_set_meta(ht_t *ht, ipc_t *ipc, PWR_AttrName attr, PWR_MetaName meta, const void *value); int x86_ht_get_meta_at_index(ht_t *ht, PWR_AttrName attr, unsigned int index, void *value, char *value_str); #endif /* _X86_OBJ_H */
37.558719
80
0.703619
[ "object" ]
7b62a041d21dbe8bbc4ff7ad38eb1f1a436abd39
1,358
h
C
plugins/flurry/android/src/cpp/include/AndroidLuaLibFlurry.h
mikolajgucki/ae-engine
c4953feb74853b01b39b45b3bce23c10f6f74db0
[ "MIT" ]
1
2021-02-23T09:36:42.000Z
2021-02-23T09:36:42.000Z
plugins/flurry/android/src/cpp/include/AndroidLuaLibFlurry.h
mikolajgucki/ae-engine
c4953feb74853b01b39b45b3bce23c10f6f74db0
[ "MIT" ]
null
null
null
plugins/flurry/android/src/cpp/include/AndroidLuaLibFlurry.h
mikolajgucki/ae-engine
c4953feb74853b01b39b45b3bce23c10f6f74db0
[ "MIT" ]
null
null
null
#ifndef AE_ANDROID_LUA_LIB_FLURRY_H #define AE_ANDROID_LUA_LIB_FLURRY_H #include <jni.h> #include "LuaLibFlurry.h" namespace ae { namespace flurry { /** * \brief The Android implementation of the Flurry Lua library. */ class AndroidLuaLibFlurry:public LuaLibFlurry { /// The JNI environment. JNIEnv *env; /** */ void getJNIEnv(); /** * \brief Creates a Java map object from parameters. * \param parameters The parameters. * \return The Java object or zero on error. */ jobject createMap(std::map<std::string,std::string> &parameters); public: /** */ AndroidLuaLibFlurry():LuaLibFlurry(),env((JNIEnv *)0) { } /** */ virtual ~AndroidLuaLibFlurry() { } /** */ virtual void init(); /** */ virtual void logEvent(const std::string &eventId,bool timed); /** */ virtual void logEvent(const std::string &eventId, std::map<std::string,std::string> &parameters,bool timed); /** */ virtual void endTimedEvent(const std::string &eventId); /** */ virtual void endTimedEvent(const std::string &eventId, std::map<std::string,std::string> &parameters); }; } // namespace } // namespace #endif // AE_ANDROID_LUA_LIB_FLURRY_H
23.016949
70
0.587629
[ "object" ]
7b6ed18a741860f60242a3a7c8fbae62cdbdc85c
2,130
h
C
lexer/regexp/nfa.h
SketchAlgorithms/Lexer
1b0917de46e94d39117e70afb12ce1c467de0d69
[ "MIT" ]
null
null
null
lexer/regexp/nfa.h
SketchAlgorithms/Lexer
1b0917de46e94d39117e70afb12ce1c467de0d69
[ "MIT" ]
null
null
null
lexer/regexp/nfa.h
SketchAlgorithms/Lexer
1b0917de46e94d39117e70afb12ce1c467de0d69
[ "MIT" ]
null
null
null
#if !defined(NFA_H) #define NFA_H #include <vector> #include <memory> #include <set> #include "fa_state.h" class NFA { private: std::vector<std::shared_ptr<FAState>> states; std::shared_ptr<FAState> start; std::set<int> current; public: bool isAccepted; bool isRejected; explicit NFA() { } explicit NFA(std::vector<std::shared_ptr<FAState>> states) { setStates(states); } void setStates(std::vector<std::shared_ptr<FAState>> states) { if (states.size()) { this->states = states; resetCurrent(); } else { throw "Error"; } } void resetCurrent() { this->current = {0}; } auto getStates() { return states; } auto getStart() { return states.at(0); } auto getCurrent() { return current; } bool next(char c) { isRejected = true; isAccepted = false; std::set<int> next = {}; for (auto pos : current) { auto trans = states.at(pos)->transition(c, pos); next.insert(trans.begin(), trans.end()); } current = next; for (auto pos : current) { isRejected = false; if (states.at(pos)->isFinal) { isAccepted = true; break; } } return !isRejected; } bool etf(std::string input) { std::set<int> current = {0}; for (auto character : input) { std::set<int> next = {}; for (auto pos : current) { auto trans = states.at(pos)->transition(character, pos); next.insert(trans.begin(), trans.end()); } if (next.empty()) return false; current = next; } for (auto pos : current) { if (states.at(pos)->isFinal) { return true; } } return false; } }; #endif // NFA_H
19.189189
72
0.457746
[ "vector" ]
7b70686993f30f33ff02f9232d0478a36e522c97
3,206
h
C
src/libobus/src/obus_call.h
Parrot-Developers/obus
d7104526659a12cccc1799e88f96192d9b1b5345
[ "BSD-3-Clause" ]
null
null
null
src/libobus/src/obus_call.h
Parrot-Developers/obus
d7104526659a12cccc1799e88f96192d9b1b5345
[ "BSD-3-Clause" ]
1
2021-03-31T10:29:33.000Z
2021-03-31T10:29:33.000Z
src/libobus/src/obus_call.h
isabella232/obus
d7104526659a12cccc1799e88f96192d9b1b5345
[ "BSD-3-Clause" ]
1
2016-11-03T10:42:14.000Z
2016-11-03T10:42:14.000Z
/****************************************************************************** * libobus - linux interprocess objects synchronization protocol. * * @file obus_call.h * * @brief obus object call * * @author jean-baptiste.dubois@parrot.com * * Copyright (c) 2013 Parrot S.A. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Parrot Company nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL PARROT COMPANY BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ #ifndef _OBUS_CALL_H_ #define _OBUS_CALL_H_ struct obus_call { /* call node */ struct obus_node node; /* call method description */ const struct obus_method_desc *desc; /* call related object */ struct obus_object *obj; /* call handle */ obus_handle_t handle; /* peer which do the call */ struct obus_peer *peer; /* call status */ enum obus_call_status status; /* method call arguments */ struct obus_struct args; /* call ack handler */ obus_method_call_status_handler_cb_t cb; }; struct obus_call *obus_call_new(struct obus_object *obj, const struct obus_method_desc *desc, obus_method_call_status_handler_cb_t cb, const struct obus_struct *args); int obus_call_destroy(struct obus_call *call); struct obus_object *obus_call_get_object(struct obus_call *call); const struct obus_object_desc * obus_call_get_object_desc(const struct obus_call *call); int obus_call_encode(struct obus_call *call, struct obus_buffer *buf); struct obus_call *obus_call_decode(struct obus_bus *bus, struct obus_buffer *buf); void obus_call_log(struct obus_call *call, enum obus_log_level level); void obus_ack_log(struct obus_ack *ack, struct obus_call *call, enum obus_log_level level); void obus_call_ack_notify(struct obus_call *call, enum obus_call_status status); #endif /* _OBUS_CALL_H_ */
37.717647
80
0.72645
[ "object" ]
7b7f810e8d1f94de514c5efdf68d329badaf84dd
5,312
h
C
tests/request_mock.h
YuriyLisovskiy/oauth-service
b2ab60e1d32b2f198c074d7646ea4e76bdff6bf7
[ "MIT" ]
null
null
null
tests/request_mock.h
YuriyLisovskiy/oauth-service
b2ab60e1d32b2f198c074d7646ea4e76bdff6bf7
[ "MIT" ]
null
null
null
tests/request_mock.h
YuriyLisovskiy/oauth-service
b2ab60e1d32b2f198c074d7646ea4e76bdff6bf7
[ "MIT" ]
null
null
null
/* * Copyright (c) 2021 Yuriy Lisovskiy */ #pragma once #include <list> #include <string> #include <xalwart/http/interfaces.h> class HttpRequestMock : public xw::http::IRequest { public: [[nodiscard]] inline std::string method() const override { return this->_method; } [[nodiscard]] inline const xw::http::URL& url() const override { return this->_url; } [[nodiscard]] inline Proto proto() const override { return this->_proto; } [[nodiscard]] inline const std::map<std::string, std::string>& headers() const override { return this->_headers; } [[nodiscard]] inline std::string user_agent() const override { return this->_user_agent; } [[nodiscard]] inline bool has_header(const std::string& key) const override { return this->_headers.contains(key); } [[nodiscard]] inline std::string get_header(const std::string& key, const std::string& default_value) const override { return this->_headers.contains(key) ? this->_headers.at(key) : default_value; } inline void set_header(const std::string& key, const std::string& value) override { this->_headers[key] = value; } [[nodiscard]] inline bool is_json() const override { return this->_is_json; } [[nodiscard]] inline std::vector<xw::http::Cookie> cookies() const override { return this->_cookies; } [[nodiscard]] inline std::optional<xw::http::Cookie> cookie(const std::string& name) const override { auto cookie = std::find_if( this->_cookies.begin(), this->_cookies.end(), [name](const xw::http::Cookie& item) -> bool { return item.name() == name; } ); if (cookie != this->_cookies.end()) { return *cookie; } return {}; } [[nodiscard]] inline std::string referer() const override { return this->_referer; } inline const xw::http::Query& form() override { return this->_form; } inline const xw::http::mime::multipart::Form& multipart_form() override { return this->_multipart_form; } inline nlohmann::json json() override { return this->_json_data; } [[nodiscard]] inline std::string host() const override { return this->_host; } [[nodiscard]] inline ssize_t content_length() const override { return this->_content_length; } [[nodiscard]] inline const std::vector<std::string>& transfer_encoding() const override { return this->_transfer_encoding; } [[nodiscard]] inline const std::map<std::string, std::string>& environment() const override { return this->_environment; } [[nodiscard]] inline std::string scheme( const std::optional<xw::conf::Secure::Header>& secure_proxy_ssl_header ) const override { return this->_scheme; } inline std::string get_host( const std::optional<xw::conf::Secure::Header>& secure_proxy_ssl_header, bool use_x_forwarded_host, bool use_x_forwarded_port, bool debug, std::vector<std::string> allowed_hosts ) override { return this->_parameterized_host; } [[nodiscard]] inline bool is_secure(const std::optional<xw::conf::Secure::Header>& secure_proxy_ssl_header) const override { return this->_is_secure; } void set_method(std::string method) { this->_method = std::move(method); } void set_url(xw::http::URL url) { this->_url = std::move(url); } void set_proto(Proto proto) { this->_proto = std::move(proto); } void set_headers(std::map<std::string, std::string> headers) { this->_headers = std::move(headers); } void set_user_agent(std::string user_agent) { this->_user_agent = std::move(user_agent); } void set_is_json(bool value) { this->_is_json = value; } void set_cookies(std::vector<xw::http::Cookie> cookies) { this->_cookies = std::move(cookies); } void set_referer(std::string referer) { this->_referer = std::move(referer); } void set_form(xw::http::Query form) { this->_form = std::move(form); } void set_multipart_form(xw::http::mime::multipart::Form multipart_form) { this->_multipart_form = std::move(multipart_form); } void set_json(nlohmann::json data) { this->_json_data = std::move(data); } void set_host(std::string host) { this->_host = std::move(host); } void set_content_length(ssize_t content_length) { this->_content_length = content_length; } void set_transfer_encoding(std::vector<std::string> transfer_encoding) { this->_transfer_encoding = std::move(transfer_encoding); } void set_environment(std::map<std::string, std::string> environment) { this->_environment = std::move(environment); } void set_scheme(std::string scheme) { this->_scheme = std::move(scheme); } void set_parameterized_host(std::string parameterized_host) { this->_parameterized_host = std::move(parameterized_host); } void set_is_secure(bool value) { this->_is_secure = value; } private: std::string _method; xw::http::URL _url; Proto _proto; std::map<std::string, std::string> _headers; std::string _user_agent; bool _is_json; std::vector<xw::http::Cookie> _cookies; std::string _referer; xw::http::Query _form; xw::http::mime::multipart::Form _multipart_form; nlohmann::json _json_data = nullptr; std::string _host; ssize_t _content_length; std::vector<std::string> _transfer_encoding; std::map<std::string, std::string> _environment; std::string _scheme; std::string _parameterized_host; bool _is_secure; };
19.601476
109
0.69503
[ "vector" ]
7b854ed59d4a80edff4f044786aa6259b72f1790
5,106
h
C
admin/wmi/wbem/providers/snmpprovider/smir/include/helper.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
admin/wmi/wbem/providers/snmpprovider/smir/include/helper.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
admin/wmi/wbem/providers/snmpprovider/smir/include/helper.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
//*************************************************************************** // // File: // // Module: MS SNMP Provider // // Purpose: // // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved // //*************************************************************************** #ifndef _HELPER_H_ #define _HELPER_H_ /*helper classes */ class SmirClassFactoryHelper; extern SmirClassFactoryHelper *g_pClassFactoryHelper; HRESULT CopyBSTR(BSTR *pDst, BSTR *pSrc); void FormatProviderErrorMsg(char*,int,HRESULT); class CNotificationMapper { public: CNotificationMapper(){} ~CNotificationMapper(){} static STDMETHODIMP Map(CSmir *a_Smir,IWbemClassObject *pObj, enum NotificationMapperType type); private: //private copy constructors to prevent bcopy CNotificationMapper(CNotificationMapper&); const CNotificationMapper& operator=(CNotificationMapper &); }; class CXToClassAssociator { public: CXToClassAssociator(){} ~CXToClassAssociator(){} private: //private copy constructors to prevent bcopy CXToClassAssociator(CXToClassAssociator&); const CXToClassAssociator& operator=(CXToClassAssociator &); }; class CGroupToClassAssociator : public CXToClassAssociator { public: CGroupToClassAssociator(){} ~CGroupToClassAssociator(){} static STDMETHODIMP Associate(CSmir *a_Smir,BSTR szModule, BSTR szGroup, ISmirClassHandle *hClass); private: //private copy constructors to prevent bcopy CGroupToClassAssociator(CXToClassAssociator&); const CGroupToClassAssociator& operator=(CGroupToClassAssociator &); }; class CModuleToClassAssociator : public CXToClassAssociator { public: CModuleToClassAssociator(){} ~CModuleToClassAssociator(){} static STDMETHODIMP Associate(CSmir *a_Smir,BSTR szModule, ISmirClassHandle *hClass); private: //private copy constructors to prevent bcopy CModuleToClassAssociator(CXToClassAssociator&); const CModuleToClassAssociator& operator=(CModuleToClassAssociator &); }; class CModuleToNotificationClassAssociator : public CXToClassAssociator { public: CModuleToNotificationClassAssociator(){} ~CModuleToNotificationClassAssociator(){} static STDMETHODIMP Associate(CSmir *a_Smir,BSTR szModule, ISmirNotificationClassHandle *hClass); private: //private copy constructors to prevent bcopy CModuleToNotificationClassAssociator(CXToClassAssociator&); const CModuleToNotificationClassAssociator& operator=(CModuleToNotificationClassAssociator &); }; class CModuleToExtNotificationClassAssociator : public CXToClassAssociator { public: CModuleToExtNotificationClassAssociator(){} ~CModuleToExtNotificationClassAssociator(){} static STDMETHODIMP Associate(CSmir *a_Smir,BSTR szModule, ISmirExtNotificationClassHandle *hClass); private: //private copy constructors to prevent bcopy CModuleToExtNotificationClassAssociator(CXToClassAssociator&); const CModuleToExtNotificationClassAssociator& operator=(CModuleToExtNotificationClassAssociator &); }; class CSMIRToClassAssociator : public CXToClassAssociator { public: CSMIRToClassAssociator(){} ~CSMIRToClassAssociator(){} static STDMETHODIMP Associate(CSmir *a_Smir,ISmirClassHandle *hClass); private: //private copy constructors to prevent bcopy CSMIRToClassAssociator(CSMIRToClassAssociator&); const CSMIRToClassAssociator& operator=(CSMIRToClassAssociator &); }; class CSmirAccess { private: static STDMETHODIMP Connect ( CSmir *a_Smir , OUT IWbemServices **server, IN BSTR ObjectPath, IN BOOL relativeToSMIR ); public: enum eOpenType { eModule=1, eGroup }; //undefined constructor and destructor //so object should never be instantiated CSmirAccess(); virtual ~CSmirAccess(); static STDMETHODIMP Init(); static void ShutDown(); static STDMETHODIMP Open ( CSmir *a_Smir , IWbemServices **server, BSTR ObjectPath=NULL, BOOL relativeToSMIR = FALSE ); static STDMETHODIMP Open ( CSmir *a_Smir , IWbemServices **server, ISmirClassHandle *hClass, eOpenType eType=eGroup ); static STDMETHODIMP Open ( CSmir *a_Smir , IWbemServices **server, ISmirGroupHandle *hGroup, eOpenType eType=eGroup ); static STDMETHODIMP Open ( CSmir *a_Smir , IWbemServices **server, ISmirModHandle *hMod ); static STDMETHODIMP GetContext ( CSmir *a_Smir , IWbemContext **a_Context ) ; }; class SmirClassFactoryHelper { private: CGroupHandleClassFactory *pGroupHandleClassFactory; CClassHandleClassFactory *pClassHandleClassFactory; CNotificationClassHandleClassFactory *pNotificationClassHandleClassFactory; CExtNotificationClassHandleClassFactory *pExtNotificationClassHandleClassFactory; CModHandleClassFactory *pModHandleClassFactory; CSMIRClassFactory *pSMIRClassFactory; public: SmirClassFactoryHelper(); virtual ~SmirClassFactoryHelper(); HRESULT CreateInstance(REFCLSID rclsid, REFIID riid, LPVOID * ppv); }; #endif
23.104072
102
0.733451
[ "object" ]
7b8d9b6ffc5e07d2adcac21dadd7fd554b8d12ef
4,685
h
C
talk/session/phone/call.h
udit043/libjingle
dd7c03d0c5c358ada97feae44a5f76acad8dca13
[ "BSD-3-Clause" ]
5
2015-09-16T06:10:59.000Z
2019-12-25T05:30:00.000Z
talk/session/phone/call.h
udit043/libjingle
dd7c03d0c5c358ada97feae44a5f76acad8dca13
[ "BSD-3-Clause" ]
null
null
null
talk/session/phone/call.h
udit043/libjingle
dd7c03d0c5c358ada97feae44a5f76acad8dca13
[ "BSD-3-Clause" ]
3
2015-08-01T11:38:08.000Z
2019-11-01T05:16:09.000Z
/* * libjingle * Copyright 2004--2005, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _CALL_H_ #define _CALL_H_ #include "talk/base/messagequeue.h" #include "talk/p2p/base/session.h" #include "talk/p2p/client/socketmonitor.h" #include "talk/xmpp/jid.h" #include "talk/session/phone/phonesessionclient.h" #include "talk/session/phone/voicechannel.h" #include "talk/session/phone/audiomonitor.h" #include <map> #include <vector> #include <deque> namespace cricket { class PhoneSessionClient; class Call : public talk_base::MessageHandler, public sigslot::has_slots<> { public: Call(PhoneSessionClient *session_client); ~Call(); Session *InitiateSession(const buzz::Jid &jid, std::vector<buzz::XmlElement*>* extra_xml); void AcceptSession(Session *session); void RedirectSession(Session *session, const buzz::Jid &to); void RejectSession(Session *session); void TerminateSession(Session *session); void Terminate(); void StartConnectionMonitor(Session *session, int cms); void StopConnectionMonitor(Session *session); void StartAudioMonitor(Session *session, int cms); void StopAudioMonitor(Session *session); void Mute(bool mute); const std::vector<Session *> &sessions(); uint32 id(); bool muted() const { return muted_; } // Setting this to false will cause the call to have a longer timeout and // for the SignalSetupToCallVoicemail to never fire. void set_send_to_voicemail(bool send_to_voicemail) { send_to_voicemail_ = send_to_voicemail; } bool send_to_voicemail() { return send_to_voicemail_; } // Sets a flag on the chatapp that will redirect the call to voicemail once // the call has been terminated sigslot::signal0<> SignalSetupToCallVoicemail; sigslot::signal2<Call *, Session *> SignalAddSession; sigslot::signal2<Call *, Session *> SignalRemoveSession; sigslot::signal3<Call *, Session *, Session::State> SignalSessionState; sigslot::signal3<Call *, Session *, Session::Error> SignalSessionError; sigslot::signal3<Call *, Session *, const std::string &> SignalReceivedTerminateReason; sigslot::signal3<Call *, Session *, const std::vector<ConnectionInfo> &> SignalConnectionMonitor; sigslot::signal3<Call *, Session *, const AudioInfo&> SignalAudioMonitor; sigslot::signal3<Call *, Session *, const MediaInfo&> SignalMediaMonitor; private: void OnMessage(talk_base::Message *message); void OnSessionState(Session *session, Session::State state); void OnSessionError(Session *session, Session::Error error); void OnReceivedTerminateReason(Session *session, const std::string &reason); void AddSession(Session *session); void RemoveSession(Session *session); void EnableChannels(bool enable); void Join(Call *call, bool enable); void OnConnectionMonitor(VoiceChannel *channel, const std::vector<ConnectionInfo> &infos); void OnAudioMonitor(VoiceChannel *channel, const AudioInfo& info); void OnMediaMonitor(VoiceChannel *channel, const MediaInfo& info); VoiceChannel* GetChannel(Session* session); uint32 id_; PhoneSessionClient *session_client_; std::vector<Session *> sessions_; std::map<SessionID, VoiceChannel *> channel_map_; bool muted_; bool send_to_voicemail_; friend class PhoneSessionClient; }; } #endif // _CALL_H_
40.042735
99
0.753255
[ "vector" ]
7b952fe58055ff60e7e7127a8faa6fa71ce9e3ca
17,260
h
C
src/main/include/Constants.h
ParadigmShift1259/FRC_Robot_2021
0ed3b2a7b6708ac23a0df1acada6c53d8af59b6a
[ "BSD-3-Clause" ]
null
null
null
src/main/include/Constants.h
ParadigmShift1259/FRC_Robot_2021
0ed3b2a7b6708ac23a0df1acada6c53d8af59b6a
[ "BSD-3-Clause" ]
null
null
null
src/main/include/Constants.h
ParadigmShift1259/FRC_Robot_2021
0ed3b2a7b6708ac23a0df1acada6c53d8af59b6a
[ "BSD-3-Clause" ]
null
null
null
/*----------------------------------------------------------------------------*/ /* Copyright (c) 2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ #pragma once #include <frc/geometry/Translation2d.h> #include <frc/kinematics/SwerveDriveKinematics.h> #include <frc/trajectory/TrapezoidProfile.h> #include <units/time.h> #include <units/velocity.h> #include <units/acceleration.h> #include <wpi/math> #include <ctre/phoenix/CANifier.h> using namespace ctre::phoenix; // Uncomment this to use Mk2 swerve drive instead of Mk3 swerve drive //#define Mk2 #define DualJoysticks /** * The Constants header provides a convenient place for teams to hold robot-wide * numerical or bool constants. This should not be used for any other purpose. * * It is generally a good idea to place constants into subsystem- or * command-specific namespaces within this header, which can then be used where * they are needed. */ namespace Math { constexpr double kTau = 2.0 * wpi::math::pi; } namespace DriveConstants { constexpr int kNumSwerveModules = 4; /// \name CAN bus IDs ///@{ /// CAN IDs for swerve modules constexpr int kCanifierID = 0; //!< CANifier CAN ID (for absolute encoder PWM inputs) constexpr int kFrontLeftDriveMotorPort = 1; //!< Front Left Drive CAN ID (TalonFX) constexpr int kFrontLeftTurningMotorPort = 2; //!< Front Left Turn CAN ID (SparkMAX) constexpr int kFrontRightDriveMotorPort = 3; //!< Front Right Drive CAN ID (TalonFX) constexpr int kFrontRightTurningMotorPort = 4; //!< Front Right Turn CAN ID (SparkMAX) constexpr int kRearRightDriveMotorPort = 5; //!< Rear Right Drive CAN ID (TalonFX) constexpr int kRearRightTurningMotorPort = 6; //!< Rear Right Turn CAN ID (SparkMAX) constexpr int kRearLeftDriveMotorPort = 7; //!< Rear Left Drive CAN ID (TalonFX) constexpr int kRearLeftTurningMotorPort = 8; //!< Rear Left Turn CAN ID (SparkMAX) ///@} /// \name Teleop Drive Constraints constexpr auto kDriveSpeed = units::meters_per_second_t(3.0); constexpr auto kDriveAngularSpeed = units::radians_per_second_t(wpi::math::pi); /// \name Canifier PWM channels ///@{ /// PWM channels for the canifier constexpr CANifier::PWMChannel kFrontLeftPWM = CANifier::PWMChannel::PWMChannel0; constexpr CANifier::PWMChannel kFrontRightPWM = CANifier::PWMChannel::PWMChannel2; constexpr CANifier::PWMChannel kRearRightPWM = CANifier::PWMChannel::PWMChannel1; constexpr CANifier::PWMChannel kRearLeftPWM = CANifier::PWMChannel::PWMChannel3; ///@} /// \name Roborio analog input channels ///@{ /// Roborio analog input channels for Mk2 absolute encoders constexpr int kFrontLeftTurningEncoderPort = 0; constexpr int kFrontRightTurningEncoderPort = 1; constexpr int kRearRightTurningEncoderPort = 2; constexpr int kRearLeftTurningEncoderPort = 3; ///@} /// \name Drive wheel reversal (inverting) flags ///@{ /// To keep the swerve module bevel gear facing inwards we need to reverse the right side #ifdef Mk2 constexpr bool kFrontLeftDriveMotorReversed = false; constexpr bool kRearLeftDriveMotorReversed = false; constexpr bool kFrontRightDriveMotorReversed = true; constexpr bool kRearRightDriveMotorReversed = true; #else constexpr bool kFrontLeftDriveMotorReversed = true; constexpr bool kRearLeftDriveMotorReversed = true; constexpr bool kFrontRightDriveMotorReversed = false; constexpr bool kRearRightDriveMotorReversed = false; #endif constexpr double kLeftMultipler = 1.21951; // 1.149425; ///@} constexpr bool kGyroReversed = false; // Process for reentering values: 0 all values out, line up with stick, all gears face inwards // Line up based on side, left or right // Record values, enter below, then redeploy // All gears should face outwards #ifdef Mk2 constexpr double kFrontLeftOffset = (6.28 - 3.14); //3.142; //6.412; //3.142; // 3.14; constexpr double kFrontRightOffset = (6.28 - 1.21); //5.105; //5.155 + 1.57; //5.105; // 5.07; //5.66; constexpr double kRearLeftOffset = (6.28 - 0.36); //5.963; //1.6292; //1.8292; //4.85; //1.42921; // 3.34; //4.29; constexpr double kRearRightOffset = (6.28 - 5.67); //0.665; //0.635 + 1.57; //0.665; // 0.63; //5.29; #else //Mk3 swerve module //============================================LEAVE THESE ZEROES COMMENTED OUT!!! // constexpr double kFrontLeftOffset = 0.0; // constexpr double kFrontRightOffset = 0.0; // constexpr double kRearRightOffset = 0.0; // constexpr double kRearLeftOffset = 0.0; //=============================================================================== constexpr double kFrontLeftOffset = 2689.0; //2670.0; //2710.0; //2695.0; constexpr double kFrontRightOffset = 205.0; //190.0; //201.0; //209.0; //195.0; constexpr double kRearRightOffset = 1858.0; //1865.0; //1876.0; //1861.0; //1829.0; constexpr double kRearLeftOffset = 983.0; //1013.0; //3317.0; //3175.0; //3085.0; //2823.0; //2692.0; //2717.0; //486.0; //234.0; //362.891; //147.0; #endif constexpr double kMaxAnalogVoltage = 4.93; //!< Absolute encoder runs 0 to 4.93V constexpr double kTurnVoltageToRadians = 2.0 * wpi::math::pi / kMaxAnalogVoltage; constexpr double KTurnVoltageToDegrees = 360 / kMaxAnalogVoltage; // Pulse Width per rotation is not equal for all encoders. Some are 0 - 3865, some are 0 - 4096 // FL: 4096 // FR: 3970 // RL: 4096 // RR: 3865 constexpr double kPulseWidthToZeroOne = 4096.0; // 4096 micro second pulse width is full circle constexpr double kPulseWidthToRadians = Math::kTau / kPulseWidthToZeroOne; /// \name Turn PID Controller for Swerve Modules ///@{ #ifdef Mk2 constexpr double kTurnP = 0.35; // 0.35 // 0.1 constexpr double kTurnI = 0; //1e-4; constexpr double kTurnD = 1.85; // 1.85 // 1 #else constexpr double kTurnP = 0.75; //0.35; //0.35; constexpr double kTurnI = 0.0; //1e-4; constexpr double kTurnD = 0.0; //1.1; // 1.85 #endif ///@} /// \name Turn PID Controller for Swerve Modules ///@{ constexpr double kDriveP = 0.1; constexpr double kDriveI = 0;//0.0000015; constexpr double kDriveD = 0; ///@} /// \name Robot Rotation PID Controller ///@{ /// Rotation PID Controller for Rotation Drive, converts between radians angle error to radians per second turn constexpr double kRotationP = 1; constexpr double kRotationI = 0; constexpr double kRotationIMaxRange = 0; constexpr double kRotationD = 0.025; /// Rotation PID Controller additional parameters /// Max speed for control constexpr double kMaxAbsoluteRotationSpeed = 3.5; /// Speeds higher than value will prevent robot from changing directions for a turn constexpr double kMaxAbsoluteTurnableSpeed = 3; /// Maximum tolerance for turning constexpr double kAbsoluteRotationTolerance = 0.07; ///@} constexpr double kMinTurnPrioritySpeed = 0.4; } // namespace DriveConstants namespace ModuleConstants { #ifdef Mk2 constexpr int kEncoderCPR = 1024; #else constexpr int kEncoderCPR = 2048; #endif constexpr int kEncoderTicksPerSec = 10; //!< TalonFX::GetSelectedSensorVelocity() returns ticks/100ms = 10 ticks/sec constexpr double kWheelDiameterMeters = .1016; //!< 4" #ifdef Mk2 constexpr double kDriveGearRatio = 8.31; //!< MK2 swerve modules 11.9 ft/sec constexpr double kTurnMotorRevsPerWheelRev = 18.0; // 12.8 Mk3 constexpr double kDriveEncoderDistancePerPulse = (kWheelDiameterMeters * wpi::math::pi) / static_cast<double>(kEncoderCPR); #else constexpr double kDriveGearRatio = 8.16; //!< MK3 swerve modules w/NEOs 12.1 ft/sec w/Falcon 13.6 ft/sec constexpr double kTurnMotorRevsPerWheelRev = 12.8; /// Assumes the encoders are directly mounted on the wheel shafts // ticks / 100 ms -> ticks / s -> motor rev / s -> wheel rev / s -> m / s constexpr double kDriveEncoderMetersPerSec = kEncoderTicksPerSec / static_cast<double>(kEncoderCPR) / kDriveGearRatio * (kWheelDiameterMeters * wpi::math::pi); #endif constexpr double kTurnEncoderCPR = 4096.0 / kTurnMotorRevsPerWheelRev; // Mag encoder relative output to SparkMax #ifdef Mk2 constexpr double kP_ModuleTurningController = 1.1; #else constexpr double kP_ModuleTurningController = 1.1; #endif constexpr double kD_ModuleTurningController = 0.03; constexpr double kPModuleDriveController = 0.001; constexpr uint kMotorCurrentLimit = 30; } // namespace ModuleConstants namespace AutoConstants { using radians_per_second_squared_t = units::compound_unit<units::radians, units::inverse<units::squared<units::second>>>; constexpr auto kMaxSpeed = units::meters_per_second_t(3.75); // 1.0 // 5.0 constexpr auto kMaxAcceleration = units::meters_per_second_squared_t(4.5); // 0.1 constexpr auto kMaxAngularSpeed = units::radians_per_second_t(wpi::math::pi * 6.0); constexpr auto kMaxAngularAcceleration = units::unit_t<radians_per_second_squared_t>(wpi::math::pi * 6.0); constexpr auto kTeleMaxAngularSpeed = units::radians_per_second_t(wpi::math::pi * 2.0); #ifdef Mk2 constexpr double kPXController = 2.0; // 0.25 constexpr double kPYController = 2.0; // 0.25 constexpr double kPThetaController = 4.0; // 2.0 #else constexpr double kPXController = 7.0; constexpr double kDXController = 0.7; constexpr double kPYController = 7.0; constexpr double kDYController = 0.7; constexpr double kPThetaController = 10.0; constexpr double kDThetaController = 0.9; #endif extern const frc::TrapezoidProfile<units::radians>::Constraints kThetaControllerConstraints; } // namespace AutoConstants namespace OIConstants { constexpr double kDeadzoneX = 0.015; constexpr double kDeadzoneY = 0.015; constexpr double kDeadzoneXY = 0.08; constexpr double kDeadzoneRot = 0.10; constexpr double kDeadzoneAbsRot = 0.50; constexpr int kPrimaryControllerPort = 0; #ifdef DualJoysticks constexpr int kSecondaryControllerPort = 1; #else constexpr int kSecondaryControllerPort = 0; #endif } // namespace OIConstants // Intake Subsystem constants namespace IntakeConstants { constexpr double kMotorPort = 9; // Intake rollers PWM channel (Spark) constexpr double kMotorReverseConstant = 1; constexpr double kIngestLow = 0.3; constexpr double kIngestHigh = 0.80; constexpr double kReleaseLow = -0.3; constexpr double kReleaseHigh = -0.70; } // Flywheel Subsystem constants namespace FlywheelConstants { constexpr double kMotorPort = 20; //!< Flywheel CAN ID (SparkMAX) constexpr double kRampRate = 1.0; // Total error allowed for the flywheel, in RPM constexpr double kAllowedError = 75;//65; constexpr double kMaintainPIDError = 300; // General multiplier added, adjusts for ball conditions and general firing constexpr double kHomingRPMMultiplier = 1.0175; constexpr double kIdleHomingRPMMultiplier = 1.01; // Additional multiplier applied to flywheel speed while firing // Ensures all ball trajectories are straight constexpr double kFiringRPMMultiplier = 1.01; //TEMP 1.015; //2; //1.035; //1.05; // Launch PID values, used to first get to setpoint constexpr double kP = 0.0002900; constexpr double kI = 0; constexpr double kD = 0; // Maintain PID values, used to adjust for error once the robot is shooting constexpr double kMP = 0.002000;//0.001700; constexpr double kMI = 0.00000001; constexpr double kMD = 0.000001; constexpr double kMinOut = 0; constexpr double kMaxOut = 1.0; constexpr double kS = 0.059; constexpr double kV = 0.102834; constexpr double kA = 0;//0.0399; // Diameter is in meters constexpr double kWheelDiameter = 0.1524; constexpr double kSecondsPerMinute = 60; constexpr double kWheelMetersPerRev = kWheelDiameter * wpi::math::pi; // Meters per second to Revolutions per minute constexpr double kMPSPerRPM = kWheelMetersPerRev / kSecondsPerMinute; constexpr double kWheelRevPerMotorRev = 1.25; /// Use MPSPerRPM to determine the ramp rates, current values are just placeholders constexpr double kIdleRPM = 2950; //0; /// The fixed RPM to fire at the trench given very heavy defense constexpr double kTrenchRPM = 3400; } // Turret Subsystem Constants namespace TurretConstants { constexpr double kMotorPort = 11; //!< Turret CAN ID (TalonSRX) constexpr double kP = 0.30114; constexpr double kI = 0.00035; constexpr double kD = 19.6; constexpr double kMinOut = 0; constexpr double kMaxOut = 0.700; constexpr double kTimeout = 30; constexpr double kInverted = true; constexpr double kSensorPhase = true; constexpr double kMaxOverrideAngle = 5.0; //10.0; constexpr double kDegreeStopRange = 0.85; //1; //1.35; //0.6; //0.4; //0.5; constexpr double kDegreePIDStopRange = 0.25; //0.35; //0.35; constexpr double kPulley = 2.7305; constexpr double kSpinner = 29.845; // The motor on the turret drives a pulley, while drives the turret // MotorRev indicates the revolution of the motor, while Rev indicates the revolution of the turret constexpr double kMotorRevPerRev = kPulley / kSpinner; constexpr double kTicksPerRev = 4096.0; constexpr double kDegreesPerRev = 360.0; constexpr double kRadiansPerRev = wpi::math::pi * 2.0; // Offset of origin point of turret angle and robot angle, in degrees. Robot 0 is forward constexpr double kTurretToRobotAngleOffset = -45; // Maximum rotation of the turret relative to the turret, in degrees constexpr double kMinAngle = 0; constexpr double kMaxAngle = 90; // Range of angle allowed for auto targeting by default constexpr double kMinAutoAngle = 25; constexpr double kMaxAutoAngle = 65; // Maximum relative angle allowed for auto targeting by default constexpr double kMaxAutoRelAngle = 20; // initial configured angle of the turret relative to the turret, in degrees constexpr double kStartingPositionDegrees = 45; } /// Hood subsystem constants namespace HoodConstants { /// PWM Port for hood servo constexpr int kPWMPort = 8; //!< Hood servo PWM channel constexpr double kTestServoSpeed = 0.14; // Drives from Max to Min, where hood is smallest at 0.85, and greatest at 0.0485 constexpr double kMax = .95; constexpr double kMin = .20; /// The fixed hood to fire in the trench given very heavy defense constexpr double kTrenchPosition = 0.223; } // Cycler Subsystem Constants namespace CyclerConstants { constexpr double kFeederPort = 30; //!< Feeder CAN ID (SparkMAX) constexpr double kTurnTablePort = 31; //!< Turn table CAN ID (TalonSRX) constexpr double kFeederSpeed = 0.4; //TEMP0.350; constexpr double kTurnTableSpeed = 0.55; //6; //TEMP0.400; constexpr double kTurnTableSpeedHigher = 0.550; constexpr double kTurnTableHoneSpeed = 0.300; constexpr units::second_t kMaxCyclerTime = 5.0_s; constexpr double kSensorInvert = true; // Time to go from 0 to full throttle constexpr double kTurnTableRampRate = 0.75; constexpr double kTimePassed = 0.25; constexpr double kTimeLaunch = 4.00; constexpr double kTimeout = 30; constexpr double kTurnTableInverted = false; constexpr double kFeederInverted = true; } // Vision Subsystem Constants namespace VisionConstants { // 6/30/21 // Limelight X Offset: -0.04 // Mounting angle of the limelight, in degrees constexpr double kMountingAngle = 25.0; // Permanent X adjustment -0.05 // Mounting height of the limelight from the ground, in inches constexpr double kMountingHeight = 22; // Target center height, in inches // 6/30/21 Changed: Target bottom now instead for consistent tracking in worse conditions constexpr double kTargetHeight = 81.25; //98.25; constexpr double kMinTargetDistance = 70; constexpr double kMaxTargetDistance = 380; constexpr double kMinHoneDistance = 130; constexpr double kMaxHoneDistance = 260; } // Climber Subsystem constants namespace ClimberConstants { constexpr double kMotorPort = 7; // Climber CAN ID (TalonSRX? not installed) constexpr double kMotorReverseConstant = -1; constexpr double kMotorSpeed = 0.9; }
39.861432
163
0.675319
[ "geometry" ]
7b97888f1caaee4698df7ac139a6a4d695900905
471
h
C
src/machine/namco05.h
ascottix/tickle
de3b7df8a6e719b7682398ac689a7e439b40876f
[ "MIT" ]
1
2021-05-31T21:09:50.000Z
2021-05-31T21:09:50.000Z
src/machine/namco05.h
ascottix/tickle
de3b7df8a6e719b7682398ac689a7e439b40876f
[ "MIT" ]
null
null
null
src/machine/namco05.h
ascottix/tickle
de3b7df8a6e719b7682398ac689a7e439b40876f
[ "MIT" ]
null
null
null
/* Namco 05xx (starfield generator) custom chip emulator Copyright (c) 2011 Alessandro Scotti */ #ifndef NAMCO_05XX_ #define NAMCO_05XX_ #include <emu/emu_bitmap.h> struct Namco05xx { unsigned char state_; int scroll_x_; int scroll_y_; Namco05xx(); void reset(); void writeRegister( unsigned index, unsigned char value ); void update(); void render( TBitmapIndexed * screen ); }; #endif // NAMCO_05XX_
16.821429
62
0.653928
[ "render" ]
7b9f3fe6a0c0096d8efec121b52f55e185d7d5da
3,332
h
C
include/helpers/usuarios/setup.h
guilhermebkel/sales-machine
f0c0e12b543733bb7edf0a49e686331686e476e8
[ "MIT" ]
null
null
null
include/helpers/usuarios/setup.h
guilhermebkel/sales-machine
f0c0e12b543733bb7edf0a49e686331686e476e8
[ "MIT" ]
null
null
null
include/helpers/usuarios/setup.h
guilhermebkel/sales-machine
f0c0e12b543733bb7edf0a49e686331686e476e8
[ "MIT" ]
null
null
null
#include <iostream> #include <fstream> #include <vector> #include "usuarios/usuario.h" #include "usuarios/crianca.h" #include "usuarios/adulto.h" #include "usuarios/idoso.h" std::vector<Usuario*> setup_usuarios(){ std::ifstream usuariosDatabase("database/usuarios.csv"); std::string usuarioId, usuarioTipo, usuarioNome, usuarioIdade, usuarioSaldo, usuarioResponsavel_id; std::vector<Crianca*> usuarioDependentes; Adulto* usuarioResponsavel; std::vector<Usuario*> usuarios; while(usuariosDatabase.good()){ std::getline(usuariosDatabase, usuarioId, ','); std::getline(usuariosDatabase, usuarioTipo, ','); std::getline(usuariosDatabase, usuarioNome, ','); std::getline(usuariosDatabase, usuarioIdade, ','); // Verifica o tipo da linha atual // para decidir quando ler o último termo como '\n' // visto que a forma de leitura de criancas e adultos é diferente if(!usuarioTipo.compare("adulto")){ std::getline(usuariosDatabase, usuarioSaldo, '\n'); usuarios.push_back(new Adulto(std::stoi(usuarioId), usuarioNome, std::stoi(usuarioIdade), std::stof(usuarioSaldo))); } else if(!usuarioTipo.compare("idoso")){ std::getline(usuariosDatabase, usuarioSaldo, '\n'); usuarios.push_back(new Idoso(std::stoi(usuarioId), usuarioNome, std::stoi(usuarioIdade), std::stof(usuarioSaldo))); } else if(!usuarioTipo.compare("crianca")){ std::getline(usuariosDatabase, usuarioSaldo, ','); std::getline(usuariosDatabase, usuarioResponsavel_id, '\n'); // Associa o adulto respoonsavel com seu filho. for(Usuario* usuario : usuarios){ Adulto* adulto = dynamic_cast<Adulto*>(usuario); Idoso* idoso = dynamic_cast<Idoso*>(usuario); // Caso for adulto if(adulto != nullptr && adulto->get_id() == std::stoi(usuarioResponsavel_id)){ usuarioResponsavel = adulto; break; } // Caso for idoso else if(idoso != nullptr && idoso->get_id() == std::stoi(usuarioResponsavel_id)){ usuarioResponsavel = idoso; break; } } usuarios.push_back(new Crianca(std::stoi(usuarioId), usuarioNome, std::stoi(usuarioIdade), std::stof(usuarioSaldo), usuarioResponsavel)); } usuarioResponsavel = nullptr; } usuariosDatabase.close(); // Faz as associações dos dependentes de cada adulto for(Usuario* usuario : usuarios){ Adulto* adulto = dynamic_cast<Adulto*>(usuario); Idoso* idoso = dynamic_cast<Idoso*>(usuario); for(Usuario* usuario : usuarios){ Crianca* crianca = dynamic_cast<Crianca*>(usuario); // Caso for adulto + crianca if(adulto != nullptr && crianca != nullptr && adulto->get_id() == crianca->get_responsavel()->get_id()){ usuarioDependentes.push_back(crianca); } // Caso for idoso + crianca else if(idoso != nullptr && crianca != nullptr && idoso->get_id() == crianca->get_responsavel()->get_id()){ usuarioDependentes.push_back(crianca); } } // Caso for adulto if(usuarioDependentes.size() && adulto != nullptr){ adulto->set_dependentes(usuarioDependentes); usuarioDependentes.clear(); } // Caso for idoso else if(usuarioDependentes.size() && idoso != nullptr){ idoso->set_dependentes(usuarioDependentes); usuarioDependentes.clear(); } } return usuarios; } void deallocate_usuarios(std::vector<Usuario*> usuarios){ for (Usuario *usuario : usuarios){ delete usuario; } }
32.666667
140
0.704382
[ "vector" ]
7baa8aaae74e6ea90eccdaf13c6ec3253277a887
6,445
h
C
aten/src/ATen/test/rng_test.h
Hacky-DH/pytorch
80dc4be615854570aa39a7e36495897d8a040ecc
[ "Intel" ]
60,067
2017-01-18T17:21:31.000Z
2022-03-31T21:37:45.000Z
aten/src/ATen/test/rng_test.h
Hacky-DH/pytorch
80dc4be615854570aa39a7e36495897d8a040ecc
[ "Intel" ]
66,955
2017-01-18T17:21:38.000Z
2022-03-31T23:56:11.000Z
aten/src/ATen/test/rng_test.h
Hacky-DH/pytorch
80dc4be615854570aa39a7e36495897d8a040ecc
[ "Intel" ]
19,210
2017-01-18T17:45:04.000Z
2022-03-31T23:51:56.000Z
#include <gtest/gtest.h> #include <ATen/Generator.h> #include <ATen/Tensor.h> #include <ATen/native/TensorIterator.h> #include <torch/library.h> #include <c10/util/Optional.h> #include <torch/all.h> #include <stdexcept> namespace { constexpr auto int64_min_val = std::numeric_limits<int64_t>::lowest(); constexpr auto int64_max_val = std::numeric_limits<int64_t>::max(); template <typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0> constexpr int64_t _min_val() { return int64_min_val; } template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> constexpr int64_t _min_val() { return static_cast<int64_t>(std::numeric_limits<T>::lowest()); } template <typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0> constexpr int64_t _min_from() { return -(static_cast<int64_t>(1) << std::numeric_limits<T>::digits); } template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> constexpr int64_t _min_from() { return _min_val<T>(); } template <typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0> constexpr int64_t _max_val() { return int64_max_val; } template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> constexpr int64_t _max_val() { return static_cast<int64_t>(std::numeric_limits<T>::max()); } template <typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0> constexpr int64_t _max_to() { return static_cast<int64_t>(1) << std::numeric_limits<T>::digits; } template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> constexpr int64_t _max_to() { return _max_val<T>(); } template<typename RNG, c10::ScalarType S, typename T> void test_random_from_to(const at::Device& device) { constexpr int64_t min_val = _min_val<T>(); constexpr int64_t min_from = _min_from<T>(); constexpr int64_t max_val = _max_val<T>(); constexpr int64_t max_to = _max_to<T>(); constexpr auto uint64_max_val = std::numeric_limits<uint64_t>::max(); std::vector<int64_t> froms; std::vector<c10::optional<int64_t>> tos; if (std::is_same<T, bool>::value) { froms = { 0L }; tos = { 1L, static_cast<c10::optional<int64_t>>(c10::nullopt) }; } else if (std::is_signed<T>::value) { froms = { min_from, -42L, 0L, 42L }; tos = { c10::optional<int64_t>(-42L), c10::optional<int64_t>(0L), c10::optional<int64_t>(42L), c10::optional<int64_t>(max_to), static_cast<c10::optional<int64_t>>(c10::nullopt) }; } else { froms = { 0L, 42L }; tos = { c10::optional<int64_t>(42L), c10::optional<int64_t>(max_to), static_cast<c10::optional<int64_t>>(c10::nullopt) }; } const std::vector<uint64_t> vals = { 0L, 42L, static_cast<uint64_t>(max_val), static_cast<uint64_t>(max_val) + 1, uint64_max_val }; bool full_64_bit_range_case_covered = false; bool from_to_case_covered = false; bool from_case_covered = false; for (const int64_t from : froms) { for (const c10::optional<int64_t> to : tos) { if (!to.has_value() || from < *to) { for (const uint64_t val : vals) { auto gen = at::make_generator<RNG>(val); auto actual = torch::empty({3, 3}, torch::TensorOptions().dtype(S).device(device)); actual.random_(from, to, gen); T exp; uint64_t range; if (!to.has_value() && from == int64_min_val) { exp = static_cast<int64_t>(val); full_64_bit_range_case_covered = true; } else { if (to.has_value()) { range = static_cast<uint64_t>(*to) - static_cast<uint64_t>(from); from_to_case_covered = true; } else { range = static_cast<uint64_t>(max_to) - static_cast<uint64_t>(from) + 1; from_case_covered = true; } if (range < (1ULL << 32)) { exp = static_cast<T>(static_cast<int64_t>((static_cast<uint32_t>(val) % range + from))); } else { exp = static_cast<T>(static_cast<int64_t>((val % range + from))); } } ASSERT_TRUE(from <= exp); if (to.has_value()) { ASSERT_TRUE(static_cast<int64_t>(exp) < *to); } const auto expected = torch::full_like(actual, exp); if (std::is_same<T, bool>::value) { ASSERT_TRUE(torch::allclose(actual.toType(torch::kInt), expected.toType(torch::kInt))); } else { ASSERT_TRUE(torch::allclose(actual, expected)); } } } } } if (std::is_same<T, int64_t>::value) { ASSERT_TRUE(full_64_bit_range_case_covered); } ASSERT_TRUE(from_to_case_covered); ASSERT_TRUE(from_case_covered); } template<typename RNG, c10::ScalarType S, typename T> void test_random(const at::Device& device) { const auto max_val = _max_val<T>(); const auto uint64_max_val = std::numeric_limits<uint64_t>::max(); const std::vector<uint64_t> vals = { 0L, 42L, static_cast<uint64_t>(max_val), static_cast<uint64_t>(max_val) + 1, uint64_max_val }; for (const uint64_t val : vals) { auto gen = at::make_generator<RNG>(val); auto actual = torch::empty({3, 3}, torch::TensorOptions().dtype(S).device(device)); actual.random_(gen); uint64_t range; if (std::is_floating_point<T>::value) { range = static_cast<uint64_t>((1ULL << std::numeric_limits<T>::digits) + 1); } else if (std::is_same<T, bool>::value) { range = 2; } else { range = static_cast<uint64_t>(std::numeric_limits<T>::max()) + 1; } T exp; if (std::is_same<T, double>::value || std::is_same<T, int64_t>::value) { exp = val % range; } else { exp = static_cast<uint32_t>(val) % range; } ASSERT_TRUE(0 <= static_cast<int64_t>(exp)); ASSERT_TRUE(static_cast<uint64_t>(exp) < range); const auto expected = torch::full_like(actual, exp); if (std::is_same<T, bool>::value) { ASSERT_TRUE(torch::allclose(actual.toType(torch::kInt), expected.toType(torch::kInt))); } else { ASSERT_TRUE(torch::allclose(actual, expected)); } } } }
29.837963
102
0.61955
[ "vector" ]
7bb6dd8e5eabef9b0b6b31e22731058d16dda812
5,641
h
C
conex/constraint.h
ToyotaResearchInstitute/conex
181a4a9b77d7331464fffc7afc45fe8be29168d2
[ "MIT" ]
12
2021-02-08T08:02:17.000Z
2022-01-25T21:53:22.000Z
conex/constraint.h
ToyotaResearchInstitute/conex
181a4a9b77d7331464fffc7afc45fe8be29168d2
[ "MIT" ]
null
null
null
conex/constraint.h
ToyotaResearchInstitute/conex
181a4a9b77d7331464fffc7afc45fe8be29168d2
[ "MIT" ]
3
2020-12-21T16:02:22.000Z
2021-05-20T11:25:46.000Z
#pragma once #include <memory> #include <vector> #include <Eigen/Dense> #include "conex/error_checking_macros.h" #include "conex/newton_step.h" #include "conex/workspace.h" namespace conex { template <typename T> bool Permute(T*, std::vector<int> P) { CONEX_DEMAND(false, "Constraint does not support updates of linear operator."); } template <typename T> bool UpdateLinearOperator(T*, double, int, int, int, int) { CONEX_DEMAND(false, "Constraint does not support updates of linear operator."); } template <typename T> bool UpdateAffineTerm(T*, double, int, int, int) { CONEX_DEMAND(false, "Constraint does not support updates of affine term."); } // A helper class for forwarding to different implementations of an "interface." // With this approach, implementations do not need to use inheritance or virtual // functions. Instead, they simply provide functions of appropriate name and // signature, e.g., // // void TakeStep(Implementation1*, {arguments}); // void Rank(Implementation1*, {arguments}); // .. // void TakeStep(Implementation2*, {arguments}); // void Rank(Implementation2*, {arguments}); // // Note that implementations can be ANSI C compliant when the signature is. // // Reference: "Inheritance is the base-class of evil" by Sean Parent. class // Constraint { class Constraint { public: template <typename Implementation> Constraint(Implementation* t) : model(std::make_unique<Model<Implementation>>(t)) {} friend void ConstructSchurComplementSystem(Constraint* o, bool initialize, SchurComplementSystem* sys) { o->model->do_schur_complement(initialize, sys); } friend void SetIdentity(Constraint* o) { o->model->do_set_identity(); } friend void TakeStep(Constraint* o, const StepOptions& opt, const Ref& y, StepInfo* info) { o->model->do_take_step(opt, y, info); } friend void GetMuSelectionParameters(Constraint* o, const Ref& y, MuSelectionParameters* p) { o->model->do_min_mu(y, p); } friend int Rank(const Constraint& o) { return o.model->do_rank(); } Workspace workspace() { return model->do_get_workspace(); } void get_dual_variable(double* v) { return model->do_get_dual_variable(v); } int dual_variable_size() { return model->do_dual_variable_size(); } int number_of_variables() { return model->do_number_of_variables(); } friend bool UpdateLinearOperator(Constraint* o, double val, int var, int row, int col, int hyper_complex_dim) { return o->model->do_update_linear_operator(val, var, row, col, hyper_complex_dim); } friend bool UpdateAffineTerm(Constraint* o, double val, int row, int col, int hyper_complex_dim) { return o->model->do_update_affine_term(val, row, col, hyper_complex_dim); } private: struct Concept { virtual void do_schur_complement(bool initialize, SchurComplementSystem* sys) = 0; virtual void do_set_identity() = 0; virtual void do_min_mu(const Ref& y, MuSelectionParameters* p) = 0; virtual Workspace do_get_workspace() = 0; virtual void do_take_step(const StepOptions& opt, const Ref& y, StepInfo* info) = 0; virtual void do_get_dual_variable(double*) = 0; virtual int do_dual_variable_size() = 0; virtual int do_number_of_variables() = 0; virtual bool do_update_linear_operator(double val, int var, int row, int col, int hyper_complex_dim) = 0; virtual bool do_update_affine_term(double val, int row, int col, int hyper_complex_dim) = 0; virtual int do_rank() = 0; virtual ~Concept() = default; }; template <typename Implementation> struct Model final : Concept { Model(Implementation* t) : data(t) {} void do_schur_complement(bool initialize, SchurComplementSystem* sys) override { ConstructSchurComplementSystem(data, initialize, sys); } void do_set_identity() override { SetIdentity(data); } void do_min_mu(const Ref& y, MuSelectionParameters* p) override { GetMuSelectionParameters(data, y, p); } int do_rank() override { return Rank(*data); } int do_number_of_variables() override { return data->number_of_variables(); } Workspace do_get_workspace() override { return Workspace(data->workspace()); } void do_get_dual_variable(double* var) override { memcpy(static_cast<void*>(var), static_cast<void*>(data->workspace()->W.data()), sizeof(double) * do_dual_variable_size()); } int do_dual_variable_size() override { return data->workspace()->W.rows() * data->workspace()->W.cols(); } bool do_update_linear_operator(double val, int var, int row, int col, int hyper_complex_dim) override { return UpdateLinearOperator(data, val, var, row, col, hyper_complex_dim); } bool do_update_affine_term(double val, int row, int col, int hyper_complex_dim) override { return UpdateAffineTerm(data, val, row, col, hyper_complex_dim); } void do_take_step(const StepOptions& opt, const Ref& y, StepInfo* info) override { TakeStep(data, opt, y, info); } Implementation* data; }; std::unique_ptr<Concept> model; }; } // namespace conex
34.187879
80
0.645807
[ "vector", "model" ]
7bb82f48dec53dbd38437c1cc0880de5fd2fa487
33,603
c
C
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/iconv/skeleton.c
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/iconv/skeleton.c
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/iconv/skeleton.c
sotaoverride/backup
ca53a10b72295387ef4948a9289cb78ab70bc449
[ "Apache-2.0" ]
null
null
null
/* Skeleton for a conversion module. Copyright (C) 1998-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ /* This file can be included to provide definitions of several things many modules have in common. It can be customized using the following macros: DEFINE_INIT define the default initializer. This requires the following symbol to be defined. CHARSET_NAME string with official name of the coded character set (in all-caps) DEFINE_FINI define the default destructor function. MIN_NEEDED_FROM minimal number of bytes needed for the from-charset. MIN_NEEDED_TO likewise for the to-charset. MAX_NEEDED_FROM maximal number of bytes needed for the from-charset. This macro is optional, it defaults to MIN_NEEDED_FROM. MAX_NEEDED_TO likewise for the to-charset. FROM_LOOP_MIN_NEEDED_FROM FROM_LOOP_MAX_NEEDED_FROM minimal/maximal number of bytes needed on input of one round through the FROM_LOOP. Defaults to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively. FROM_LOOP_MIN_NEEDED_TO FROM_LOOP_MAX_NEEDED_TO minimal/maximal number of bytes needed on output of one round through the FROM_LOOP. Defaults to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively. TO_LOOP_MIN_NEEDED_FROM TO_LOOP_MAX_NEEDED_FROM minimal/maximal number of bytes needed on input of one round through the TO_LOOP. Defaults to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively. TO_LOOP_MIN_NEEDED_TO TO_LOOP_MAX_NEEDED_TO minimal/maximal number of bytes needed on output of one round through the TO_LOOP. Defaults to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively. FROM_DIRECTION this macro is supposed to return a value != 0 if we convert from the current character set, otherwise it return 0. EMIT_SHIFT_TO_INIT this symbol is optional. If it is defined it defines some code which writes out a sequence of bytes which bring the current state into the initial state. FROM_LOOP name of the function implementing the conversion from the current character set. TO_LOOP likewise for the other direction ONE_DIRECTION optional. If defined to 1, only one conversion direction is defined instead of two. In this case, FROM_DIRECTION should be defined to 1, and FROM_LOOP and TO_LOOP should have the same value. SAVE_RESET_STATE in case of an error we must reset the state for the rerun so this macro must be defined for stateful encodings. It takes an argument which is nonzero when saving. RESET_INPUT_BUFFER If the input character sets allow this the macro can be defined to reset the input buffer pointers to cover only those characters up to the error. FUNCTION_NAME if not set the conversion function is named `gconv'. PREPARE_LOOP optional code preparing the conversion loop. Can contain variable definitions. END_LOOP also optional, may be used to store information EXTRA_LOOP_ARGS optional macro specifying extra arguments passed to loop function. STORE_REST optional, needed only when MAX_NEEDED_FROM > 4. This macro stores the seen but unconverted input bytes in the state. FROM_ONEBYTE optional. If defined, should be the name of a specialized conversion function for a single byte from the current character set to INTERNAL. This function has prototype wint_t FROM_ONEBYTE (struct __gconv_step *, unsigned char); and does a special conversion: - The input is a single byte. - The output is a single uint32_t. - The state before the conversion is the initial state; the state after the conversion is irrelevant. - No transliteration. - __invocation_counter = 0. - __internal_use = 1. - do_flush = 0. Modules can use mbstate_t to store conversion state as follows: * Bits 2..0 of '__count' contain the number of lookahead input bytes stored in __value.__wchb. Always zero if the converter never returns __GCONV_INCOMPLETE_INPUT. * Bits 31..3 of '__count' are module dependent shift state. * __value: When STORE_REST/UNPACK_BYTES aren't defined and when the converter has returned __GCONV_INCOMPLETE_INPUT, this contains at most 4 lookahead bytes. Converters with an mb_cur_max > 4 (currently only UTF-8) must find a way to store their state in __value.__wch and define STORE_REST/UNPACK_BYTES appropriately. When __value contains lookahead, __count must not be zero, because the converter is not in the initial state then, and mbsinit() -- defined as a (__count == 0) test -- must reflect this. */ #include <assert.h> #include <gconv.h> #include <string.h> #define __need_size_t #define __need_NULL #include <stddef.h> #ifndef STATIC_GCONV #include <dlfcn.h> #endif #include <stdint.h> #include <sysdep.h> #ifndef DL_CALL_FCT #define DL_CALL_FCT(fct, args) fct args #endif /* The direction objects. */ #if DEFINE_INIT #ifndef FROM_DIRECTION #define FROM_DIRECTION_VAL NULL #define TO_DIRECTION_VAL ((void*)~((uintptr_t)0)) #define FROM_DIRECTION (step->__data == FROM_DIRECTION_VAL) #endif #else #ifndef FROM_DIRECTION #error "FROM_DIRECTION must be provided if non-default init is used" #endif #endif /* How many bytes are needed at most for the from-charset. */ #ifndef MAX_NEEDED_FROM #define MAX_NEEDED_FROM MIN_NEEDED_FROM #endif /* Same for the to-charset. */ #ifndef MAX_NEEDED_TO #define MAX_NEEDED_TO MIN_NEEDED_TO #endif /* Defaults for the per-direction min/max constants. */ #ifndef FROM_LOOP_MIN_NEEDED_FROM #define FROM_LOOP_MIN_NEEDED_FROM MIN_NEEDED_FROM #endif #ifndef FROM_LOOP_MAX_NEEDED_FROM #define FROM_LOOP_MAX_NEEDED_FROM MAX_NEEDED_FROM #endif #ifndef FROM_LOOP_MIN_NEEDED_TO #define FROM_LOOP_MIN_NEEDED_TO MIN_NEEDED_TO #endif #ifndef FROM_LOOP_MAX_NEEDED_TO #define FROM_LOOP_MAX_NEEDED_TO MAX_NEEDED_TO #endif #ifndef TO_LOOP_MIN_NEEDED_FROM #define TO_LOOP_MIN_NEEDED_FROM MIN_NEEDED_TO #endif #ifndef TO_LOOP_MAX_NEEDED_FROM #define TO_LOOP_MAX_NEEDED_FROM MAX_NEEDED_TO #endif #ifndef TO_LOOP_MIN_NEEDED_TO #define TO_LOOP_MIN_NEEDED_TO MIN_NEEDED_FROM #endif #ifndef TO_LOOP_MAX_NEEDED_TO #define TO_LOOP_MAX_NEEDED_TO MAX_NEEDED_FROM #endif /* Define macros which can access unaligned buffers. These macros are supposed to be used only in code outside the inner loops. For the inner loops we have other definitions which allow optimized access. */ #if _STRING_ARCH_unaligned /* We can handle unaligned memory access. */ #define get16u(addr) *((const uint16_t*)(addr)) #define get32u(addr) *((const uint32_t*)(addr)) /* We need no special support for writing values either. */ #define put16u(addr, val) *((uint16_t*)(addr)) = (val) #define put32u(addr, val) *((uint32_t*)(addr)) = (val) #else /* Distinguish between big endian and little endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN #define get16u(addr) \ (((const unsigned char*)(addr))[1] << 8 | ((const unsigned char*)(addr))[0]) #define get32u(addr) \ (((((const unsigned char*)(addr))[3] << 8 | \ ((const unsigned char*)(addr))[2]) \ << 8 | \ ((const unsigned char*)(addr))[1]) \ << 8 | \ ((const unsigned char*)(addr))[0]) #define put16u(addr, val) \ ({ \ uint16_t __val = (val); \ ((unsigned char*)(addr))[0] = __val; \ ((unsigned char*)(addr))[1] = __val >> 8; \ (void)0; \ }) #define put32u(addr, val) \ ({ \ uint32_t __val = (val); \ ((unsigned char*)(addr))[0] = __val; \ __val >>= 8; \ ((unsigned char*)(addr))[1] = __val; \ __val >>= 8; \ ((unsigned char*)(addr))[2] = __val; \ __val >>= 8; \ ((unsigned char*)(addr))[3] = __val; \ (void)0; \ }) #else #define get16u(addr) \ (((const unsigned char*)(addr))[0] << 8 | ((const unsigned char*)(addr))[1]) #define get32u(addr) \ (((((const unsigned char*)(addr))[0] << 8 | \ ((const unsigned char*)(addr))[1]) \ << 8 | \ ((const unsigned char*)(addr))[2]) \ << 8 | \ ((const unsigned char*)(addr))[3]) #define put16u(addr, val) \ ({ \ uint16_t __val = (val); \ ((unsigned char*)(addr))[1] = __val; \ ((unsigned char*)(addr))[0] = __val >> 8; \ (void)0; \ }) #define put32u(addr, val) \ ({ \ uint32_t __val = (val); \ ((unsigned char*)(addr))[3] = __val; \ __val >>= 8; \ ((unsigned char*)(addr))[2] = __val; \ __val >>= 8; \ ((unsigned char*)(addr))[1] = __val; \ __val >>= 8; \ ((unsigned char*)(addr))[0] = __val; \ (void)0; \ }) #endif #endif /* For conversions from a fixed width character set to another fixed width character set we can define RESET_INPUT_BUFFER in a very fast way. */ #if !defined RESET_INPUT_BUFFER && !defined SAVE_RESET_STATE #if FROM_LOOP_MIN_NEEDED_FROM == FROM_LOOP_MAX_NEEDED_FROM && \ FROM_LOOP_MIN_NEEDED_TO == FROM_LOOP_MAX_NEEDED_TO && \ TO_LOOP_MIN_NEEDED_FROM == TO_LOOP_MAX_NEEDED_FROM && \ TO_LOOP_MIN_NEEDED_TO == TO_LOOP_MAX_NEEDED_TO /* We have to use these `if's here since the compiler cannot know that (outbuf - outerr) is always divisible by FROM/TO_LOOP_MIN_NEEDED_TO. The ?:1 avoids division by zero warnings that gcc 3.2 emits even for obviously unreachable code. */ #define RESET_INPUT_BUFFER \ if (FROM_DIRECTION) \ { \ if (FROM_LOOP_MIN_NEEDED_FROM % FROM_LOOP_MIN_NEEDED_TO == 0) \ *inptrp -= (outbuf - outerr) * \ (FROM_LOOP_MIN_NEEDED_FROM / FROM_LOOP_MIN_NEEDED_TO); \ else if (FROM_LOOP_MIN_NEEDED_TO % FROM_LOOP_MIN_NEEDED_FROM == 0) \ *inptrp -= \ (outbuf - outerr) / \ (FROM_LOOP_MIN_NEEDED_TO / FROM_LOOP_MIN_NEEDED_FROM ?: 1); \ else \ *inptrp -= ((outbuf - outerr) / FROM_LOOP_MIN_NEEDED_TO) * \ FROM_LOOP_MIN_NEEDED_FROM; \ } \ else \ { \ if (TO_LOOP_MIN_NEEDED_FROM % TO_LOOP_MIN_NEEDED_TO == 0) \ *inptrp -= (outbuf - outerr) * \ (TO_LOOP_MIN_NEEDED_FROM / TO_LOOP_MIN_NEEDED_TO); \ else if (TO_LOOP_MIN_NEEDED_TO % TO_LOOP_MIN_NEEDED_FROM == 0) \ *inptrp -= (outbuf - outerr) / \ (TO_LOOP_MIN_NEEDED_TO / TO_LOOP_MIN_NEEDED_FROM ?: 1); \ else \ *inptrp -= ((outbuf - outerr) / TO_LOOP_MIN_NEEDED_TO) * \ TO_LOOP_MIN_NEEDED_FROM; \ } #endif #endif /* The default init function. It simply matches the name and initializes the step data to point to one of the objects above. */ #if DEFINE_INIT #ifndef CHARSET_NAME #error "CHARSET_NAME not defined" #endif extern int gconv_init(struct __gconv_step* step); int gconv_init(struct __gconv_step* step) { /* Determine which direction. */ if (strcmp(step->__from_name, CHARSET_NAME) == 0) { step->__data = FROM_DIRECTION_VAL; step->__min_needed_from = FROM_LOOP_MIN_NEEDED_FROM; step->__max_needed_from = FROM_LOOP_MAX_NEEDED_FROM; step->__min_needed_to = FROM_LOOP_MIN_NEEDED_TO; step->__max_needed_to = FROM_LOOP_MAX_NEEDED_TO; #ifdef FROM_ONEBYTE step->__btowc_fct = FROM_ONEBYTE; #endif } else if (__builtin_expect(strcmp(step->__to_name, CHARSET_NAME), 0) == 0) { step->__data = TO_DIRECTION_VAL; step->__min_needed_from = TO_LOOP_MIN_NEEDED_FROM; step->__max_needed_from = TO_LOOP_MAX_NEEDED_FROM; step->__min_needed_to = TO_LOOP_MIN_NEEDED_TO; step->__max_needed_to = TO_LOOP_MAX_NEEDED_TO; } else return __GCONV_NOCONV; #ifdef SAVE_RESET_STATE step->__stateful = 1; #else step->__stateful = 0; #endif return __GCONV_OK; } #endif /* The default destructor function does nothing in the moment and so we don't define it at all. But we still provide the macro just in case we need it some day. */ #if DEFINE_FINI #endif /* If no arguments have to passed to the loop function define the macro as empty. */ #ifndef EXTRA_LOOP_ARGS #define EXTRA_LOOP_ARGS #endif /* This is the actual conversion function. */ #ifndef FUNCTION_NAME #define FUNCTION_NAME gconv #endif /* The macros are used to access the function to convert single characters. */ #define SINGLE(fct) SINGLE2(fct) #define SINGLE2(fct) fct##_single extern int FUNCTION_NAME(struct __gconv_step* step, struct __gconv_step_data* data, const unsigned char** inptrp, const unsigned char* inend, unsigned char** outbufstart, size_t* irreversible, int do_flush, int consume_incomplete); int FUNCTION_NAME(struct __gconv_step* step, struct __gconv_step_data* data, const unsigned char** inptrp, const unsigned char* inend, unsigned char** outbufstart, size_t* irreversible, int do_flush, int consume_incomplete) { struct __gconv_step* next_step = step + 1; struct __gconv_step_data* next_data = data + 1; __gconv_fct fct = NULL; int status; if ((data->__flags & __GCONV_IS_LAST) == 0) { fct = next_step->__fct; #ifdef PTR_DEMANGLE if (next_step->__shlib_handle != NULL) PTR_DEMANGLE(fct); #endif } /* If the function is called with no input this means we have to reset to the initial state. The possibly partly converted input is dropped. */ if (__glibc_unlikely(do_flush)) { /* This should never happen during error handling. */ assert(outbufstart == NULL); status = __GCONV_OK; #ifdef EMIT_SHIFT_TO_INIT if (do_flush == 1) { /* We preserve the initial values of the pointer variables. */ unsigned char* outbuf = data->__outbuf; unsigned char* outstart = outbuf; unsigned char* outend = data->__outbufend; #ifdef PREPARE_LOOP PREPARE_LOOP #endif #ifdef SAVE_RESET_STATE SAVE_RESET_STATE(1); #endif /* Emit the escape sequence to reset the state. */ EMIT_SHIFT_TO_INIT; /* Call the steps down the chain if there are any but only if we successfully emitted the escape sequence. This should only fail if the output buffer is full. If the input is invalid it should be discarded since the user wants to start from a clean state. */ if (status == __GCONV_OK) { if (data->__flags & __GCONV_IS_LAST) /* Store information about how many bytes are available. */ data->__outbuf = outbuf; else { /* Write out all output which was produced. */ if (outbuf > outstart) { const unsigned char* outerr = outstart; int result; result = DL_CALL_FCT( fct, (next_step, next_data, &outerr, outbuf, NULL, irreversible, 0, consume_incomplete)); if (result != __GCONV_EMPTY_INPUT) { if (__glibc_unlikely(outerr != outbuf)) { /* We have a problem. Undo the conversion. */ outbuf = outstart; /* Restore the state. */ #ifdef SAVE_RESET_STATE SAVE_RESET_STATE(0); #endif } /* Change the status. */ status = result; } } if (status == __GCONV_OK) /* Now flush the remaining steps. */ status = DL_CALL_FCT(fct, (next_step, next_data, NULL, NULL, NULL, irreversible, 1, consume_incomplete)); } } } else #endif { /* Clear the state object. There might be bytes in there from previous calls with CONSUME_INCOMPLETE == 1. But don't emit escape sequences. */ memset(data->__statep, '\0', sizeof(*data->__statep)); if (!(data->__flags & __GCONV_IS_LAST)) /* Now flush the remaining steps. */ status = DL_CALL_FCT(fct, (next_step, next_data, NULL, NULL, NULL, irreversible, do_flush, consume_incomplete)); } } else { /* We preserve the initial values of the pointer variables, but only some conversion modules need it. */ const unsigned char* inptr __attribute__((__unused__)) = *inptrp; unsigned char* outbuf = (__builtin_expect(outbufstart == NULL, 1) ? data->__outbuf : *outbufstart); unsigned char* outend = data->__outbufend; unsigned char* outstart; /* This variable is used to count the number of characters we actually converted. */ size_t lirreversible = 0; size_t* lirreversiblep = irreversible ? &lirreversible : NULL; /* The following assumes that encodings, which have a variable length what might unalign a buffer even though it is an aligned in the beginning, either don't have the minimal number of bytes as a divisor of the maximum length or have a minimum length of 1. This is true for all known and supported encodings. We use && instead of || to combine the subexpression for the FROM encoding and for the TO encoding, because usually one of them is INTERNAL, for which the subexpression evaluates to 1, but INTERNAL buffers are always aligned correctly. */ #define POSSIBLY_UNALIGNED \ (!_STRING_ARCH_unaligned && \ (((FROM_LOOP_MIN_NEEDED_FROM != 1 && \ FROM_LOOP_MAX_NEEDED_FROM % FROM_LOOP_MIN_NEEDED_FROM == 0) && \ (FROM_LOOP_MIN_NEEDED_TO != 1 && \ FROM_LOOP_MAX_NEEDED_TO % FROM_LOOP_MIN_NEEDED_TO == 0)) || \ ((TO_LOOP_MIN_NEEDED_FROM != 1 && \ TO_LOOP_MAX_NEEDED_FROM % TO_LOOP_MIN_NEEDED_FROM == 0) && \ (TO_LOOP_MIN_NEEDED_TO != 1 && \ TO_LOOP_MAX_NEEDED_TO % TO_LOOP_MIN_NEEDED_TO == 0)))) #if POSSIBLY_UNALIGNED int unaligned; #define GEN_unaligned(name) GEN_unaligned2(name) #define GEN_unaligned2(name) name##_unaligned #else #define unaligned 0 #endif #ifdef PREPARE_LOOP PREPARE_LOOP #endif #if FROM_LOOP_MAX_NEEDED_FROM > 1 || TO_LOOP_MAX_NEEDED_FROM > 1 /* If the function is used to implement the mb*towc*() or wc*tomb*() functions we must test whether any bytes from the last call are stored in the `state' object. */ if (((FROM_LOOP_MAX_NEEDED_FROM > 1 && TO_LOOP_MAX_NEEDED_FROM > 1) || (FROM_LOOP_MAX_NEEDED_FROM > 1 && FROM_DIRECTION) || (TO_LOOP_MAX_NEEDED_FROM > 1 && !FROM_DIRECTION)) && consume_incomplete && (data->__statep->__count & 7) != 0) { /* Yep, we have some bytes left over. Process them now. But this must not happen while we are called from an error handler. */ assert(outbufstart == NULL); #if FROM_LOOP_MAX_NEEDED_FROM > 1 if (TO_LOOP_MAX_NEEDED_FROM == 1 || FROM_DIRECTION) status = SINGLE(FROM_LOOP)(step, data, inptrp, inend, &outbuf, outend, lirreversiblep EXTRA_LOOP_ARGS); #endif #if !ONE_DIRECTION #if FROM_LOOP_MAX_NEEDED_FROM > 1 && TO_LOOP_MAX_NEEDED_FROM > 1 else #endif #if TO_LOOP_MAX_NEEDED_FROM > 1 status = SINGLE(TO_LOOP)(step, data, inptrp, inend, &outbuf, outend, lirreversiblep EXTRA_LOOP_ARGS); #endif #endif if (__builtin_expect(status, __GCONV_OK) != __GCONV_OK) return status; } #endif #if POSSIBLY_UNALIGNED unaligned = ((FROM_DIRECTION && ((uintptr_t)inptr % FROM_LOOP_MIN_NEEDED_FROM != 0 || ((data->__flags & __GCONV_IS_LAST) && (uintptr_t)outbuf % FROM_LOOP_MIN_NEEDED_TO != 0))) || (!FROM_DIRECTION && (((data->__flags & __GCONV_IS_LAST) && (uintptr_t)outbuf % TO_LOOP_MIN_NEEDED_TO != 0) || (uintptr_t)inptr % TO_LOOP_MIN_NEEDED_FROM != 0))); #endif while (1) { /* Remember the start value for this round. */ inptr = *inptrp; /* The outbuf buffer is empty. */ outstart = outbuf; #ifdef SAVE_RESET_STATE SAVE_RESET_STATE(1); #endif if (__glibc_likely(!unaligned)) { if (FROM_DIRECTION) /* Run the conversion loop. */ status = FROM_LOOP(step, data, inptrp, inend, &outbuf, outend, lirreversiblep EXTRA_LOOP_ARGS); else /* Run the conversion loop. */ status = TO_LOOP(step, data, inptrp, inend, &outbuf, outend, lirreversiblep EXTRA_LOOP_ARGS); } #if POSSIBLY_UNALIGNED else { if (FROM_DIRECTION) /* Run the conversion loop. */ status = GEN_unaligned(FROM_LOOP)( step, data, inptrp, inend, &outbuf, outend, lirreversiblep EXTRA_LOOP_ARGS); else /* Run the conversion loop. */ status = GEN_unaligned(TO_LOOP)( step, data, inptrp, inend, &outbuf, outend, lirreversiblep EXTRA_LOOP_ARGS); } #endif /* If we were called as part of an error handling module we don't do anything else here. */ if (__glibc_unlikely(outbufstart != NULL)) { *outbufstart = outbuf; return status; } /* We finished one use of the loops. */ ++data->__invocation_counter; /* If this is the last step leave the loop, there is nothing we can do. */ if (__glibc_unlikely(data->__flags & __GCONV_IS_LAST)) { /* Store information about how many bytes are available. */ data->__outbuf = outbuf; /* Remember how many non-identical characters we converted in an irreversible way. */ *irreversible += lirreversible; break; } /* Write out all output which was produced. */ if (__glibc_likely(outbuf > outstart)) { const unsigned char* outerr = data->__outbuf; int result; result = DL_CALL_FCT(fct, (next_step, next_data, &outerr, outbuf, NULL, irreversible, 0, consume_incomplete)); if (result != __GCONV_EMPTY_INPUT) { if (__glibc_unlikely(outerr != outbuf)) { #ifdef RESET_INPUT_BUFFER RESET_INPUT_BUFFER; #else /* We have a problem in one of the functions below. Undo the conversion upto the error point. */ size_t nstatus __attribute__((unused)); /* Reload the pointers. */ *inptrp = inptr; outbuf = outstart; /* Restore the state. */ #ifdef SAVE_RESET_STATE SAVE_RESET_STATE(0); #endif if (__glibc_likely(!unaligned)) { if (FROM_DIRECTION) /* Run the conversion loop. */ nstatus = FROM_LOOP( step, data, inptrp, inend, &outbuf, outerr, lirreversiblep EXTRA_LOOP_ARGS); else /* Run the conversion loop. */ nstatus = TO_LOOP( step, data, inptrp, inend, &outbuf, outerr, lirreversiblep EXTRA_LOOP_ARGS); } #if POSSIBLY_UNALIGNED else { if (FROM_DIRECTION) /* Run the conversion loop. */ nstatus = GEN_unaligned(FROM_LOOP)( step, data, inptrp, inend, &outbuf, outerr, lirreversiblep EXTRA_LOOP_ARGS); else /* Run the conversion loop. */ nstatus = GEN_unaligned(TO_LOOP)( step, data, inptrp, inend, &outbuf, outerr, lirreversiblep EXTRA_LOOP_ARGS); } #endif /* We must run out of output buffer space in this rerun. */ assert(outbuf == outerr); assert(nstatus == __GCONV_FULL_OUTPUT); /* If we haven't consumed a single byte decrement the invocation counter. */ if (__glibc_unlikely(outbuf == outstart)) --data->__invocation_counter; #endif /* reset input buffer */ } /* Change the status. */ status = result; } else /* All the output is consumed, we can make another run if everything was ok. */ if (status == __GCONV_FULL_OUTPUT) { status = __GCONV_OK; outbuf = data->__outbuf; } } if (status != __GCONV_OK) break; /* Reset the output buffer pointer for the next round. */ outbuf = data->__outbuf; } #ifdef END_LOOP END_LOOP #endif /* If we are supposed to consume all character store now all of the remaining characters in the `state' object. */ #if FROM_LOOP_MAX_NEEDED_FROM > 1 || TO_LOOP_MAX_NEEDED_FROM > 1 if (((FROM_LOOP_MAX_NEEDED_FROM > 1 && TO_LOOP_MAX_NEEDED_FROM > 1) || (FROM_LOOP_MAX_NEEDED_FROM > 1 && FROM_DIRECTION) || (TO_LOOP_MAX_NEEDED_FROM > 1 && !FROM_DIRECTION)) && __builtin_expect(consume_incomplete, 0) && status == __GCONV_INCOMPLETE_INPUT) { #ifdef STORE_REST mbstate_t* state = data->__statep; STORE_REST #else /* Make sure the remaining bytes fit into the state objects buffer. */ assert(inend - *inptrp < 4); size_t cnt; for (cnt = 0; *inptrp < inend; ++cnt) data->__statep->__value.__wchb[cnt] = *(*inptrp)++; data->__statep->__count &= ~7; data->__statep->__count |= cnt; #endif } #endif #undef unaligned #undef POSSIBLY_UNALIGNED } return status; } #undef DEFINE_INIT #undef CHARSET_NAME #undef DEFINE_FINI #undef MIN_NEEDED_FROM #undef MIN_NEEDED_TO #undef MAX_NEEDED_FROM #undef MAX_NEEDED_TO #undef FROM_LOOP_MIN_NEEDED_FROM #undef FROM_LOOP_MAX_NEEDED_FROM #undef FROM_LOOP_MIN_NEEDED_TO #undef FROM_LOOP_MAX_NEEDED_TO #undef TO_LOOP_MIN_NEEDED_FROM #undef TO_LOOP_MAX_NEEDED_FROM #undef TO_LOOP_MIN_NEEDED_TO #undef TO_LOOP_MAX_NEEDED_TO #undef FROM_DIRECTION #undef EMIT_SHIFT_TO_INIT #undef FROM_LOOP #undef TO_LOOP #undef ONE_DIRECTION #undef SAVE_RESET_STATE #undef RESET_INPUT_BUFFER #undef FUNCTION_NAME #undef PREPARE_LOOP #undef END_LOOP #undef EXTRA_LOOP_ARGS #undef STORE_REST #undef FROM_ONEBYTE
41.281327
80
0.524001
[ "object" ]
7bc0cb9fe5390bbc8236c6f08077ccebce339a9f
2,392
h
C
src/Species/_Species.h
nwieder/SSTS
ff59aab0fd6b9b6ca5f6611153c784b6f61178ff
[ "MIT" ]
1
2018-07-05T10:43:00.000Z
2018-07-05T10:43:00.000Z
src/Species/_Species.h
nwieder/SSTS
ff59aab0fd6b9b6ca5f6611153c784b6f61178ff
[ "MIT" ]
null
null
null
src/Species/_Species.h
nwieder/SSTS
ff59aab0fd6b9b6ca5f6611153c784b6f61178ff
[ "MIT" ]
null
null
null
#include <string> #ifndef _SPECIES_H_ #define _SPECIES_H_ namespace nw{ using namespace std; /** Definition of Avogadro's constant*/ static const double N_AVO = 6.022e23; /** @brief Abstract base class for the molecular species of a system.*/ class _Species { public: /** @brief Constructor * * @param id Species ID * @param name Species name * @param init_conc initial concentration */ _Species(long id,string name, double init_conc): id(id), name(name), dirty_flag(true), initial_conc(init_conc) {} /** @brief Destructor */ virtual ~_Species(){}; /** @brief Get current number of molecules * * @return current number of molecules*/ virtual long get_n_molecules() = 0; /** @brief Modify number of molecules (n_molecules). * @param n Summand that is added to the current number of molecules. * * If an event occurs, this function is called to update the number of molecules * based on the state change vector of the firing _Event. If n is positive, the number * of molecules is increased, if it is negative the number of molecules in decrease. */ virtual void mod_n_molecules(long n) = 0; /** @brief Copy method. * @return Reference to an object identical to this * * Copy method that generates a copy of this. It is is a virtual function to ensure * that whenever this function is called, the most specific object (derived from this * abstract base class) is copied. */ virtual _Species* copy() = 0; /** @brief Set initial molecular count (n_molecules). * * Called in the constructor of every _Voxel to set the correct (_Voxel volume adapted) * number of molecules. This makes it easier to define _Species and _Voxel in the * input file.*/ virtual void set_n_molecules(double volume){ this->n_molecules = volume*1e-6*N_AVO*initial_conc;} // getter and setter long get_id(){return id;} string get_name(){return name;} double get_initial_conc(){return initial_conc;} bool get_dirty_flag(){return dirty_flag;} void set_dirty_flag(bool b) {dirty_flag = b;} protected: long id; //!< Species ID string name; //!< Species name bool dirty_flag; //!< Indicates whether this _Species needs to be updated or not long n_molecules; //!< Current number of molecules double initial_conc; //!< Initial concentration double volume; //!< Volume of the _Voxel containing this _Species }; } #endif /* EVENT_H_ */
31.473684
88
0.7199
[ "object", "vector" ]
7bc0daacded505519cdb2269446e5c670b02622d
3,055
h
C
gnu/gcc/gcc/config/m68k/coff.h
ArrogantWombatics/openbsd-src
75721e1d44322953075b7c4b89337b163a395291
[ "BSD-3-Clause" ]
105
2015-03-02T16:58:34.000Z
2022-03-28T07:17:49.000Z
gnu/gcc/gcc/config/m68k/coff.h
ArrogantWombatics/openbsd-src
75721e1d44322953075b7c4b89337b163a395291
[ "BSD-3-Clause" ]
145
2015-03-18T10:08:17.000Z
2022-03-31T01:27:08.000Z
gnu/gcc/gcc/config/m68k/coff.h
ArrogantWombatics/openbsd-src
75721e1d44322953075b7c4b89337b163a395291
[ "BSD-3-Clause" ]
26
2015-10-10T09:37:44.000Z
2022-02-23T02:02:05.000Z
/* Definitions of target machine for GNU compiler. m68k series COFF object files and debugging, version. Copyright (C) 1994, 1996, 1997, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GCC 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 GCC; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file is included after m68k.h by CPU COFF specific files. It is not a complete target itself. */ /* Used in m68k.c to include required support code. */ #define M68K_TARGET_COFF 1 /* Generate sdb debugging information. */ #define SDB_DEBUGGING_INFO 1 /* COFF symbols don't start with an underscore. */ #undef USER_LABEL_PREFIX #define USER_LABEL_PREFIX "" /* Use a prefix for local labels, just to be on the save side. */ #undef LOCAL_LABEL_PREFIX #define LOCAL_LABEL_PREFIX "." /* Use a register prefix to avoid clashes with external symbols (classic example: `extern char PC;' in termcap). */ #undef REGISTER_PREFIX #define REGISTER_PREFIX "%" /* In the machine description we can't use %R, because it will not be seen by ASM_FPRINTF. (Isn't that a design bug?). */ #undef REGISTER_PREFIX_MD #define REGISTER_PREFIX_MD "%%" /* config/m68k.md has an explicit reference to the program counter, prefix this by the register prefix. */ #define ASM_RETURN_CASE_JUMP \ do { \ if (TARGET_COLDFIRE) \ { \ if (ADDRESS_REG_P (operands[0])) \ return "jmp %%pc@(2,%0:l)"; \ else \ return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \ } \ else \ return "jmp %%pc@(2,%0:w)"; \ } while (0) #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true /* If defined, a C expression whose value is a string containing the assembler operation to identify the following data as uninitialized global data. */ #define BSS_SECTION_ASM_OP "\t.section\t.bss" /* A C statement (sans semicolon) to output to the stdio stream FILE the assembler definition of uninitialized global DECL named NAME whose size is SIZE bytes and alignment is ALIGN bytes. Try to use asm_output_aligned_bss to implement this macro. */ #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) /* Switch into a generic section. */ #undef TARGET_ASM_NAMED_SECTION #define TARGET_ASM_NAMED_SECTION m68k_coff_asm_named_section /* Don't assume anything about startfiles. */ #undef STARTFILE_SPEC #define STARTFILE_SPEC ""
32.157895
88
0.723732
[ "object" ]
7bc5a8172997142769088a91f30f7dac61222091
625
h
C
SimpleRPG-Text/Battle.h
utilForever/SimpleRPG-Text
546c130f93505984dc77c51a872254c52ef99470
[ "MIT" ]
33
2015-10-01T05:38:05.000Z
2021-09-25T01:43:30.000Z
SimpleRPG-Text/Battle.h
mudaliaraditya/SimpleRPG-Text
546c130f93505984dc77c51a872254c52ef99470
[ "MIT" ]
1
2015-10-02T15:20:22.000Z
2015-10-02T15:20:22.000Z
SimpleRPG-Text/Battle.h
mudaliaraditya/SimpleRPG-Text
546c130f93505984dc77c51a872254c52ef99470
[ "MIT" ]
10
2015-09-30T14:54:59.000Z
2020-05-20T19:26:42.000Z
#ifndef BATTLE_H #define BATTLE_H #include <vector> #include "Dialogue.h" class Creature; enum class BattleEventType { ATTACK, DEFEND }; class BattleEvent { private: Creature* source; Creature* target; BattleEventType type; public: BattleEvent(Creature* _source, Creature* _target, BattleEventType _type); Creature* GetSource(); Creature* GetTarget(); BattleEventType GetType(); int Run(); }; class Battle { private: std::vector<Creature*> combatants; Dialogue battleOptions; public: Battle(std::vector<Creature*>& _combatants); void Run(); void Kill(Creature* creature); void NextTurn(); }; #endif
14.534884
74
0.7344
[ "vector" ]
7bc7ee83d74593b053df8ef9ed0a0d60820f4d5f
2,584
h
C
bin/seispp/hdrmath/HdrmathArg.h
chad-iris/antelope_contrib
d4cb83d433f30fd76ee7416f3106a4074a7206d4
[ "BSD-2-Clause", "MIT" ]
30
2015-02-20T21:44:29.000Z
2021-09-27T02:53:14.000Z
bin/seispp/hdrmath/HdrmathArg.h
chad-iris/antelope_contrib
d4cb83d433f30fd76ee7416f3106a4074a7206d4
[ "BSD-2-Clause", "MIT" ]
14
2015-07-07T19:17:24.000Z
2020-12-19T19:18:53.000Z
bin/seispp/hdrmath/HdrmathArg.h
chad-iris/antelope_contrib
d4cb83d433f30fd76ee7416f3106a4074a7206d4
[ "BSD-2-Clause", "MIT" ]
46
2015-02-06T16:22:41.000Z
2022-03-30T11:46:37.000Z
#include "Metadata.h" using namespace SEISPP; class HdrmathArg { public: HdrmathArg(); /*!~ Primary constructor for this application. Parse command line argument that assumes syntax name:type or a number */ HdrmathArg(char *arg); HdrmathArg(long val); HdrmathArg(int val); HdrmathArg(float val); HdrmathArg(double val); /*! Initialize from metdata. This constructor is used for the left hand side argument of a sequence of operations. e.g. chan += 2 */ HdrmathArg(Metadata& md, string key, MDtype mt); /*! Copy constructor. */ HdrmathArg(const HdrmathArg& parent); /*! Boolean defines if this entity is a metadata attribute. If set true the contents are expected to be available by fetching with get methods defined in Metadata.h. If false, the value is assumed to be a constant. */ bool IsMetadata; string key; MDtype mdt; long get_long(); double get_double(); /* In every other class definition I've (glp) ever done these operator definitions have a const qualifier for the argument. For reasons I don't get this created a conflict here so they are by necessity NOT const. */ //HdrmathArg& operator=(HdrmathArg&& parent); HdrmathArg& operator=(const HdrmathArg& parent); /* All of the operators will require that if the type of the left hand side will always take precedence. That will assure that the ultimate target of a string of operators will match the required type of the result that is to be set. */ HdrmathArg& operator+=(HdrmathArg& other); HdrmathArg& operator-=(HdrmathArg& other); HdrmathArg& operator*=(HdrmathArg& other); HdrmathArg& operator/=(HdrmathArg& other); HdrmathArg& operator%=(HdrmathArg& other); HdrmathArg operator+(HdrmathArg& other); HdrmathArg operator-(HdrmathArg& other); HdrmathArg operator*(HdrmathArg& other); HdrmathArg operator/(HdrmathArg& other); HdrmathArg operator%(HdrmathArg& other); /*! Set the Metadata component with new data. The way this object is used is expected to be this. The arg list is parsed to make a skeleton for each HdrmathArg object in which the metadata itself is empty. When a new block of data is read we load each HdrmathArg object with the metadata (header) from the parent data. This method is used to set that data. */ void SetMetadata(Metadata& dnew); private: /* One of these to variables are set when arg is constant (IsMetadata is false). */ long ival; double rval; Metadata d; // a copy of the header of the object being processed };
38.567164
75
0.718266
[ "object" ]
7bca395e9f6e7380bb6407aab7072643fb350319
8,953
c
C
patches/support_g729/g729/src/gainpred.c
ngoclt/pjsip-android-builder
9da20ec9d5b8cde425ae92a22ccbfccc6d0b4495
[ "Apache-2.0" ]
4
2016-09-29T00:04:31.000Z
2021-12-02T08:39:51.000Z
patches/support_g729/g729/src/gainpred.c
ngoclt/pjsip-android-builder
9da20ec9d5b8cde425ae92a22ccbfccc6d0b4495
[ "Apache-2.0" ]
null
null
null
patches/support_g729/g729/src/gainpred.c
ngoclt/pjsip-android-builder
9da20ec9d5b8cde425ae92a22ccbfccc6d0b4495
[ "Apache-2.0" ]
null
null
null
/** * g729a codec for iPhone and iPod Touch * Copyright (C) 2009 Samuel <samuelv0304@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /**************************************************************************************** Portions of this file are derived from the following ITU standard: ITU-T G.729A Speech Coder ANSI-C Source Code Version 1.1 Last modified: September 1996 Copyright (c) 1996, AT&T, France Telecom, NTT, Universite de Sherbrooke ****************************************************************************************/ /*---------------------------------------------------------------------------* * Gain_predict() : make gcode0(exp_gcode0) * * Gain_update() : update table of past quantized energies. * * Gain_update_erasure() : update table of past quantized energies. * * (frame erasure) * * This function is used both Coder and Decoder. * *---------------------------------------------------------------------------*/ #include "typedef.h" #include "basic_op.h" #include "ld8a.h" #include "tab_ld8a.h" #include "oper_32b.h" /*---------------------------------------------------------------------------* * Function Gain_predict * * ~~~~~~~~~~~~~~~~~~~~~~ * * MA prediction is performed on the innovation energy (in dB with mean * * removed). * *---------------------------------------------------------------------------*/ void Gain_predict( Word16 past_qua_en[], /* (i) Q10 :Past quantized energies */ Word16 code[], /* (i) Q13 :Innovative vector. */ Word16 L_subfr, /* (i) :Subframe length. */ Word16 *gcode0, /* (o) Qxx :Predicted codebook gain */ Word16 *exp_gcode0 /* (o) :Q-Format(gcode0) */ ) { Word16 i, exp, frac; Word32 L_tmp; /*-------------------------------* * Energy coming from code * *-------------------------------*/ L_tmp = 0; for(i=0; i<L_subfr; i++) L_tmp += code[i] * code[i]; L_tmp <<= 1; /*-----------------------------------------------------------------* * Compute: means_ener - 10log10(ener_code/ L_sufr) * * Note: mean_ener change from 36 dB to 30 dB because input/2 * * * * = 30.0 - 10 log10( ener_code / lcode) + 10log10(2^27) * * !!ener_code in Q27!! * * = 30.0 - 3.0103 * log2(ener_code) + 10log10(40) + 10log10(2^27) * * = 30.0 - 3.0103 * log2(ener_code) + 16.02 + 81.278 * * = 127.298 - 3.0103 * log2(ener_code) * *-----------------------------------------------------------------*/ Log2(L_tmp, &exp, &frac); /* Q27->Q0 ^Q0 ^Q15 */ //L_tmp = Mpy_32_16(exp, frac, -24660); /* Q0 Q15 Q13 -> ^Q14 */ /* hi:Q0+Q13+1 */ /* lo:Q15+Q13-15+1 */ /* -24660[Q13]=-3.0103 */ L_tmp = (Word32)exp * -24660LL; L_tmp += ((Word16)((Word32)frac * -24660LL >> 15)); L_tmp <<= 1; //L_tmp = L_mac(L_tmp, 32588, 32); /* 32588*32[Q14]=127.298 */ L_tmp += 2085632; //32588 * 32 *2; /*-----------------------------------------------------------------* * Compute gcode0. * * = Sum(i=0,3) pred[i]*past_qua_en[i] - ener_code + mean_ener * *-----------------------------------------------------------------*/ L_tmp <<= 10; /* From Q14 to Q24 */ for(i=0; i<4; i++) L_tmp += pred[i] * past_qua_en[i] << 1; /* Q13*Q10 ->Q24 */ *gcode0 = L_tmp >> 16; /* From Q24 to Q8 */ /*-----------------------------------------------------------------* * gcode0 = pow(10.0, gcode0/20) * * = pow(2, 3.3219*gcode0/20) * * = pow(2, 0.166*gcode0) * *-----------------------------------------------------------------*/ //L_tmp = *gcode0 * 5439 << 1; /* *0.166 in Q15, result in Q24*/ //L_tmp = L_tmp >> 8; /* From Q24 to Q16 */ L_tmp = *gcode0 * 5439 >> 7; //L_Extract(L_tmp, &exp, &frac); /* Extract exponent of gcode0 */ exp = (Word16)(L_tmp >> 16); frac = (Word16)((L_tmp >> 1) - (exp << 15)); *gcode0 = (Word16)Pow2(14, frac); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16768 < Pow2() <= 32767 */ *exp_gcode0 = 14 - exp; } /*---------------------------------------------------------------------------* * Function Gain_update * * ~~~~~~~~~~~~~~~~~~~~~~ * * update table of past quantized energies * *---------------------------------------------------------------------------*/ void Gain_update( Word16 past_qua_en[], /* (io) Q10 :Past quantized energies */ Word32 L_gbk12 /* (i) Q13 : gbk1[indice1][1]+gbk2[indice2][1] */ ) { Word16 i, tmp; Word16 exp, frac; Word32 L_acc; for(i=3; i>0; i--){ past_qua_en[i] = past_qua_en[i-1]; /* Q10 */ } /*----------------------------------------------------------------------* * -- past_qua_en[0] = 20*log10(gbk1[index1][1]+gbk2[index2][1]); -- * * 2 * 10 log10( gbk1[index1][1]+gbk2[index2][1] ) * * = 2 * 3.0103 log2( gbk1[index1][1]+gbk2[index2][1] ) * * = 2 * 3.0103 log2( gbk1[index1][1]+gbk2[index2][1] ) * * 24660:Q12(6.0205) * *----------------------------------------------------------------------*/ Log2( L_gbk12, &exp, &frac ); /* L_gbk12:Q13 */ L_acc = (((Word32)(exp - 13) << 16) + ((Word32)(frac) << 1)); /* L_acc:Q16 */ tmp = extract_h( L_shl( L_acc,13 ) ); /* tmp:Q13 */ past_qua_en[0] = mult( tmp, 24660 ); /* past_qua_en[]:Q10 */ } /*---------------------------------------------------------------------------* * Function Gain_update_erasure * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * update table of past quantized energies (frame erasure) * *---------------------------------------------------------------------------* * av_pred_en = 0.0; * * for (i = 0; i < 4; i++) * * av_pred_en += past_qua_en[i]; * * av_pred_en = av_pred_en*0.25 - 4.0; * * if (av_pred_en < -14.0) av_pred_en = -14.0; * *---------------------------------------------------------------------------*/ void Gain_update_erasure( Word16 past_qua_en[] /* (i) Q10 :Past quantized energies */ ) { Word16 i, av_pred_en; Word32 L_tmp; L_tmp = 0; /* Q10 */ for(i=0; i<4; i++) L_tmp += (Word32)past_qua_en[i]; av_pred_en = (Word16)(L_tmp >> 2) - 4096; if( av_pred_en < -14336 ){ av_pred_en = -14336; /* 14336:14[Q10] */ } for(i=3; i>0; i--) past_qua_en[i] = past_qua_en[i-1]; past_qua_en[0] = av_pred_en; }
47.877005
90
0.356975
[ "vector" ]
efb68b1b028e7c3fbc8b212b820e16958c7415bb
3,385
h
C
Core/Inc/nextion.h
callidex/my12
256cbc5d838c425427d67df956569e1b88a38e6e
[ "MIT" ]
null
null
null
Core/Inc/nextion.h
callidex/my12
256cbc5d838c425427d67df956569e1b88a38e6e
[ "MIT" ]
null
null
null
Core/Inc/nextion.h
callidex/my12
256cbc5d838c425427d67df956569e1b88a38e6e
[ "MIT" ]
2
2020-11-09T12:36:17.000Z
2021-05-20T08:33:42.000Z
/* * nextion.h * * Created on: 5 Nov 2020 * Author: bob * from my Freqref project 15/09/17 */ #ifndef INC_NEXTION_H_ #define INC_NEXTION_H_ // Nextion LCD definitions volatile extern uint8_t lcdstatus; volatile extern uint8_t lcdtouched; extern uint8_t lcdrxbuffer[]; volatile extern uint8_t lcdpevent; // lcd reported a page. set to 0xff for new report volatile extern uint8_t lcd_currentpage; // binary LCD page number unsigned int dimtimer; // try to get one packet from the LCD extern void decodelcd(void); // write a number digit on the LCD to a num object extern void setndig(char *, uint8_t); // interrogate the lcd for its current display page extern int getlcdpage(void); // display a chosen page extern int setlcdpage(char *, bool); // request to read a lcd named variable (unsigned long) expects numeric value // return -1 for error extern int getlcdnvar(char *); // write to a text object extern int setlcdtext(char *, char *); // send some numbers to a lcd obj.val object, param is text extern void setlcdnum(char *, char *); // send some numbers to a lcd obj.val object, param is binary long number extern int setlcdbin(char *, unsigned long); // send a string to the LCD (len max 255) // write to the lcd extern void writelcd(char *); //write a lcd cmd extern int writelcdcmd(char *); // Nextion return status codes // Device only returns error codes unless sys var bkcmd is non zero #define NEX_SINV 0x00 // Invalid Instruction #define NEX_SOK 0x01 // successful Instruction #define NEX_SID 0x02 // Component ID invalid #define NEX_SPAGE 0x03 // Page ID invalid #define NEX_SPIC 0x04 // Picture ID Invalid #define NEX_SFONT 0x05 // Font ID Invalid #define NEX_SBAUD 0x11 // Baud Invalid #define NEX_SCURVE 0x12 // Curve ControlInvalid #define NEX_SVAR 0x1A // Variable Name Invalid #define NEX_SVOP 0x1B // Variable Operation Invalid #define NEX_SASS 0x1c // Failed to assign #define NEX_SEEP 0x1d // EEPROM op failed #define NEX_SPAR 0x1e // Parameter quantity wrong #define NEX_SIO 0x1f // IO Operation failed #define NEX_SESC 0x20 // Undefined escape char used #define NEX_SLEN 0x23 // Too long variable name #define NEX_ETOUCH 0x65 // Touch event #define NEX_EPAGE 0x66 // Current Page ID from sendme cmd #define NEX_ECOOR 0x67 // Touch coord data event #define NEX_ETSLP 0x68 // Touch event in sleep mode #define NEX_ESTR 0x70 // String variable data returns #define NEX_ENUM 0x71 // Numeric variable dat returns #define NEX_ESLEEP 0x86 // Device entered auto sleep #define NEX_EWAKE 0x87 // Device automatically woke up #define NEX_EUP 0x88 // Successful system start-up #define NEX_ESDUG 0x89 // SD card starting upgrade #define NEX_EDFIN 0xfd // Data transparent transmit finished #define NEX_EDRDY 0xfe // Data transparent transmit ready #define NEX_CRED 63488 // Red #define NEX_CBLUE 31 // Blue #define NEX_CGREY 33840 // Gray #define NEX_CBLACK 0 // Black #define NEX_CWHITE 65535 // White #define NEX_CGREEN 2016 // Green #define NEX_CBROWN 48192 // Brown #define NEX_CYELLOW 65504 // Yellow #define NEX_TRED "63488" // Red #define NEX_TBLUE "31" // Blue #define NEX_TGREY "33840" // Gray #define NEX_TBLACK "0" // Black #define NEX_TWHITE "65535" // White #define NEX_TGREEN "2016" // Green #define NEX_TBROWN "48192" // Brown #define NEX_TYELLOW "65504" // Yellow #endif /* INC_NEXTION_H_ */
31.342593
86
0.748006
[ "object" ]
efc10de35f52a46623597d419bb9b6270938a5b8
3,861
h
C
argos3/src/plugins/robots/prototype/simulator/prototype_joint_entity.h
yiftachn/krembot_sim_fork
d3d1b050f9fff4c96bded298eadde5a9ca4dab6b
[ "MIT" ]
211
2015-01-27T20:16:40.000Z
2022-02-25T03:11:13.000Z
argos3/src/plugins/robots/prototype/simulator/prototype_joint_entity.h
yiftachn/krembot_sim_fork
d3d1b050f9fff4c96bded298eadde5a9ca4dab6b
[ "MIT" ]
154
2015-02-09T20:32:38.000Z
2022-03-30T21:35:24.000Z
argos3/src/plugins/robots/prototype/simulator/prototype_joint_entity.h
yiftachn/krembot_sim_fork
d3d1b050f9fff4c96bded298eadde5a9ca4dab6b
[ "MIT" ]
128
2015-02-09T10:21:49.000Z
2022-03-31T22:24:51.000Z
/** * @file <argos3/plugins/robots/prototype/simulator/prototype_joint_entity.h> * * @author Michael Allwright - <allsey87@gmail.com> */ #ifndef PROTOTYPE_JOINT_ENTITY_H #define PROTOTYPE_JOINT_ENTITY_H namespace argos { class CPrototypeLinkEntity; class CPrototypeJointEntity; } #include <argos3/core/simulator/entity/composable_entity.h> #include <argos3/core/utility/math/quaternion.h> #include <argos3/core/utility/math/vector3.h> namespace argos { class CPrototypeJointEntity : public CComposableEntity { public: ENABLE_VTABLE(); using TVector = std::vector<CPrototypeJointEntity*>; using TVectorIterator = std::vector<CPrototypeJointEntity*>::iterator; using TVectorConstIterator = std::vector<CPrototypeJointEntity*>::const_iterator; public: enum class EType { FIXED, PRISMATIC, REVOLUTE, SPHERICAL, PLANAR, }; union ULimit { ULimit() {} CRange<Real> Prismatic; CRange<CRadians> Revolute; }; struct SActuator { enum class EMode { DISABLED, POSITION, VELOCITY, }; Real Target = 0.0f; Real MaxImpulse = 0.0f; EMode Mode = EMode::DISABLED; }; struct SSensor { enum class EMode { DISABLED, POSITION, VELOCITY, }; Real Value = 0.0f; EMode Mode = EMode::DISABLED; }; public: CPrototypeJointEntity(CComposableEntity* pc_parent); virtual ~CPrototypeJointEntity() {} virtual void Init(TConfigurationNode& t_tree); virtual std::string GetTypeDescription() const { return "joint"; } inline CPrototypeLinkEntity& GetParentLink() { return *m_pcParentLink; } inline const CPrototypeLinkEntity& GetParentLink() const { return *m_pcParentLink; } inline const CVector3& GetParentLinkJointPosition() const { return m_cParentLinkJointPosition; } inline const CQuaternion& GetParentLinkJointOrientation() const { return m_cParentLinkJointOrientation; } inline CPrototypeLinkEntity& GetChildLink() { return *m_pcChildLink; } inline const CPrototypeLinkEntity& GetChildLink() const { return *m_pcChildLink; } inline const CVector3& GetChildLinkJointPosition() const { return m_cChildLinkJointPosition; } inline const CQuaternion& GetChildLinkJointOrientation() const { return m_cChildLinkJointOrientation; } inline bool GetDisableCollision() const { return m_bDisableCollision; } inline EType GetType() const { return m_eType; } inline const CVector3& GetJointAxis() const { return m_cJointAxis; } bool HasLimit() { return m_bHasLimit; } const ULimit& GetLimit() const { ARGOS_ASSERT(m_bHasLimit == true, "CPrototypeJointEntity::GetLimit(), id=\"" << GetId() << "\": joint was not initialized with a limit"); return m_uLimit; } SSensor& GetSensor() { return m_cSensor; } SActuator& GetActuator() { return m_cActuator; } private: CPrototypeLinkEntity* m_pcParentLink; CVector3 m_cParentLinkJointPosition; CQuaternion m_cParentLinkJointOrientation; CPrototypeLinkEntity* m_pcChildLink; CVector3 m_cChildLinkJointPosition; CQuaternion m_cChildLinkJointOrientation; bool m_bDisableCollision; EType m_eType; CVector3 m_cJointAxis; bool m_bHasLimit; ULimit m_uLimit; SSensor m_cSensor; SActuator m_cActuator; }; } #endif
23.4
87
0.620565
[ "vector" ]
efc6aa66db45768a69b7a596fd964596cf48c9e1
9,763
c
C
src/arabic.c
zvezdan/vim
3215466af9abfc9fbbfba81d166d625176993486
[ "Vim" ]
518
2020-01-02T18:49:01.000Z
2022-03-16T03:18:20.000Z
src/arabic.c
zvezdan/vim
3215466af9abfc9fbbfba81d166d625176993486
[ "Vim" ]
229
2017-08-09T12:20:55.000Z
2022-03-31T15:12:18.000Z
src/arabic.c
zvezdan/vim
3215466af9abfc9fbbfba81d166d625176993486
[ "Vim" ]
39
2017-09-01T16:21:32.000Z
2022-02-08T14:57:18.000Z
/* vi:set ts=8 sts=4 sw=4 noet: * * VIM - Vi IMproved by Bram Moolenaar * * Do ":help uganda" in Vim to read copying and usage conditions. * Do ":help credits" in Vim to see a list of people who contributed. * See README.txt for an overview of the Vim source code. */ /* * arabic.c: functions for Arabic language * * Author: Nadim Shaikli & Isam Bayazidi * Farsi support and restructuring to make adding new letters easier by Ali * Gholami Rudi. Further work by Ameretat Reith. */ /* * Sorted list of unicode Arabic characters. Each entry holds the * presentation forms of a letter. * * Arabic characters are categorized into following types: * * Isolated - iso-8859-6 form * Initial - unicode form-B start * Medial - unicode form-B middle * Final - unicode form-B final * Stand-Alone - unicode form-B isolated */ #include "vim.h" #if defined(FEAT_ARABIC) || defined(PROTO) // Unicode values for Arabic characters. #define a_HAMZA 0x0621 #define a_ALEF_MADDA 0x0622 #define a_ALEF_HAMZA_ABOVE 0x0623 #define a_WAW_HAMZA 0x0624 #define a_ALEF_HAMZA_BELOW 0x0625 #define a_YEH_HAMZA 0x0626 #define a_ALEF 0x0627 #define a_BEH 0x0628 #define a_TEH_MARBUTA 0x0629 #define a_TEH 0x062a #define a_THEH 0x062b #define a_JEEM 0x062c #define a_HAH 0x062d #define a_KHAH 0x062e #define a_DAL 0x062f #define a_THAL 0x0630 #define a_REH 0x0631 #define a_ZAIN 0x0632 #define a_SEEN 0x0633 #define a_SHEEN 0x0634 #define a_SAD 0x0635 #define a_DAD 0x0636 #define a_TAH 0x0637 #define a_ZAH 0x0638 #define a_AIN 0x0639 #define a_GHAIN 0x063a #define a_TATWEEL 0x0640 #define a_FEH 0x0641 #define a_QAF 0x0642 #define a_KAF 0x0643 #define a_LAM 0x0644 #define a_MEEM 0x0645 #define a_NOON 0x0646 #define a_HEH 0x0647 #define a_WAW 0x0648 #define a_ALEF_MAKSURA 0x0649 #define a_YEH 0x064a #define a_FATHATAN 0x064b #define a_DAMMATAN 0x064c #define a_KASRATAN 0x064d #define a_FATHA 0x064e #define a_DAMMA 0x064f #define a_KASRA 0x0650 #define a_SHADDA 0x0651 #define a_SUKUN 0x0652 #define a_MADDA_ABOVE 0x0653 #define a_HAMZA_ABOVE 0x0654 #define a_HAMZA_BELOW 0x0655 #define a_PEH 0x067e #define a_TCHEH 0x0686 #define a_JEH 0x0698 #define a_FKAF 0x06a9 #define a_GAF 0x06af #define a_FYEH 0x06cc #define a_s_LAM_ALEF_MADDA_ABOVE 0xfef5 #define a_f_LAM_ALEF_MADDA_ABOVE 0xfef6 #define a_s_LAM_ALEF_HAMZA_ABOVE 0xfef7 #define a_f_LAM_ALEF_HAMZA_ABOVE 0xfef8 #define a_s_LAM_ALEF_HAMZA_BELOW 0xfef9 #define a_f_LAM_ALEF_HAMZA_BELOW 0xfefa #define a_s_LAM_ALEF 0xfefb #define a_f_LAM_ALEF 0xfefc static struct achar { unsigned c; unsigned isolated; unsigned initial; unsigned medial; unsigned final; } achars[] = { {a_HAMZA, 0xfe80, 0, 0, 0}, {a_ALEF_MADDA, 0xfe81, 0, 0, 0xfe82}, {a_ALEF_HAMZA_ABOVE, 0xfe83, 0, 0, 0xfe84}, {a_WAW_HAMZA, 0xfe85, 0, 0, 0xfe86}, {a_ALEF_HAMZA_BELOW, 0xfe87, 0, 0, 0xfe88}, {a_YEH_HAMZA, 0xfe89, 0xfe8b, 0xfe8c, 0xfe8a}, {a_ALEF, 0xfe8d, 0, 0, 0xfe8e}, {a_BEH, 0xfe8f, 0xfe91, 0xfe92, 0xfe90}, {a_TEH_MARBUTA, 0xfe93, 0, 0, 0xfe94}, {a_TEH, 0xfe95, 0xfe97, 0xfe98, 0xfe96}, {a_THEH, 0xfe99, 0xfe9b, 0xfe9c, 0xfe9a}, {a_JEEM, 0xfe9d, 0xfe9f, 0xfea0, 0xfe9e}, {a_HAH, 0xfea1, 0xfea3, 0xfea4, 0xfea2}, {a_KHAH, 0xfea5, 0xfea7, 0xfea8, 0xfea6}, {a_DAL, 0xfea9, 0, 0, 0xfeaa}, {a_THAL, 0xfeab, 0, 0, 0xfeac}, {a_REH, 0xfead, 0, 0, 0xfeae}, {a_ZAIN, 0xfeaf, 0, 0, 0xfeb0}, {a_SEEN, 0xfeb1, 0xfeb3, 0xfeb4, 0xfeb2}, {a_SHEEN, 0xfeb5, 0xfeb7, 0xfeb8, 0xfeb6}, {a_SAD, 0xfeb9, 0xfebb, 0xfebc, 0xfeba}, {a_DAD, 0xfebd, 0xfebf, 0xfec0, 0xfebe}, {a_TAH, 0xfec1, 0xfec3, 0xfec4, 0xfec2}, {a_ZAH, 0xfec5, 0xfec7, 0xfec8, 0xfec6}, {a_AIN, 0xfec9, 0xfecb, 0xfecc, 0xfeca}, {a_GHAIN, 0xfecd, 0xfecf, 0xfed0, 0xfece}, {a_TATWEEL, 0, 0x0640, 0x0640, 0x0640}, {a_FEH, 0xfed1, 0xfed3, 0xfed4, 0xfed2}, {a_QAF, 0xfed5, 0xfed7, 0xfed8, 0xfed6}, {a_KAF, 0xfed9, 0xfedb, 0xfedc, 0xfeda}, {a_LAM, 0xfedd, 0xfedf, 0xfee0, 0xfede}, {a_MEEM, 0xfee1, 0xfee3, 0xfee4, 0xfee2}, {a_NOON, 0xfee5, 0xfee7, 0xfee8, 0xfee6}, {a_HEH, 0xfee9, 0xfeeb, 0xfeec, 0xfeea}, {a_WAW, 0xfeed, 0, 0, 0xfeee}, {a_ALEF_MAKSURA, 0xfeef, 0, 0, 0xfef0}, {a_YEH, 0xfef1, 0xfef3, 0xfef4, 0xfef2}, {a_FATHATAN, 0xfe70, 0, 0, 0}, {a_DAMMATAN, 0xfe72, 0, 0, 0}, {a_KASRATAN, 0xfe74, 0, 0, 0}, {a_FATHA, 0xfe76, 0, 0xfe77, 0}, {a_DAMMA, 0xfe78, 0, 0xfe79, 0}, {a_KASRA, 0xfe7a, 0, 0xfe7b, 0}, {a_SHADDA, 0xfe7c, 0, 0xfe7c, 0}, {a_SUKUN, 0xfe7e, 0, 0xfe7f, 0}, {a_MADDA_ABOVE, 0, 0, 0, 0}, {a_HAMZA_ABOVE, 0, 0, 0, 0}, {a_HAMZA_BELOW, 0, 0, 0, 0}, {a_PEH, 0xfb56, 0xfb58, 0xfb59, 0xfb57}, {a_TCHEH, 0xfb7a, 0xfb7c, 0xfb7d, 0xfb7b}, {a_JEH, 0xfb8a, 0, 0, 0xfb8b}, {a_FKAF, 0xfb8e, 0xfb90, 0xfb91, 0xfb8f}, {a_GAF, 0xfb92, 0xfb94, 0xfb95, 0xfb93}, {a_FYEH, 0xfbfc, 0xfbfe, 0xfbff, 0xfbfd}, }; #define a_BYTE_ORDER_MARK 0xfeff #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) /* * Find the struct achar pointer to the given Arabic char. * Returns NULL if not found. */ static struct achar * find_achar(int c) { int h, m, l; // using binary search to find c h = ARRAY_SIZE(achars); l = 0; while (l < h) { m = (h + l) / 2; if (achars[m].c == (unsigned)c) return &achars[m]; if ((unsigned)c < achars[m].c) h = m; else l = m + 1; } return NULL; } /* * Change shape - from Combination (2 char) to an Isolated */ static int chg_c_laa2i(int hid_c) { int tempc; switch (hid_c) { case a_ALEF_MADDA: tempc = a_s_LAM_ALEF_MADDA_ABOVE; break; case a_ALEF_HAMZA_ABOVE: tempc = a_s_LAM_ALEF_HAMZA_ABOVE; break; case a_ALEF_HAMZA_BELOW: tempc = a_s_LAM_ALEF_HAMZA_BELOW; break; case a_ALEF: tempc = a_s_LAM_ALEF; break; default: tempc = 0; } return tempc; } /* * Change shape - from Combination-Isolated to Final */ static int chg_c_laa2f(int hid_c) { int tempc; switch (hid_c) { case a_ALEF_MADDA: tempc = a_f_LAM_ALEF_MADDA_ABOVE; break; case a_ALEF_HAMZA_ABOVE: tempc = a_f_LAM_ALEF_HAMZA_ABOVE; break; case a_ALEF_HAMZA_BELOW: tempc = a_f_LAM_ALEF_HAMZA_BELOW; break; case a_ALEF: tempc = a_f_LAM_ALEF; break; default: tempc = 0; } return tempc; } /* * Returns whether it is possible to join the given letters */ static int can_join(int c1, int c2) { struct achar *a1 = find_achar(c1); struct achar *a2 = find_achar(c2); return a1 && a2 && (a1->initial || a1->medial) && (a2->final || a2->medial); } /* * Check whether we are dealing with a character that could be regarded as an * Arabic combining character, need to check the character before this. */ int arabic_maycombine(int two) { if (p_arshape && !p_tbidi) return (two == a_ALEF_MADDA || two == a_ALEF_HAMZA_ABOVE || two == a_ALEF_HAMZA_BELOW || two == a_ALEF); return FALSE; } /* * Check whether we are dealing with Arabic combining characters. * Note: these are NOT really composing characters! */ int arabic_combine( int one, // first character int two) // character just after "one" { if (one == a_LAM) return arabic_maycombine(two); return FALSE; } /* * A_is_iso returns true if 'c' is an Arabic ISO-8859-6 character * (alphabet/number/punctuation) */ static int A_is_iso(int c) { return find_achar(c) != NULL; } /* * A_is_ok returns true if 'c' is an Arabic 10646 (8859-6 or Form-B) */ static int A_is_ok(int c) { return (A_is_iso(c) || c == a_BYTE_ORDER_MARK); } /* * A_is_valid returns true if 'c' is an Arabic 10646 (8859-6 or Form-B) * with some exceptions/exclusions */ static int A_is_valid(int c) { return (A_is_ok(c) && c != a_HAMZA); } /* * Do Arabic shaping on character "c". Returns the shaped character. * out: "ccp" points to the first byte of the character to be shaped. * in/out: "c1p" points to the first composing char for "c". * in: "prev_c" is the previous character (not shaped) * in: "prev_c1" is the first composing char for the previous char * (not shaped) * in: "next_c" is the next character (not shaped). */ int arabic_shape( int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c) { int curr_c; int curr_laa; int prev_laa; // Deal only with Arabic characters, pass back all others if (!A_is_ok(c)) return c; curr_laa = arabic_combine(c, *c1p); prev_laa = arabic_combine(prev_c, prev_c1); if (curr_laa) { if (A_is_valid(prev_c) && can_join(prev_c, a_LAM) && !prev_laa) curr_c = chg_c_laa2f(*c1p); else curr_c = chg_c_laa2i(*c1p); // Remove the composing character *c1p = 0; } else { struct achar *curr_a = find_achar(c); int backward_combine = !prev_laa && can_join(prev_c, c); int forward_combine = can_join(c, next_c); if (backward_combine) { if (forward_combine) curr_c = curr_a->medial; else curr_c = curr_a->final; } else { if (forward_combine) curr_c = curr_a->initial; else curr_c = curr_a->isolated; } } // Character missing from the table means using original character. if (curr_c == NUL) curr_c = c; if (curr_c != c && ccp != NULL) { char_u buf[MB_MAXBYTES + 1]; // Update the first byte of the character. (*mb_char2bytes)(curr_c, buf); *ccp = buf[0]; } // Return the shaped character return curr_c; } #endif // FEAT_ARABIC
24.468672
80
0.65738
[ "shape" ]
efceee5477998046597a0a610141c93a01597f12
4,264
h
C
RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerTiles.h
scodella/cmssw
974479b50b19bd795cb5f91eac872857fd6290f6
[ "Apache-2.0" ]
1
2021-04-13T13:26:16.000Z
2021-04-13T13:26:16.000Z
RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerTiles.h
scodella/cmssw
974479b50b19bd795cb5f91eac872857fd6290f6
[ "Apache-2.0" ]
2
2020-11-03T19:02:02.000Z
2020-11-10T16:44:22.000Z
RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerTiles.h
scodella/cmssw
974479b50b19bd795cb5f91eac872857fd6290f6
[ "Apache-2.0" ]
1
2020-04-01T15:30:45.000Z
2020-04-01T15:30:45.000Z
// Authors: Felice Pantaleo - felice.pantaleo@cern.ch // Date: 03/2019 #ifndef RecoLocalCalo_HGCalRecAlgos_HGCalLayerTiles #define RecoLocalCalo_HGCalRecAlgos_HGCalLayerTiles #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalTilesConstants.h" #include <vector> #include <array> #include <cmath> #include <algorithm> #include <cassert> class HGCalLayerTiles { public: void fill(const std::vector<float>& x, const std::vector<float>& y, const std::vector<float>& eta, const std::vector<float>& phi, const std::vector<bool>& isSi) { auto cellsSize = x.size(); for (unsigned int i = 0; i < cellsSize; ++i) { tiles_[getGlobalBin(x[i], y[i])].push_back(i); if (!isSi[i]) { tiles_[getGlobalBinEtaPhi(eta[i], phi[i])].push_back(i); // Copy cells in phi=[-3.15,-3.] to the last bin if (getPhiBin(phi[i]) == mPiPhiBin) { tiles_[getGlobalBinEtaPhi(eta[i], phi[i] + 2 * M_PI)].push_back(i); } // Copy cells in phi=[3.,3.15] to the first bin if (getPhiBin(phi[i]) == pPiPhiBin) { tiles_[getGlobalBinEtaPhi(eta[i], phi[i] - 2 * M_PI)].push_back(i); } } } } int getXBin(float x) const { constexpr float xRange = hgcaltilesconstants::maxX - hgcaltilesconstants::minX; static_assert(xRange >= 0.); constexpr float r = hgcaltilesconstants::nColumns / xRange; int xBin = (x - hgcaltilesconstants::minX) * r; xBin = std::clamp(xBin, 0, hgcaltilesconstants::nColumns - 1); return xBin; } int getYBin(float y) const { constexpr float yRange = hgcaltilesconstants::maxY - hgcaltilesconstants::minY; static_assert(yRange >= 0.); constexpr float r = hgcaltilesconstants::nRows / yRange; int yBin = (y - hgcaltilesconstants::minY) * r; yBin = std::clamp(yBin, 0, hgcaltilesconstants::nRows - 1); return yBin; } int getEtaBin(float eta) const { constexpr float etaRange = hgcaltilesconstants::maxEta - hgcaltilesconstants::minEta; static_assert(etaRange >= 0.); constexpr float r = hgcaltilesconstants::nColumnsEta / etaRange; int etaBin = (eta - hgcaltilesconstants::minEta) * r; etaBin = std::clamp(etaBin, 0, hgcaltilesconstants::nColumnsEta - 1); return etaBin; } int getPhiBin(float phi) const { constexpr float phiRange = hgcaltilesconstants::maxPhi - hgcaltilesconstants::minPhi; static_assert(phiRange >= 0.); constexpr float r = hgcaltilesconstants::nRowsPhi / phiRange; int phiBin = (phi - hgcaltilesconstants::minPhi) * r; phiBin = std::clamp(phiBin, 0, hgcaltilesconstants::nRowsPhi - 1); return phiBin; } int mPiPhiBin = getPhiBin(-M_PI); int pPiPhiBin = getPhiBin(M_PI); int getGlobalBin(float x, float y) const { return getXBin(x) + getYBin(y) * hgcaltilesconstants::nColumns; } int getGlobalBinByBin(int xBin, int yBin) const { return xBin + yBin * hgcaltilesconstants::nColumns; } int getGlobalBinEtaPhi(float eta, float phi) const { return hgcaltilesconstants::nColumns * hgcaltilesconstants::nRows + getEtaBin(eta) + getPhiBin(phi) * hgcaltilesconstants::nColumnsEta; } int getGlobalBinByBinEtaPhi(int etaBin, int phiBin) const { return hgcaltilesconstants::nColumns * hgcaltilesconstants::nRows + etaBin + phiBin * hgcaltilesconstants::nColumnsEta; } std::array<int, 4> searchBox(float xMin, float xMax, float yMin, float yMax) const { int xBinMin = getXBin(xMin); int xBinMax = getXBin(xMax); int yBinMin = getYBin(yMin); int yBinMax = getYBin(yMax); return std::array<int, 4>({{xBinMin, xBinMax, yBinMin, yBinMax}}); } std::array<int, 4> searchBoxEtaPhi(float etaMin, float etaMax, float phiMin, float phiMax) const { int etaBinMin = getEtaBin(etaMin); int etaBinMax = getEtaBin(etaMax); int phiBinMin = getPhiBin(phiMin); int phiBinMax = getPhiBin(phiMax); return std::array<int, 4>({{etaBinMin, etaBinMax, phiBinMin, phiBinMax}}); } void clear() { for (auto& t : tiles_) t.clear(); } const std::vector<int>& operator[](int globalBinId) const { return tiles_[globalBinId]; } private: std::array<std::vector<int>, hgcaltilesconstants::nTiles> tiles_; }; #endif
35.533333
110
0.673546
[ "vector" ]
efd30fd5521acb45c369d600a14ebd1f13a43970
337,283
c
C
ofagent/indigo/submodules/loxigen-artifacts/loci/src/class00.c
lanpinguo/apple-sauce
b16e7b78e58d0d17ad7f05476f38704a6b519ece
[ "Apache-2.0" ]
1
2021-05-14T15:33:21.000Z
2021-05-14T15:33:21.000Z
ofagent/indigo/submodules/loxigen-artifacts/loci/src/class00.c
lanpinguo/apple-sauce
b16e7b78e58d0d17ad7f05476f38704a6b519ece
[ "Apache-2.0" ]
null
null
null
ofagent/indigo/submodules/loxigen-artifacts/loci/src/class00.c
lanpinguo/apple-sauce
b16e7b78e58d0d17ad7f05476f38704a6b519ece
[ "Apache-2.0" ]
2
2019-07-13T06:58:33.000Z
2022-03-23T03:02:57.000Z
/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_action_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 0)); /* type */ switch (value) { case 0x0: *id = OF_ACTION_OUTPUT; break; case 0x1: *id = OF_ACTION_SET_VLAN_VID; break; case 0x2: *id = OF_ACTION_SET_VLAN_PCP; break; case 0x3: *id = OF_ACTION_STRIP_VLAN; break; case 0x4: *id = OF_ACTION_SET_DL_SRC; break; case 0x5: *id = OF_ACTION_SET_DL_DST; break; case 0x6: *id = OF_ACTION_SET_NW_SRC; break; case 0x7: *id = OF_ACTION_SET_NW_DST; break; case 0x8: *id = OF_ACTION_SET_NW_TOS; break; case 0x9: *id = OF_ACTION_SET_TP_SRC; break; case 0xa: *id = OF_ACTION_SET_TP_DST; break; case 0xb: *id = OF_ACTION_ENQUEUE; break; case 0xffff: of_action_experimenter_wire_object_id_get(obj, id); break; default: *id = OF_ACTION; break; } break; } case OF_VERSION_1_1: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 0)); /* type */ switch (value) { case 0x0: *id = OF_ACTION_OUTPUT; break; case 0x1: *id = OF_ACTION_SET_VLAN_VID; break; case 0x2: *id = OF_ACTION_SET_VLAN_PCP; break; case 0x3: *id = OF_ACTION_SET_DL_SRC; break; case 0x4: *id = OF_ACTION_SET_DL_DST; break; case 0x5: *id = OF_ACTION_SET_NW_SRC; break; case 0x6: *id = OF_ACTION_SET_NW_DST; break; case 0x7: *id = OF_ACTION_SET_NW_TOS; break; case 0x8: *id = OF_ACTION_SET_NW_ECN; break; case 0x9: *id = OF_ACTION_SET_TP_SRC; break; case 0xa: *id = OF_ACTION_SET_TP_DST; break; case 0xb: *id = OF_ACTION_COPY_TTL_OUT; break; case 0xc: *id = OF_ACTION_COPY_TTL_IN; break; case 0xd: *id = OF_ACTION_SET_MPLS_LABEL; break; case 0xe: *id = OF_ACTION_SET_MPLS_TC; break; case 0xf: *id = OF_ACTION_SET_MPLS_TTL; break; case 0x10: *id = OF_ACTION_DEC_MPLS_TTL; break; case 0x11: *id = OF_ACTION_PUSH_VLAN; break; case 0x12: *id = OF_ACTION_POP_VLAN; break; case 0x13: *id = OF_ACTION_PUSH_MPLS; break; case 0x14: *id = OF_ACTION_POP_MPLS; break; case 0x15: *id = OF_ACTION_SET_QUEUE; break; case 0x16: *id = OF_ACTION_GROUP; break; case 0x17: *id = OF_ACTION_SET_NW_TTL; break; case 0x18: *id = OF_ACTION_DEC_NW_TTL; break; case 0xffff: of_action_experimenter_wire_object_id_get(obj, id); break; default: *id = OF_ACTION; break; } break; } case OF_VERSION_1_2: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 0)); /* type */ switch (value) { case 0x0: *id = OF_ACTION_OUTPUT; break; case 0xb: *id = OF_ACTION_COPY_TTL_OUT; break; case 0xc: *id = OF_ACTION_COPY_TTL_IN; break; case 0xf: *id = OF_ACTION_SET_MPLS_TTL; break; case 0x10: *id = OF_ACTION_DEC_MPLS_TTL; break; case 0x11: *id = OF_ACTION_PUSH_VLAN; break; case 0x12: *id = OF_ACTION_POP_VLAN; break; case 0x13: *id = OF_ACTION_PUSH_MPLS; break; case 0x14: *id = OF_ACTION_POP_MPLS; break; case 0x15: *id = OF_ACTION_SET_QUEUE; break; case 0x16: *id = OF_ACTION_GROUP; break; case 0x17: *id = OF_ACTION_SET_NW_TTL; break; case 0x18: *id = OF_ACTION_DEC_NW_TTL; break; case 0x19: *id = OF_ACTION_SET_FIELD; break; case 0xffff: of_action_experimenter_wire_object_id_get(obj, id); break; default: *id = OF_ACTION; break; } break; } case OF_VERSION_1_3: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 0)); /* type */ switch (value) { case 0x0: *id = OF_ACTION_OUTPUT; break; case 0xb: *id = OF_ACTION_COPY_TTL_OUT; break; case 0xc: *id = OF_ACTION_COPY_TTL_IN; break; case 0xf: *id = OF_ACTION_SET_MPLS_TTL; break; case 0x10: *id = OF_ACTION_DEC_MPLS_TTL; break; case 0x11: *id = OF_ACTION_PUSH_VLAN; break; case 0x12: *id = OF_ACTION_POP_VLAN; break; case 0x13: *id = OF_ACTION_PUSH_MPLS; break; case 0x14: *id = OF_ACTION_POP_MPLS; break; case 0x15: *id = OF_ACTION_SET_QUEUE; break; case 0x16: *id = OF_ACTION_GROUP; break; case 0x17: *id = OF_ACTION_SET_NW_TTL; break; case 0x18: *id = OF_ACTION_DEC_NW_TTL; break; case 0x19: *id = OF_ACTION_SET_FIELD; break; case 0x1a: *id = OF_ACTION_PUSH_PBB; break; case 0x1b: *id = OF_ACTION_POP_PBB; break; case 0xffff: of_action_experimenter_wire_object_id_get(obj, id); break; default: *id = OF_ACTION; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_action of_action */ /** * Create a new of_action object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action */ of_action_t * of_action_new(of_version_t version) { of_action_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION] + of_object_extra_len[version][OF_ACTION]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_action. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_init(of_action_t *obj_p, of_version_t version, int bytes, int clean_wire) { of_action_header_t *obj; obj = &obj_p->header; /* Need instantiable subclass */ LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION] + of_object_extra_len[version][OF_ACTION]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION; /* Set up the object's function pointers */ obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_action_experimenter_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 4)); /* experimenter */ switch (value) { case 0x2320: of_action_nicira_wire_object_id_get(obj, id); break; case 0x5c16c7: of_action_bsn_wire_object_id_get(obj, id); break; default: *id = OF_ACTION_EXPERIMENTER; break; } break; } case OF_VERSION_1_1: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 4)); /* experimenter */ switch (value) { case 0x2320: of_action_nicira_wire_object_id_get(obj, id); break; case 0x5c16c7: of_action_bsn_wire_object_id_get(obj, id); break; default: *id = OF_ACTION_EXPERIMENTER; break; } break; } case OF_VERSION_1_2: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 4)); /* experimenter */ switch (value) { case 0x2320: of_action_nicira_wire_object_id_get(obj, id); break; case 0x5c16c7: of_action_bsn_wire_object_id_get(obj, id); break; default: *id = OF_ACTION_EXPERIMENTER; break; } break; } case OF_VERSION_1_3: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 4)); /* experimenter */ switch (value) { case 0x1018: of_action_ofdpa_wire_object_id_get(obj, id); break; case 0x2320: of_action_nicira_wire_object_id_get(obj, id); break; case 0x5c16c7: of_action_bsn_wire_object_id_get(obj, id); break; case 0x4f4e4600: of_action_onf_wire_object_id_get(obj, id); break; default: *id = OF_ACTION_EXPERIMENTER; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_action_experimenter of_action_experimenter */ /** * Create a new of_action_experimenter object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_experimenter */ of_action_experimenter_t * of_action_experimenter_new(of_version_t version) { of_action_experimenter_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_EXPERIMENTER] + of_object_extra_len[version][OF_ACTION_EXPERIMENTER]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_experimenter_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_experimenter_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_action_experimenter. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_experimenter_init(of_action_experimenter_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_EXPERIMENTER] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_EXPERIMENTER] + of_object_extra_len[version][OF_ACTION_EXPERIMENTER]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_EXPERIMENTER; /* Set up the object's function pointers */ obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get experimenter from an object of type of_action_experimenter. * @param obj Pointer to an object of type of_action_experimenter. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_experimenter_experimenter_get( of_action_experimenter_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_action_experimenter. * @param obj Pointer to an object of type of_action_experimenter. * @param experimenter The value to write into the object */ void of_action_experimenter_experimenter_set( of_action_experimenter_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get data from an object of type of_action_experimenter. * @param obj Pointer to an object of type of_action_experimenter. * @param data Pointer to the child object of type * of_octets_t to be filled out. * */ void of_action_experimenter_data_get( of_action_experimenter_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ LOCI_ASSERT(obj->object_id == OF_ACTION_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); LOCI_ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf)); data->bytes = cur_len; data->data = OF_WIRE_BUFFER_INDEX(wbuf, abs_offset); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set data in an object of type of_action_experimenter. * @param obj Pointer to an object of type of_action_experimenter. * @param data The value to write into the object */ int WARN_UNUSED_RESULT of_action_experimenter_data_set( of_action_experimenter_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ int new_len, delta; /* For set, need new length and delta */ LOCI_ASSERT(obj->object_id == OF_ACTION_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); new_len = data->bytes; of_wire_buffer_grow(wbuf, abs_offset + (new_len - cur_len)); of_wire_buffer_octets_data_set(wbuf, abs_offset, data, cur_len); /* Not scalar, update lengths if needed */ delta = new_len - cur_len; if (delta != 0) { /* Update parent(s) */ of_object_parent_length_update((of_object_t *)obj, delta); } OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_action_bsn_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* subtype */ switch (value) { case 0x1: *id = OF_ACTION_BSN_MIRROR; break; case 0x2: *id = OF_ACTION_BSN_SET_TUNNEL_DST; break; default: *id = OF_ACTION_BSN; break; } break; } case OF_VERSION_1_1: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* subtype */ switch (value) { case 0x1: *id = OF_ACTION_BSN_MIRROR; break; case 0x2: *id = OF_ACTION_BSN_SET_TUNNEL_DST; break; default: *id = OF_ACTION_BSN; break; } break; } case OF_VERSION_1_2: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* subtype */ switch (value) { case 0x1: *id = OF_ACTION_BSN_MIRROR; break; case 0x2: *id = OF_ACTION_BSN_SET_TUNNEL_DST; break; default: *id = OF_ACTION_BSN; break; } break; } case OF_VERSION_1_3: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* subtype */ switch (value) { case 0x1: *id = OF_ACTION_BSN_MIRROR; break; case 0x2: *id = OF_ACTION_BSN_SET_TUNNEL_DST; break; default: *id = OF_ACTION_BSN; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_action_bsn of_action_bsn */ /** * Create a new of_action_bsn object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_bsn */ of_action_bsn_t * of_action_bsn_new(of_version_t version) { of_action_bsn_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_BSN] + of_object_extra_len[version][OF_ACTION_BSN]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_bsn_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_bsn_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_action_bsn. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_bsn_init(of_action_bsn_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_BSN] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_BSN] + of_object_extra_len[version][OF_ACTION_BSN]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_BSN; /* Set up the object's function pointers */ obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get experimenter from an object of type of_action_bsn. * @param obj Pointer to an object of type of_action_bsn. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_experimenter_get( of_action_bsn_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_action_bsn. * @param obj Pointer to an object of type of_action_bsn. * @param experimenter The value to write into the object */ void of_action_bsn_experimenter_set( of_action_bsn_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_action_bsn. * @param obj Pointer to an object of type of_action_bsn. * @param subtype Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_subtype_get( of_action_bsn_t *obj, uint32_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_action_bsn. * @param obj Pointer to an object of type of_action_bsn. * @param subtype The value to write into the object */ void of_action_bsn_subtype_set( of_action_bsn_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_bsn_mirror_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint16_t *)(buf + 0) = U16_HTON(0xffff); /* type */ *(uint32_t *)(buf + 4) = U32_HTON(0x5c16c7); /* experimenter */ *(uint32_t *)(buf + 8) = U32_HTON(0x1); /* subtype */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_bsn_mirror of_action_bsn_mirror */ /** * Helper function to push values into the wire buffer */ static inline int of_action_bsn_mirror_push_wire_values(of_action_bsn_mirror_t *obj) { of_action_bsn_mirror_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_bsn_mirror object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_bsn_mirror */ of_action_bsn_mirror_t * of_action_bsn_mirror_new(of_version_t version) { of_action_bsn_mirror_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_BSN_MIRROR] + of_object_extra_len[version][OF_ACTION_BSN_MIRROR]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_bsn_mirror_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_bsn_mirror_init(obj, version, bytes, 0); if (of_action_bsn_mirror_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_bsn_mirror. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_bsn_mirror_init(of_action_bsn_mirror_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_BSN_MIRROR] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_BSN_MIRROR] + of_object_extra_len[version][OF_ACTION_BSN_MIRROR]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_BSN_MIRROR; /* Set up the object's function pointers */ obj->wire_type_set = of_action_bsn_mirror_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get experimenter from an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_mirror_experimenter_get( of_action_bsn_mirror_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param experimenter The value to write into the object */ void of_action_bsn_mirror_experimenter_set( of_action_bsn_mirror_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param subtype Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_mirror_subtype_get( of_action_bsn_mirror_t *obj, uint32_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param subtype The value to write into the object */ void of_action_bsn_mirror_subtype_set( of_action_bsn_mirror_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get dest_port from an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param dest_port Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_mirror_dest_port_get( of_action_bsn_mirror_t *obj, uint32_t *dest_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, dest_port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set dest_port in an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param dest_port The value to write into the object */ void of_action_bsn_mirror_dest_port_set( of_action_bsn_mirror_t *obj, uint32_t dest_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, dest_port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get vlan_tag from an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param vlan_tag Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_mirror_vlan_tag_get( of_action_bsn_mirror_t *obj, uint32_t *vlan_tag) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, vlan_tag); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set vlan_tag in an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param vlan_tag The value to write into the object */ void of_action_bsn_mirror_vlan_tag_set( of_action_bsn_mirror_t *obj, uint32_t vlan_tag) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, vlan_tag); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get copy_stage from an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param copy_stage Pointer to the child object of type * uint8_t to be filled out. * */ void of_action_bsn_mirror_copy_stage_get( of_action_bsn_mirror_t *obj, uint8_t *copy_stage) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 20; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_get(wbuf, abs_offset, copy_stage); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set copy_stage in an object of type of_action_bsn_mirror. * @param obj Pointer to an object of type of_action_bsn_mirror. * @param copy_stage The value to write into the object */ void of_action_bsn_mirror_copy_stage_set( of_action_bsn_mirror_t *obj, uint8_t copy_stage) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 20; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_set(wbuf, abs_offset, copy_stage); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_bsn_set_tunnel_dst_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint16_t *)(buf + 0) = U16_HTON(0xffff); /* type */ *(uint32_t *)(buf + 4) = U32_HTON(0x5c16c7); /* experimenter */ *(uint32_t *)(buf + 8) = U32_HTON(0x2); /* subtype */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_bsn_set_tunnel_dst of_action_bsn_set_tunnel_dst */ /** * Helper function to push values into the wire buffer */ static inline int of_action_bsn_set_tunnel_dst_push_wire_values(of_action_bsn_set_tunnel_dst_t *obj) { of_action_bsn_set_tunnel_dst_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_bsn_set_tunnel_dst object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_bsn_set_tunnel_dst */ of_action_bsn_set_tunnel_dst_t * of_action_bsn_set_tunnel_dst_new(of_version_t version) { of_action_bsn_set_tunnel_dst_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_BSN_SET_TUNNEL_DST] + of_object_extra_len[version][OF_ACTION_BSN_SET_TUNNEL_DST]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_bsn_set_tunnel_dst_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_bsn_set_tunnel_dst_init(obj, version, bytes, 0); if (of_action_bsn_set_tunnel_dst_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_bsn_set_tunnel_dst. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_bsn_set_tunnel_dst_init(of_action_bsn_set_tunnel_dst_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_BSN_SET_TUNNEL_DST] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_BSN_SET_TUNNEL_DST] + of_object_extra_len[version][OF_ACTION_BSN_SET_TUNNEL_DST]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_BSN_SET_TUNNEL_DST; /* Set up the object's function pointers */ obj->wire_type_set = of_action_bsn_set_tunnel_dst_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get experimenter from an object of type of_action_bsn_set_tunnel_dst. * @param obj Pointer to an object of type of_action_bsn_set_tunnel_dst. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_set_tunnel_dst_experimenter_get( of_action_bsn_set_tunnel_dst_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_SET_TUNNEL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_action_bsn_set_tunnel_dst. * @param obj Pointer to an object of type of_action_bsn_set_tunnel_dst. * @param experimenter The value to write into the object */ void of_action_bsn_set_tunnel_dst_experimenter_set( of_action_bsn_set_tunnel_dst_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_SET_TUNNEL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_action_bsn_set_tunnel_dst. * @param obj Pointer to an object of type of_action_bsn_set_tunnel_dst. * @param subtype Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_set_tunnel_dst_subtype_get( of_action_bsn_set_tunnel_dst_t *obj, uint32_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_SET_TUNNEL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_action_bsn_set_tunnel_dst. * @param obj Pointer to an object of type of_action_bsn_set_tunnel_dst. * @param subtype The value to write into the object */ void of_action_bsn_set_tunnel_dst_subtype_set( of_action_bsn_set_tunnel_dst_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_SET_TUNNEL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get dst from an object of type of_action_bsn_set_tunnel_dst. * @param obj Pointer to an object of type of_action_bsn_set_tunnel_dst. * @param dst Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_bsn_set_tunnel_dst_dst_get( of_action_bsn_set_tunnel_dst_t *obj, uint32_t *dst) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_SET_TUNNEL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, dst); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set dst in an object of type of_action_bsn_set_tunnel_dst. * @param obj Pointer to an object of type of_action_bsn_set_tunnel_dst. * @param dst The value to write into the object */ void of_action_bsn_set_tunnel_dst_dst_set( of_action_bsn_set_tunnel_dst_t *obj, uint32_t dst) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_BSN_SET_TUNNEL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, dst); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_enqueue_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint16_t *)(buf + 0) = U16_HTON(0xb); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_enqueue of_action_enqueue */ /** * Helper function to push values into the wire buffer */ static inline int of_action_enqueue_push_wire_values(of_action_enqueue_t *obj) { of_action_enqueue_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_enqueue object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_enqueue */ of_action_enqueue_t * of_action_enqueue_new(of_version_t version) { of_action_enqueue_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_ENQUEUE] + of_object_extra_len[version][OF_ACTION_ENQUEUE]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_enqueue_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_enqueue_init(obj, version, bytes, 0); if (of_action_enqueue_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_enqueue. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_enqueue_init(of_action_enqueue_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_ENQUEUE] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_ENQUEUE] + of_object_extra_len[version][OF_ACTION_ENQUEUE]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_ENQUEUE; /* Set up the object's function pointers */ obj->wire_type_set = of_action_enqueue_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get port from an object of type of_action_enqueue. * @param obj Pointer to an object of type of_action_enqueue. * @param port Pointer to the child object of type * of_port_no_t to be filled out. * */ void of_action_enqueue_port_get( of_action_enqueue_t *obj, of_port_no_t *port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_ENQUEUE); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_port_no_get(ver, wbuf, abs_offset, port); OF_PORT_NO_VALUE_CHECK(*port, ver); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set port in an object of type of_action_enqueue. * @param obj Pointer to an object of type of_action_enqueue. * @param port The value to write into the object */ void of_action_enqueue_port_set( of_action_enqueue_t *obj, of_port_no_t port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_ENQUEUE); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_port_no_set(ver, wbuf, abs_offset, port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get queue_id from an object of type of_action_enqueue. * @param obj Pointer to an object of type of_action_enqueue. * @param queue_id Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_enqueue_queue_id_get( of_action_enqueue_t *obj, uint32_t *queue_id) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_ENQUEUE); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, queue_id); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set queue_id in an object of type of_action_enqueue. * @param obj Pointer to an object of type of_action_enqueue. * @param queue_id The value to write into the object */ void of_action_enqueue_queue_id_set( of_action_enqueue_t *obj, uint32_t queue_id) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_ENQUEUE); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, queue_id); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_action_nicira_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* subtype */ switch (value) { case 0x12: *id = OF_ACTION_NICIRA_DEC_TTL; break; default: *id = OF_ACTION_NICIRA; break; } break; } case OF_VERSION_1_1: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* subtype */ switch (value) { case 0x12: *id = OF_ACTION_NICIRA_DEC_TTL; break; default: *id = OF_ACTION_NICIRA; break; } break; } case OF_VERSION_1_2: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* subtype */ switch (value) { case 0x12: *id = OF_ACTION_NICIRA_DEC_TTL; break; default: *id = OF_ACTION_NICIRA; break; } break; } case OF_VERSION_1_3: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* subtype */ switch (value) { case 0x12: *id = OF_ACTION_NICIRA_DEC_TTL; break; default: *id = OF_ACTION_NICIRA; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_action_nicira of_action_nicira */ /** * Create a new of_action_nicira object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_nicira */ of_action_nicira_t * of_action_nicira_new(of_version_t version) { of_action_nicira_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_NICIRA] + of_object_extra_len[version][OF_ACTION_NICIRA]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_nicira_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_nicira_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_action_nicira. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_nicira_init(of_action_nicira_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_NICIRA] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_NICIRA] + of_object_extra_len[version][OF_ACTION_NICIRA]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_NICIRA; /* Set up the object's function pointers */ obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get experimenter from an object of type of_action_nicira. * @param obj Pointer to an object of type of_action_nicira. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_nicira_experimenter_get( of_action_nicira_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_action_nicira. * @param obj Pointer to an object of type of_action_nicira. * @param experimenter The value to write into the object */ void of_action_nicira_experimenter_set( of_action_nicira_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_action_nicira. * @param obj Pointer to an object of type of_action_nicira. * @param subtype Pointer to the child object of type * uint16_t to be filled out. * */ void of_action_nicira_subtype_get( of_action_nicira_t *obj, uint16_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_action_nicira. * @param obj Pointer to an object of type of_action_nicira. * @param subtype The value to write into the object */ void of_action_nicira_subtype_set( of_action_nicira_t *obj, uint16_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_nicira_dec_ttl_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint16_t *)(buf + 0) = U16_HTON(0xffff); /* type */ *(uint32_t *)(buf + 4) = U32_HTON(0x2320); /* experimenter */ *(uint16_t *)(buf + 8) = U16_HTON(0x12); /* subtype */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_nicira_dec_ttl of_action_nicira_dec_ttl */ /** * Helper function to push values into the wire buffer */ static inline int of_action_nicira_dec_ttl_push_wire_values(of_action_nicira_dec_ttl_t *obj) { of_action_nicira_dec_ttl_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_nicira_dec_ttl object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_nicira_dec_ttl */ of_action_nicira_dec_ttl_t * of_action_nicira_dec_ttl_new(of_version_t version) { of_action_nicira_dec_ttl_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_NICIRA_DEC_TTL] + of_object_extra_len[version][OF_ACTION_NICIRA_DEC_TTL]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_nicira_dec_ttl_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_nicira_dec_ttl_init(obj, version, bytes, 0); if (of_action_nicira_dec_ttl_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_nicira_dec_ttl. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_nicira_dec_ttl_init(of_action_nicira_dec_ttl_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_NICIRA_DEC_TTL] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_NICIRA_DEC_TTL] + of_object_extra_len[version][OF_ACTION_NICIRA_DEC_TTL]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_NICIRA_DEC_TTL; /* Set up the object's function pointers */ obj->wire_type_set = of_action_nicira_dec_ttl_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get experimenter from an object of type of_action_nicira_dec_ttl. * @param obj Pointer to an object of type of_action_nicira_dec_ttl. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_nicira_dec_ttl_experimenter_get( of_action_nicira_dec_ttl_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA_DEC_TTL); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_action_nicira_dec_ttl. * @param obj Pointer to an object of type of_action_nicira_dec_ttl. * @param experimenter The value to write into the object */ void of_action_nicira_dec_ttl_experimenter_set( of_action_nicira_dec_ttl_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA_DEC_TTL); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_action_nicira_dec_ttl. * @param obj Pointer to an object of type of_action_nicira_dec_ttl. * @param subtype Pointer to the child object of type * uint16_t to be filled out. * */ void of_action_nicira_dec_ttl_subtype_get( of_action_nicira_dec_ttl_t *obj, uint16_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA_DEC_TTL); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_action_nicira_dec_ttl. * @param obj Pointer to an object of type of_action_nicira_dec_ttl. * @param subtype The value to write into the object */ void of_action_nicira_dec_ttl_subtype_set( of_action_nicira_dec_ttl_t *obj, uint16_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_NICIRA_DEC_TTL); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_output_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint16_t *)(buf + 0) = U16_HTON(0x0); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_output of_action_output */ /** * Helper function to push values into the wire buffer */ static inline int of_action_output_push_wire_values(of_action_output_t *obj) { of_action_output_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_output object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_output */ of_action_output_t * of_action_output_new(of_version_t version) { of_action_output_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_OUTPUT] + of_object_extra_len[version][OF_ACTION_OUTPUT]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_output_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_output_init(obj, version, bytes, 0); if (of_action_output_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_output. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_output_init(of_action_output_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_OUTPUT] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_OUTPUT] + of_object_extra_len[version][OF_ACTION_OUTPUT]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_OUTPUT; /* Set up the object's function pointers */ obj->wire_type_set = of_action_output_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get port from an object of type of_action_output. * @param obj Pointer to an object of type of_action_output. * @param port Pointer to the child object of type * of_port_no_t to be filled out. * */ void of_action_output_port_get( of_action_output_t *obj, of_port_no_t *port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_OUTPUT); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 4; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_port_no_get(ver, wbuf, abs_offset, port); OF_PORT_NO_VALUE_CHECK(*port, ver); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set port in an object of type of_action_output. * @param obj Pointer to an object of type of_action_output. * @param port The value to write into the object */ void of_action_output_port_set( of_action_output_t *obj, of_port_no_t port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_OUTPUT); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 4; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_port_no_set(ver, wbuf, abs_offset, port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get max_len from an object of type of_action_output. * @param obj Pointer to an object of type of_action_output. * @param max_len Pointer to the child object of type * uint16_t to be filled out. * */ void of_action_output_max_len_get( of_action_output_t *obj, uint16_t *max_len) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_OUTPUT); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 6; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, max_len); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set max_len in an object of type of_action_output. * @param obj Pointer to an object of type of_action_output. * @param max_len The value to write into the object */ void of_action_output_max_len_set( of_action_output_t *obj, uint16_t max_len) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_OUTPUT); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 6; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, max_len); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_dl_dst_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint16_t *)(buf + 0) = U16_HTON(0x5); /* type */ break; case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x4); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_dl_dst of_action_set_dl_dst */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_dl_dst_push_wire_values(of_action_set_dl_dst_t *obj) { of_action_set_dl_dst_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_dl_dst object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_dl_dst */ of_action_set_dl_dst_t * of_action_set_dl_dst_new(of_version_t version) { of_action_set_dl_dst_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_DL_DST] + of_object_extra_len[version][OF_ACTION_SET_DL_DST]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_dl_dst_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_dl_dst_init(obj, version, bytes, 0); if (of_action_set_dl_dst_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_dl_dst. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_dl_dst_init(of_action_set_dl_dst_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_DL_DST] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_DL_DST] + of_object_extra_len[version][OF_ACTION_SET_DL_DST]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_DL_DST; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_dl_dst_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get dl_addr from an object of type of_action_set_dl_dst. * @param obj Pointer to an object of type of_action_set_dl_dst. * @param dl_addr Pointer to the child object of type * of_mac_addr_t to be filled out. * */ void of_action_set_dl_dst_dl_addr_get( of_action_set_dl_dst_t *obj, of_mac_addr_t *dl_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_DL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_mac_get(wbuf, abs_offset, dl_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set dl_addr in an object of type of_action_set_dl_dst. * @param obj Pointer to an object of type of_action_set_dl_dst. * @param dl_addr The value to write into the object */ void of_action_set_dl_dst_dl_addr_set( of_action_set_dl_dst_t *obj, of_mac_addr_t dl_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_DL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_mac_set(wbuf, abs_offset, dl_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_dl_src_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint16_t *)(buf + 0) = U16_HTON(0x4); /* type */ break; case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x3); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_dl_src of_action_set_dl_src */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_dl_src_push_wire_values(of_action_set_dl_src_t *obj) { of_action_set_dl_src_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_dl_src object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_dl_src */ of_action_set_dl_src_t * of_action_set_dl_src_new(of_version_t version) { of_action_set_dl_src_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_DL_SRC] + of_object_extra_len[version][OF_ACTION_SET_DL_SRC]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_dl_src_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_dl_src_init(obj, version, bytes, 0); if (of_action_set_dl_src_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_dl_src. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_dl_src_init(of_action_set_dl_src_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_DL_SRC] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_DL_SRC] + of_object_extra_len[version][OF_ACTION_SET_DL_SRC]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_DL_SRC; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_dl_src_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get dl_addr from an object of type of_action_set_dl_src. * @param obj Pointer to an object of type of_action_set_dl_src. * @param dl_addr Pointer to the child object of type * of_mac_addr_t to be filled out. * */ void of_action_set_dl_src_dl_addr_get( of_action_set_dl_src_t *obj, of_mac_addr_t *dl_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_DL_SRC); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_mac_get(wbuf, abs_offset, dl_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set dl_addr in an object of type of_action_set_dl_src. * @param obj Pointer to an object of type of_action_set_dl_src. * @param dl_addr The value to write into the object */ void of_action_set_dl_src_dl_addr_set( of_action_set_dl_src_t *obj, of_mac_addr_t dl_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_DL_SRC); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_mac_set(wbuf, abs_offset, dl_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_nw_dst_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint16_t *)(buf + 0) = U16_HTON(0x7); /* type */ break; case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x6); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_nw_dst of_action_set_nw_dst */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_nw_dst_push_wire_values(of_action_set_nw_dst_t *obj) { of_action_set_nw_dst_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_nw_dst object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_nw_dst */ of_action_set_nw_dst_t * of_action_set_nw_dst_new(of_version_t version) { of_action_set_nw_dst_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_NW_DST] + of_object_extra_len[version][OF_ACTION_SET_NW_DST]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_nw_dst_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_nw_dst_init(obj, version, bytes, 0); if (of_action_set_nw_dst_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_nw_dst. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_nw_dst_init(of_action_set_nw_dst_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_NW_DST] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_NW_DST] + of_object_extra_len[version][OF_ACTION_SET_NW_DST]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_NW_DST; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_nw_dst_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get nw_addr from an object of type of_action_set_nw_dst. * @param obj Pointer to an object of type of_action_set_nw_dst. * @param nw_addr Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_set_nw_dst_nw_addr_get( of_action_set_nw_dst_t *obj, uint32_t *nw_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_NW_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, nw_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set nw_addr in an object of type of_action_set_nw_dst. * @param obj Pointer to an object of type of_action_set_nw_dst. * @param nw_addr The value to write into the object */ void of_action_set_nw_dst_nw_addr_set( of_action_set_nw_dst_t *obj, uint32_t nw_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_NW_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, nw_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_nw_src_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint16_t *)(buf + 0) = U16_HTON(0x6); /* type */ break; case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x5); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_nw_src of_action_set_nw_src */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_nw_src_push_wire_values(of_action_set_nw_src_t *obj) { of_action_set_nw_src_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_nw_src object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_nw_src */ of_action_set_nw_src_t * of_action_set_nw_src_new(of_version_t version) { of_action_set_nw_src_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_NW_SRC] + of_object_extra_len[version][OF_ACTION_SET_NW_SRC]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_nw_src_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_nw_src_init(obj, version, bytes, 0); if (of_action_set_nw_src_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_nw_src. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_nw_src_init(of_action_set_nw_src_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_NW_SRC] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_NW_SRC] + of_object_extra_len[version][OF_ACTION_SET_NW_SRC]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_NW_SRC; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_nw_src_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get nw_addr from an object of type of_action_set_nw_src. * @param obj Pointer to an object of type of_action_set_nw_src. * @param nw_addr Pointer to the child object of type * uint32_t to be filled out. * */ void of_action_set_nw_src_nw_addr_get( of_action_set_nw_src_t *obj, uint32_t *nw_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_NW_SRC); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, nw_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set nw_addr in an object of type of_action_set_nw_src. * @param obj Pointer to an object of type of_action_set_nw_src. * @param nw_addr The value to write into the object */ void of_action_set_nw_src_nw_addr_set( of_action_set_nw_src_t *obj, uint32_t nw_addr) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_NW_SRC); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, nw_addr); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_nw_tos_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint16_t *)(buf + 0) = U16_HTON(0x8); /* type */ break; case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x7); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_nw_tos of_action_set_nw_tos */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_nw_tos_push_wire_values(of_action_set_nw_tos_t *obj) { of_action_set_nw_tos_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_nw_tos object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_nw_tos */ of_action_set_nw_tos_t * of_action_set_nw_tos_new(of_version_t version) { of_action_set_nw_tos_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_NW_TOS] + of_object_extra_len[version][OF_ACTION_SET_NW_TOS]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_nw_tos_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_nw_tos_init(obj, version, bytes, 0); if (of_action_set_nw_tos_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_nw_tos. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_nw_tos_init(of_action_set_nw_tos_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_NW_TOS] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_NW_TOS] + of_object_extra_len[version][OF_ACTION_SET_NW_TOS]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_NW_TOS; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_nw_tos_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get nw_tos from an object of type of_action_set_nw_tos. * @param obj Pointer to an object of type of_action_set_nw_tos. * @param nw_tos Pointer to the child object of type * uint8_t to be filled out. * */ void of_action_set_nw_tos_nw_tos_get( of_action_set_nw_tos_t *obj, uint8_t *nw_tos) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_NW_TOS); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_get(wbuf, abs_offset, nw_tos); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set nw_tos in an object of type of_action_set_nw_tos. * @param obj Pointer to an object of type of_action_set_nw_tos. * @param nw_tos The value to write into the object */ void of_action_set_nw_tos_nw_tos_set( of_action_set_nw_tos_t *obj, uint8_t nw_tos) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_NW_TOS); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_set(wbuf, abs_offset, nw_tos); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_tp_dst_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0xa); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_tp_dst of_action_set_tp_dst */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_tp_dst_push_wire_values(of_action_set_tp_dst_t *obj) { of_action_set_tp_dst_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_tp_dst object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_tp_dst */ of_action_set_tp_dst_t * of_action_set_tp_dst_new(of_version_t version) { of_action_set_tp_dst_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_TP_DST] + of_object_extra_len[version][OF_ACTION_SET_TP_DST]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_tp_dst_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_tp_dst_init(obj, version, bytes, 0); if (of_action_set_tp_dst_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_tp_dst. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_tp_dst_init(of_action_set_tp_dst_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_TP_DST] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_TP_DST] + of_object_extra_len[version][OF_ACTION_SET_TP_DST]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_TP_DST; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_tp_dst_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get tp_port from an object of type of_action_set_tp_dst. * @param obj Pointer to an object of type of_action_set_tp_dst. * @param tp_port Pointer to the child object of type * uint16_t to be filled out. * */ void of_action_set_tp_dst_tp_port_get( of_action_set_tp_dst_t *obj, uint16_t *tp_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_TP_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, tp_port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set tp_port in an object of type of_action_set_tp_dst. * @param obj Pointer to an object of type of_action_set_tp_dst. * @param tp_port The value to write into the object */ void of_action_set_tp_dst_tp_port_set( of_action_set_tp_dst_t *obj, uint16_t tp_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_TP_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, tp_port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_tp_src_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x9); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_tp_src of_action_set_tp_src */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_tp_src_push_wire_values(of_action_set_tp_src_t *obj) { of_action_set_tp_src_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_tp_src object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_tp_src */ of_action_set_tp_src_t * of_action_set_tp_src_new(of_version_t version) { of_action_set_tp_src_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_TP_SRC] + of_object_extra_len[version][OF_ACTION_SET_TP_SRC]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_tp_src_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_tp_src_init(obj, version, bytes, 0); if (of_action_set_tp_src_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_tp_src. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_tp_src_init(of_action_set_tp_src_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_TP_SRC] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_TP_SRC] + of_object_extra_len[version][OF_ACTION_SET_TP_SRC]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_TP_SRC; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_tp_src_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get tp_port from an object of type of_action_set_tp_src. * @param obj Pointer to an object of type of_action_set_tp_src. * @param tp_port Pointer to the child object of type * uint16_t to be filled out. * */ void of_action_set_tp_src_tp_port_get( of_action_set_tp_src_t *obj, uint16_t *tp_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_TP_SRC); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, tp_port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set tp_port in an object of type of_action_set_tp_src. * @param obj Pointer to an object of type of_action_set_tp_src. * @param tp_port The value to write into the object */ void of_action_set_tp_src_tp_port_set( of_action_set_tp_src_t *obj, uint16_t tp_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_TP_SRC); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, tp_port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_vlan_pcp_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x2); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_vlan_pcp of_action_set_vlan_pcp */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_vlan_pcp_push_wire_values(of_action_set_vlan_pcp_t *obj) { of_action_set_vlan_pcp_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_vlan_pcp object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_vlan_pcp */ of_action_set_vlan_pcp_t * of_action_set_vlan_pcp_new(of_version_t version) { of_action_set_vlan_pcp_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_VLAN_PCP] + of_object_extra_len[version][OF_ACTION_SET_VLAN_PCP]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_vlan_pcp_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_vlan_pcp_init(obj, version, bytes, 0); if (of_action_set_vlan_pcp_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_vlan_pcp. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_vlan_pcp_init(of_action_set_vlan_pcp_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_VLAN_PCP] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_VLAN_PCP] + of_object_extra_len[version][OF_ACTION_SET_VLAN_PCP]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_VLAN_PCP; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_vlan_pcp_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get vlan_pcp from an object of type of_action_set_vlan_pcp. * @param obj Pointer to an object of type of_action_set_vlan_pcp. * @param vlan_pcp Pointer to the child object of type * uint8_t to be filled out. * */ void of_action_set_vlan_pcp_vlan_pcp_get( of_action_set_vlan_pcp_t *obj, uint8_t *vlan_pcp) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_VLAN_PCP); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_get(wbuf, abs_offset, vlan_pcp); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set vlan_pcp in an object of type of_action_set_vlan_pcp. * @param obj Pointer to an object of type of_action_set_vlan_pcp. * @param vlan_pcp The value to write into the object */ void of_action_set_vlan_pcp_vlan_pcp_set( of_action_set_vlan_pcp_t *obj, uint8_t vlan_pcp) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_VLAN_PCP); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_set(wbuf, abs_offset, vlan_pcp); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_set_vlan_vid_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: *(uint16_t *)(buf + 0) = U16_HTON(0x1); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_set_vlan_vid of_action_set_vlan_vid */ /** * Helper function to push values into the wire buffer */ static inline int of_action_set_vlan_vid_push_wire_values(of_action_set_vlan_vid_t *obj) { of_action_set_vlan_vid_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_set_vlan_vid object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_set_vlan_vid */ of_action_set_vlan_vid_t * of_action_set_vlan_vid_new(of_version_t version) { of_action_set_vlan_vid_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_SET_VLAN_VID] + of_object_extra_len[version][OF_ACTION_SET_VLAN_VID]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_set_vlan_vid_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_set_vlan_vid_init(obj, version, bytes, 0); if (of_action_set_vlan_vid_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_set_vlan_vid. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_set_vlan_vid_init(of_action_set_vlan_vid_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_SET_VLAN_VID] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_SET_VLAN_VID] + of_object_extra_len[version][OF_ACTION_SET_VLAN_VID]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_SET_VLAN_VID; /* Set up the object's function pointers */ obj->wire_type_set = of_action_set_vlan_vid_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get vlan_vid from an object of type of_action_set_vlan_vid. * @param obj Pointer to an object of type of_action_set_vlan_vid. * @param vlan_vid Pointer to the child object of type * uint16_t to be filled out. * */ void of_action_set_vlan_vid_vlan_vid_get( of_action_set_vlan_vid_t *obj, uint16_t *vlan_vid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_VLAN_VID); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, vlan_vid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set vlan_vid in an object of type of_action_set_vlan_vid. * @param obj Pointer to an object of type of_action_set_vlan_vid. * @param vlan_vid The value to write into the object */ void of_action_set_vlan_vid_vlan_vid_set( of_action_set_vlan_vid_t *obj, uint16_t vlan_vid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ACTION_SET_VLAN_VID); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, vlan_vid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_action_strip_vlan_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint16_t *)(buf + 0) = U16_HTON(0x3); /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_action_strip_vlan of_action_strip_vlan */ /** * Helper function to push values into the wire buffer */ static inline int of_action_strip_vlan_push_wire_values(of_action_strip_vlan_t *obj) { of_action_strip_vlan_push_wire_types(obj); /* TLV obj; set length */ of_tlv16_wire_length_set((of_object_t *)obj, obj->length); return OF_ERROR_NONE; } /** * Create a new of_action_strip_vlan object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_action_strip_vlan */ of_action_strip_vlan_t * of_action_strip_vlan_new(of_version_t version) { of_action_strip_vlan_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ACTION_STRIP_VLAN] + of_object_extra_len[version][OF_ACTION_STRIP_VLAN]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_action_strip_vlan_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_action_strip_vlan_init(obj, version, bytes, 0); if (of_action_strip_vlan_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_action_strip_vlan. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_action_strip_vlan_init(of_action_strip_vlan_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ACTION_STRIP_VLAN] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ACTION_STRIP_VLAN] + of_object_extra_len[version][OF_ACTION_STRIP_VLAN]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ACTION_STRIP_VLAN; /* Set up the object's function pointers */ obj->wire_type_set = of_action_strip_vlan_push_wire_types; obj->wire_length_set = of_tlv16_wire_length_set; obj->wire_length_get = of_tlv16_wire_length_get; obj->wire_type_get = of_action_wire_object_id_get; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_header_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint8_t value = *(uint8_t *)(buf + 1); /* type */ switch (value) { case 0x0: *id = OF_HELLO; break; case 0x1: of_error_msg_wire_object_id_get(obj, id); break; case 0x2: *id = OF_ECHO_REQUEST; break; case 0x3: *id = OF_ECHO_REPLY; break; case 0x4: of_experimenter_wire_object_id_get(obj, id); break; case 0x5: *id = OF_FEATURES_REQUEST; break; case 0x6: *id = OF_FEATURES_REPLY; break; case 0x7: *id = OF_GET_CONFIG_REQUEST; break; case 0x8: *id = OF_GET_CONFIG_REPLY; break; case 0x9: *id = OF_SET_CONFIG; break; case 0xa: *id = OF_PACKET_IN; break; case 0xb: *id = OF_FLOW_REMOVED; break; case 0xc: *id = OF_PORT_STATUS; break; case 0xd: *id = OF_PACKET_OUT; break; case 0xe: of_flow_mod_wire_object_id_get(obj, id); break; case 0xf: *id = OF_PORT_MOD; break; case 0x10: of_stats_request_wire_object_id_get(obj, id); break; case 0x11: of_stats_reply_wire_object_id_get(obj, id); break; case 0x12: *id = OF_BARRIER_REQUEST; break; case 0x13: *id = OF_BARRIER_REPLY; break; case 0x14: *id = OF_QUEUE_GET_CONFIG_REQUEST; break; case 0x15: *id = OF_QUEUE_GET_CONFIG_REPLY; break; case 0x16: *id = OF_TABLE_MOD; break; default: *id = OF_HEADER; break; } break; } case OF_VERSION_1_1: { uint8_t value = *(uint8_t *)(buf + 1); /* type */ switch (value) { case 0x0: *id = OF_HELLO; break; case 0x1: of_error_msg_wire_object_id_get(obj, id); break; case 0x2: *id = OF_ECHO_REQUEST; break; case 0x3: *id = OF_ECHO_REPLY; break; case 0x4: of_experimenter_wire_object_id_get(obj, id); break; case 0x5: *id = OF_FEATURES_REQUEST; break; case 0x6: *id = OF_FEATURES_REPLY; break; case 0x7: *id = OF_GET_CONFIG_REQUEST; break; case 0x8: *id = OF_GET_CONFIG_REPLY; break; case 0x9: *id = OF_SET_CONFIG; break; case 0xa: *id = OF_PACKET_IN; break; case 0xb: *id = OF_FLOW_REMOVED; break; case 0xc: *id = OF_PORT_STATUS; break; case 0xd: *id = OF_PACKET_OUT; break; case 0xe: of_flow_mod_wire_object_id_get(obj, id); break; case 0xf: of_group_mod_wire_object_id_get(obj, id); break; case 0x10: *id = OF_PORT_MOD; break; case 0x11: *id = OF_TABLE_MOD; break; case 0x12: of_stats_request_wire_object_id_get(obj, id); break; case 0x13: of_stats_reply_wire_object_id_get(obj, id); break; case 0x14: *id = OF_BARRIER_REQUEST; break; case 0x15: *id = OF_BARRIER_REPLY; break; case 0x16: *id = OF_QUEUE_GET_CONFIG_REQUEST; break; case 0x17: *id = OF_QUEUE_GET_CONFIG_REPLY; break; default: *id = OF_HEADER; break; } break; } case OF_VERSION_1_2: { uint8_t value = *(uint8_t *)(buf + 1); /* type */ switch (value) { case 0x0: *id = OF_HELLO; break; case 0x1: of_error_msg_wire_object_id_get(obj, id); break; case 0x2: *id = OF_ECHO_REQUEST; break; case 0x3: *id = OF_ECHO_REPLY; break; case 0x4: of_experimenter_wire_object_id_get(obj, id); break; case 0x5: *id = OF_FEATURES_REQUEST; break; case 0x6: *id = OF_FEATURES_REPLY; break; case 0x7: *id = OF_GET_CONFIG_REQUEST; break; case 0x8: *id = OF_GET_CONFIG_REPLY; break; case 0x9: *id = OF_SET_CONFIG; break; case 0xa: *id = OF_PACKET_IN; break; case 0xb: *id = OF_FLOW_REMOVED; break; case 0xc: *id = OF_PORT_STATUS; break; case 0xd: *id = OF_PACKET_OUT; break; case 0xe: of_flow_mod_wire_object_id_get(obj, id); break; case 0xf: of_group_mod_wire_object_id_get(obj, id); break; case 0x10: *id = OF_PORT_MOD; break; case 0x11: *id = OF_TABLE_MOD; break; case 0x12: of_stats_request_wire_object_id_get(obj, id); break; case 0x13: of_stats_reply_wire_object_id_get(obj, id); break; case 0x14: *id = OF_BARRIER_REQUEST; break; case 0x15: *id = OF_BARRIER_REPLY; break; case 0x16: *id = OF_QUEUE_GET_CONFIG_REQUEST; break; case 0x17: *id = OF_QUEUE_GET_CONFIG_REPLY; break; case 0x18: *id = OF_ROLE_REQUEST; break; case 0x19: *id = OF_ROLE_REPLY; break; default: *id = OF_HEADER; break; } break; } case OF_VERSION_1_3: { uint8_t value = *(uint8_t *)(buf + 1); /* type */ switch (value) { case 0x0: *id = OF_HELLO; break; case 0x1: of_error_msg_wire_object_id_get(obj, id); break; case 0x2: *id = OF_ECHO_REQUEST; break; case 0x3: *id = OF_ECHO_REPLY; break; case 0x4: of_experimenter_wire_object_id_get(obj, id); break; case 0x5: *id = OF_FEATURES_REQUEST; break; case 0x6: *id = OF_FEATURES_REPLY; break; case 0x7: *id = OF_GET_CONFIG_REQUEST; break; case 0x8: *id = OF_GET_CONFIG_REPLY; break; case 0x9: *id = OF_SET_CONFIG; break; case 0xa: *id = OF_PACKET_IN; break; case 0xb: *id = OF_FLOW_REMOVED; break; case 0xc: *id = OF_PORT_STATUS; break; case 0xd: *id = OF_PACKET_OUT; break; case 0xe: of_flow_mod_wire_object_id_get(obj, id); break; case 0xf: of_group_mod_wire_object_id_get(obj, id); break; case 0x10: *id = OF_PORT_MOD; break; case 0x11: *id = OF_TABLE_MOD; break; case 0x12: of_stats_request_wire_object_id_get(obj, id); break; case 0x13: of_stats_reply_wire_object_id_get(obj, id); break; case 0x14: *id = OF_BARRIER_REQUEST; break; case 0x15: *id = OF_BARRIER_REPLY; break; case 0x16: *id = OF_QUEUE_GET_CONFIG_REQUEST; break; case 0x17: *id = OF_QUEUE_GET_CONFIG_REPLY; break; case 0x18: *id = OF_ROLE_REQUEST; break; case 0x19: *id = OF_ROLE_REPLY; break; case 0x1a: *id = OF_ASYNC_GET_REQUEST; break; case 0x1b: *id = OF_ASYNC_GET_REPLY; break; case 0x1c: *id = OF_ASYNC_SET; break; case 0x1d: of_meter_mod_wire_object_id_get(obj, id); break; default: *id = OF_HEADER; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_header of_header */ /** * Create a new of_header object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_header */ of_header_t * of_header_new(of_version_t version) { of_header_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_HEADER] + of_object_extra_len[version][OF_HEADER]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_header_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_header_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_header. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_header_init(of_header_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_HEADER] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_HEADER] + of_object_extra_len[version][OF_HEADER]; } obj->version = version; obj->length = bytes; obj->object_id = OF_HEADER; /* Set up the object's function pointers */ /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Get xid from an object of type of_header. * @param obj Pointer to an object of type of_header. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_header_xid_get( of_header_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_header. * @param obj Pointer to an object of type of_header. * @param xid The value to write into the object */ void of_header_xid_set( of_header_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_stats_reply_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REPLY; break; case 0x1: *id = OF_FLOW_STATS_REPLY; break; case 0x2: *id = OF_AGGREGATE_STATS_REPLY; break; case 0x3: *id = OF_TABLE_STATS_REPLY; break; case 0x4: *id = OF_PORT_STATS_REPLY; break; case 0x5: *id = OF_QUEUE_STATS_REPLY; break; case 0xffff: of_experimenter_stats_reply_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REPLY; break; } break; } case OF_VERSION_1_1: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REPLY; break; case 0x1: *id = OF_FLOW_STATS_REPLY; break; case 0x2: *id = OF_AGGREGATE_STATS_REPLY; break; case 0x3: *id = OF_TABLE_STATS_REPLY; break; case 0x4: *id = OF_PORT_STATS_REPLY; break; case 0x5: *id = OF_QUEUE_STATS_REPLY; break; case 0x6: *id = OF_GROUP_STATS_REPLY; break; case 0x7: *id = OF_GROUP_DESC_STATS_REPLY; break; case 0xffff: of_experimenter_stats_reply_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REPLY; break; } break; } case OF_VERSION_1_2: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REPLY; break; case 0x1: *id = OF_FLOW_STATS_REPLY; break; case 0x2: *id = OF_AGGREGATE_STATS_REPLY; break; case 0x3: *id = OF_TABLE_STATS_REPLY; break; case 0x4: *id = OF_PORT_STATS_REPLY; break; case 0x5: *id = OF_QUEUE_STATS_REPLY; break; case 0x6: *id = OF_GROUP_STATS_REPLY; break; case 0x7: *id = OF_GROUP_DESC_STATS_REPLY; break; case 0x8: *id = OF_GROUP_FEATURES_STATS_REPLY; break; case 0xffff: of_experimenter_stats_reply_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REPLY; break; } break; } case OF_VERSION_1_3: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REPLY; break; case 0x1: *id = OF_FLOW_STATS_REPLY; break; case 0x2: *id = OF_AGGREGATE_STATS_REPLY; break; case 0x3: *id = OF_TABLE_STATS_REPLY; break; case 0x4: *id = OF_PORT_STATS_REPLY; break; case 0x5: *id = OF_QUEUE_STATS_REPLY; break; case 0x6: *id = OF_GROUP_STATS_REPLY; break; case 0x7: *id = OF_GROUP_DESC_STATS_REPLY; break; case 0x8: *id = OF_GROUP_FEATURES_STATS_REPLY; break; case 0x9: *id = OF_METER_STATS_REPLY; break; case 0xa: *id = OF_METER_CONFIG_STATS_REPLY; break; case 0xb: *id = OF_METER_FEATURES_STATS_REPLY; break; case 0xc: *id = OF_TABLE_FEATURES_STATS_REPLY; break; case 0xd: *id = OF_PORT_DESC_STATS_REPLY; break; case 0xffff: of_experimenter_stats_reply_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REPLY; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_stats_reply of_stats_reply */ /** * Create a new of_stats_reply object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_stats_reply */ of_stats_reply_t * of_stats_reply_new(of_version_t version) { of_stats_reply_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_STATS_REPLY] + of_object_extra_len[version][OF_STATS_REPLY]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_stats_reply_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_stats_reply_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_stats_reply. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_stats_reply_init(of_stats_reply_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_STATS_REPLY] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_STATS_REPLY] + of_object_extra_len[version][OF_STATS_REPLY]; } obj->version = version; obj->length = bytes; obj->object_id = OF_STATS_REPLY; /* Set up the object's function pointers */ obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_stats_reply object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_stats_reply */ of_stats_reply_t * of_stats_reply_new_from_message(of_message_t msg) { of_stats_reply_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_stats_reply_t *)of_object_new(-1)) == NULL) { return NULL; } of_stats_reply_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_stats_reply. * @param obj Pointer to an object of type of_stats_reply. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_stats_reply_xid_get( of_stats_reply_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_stats_reply. * @param obj Pointer to an object of type of_stats_reply. * @param xid The value to write into the object */ void of_stats_reply_xid_set( of_stats_reply_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get flags from an object of type of_stats_reply. * @param obj Pointer to an object of type of_stats_reply. * @param flags Pointer to the child object of type * uint16_t to be filled out. * */ void of_stats_reply_flags_get( of_stats_reply_t *obj, uint16_t *flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set flags in an object of type of_stats_reply. * @param obj Pointer to an object of type of_stats_reply. * @param flags The value to write into the object */ void of_stats_reply_flags_set( of_stats_reply_t *obj, uint16_t flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_aggregate_stats_reply_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x11; /* type */ *(uint16_t *)(buf + 8) = U16_HTON(0x2); /* stats_type */ break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x13; /* type */ *(uint16_t *)(buf + 8) = U16_HTON(0x2); /* stats_type */ break; default: UNREACHABLE(); } } /** * \defgroup of_aggregate_stats_reply of_aggregate_stats_reply */ /** * Helper function to push values into the wire buffer */ static inline int of_aggregate_stats_reply_push_wire_values(of_aggregate_stats_reply_t *obj) { of_aggregate_stats_reply_push_wire_types(obj); /* Message obj; set length */ of_message_t msg; if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) { of_message_length_set(msg, obj->length); } return OF_ERROR_NONE; } /** * Create a new of_aggregate_stats_reply object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_aggregate_stats_reply */ of_aggregate_stats_reply_t * of_aggregate_stats_reply_new(of_version_t version) { of_aggregate_stats_reply_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_AGGREGATE_STATS_REPLY] + of_object_extra_len[version][OF_AGGREGATE_STATS_REPLY]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_aggregate_stats_reply_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_aggregate_stats_reply_init(obj, version, bytes, 0); if (of_aggregate_stats_reply_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_aggregate_stats_reply. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_aggregate_stats_reply_init(of_aggregate_stats_reply_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_AGGREGATE_STATS_REPLY] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_AGGREGATE_STATS_REPLY] + of_object_extra_len[version][OF_AGGREGATE_STATS_REPLY]; } obj->version = version; obj->length = bytes; obj->object_id = OF_AGGREGATE_STATS_REPLY; /* Set up the object's function pointers */ obj->wire_type_set = of_aggregate_stats_reply_push_wire_types; obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_aggregate_stats_reply object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_aggregate_stats_reply */ of_aggregate_stats_reply_t * of_aggregate_stats_reply_new_from_message(of_message_t msg) { of_aggregate_stats_reply_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_aggregate_stats_reply_t *)of_object_new(-1)) == NULL) { return NULL; } of_aggregate_stats_reply_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_aggregate_stats_reply_xid_get( of_aggregate_stats_reply_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param xid The value to write into the object */ void of_aggregate_stats_reply_xid_set( of_aggregate_stats_reply_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get flags from an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param flags Pointer to the child object of type * uint16_t to be filled out. * */ void of_aggregate_stats_reply_flags_get( of_aggregate_stats_reply_t *obj, uint16_t *flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set flags in an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param flags The value to write into the object */ void of_aggregate_stats_reply_flags_set( of_aggregate_stats_reply_t *obj, uint16_t flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get packet_count from an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param packet_count Pointer to the child object of type * uint64_t to be filled out. * */ void of_aggregate_stats_reply_packet_count_get( of_aggregate_stats_reply_t *obj, uint64_t *packet_count) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_get(wbuf, abs_offset, packet_count); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set packet_count in an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param packet_count The value to write into the object */ void of_aggregate_stats_reply_packet_count_set( of_aggregate_stats_reply_t *obj, uint64_t packet_count) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_set(wbuf, abs_offset, packet_count); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get byte_count from an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param byte_count Pointer to the child object of type * uint64_t to be filled out. * */ void of_aggregate_stats_reply_byte_count_get( of_aggregate_stats_reply_t *obj, uint64_t *byte_count) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 20; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 24; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_get(wbuf, abs_offset, byte_count); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set byte_count in an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param byte_count The value to write into the object */ void of_aggregate_stats_reply_byte_count_set( of_aggregate_stats_reply_t *obj, uint64_t byte_count) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 20; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 24; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_set(wbuf, abs_offset, byte_count); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get flow_count from an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param flow_count Pointer to the child object of type * uint32_t to be filled out. * */ void of_aggregate_stats_reply_flow_count_get( of_aggregate_stats_reply_t *obj, uint32_t *flow_count) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 28; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 32; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, flow_count); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set flow_count in an object of type of_aggregate_stats_reply. * @param obj Pointer to an object of type of_aggregate_stats_reply. * @param flow_count The value to write into the object */ void of_aggregate_stats_reply_flow_count_set( of_aggregate_stats_reply_t *obj, uint32_t flow_count) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 28; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 32; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, flow_count); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_stats_request_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REQUEST; break; case 0x1: *id = OF_FLOW_STATS_REQUEST; break; case 0x2: *id = OF_AGGREGATE_STATS_REQUEST; break; case 0x3: *id = OF_TABLE_STATS_REQUEST; break; case 0x4: *id = OF_PORT_STATS_REQUEST; break; case 0x5: *id = OF_QUEUE_STATS_REQUEST; break; case 0xffff: of_experimenter_stats_request_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REQUEST; break; } break; } case OF_VERSION_1_1: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REQUEST; break; case 0x1: *id = OF_FLOW_STATS_REQUEST; break; case 0x2: *id = OF_AGGREGATE_STATS_REQUEST; break; case 0x3: *id = OF_TABLE_STATS_REQUEST; break; case 0x4: *id = OF_PORT_STATS_REQUEST; break; case 0x5: *id = OF_QUEUE_STATS_REQUEST; break; case 0x6: *id = OF_GROUP_STATS_REQUEST; break; case 0x7: *id = OF_GROUP_DESC_STATS_REQUEST; break; case 0xffff: of_experimenter_stats_request_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REQUEST; break; } break; } case OF_VERSION_1_2: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REQUEST; break; case 0x1: *id = OF_FLOW_STATS_REQUEST; break; case 0x2: *id = OF_AGGREGATE_STATS_REQUEST; break; case 0x3: *id = OF_TABLE_STATS_REQUEST; break; case 0x4: *id = OF_PORT_STATS_REQUEST; break; case 0x5: *id = OF_QUEUE_STATS_REQUEST; break; case 0x6: *id = OF_GROUP_STATS_REQUEST; break; case 0x7: *id = OF_GROUP_DESC_STATS_REQUEST; break; case 0x8: *id = OF_GROUP_FEATURES_STATS_REQUEST; break; case 0xffff: of_experimenter_stats_request_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REQUEST; break; } break; } case OF_VERSION_1_3: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* stats_type */ switch (value) { case 0x0: *id = OF_DESC_STATS_REQUEST; break; case 0x1: *id = OF_FLOW_STATS_REQUEST; break; case 0x2: *id = OF_AGGREGATE_STATS_REQUEST; break; case 0x3: *id = OF_TABLE_STATS_REQUEST; break; case 0x4: *id = OF_PORT_STATS_REQUEST; break; case 0x5: *id = OF_QUEUE_STATS_REQUEST; break; case 0x6: *id = OF_GROUP_STATS_REQUEST; break; case 0x7: *id = OF_GROUP_DESC_STATS_REQUEST; break; case 0x8: *id = OF_GROUP_FEATURES_STATS_REQUEST; break; case 0x9: *id = OF_METER_STATS_REQUEST; break; case 0xa: *id = OF_METER_CONFIG_STATS_REQUEST; break; case 0xb: *id = OF_METER_FEATURES_STATS_REQUEST; break; case 0xc: *id = OF_TABLE_FEATURES_STATS_REQUEST; break; case 0xd: *id = OF_PORT_DESC_STATS_REQUEST; break; case 0xffff: of_experimenter_stats_request_wire_object_id_get(obj, id); break; default: *id = OF_STATS_REQUEST; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_stats_request of_stats_request */ /** * Create a new of_stats_request object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_stats_request */ of_stats_request_t * of_stats_request_new(of_version_t version) { of_stats_request_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_STATS_REQUEST] + of_object_extra_len[version][OF_STATS_REQUEST]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_stats_request_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_stats_request_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_stats_request. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_stats_request_init(of_stats_request_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_STATS_REQUEST] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_STATS_REQUEST] + of_object_extra_len[version][OF_STATS_REQUEST]; } obj->version = version; obj->length = bytes; obj->object_id = OF_STATS_REQUEST; /* Set up the object's function pointers */ obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_stats_request object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_stats_request */ of_stats_request_t * of_stats_request_new_from_message(of_message_t msg) { of_stats_request_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_stats_request_t *)of_object_new(-1)) == NULL) { return NULL; } of_stats_request_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_stats_request. * @param obj Pointer to an object of type of_stats_request. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_stats_request_xid_get( of_stats_request_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_stats_request. * @param obj Pointer to an object of type of_stats_request. * @param xid The value to write into the object */ void of_stats_request_xid_set( of_stats_request_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get flags from an object of type of_stats_request. * @param obj Pointer to an object of type of_stats_request. * @param flags Pointer to the child object of type * uint16_t to be filled out. * */ void of_stats_request_flags_get( of_stats_request_t *obj, uint16_t *flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set flags in an object of type of_stats_request. * @param obj Pointer to an object of type of_stats_request. * @param flags The value to write into the object */ void of_stats_request_flags_set( of_stats_request_t *obj, uint16_t flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_aggregate_stats_request_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x10; /* type */ *(uint16_t *)(buf + 8) = U16_HTON(0x2); /* stats_type */ break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x12; /* type */ *(uint16_t *)(buf + 8) = U16_HTON(0x2); /* stats_type */ break; default: UNREACHABLE(); } } /** * \defgroup of_aggregate_stats_request of_aggregate_stats_request */ /** * Helper function to push values into the wire buffer */ static inline int of_aggregate_stats_request_push_wire_values(of_aggregate_stats_request_t *obj) { of_aggregate_stats_request_push_wire_types(obj); /* Message obj; set length */ of_message_t msg; if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) { of_message_length_set(msg, obj->length); } return OF_ERROR_NONE; } /** * Create a new of_aggregate_stats_request object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_aggregate_stats_request */ of_aggregate_stats_request_t * of_aggregate_stats_request_new(of_version_t version) { of_aggregate_stats_request_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_AGGREGATE_STATS_REQUEST] + of_object_extra_len[version][OF_AGGREGATE_STATS_REQUEST]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_aggregate_stats_request_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_aggregate_stats_request_init(obj, version, bytes, 0); if (of_aggregate_stats_request_push_wire_values(obj) < 0) { FREE(obj); return NULL; } /* Initialize match TLV for 1.2 */ /* FIXME: Check 1.3 below */ if ((version == OF_VERSION_1_2) || (version == OF_VERSION_1_3)) { of_object_u16_set((of_object_t *)obj, 48 + 2, 4); } return obj; } /** * Initialize an object of type of_aggregate_stats_request. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_aggregate_stats_request_init(of_aggregate_stats_request_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_AGGREGATE_STATS_REQUEST] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_AGGREGATE_STATS_REQUEST] + of_object_extra_len[version][OF_AGGREGATE_STATS_REQUEST]; } obj->version = version; obj->length = bytes; obj->object_id = OF_AGGREGATE_STATS_REQUEST; /* Set up the object's function pointers */ obj->wire_type_set = of_aggregate_stats_request_push_wire_types; obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_aggregate_stats_request object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_aggregate_stats_request */ of_aggregate_stats_request_t * of_aggregate_stats_request_new_from_message(of_message_t msg) { of_aggregate_stats_request_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_aggregate_stats_request_t *)of_object_new(-1)) == NULL) { return NULL; } of_aggregate_stats_request_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_aggregate_stats_request_xid_get( of_aggregate_stats_request_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param xid The value to write into the object */ void of_aggregate_stats_request_xid_set( of_aggregate_stats_request_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get flags from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param flags Pointer to the child object of type * uint16_t to be filled out. * */ void of_aggregate_stats_request_flags_get( of_aggregate_stats_request_t *obj, uint16_t *flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set flags in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param flags The value to write into the object */ void of_aggregate_stats_request_flags_set( of_aggregate_stats_request_t *obj, uint16_t flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get table_id from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param table_id Pointer to the child object of type * uint8_t to be filled out. * */ void of_aggregate_stats_request_table_id_get( of_aggregate_stats_request_t *obj, uint8_t *table_id) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 52; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_get(wbuf, abs_offset, table_id); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set table_id in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param table_id The value to write into the object */ void of_aggregate_stats_request_table_id_set( of_aggregate_stats_request_t *obj, uint8_t table_id) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 52; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u8_set(wbuf, abs_offset, table_id); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get out_port from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param out_port Pointer to the child object of type * of_port_no_t to be filled out. * */ void of_aggregate_stats_request_out_port_get( of_aggregate_stats_request_t *obj, of_port_no_t *out_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 54; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 20; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_port_no_get(ver, wbuf, abs_offset, out_port); OF_PORT_NO_VALUE_CHECK(*out_port, ver); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set out_port in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param out_port The value to write into the object */ void of_aggregate_stats_request_out_port_set( of_aggregate_stats_request_t *obj, of_port_no_t out_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 54; break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 20; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_port_no_set(ver, wbuf, abs_offset, out_port); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get out_group from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param out_group Pointer to the child object of type * uint32_t to be filled out. * */ void of_aggregate_stats_request_out_group_get( of_aggregate_stats_request_t *obj, uint32_t *out_group) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 24; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, out_group); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set out_group in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param out_group The value to write into the object */ void of_aggregate_stats_request_out_group_set( of_aggregate_stats_request_t *obj, uint32_t out_group) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 24; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, out_group); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get cookie from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param cookie Pointer to the child object of type * uint64_t to be filled out. * */ void of_aggregate_stats_request_cookie_get( of_aggregate_stats_request_t *obj, uint64_t *cookie) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 32; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_get(wbuf, abs_offset, cookie); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set cookie in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param cookie The value to write into the object */ void of_aggregate_stats_request_cookie_set( of_aggregate_stats_request_t *obj, uint64_t cookie) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 32; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_set(wbuf, abs_offset, cookie); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get cookie_mask from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param cookie_mask Pointer to the child object of type * uint64_t to be filled out. * */ void of_aggregate_stats_request_cookie_mask_get( of_aggregate_stats_request_t *obj, uint64_t *cookie_mask) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 40; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_get(wbuf, abs_offset, cookie_mask); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set cookie_mask in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param cookie_mask The value to write into the object */ void of_aggregate_stats_request_cookie_mask_set( of_aggregate_stats_request_t *obj, uint64_t cookie_mask) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 40; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u64_set(wbuf, abs_offset, cookie_mask); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get match from an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param match Pointer to the child object of type * of_match_t to be filled out. * */ int WARN_UNUSED_RESULT of_aggregate_stats_request_match_get( of_aggregate_stats_request_t *obj, of_match_t *match) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ of_octets_t match_octets; /* Serialized string for match */ LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_1: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); LOCI_ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf)); match_octets.bytes = cur_len; match_octets.data = OF_OBJECT_BUFFER_INDEX(obj, offset); OF_TRY(of_match_deserialize(ver, match, &match_octets)); OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; } /** * Set match in an object of type of_aggregate_stats_request. * @param obj Pointer to an object of type of_aggregate_stats_request. * @param match Pointer to the child of type of_match_t. * * If the child's wire buffer is the same as the parent's, then * nothing is done as the changes have already been registered in the * parent. Otherwise, the data in the child's wire buffer is inserted * into the parent's and the appropriate lengths are updated. */ int WARN_UNUSED_RESULT of_aggregate_stats_request_match_set( of_aggregate_stats_request_t *obj, of_match_t *match) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ int new_len, delta; /* For set, need new length and delta */ of_octets_t match_octets; /* Serialized string for match */ LOCI_ASSERT(obj->object_id == OF_AGGREGATE_STATS_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_1: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); /* Match object */ OF_TRY(of_match_serialize(ver, match, &match_octets)); new_len = match_octets.bytes; of_wire_buffer_replace_data(wbuf, abs_offset, cur_len, match_octets.data, new_len); /* Free match serialized octets */ FREE(match_octets.data); /* Not scalar, update lengths if needed */ delta = new_len - cur_len; if (delta != 0) { /* Update parent(s) */ of_object_parent_length_update((of_object_t *)obj, delta); } OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_error_msg_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* err_type */ switch (value) { case 0x0: *id = OF_HELLO_FAILED_ERROR_MSG; break; case 0x1: *id = OF_BAD_REQUEST_ERROR_MSG; break; case 0x2: *id = OF_BAD_ACTION_ERROR_MSG; break; case 0x3: *id = OF_FLOW_MOD_FAILED_ERROR_MSG; break; case 0x4: *id = OF_PORT_MOD_FAILED_ERROR_MSG; break; case 0x5: *id = OF_QUEUE_OP_FAILED_ERROR_MSG; break; default: *id = OF_ERROR_MSG; break; } break; } case OF_VERSION_1_1: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* err_type */ switch (value) { case 0x0: *id = OF_HELLO_FAILED_ERROR_MSG; break; case 0x1: *id = OF_BAD_REQUEST_ERROR_MSG; break; case 0x2: *id = OF_BAD_ACTION_ERROR_MSG; break; case 0x3: *id = OF_BAD_INSTRUCTION_ERROR_MSG; break; case 0x4: *id = OF_BAD_MATCH_ERROR_MSG; break; case 0x5: *id = OF_FLOW_MOD_FAILED_ERROR_MSG; break; case 0x6: *id = OF_GROUP_MOD_FAILED_ERROR_MSG; break; case 0x7: *id = OF_PORT_MOD_FAILED_ERROR_MSG; break; case 0x8: *id = OF_TABLE_MOD_FAILED_ERROR_MSG; break; case 0x9: *id = OF_QUEUE_OP_FAILED_ERROR_MSG; break; case 0xa: *id = OF_SWITCH_CONFIG_FAILED_ERROR_MSG; break; default: *id = OF_ERROR_MSG; break; } break; } case OF_VERSION_1_2: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* err_type */ switch (value) { case 0x0: *id = OF_HELLO_FAILED_ERROR_MSG; break; case 0x1: *id = OF_BAD_REQUEST_ERROR_MSG; break; case 0x2: *id = OF_BAD_ACTION_ERROR_MSG; break; case 0x3: *id = OF_BAD_INSTRUCTION_ERROR_MSG; break; case 0x4: *id = OF_BAD_MATCH_ERROR_MSG; break; case 0x5: *id = OF_FLOW_MOD_FAILED_ERROR_MSG; break; case 0x6: *id = OF_GROUP_MOD_FAILED_ERROR_MSG; break; case 0x7: *id = OF_PORT_MOD_FAILED_ERROR_MSG; break; case 0x8: *id = OF_TABLE_MOD_FAILED_ERROR_MSG; break; case 0x9: *id = OF_QUEUE_OP_FAILED_ERROR_MSG; break; case 0xa: *id = OF_SWITCH_CONFIG_FAILED_ERROR_MSG; break; case 0xb: *id = OF_ROLE_REQUEST_FAILED_ERROR_MSG; break; case 0xffff: *id = OF_EXPERIMENTER_ERROR_MSG; break; default: *id = OF_ERROR_MSG; break; } break; } case OF_VERSION_1_3: { uint16_t value = U16_NTOH(*(uint16_t *)(buf + 8)); /* err_type */ switch (value) { case 0x0: *id = OF_HELLO_FAILED_ERROR_MSG; break; case 0x1: *id = OF_BAD_REQUEST_ERROR_MSG; break; case 0x2: *id = OF_BAD_ACTION_ERROR_MSG; break; case 0x3: *id = OF_BAD_INSTRUCTION_ERROR_MSG; break; case 0x4: *id = OF_BAD_MATCH_ERROR_MSG; break; case 0x5: *id = OF_FLOW_MOD_FAILED_ERROR_MSG; break; case 0x6: *id = OF_GROUP_MOD_FAILED_ERROR_MSG; break; case 0x7: *id = OF_PORT_MOD_FAILED_ERROR_MSG; break; case 0x8: *id = OF_TABLE_MOD_FAILED_ERROR_MSG; break; case 0x9: *id = OF_QUEUE_OP_FAILED_ERROR_MSG; break; case 0xa: *id = OF_SWITCH_CONFIG_FAILED_ERROR_MSG; break; case 0xb: *id = OF_ROLE_REQUEST_FAILED_ERROR_MSG; break; case 0xc: *id = OF_METER_MOD_FAILED_ERROR_MSG; break; case 0xd: *id = OF_TABLE_FEATURES_FAILED_ERROR_MSG; break; case 0xffff: *id = OF_EXPERIMENTER_ERROR_MSG; break; default: *id = OF_ERROR_MSG; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_error_msg of_error_msg */ /** * Create a new of_error_msg object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_error_msg */ of_error_msg_t * of_error_msg_new(of_version_t version) { of_error_msg_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_ERROR_MSG] + of_object_extra_len[version][OF_ERROR_MSG]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_error_msg_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_error_msg_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_error_msg. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_error_msg_init(of_error_msg_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_ERROR_MSG] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_ERROR_MSG] + of_object_extra_len[version][OF_ERROR_MSG]; } obj->version = version; obj->length = bytes; obj->object_id = OF_ERROR_MSG; /* Set up the object's function pointers */ obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_error_msg object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_error_msg */ of_error_msg_t * of_error_msg_new_from_message(of_message_t msg) { of_error_msg_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_error_msg_t *)of_object_new(-1)) == NULL) { return NULL; } of_error_msg_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_error_msg. * @param obj Pointer to an object of type of_error_msg. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_error_msg_xid_get( of_error_msg_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_error_msg. * @param obj Pointer to an object of type of_error_msg. * @param xid The value to write into the object */ void of_error_msg_xid_set( of_error_msg_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_bad_action_error_msg_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x1; /* type */ *(uint16_t *)(buf + 8) = U16_HTON(0x2); /* err_type */ break; default: UNREACHABLE(); } } /** * \defgroup of_bad_action_error_msg of_bad_action_error_msg */ /** * Helper function to push values into the wire buffer */ static inline int of_bad_action_error_msg_push_wire_values(of_bad_action_error_msg_t *obj) { of_bad_action_error_msg_push_wire_types(obj); /* Message obj; set length */ of_message_t msg; if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) { of_message_length_set(msg, obj->length); } return OF_ERROR_NONE; } /** * Create a new of_bad_action_error_msg object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_bad_action_error_msg */ of_bad_action_error_msg_t * of_bad_action_error_msg_new(of_version_t version) { of_bad_action_error_msg_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_BAD_ACTION_ERROR_MSG] + of_object_extra_len[version][OF_BAD_ACTION_ERROR_MSG]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_bad_action_error_msg_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_bad_action_error_msg_init(obj, version, bytes, 0); if (of_bad_action_error_msg_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_bad_action_error_msg. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_bad_action_error_msg_init(of_bad_action_error_msg_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_BAD_ACTION_ERROR_MSG] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_BAD_ACTION_ERROR_MSG] + of_object_extra_len[version][OF_BAD_ACTION_ERROR_MSG]; } obj->version = version; obj->length = bytes; obj->object_id = OF_BAD_ACTION_ERROR_MSG; /* Set up the object's function pointers */ obj->wire_type_set = of_bad_action_error_msg_push_wire_types; obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_bad_action_error_msg object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_bad_action_error_msg */ of_bad_action_error_msg_t * of_bad_action_error_msg_new_from_message(of_message_t msg) { of_bad_action_error_msg_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_bad_action_error_msg_t *)of_object_new(-1)) == NULL) { return NULL; } of_bad_action_error_msg_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_bad_action_error_msg. * @param obj Pointer to an object of type of_bad_action_error_msg. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_bad_action_error_msg_xid_get( of_bad_action_error_msg_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_ACTION_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_bad_action_error_msg. * @param obj Pointer to an object of type of_bad_action_error_msg. * @param xid The value to write into the object */ void of_bad_action_error_msg_xid_set( of_bad_action_error_msg_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_ACTION_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get code from an object of type of_bad_action_error_msg. * @param obj Pointer to an object of type of_bad_action_error_msg. * @param code Pointer to the child object of type * uint16_t to be filled out. * */ void of_bad_action_error_msg_code_get( of_bad_action_error_msg_t *obj, uint16_t *code) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_ACTION_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, code); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set code in an object of type of_bad_action_error_msg. * @param obj Pointer to an object of type of_bad_action_error_msg. * @param code The value to write into the object */ void of_bad_action_error_msg_code_set( of_bad_action_error_msg_t *obj, uint16_t code) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_ACTION_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, code); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get data from an object of type of_bad_action_error_msg. * @param obj Pointer to an object of type of_bad_action_error_msg. * @param data Pointer to the child object of type * of_octets_t to be filled out. * */ void of_bad_action_error_msg_data_get( of_bad_action_error_msg_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ LOCI_ASSERT(obj->object_id == OF_BAD_ACTION_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); LOCI_ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf)); data->bytes = cur_len; data->data = OF_WIRE_BUFFER_INDEX(wbuf, abs_offset); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set data in an object of type of_bad_action_error_msg. * @param obj Pointer to an object of type of_bad_action_error_msg. * @param data The value to write into the object */ int WARN_UNUSED_RESULT of_bad_action_error_msg_data_set( of_bad_action_error_msg_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ int new_len, delta; /* For set, need new length and delta */ LOCI_ASSERT(obj->object_id == OF_BAD_ACTION_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); new_len = data->bytes; of_wire_buffer_grow(wbuf, abs_offset + (new_len - cur_len)); of_wire_buffer_octets_data_set(wbuf, abs_offset, data, cur_len); /* Not scalar, update lengths if needed */ delta = new_len - cur_len; if (delta != 0) { /* Update parent(s) */ of_object_parent_length_update((of_object_t *)obj, delta); } OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_bad_request_error_msg_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x1; /* type */ *(uint16_t *)(buf + 8) = U16_HTON(0x1); /* err_type */ break; default: UNREACHABLE(); } } /** * \defgroup of_bad_request_error_msg of_bad_request_error_msg */ /** * Helper function to push values into the wire buffer */ static inline int of_bad_request_error_msg_push_wire_values(of_bad_request_error_msg_t *obj) { of_bad_request_error_msg_push_wire_types(obj); /* Message obj; set length */ of_message_t msg; if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) { of_message_length_set(msg, obj->length); } return OF_ERROR_NONE; } /** * Create a new of_bad_request_error_msg object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_bad_request_error_msg */ of_bad_request_error_msg_t * of_bad_request_error_msg_new(of_version_t version) { of_bad_request_error_msg_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_BAD_REQUEST_ERROR_MSG] + of_object_extra_len[version][OF_BAD_REQUEST_ERROR_MSG]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_bad_request_error_msg_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_bad_request_error_msg_init(obj, version, bytes, 0); if (of_bad_request_error_msg_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_bad_request_error_msg. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_bad_request_error_msg_init(of_bad_request_error_msg_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_BAD_REQUEST_ERROR_MSG] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_BAD_REQUEST_ERROR_MSG] + of_object_extra_len[version][OF_BAD_REQUEST_ERROR_MSG]; } obj->version = version; obj->length = bytes; obj->object_id = OF_BAD_REQUEST_ERROR_MSG; /* Set up the object's function pointers */ obj->wire_type_set = of_bad_request_error_msg_push_wire_types; obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_bad_request_error_msg object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_bad_request_error_msg */ of_bad_request_error_msg_t * of_bad_request_error_msg_new_from_message(of_message_t msg) { of_bad_request_error_msg_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_bad_request_error_msg_t *)of_object_new(-1)) == NULL) { return NULL; } of_bad_request_error_msg_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_bad_request_error_msg. * @param obj Pointer to an object of type of_bad_request_error_msg. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_bad_request_error_msg_xid_get( of_bad_request_error_msg_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_REQUEST_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_bad_request_error_msg. * @param obj Pointer to an object of type of_bad_request_error_msg. * @param xid The value to write into the object */ void of_bad_request_error_msg_xid_set( of_bad_request_error_msg_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_REQUEST_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get code from an object of type of_bad_request_error_msg. * @param obj Pointer to an object of type of_bad_request_error_msg. * @param code Pointer to the child object of type * uint16_t to be filled out. * */ void of_bad_request_error_msg_code_get( of_bad_request_error_msg_t *obj, uint16_t *code) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_REQUEST_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_get(wbuf, abs_offset, code); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set code in an object of type of_bad_request_error_msg. * @param obj Pointer to an object of type of_bad_request_error_msg. * @param code The value to write into the object */ void of_bad_request_error_msg_code_set( of_bad_request_error_msg_t *obj, uint16_t code) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BAD_REQUEST_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, code); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get data from an object of type of_bad_request_error_msg. * @param obj Pointer to an object of type of_bad_request_error_msg. * @param data Pointer to the child object of type * of_octets_t to be filled out. * */ void of_bad_request_error_msg_data_get( of_bad_request_error_msg_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ LOCI_ASSERT(obj->object_id == OF_BAD_REQUEST_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); LOCI_ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf)); data->bytes = cur_len; data->data = OF_WIRE_BUFFER_INDEX(wbuf, abs_offset); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set data in an object of type of_bad_request_error_msg. * @param obj Pointer to an object of type of_bad_request_error_msg. * @param data The value to write into the object */ int WARN_UNUSED_RESULT of_bad_request_error_msg_data_set( of_bad_request_error_msg_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ int new_len, delta; /* For set, need new length and delta */ LOCI_ASSERT(obj->object_id == OF_BAD_REQUEST_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); new_len = data->bytes; of_wire_buffer_grow(wbuf, abs_offset + (new_len - cur_len)); of_wire_buffer_octets_data_set(wbuf, abs_offset, data, cur_len); /* Not scalar, update lengths if needed */ delta = new_len - cur_len; if (delta != 0) { /* Update parent(s) */ of_object_parent_length_update((of_object_t *)obj, delta); } OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_barrier_reply_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x13; /* type */ break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x15; /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_barrier_reply of_barrier_reply */ /** * Helper function to push values into the wire buffer */ static inline int of_barrier_reply_push_wire_values(of_barrier_reply_t *obj) { of_barrier_reply_push_wire_types(obj); /* Message obj; set length */ of_message_t msg; if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) { of_message_length_set(msg, obj->length); } return OF_ERROR_NONE; } /** * Create a new of_barrier_reply object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_barrier_reply */ of_barrier_reply_t * of_barrier_reply_new(of_version_t version) { of_barrier_reply_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_BARRIER_REPLY] + of_object_extra_len[version][OF_BARRIER_REPLY]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_barrier_reply_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_barrier_reply_init(obj, version, bytes, 0); if (of_barrier_reply_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_barrier_reply. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_barrier_reply_init(of_barrier_reply_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_BARRIER_REPLY] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_BARRIER_REPLY] + of_object_extra_len[version][OF_BARRIER_REPLY]; } obj->version = version; obj->length = bytes; obj->object_id = OF_BARRIER_REPLY; /* Set up the object's function pointers */ obj->wire_type_set = of_barrier_reply_push_wire_types; obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_barrier_reply object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_barrier_reply */ of_barrier_reply_t * of_barrier_reply_new_from_message(of_message_t msg) { of_barrier_reply_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_barrier_reply_t *)of_object_new(-1)) == NULL) { return NULL; } of_barrier_reply_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_barrier_reply. * @param obj Pointer to an object of type of_barrier_reply. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_barrier_reply_xid_get( of_barrier_reply_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BARRIER_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_barrier_reply. * @param obj Pointer to an object of type of_barrier_reply. * @param xid The value to write into the object */ void of_barrier_reply_xid_set( of_barrier_reply_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BARRIER_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_barrier_request_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x12; /* type */ break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x14; /* type */ break; default: UNREACHABLE(); } } /** * \defgroup of_barrier_request of_barrier_request */ /** * Helper function to push values into the wire buffer */ static inline int of_barrier_request_push_wire_values(of_barrier_request_t *obj) { of_barrier_request_push_wire_types(obj); /* Message obj; set length */ of_message_t msg; if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) { of_message_length_set(msg, obj->length); } return OF_ERROR_NONE; } /** * Create a new of_barrier_request object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_barrier_request */ of_barrier_request_t * of_barrier_request_new(of_version_t version) { of_barrier_request_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_BARRIER_REQUEST] + of_object_extra_len[version][OF_BARRIER_REQUEST]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_barrier_request_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_barrier_request_init(obj, version, bytes, 0); if (of_barrier_request_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_barrier_request. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_barrier_request_init(of_barrier_request_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_BARRIER_REQUEST] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_BARRIER_REQUEST] + of_object_extra_len[version][OF_BARRIER_REQUEST]; } obj->version = version; obj->length = bytes; obj->object_id = OF_BARRIER_REQUEST; /* Set up the object's function pointers */ obj->wire_type_set = of_barrier_request_push_wire_types; obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_barrier_request object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_barrier_request */ of_barrier_request_t * of_barrier_request_new_from_message(of_message_t msg) { of_barrier_request_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_barrier_request_t *)of_object_new(-1)) == NULL) { return NULL; } of_barrier_request_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_barrier_request. * @param obj Pointer to an object of type of_barrier_request. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_barrier_request_xid_get( of_barrier_request_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BARRIER_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_barrier_request. * @param obj Pointer to an object of type of_barrier_request. * @param xid The value to write into the object */ void of_barrier_request_xid_set( of_barrier_request_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BARRIER_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_experimenter_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* experimenter */ switch (value) { case 0x2320: of_nicira_header_wire_object_id_get(obj, id); break; case 0x5c16c7: of_bsn_header_wire_object_id_get(obj, id); break; default: *id = OF_EXPERIMENTER; break; } break; } case OF_VERSION_1_1: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* experimenter */ switch (value) { case 0x2320: of_nicira_header_wire_object_id_get(obj, id); break; case 0x5c16c7: of_bsn_header_wire_object_id_get(obj, id); break; default: *id = OF_EXPERIMENTER; break; } break; } case OF_VERSION_1_2: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* experimenter */ switch (value) { case 0x2320: of_nicira_header_wire_object_id_get(obj, id); break; case 0x5c16c7: of_bsn_header_wire_object_id_get(obj, id); break; default: *id = OF_EXPERIMENTER; break; } break; } case OF_VERSION_1_3: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 8)); /* experimenter */ switch (value) { case 0x1018: case 0xFF00000A: of_experimenter_ofdpa_wire_object_id_get(obj, id); break; case 0x2320: of_nicira_header_wire_object_id_get(obj, id); break; case 0x5c16c7: of_bsn_header_wire_object_id_get(obj, id); break; default: *id = OF_EXPERIMENTER; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_experimenter of_experimenter */ /** * Create a new of_experimenter object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_experimenter */ of_experimenter_t * of_experimenter_new(of_version_t version) { of_experimenter_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_EXPERIMENTER] + of_object_extra_len[version][OF_EXPERIMENTER]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_experimenter_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_experimenter_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_experimenter. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_experimenter_init(of_experimenter_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_EXPERIMENTER] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_EXPERIMENTER] + of_object_extra_len[version][OF_EXPERIMENTER]; } obj->version = version; obj->length = bytes; obj->object_id = OF_EXPERIMENTER; /* Set up the object's function pointers */ obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_experimenter object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_experimenter */ of_experimenter_t * of_experimenter_new_from_message(of_message_t msg) { of_experimenter_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_experimenter_t *)of_object_new(-1)) == NULL) { return NULL; } of_experimenter_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_experimenter_xid_get( of_experimenter_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param xid The value to write into the object */ void of_experimenter_xid_set( of_experimenter_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get experimenter from an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_experimenter_experimenter_get( of_experimenter_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param experimenter The value to write into the object */ void of_experimenter_experimenter_set( of_experimenter_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param subtype Pointer to the child object of type * uint32_t to be filled out. * */ void of_experimenter_subtype_get( of_experimenter_t *obj, uint32_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param subtype The value to write into the object */ void of_experimenter_subtype_set( of_experimenter_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get data from an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param data Pointer to the child object of type * of_octets_t to be filled out. * */ void of_experimenter_data_get( of_experimenter_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); LOCI_ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf)); data->bytes = cur_len; data->data = OF_WIRE_BUFFER_INDEX(wbuf, abs_offset); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set data in an object of type of_experimenter. * @param obj Pointer to an object of type of_experimenter. * @param data The value to write into the object */ int WARN_UNUSED_RESULT of_experimenter_data_set( of_experimenter_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ int new_len, delta; /* For set, need new length and delta */ LOCI_ASSERT(obj->object_id == OF_EXPERIMENTER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; cur_len = _END_LEN(obj, offset); break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); LOCI_ASSERT(cur_len >= 0 && cur_len < 64 * 1024); new_len = data->bytes; of_wire_buffer_grow(wbuf, abs_offset + (new_len - cur_len)); of_wire_buffer_octets_data_set(wbuf, abs_offset, data, cur_len); /* Not scalar, update lengths if needed */ delta = new_len - cur_len; if (delta != 0) { /* Update parent(s) */ of_object_parent_length_update((of_object_t *)obj, delta); } OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" void of_bsn_header_wire_object_id_get(of_object_t *obj, of_object_id_t *id) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 12)); /* subtype */ switch (value) { case 0x0: *id = OF_BSN_SET_IP_MASK; break; case 0x1: *id = OF_BSN_GET_IP_MASK_REQUEST; break; case 0x2: *id = OF_BSN_GET_IP_MASK_REPLY; break; case 0x3: *id = OF_BSN_SET_MIRRORING; break; case 0x4: *id = OF_BSN_GET_MIRRORING_REQUEST; break; case 0x5: *id = OF_BSN_GET_MIRRORING_REPLY; break; case 0x6: *id = OF_BSN_SHELL_COMMAND; break; case 0x7: *id = OF_BSN_SHELL_OUTPUT; break; case 0x8: *id = OF_BSN_SHELL_STATUS; break; case 0x9: *id = OF_BSN_GET_INTERFACES_REQUEST; break; case 0xa: *id = OF_BSN_GET_INTERFACES_REPLY; break; case 0xb: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REQUEST; break; case 0xc: *id = OF_BSN_SET_L2_TABLE_REQUEST; break; case 0xd: *id = OF_BSN_GET_L2_TABLE_REQUEST; break; case 0xe: *id = OF_BSN_GET_L2_TABLE_REPLY; break; case 0xf: *id = OF_BSN_VIRTUAL_PORT_CREATE_REQUEST; break; case 0x10: *id = OF_BSN_VIRTUAL_PORT_CREATE_REPLY; break; case 0x11: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REQUEST; break; case 0x12: *id = OF_BSN_BW_ENABLE_SET_REQUEST; break; case 0x13: *id = OF_BSN_BW_ENABLE_GET_REQUEST; break; case 0x14: *id = OF_BSN_BW_ENABLE_GET_REPLY; break; case 0x15: *id = OF_BSN_BW_CLEAR_DATA_REQUEST; break; case 0x16: *id = OF_BSN_BW_CLEAR_DATA_REPLY; break; case 0x17: *id = OF_BSN_BW_ENABLE_SET_REPLY; break; case 0x18: *id = OF_BSN_SET_L2_TABLE_REPLY; break; case 0x19: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REPLY; break; case 0x1a: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REPLY; break; case 0x1b: *id = OF_BSN_HYBRID_GET_REQUEST; break; case 0x1c: *id = OF_BSN_HYBRID_GET_REPLY; break; case 0x1f: *id = OF_BSN_PDU_TX_REQUEST; break; case 0x20: *id = OF_BSN_PDU_TX_REPLY; break; case 0x21: *id = OF_BSN_PDU_RX_REQUEST; break; case 0x22: *id = OF_BSN_PDU_RX_REPLY; break; case 0x23: *id = OF_BSN_PDU_RX_TIMEOUT; break; default: *id = OF_BSN_HEADER; break; } break; } case OF_VERSION_1_1: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 12)); /* subtype */ switch (value) { case 0x3: *id = OF_BSN_SET_MIRRORING; break; case 0x4: *id = OF_BSN_GET_MIRRORING_REQUEST; break; case 0x5: *id = OF_BSN_GET_MIRRORING_REPLY; break; case 0x9: *id = OF_BSN_GET_INTERFACES_REQUEST; break; case 0xa: *id = OF_BSN_GET_INTERFACES_REPLY; break; case 0xb: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REQUEST; break; case 0xf: *id = OF_BSN_VIRTUAL_PORT_CREATE_REQUEST; break; case 0x10: *id = OF_BSN_VIRTUAL_PORT_CREATE_REPLY; break; case 0x11: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REQUEST; break; case 0x12: *id = OF_BSN_BW_ENABLE_SET_REQUEST; break; case 0x13: *id = OF_BSN_BW_ENABLE_GET_REQUEST; break; case 0x14: *id = OF_BSN_BW_ENABLE_GET_REPLY; break; case 0x15: *id = OF_BSN_BW_CLEAR_DATA_REQUEST; break; case 0x16: *id = OF_BSN_BW_CLEAR_DATA_REPLY; break; case 0x17: *id = OF_BSN_BW_ENABLE_SET_REPLY; break; case 0x19: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REPLY; break; case 0x1a: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REPLY; break; case 0x1f: *id = OF_BSN_PDU_TX_REQUEST; break; case 0x20: *id = OF_BSN_PDU_TX_REPLY; break; case 0x21: *id = OF_BSN_PDU_RX_REQUEST; break; case 0x22: *id = OF_BSN_PDU_RX_REPLY; break; case 0x23: *id = OF_BSN_PDU_RX_TIMEOUT; break; default: *id = OF_BSN_HEADER; break; } break; } case OF_VERSION_1_2: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 12)); /* subtype */ switch (value) { case 0x3: *id = OF_BSN_SET_MIRRORING; break; case 0x4: *id = OF_BSN_GET_MIRRORING_REQUEST; break; case 0x5: *id = OF_BSN_GET_MIRRORING_REPLY; break; case 0x9: *id = OF_BSN_GET_INTERFACES_REQUEST; break; case 0xa: *id = OF_BSN_GET_INTERFACES_REPLY; break; case 0xb: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REQUEST; break; case 0xf: *id = OF_BSN_VIRTUAL_PORT_CREATE_REQUEST; break; case 0x10: *id = OF_BSN_VIRTUAL_PORT_CREATE_REPLY; break; case 0x11: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REQUEST; break; case 0x12: *id = OF_BSN_BW_ENABLE_SET_REQUEST; break; case 0x13: *id = OF_BSN_BW_ENABLE_GET_REQUEST; break; case 0x14: *id = OF_BSN_BW_ENABLE_GET_REPLY; break; case 0x15: *id = OF_BSN_BW_CLEAR_DATA_REQUEST; break; case 0x16: *id = OF_BSN_BW_CLEAR_DATA_REPLY; break; case 0x17: *id = OF_BSN_BW_ENABLE_SET_REPLY; break; case 0x19: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REPLY; break; case 0x1a: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REPLY; break; case 0x1f: *id = OF_BSN_PDU_TX_REQUEST; break; case 0x20: *id = OF_BSN_PDU_TX_REPLY; break; case 0x21: *id = OF_BSN_PDU_RX_REQUEST; break; case 0x22: *id = OF_BSN_PDU_RX_REPLY; break; case 0x23: *id = OF_BSN_PDU_RX_TIMEOUT; break; default: *id = OF_BSN_HEADER; break; } break; } case OF_VERSION_1_3: { uint32_t value = U32_NTOH(*(uint32_t *)(buf + 12)); /* subtype */ switch (value) { case 0x3: *id = OF_BSN_SET_MIRRORING; break; case 0x4: *id = OF_BSN_GET_MIRRORING_REQUEST; break; case 0x5: *id = OF_BSN_GET_MIRRORING_REPLY; break; case 0x9: *id = OF_BSN_GET_INTERFACES_REQUEST; break; case 0xa: *id = OF_BSN_GET_INTERFACES_REPLY; break; case 0xb: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REQUEST; break; case 0xf: *id = OF_BSN_VIRTUAL_PORT_CREATE_REQUEST; break; case 0x10: *id = OF_BSN_VIRTUAL_PORT_CREATE_REPLY; break; case 0x11: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REQUEST; break; case 0x12: *id = OF_BSN_BW_ENABLE_SET_REQUEST; break; case 0x13: *id = OF_BSN_BW_ENABLE_GET_REQUEST; break; case 0x14: *id = OF_BSN_BW_ENABLE_GET_REPLY; break; case 0x15: *id = OF_BSN_BW_CLEAR_DATA_REQUEST; break; case 0x16: *id = OF_BSN_BW_CLEAR_DATA_REPLY; break; case 0x17: *id = OF_BSN_BW_ENABLE_SET_REPLY; break; case 0x19: *id = OF_BSN_SET_PKTIN_SUPPRESSION_REPLY; break; case 0x1a: *id = OF_BSN_VIRTUAL_PORT_REMOVE_REPLY; break; case 0x1f: *id = OF_BSN_PDU_TX_REQUEST; break; case 0x20: *id = OF_BSN_PDU_TX_REPLY; break; case 0x21: *id = OF_BSN_PDU_RX_REQUEST; break; case 0x22: *id = OF_BSN_PDU_RX_REPLY; break; case 0x23: *id = OF_BSN_PDU_RX_TIMEOUT; break; case 0x24: *id = OF_BSN_FLOW_IDLE_ENABLE_SET_REQUEST; break; case 0x25: *id = OF_BSN_FLOW_IDLE_ENABLE_SET_REPLY; break; case 0x26: *id = OF_BSN_FLOW_IDLE_ENABLE_GET_REQUEST; break; case 0x27: *id = OF_BSN_FLOW_IDLE_ENABLE_GET_REPLY; break; case 0x28: *id = OF_BSN_FLOW_IDLE; break; case 0x29: *id = OF_BSN_SET_LACP_REQUEST; break; case 0x2a: *id = OF_BSN_SET_LACP_REPLY; break; case 0x2b: *id = OF_BSN_LACP_CONVERGENCE_NOTIF; break; case 0x2c: *id = OF_BSN_TIME_REQUEST; break; case 0x2d: *id = OF_BSN_TIME_REPLY; break; case 0x2e: *id = OF_BSN_GENTABLE_ENTRY_ADD; break; case 0x2f: *id = OF_BSN_GENTABLE_ENTRY_DELETE; break; case 0x30: *id = OF_BSN_GENTABLE_CLEAR_REQUEST; break; case 0x31: *id = OF_BSN_GENTABLE_CLEAR_REPLY; break; case 0x32: *id = OF_BSN_GENTABLE_SET_BUCKETS_SIZE; break; case 0x33: *id = OF_BSN_GET_SWITCH_PIPELINE_REQUEST; break; case 0x34: *id = OF_BSN_GET_SWITCH_PIPELINE_REPLY; break; case 0x35: *id = OF_BSN_SET_SWITCH_PIPELINE_REQUEST; break; case 0x36: *id = OF_BSN_SET_SWITCH_PIPELINE_REPLY; break; case 0x37: *id = OF_BSN_ROLE_STATUS; break; case 0x38: *id = OF_BSN_CONTROLLER_CONNECTIONS_REQUEST; break; case 0x39: *id = OF_BSN_CONTROLLER_CONNECTIONS_REPLY; break; case 0x3a: *id = OF_BSN_SET_AUX_CXNS_REQUEST; break; case 0x3b: *id = OF_BSN_SET_AUX_CXNS_REPLY; break; case 0x3c: *id = OF_BSN_ARP_IDLE; break; case 0x3d: *id = OF_BSN_TABLE_SET_BUCKETS_SIZE; break; default: *id = OF_BSN_HEADER; break; } break; } default: LOCI_ASSERT(0); } } /** * \defgroup of_bsn_header of_bsn_header */ /** * Create a new of_bsn_header object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_bsn_header */ of_bsn_header_t * of_bsn_header_new(of_version_t version) { of_bsn_header_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_BSN_HEADER] + of_object_extra_len[version][OF_BSN_HEADER]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_bsn_header_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_bsn_header_init(obj, version, bytes, 0); return obj; } /** * Initialize an object of type of_bsn_header. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_bsn_header_init(of_bsn_header_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_BSN_HEADER] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_BSN_HEADER] + of_object_extra_len[version][OF_BSN_HEADER]; } obj->version = version; obj->length = bytes; obj->object_id = OF_BSN_HEADER; /* Set up the object's function pointers */ obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_bsn_header object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_bsn_header */ of_bsn_header_t * of_bsn_header_new_from_message(of_message_t msg) { of_bsn_header_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_bsn_header_t *)of_object_new(-1)) == NULL) { return NULL; } of_bsn_header_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_bsn_header. * @param obj Pointer to an object of type of_bsn_header. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_header_xid_get( of_bsn_header_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_bsn_header. * @param obj Pointer to an object of type of_bsn_header. * @param xid The value to write into the object */ void of_bsn_header_xid_set( of_bsn_header_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get experimenter from an object of type of_bsn_header. * @param obj Pointer to an object of type of_bsn_header. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_header_experimenter_get( of_bsn_header_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_bsn_header. * @param obj Pointer to an object of type of_bsn_header. * @param experimenter The value to write into the object */ void of_bsn_header_experimenter_set( of_bsn_header_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_bsn_header. * @param obj Pointer to an object of type of_bsn_header. * @param subtype Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_header_subtype_get( of_bsn_header_t *obj, uint32_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_bsn_header. * @param obj Pointer to an object of type of_bsn_header. * @param subtype The value to write into the object */ void of_bsn_header_subtype_set( of_bsn_header_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_HEADER); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */ /* Copyright (c) 2011, 2012 Open Networking Foundation */ /* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */ /* See the file LICENSE.loci which should have been included in the source distribution */ #ifdef __GNUC__ #ifdef __linux__ /* glibc */ #include <features.h> #else /* NetBSD etc */ #include <sys/cdefs.h> #ifdef __GNUC_PREREQ__ #define __GNUC_PREREQ __GNUC_PREREQ__ #endif #endif #ifndef __GNUC_PREREQ /* fallback */ #define __GNUC_PREREQ(maj, min) 0 #endif #if __GNUC_PREREQ(4,6) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #endif #include "loci_log.h" #include "loci_int.h" static void of_bsn_bw_clear_data_reply_push_wire_types(of_object_t *obj) { unsigned char *buf = OF_OBJECT_BUFFER_INDEX(obj, 0); switch (obj->version) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: *(uint8_t *)(buf + 0) = obj->version; /* version */ *(uint8_t *)(buf + 1) = 0x4; /* type */ *(uint32_t *)(buf + 8) = U32_HTON(0x5c16c7); /* experimenter */ *(uint32_t *)(buf + 12) = U32_HTON(0x16); /* subtype */ break; default: UNREACHABLE(); } } /** * \defgroup of_bsn_bw_clear_data_reply of_bsn_bw_clear_data_reply */ /** * Helper function to push values into the wire buffer */ static inline int of_bsn_bw_clear_data_reply_push_wire_values(of_bsn_bw_clear_data_reply_t *obj) { of_bsn_bw_clear_data_reply_push_wire_types(obj); /* Message obj; set length */ of_message_t msg; if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) { of_message_length_set(msg, obj->length); } return OF_ERROR_NONE; } /** * Create a new of_bsn_bw_clear_data_reply object * * @param version The wire version to use for the object * @return Pointer to the newly create object or NULL on error * * Initializes the new object with it's default fixed length associating * a new underlying wire buffer. * * Use new_from_message to bind an existing message to a message object, * or a _get function for non-message objects. * * \ingroup of_bsn_bw_clear_data_reply */ of_bsn_bw_clear_data_reply_t * of_bsn_bw_clear_data_reply_new(of_version_t version) { of_bsn_bw_clear_data_reply_t *obj; int bytes; bytes = of_object_fixed_len[version][OF_BSN_BW_CLEAR_DATA_REPLY] + of_object_extra_len[version][OF_BSN_BW_CLEAR_DATA_REPLY]; /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */ if ((obj = (of_bsn_bw_clear_data_reply_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) { return NULL; } of_bsn_bw_clear_data_reply_init(obj, version, bytes, 0); if (of_bsn_bw_clear_data_reply_push_wire_values(obj) < 0) { FREE(obj); return NULL; } return obj; } /** * Initialize an object of type of_bsn_bw_clear_data_reply. * * @param obj Pointer to the object to initialize * @param version The wire version to use for the object * @param bytes How many bytes in the object * @param clean_wire Boolean: If true, clear the wire object control struct * * If bytes < 0, then the default fixed length is used for the object * * This is a "coerce" function that sets up the pointers for the * accessors properly. * * If anything other than 0 is passed in for the buffer size, the underlying * wire buffer will have 'grow' called. */ void of_bsn_bw_clear_data_reply_init(of_bsn_bw_clear_data_reply_t *obj, of_version_t version, int bytes, int clean_wire) { LOCI_ASSERT(of_object_fixed_len[version][OF_BSN_BW_CLEAR_DATA_REPLY] >= 0); if (clean_wire) { MEMSET(obj, 0, sizeof(*obj)); } if (bytes < 0) { bytes = of_object_fixed_len[version][OF_BSN_BW_CLEAR_DATA_REPLY] + of_object_extra_len[version][OF_BSN_BW_CLEAR_DATA_REPLY]; } obj->version = version; obj->length = bytes; obj->object_id = OF_BSN_BW_CLEAR_DATA_REPLY; /* Set up the object's function pointers */ obj->wire_type_set = of_bsn_bw_clear_data_reply_push_wire_types; obj->wire_length_get = of_object_message_wire_length_get; obj->wire_length_set = of_object_message_wire_length_set; /* Grow the wire buffer */ if (obj->wire_object.wbuf != NULL) { int tot_bytes; tot_bytes = bytes + obj->wire_object.obj_offset; of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes); } } /** * Create a new of_bsn_bw_clear_data_reply object and bind it to an existing message * * @param msg The message to bind the new object to * @return Pointer to the newly create object or NULL on error * * \ingroup of_bsn_bw_clear_data_reply */ of_bsn_bw_clear_data_reply_t * of_bsn_bw_clear_data_reply_new_from_message(of_message_t msg) { of_bsn_bw_clear_data_reply_t *obj = NULL; of_version_t version; int length; if (msg == NULL) return NULL; version = of_message_version_get(msg); if (!OF_VERSION_OKAY(version)) return NULL; length = of_message_length_get(msg); if ((obj = (of_bsn_bw_clear_data_reply_t *)of_object_new(-1)) == NULL) { return NULL; } of_bsn_bw_clear_data_reply_init(obj, version, 0, 0); if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg), length, OF_MESSAGE_FREE_FUNCTION)) < 0) { FREE(obj); return NULL; } obj->length = length; obj->version = version; return obj; } /** * Get xid from an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param xid Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_bw_clear_data_reply_xid_get( of_bsn_bw_clear_data_reply_t *obj, uint32_t *xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set xid in an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param xid The value to write into the object */ void of_bsn_bw_clear_data_reply_xid_set( of_bsn_bw_clear_data_reply_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get experimenter from an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param experimenter Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_bw_clear_data_reply_experimenter_get( of_bsn_bw_clear_data_reply_t *obj, uint32_t *experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set experimenter in an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param experimenter The value to write into the object */ void of_bsn_bw_clear_data_reply_experimenter_set( of_bsn_bw_clear_data_reply_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get subtype from an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param subtype Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_bw_clear_data_reply_subtype_get( of_bsn_bw_clear_data_reply_t *obj, uint32_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set subtype in an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param subtype The value to write into the object */ void of_bsn_bw_clear_data_reply_subtype_set( of_bsn_bw_clear_data_reply_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Get status from an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param status Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_bw_clear_data_reply_status_get( of_bsn_bw_clear_data_reply_t *obj, uint32_t *status) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, status); OF_LENGTH_CHECK_ASSERT(obj); return ; } /** * Set status in an object of type of_bsn_bw_clear_data_reply. * @param obj Pointer to an object of type of_bsn_bw_clear_data_reply. * @param status The value to write into the object */ void of_bsn_bw_clear_data_reply_status_set( of_bsn_bw_clear_data_reply_t *obj, uint32_t status) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; LOCI_ASSERT(obj->object_id == OF_BSN_BW_CLEAR_DATA_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); LOCI_ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: LOCI_ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); LOCI_ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, status); OF_LENGTH_CHECK_ASSERT(obj); return ; }
26.50554
136
0.662459
[ "object" ]
efda96bb763d9ac3d71df18a7d72848d4257db3d
2,896
h
C
include/compiler.h
THOSE-EYES/mmix
e27ae3e98cb0cac72b919312d4c3d6ad7a27d92d
[ "Apache-2.0" ]
null
null
null
include/compiler.h
THOSE-EYES/mmix
e27ae3e98cb0cac72b919312d4c3d6ad7a27d92d
[ "Apache-2.0" ]
null
null
null
include/compiler.h
THOSE-EYES/mmix
e27ae3e98cb0cac72b919312d4c3d6ad7a27d92d
[ "Apache-2.0" ]
null
null
null
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #pragma once // Include C++ STL headers #include <vector> #include <map> #include <string> // Include project headers #include "instruction.h" #include "mnemonics.h" #include "sizes.h" #include "preprocessor.h" namespace mmix { namespace compiler { using CompiledProgram = std::vector<uint64_t>; } /** * The compiler of MMIX instructions */ // FIXME : addresses should be instruction_number * obj_entry_size class Compiler { protected : using AllocatedData = std::pair<const std::string, uint64_t>; using DataTable = std::map<std::string, uint64_t>; // FIXME : store an instance of Lexer class std::shared_ptr<preprocessor::PreprocessedProgram> program_; // The preprocessed program std::shared_ptr<compiler::CompiledProgram> compiled_; // The compiled sources std::shared_ptr<DataTable> data_table_; // Table of addresses of the allocated data protected : /** * Allocate data for the value * @param size the size of the data * @param value the value to store in the allocated space */ void allocate(std::string size, std::string value); /** * Allocate data for the value * @param size the size of the data * @param value the value to store in the allocated space */ void allocate(std::string size, uint32_t value); /** * Convert instruction into digital representation * @param instruction the instruction to convert */ void convert(std::shared_ptr<Mnemonic>& instruction); /** * Fill the table of addresses */ void fill_table(void); /** * Replace labels with the addresses from the table * @param instruction the instruction to process */ void replace_labels(Instruction::Parameters& parameters); /** * Compile the program */ void compile(void); public : /** * Constructor * @param program the program to compile */ Compiler(std::shared_ptr<preprocessor::PreprocessedProgram> program); /** * Get the compiled program * @return a compiled version of the program */ std::shared_ptr<compiler::CompiledProgram> get(void); }; }
28.116505
92
0.709599
[ "vector" ]
efe39cef4f12556e0f6acccf619d44c533b1134e
468
h
C
packages/mccomponents/lib/kernels/sample/SQ/fxyz.h
mcvine/mcvine
42232534b0c6af729628009bed165cd7d833789d
[ "BSD-3-Clause" ]
5
2017-01-16T03:59:47.000Z
2020-06-23T02:54:19.000Z
packages/mccomponents/lib/kernels/sample/SQ/fxyz.h
mcvine/mcvine
42232534b0c6af729628009bed165cd7d833789d
[ "BSD-3-Clause" ]
293
2015-10-29T17:45:52.000Z
2022-01-07T16:31:09.000Z
packages/mccomponents/lib/kernels/sample/SQ/fxyz.h
mcvine/mcvine
42232534b0c6af729628009bed165cd7d833789d
[ "BSD-3-Clause" ]
1
2019-05-25T00:53:31.000Z
2019-05-25T00:53:31.000Z
// -*- C++ -*- // // #ifndef MCCOMPONENTS_KERNELS_SAMPLE_SQ_FXYZ_H #define MCCOMPONENTS_KERNELS_SAMPLE_SQ_FXYZ_H #include <vector> #include "histogram/EvenlySpacedGridData_3D.h" namespace mccomponents { namespace sample { typedef DANSE::Histogram::EvenlySpacedGridData_3D <double, double, double, double, std::vector<double>::iterator > fxyz; } // sample:: } // mccomponents:: #endif // MCCOMPONENTS_KERNELS_SAMPLE_SQ_FXYZ_H // End of file
16.714286
53
0.726496
[ "vector" ]
efed3ab04f3c587a194bf5ccfe9438cd287d908c
63,952
c
C
RIPEM3B4/ripem/main/keyman.c
ab300819/applied-cryptography
3fddc4cda2e1874e978608259034d36c60a4dbba
[ "MIT", "Unlicense" ]
1
2021-04-17T05:01:00.000Z
2021-04-17T05:01:00.000Z
RIPEM3B4/ripem/main/keyman.c
ab300819/applied-cryptography
3fddc4cda2e1874e978608259034d36c60a4dbba
[ "MIT", "Unlicense" ]
null
null
null
RIPEM3B4/ripem/main/keyman.c
ab300819/applied-cryptography
3fddc4cda2e1874e978608259034d36c60a4dbba
[ "MIT", "Unlicense" ]
null
null
null
/* No representations are made concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. License to copy and use this software is granted provided that these notices are retained in any copies of any part of this documentation and/or software. */ /*--- file keyman.c -- Manage public keys * * Mark Riordan 20 May 1992 */ #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> #include "global.h" #include "rsaref.h" #include "ripem.h" #include "keyfield.h" #ifdef USE_DDES #include "ddes.h" #else #include "des.h" #endif #include "keymanpr.h" #include "strutilp.h" #include "derkeypr.h" #include "hexbinpr.h" #include "ripemsop.h" #include "pubinfop.h" #include "keyderpr.h" #include "bfstream.h" #include "rdwrmsgp.h" #include "certder.h" #include "certutil.h" #include "bemparse.h" #include "p.h" #define DER_SEQ 0x30 #define RECSIZE 3000 #define MAXKEYBYTES 1024 #define MAX_PRENCODE_BYTES 48 #define LINELEN 256 static char *GetKeyBytesFromFile P((char *, char *, FILE *, char *, BOOL *, unsigned char **, unsigned int *, RIPEMInfo *)); static char *GetNextCRLFromFile P((BOOL *, unsigned char **, UINT4 *, FILE *, char *, UINT4)); static char *ReadEncodedField P((unsigned char **, unsigned int *, FILE *)); static char *GetUserRecordFromFile P((char *, TypFile *, unsigned int, char *, BOOL *, RIPEMInfo *)); static char *OpenKeySource P((TypKeySource *, char *, RIPEMInfo *)); /* Initialize the key sources and origins. */ void RIPEMDatabaseConstructor (ripemDatabase) RIPEMDatabase *ripemDatabase; { InitList (&ripemDatabase->pubKeySource.filelist); InitList (&ripemDatabase->privKeySource.filelist); InitList (&ripemDatabase->crlSource.filelist); InitList (&ripemDatabase->privKeySource.serverlist); InitList (&ripemDatabase->pubKeySource.serverlist); InitList (&ripemDatabase->crlSource.serverlist); ripemDatabase->pubKeySource.origin[0] = KEY_FROM_SERVER; ripemDatabase->privKeySource.origin[0] = KEY_FROM_SERVER; ripemDatabase->crlSource.origin[0] = KEY_FROM_SERVER; ripemDatabase->pubKeySource.origin[1] = KEY_FROM_FILE; ripemDatabase->privKeySource.origin[1] = KEY_FROM_FILE; ripemDatabase->crlSource.origin[1] = KEY_FROM_FILE; ripemDatabase->pubKeySource.origin[2] = KEY_FROM_FINGER; ripemDatabase->privKeySource.origin[2] = KEY_FROM_FINGER; ripemDatabase->crlSource.origin[2] = KEY_FROM_FINGER; ripemDatabase->preferencesFilename = (char *)NULL; } /* Insert the filename at the beginning of keySource's filelist if it is not already in the list. This makes a copy of the filename. This does not open the file. (Use InitRIPEMDatabase after all filenames for all key sources have been added.) Return NULL for success, otherwise error string. */ char *AddKeySourceFilename (keySource, filename) TypKeySource *keySource; char *filename; { TypListEntry *entry; TypFile *typFile; char *errorMessage; /* First check if the filename is already in the key source. */ for (entry = keySource->filelist.firstptr; entry != (TypListEntry *)NULL; entry = entry->nextptr) { if (strcmp (filename, ((TypFile *)entry->dataptr)->filename) == 0) /* Already have the filename, so do nothing. */ return ((char *)NULL); } if ((typFile = (TypFile *)malloc (sizeof (*typFile))) == (TypFile *)NULL) return (ERR_MALLOC); typFile->stream = NULL; if (strcpyalloc (&typFile->filename, filename) == (char *)NULL) { free (typFile); return (ERR_MALLOC); } if ((errorMessage = PrependToList (typFile, sizeof (*typFile), &keySource->filelist)) != (char *)NULL) { free (typFile->filename); free (typFile); return (errorMessage); } return ((char *)NULL); } /* homeDir is the name of the RIPEM home directory. It must end in the necessary directory separator, such as '/' in Unix, so that filenames in the directory can just be appended. The calling routine is also responsible for making sure the directory exists. This can be done, for example, by trying the open the crls file for append. This adds pubkeys, privkey, and crls in the homeDir to pubKeySource, privKeySource and crlSource in ripemDatabase if not already there. This then makes sure these filenames can be opened for output and are in the front of the keySource list as required for database output files. Then it opens all the fileList->stream entries in the keySources for read. (There may already be files which were added by AddKeySourceFilename.) This also allocates and sets ripemDatabase->preferencesFilename to preferen in the homeDir and makes sure it can be opened for append. ripemInfo is used only for error and debug output. */ char *InitRIPEMDatabase (ripemDatabase, homeDir, ripemInfo) RIPEMDatabase *ripemDatabase; char *homeDir; RIPEMInfo *ripemInfo; { FILE *stream; char *path = (char *)NULL, *errorMessage = (char *)NULL; unsigned int homeDirLen; /* For error, break to end of do while (0) block. */ do { /* Allocate space for the homeDir plus a filename in the path and copy the homeDir to the front of the path. */ homeDirLen = strlen (homeDir); if ((path = malloc (homeDirLen + 10)) == (char *)NULL) { errorMessage = ERR_MALLOC; break; } strcpy (path, homeDir); /* For each of the databases, concatenate the file name to the homeDir, add the name to the key sources, and then open the key source. */ strcpy (path + homeDirLen, "pubkeys"); if ((errorMessage = AddKeySourceFilename (&ripemDatabase->pubKeySource, path)) != (char *)NULL) break; if ((errorMessage = OpenKeySource (&ripemDatabase->pubKeySource, path, ripemInfo)) != (char *)NULL) break; strcpy (path + homeDirLen, "privkey"); if ((errorMessage = AddKeySourceFilename (&ripemDatabase->privKeySource, path)) != (char *)NULL) break; if ((errorMessage = OpenKeySource (&ripemDatabase->privKeySource, path, ripemInfo)) != (char *)NULL) break; strcpy (path + homeDirLen, "crls"); if ((errorMessage = AddKeySourceFilename (&ripemDatabase->crlSource, path)) != (char *)NULL) break; if ((errorMessage = OpenKeySource (&ripemDatabase->crlSource, path, ripemInfo)) != (char *)NULL) break; /* Make sure the preferences file can be opened for append. This will create the file if it doesn't exist. */ strcpy (path + homeDirLen, "preferen"); if ((stream = fopen (path, "a")) == (FILE *)NULL) { sprintf (ripemInfo->errMsgTxt, "Can't write to file \"%s\". (Does its directory exist?)", path); errorMessage = ripemInfo->errMsgTxt; break; } /* Successfully opened, so just close it. */ fclose (stream); /* Set the preferences filename by trasferring the path string to the ripemDatabase since we are done with the path. */ ripemDatabase->preferencesFilename = path; /* Set to NULL so it won't be freed below. */ path = (char *)NULL; } while (0); free (path); return (errorMessage); } /* Close the files and free the key source lists. */ void RIPEMDatabaseDestructor (ripemDatabase) RIPEMDatabase *ripemDatabase; { TypListEntry *entry; TypFile *typFile; for (entry = ripemDatabase->privKeySource.filelist.firstptr; entry != (TypListEntry *)NULL; entry = entry->nextptr) { typFile = (TypFile *)entry->dataptr; free (typFile->filename); if (typFile->stream != (FILE *)NULL) fclose (typFile->stream); } for (entry = ripemDatabase->pubKeySource.filelist.firstptr; entry != (TypListEntry *)NULL; entry = entry->nextptr) { typFile = (TypFile *)entry->dataptr; free (typFile->filename); if (typFile->stream != (FILE *)NULL) fclose (typFile->stream); } for (entry = ripemDatabase->crlSource.filelist.firstptr; entry != (TypListEntry *)NULL; entry = entry->nextptr) { typFile = (TypFile *)entry->dataptr; free (typFile->filename); if (typFile->stream != (FILE *)NULL) fclose (typFile->stream); } FreeList (&ripemDatabase->pubKeySource.filelist); FreeList (&ripemDatabase->privKeySource.filelist); FreeList (&ripemDatabase->crlSource.filelist); FreeList (&ripemDatabase->privKeySource.serverlist); FreeList (&ripemDatabase->pubKeySource.serverlist); FreeList (&ripemDatabase->crlSource.serverlist); free (ripemDatabase->preferencesFilename); } /* Get the public key of a user from a PublicKeyInfo field (as opposed * to a certificate). This is provided only for compatibility with * RIPEM 1.1. * * Entry: user is the user's email address. * source tells us where to look. * ripemInfo is used to access debug and debugStream. * * Exit: key is the key (if found). * found is TRUE if we found the key. * Returns an error message if something goes wrong more * serious than not being able to find the key. */ char *GetUnvalidatedPublicKey (user, source, key, found, ripemInfo) char *user; TypKeySource *source; R_RSA_PUBLIC_KEY *key; BOOL *found; RIPEMInfo *ripemInfo; { int sour; unsigned int derLen = 0; static BOOL server_ok=TRUE; #define MAXDIGESTSIZE 36 char *rec = (char *)NULL, *coded_bytes = (char *)NULL, *errorMessage = (char *)NULL, computed_hex_digest[MAXDIGESTSIZE], records_hex_digest[MAXDIGESTSIZE]; unsigned char *key_bytes = (unsigned char *)NULL, *bytes = NULL; TypFile *fptr; /* For error, break to end of do while (0) block. */ do { /* Allocate on heap since they are too big for the stack */ if ((rec = (char *)malloc (RECSIZE)) == (char *)NULL) { errorMessage = ERR_MALLOC; break; } if ((coded_bytes = (char *)malloc (MAXKEYBYTES)) == (char *)NULL) { errorMessage = ERR_MALLOC; break; } if ((key_bytes = (unsigned char *)malloc (MAXKEYBYTES)) == (unsigned char *)NULL) { errorMessage = ERR_MALLOC; break; } *found = FALSE; for(sour=0; !*found && sour<MAX_KEY_SOURCES; sour++) switch(source->origin[sour]) { /* Search the key file */ case KEY_FROM_FILE: FORLIST(&(source->filelist)); fptr = (TypFile *)dptr; if(!fptr->stream) { sprintf(ripemInfo->errMsgTxt,"Can't open public key file \"%s\".", fptr->filename); errorMessage = ripemInfo->errMsgTxt; continue; } /* Get the user record for this user from the file. */ errorMessage = GetUserRecordFromFile (user,fptr,RECSIZE,rec,found,ripemInfo); if(*found) goto decodekey; ENDFORLIST; break; /* Get key from server. */ case KEY_FROM_SERVER: if(server_ok) { errorMessage = GetUserRecordFromServer (user,source, rec,RECSIZE,&server_ok,found,ripemInfo); goto decodekey; } /* Get key from finger. */ case KEY_FROM_FINGER: errorMessage = GetUserRecordFromFinger (user,rec,RECSIZE,found,ripemInfo); decodekey: if(ripemInfo->debug>1) { if(errorMessage) { fprintf(ripemInfo->debugStream, "Error retrieving key for %s from server: %s\n", user,errorMessage); } else if(*found) { fprintf(ripemInfo->debugStream, "Found %s's public key record:\n%s\n",user,rec); } else { fprintf(ripemInfo->debugStream, "Couldn't find %s's public key record.\n", user); } } if(*found) { if (!CrackKeyField(rec,PUBLIC_KEY_FIELD,coded_bytes,MAXKEYBYTES)) { /* There is no public key field. */ *found = FALSE; break; } if(ripemInfo->debug>1) { fprintf(ripemInfo->debugStream,"Coded pub key=\"%s\"\n",coded_bytes); } /* CrackKeyField skips all whitespace and null-terminates the coded_bytes. key_bytes is the same size as coded_bytes so the smaller decoded bytes will fit. */ R_DecodePEMBlock (key_bytes, &derLen, (unsigned char *)coded_bytes, strlen (coded_bytes)); bytes = key_bytes; } break; default: break; /* XXX */ } if(*found) { /* Convert key bytes to public key structure format. */ if(DERToPubKey(bytes,key)) { /* Conversion didn't work. */ sprintf(ripemInfo->errMsgTxt,"Error parsing public key for %s.",user); errorMessage = ripemInfo->errMsgTxt; } else { /* Conversion from BER format worked OK. * Now check this public key against the enclosed digest. */ MakeHexDigest((unsigned char *)bytes,derLen,computed_hex_digest); if(CrackKeyField(rec,PUBLIC_KEY_DIGEST_FIELD, records_hex_digest,MAXDIGESTSIZE)) { if(ripemInfo->debug > 2) { fprintf(ripemInfo->debugStream, "der len=%u\nComputed MD5 of %s's pubkey=%s\n",derLen, user, computed_hex_digest); fprintf(ripemInfo->debugStream, "Retrieved MD5 of %s's pubkey=%s\n",user, records_hex_digest); } if(strcmp(computed_hex_digest,records_hex_digest)) { sprintf(ripemInfo->errMsgTxt, "Public key of '%s' is garbled--digest does not match.", user); errorMessage = ripemInfo->errMsgTxt; } } else { if (ripemInfo->debug > 1) fprintf (ripemInfo->debugStream, "Warning--could not find %s's key digest.\n", user); } } } } while (0); free (rec); free (coded_bytes); free (key_bytes); return (errorMessage); } /*--- function GetPrivateKey ------------------------------------- * * Get the private key of a user. * RIPEMInfo is used for debug and debugStream. */ char *GetPrivateKey (user, source, key, password, passwordLen, ripemInfo) char *user; TypKeySource *source; R_RSA_PRIVATE_KEY *key; unsigned char *password; unsigned int passwordLen; RIPEMInfo *ripemInfo; { BOOL found = FALSE; TypFile *fptr; char *errorMessage = (char *)NULL; int digest_alg, sour; unsigned char *bytes = (unsigned char *)NULL, *enc_key = (unsigned char *)NULL, salt[SALT_SIZE]; unsigned int enc_key_len, iter_count, num_der_bytes, nbytes, enc_keyBufferSize = 0; /* For error, break to end of do while (0) block. */ do { for (sour = 0; sour < MAX_KEY_SOURCES; sour++) { if (source->origin[sour] == KEY_FROM_FILE) { FORLIST (&(source->filelist)); fptr = (TypFile *)dptr; if (!fptr->stream) { sprintf (ripemInfo->errMsgTxt, "Private key file \"%s\" is not open.", fptr->filename); errorMessage = ripemInfo->errMsgTxt; break; } /* Rewind in order to search from the beginning. */ fseek (fptr->stream, 0L, 0); if ((errorMessage = GetKeyBytesFromFile (USER_FIELD, user, fptr->stream, PRIVATE_KEY_FIELD, &found, &bytes, &nbytes, ripemInfo)) != (char *)NULL) break; if (found) break; ENDFORLIST; if (errorMessage != (char *)NULL) /* broke loop because of error */ break; } } if (errorMessage != (char *)NULL) /* broke loop because of error */ break; if (!found) { sprintf (ripemInfo->errMsgTxt, "Can't find private key for %s.", user); errorMessage = ripemInfo->errMsgTxt; break; } /* We now have the DER-encoded encrypted private key structure. First, decode it to obtain the encryption algorithm parameters and the actual bytes of the encrypted key. */ if (ripemInfo->debug > 1) { fprintf (ripemInfo->debugStream, "Obtained %u byte encrypted private key for %s:\n", nbytes, user); BEMParse (bytes, ripemInfo->debugStream); } /* Allocate a buffer the the encrypted bytes. */ enc_keyBufferSize = nbytes; if ((enc_key = (unsigned char *)malloc (enc_keyBufferSize)) == (unsigned char *)NULL) { errorMessage = ERR_MALLOC; break; } if (DERToEncryptedPrivKey (bytes, nbytes, &digest_alg, salt, &iter_count, enc_key, &enc_key_len)) { errorMessage = "Error decoding encrypted private key."; break; } /* Now decrypt the encrypted key. */ if (pbeWithMDAndDESWithCBC (FALSE, digest_alg, enc_key, enc_key_len, password, passwordLen, salt, iter_count, &num_der_bytes) != 0) { errorMessage = "Can't decrypt private key."; break; } /* We have the plaintext private key in DER format. * Check to make sure it looks as if it was decrypted OK. * Then Decode to RSAREF format. */ if (enc_key[0] != DER_SEQ) { errorMessage = "Private key could not be decrypted with this password."; break; } if (DERToPrivKey (enc_key, key)) { sprintf (ripemInfo->errMsgTxt, "Error parsing private key for %s.",user); errorMessage = ripemInfo->errMsgTxt; break; } if (ripemInfo->debug > 1) { fprintf (ripemInfo->debugStream, "Dump of decrypted private key:\n"); DumpPrivKey (key, ripemInfo->debugStream); } } while (0); if (enc_key != (unsigned char *)NULL) { R_memset ((POINTER)enc_key, 0, enc_keyBufferSize); free (enc_key); } free (bytes); return (errorMessage); } #ifndef RIPEMSIG /* Generate a DEK and encrypt it with each recipient's public key. Also generate the IV and initialize the sealContext. Note that the encrypted DEKs are not ASCII recoded. encryptedKeysBuffer has recipientKeyCount concatenated buffers of length MAX_ENCRYTED_KEY_LEN. encryptedKeyLens is an array of recipientKeyCount unsigned ints which will receive the lengths of the encrypted keys (see R_SealInit). ripemInfo is used for random struct and debug info. */ char *RIPEMSealInit (ripemInfo, sealContext, iv, encryptedKeysBuffer, encryptedKeyLens, recipientKeys, recipientKeyCount, encryptionAlgorithm) RIPEMInfo *ripemInfo; R_ENVELOPE_CTX *sealContext; unsigned char *iv; unsigned char *encryptedKeysBuffer; unsigned int *encryptedKeyLens; RecipientKeyInfo *recipientKeys; unsigned int recipientKeyCount; int encryptionAlgorithm; { R_RSA_PUBLIC_KEY **publicKeys = (R_RSA_PUBLIC_KEY **)NULL; char *errorMessage = (char *)NULL; int status; unsigned char **encryptedKeys = (unsigned char **)NULL; unsigned int i; /* For error, break to end of do while (0) block. */ do { /* Allocate arrays for the public key and encrypted key pointers. */ if ((publicKeys = (R_RSA_PUBLIC_KEY **)malloc (recipientKeyCount * sizeof (*publicKeys))) == (R_RSA_PUBLIC_KEY **)NULL || (encryptedKeys = (unsigned char **)malloc (recipientKeyCount * sizeof (*encryptedKeys))) == (unsigned char **)NULL) { errorMessage = ERR_MALLOC; break; } /* Set up the arrays for each public key and allocate the buffers which will hold the actual encrypted keys. */ for (i = 0; i < recipientKeyCount; ++i) { publicKeys[i] = &recipientKeys[i].publicKey; encryptedKeys[i] = encryptedKeysBuffer + i * MAX_ENCRYPTED_KEY_LEN; } /* Now we can call R_SealInit which will create all the encrypted DEKs and generate the iv. */ if ((status = R_SealInit (sealContext, encryptedKeys, encryptedKeyLens, iv, recipientKeyCount, publicKeys, encryptionAlgorithm, &ripemInfo->randomStruct)) != 0) return (FormatRSAError (status)); if (ripemInfo->debug > 1) { char hex_digest[36], line[80]; /* Now print the debug info. */ for (i = 0; i < recipientKeyCount; ++i) { fprintf (ripemInfo->debugStream, "keyLen=%u, user=%s\n", encryptedKeyLens[i], recipientKeys[i].username); MakeHexDigest (encryptedKeys[i], encryptedKeyLens[i], hex_digest); fprintf (ripemInfo->debugStream, " MD5 of Encrypted Key (not recoded) = %s\n", hex_digest); fprintf(ripemInfo->debugStream," Encrypted, encoded MIC =\n"); BinToHex (iv, 8, line); fprintf (ripemInfo->debugStream, " Initializing vector = %s\n", line); } BinToHex (iv, 8, line); fprintf (ripemInfo->debugStream, " Initializing vector = %s\n", line); } } while (0); free (publicKeys); free (encryptedKeys); return (errorMessage); } #endif /* Obtain the value of a field from a flat file. This searches for the next record with the given keyName with a matching keyValue and gets the fieldName. The calling routine must rewind the file to begin a new search. The file is ASCII newline-delimited and consists of keys of form: keyName: keyValue and fields of form: fieldName: value... (RFC1113 encoded) Entry: keyName is the key name like "User:" keyValue is the key value for keyName. If this is (char *)NULL, then the match is always true. stream is the stream pointing at the file. fieldName is the name of the field, e.g. PublicKeyInfo. ripemInfo is used for debug and debugStream. Exit: bytes points to the bytes as a newly allocated buffer. numBytes is the number of bytes retrieved. found is TRUE if we found the key. Returns an error message if an error was found (more serious than the key value not being found). */ static char *GetKeyBytesFromFile (keyName, keyValue, stream, fieldName, found, bytes, numBytes, ripemInfo) char *keyName; char *keyValue; FILE *stream; char *fieldName; BOOL *found; unsigned char **bytes; unsigned int *numBytes; RIPEMInfo *ripemInfo; { #define VALUELEN 120 char value[VALUELEN]; BOOL gotRecord; char *errorMessage = NULL; /* Default to not found */ *found = FALSE; *bytes = (unsigned char *)NULL; /* For error, break to end of do while (0) block. */ do { /* Position to just after the line containing the keyValue's name. */ gotRecord = FALSE; while (GetFileLine (stream, keyName, value, sizeof (value))) { if (keyValue == (char *)NULL || R_match (value, keyValue)) { gotRecord = TRUE; break; } } if (!gotRecord) break; /* We are now in the section of the file that corresponds to this keyValue. Position to the desired field. (There aren't many fields; we do this in case there are multiple "keyName:" fields and to account for future changes.) Assume the fieldName is on a line by itself. */ if (!PosFileLine (stream, fieldName, (FILE *)NULL)) /* *found is already false */ break; /* Now read the RFC1113-encoded lines and translate them to binary. */ if ((errorMessage = ReadEncodedField (bytes, numBytes, stream)) != (char *)NULL) break; *found = TRUE; } while (0); if(ripemInfo->debug > 1) { if (*found) { fprintf (ripemInfo->debugStream,"Obtained %s for %s from file.\n", fieldName, value); } else { if (keyValue == (char *)NULL) fprintf (ripemInfo->debugStream, "Could not find %s for key type %s in file.\n", fieldName, keyName); else fprintf (ripemInfo->debugStream, "Could not find %s of keyValue %s in file.\n", fieldName, keyValue); } } return (errorMessage); } /* Read an encoded field from a file and return it in an allocated buffer. This reads lines until a blank line, end of file, or a line with non-whitespace in the first column. Return NULL for success, otherwise error string. */ static char *ReadEncodedField (field, fieldLen, stream) unsigned char **field; unsigned int *fieldLen; FILE *stream; { #define KALLOC_INC 1080 char line[VALUELEN]; unsigned char *bytes, *newField; int bytesleft, allocSize; unsigned int bytesInLine; /* Allocate initial buffer. */ if ((*field = (unsigned char *)malloc (KALLOC_INC)) == (unsigned char *)NULL) return (ERR_MALLOC); bytes = *field; allocSize = bytesleft = KALLOC_INC; *fieldLen = 0; while (1) { if (!fgets (line, sizeof (line), stream)) { /* Make sure we got NULL because of end of file. */ if (!feof (stream)) return ("Error reading bytes from flat file"); /* Done */ return ((char *)NULL); } if (!WhiteSpace (line[0]) || LineIsWhiteSpace (line)) /* Reached the end */ return ((char *)NULL); /* If we need more room in field, allocate more. Reassign pointers as necessary. */ if (bytesleft < MAX_PRENCODE_BYTES) { allocSize += KALLOC_INC; if ((newField = (unsigned char *)R_realloc (*field, allocSize)) == (unsigned char *)NULL) { free (*field); return (ERR_MALLOC); } *field = newField; bytes = *field + *fieldLen; } /* Decode the line into the value buffer. Assume the input line has one prefix space and that the decode won't return more than MAX_PRENCODE_BYTES. Assume each line except the last has a multiple of 4 chars. Also assume there is one '\n' and no spaces at the end of line. */ R_DecodePEMBlock (bytes, &bytesInLine, (unsigned char *)(line + 1), strlen (line + 1) - 1); bytes += bytesInLine; *fieldLen += bytesInLine; bytesleft -= bytesInLine; } } /*--- function GetUserRecordFromFile -------------------------------------- * * Get the user record for a user from a file. A user record * is a series of ASCII lines like: * User: joe@bigu.edu * PublicKeyInfo: * MIGcMAoGBFUIAQECAgQAA4GNADCBiQKBgQDGQci5pOCGqQgW6XUYyGCcZFIyyLb7 * 18nsKtQNjHZRODHkd+5tmHzMWp2BdFfV+CQzbMeNcdC9lC/RhLb7AgMBAAE= * MD5OfPublicKey: E69AB9AA2A2697FCB5B1821DC3596345 * * Entry: user is the user name (email address) whose record we want. * fileptr contains the stream pointing at the file. * maxBytes is the size of the buffer used to return data. * ripemInfo is used for debug and debugStream. * * Exit: userRec contains the user record, if found. It is * zero-terminated. * found is TRUE if we found the key. * Returns an error message if an error was found (more serious * than the key value not being found), else NULL. */ static char *GetUserRecordFromFile (user, fileptr, maxBytes, userRec, found, ripemInfo) char *user; TypFile *fileptr; unsigned int maxBytes; char *userRec; BOOL *found; RIPEMInfo *ripemInfo; { BOOL got_next_rec; char *errorMessage; *found = FALSE; fseek(fileptr->stream,0L,0); /* Rewind the file. */ if(ripemInfo->debug>1) { fprintf(ripemInfo->debugStream,"Looking in '%s' for public key for %s.\n", fileptr->filename,user); } while (1) { if ((errorMessage = GetNextUserRecordFromFile (fileptr->stream, maxBytes, userRec, &got_next_rec)) != (char *)NULL) return (errorMessage); if (got_next_rec) { if ((errorMessage = FindUserInRecord (found, user, userRec)) != (char *)NULL) return (errorMessage); if (*found) break; } else break; } if(ripemInfo->debug>1) { if(*found) { fprintf(ripemInfo->debugStream,"Found %s's public key record in file.\n", user); } else { fprintf(ripemInfo->debugStream,"Didn't find %s's public key in file.\n", user); } } return ((char *)NULL); } /*--- function GetNextUserRecordFromFile ---------------------------------- * * Get the next user record from a sequential file. * A user record is just a sequence of lines limited by a * blank line or a line starting with "--". * * Entry: ustream is the stream of the file. * maxBytes is the buffer size of userRec. * * Exit: userRec is the user record, if found. * found is TRUE if we successfully retrieved a record. * Returns an error message if there was a problem worse * than EOF, else NULL. */ char *GetNextUserRecordFromFile (ustream, maxBytes, userRec, found) FILE *ustream; unsigned int maxBytes; char *userRec; BOOL *found; { char *line = (char *)NULL, *errorMessage = (char *)NULL, *uptr, *got_line; unsigned int mylen; BOOL finished; /* For error, break to end of do while (0) block. */ do { /* Allocate on heap since it is too big for the stack */ if ((line = (char *)malloc (LINELEN)) == (char *)NULL) { errorMessage = ERR_MALLOC; break; } uptr = userRec; *found = FALSE; /* Skip past leading blank lines */ finished = FALSE; do { if (!fgets (line, LINELEN, ustream)) { if (!feof (ustream)) { errorMessage = "Error in stream while reading user record"; break; } finished = TRUE; break; } } while (LineIsWhiteSpace (line) || strncmp (line ,"---", 2) == 0); if (finished || errorMessage != (char *)NULL) break; /* We hit a non-blank line. Copy lines into the buffer until we hit EOF or blank line. */ *found = TRUE; do { mylen = (unsigned int)strlen (line); /* Copy this line into the buffer if there's room, * else just return the truncated buffer. */ if (maxBytes > mylen) { strcpy (uptr, line); uptr += mylen; maxBytes -= mylen; } else break; got_line = fgets (line, LINELEN, ustream); } while (got_line && !LineIsWhiteSpace (line) && strncmp (line, "---", 2)); } while (0); free (line); return (errorMessage); } /*--- function pbeWithMDAndDESWithCBC -------------------------------------- * * Encrypt or decrypt a buffer in place with DES-CBC, using a key derived * from using a message disest (MDx) function on a password * and salt value. */ int pbeWithMDAndDESWithCBC (encrypt, digestAlg, buf, numInBytes, password, passwordLen, salt, iterationCount, numOutBytes) int encrypt; int digestAlg; unsigned char *buf; unsigned int numInBytes; unsigned char *password; unsigned int passwordLen; unsigned char *salt; unsigned int iterationCount; unsigned int *numOutBytes; { R_DIGEST_CTX context; unsigned char byte, parity, *bptr, digest[MD5_LEN], des_key[DES_KEY_SIZE], iv[DES_BLOCK_SIZE]; unsigned int n_pad_bytes, j, bit, digestLen; if(digestAlg != DA_MD5) return 1; /* First iteration is a digest of password || salt */ R_DigestInit (&context, DA_MD5); R_DigestUpdate (&context, password, passwordLen); R_DigestUpdate (&context, salt, SALT_SIZE); R_DigestFinal (&context, digest, &digestLen); /* Subsequent iterations are digests of the previous digest. */ while (--iterationCount) R_DigestBlock (digest, &digestLen, digest, MD5_LEN, DA_MD5); /* Create the DES key by taking the first 8 bytes of the * digest and setting the low order bit to be an odd parity bit. */ for(j=0; j<DES_KEY_SIZE; j++) { byte = digest[j]; for(parity=0x01,bit=0; bit<7; bit++) { byte >>= 1; parity ^= (byte&0x01); } des_key[j] = (digest[j]&0xfe) | parity; } /* Create the initialization vector from the last 8 bytes of the digest */ R_memcpy(iv,digest+DES_KEY_SIZE,DES_BLOCK_SIZE); /* Now we have the DES key and the init vector. * Do the encrypt or decrypt. */ if(encrypt) { /* Pad the last block of the buffer with 1 to 8 bytes of * the value 01 or 0202 or 030303 or... */ n_pad_bytes = DES_BLOCK_SIZE - numInBytes%DES_BLOCK_SIZE; for(bptr=buf+numInBytes,j=0; j<n_pad_bytes; j++,bptr++) { *bptr = n_pad_bytes; } *numOutBytes = numInBytes+n_pad_bytes; DESWithCBC(encrypt,buf,*numOutBytes,des_key,iv); } else { /* Do the decryption */ if(numInBytes%DES_BLOCK_SIZE) return 1; DESWithCBC(encrypt,buf,numInBytes,des_key,iv); n_pad_bytes = buf[numInBytes-1]; *numOutBytes = numInBytes - n_pad_bytes; } R_memset (digest, 0, sizeof (digest)); R_memset (des_key, 0, sizeof (des_key)); R_memset (iv, 0, sizeof (iv)); return 0; } /*--- function DESWithCBC ------------------------------------------ * * Encrypt or decrypt a buffer with DES with Cipher Block Chaining. * * Entry: encrypt is TRUE to encrypt, else decrypt. * buf is the beginning of the buffer. * numBytes is the number of bytes to encrypt/decrypt. * It is rounded up to a multiple of 8. * key is the 8-byte key. * iv is the initialization vector. (We pretend * it is the output from the previous round * of encryption.) * * Exit: buf has been encrypted/decrypted. */ void DESWithCBC(encrypt,buf,numBytes,key,iv) int encrypt; unsigned char *buf; unsigned int numBytes; unsigned char *key; unsigned char *iv; { #ifdef USE_DDES int mode = !encrypt, count; unsigned char my_iv[DES_BLOCK_SIZE], save_iv[DES_BLOCK_SIZE]; unsigned char *source, *targ; unsigned int block_cnt = (numBytes+DES_BLOCK_SIZE-1)/DES_BLOCK_SIZE; deskey(key,mode); R_memcpy(my_iv,iv,DES_BLOCK_SIZE); if(encrypt) { while(block_cnt--) { for(targ=buf,source=my_iv,count=DES_BLOCK_SIZE; count; count--) { *(targ++) ^= *(source++); } des(buf,buf); R_memcpy(my_iv,buf,DES_BLOCK_SIZE); buf += DES_BLOCK_SIZE; } } else { while(block_cnt--) { R_memcpy(save_iv,buf,DES_BLOCK_SIZE); des(buf,buf); for(targ=buf,source=my_iv,count=DES_BLOCK_SIZE; count; count--) { *(targ++) ^= *(source++); } R_memcpy(my_iv,save_iv,DES_BLOCK_SIZE); buf += DES_BLOCK_SIZE; } } #else DES_CBC_CTX context; unsigned int len; len = (numBytes+DES_BLOCK_SIZE-1)/DES_BLOCK_SIZE; len *= DES_BLOCK_SIZE; DES_CBCInit(&context, key, iv, encrypt); DES_CBCUpdate(&context, buf, buf, len); R_memset ((POINTER)&context, 0, sizeof (context)); #endif } /*--- function DumpPubKey ------------------------------------------ * */ void DumpPubKey(pubKey, stream) R_RSA_PUBLIC_KEY *pubKey; FILE *stream; { fprintf(stream,"Dump of %d bit key:\n",pubKey->bits); fprintf(stream," Mod="); DumpBigNum(pubKey->modulus,MAX_RSA_MODULUS_LEN, stream); fputs(" exp=",stream); DumpBigNum(pubKey->exponent,MAX_RSA_MODULUS_LEN, stream); } /*--- function DumpPrivKey ------------------------------------------ * */ void DumpPrivKey(privKey, stream) R_RSA_PRIVATE_KEY *privKey; FILE *stream; { fprintf(stream,"Dump of %d bit private key:\n",privKey->bits); fputs(" mod =",stream); DumpBigNum(privKey->modulus,MAX_RSA_MODULUS_LEN, stream); fputs(" pubExp=",stream); DumpBigNum(privKey->publicExponent,MAX_RSA_MODULUS_LEN, stream); fputs(" exp =",stream); DumpBigNum(privKey->exponent,MAX_RSA_MODULUS_LEN, stream); fputs(" prime1=",stream); DumpBigNum(privKey->prime[0],MAX_RSA_PRIME_LEN, stream); fputs(" prime2=",stream); DumpBigNum(privKey->prime[1],MAX_RSA_PRIME_LEN, stream); fputs(" prExp1=",stream); DumpBigNum(privKey->primeExponent[0],MAX_RSA_PRIME_LEN, stream); fputs(" prExp2=",stream); DumpBigNum(privKey->primeExponent[1],MAX_RSA_PRIME_LEN, stream); fputs(" coeffi=",stream); DumpBigNum(privKey->coefficient,MAX_RSA_PRIME_LEN, stream); } /*--- function DumpBigNum ------------------------------------------- * */ void DumpBigNum(bigNum, numLen, stream) unsigned char *bigNum; int numLen; FILE *stream; { char buf[4]; int j, bytesonline=0; for(j=0; j<numLen && !bigNum[j]; j++); for(; j<numLen; j++) { BinToHex(bigNum+j,1,buf); if(++bytesonline >= 32) { fputs("\n ",stream); bytesonline=1; } fputs(buf,stream); } fputs("\n",stream); } /* Look in the public key source files for all records with the smartName and append the contents of each CertificateInfo field to the certs list. This will ASCII decode the CertificateInfo fields. Must initialize the certs list using InitList before calling this. ripemInfo is only used for debug and debugStream. */ char *GetCertsBySmartname (ripemDatabase, certs, smartName, ripemInfo) RIPEMDatabase *ripemDatabase; TypList *certs; char *smartName; RIPEMInfo *ripemInfo; { RIPEMDatabaseCursor cursor; char *errorMessage = (char *)NULL; BOOL found; RIPEMDatabaseCursorConstructor (&cursor); /* For error, break to end of do while (0) block. */ do { if ((errorMessage = RIPEMCertCursorInit (&cursor, smartName, ripemDatabase)) != (char *)NULL) break; do { if ((errorMessage = RIPEMCertCursorUpdate (&cursor, &found, certs, ripemDatabase, ripemInfo)) != (char *)NULL) break; } while (found); } while (0); RIPEMDatabaseCursorDestructor (&cursor); return (errorMessage); } /* Must call init routine such as RIPEMCertCursorInit to use the cursor. */ void RIPEMDatabaseCursorConstructor (cursor) RIPEMDatabaseCursor *cursor; { cursor->smartName = (char *)NULL; } void RIPEMDatabaseCursorDestructor (cursor) RIPEMDatabaseCursor *cursor; { free (cursor->smartName); } /* Must call RIPEMDatabaseCursorConstructor before using this. Initialize the cursor to search for certificates matching smartName. If smartName is (char *)NULL, this will search for all certificates. This keeps an internal copy of smartName, so the given smartName buffer does not need to be preserved. ripemDatabase is not used, but is included for future compatibility. Return NULL for success or error string. */ char *RIPEMCertCursorInit (cursor, smartName, ripemDatabase) RIPEMDatabaseCursor *cursor; char *smartName; RIPEMDatabase *ripemDatabase; { UNUSED_ARG (ripemDatabase) /* Free any previous smartName and put the smartName in the cursor. */ free (cursor->smartName); if (smartName == (char *)NULL) /* This means search for all certs */ cursor->smartName = (char *)NULL; else { if (strcpyalloc (&cursor->smartName, smartName) == (char *)NULL) return (ERR_MALLOC); } cursor->finished = FALSE; /* This will cause RIPEMCertCursorUpdate to initialize */ cursor->firstCall = TRUE; return ((char *)NULL); } /* Returns the next certificate from ripemDatabase according to the smartName given to RIPEMCertCursorInit. On return, if *found is set TRUE, then the certificate is found and is added to the end of the certs list. Must initialize the certs list using InitList before calling this. If *found is set FALSE, then there are no more matching certificates. ripemInfo is only used for debug and debugStream. Return NULL for success or error string. */ char *RIPEMCertCursorUpdate (cursor, found, certs, ripemDatabase, ripemInfo) RIPEMDatabaseCursor *cursor; BOOL *found; TypList *certs; RIPEMDatabase *ripemDatabase; RIPEMInfo *ripemInfo; { BOOL repositioning; char *errorMessage; unsigned char *newCert; unsigned int newCertLen; /* Default to not found */ *found = FALSE; if (cursor->finished) return ((char *)NULL); if (cursor->firstCall) { /* This is the first call, so we need to go through all the loop initialization */ cursor->keySource = 0; repositioning = FALSE; } else /* This will make us skip all the loop control until we get back to where we returned from the last time. */ repositioning = TRUE; while (1) { if (!repositioning) { if (cursor->keySource >= MAX_KEY_SOURCES) /* We have looked through everything. */ break; /* Only look in files for now. */ if (ripemDatabase->pubKeySource.origin[cursor->keySource] != KEY_FROM_FILE) { ++cursor->keySource; continue; } cursor->fileEntry = ripemDatabase->pubKeySource.filelist.firstptr; } while (1) { if (!repositioning) { if (cursor->fileEntry == (TypListEntry *)NULL) break; /* Get typFile as a convenience. We must keep it in the cursor as well. */ cursor->typFile = (TypFile *)cursor->fileEntry->dataptr; if (!cursor->typFile->stream) { sprintf (ripemInfo->errMsgTxt, "Public key file %s is not open.", cursor->typFile->filename); return (ripemInfo->errMsgTxt); } /* Rewind the file */ fseek (cursor->typFile->stream, 0L, 0); /* Look for certificates until end of file. */ } do { /* In case this was the first call, we have gotten to where we want to be by initializing the loops. */ cursor->firstCall = FALSE; if (*found) /* We have already run through these loops and gotten a cert, so return now so that we can reposition back to here to try to get another. */ return ((char *)NULL); /* We have gotten back to where we want to be inside the loops */ repositioning = FALSE; do { if ((errorMessage = GetKeyBytesFromFile (USER_FIELD, cursor->smartName, cursor->typFile->stream, CERT_INFO_FIELD, found, &newCert, &newCertLen, ripemInfo)) != (char *)NULL) return (errorMessage); } while (!(*found) && !feof (cursor->typFile->stream)); if (*found) { /* Append the newly allocated cert to the list. */ if ((errorMessage = AddToList ((TypListEntry *)NULL, newCert, newCertLen, certs)) != (char *)NULL) { /* error, so free the newCert */ free (newCert); return (errorMessage); } } } while (!feof (cursor->typFile->stream)); cursor->fileEntry = cursor->fileEntry->nextptr; } ++cursor->keySource; } cursor->finished = TRUE; return ((char *)NULL); } /* Search the CRL file for the most recent CRL for the issuer with a last update equal to or before the given time. The issuer is given by the MD5 public key digest. (This is done instead of the issuer name since the issuer may have multiple public keys.) time is seconds since 1/1/70. Typically, it is set to now, but may also be set to a certificate's expiration time to see if it was revoked at that time. If found, crlDER is set to an allocated buffer containing the CRL DER. The caller must free this buffer. If not found, crlDER is set to NULL. Returns NULL for success, otherwise error string. */ char *GetLatestCRL (ripemDatabase, crlDER, publicKeyDigest, time) RIPEMDatabase *ripemDatabase; unsigned char **crlDER; unsigned char *publicKeyDigest; UINT4 time; { BOOL gotCRL; TypFile *typFile; UINT4 lastUpdate, bestLastUpdate; char *errorMessage, publicKeyHexDigest[33]; unsigned char *newCRL; unsigned int i; /* Initialize allocated CRL pointer to NULL. */ *crlDER = (unsigned char *)NULL; /* We need to match on the hex digest of the public key */ BinToHex (publicKeyDigest, MD5_LEN, publicKeyHexDigest); bestLastUpdate = (UINT4)0; for (i = 0; i < MAX_KEY_SOURCES; ++i) { /* Only look in files for now. */ if (ripemDatabase->crlSource.origin[i] == KEY_FROM_FILE) { FORLIST(&ripemDatabase->crlSource.filelist); typFile = (TypFile *)dptr; if (!typFile->stream) return ("CRL file is not open."); /* Rewind the file */ fseek (typFile->stream, 0L, 0); /* Look for CRL until end of file. */ do { if ((errorMessage = GetNextCRLFromFile (&gotCRL, &newCRL, &lastUpdate, typFile->stream, publicKeyHexDigest, time)) != (char *)NULL) return (errorMessage); if (!gotCRL) /* Finished with this record. Try the next. */ continue; if (lastUpdate > bestLastUpdate) { /* Found a more recent CRL, so assign it to the return arg. */ *crlDER = newCRL; bestLastUpdate = lastUpdate; } else /* Free newCRL for next pass */ free (newCRL); } while (!feof (typFile->stream)); ENDFORLIST; } } return ((char *)NULL); } /* Read the next record from stream with a public key digest (for the CRL issuer) equal to publicKeyHexDigest and a lastUpdate equal to or before time. Return the lastUpdate and the allocated crlDER. publicKeyHexDigest is a null-terminated string of the hex value of the digest. Set found to whether a field is found. Return NULL for success, otherwise error string. */ static char *GetNextCRLFromFile (found, crlDER, lastUpdate, stream, publicKeyHexDigest, time) BOOL *found; unsigned char **crlDER; UINT4 *lastUpdate; FILE *stream; char *publicKeyHexDigest; UINT4 time; { char value[VALUELEN]; BOOL gotRecord; char *errorMessage; unsigned int numBytes; /* Default to not found */ *found = FALSE; *crlDER = (unsigned char *)NULL; /* Position to just after the line containing the hex digest. */ gotRecord = FALSE; while (GetFileLine (stream, PUBLIC_KEY_DIGEST_FIELD, value, sizeof (value))) { if (!R_match (value, publicKeyHexDigest)) /* Try next one. */ continue; /* We are now in the section of the file that corresponds to this issuer public key. Get the lastUpdate time. Assume this is on the next line in the file. */ GetFileLine (stream, LAST_UPDATE_FIELD, value, sizeof (value)); sscanf (value, "%lX", lastUpdate); if (*lastUpdate > time) /* This lastUpdate time is later than the specified value, so try the next one. */ continue; gotRecord = TRUE; break; } if (!gotRecord) return ((char *)NULL); /* Position on CRL field. Assume the "CRLInfo:" is on a line by itself. */ if (!PosFileLine (stream, CRL_INFO_FIELD, (FILE *)NULL)) /* Didn't find a CRLInfo in this record. *found is already false */ return ((char *)NULL); /* Now read the RFC1113-encoded lines and translate them to binary. */ if ((errorMessage = ReadEncodedField (crlDER, &numBytes, stream)) != (char *)NULL) return (errorMessage); *found = TRUE; return ((char *)NULL); } /* Write the cert's subject smartname, the cert and the public key digest to the public key file. certDERLen is computed internally when certDER is decoded to get the smart name, etc. This opens the filename in the first entry in ripemDatabase->pubKeySource.filelist opened in "a" mode. If there are no entries, this does nothing. If the file cannot be opened, this returns an error. Return NULL for success, otherwise error. */ char *WriteCert (certDER, ripemDatabase) unsigned char *certDER; RIPEMDatabase *ripemDatabase; { CertificateStruct *certStruct = (CertificateStruct *)NULL; char *errorMessage = (char *)NULL, hexDigest[33]; int certDERLen; FILE *pubOutStream = (FILE *)NULL; unsigned char digest[MD5_LEN]; /* For error, break to end of do while (0) block. */ do { if (!ripemDatabase->pubKeySource.filelist.firstptr) /* No public key source entries. */ break; if ((pubOutStream = fopen (((TypFile *)ripemDatabase->pubKeySource.filelist.firstptr->dataptr)-> filename, "a")) == (FILE *)NULL) { errorMessage = "Cannot open public key file for append"; break; } /* Allocate the certStruct on the heap because it's big. */ if ((certStruct = (CertificateStruct *)malloc (sizeof (*certStruct))) == (CertificateStruct *)NULL) { errorMessage = ERR_MALLOC; break; } if ((certDERLen = DERToCertificate (certDER, certStruct, (CertFieldPointers *)NULL)) < 0) { errorMessage = "Can't decode certificate while saving it"; break; } /* Print separating blank. */ fprintf (pubOutStream, "\n"); /* We are going to use the smart name in the "username" field. Write a blank line and the Username. */ fprintf (pubOutStream, "%s %s\n", USER_FIELD, GetDNSmartNameValue (&certStruct->subject)); /* Write the digest of the public key. Note that we write this before the certificate since we may need to use it as an index field in the future. */ if ((errorMessage = GetPublicKeyDigest (digest, &certStruct->publicKey)) != (char *)NULL) break; BinToHex (digest, MD5_LEN, hexDigest); fprintf (pubOutStream, "%s %s\n", PUBLIC_KEY_DIGEST_FIELD, hexDigest); /* Encode and output the cert DER. */ fprintf (pubOutStream, "%s\n", CERT_INFO_FIELD); CodeAndWriteBytes (certDER, (unsigned int)certDERLen, " ", pubOutStream); } while (0); free (certStruct); if (pubOutStream != (FILE *)NULL) fclose (pubOutStream); return (errorMessage); } /* Write the given MD5 digest of the issuer's public key and the crlDER to the CRL file. crlDERLen is computed internally when crlDER is decoded to get the last update. This opens the filename in the first entry in ripemDatabase->crlSource.filelist opened in "a" mode. If there are no entries, this does nothing. If the file cannot be opened, this returns an error. Return NULL for success, otherwise error. */ char *WriteCRL (crlDER, publicKeyDigest, ripemDatabase) unsigned char *crlDER; unsigned char *publicKeyDigest; RIPEMDatabase *ripemDatabase; { char hexDigest[33], *errorMessage = (char *)NULL; CRLStruct *crlStruct = (CRLStruct *)NULL; int crlDERLen; FILE *crlOutStream = (FILE *)NULL; /* For error, break to end of do while (0) block. */ do { if (!ripemDatabase->crlSource.filelist.firstptr) /* No CRL entries. */ break; if ((crlOutStream = fopen (((TypFile *)ripemDatabase->crlSource.filelist.firstptr->dataptr)-> filename, "a")) == (FILE *)NULL) { errorMessage = "Cannot open CRL file for append"; break; } /* Allocate the crlStruct on the heap because it's big. */ if ((crlStruct = (CRLStruct *)malloc (sizeof (*crlStruct))) == (CRLStruct *)NULL) { errorMessage = ERR_MALLOC; break; } if ((crlDERLen = DERToCRL (crlDER, crlStruct, (CRLFieldPointers *)NULL)) < 0) { errorMessage = "Can't decode CRL while saving it"; break; } /* Print separating blank. */ fprintf (crlOutStream, "\n"); /* Write the digest of the issuer's public key. */ BinToHex (publicKeyDigest, MD5_LEN, hexDigest); fprintf (crlOutStream, "%s %s\n", PUBLIC_KEY_DIGEST_FIELD, hexDigest); /* Write the last update time as a hex number. */ fprintf (crlOutStream, "%s %lX\n", LAST_UPDATE_FIELD, crlStruct->lastUpdate); /* Encode and output the DER. */ fprintf (crlOutStream, "%s\n", CRL_INFO_FIELD); CodeAndWriteBytes (crlDER, crlDERLen, " ", crlOutStream); } while (0); free (crlStruct); if (crlOutStream != (FILE *)NULL) fclose (crlOutStream); return (errorMessage); } /* Open ripemDatabase->preferencesFilename and search for the user's preferences where the user is given by the public key MD5 digest. If found, preferencesDER is set to an allocated buffer containing the preferences DER. The caller must free this buffer. If not found, preferencesDER is set to NULL. If ripemDatabase->preferencesFilename is NULL or the file cannot be opened for read, this also sets preferencesDER to NULL. ripemInfo is for debug info only. Returns NULL for success, otherwise error string. */ char *GetPreferencesByDigest (ripemDatabase, preferencesDER, publicKeyDigest, ripemInfo) RIPEMDatabase *ripemDatabase; unsigned char **preferencesDER; unsigned char *publicKeyDigest; RIPEMInfo *ripemInfo; { char *errorMessage = (char *)NULL, publicKeyHexDigest[33]; FILE *stream = (FILE *)NULL; unsigned int derLen; BOOL found; if(ripemInfo->debug>1) { fprintf(ripemInfo->debugStream, "GetPreferencesByDigest looking for %s\n", PUBLIC_KEY_DIGEST_FIELD); } /* Initialize allocated pointer to NULL. */ *preferencesDER = (unsigned char *)NULL; /* For error, break to end of do while (0) block. */ do { if (ripemDatabase->preferencesFilename == (char *)NULL) /* preferencesDER is already NULL. Just return. */ break; if ((stream = fopen (ripemDatabase->preferencesFilename, "r")) == (FILE *)NULL) /* preferencesDER is already NULL. Just return. */ break; /* We need to match on the hex digest of the public key */ BinToHex (publicKeyDigest, MD5_LEN, publicKeyHexDigest); if ((errorMessage = GetKeyBytesFromFile (PUBLIC_KEY_DIGEST_FIELD, publicKeyHexDigest, stream, PREFERENCES_INFO_FIELD, &found, preferencesDER, &derLen, ripemInfo)) != (char *)NULL) break; } while (0); if (stream != (FILE *)NULL) fclose (stream); return (errorMessage); } /* In ripemDatabase->preferencesFilename, write the encoded preferences in der of length derLen with a key field of the publicKeyDigest. This replaces an existing entry with the same publicKeyDigest. ripemInfo is only used for errMsgTxt. It is an error if the filename is NULL. */ char *WriteRIPEMPreferences (der, derLen, publicKeyDigest, ripemDatabase, ripemInfo) unsigned char *der; unsigned int derLen; unsigned char *publicKeyDigest; RIPEMDatabase *ripemDatabase; RIPEMInfo *ripemInfo; { char hexDigest[33], *errorMessage = (char *)NULL; BOOL foundEntry; FILE *stream = (FILE *)NULL; /* For error, break to end of do while (0) block. */ do { if (ripemDatabase->preferencesFilename == (char *)NULL) { errorMessage = "Preferences filename is not specified."; break; } /* Write the digest of the public key. */ BinToHex (publicKeyDigest, MD5_LEN, hexDigest); if ((errorMessage = RIPEMUpdateFieldValue (&foundEntry, ripemDatabase->preferencesFilename, PUBLIC_KEY_DIGEST_FIELD, hexDigest, PREFERENCES_INFO_FIELD, der, derLen, ripemInfo)) != (char *)NULL) break; if (!foundEntry) { /* We must append the entry to the preferences file. */ if ((stream = fopen (ripemDatabase->preferencesFilename, "a")) == (FILE *)NULL) { errorMessage = "Can't open preferences file for append."; break; } /* Print separating blank. Only check for write error here. */ if (fprintf (stream, "\n") < 0) { errorMessage = "Error writing to preferences file."; break; } fprintf (stream, "%s %s\n", PUBLIC_KEY_DIGEST_FIELD, hexDigest); fprintf (stream, "%s\n", PREFERENCES_INFO_FIELD); CodeAndWriteBytes (der, derLen, " ", stream); } } while (0); if (stream != (FILE *)NULL) fclose (stream); return (errorMessage); } /* Open all the entries in keySource's filelist for read. This makes sure outFilename is at the front of the list and that it can be opened for append. This assumes outFilename is already in the keySource list. ripemInfo is used only for error and debug output. Return NULL for success, otherwise error string. */ static char *OpenKeySource (keySource, outFilename, ripemInfo) TypKeySource *keySource; char *outFilename; RIPEMInfo *ripemInfo; { FILE *stream; TypListEntry *entry; TypFile *typFile; void *tempPointer; /* Make sure we can open the outFilename for append. This will create it if it doesn't exist. */ if ((stream = fopen (outFilename, "a")) == (FILE *)NULL) { sprintf (ripemInfo->errMsgTxt, "Can't write to file \"%s\". (Does its directory exist?)", outFilename); return (ripemInfo->errMsgTxt); } else /* Successfully opened, so just close it to be opened for read. */ fclose (stream); /* We want to make sure the output filename is the first in the list since that is the one RIPEM will use. First scan to see if this filename is already listed as one of the key sources. */ for (entry = keySource->filelist.firstptr; entry != (TypListEntry *)NULL; entry = entry->nextptr) { if (strcmp (((TypFile *)entry->dataptr)->filename, outFilename) == 0) { /* This output filename is already in the list, make sure it is the first one and quit. */ tempPointer = keySource->filelist.firstptr->dataptr; keySource->filelist.firstptr->dataptr = entry->dataptr; entry->dataptr = tempPointer; break; } } /* Open the files. */ for (entry = keySource->filelist.firstptr; entry != (TypListEntry *)NULL; entry = entry->nextptr) { typFile = (TypFile *)entry->dataptr; if (typFile->stream != (FILE *)NULL) /* Somehow, this is already opened. */ continue; if ((typFile->stream = fopen (typFile->filename, "r")) == (FILE *)NULL) { sprintf(ripemInfo->errMsgTxt, "Can't open file \"%s\" for read", typFile->filename); return (ripemInfo->errMsgTxt); } } return ((char *)NULL); } /* This replaced a field value in filename as follows: This opens filename for read and copies it to filename.bak. (filename should be a full path such as C:\RIPEMHOM\privkey). Then this reopens filename for write and copies filename.bak back into filename, searching for the first entry matching with keyName and keyValue as in GetKeyBytesFromFile. If found, this searches for fieldName within the same key section (before any blank line) and, if found, substitutes the field value using the supplied entry given by bytes and numBytes. (This will base64 recode the bytes). Then this continues copying from filename.bak back into filename. If the field is found and substituted, this returns TRUE in foundEntry. If not found, this returns FALSE and the calling routing can open filename for append and write the entry. This assumes that filename is closed when this is first called. This closes filename upon return. ripemInfo is only used for errMsgTxt. Return (char *)NULL for success, otherwise error string. */ char *RIPEMUpdateFieldValue (foundEntry, filename, keyName, keyValue, fieldName, bytes, numBytes, ripemInfo) BOOL *foundEntry; char *filename; char *keyName; char *keyValue; char *fieldName; unsigned char *bytes; unsigned int numBytes; RIPEMInfo *ripemInfo; { FILE *stream = (FILE *)NULL, *backupStream = (FILE *)NULL; char *cptr, *line = (char *)NULL, *errorMessage = (char *)NULL, *backupFilename = (char *)NULL; int keyNameLen, tempLen; /* For error, break to end of do while (0) block. */ do { /* Allocate on heap since it is too big for the stack */ if ((line = (char *)malloc (LINELEN)) == (char *)NULL) { errorMessage = ERR_MALLOC; break; } /* Default to not found */ *foundEntry = FALSE; /* Determine backup filename. */ if ((backupFilename = (char *)malloc (strlen (filename) + 5)) == (char *)NULL) { errorMessage = ERR_MALLOC; break; } strcpy (backupFilename, filename); strcat (backupFilename, ".bak"); /* Copy filename to backupFilename. */ if ((stream = fopen (filename, "r")) == (FILE *)NULL) { sprintf(ripemInfo->errMsgTxt, "Can't open file \"%s\" for read", filename); errorMessage = ripemInfo->errMsgTxt; break; } if ((backupStream = fopen (backupFilename, "w")) == (FILE *)NULL) { sprintf(ripemInfo->errMsgTxt, "Can't open file \"%s\" for write", backupFilename); errorMessage = ripemInfo->errMsgTxt; break; } while (fgets (line, LINELEN, stream)) { if (fputs (line, backupStream) < 0) { sprintf(ripemInfo->errMsgTxt, "Error writing to file \"%s\".", backupFilename); errorMessage = ripemInfo->errMsgTxt; break; } } if (errorMessage != (char *)NULL) /* Broke because of error. */ break; fclose (stream); stream = (FILE *)NULL; fclose (backupStream); backupStream = (FILE *)NULL; /* Open for copying from backupFilename back into filename. */ if ((stream = fopen (filename, "w")) == (FILE *)NULL) { sprintf(ripemInfo->errMsgTxt, "Can't open file \"%s\" for write", filename); errorMessage = ripemInfo->errMsgTxt; break; } if ((backupStream = fopen (backupFilename, "r")) == (FILE *)NULL) { sprintf(ripemInfo->errMsgTxt, "Can't open file \"%s\" for read", backupFilename); errorMessage = ripemInfo->errMsgTxt; break; } /* Now copy from backupStream to stream, searching for the field to replace and substituting the new one if found. */ keyNameLen = strlen (keyName); while (fgets (line, LINELEN, backupStream)) { if (fputs (line, stream) < 0) { sprintf(ripemInfo->errMsgTxt, "Error writing to file \"%s\".", filename); errorMessage = ripemInfo->errMsgTxt; break; } /* If already found the entry, just continue with copying the rest of the file. */ if (*foundEntry) continue; if (strncmp (line, keyName, keyNameLen) == 0) { /* Found the right key name, so check the keyValue. */ cptr = line + keyNameLen; while (WhiteSpace (*cptr) && *cptr) cptr++; tempLen = strlen (cptr); if (cptr[tempLen - 1] == '\n') cptr[tempLen - 1] = '\0'; if (!R_match (keyValue, cptr)) continue; /* Found the correct key field. We already copied it to the output, so search for the field name. */ if (!PosFileLine (backupStream, fieldName, stream)) /* Didn't find the field name, so continue searching. */ continue; /* We just read the correct field name and wrote it to the output, so now write the new field value. */ *foundEntry = TRUE; CodeAndWriteBytes (bytes, numBytes, " ", stream); /* Skip over the original field value in the input stream by seeking to the next blank line, line beginning with non-whitespace, or the end of the file. This is the same algorithm used by ReadEncodedField. */ while (fgets (line, LINELEN, backupStream)) { if (!WhiteSpace (line[0]) || LineIsWhiteSpace (line)) { /* We just read a line which follows the field we substituted, so it needs to be copied to the output before we break. */ fputs (line, stream); break; } } } } } while (0); if (stream != (FILE *)NULL) fclose (stream); if (backupStream != (FILE *)NULL) fclose (backupStream); free (backupFilename); free (line); return (errorMessage); }
31.976
79
0.635039
[ "vector" ]
efeedc6c6b08c89fb9c60bd271ed4b51bb60d32d
837
h
C
src/clang_translation_unit.h
mkwork/cquery
fc2af50c27e8d64e985ef90c0a3da73c798c6f56
[ "MIT" ]
null
null
null
src/clang_translation_unit.h
mkwork/cquery
fc2af50c27e8d64e985ef90c0a3da73c798c6f56
[ "MIT" ]
null
null
null
src/clang_translation_unit.h
mkwork/cquery
fc2af50c27e8d64e985ef90c0a3da73c798c6f56
[ "MIT" ]
null
null
null
#pragma once #include "clang_cursor.h" #include "clang_index.h" #include <clang-c/Index.h> #include <memory> #include <string> #include <vector> // RAII wrapper around CXTranslationUnit which also makes it much more // challenging to use a CXTranslationUnit instance that is not correctly // initialized. struct ClangTranslationUnit { static std::unique_ptr<ClangTranslationUnit> Create( ClangIndex* index, const std::string& filepath, const std::vector<std::string>& arguments, std::vector<CXUnsavedFile>& unsaved_files, unsigned flags); static std::unique_ptr<ClangTranslationUnit> Reparse( std::unique_ptr<ClangTranslationUnit> tu, std::vector<CXUnsavedFile>& unsaved); explicit ClangTranslationUnit(CXTranslationUnit tu); ~ClangTranslationUnit(); CXTranslationUnit cx_tu; };
27
72
0.744325
[ "vector" ]
effa4237cd027b238fc94a8ffd7cdb81a064dea5
6,780
h
C
SOURCES/sim/include/cphsi.h
IsraelyFlightSimulator/Negev-Storm
86de63e195577339f6e4a94198bedd31833a8be8
[ "Unlicense" ]
1
2021-02-19T06:06:31.000Z
2021-02-19T06:06:31.000Z
src/sim/include/cphsi.h
markbb1957/FFalconSource
07b12e2c41a93fa3a95b912a2433a8056de5bc4d
[ "BSD-2-Clause" ]
null
null
null
src/sim/include/cphsi.h
markbb1957/FFalconSource
07b12e2c41a93fa3a95b912a2433a8056de5bc4d
[ "BSD-2-Clause" ]
2
2019-08-20T13:35:13.000Z
2021-04-24T07:32:04.000Z
#ifndef _CPHSI_H #define _CPHSI_H #include "cpobject.h" #include "navsystem.h" #ifdef USE_SH_POOLS extern MEM_POOL gCockMemPool; #endif const float COMPASS_X_CENTER = 0.0F; const float COMPASS_Y_CENTER = -0.1F; const float HALFPI = 1.5708F; const float TWOPI = 6.2832F; const int NORMAL_HSI_CRS_STATE = 7; const int NORMAL_HSI_HDG_STATE = 7; enum HSIColors { HSI_COLOR_ARROWS, HSI_COLOR_ARROWGHOST, HSI_COLOR_COURSEWARN, HSI_COLOR_HEADINGMARK, HSI_COLOR_STATIONBEARING, HSI_COLOR_COURSE, HSI_COLOR_AIRCRAFT, HSI_COLOR_CIRCLES, HSI_COLOR_DEVBAR, HSI_COLOR_ILSDEVWARN, HSI_COLOR_TOTAL }; //==================================================== // Predeclarations //==================================================== class CPObject; class CPHsi; //==================================================== // Structures used for HSI Initialization //==================================================== typedef struct { int compassTransparencyType; RECT compassSrc; RECT compassDest; RECT devSrc; RECT devDest; RECT warnFlag; CPHsi *pHsi; long colors[HSI_COLOR_TOTAL]; BYTE *sourcehsi; //Wombat778 3-24-04 } HsiInitStr; //==================================================== // CPHsi Class Definition //==================================================== class CPHsi { #ifdef USE_SH_POOLS public: // Overload new/delete to use a SmartHeap pool void *operator new(size_t size) { return MemAllocPtr(gCockMemPool,size,FALSE); }; void operator delete(void *mem) { if (mem) MemFreePtr(mem); }; #endif public: //==================================================== // Button States //==================================================== typedef enum HSIButtonStates { HSI_STA_CRS_STATE, HSI_STA_HDG_STATE, HSI_STA_TOTAL_STATES }; //==================================================== // Horizontal Situaton Geometry //==================================================== typedef enum HSIValues { HSI_VAL_CRS_DEVIATION, HSI_VAL_DESIRED_CRS, HSI_VAL_DISTANCE_TO_BEACON, HSI_VAL_BEARING_TO_BEACON, HSI_VAL_CURRENT_HEADING, HSI_VAL_DESIRED_HEADING, HSI_VAL_DEV_LIMIT, HSI_VAL_HALF_DEV_LIMIT, HSI_VAL_LOCALIZER_CRS, HSI_VAL_AIRBASE_X, HSI_VAL_AIRBASE_Y, HSI_VAL_TOTAL_VALUES }; //==================================================== // Control Flags //==================================================== typedef enum HSIFlags { HSI_FLAG_TO_TRUE, HSI_FLAG_ILS_WARN, HSI_FLAG_CRS_WARN, HSI_FLAG_INIT, HSI_FLAG_TOTAL_FLAGS }; //==================================================== // Constructors and Destructors //==================================================== CPHsi(); //==================================================== // Runtime Public Member Functions //==================================================== void Exec(void); //==================================================== // Access Functions //==================================================== void IncState(HSIButtonStates, float step = 5.0F); // MD -- 20040118: add default arg void DecState(HSIButtonStates, float step = 5.0F); // MD -- 20040118: add default arg int GetState(HSIButtonStates); float GetValue(HSIValues); BOOL GetFlag(HSIFlags); // long mColor[2][HSI_COLOR_TOTAL]; //MI 02/02/02 float LastHSIHeading; private: //==================================================== // Internal Data //==================================================== CockpitManager *mpCPManager; int mpHsiStates[HSI_STA_TOTAL_STATES]; float mpHsiValues[HSI_VAL_TOTAL_VALUES]; BOOL mpHsiFlags[HSI_FLAG_TOTAL_FLAGS]; NavigationSystem::Instrument_Mode mLastMode; WayPointClass* mLastWaypoint; VU_TIME lastCheck; BOOL lastResult; //==================================================== // Calculation Routines //==================================================== void ExecNav(void); void ExecTacan(void); void ExecILSNav(void); void ExecILSTacan(void); void ExecBeaconProximity(float, float, float, float); void CalcTCNCrsDev(float course); void CalcILSCrsDev(float); BOOL BeaconInRange(float rangeToBeacon, float nominalBeaconRange); }; //==================================================== // Class Definition for CPHSIView //==================================================== class CPHsiView: public CPObject { #ifdef USE_SH_POOLS public: // Overload new/delete to use a SmartHeap pool void *operator new(size_t size) { return MemAllocPtr(gCockMemPool,size,FALSE); }; void operator delete(void *mem) { if (mem) MemFreePtr(mem); }; #endif private: //==================================================== // Pointers to the Outside World //==================================================== CPHsi *mpHsi; //==================================================== // Viewport Dimension Data //==================================================== float mTop; float mLeft; float mBottom; float mRight; //==================================================== // Compass Dial Data //==================================================== int mRadius; RECT mDevSrc; RECT mDevDest; RECT mCompassSrc; RECT mCompassDest; RECT mWarnFlag; int mCompassTransparencyType; int *mpCompassCircle; int mCompassXCenter; int mCompassYCenter; int mCompassWidth; int mCompassHeight; ImageBuffer *CompassBuffer; //Wombat778 10-06-2003 Added to hold temporary buffer for HSI autoscaling/rotation ulong mColor[2][HSI_COLOR_TOTAL]; //==================================================== // Position Routines //==================================================== void MoveToCompassCenter(void); //==================================================== // Draw Routines for Needles //==================================================== void DrawCourse(float, float); void DrawStationBearing(float); void DrawAircraftSymbol(void); //==================================================== // Draw Routines for Flags //==================================================== void DrawHeadingMarker(float); void DrawCourseWarning(void); void DrawToFrom(void); public: //==================================================== // Runtime Public Draw Routines //==================================================== virtual void DisplayDraw(void); virtual void DisplayBlit(void); virtual void Exec(SimBaseClass*); //Wombat778 3-24-04 Stuff for rendered hsi void DisplayBlit3D(); GLubyte *mpSourceBuffer; virtual void CreateLit(void); //Wombat778 End //==================================================== // Constructors and Destructors //==================================================== CPHsiView(ObjectInitStr*, HsiInitStr*); virtual ~CPHsiView(); }; #endif
23.957597
116
0.506342
[ "geometry" ]
561365a95c7b549fcbd5e7d6828af83093de5cb5
320,849
h
C
google/genomics/v1/annotations.pb.h
allquixotic/kynnaugh-cc
8b4d0cdb7e6e3cae76aba43507bb56cee225c36f
[ "Apache-2.0" ]
3
2017-01-09T10:45:00.000Z
2018-12-18T19:57:13.000Z
google/genomics/v1/annotations.pb.h
allquixotic/kynnaugh-cc
8b4d0cdb7e6e3cae76aba43507bb56cee225c36f
[ "Apache-2.0" ]
null
null
null
google/genomics/v1/annotations.pb.h
allquixotic/kynnaugh-cc
8b4d0cdb7e6e3cae76aba43507bb56cee225c36f
[ "Apache-2.0" ]
null
null
null
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/genomics/v1/annotations.proto #ifndef PROTOBUF_google_2fgenomics_2fv1_2fannotations_2eproto__INCLUDED #define PROTOBUF_google_2fgenomics_2fv1_2fannotations_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> #include <google/protobuf/extension_set.h> #include <google/protobuf/map.h> #include <google/protobuf/map_field_inl.h> #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> #include "google/api/annotations.pb.h" #include <google/protobuf/empty.pb.h> #include <google/protobuf/field_mask.pb.h> #include <google/protobuf/struct.pb.h> #include <google/protobuf/wrappers.pb.h> #include "google/rpc/status.pb.h" // @@protoc_insertion_point(includes) namespace google { namespace genomics { namespace v1 { // Internal implementation detail -- do not call these. void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto(); void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); class Annotation; class AnnotationSet; class BatchCreateAnnotationsRequest; class BatchCreateAnnotationsResponse; class BatchCreateAnnotationsResponse_Entry; class CreateAnnotationRequest; class CreateAnnotationSetRequest; class DeleteAnnotationRequest; class DeleteAnnotationSetRequest; class ExternalId; class GetAnnotationRequest; class GetAnnotationSetRequest; class SearchAnnotationSetsRequest; class SearchAnnotationSetsResponse; class SearchAnnotationsRequest; class SearchAnnotationsResponse; class Transcript; class Transcript_CodingSequence; class Transcript_Exon; class UpdateAnnotationRequest; class UpdateAnnotationSetRequest; class VariantAnnotation; class VariantAnnotation_ClinicalCondition; enum VariantAnnotation_Type { VariantAnnotation_Type_TYPE_UNSPECIFIED = 0, VariantAnnotation_Type_TYPE_OTHER = 1, VariantAnnotation_Type_INSERTION = 2, VariantAnnotation_Type_DELETION = 3, VariantAnnotation_Type_SUBSTITUTION = 4, VariantAnnotation_Type_SNP = 5, VariantAnnotation_Type_STRUCTURAL = 6, VariantAnnotation_Type_CNV = 7, VariantAnnotation_Type_VariantAnnotation_Type_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min, VariantAnnotation_Type_VariantAnnotation_Type_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max }; bool VariantAnnotation_Type_IsValid(int value); const VariantAnnotation_Type VariantAnnotation_Type_Type_MIN = VariantAnnotation_Type_TYPE_UNSPECIFIED; const VariantAnnotation_Type VariantAnnotation_Type_Type_MAX = VariantAnnotation_Type_CNV; const int VariantAnnotation_Type_Type_ARRAYSIZE = VariantAnnotation_Type_Type_MAX + 1; const ::google::protobuf::EnumDescriptor* VariantAnnotation_Type_descriptor(); inline const ::std::string& VariantAnnotation_Type_Name(VariantAnnotation_Type value) { return ::google::protobuf::internal::NameOfEnum( VariantAnnotation_Type_descriptor(), value); } inline bool VariantAnnotation_Type_Parse( const ::std::string& name, VariantAnnotation_Type* value) { return ::google::protobuf::internal::ParseNamedEnum<VariantAnnotation_Type>( VariantAnnotation_Type_descriptor(), name, value); } enum VariantAnnotation_Effect { VariantAnnotation_Effect_EFFECT_UNSPECIFIED = 0, VariantAnnotation_Effect_EFFECT_OTHER = 1, VariantAnnotation_Effect_FRAMESHIFT = 2, VariantAnnotation_Effect_FRAME_PRESERVING_INDEL = 3, VariantAnnotation_Effect_SYNONYMOUS_SNP = 4, VariantAnnotation_Effect_NONSYNONYMOUS_SNP = 5, VariantAnnotation_Effect_STOP_GAIN = 6, VariantAnnotation_Effect_STOP_LOSS = 7, VariantAnnotation_Effect_SPLICE_SITE_DISRUPTION = 8, VariantAnnotation_Effect_VariantAnnotation_Effect_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min, VariantAnnotation_Effect_VariantAnnotation_Effect_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max }; bool VariantAnnotation_Effect_IsValid(int value); const VariantAnnotation_Effect VariantAnnotation_Effect_Effect_MIN = VariantAnnotation_Effect_EFFECT_UNSPECIFIED; const VariantAnnotation_Effect VariantAnnotation_Effect_Effect_MAX = VariantAnnotation_Effect_SPLICE_SITE_DISRUPTION; const int VariantAnnotation_Effect_Effect_ARRAYSIZE = VariantAnnotation_Effect_Effect_MAX + 1; const ::google::protobuf::EnumDescriptor* VariantAnnotation_Effect_descriptor(); inline const ::std::string& VariantAnnotation_Effect_Name(VariantAnnotation_Effect value) { return ::google::protobuf::internal::NameOfEnum( VariantAnnotation_Effect_descriptor(), value); } inline bool VariantAnnotation_Effect_Parse( const ::std::string& name, VariantAnnotation_Effect* value) { return ::google::protobuf::internal::ParseNamedEnum<VariantAnnotation_Effect>( VariantAnnotation_Effect_descriptor(), name, value); } enum VariantAnnotation_ClinicalSignificance { VariantAnnotation_ClinicalSignificance_CLINICAL_SIGNIFICANCE_UNSPECIFIED = 0, VariantAnnotation_ClinicalSignificance_CLINICAL_SIGNIFICANCE_OTHER = 1, VariantAnnotation_ClinicalSignificance_UNCERTAIN = 2, VariantAnnotation_ClinicalSignificance_BENIGN = 3, VariantAnnotation_ClinicalSignificance_LIKELY_BENIGN = 4, VariantAnnotation_ClinicalSignificance_LIKELY_PATHOGENIC = 5, VariantAnnotation_ClinicalSignificance_PATHOGENIC = 6, VariantAnnotation_ClinicalSignificance_DRUG_RESPONSE = 7, VariantAnnotation_ClinicalSignificance_HISTOCOMPATIBILITY = 8, VariantAnnotation_ClinicalSignificance_CONFERS_SENSITIVITY = 9, VariantAnnotation_ClinicalSignificance_RISK_FACTOR = 10, VariantAnnotation_ClinicalSignificance_ASSOCIATION = 11, VariantAnnotation_ClinicalSignificance_PROTECTIVE = 12, VariantAnnotation_ClinicalSignificance_MULTIPLE_REPORTED = 13, VariantAnnotation_ClinicalSignificance_VariantAnnotation_ClinicalSignificance_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min, VariantAnnotation_ClinicalSignificance_VariantAnnotation_ClinicalSignificance_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max }; bool VariantAnnotation_ClinicalSignificance_IsValid(int value); const VariantAnnotation_ClinicalSignificance VariantAnnotation_ClinicalSignificance_ClinicalSignificance_MIN = VariantAnnotation_ClinicalSignificance_CLINICAL_SIGNIFICANCE_UNSPECIFIED; const VariantAnnotation_ClinicalSignificance VariantAnnotation_ClinicalSignificance_ClinicalSignificance_MAX = VariantAnnotation_ClinicalSignificance_MULTIPLE_REPORTED; const int VariantAnnotation_ClinicalSignificance_ClinicalSignificance_ARRAYSIZE = VariantAnnotation_ClinicalSignificance_ClinicalSignificance_MAX + 1; const ::google::protobuf::EnumDescriptor* VariantAnnotation_ClinicalSignificance_descriptor(); inline const ::std::string& VariantAnnotation_ClinicalSignificance_Name(VariantAnnotation_ClinicalSignificance value) { return ::google::protobuf::internal::NameOfEnum( VariantAnnotation_ClinicalSignificance_descriptor(), value); } inline bool VariantAnnotation_ClinicalSignificance_Parse( const ::std::string& name, VariantAnnotation_ClinicalSignificance* value) { return ::google::protobuf::internal::ParseNamedEnum<VariantAnnotation_ClinicalSignificance>( VariantAnnotation_ClinicalSignificance_descriptor(), name, value); } enum AnnotationType { ANNOTATION_TYPE_UNSPECIFIED = 0, GENERIC = 1, VARIANT = 2, GENE = 3, TRANSCRIPT = 4, AnnotationType_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min, AnnotationType_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max }; bool AnnotationType_IsValid(int value); const AnnotationType AnnotationType_MIN = ANNOTATION_TYPE_UNSPECIFIED; const AnnotationType AnnotationType_MAX = TRANSCRIPT; const int AnnotationType_ARRAYSIZE = AnnotationType_MAX + 1; const ::google::protobuf::EnumDescriptor* AnnotationType_descriptor(); inline const ::std::string& AnnotationType_Name(AnnotationType value) { return ::google::protobuf::internal::NameOfEnum( AnnotationType_descriptor(), value); } inline bool AnnotationType_Parse( const ::std::string& name, AnnotationType* value) { return ::google::protobuf::internal::ParseNamedEnum<AnnotationType>( AnnotationType_descriptor(), name, value); } // =================================================================== class AnnotationSet : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.AnnotationSet) */ { public: AnnotationSet(); virtual ~AnnotationSet(); AnnotationSet(const AnnotationSet& from); inline AnnotationSet& operator=(const AnnotationSet& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const AnnotationSet& default_instance(); static const AnnotationSet* internal_default_instance(); void UnsafeArenaSwap(AnnotationSet* other); void Swap(AnnotationSet* other); // implements Message ---------------------------------------------- inline AnnotationSet* New() const { return New(NULL); } AnnotationSet* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const AnnotationSet& from); void MergeFrom(const AnnotationSet& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(AnnotationSet* other); void UnsafeMergeFrom(const AnnotationSet& from); protected: explicit AnnotationSet(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string id = 1; void clear_id(); static const int kIdFieldNumber = 1; const ::std::string& id() const; void set_id(const ::std::string& value); void set_id(const char* value); void set_id(const char* value, size_t size); ::std::string* mutable_id(); ::std::string* release_id(); void set_allocated_id(::std::string* id); ::std::string* unsafe_arena_release_id(); void unsafe_arena_set_allocated_id( ::std::string* id); // optional string dataset_id = 2; void clear_dataset_id(); static const int kDatasetIdFieldNumber = 2; const ::std::string& dataset_id() const; void set_dataset_id(const ::std::string& value); void set_dataset_id(const char* value); void set_dataset_id(const char* value, size_t size); ::std::string* mutable_dataset_id(); ::std::string* release_dataset_id(); void set_allocated_dataset_id(::std::string* dataset_id); ::std::string* unsafe_arena_release_dataset_id(); void unsafe_arena_set_allocated_dataset_id( ::std::string* dataset_id); // optional string reference_set_id = 3; void clear_reference_set_id(); static const int kReferenceSetIdFieldNumber = 3; const ::std::string& reference_set_id() const; void set_reference_set_id(const ::std::string& value); void set_reference_set_id(const char* value); void set_reference_set_id(const char* value, size_t size); ::std::string* mutable_reference_set_id(); ::std::string* release_reference_set_id(); void set_allocated_reference_set_id(::std::string* reference_set_id); ::std::string* unsafe_arena_release_reference_set_id(); void unsafe_arena_set_allocated_reference_set_id( ::std::string* reference_set_id); // optional string name = 4; void clear_name(); static const int kNameFieldNumber = 4; const ::std::string& name() const; void set_name(const ::std::string& value); void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); ::std::string* unsafe_arena_release_name(); void unsafe_arena_set_allocated_name( ::std::string* name); // optional string source_uri = 5; void clear_source_uri(); static const int kSourceUriFieldNumber = 5; const ::std::string& source_uri() const; void set_source_uri(const ::std::string& value); void set_source_uri(const char* value); void set_source_uri(const char* value, size_t size); ::std::string* mutable_source_uri(); ::std::string* release_source_uri(); void set_allocated_source_uri(::std::string* source_uri); ::std::string* unsafe_arena_release_source_uri(); void unsafe_arena_set_allocated_source_uri( ::std::string* source_uri); // optional .google.genomics.v1.AnnotationType type = 6; void clear_type(); static const int kTypeFieldNumber = 6; ::google::genomics::v1::AnnotationType type() const; void set_type(::google::genomics::v1::AnnotationType value); // map<string, .google.protobuf.ListValue> info = 17; int info_size() const; void clear_info(); static const int kInfoFieldNumber = 17; const ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >& info() const; ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >* mutable_info(); // @@protoc_insertion_point(class_scope:google.genomics.v1.AnnotationSet) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; typedef ::google::protobuf::internal::MapEntryLite< ::std::string, ::google::protobuf::ListValue, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > AnnotationSet_InfoEntry; ::google::protobuf::internal::MapField< ::std::string, ::google::protobuf::ListValue, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > info_; ::google::protobuf::internal::ArenaStringPtr id_; ::google::protobuf::internal::ArenaStringPtr dataset_id_; ::google::protobuf::internal::ArenaStringPtr reference_set_id_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr source_uri_; int type_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<AnnotationSet> AnnotationSet_default_instance_; // ------------------------------------------------------------------- class Annotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.Annotation) */ { public: Annotation(); virtual ~Annotation(); Annotation(const Annotation& from); inline Annotation& operator=(const Annotation& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Annotation& default_instance(); enum ValueCase { kVariant = 10, kTranscript = 11, VALUE_NOT_SET = 0, }; static const Annotation* internal_default_instance(); void UnsafeArenaSwap(Annotation* other); void Swap(Annotation* other); // implements Message ---------------------------------------------- inline Annotation* New() const { return New(NULL); } Annotation* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const Annotation& from); void MergeFrom(const Annotation& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Annotation* other); void UnsafeMergeFrom(const Annotation& from); protected: explicit Annotation(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string id = 1; void clear_id(); static const int kIdFieldNumber = 1; const ::std::string& id() const; void set_id(const ::std::string& value); void set_id(const char* value); void set_id(const char* value, size_t size); ::std::string* mutable_id(); ::std::string* release_id(); void set_allocated_id(::std::string* id); ::std::string* unsafe_arena_release_id(); void unsafe_arena_set_allocated_id( ::std::string* id); // optional string annotation_set_id = 2; void clear_annotation_set_id(); static const int kAnnotationSetIdFieldNumber = 2; const ::std::string& annotation_set_id() const; void set_annotation_set_id(const ::std::string& value); void set_annotation_set_id(const char* value); void set_annotation_set_id(const char* value, size_t size); ::std::string* mutable_annotation_set_id(); ::std::string* release_annotation_set_id(); void set_allocated_annotation_set_id(::std::string* annotation_set_id); ::std::string* unsafe_arena_release_annotation_set_id(); void unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id); // optional string name = 3; void clear_name(); static const int kNameFieldNumber = 3; const ::std::string& name() const; void set_name(const ::std::string& value); void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); ::std::string* unsafe_arena_release_name(); void unsafe_arena_set_allocated_name( ::std::string* name); // optional string reference_id = 4; void clear_reference_id(); static const int kReferenceIdFieldNumber = 4; const ::std::string& reference_id() const; void set_reference_id(const ::std::string& value); void set_reference_id(const char* value); void set_reference_id(const char* value, size_t size); ::std::string* mutable_reference_id(); ::std::string* release_reference_id(); void set_allocated_reference_id(::std::string* reference_id); ::std::string* unsafe_arena_release_reference_id(); void unsafe_arena_set_allocated_reference_id( ::std::string* reference_id); // optional string reference_name = 5; void clear_reference_name(); static const int kReferenceNameFieldNumber = 5; const ::std::string& reference_name() const; void set_reference_name(const ::std::string& value); void set_reference_name(const char* value); void set_reference_name(const char* value, size_t size); ::std::string* mutable_reference_name(); ::std::string* release_reference_name(); void set_allocated_reference_name(::std::string* reference_name); ::std::string* unsafe_arena_release_reference_name(); void unsafe_arena_set_allocated_reference_name( ::std::string* reference_name); // optional int64 start = 6; void clear_start(); static const int kStartFieldNumber = 6; ::google::protobuf::int64 start() const; void set_start(::google::protobuf::int64 value); // optional int64 end = 7; void clear_end(); static const int kEndFieldNumber = 7; ::google::protobuf::int64 end() const; void set_end(::google::protobuf::int64 value); // optional bool reverse_strand = 8; void clear_reverse_strand(); static const int kReverseStrandFieldNumber = 8; bool reverse_strand() const; void set_reverse_strand(bool value); // optional .google.genomics.v1.AnnotationType type = 9; void clear_type(); static const int kTypeFieldNumber = 9; ::google::genomics::v1::AnnotationType type() const; void set_type(::google::genomics::v1::AnnotationType value); // optional .google.genomics.v1.VariantAnnotation variant = 10; bool has_variant() const; void clear_variant(); static const int kVariantFieldNumber = 10; private: void _slow_mutable_variant(); void _slow_set_allocated_variant( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::VariantAnnotation** variant); ::google::genomics::v1::VariantAnnotation* _slow_release_variant(); public: const ::google::genomics::v1::VariantAnnotation& variant() const; ::google::genomics::v1::VariantAnnotation* mutable_variant(); ::google::genomics::v1::VariantAnnotation* release_variant(); void set_allocated_variant(::google::genomics::v1::VariantAnnotation* variant); ::google::genomics::v1::VariantAnnotation* unsafe_arena_release_variant(); void unsafe_arena_set_allocated_variant( ::google::genomics::v1::VariantAnnotation* variant); // optional .google.genomics.v1.Transcript transcript = 11; bool has_transcript() const; void clear_transcript(); static const int kTranscriptFieldNumber = 11; private: void _slow_mutable_transcript(); void _slow_set_allocated_transcript( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::Transcript** transcript); ::google::genomics::v1::Transcript* _slow_release_transcript(); public: const ::google::genomics::v1::Transcript& transcript() const; ::google::genomics::v1::Transcript* mutable_transcript(); ::google::genomics::v1::Transcript* release_transcript(); void set_allocated_transcript(::google::genomics::v1::Transcript* transcript); ::google::genomics::v1::Transcript* unsafe_arena_release_transcript(); void unsafe_arena_set_allocated_transcript( ::google::genomics::v1::Transcript* transcript); // map<string, .google.protobuf.ListValue> info = 12; int info_size() const; void clear_info(); static const int kInfoFieldNumber = 12; const ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >& info() const; ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >* mutable_info(); ValueCase value_case() const; // @@protoc_insertion_point(class_scope:google.genomics.v1.Annotation) private: inline void set_has_variant(); inline void set_has_transcript(); inline bool has_value() const; void clear_value(); inline void clear_has_value(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; typedef ::google::protobuf::internal::MapEntryLite< ::std::string, ::google::protobuf::ListValue, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > Annotation_InfoEntry; ::google::protobuf::internal::MapField< ::std::string, ::google::protobuf::ListValue, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > info_; ::google::protobuf::internal::ArenaStringPtr id_; ::google::protobuf::internal::ArenaStringPtr annotation_set_id_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr reference_id_; ::google::protobuf::internal::ArenaStringPtr reference_name_; ::google::protobuf::int64 start_; ::google::protobuf::int64 end_; bool reverse_strand_; int type_; union ValueUnion { ValueUnion() {} ::google::genomics::v1::VariantAnnotation* variant_; ::google::genomics::v1::Transcript* transcript_; } value_; mutable int _cached_size_; ::google::protobuf::uint32 _oneof_case_[1]; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<Annotation> Annotation_default_instance_; // ------------------------------------------------------------------- class VariantAnnotation_ClinicalCondition : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.VariantAnnotation.ClinicalCondition) */ { public: VariantAnnotation_ClinicalCondition(); virtual ~VariantAnnotation_ClinicalCondition(); VariantAnnotation_ClinicalCondition(const VariantAnnotation_ClinicalCondition& from); inline VariantAnnotation_ClinicalCondition& operator=(const VariantAnnotation_ClinicalCondition& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const VariantAnnotation_ClinicalCondition& default_instance(); static const VariantAnnotation_ClinicalCondition* internal_default_instance(); void UnsafeArenaSwap(VariantAnnotation_ClinicalCondition* other); void Swap(VariantAnnotation_ClinicalCondition* other); // implements Message ---------------------------------------------- inline VariantAnnotation_ClinicalCondition* New() const { return New(NULL); } VariantAnnotation_ClinicalCondition* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const VariantAnnotation_ClinicalCondition& from); void MergeFrom(const VariantAnnotation_ClinicalCondition& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(VariantAnnotation_ClinicalCondition* other); void UnsafeMergeFrom(const VariantAnnotation_ClinicalCondition& from); protected: explicit VariantAnnotation_ClinicalCondition(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated string names = 1; int names_size() const; void clear_names(); static const int kNamesFieldNumber = 1; const ::std::string& names(int index) const; ::std::string* mutable_names(int index); void set_names(int index, const ::std::string& value); void set_names(int index, const char* value); void set_names(int index, const char* value, size_t size); ::std::string* add_names(); void add_names(const ::std::string& value); void add_names(const char* value); void add_names(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& names() const; ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_names(); // repeated .google.genomics.v1.ExternalId external_ids = 2; int external_ids_size() const; void clear_external_ids(); static const int kExternalIdsFieldNumber = 2; const ::google::genomics::v1::ExternalId& external_ids(int index) const; ::google::genomics::v1::ExternalId* mutable_external_ids(int index); ::google::genomics::v1::ExternalId* add_external_ids(); ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::ExternalId >* mutable_external_ids(); const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::ExternalId >& external_ids() const; // optional string concept_id = 3; void clear_concept_id(); static const int kConceptIdFieldNumber = 3; const ::std::string& concept_id() const; void set_concept_id(const ::std::string& value); void set_concept_id(const char* value); void set_concept_id(const char* value, size_t size); ::std::string* mutable_concept_id(); ::std::string* release_concept_id(); void set_allocated_concept_id(::std::string* concept_id); ::std::string* unsafe_arena_release_concept_id(); void unsafe_arena_set_allocated_concept_id( ::std::string* concept_id); // optional string omim_id = 4; void clear_omim_id(); static const int kOmimIdFieldNumber = 4; const ::std::string& omim_id() const; void set_omim_id(const ::std::string& value); void set_omim_id(const char* value); void set_omim_id(const char* value, size_t size); ::std::string* mutable_omim_id(); ::std::string* release_omim_id(); void set_allocated_omim_id(::std::string* omim_id); ::std::string* unsafe_arena_release_omim_id(); void unsafe_arena_set_allocated_omim_id( ::std::string* omim_id); // @@protoc_insertion_point(class_scope:google.genomics.v1.VariantAnnotation.ClinicalCondition) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::std::string> names_; ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::ExternalId > external_ids_; ::google::protobuf::internal::ArenaStringPtr concept_id_; ::google::protobuf::internal::ArenaStringPtr omim_id_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<VariantAnnotation_ClinicalCondition> VariantAnnotation_ClinicalCondition_default_instance_; // ------------------------------------------------------------------- class VariantAnnotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.VariantAnnotation) */ { public: VariantAnnotation(); virtual ~VariantAnnotation(); VariantAnnotation(const VariantAnnotation& from); inline VariantAnnotation& operator=(const VariantAnnotation& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const VariantAnnotation& default_instance(); static const VariantAnnotation* internal_default_instance(); void UnsafeArenaSwap(VariantAnnotation* other); void Swap(VariantAnnotation* other); // implements Message ---------------------------------------------- inline VariantAnnotation* New() const { return New(NULL); } VariantAnnotation* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const VariantAnnotation& from); void MergeFrom(const VariantAnnotation& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(VariantAnnotation* other); void UnsafeMergeFrom(const VariantAnnotation& from); protected: explicit VariantAnnotation(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- typedef VariantAnnotation_ClinicalCondition ClinicalCondition; typedef VariantAnnotation_Type Type; static const Type TYPE_UNSPECIFIED = VariantAnnotation_Type_TYPE_UNSPECIFIED; static const Type TYPE_OTHER = VariantAnnotation_Type_TYPE_OTHER; static const Type INSERTION = VariantAnnotation_Type_INSERTION; static const Type DELETION = VariantAnnotation_Type_DELETION; static const Type SUBSTITUTION = VariantAnnotation_Type_SUBSTITUTION; static const Type SNP = VariantAnnotation_Type_SNP; static const Type STRUCTURAL = VariantAnnotation_Type_STRUCTURAL; static const Type CNV = VariantAnnotation_Type_CNV; static inline bool Type_IsValid(int value) { return VariantAnnotation_Type_IsValid(value); } static const Type Type_MIN = VariantAnnotation_Type_Type_MIN; static const Type Type_MAX = VariantAnnotation_Type_Type_MAX; static const int Type_ARRAYSIZE = VariantAnnotation_Type_Type_ARRAYSIZE; static inline const ::google::protobuf::EnumDescriptor* Type_descriptor() { return VariantAnnotation_Type_descriptor(); } static inline const ::std::string& Type_Name(Type value) { return VariantAnnotation_Type_Name(value); } static inline bool Type_Parse(const ::std::string& name, Type* value) { return VariantAnnotation_Type_Parse(name, value); } typedef VariantAnnotation_Effect Effect; static const Effect EFFECT_UNSPECIFIED = VariantAnnotation_Effect_EFFECT_UNSPECIFIED; static const Effect EFFECT_OTHER = VariantAnnotation_Effect_EFFECT_OTHER; static const Effect FRAMESHIFT = VariantAnnotation_Effect_FRAMESHIFT; static const Effect FRAME_PRESERVING_INDEL = VariantAnnotation_Effect_FRAME_PRESERVING_INDEL; static const Effect SYNONYMOUS_SNP = VariantAnnotation_Effect_SYNONYMOUS_SNP; static const Effect NONSYNONYMOUS_SNP = VariantAnnotation_Effect_NONSYNONYMOUS_SNP; static const Effect STOP_GAIN = VariantAnnotation_Effect_STOP_GAIN; static const Effect STOP_LOSS = VariantAnnotation_Effect_STOP_LOSS; static const Effect SPLICE_SITE_DISRUPTION = VariantAnnotation_Effect_SPLICE_SITE_DISRUPTION; static inline bool Effect_IsValid(int value) { return VariantAnnotation_Effect_IsValid(value); } static const Effect Effect_MIN = VariantAnnotation_Effect_Effect_MIN; static const Effect Effect_MAX = VariantAnnotation_Effect_Effect_MAX; static const int Effect_ARRAYSIZE = VariantAnnotation_Effect_Effect_ARRAYSIZE; static inline const ::google::protobuf::EnumDescriptor* Effect_descriptor() { return VariantAnnotation_Effect_descriptor(); } static inline const ::std::string& Effect_Name(Effect value) { return VariantAnnotation_Effect_Name(value); } static inline bool Effect_Parse(const ::std::string& name, Effect* value) { return VariantAnnotation_Effect_Parse(name, value); } typedef VariantAnnotation_ClinicalSignificance ClinicalSignificance; static const ClinicalSignificance CLINICAL_SIGNIFICANCE_UNSPECIFIED = VariantAnnotation_ClinicalSignificance_CLINICAL_SIGNIFICANCE_UNSPECIFIED; static const ClinicalSignificance CLINICAL_SIGNIFICANCE_OTHER = VariantAnnotation_ClinicalSignificance_CLINICAL_SIGNIFICANCE_OTHER; static const ClinicalSignificance UNCERTAIN = VariantAnnotation_ClinicalSignificance_UNCERTAIN; static const ClinicalSignificance BENIGN = VariantAnnotation_ClinicalSignificance_BENIGN; static const ClinicalSignificance LIKELY_BENIGN = VariantAnnotation_ClinicalSignificance_LIKELY_BENIGN; static const ClinicalSignificance LIKELY_PATHOGENIC = VariantAnnotation_ClinicalSignificance_LIKELY_PATHOGENIC; static const ClinicalSignificance PATHOGENIC = VariantAnnotation_ClinicalSignificance_PATHOGENIC; static const ClinicalSignificance DRUG_RESPONSE = VariantAnnotation_ClinicalSignificance_DRUG_RESPONSE; static const ClinicalSignificance HISTOCOMPATIBILITY = VariantAnnotation_ClinicalSignificance_HISTOCOMPATIBILITY; static const ClinicalSignificance CONFERS_SENSITIVITY = VariantAnnotation_ClinicalSignificance_CONFERS_SENSITIVITY; static const ClinicalSignificance RISK_FACTOR = VariantAnnotation_ClinicalSignificance_RISK_FACTOR; static const ClinicalSignificance ASSOCIATION = VariantAnnotation_ClinicalSignificance_ASSOCIATION; static const ClinicalSignificance PROTECTIVE = VariantAnnotation_ClinicalSignificance_PROTECTIVE; static const ClinicalSignificance MULTIPLE_REPORTED = VariantAnnotation_ClinicalSignificance_MULTIPLE_REPORTED; static inline bool ClinicalSignificance_IsValid(int value) { return VariantAnnotation_ClinicalSignificance_IsValid(value); } static const ClinicalSignificance ClinicalSignificance_MIN = VariantAnnotation_ClinicalSignificance_ClinicalSignificance_MIN; static const ClinicalSignificance ClinicalSignificance_MAX = VariantAnnotation_ClinicalSignificance_ClinicalSignificance_MAX; static const int ClinicalSignificance_ARRAYSIZE = VariantAnnotation_ClinicalSignificance_ClinicalSignificance_ARRAYSIZE; static inline const ::google::protobuf::EnumDescriptor* ClinicalSignificance_descriptor() { return VariantAnnotation_ClinicalSignificance_descriptor(); } static inline const ::std::string& ClinicalSignificance_Name(ClinicalSignificance value) { return VariantAnnotation_ClinicalSignificance_Name(value); } static inline bool ClinicalSignificance_Parse(const ::std::string& name, ClinicalSignificance* value) { return VariantAnnotation_ClinicalSignificance_Parse(name, value); } // accessors ------------------------------------------------------- // optional .google.genomics.v1.VariantAnnotation.Type type = 1; void clear_type(); static const int kTypeFieldNumber = 1; ::google::genomics::v1::VariantAnnotation_Type type() const; void set_type(::google::genomics::v1::VariantAnnotation_Type value); // optional .google.genomics.v1.VariantAnnotation.Effect effect = 2; void clear_effect(); static const int kEffectFieldNumber = 2; ::google::genomics::v1::VariantAnnotation_Effect effect() const; void set_effect(::google::genomics::v1::VariantAnnotation_Effect value); // optional string alternate_bases = 3; void clear_alternate_bases(); static const int kAlternateBasesFieldNumber = 3; const ::std::string& alternate_bases() const; void set_alternate_bases(const ::std::string& value); void set_alternate_bases(const char* value); void set_alternate_bases(const char* value, size_t size); ::std::string* mutable_alternate_bases(); ::std::string* release_alternate_bases(); void set_allocated_alternate_bases(::std::string* alternate_bases); ::std::string* unsafe_arena_release_alternate_bases(); void unsafe_arena_set_allocated_alternate_bases( ::std::string* alternate_bases); // optional string gene_id = 4; void clear_gene_id(); static const int kGeneIdFieldNumber = 4; const ::std::string& gene_id() const; void set_gene_id(const ::std::string& value); void set_gene_id(const char* value); void set_gene_id(const char* value, size_t size); ::std::string* mutable_gene_id(); ::std::string* release_gene_id(); void set_allocated_gene_id(::std::string* gene_id); ::std::string* unsafe_arena_release_gene_id(); void unsafe_arena_set_allocated_gene_id( ::std::string* gene_id); // repeated string transcript_ids = 5; int transcript_ids_size() const; void clear_transcript_ids(); static const int kTranscriptIdsFieldNumber = 5; const ::std::string& transcript_ids(int index) const; ::std::string* mutable_transcript_ids(int index); void set_transcript_ids(int index, const ::std::string& value); void set_transcript_ids(int index, const char* value); void set_transcript_ids(int index, const char* value, size_t size); ::std::string* add_transcript_ids(); void add_transcript_ids(const ::std::string& value); void add_transcript_ids(const char* value); void add_transcript_ids(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& transcript_ids() const; ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_transcript_ids(); // repeated .google.genomics.v1.VariantAnnotation.ClinicalCondition conditions = 6; int conditions_size() const; void clear_conditions(); static const int kConditionsFieldNumber = 6; const ::google::genomics::v1::VariantAnnotation_ClinicalCondition& conditions(int index) const; ::google::genomics::v1::VariantAnnotation_ClinicalCondition* mutable_conditions(int index); ::google::genomics::v1::VariantAnnotation_ClinicalCondition* add_conditions(); ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::VariantAnnotation_ClinicalCondition >* mutable_conditions(); const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::VariantAnnotation_ClinicalCondition >& conditions() const; // optional .google.genomics.v1.VariantAnnotation.ClinicalSignificance clinical_significance = 7; void clear_clinical_significance(); static const int kClinicalSignificanceFieldNumber = 7; ::google::genomics::v1::VariantAnnotation_ClinicalSignificance clinical_significance() const; void set_clinical_significance(::google::genomics::v1::VariantAnnotation_ClinicalSignificance value); // @@protoc_insertion_point(class_scope:google.genomics.v1.VariantAnnotation) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::std::string> transcript_ids_; ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::VariantAnnotation_ClinicalCondition > conditions_; ::google::protobuf::internal::ArenaStringPtr alternate_bases_; ::google::protobuf::internal::ArenaStringPtr gene_id_; int type_; int effect_; int clinical_significance_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<VariantAnnotation> VariantAnnotation_default_instance_; // ------------------------------------------------------------------- class Transcript_Exon : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.Transcript.Exon) */ { public: Transcript_Exon(); virtual ~Transcript_Exon(); Transcript_Exon(const Transcript_Exon& from); inline Transcript_Exon& operator=(const Transcript_Exon& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Transcript_Exon& default_instance(); static const Transcript_Exon* internal_default_instance(); void UnsafeArenaSwap(Transcript_Exon* other); void Swap(Transcript_Exon* other); // implements Message ---------------------------------------------- inline Transcript_Exon* New() const { return New(NULL); } Transcript_Exon* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const Transcript_Exon& from); void MergeFrom(const Transcript_Exon& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Transcript_Exon* other); void UnsafeMergeFrom(const Transcript_Exon& from); protected: explicit Transcript_Exon(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional int64 start = 1; void clear_start(); static const int kStartFieldNumber = 1; ::google::protobuf::int64 start() const; void set_start(::google::protobuf::int64 value); // optional int64 end = 2; void clear_end(); static const int kEndFieldNumber = 2; ::google::protobuf::int64 end() const; void set_end(::google::protobuf::int64 value); // optional .google.protobuf.Int32Value frame = 3; bool has_frame() const; void clear_frame(); static const int kFrameFieldNumber = 3; private: void _slow_mutable_frame(); void _slow_set_allocated_frame( ::google::protobuf::Arena* message_arena, ::google::protobuf::Int32Value** frame); ::google::protobuf::Int32Value* _slow_release_frame(); public: const ::google::protobuf::Int32Value& frame() const; ::google::protobuf::Int32Value* mutable_frame(); ::google::protobuf::Int32Value* release_frame(); void set_allocated_frame(::google::protobuf::Int32Value* frame); ::google::protobuf::Int32Value* unsafe_arena_release_frame(); void unsafe_arena_set_allocated_frame( ::google::protobuf::Int32Value* frame); // @@protoc_insertion_point(class_scope:google.genomics.v1.Transcript.Exon) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::Int32Value* frame_; ::google::protobuf::int64 start_; ::google::protobuf::int64 end_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<Transcript_Exon> Transcript_Exon_default_instance_; // ------------------------------------------------------------------- class Transcript_CodingSequence : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.Transcript.CodingSequence) */ { public: Transcript_CodingSequence(); virtual ~Transcript_CodingSequence(); Transcript_CodingSequence(const Transcript_CodingSequence& from); inline Transcript_CodingSequence& operator=(const Transcript_CodingSequence& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Transcript_CodingSequence& default_instance(); static const Transcript_CodingSequence* internal_default_instance(); void UnsafeArenaSwap(Transcript_CodingSequence* other); void Swap(Transcript_CodingSequence* other); // implements Message ---------------------------------------------- inline Transcript_CodingSequence* New() const { return New(NULL); } Transcript_CodingSequence* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const Transcript_CodingSequence& from); void MergeFrom(const Transcript_CodingSequence& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Transcript_CodingSequence* other); void UnsafeMergeFrom(const Transcript_CodingSequence& from); protected: explicit Transcript_CodingSequence(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional int64 start = 1; void clear_start(); static const int kStartFieldNumber = 1; ::google::protobuf::int64 start() const; void set_start(::google::protobuf::int64 value); // optional int64 end = 2; void clear_end(); static const int kEndFieldNumber = 2; ::google::protobuf::int64 end() const; void set_end(::google::protobuf::int64 value); // @@protoc_insertion_point(class_scope:google.genomics.v1.Transcript.CodingSequence) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::int64 start_; ::google::protobuf::int64 end_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<Transcript_CodingSequence> Transcript_CodingSequence_default_instance_; // ------------------------------------------------------------------- class Transcript : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.Transcript) */ { public: Transcript(); virtual ~Transcript(); Transcript(const Transcript& from); inline Transcript& operator=(const Transcript& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Transcript& default_instance(); static const Transcript* internal_default_instance(); void UnsafeArenaSwap(Transcript* other); void Swap(Transcript* other); // implements Message ---------------------------------------------- inline Transcript* New() const { return New(NULL); } Transcript* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const Transcript& from); void MergeFrom(const Transcript& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(Transcript* other); void UnsafeMergeFrom(const Transcript& from); protected: explicit Transcript(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- typedef Transcript_Exon Exon; typedef Transcript_CodingSequence CodingSequence; // accessors ------------------------------------------------------- // optional string gene_id = 1; void clear_gene_id(); static const int kGeneIdFieldNumber = 1; const ::std::string& gene_id() const; void set_gene_id(const ::std::string& value); void set_gene_id(const char* value); void set_gene_id(const char* value, size_t size); ::std::string* mutable_gene_id(); ::std::string* release_gene_id(); void set_allocated_gene_id(::std::string* gene_id); ::std::string* unsafe_arena_release_gene_id(); void unsafe_arena_set_allocated_gene_id( ::std::string* gene_id); // repeated .google.genomics.v1.Transcript.Exon exons = 2; int exons_size() const; void clear_exons(); static const int kExonsFieldNumber = 2; const ::google::genomics::v1::Transcript_Exon& exons(int index) const; ::google::genomics::v1::Transcript_Exon* mutable_exons(int index); ::google::genomics::v1::Transcript_Exon* add_exons(); ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Transcript_Exon >* mutable_exons(); const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Transcript_Exon >& exons() const; // optional .google.genomics.v1.Transcript.CodingSequence coding_sequence = 3; bool has_coding_sequence() const; void clear_coding_sequence(); static const int kCodingSequenceFieldNumber = 3; private: void _slow_mutable_coding_sequence(); void _slow_set_allocated_coding_sequence( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::Transcript_CodingSequence** coding_sequence); ::google::genomics::v1::Transcript_CodingSequence* _slow_release_coding_sequence(); public: const ::google::genomics::v1::Transcript_CodingSequence& coding_sequence() const; ::google::genomics::v1::Transcript_CodingSequence* mutable_coding_sequence(); ::google::genomics::v1::Transcript_CodingSequence* release_coding_sequence(); void set_allocated_coding_sequence(::google::genomics::v1::Transcript_CodingSequence* coding_sequence); ::google::genomics::v1::Transcript_CodingSequence* unsafe_arena_release_coding_sequence(); void unsafe_arena_set_allocated_coding_sequence( ::google::genomics::v1::Transcript_CodingSequence* coding_sequence); // @@protoc_insertion_point(class_scope:google.genomics.v1.Transcript) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Transcript_Exon > exons_; ::google::protobuf::internal::ArenaStringPtr gene_id_; ::google::genomics::v1::Transcript_CodingSequence* coding_sequence_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<Transcript> Transcript_default_instance_; // ------------------------------------------------------------------- class ExternalId : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.ExternalId) */ { public: ExternalId(); virtual ~ExternalId(); ExternalId(const ExternalId& from); inline ExternalId& operator=(const ExternalId& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const ExternalId& default_instance(); static const ExternalId* internal_default_instance(); void UnsafeArenaSwap(ExternalId* other); void Swap(ExternalId* other); // implements Message ---------------------------------------------- inline ExternalId* New() const { return New(NULL); } ExternalId* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ExternalId& from); void MergeFrom(const ExternalId& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(ExternalId* other); void UnsafeMergeFrom(const ExternalId& from); protected: explicit ExternalId(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string source_name = 1; void clear_source_name(); static const int kSourceNameFieldNumber = 1; const ::std::string& source_name() const; void set_source_name(const ::std::string& value); void set_source_name(const char* value); void set_source_name(const char* value, size_t size); ::std::string* mutable_source_name(); ::std::string* release_source_name(); void set_allocated_source_name(::std::string* source_name); ::std::string* unsafe_arena_release_source_name(); void unsafe_arena_set_allocated_source_name( ::std::string* source_name); // optional string id = 2; void clear_id(); static const int kIdFieldNumber = 2; const ::std::string& id() const; void set_id(const ::std::string& value); void set_id(const char* value); void set_id(const char* value, size_t size); ::std::string* mutable_id(); ::std::string* release_id(); void set_allocated_id(::std::string* id); ::std::string* unsafe_arena_release_id(); void unsafe_arena_set_allocated_id( ::std::string* id); // @@protoc_insertion_point(class_scope:google.genomics.v1.ExternalId) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr source_name_; ::google::protobuf::internal::ArenaStringPtr id_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<ExternalId> ExternalId_default_instance_; // ------------------------------------------------------------------- class CreateAnnotationSetRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.CreateAnnotationSetRequest) */ { public: CreateAnnotationSetRequest(); virtual ~CreateAnnotationSetRequest(); CreateAnnotationSetRequest(const CreateAnnotationSetRequest& from); inline CreateAnnotationSetRequest& operator=(const CreateAnnotationSetRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const CreateAnnotationSetRequest& default_instance(); static const CreateAnnotationSetRequest* internal_default_instance(); void UnsafeArenaSwap(CreateAnnotationSetRequest* other); void Swap(CreateAnnotationSetRequest* other); // implements Message ---------------------------------------------- inline CreateAnnotationSetRequest* New() const { return New(NULL); } CreateAnnotationSetRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const CreateAnnotationSetRequest& from); void MergeFrom(const CreateAnnotationSetRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CreateAnnotationSetRequest* other); void UnsafeMergeFrom(const CreateAnnotationSetRequest& from); protected: explicit CreateAnnotationSetRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional .google.genomics.v1.AnnotationSet annotation_set = 1; bool has_annotation_set() const; void clear_annotation_set(); static const int kAnnotationSetFieldNumber = 1; private: void _slow_mutable_annotation_set(); void _slow_set_allocated_annotation_set( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::AnnotationSet** annotation_set); ::google::genomics::v1::AnnotationSet* _slow_release_annotation_set(); public: const ::google::genomics::v1::AnnotationSet& annotation_set() const; ::google::genomics::v1::AnnotationSet* mutable_annotation_set(); ::google::genomics::v1::AnnotationSet* release_annotation_set(); void set_allocated_annotation_set(::google::genomics::v1::AnnotationSet* annotation_set); ::google::genomics::v1::AnnotationSet* unsafe_arena_release_annotation_set(); void unsafe_arena_set_allocated_annotation_set( ::google::genomics::v1::AnnotationSet* annotation_set); // @@protoc_insertion_point(class_scope:google.genomics.v1.CreateAnnotationSetRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::genomics::v1::AnnotationSet* annotation_set_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<CreateAnnotationSetRequest> CreateAnnotationSetRequest_default_instance_; // ------------------------------------------------------------------- class GetAnnotationSetRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.GetAnnotationSetRequest) */ { public: GetAnnotationSetRequest(); virtual ~GetAnnotationSetRequest(); GetAnnotationSetRequest(const GetAnnotationSetRequest& from); inline GetAnnotationSetRequest& operator=(const GetAnnotationSetRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const GetAnnotationSetRequest& default_instance(); static const GetAnnotationSetRequest* internal_default_instance(); void UnsafeArenaSwap(GetAnnotationSetRequest* other); void Swap(GetAnnotationSetRequest* other); // implements Message ---------------------------------------------- inline GetAnnotationSetRequest* New() const { return New(NULL); } GetAnnotationSetRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const GetAnnotationSetRequest& from); void MergeFrom(const GetAnnotationSetRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(GetAnnotationSetRequest* other); void UnsafeMergeFrom(const GetAnnotationSetRequest& from); protected: explicit GetAnnotationSetRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string annotation_set_id = 1; void clear_annotation_set_id(); static const int kAnnotationSetIdFieldNumber = 1; const ::std::string& annotation_set_id() const; void set_annotation_set_id(const ::std::string& value); void set_annotation_set_id(const char* value); void set_annotation_set_id(const char* value, size_t size); ::std::string* mutable_annotation_set_id(); ::std::string* release_annotation_set_id(); void set_allocated_annotation_set_id(::std::string* annotation_set_id); ::std::string* unsafe_arena_release_annotation_set_id(); void unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id); // @@protoc_insertion_point(class_scope:google.genomics.v1.GetAnnotationSetRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr annotation_set_id_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<GetAnnotationSetRequest> GetAnnotationSetRequest_default_instance_; // ------------------------------------------------------------------- class UpdateAnnotationSetRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.UpdateAnnotationSetRequest) */ { public: UpdateAnnotationSetRequest(); virtual ~UpdateAnnotationSetRequest(); UpdateAnnotationSetRequest(const UpdateAnnotationSetRequest& from); inline UpdateAnnotationSetRequest& operator=(const UpdateAnnotationSetRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const UpdateAnnotationSetRequest& default_instance(); static const UpdateAnnotationSetRequest* internal_default_instance(); void UnsafeArenaSwap(UpdateAnnotationSetRequest* other); void Swap(UpdateAnnotationSetRequest* other); // implements Message ---------------------------------------------- inline UpdateAnnotationSetRequest* New() const { return New(NULL); } UpdateAnnotationSetRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const UpdateAnnotationSetRequest& from); void MergeFrom(const UpdateAnnotationSetRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UpdateAnnotationSetRequest* other); void UnsafeMergeFrom(const UpdateAnnotationSetRequest& from); protected: explicit UpdateAnnotationSetRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string annotation_set_id = 1; void clear_annotation_set_id(); static const int kAnnotationSetIdFieldNumber = 1; const ::std::string& annotation_set_id() const; void set_annotation_set_id(const ::std::string& value); void set_annotation_set_id(const char* value); void set_annotation_set_id(const char* value, size_t size); ::std::string* mutable_annotation_set_id(); ::std::string* release_annotation_set_id(); void set_allocated_annotation_set_id(::std::string* annotation_set_id); ::std::string* unsafe_arena_release_annotation_set_id(); void unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id); // optional .google.genomics.v1.AnnotationSet annotation_set = 2; bool has_annotation_set() const; void clear_annotation_set(); static const int kAnnotationSetFieldNumber = 2; private: void _slow_mutable_annotation_set(); void _slow_set_allocated_annotation_set( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::AnnotationSet** annotation_set); ::google::genomics::v1::AnnotationSet* _slow_release_annotation_set(); public: const ::google::genomics::v1::AnnotationSet& annotation_set() const; ::google::genomics::v1::AnnotationSet* mutable_annotation_set(); ::google::genomics::v1::AnnotationSet* release_annotation_set(); void set_allocated_annotation_set(::google::genomics::v1::AnnotationSet* annotation_set); ::google::genomics::v1::AnnotationSet* unsafe_arena_release_annotation_set(); void unsafe_arena_set_allocated_annotation_set( ::google::genomics::v1::AnnotationSet* annotation_set); // optional .google.protobuf.FieldMask update_mask = 3; bool has_update_mask() const; void clear_update_mask(); static const int kUpdateMaskFieldNumber = 3; private: void _slow_mutable_update_mask(); ::google::protobuf::FieldMask* _slow_release_update_mask(); public: const ::google::protobuf::FieldMask& update_mask() const; ::google::protobuf::FieldMask* mutable_update_mask(); ::google::protobuf::FieldMask* release_update_mask(); void set_allocated_update_mask(::google::protobuf::FieldMask* update_mask); ::google::protobuf::FieldMask* unsafe_arena_release_update_mask(); void unsafe_arena_set_allocated_update_mask( ::google::protobuf::FieldMask* update_mask); // @@protoc_insertion_point(class_scope:google.genomics.v1.UpdateAnnotationSetRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr annotation_set_id_; ::google::genomics::v1::AnnotationSet* annotation_set_; ::google::protobuf::FieldMask* update_mask_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<UpdateAnnotationSetRequest> UpdateAnnotationSetRequest_default_instance_; // ------------------------------------------------------------------- class DeleteAnnotationSetRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.DeleteAnnotationSetRequest) */ { public: DeleteAnnotationSetRequest(); virtual ~DeleteAnnotationSetRequest(); DeleteAnnotationSetRequest(const DeleteAnnotationSetRequest& from); inline DeleteAnnotationSetRequest& operator=(const DeleteAnnotationSetRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const DeleteAnnotationSetRequest& default_instance(); static const DeleteAnnotationSetRequest* internal_default_instance(); void UnsafeArenaSwap(DeleteAnnotationSetRequest* other); void Swap(DeleteAnnotationSetRequest* other); // implements Message ---------------------------------------------- inline DeleteAnnotationSetRequest* New() const { return New(NULL); } DeleteAnnotationSetRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const DeleteAnnotationSetRequest& from); void MergeFrom(const DeleteAnnotationSetRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DeleteAnnotationSetRequest* other); void UnsafeMergeFrom(const DeleteAnnotationSetRequest& from); protected: explicit DeleteAnnotationSetRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string annotation_set_id = 1; void clear_annotation_set_id(); static const int kAnnotationSetIdFieldNumber = 1; const ::std::string& annotation_set_id() const; void set_annotation_set_id(const ::std::string& value); void set_annotation_set_id(const char* value); void set_annotation_set_id(const char* value, size_t size); ::std::string* mutable_annotation_set_id(); ::std::string* release_annotation_set_id(); void set_allocated_annotation_set_id(::std::string* annotation_set_id); ::std::string* unsafe_arena_release_annotation_set_id(); void unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id); // @@protoc_insertion_point(class_scope:google.genomics.v1.DeleteAnnotationSetRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr annotation_set_id_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<DeleteAnnotationSetRequest> DeleteAnnotationSetRequest_default_instance_; // ------------------------------------------------------------------- class SearchAnnotationSetsRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.SearchAnnotationSetsRequest) */ { public: SearchAnnotationSetsRequest(); virtual ~SearchAnnotationSetsRequest(); SearchAnnotationSetsRequest(const SearchAnnotationSetsRequest& from); inline SearchAnnotationSetsRequest& operator=(const SearchAnnotationSetsRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const SearchAnnotationSetsRequest& default_instance(); static const SearchAnnotationSetsRequest* internal_default_instance(); void UnsafeArenaSwap(SearchAnnotationSetsRequest* other); void Swap(SearchAnnotationSetsRequest* other); // implements Message ---------------------------------------------- inline SearchAnnotationSetsRequest* New() const { return New(NULL); } SearchAnnotationSetsRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SearchAnnotationSetsRequest& from); void MergeFrom(const SearchAnnotationSetsRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SearchAnnotationSetsRequest* other); void UnsafeMergeFrom(const SearchAnnotationSetsRequest& from); protected: explicit SearchAnnotationSetsRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated string dataset_ids = 1; int dataset_ids_size() const; void clear_dataset_ids(); static const int kDatasetIdsFieldNumber = 1; const ::std::string& dataset_ids(int index) const; ::std::string* mutable_dataset_ids(int index); void set_dataset_ids(int index, const ::std::string& value); void set_dataset_ids(int index, const char* value); void set_dataset_ids(int index, const char* value, size_t size); ::std::string* add_dataset_ids(); void add_dataset_ids(const ::std::string& value); void add_dataset_ids(const char* value); void add_dataset_ids(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& dataset_ids() const; ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_dataset_ids(); // optional string reference_set_id = 2; void clear_reference_set_id(); static const int kReferenceSetIdFieldNumber = 2; const ::std::string& reference_set_id() const; void set_reference_set_id(const ::std::string& value); void set_reference_set_id(const char* value); void set_reference_set_id(const char* value, size_t size); ::std::string* mutable_reference_set_id(); ::std::string* release_reference_set_id(); void set_allocated_reference_set_id(::std::string* reference_set_id); ::std::string* unsafe_arena_release_reference_set_id(); void unsafe_arena_set_allocated_reference_set_id( ::std::string* reference_set_id); // optional string name = 3; void clear_name(); static const int kNameFieldNumber = 3; const ::std::string& name() const; void set_name(const ::std::string& value); void set_name(const char* value); void set_name(const char* value, size_t size); ::std::string* mutable_name(); ::std::string* release_name(); void set_allocated_name(::std::string* name); ::std::string* unsafe_arena_release_name(); void unsafe_arena_set_allocated_name( ::std::string* name); // repeated .google.genomics.v1.AnnotationType types = 4; int types_size() const; void clear_types(); static const int kTypesFieldNumber = 4; ::google::genomics::v1::AnnotationType types(int index) const; void set_types(int index, ::google::genomics::v1::AnnotationType value); void add_types(::google::genomics::v1::AnnotationType value); const ::google::protobuf::RepeatedField<int>& types() const; ::google::protobuf::RepeatedField<int>* mutable_types(); // optional string page_token = 5; void clear_page_token(); static const int kPageTokenFieldNumber = 5; const ::std::string& page_token() const; void set_page_token(const ::std::string& value); void set_page_token(const char* value); void set_page_token(const char* value, size_t size); ::std::string* mutable_page_token(); ::std::string* release_page_token(); void set_allocated_page_token(::std::string* page_token); ::std::string* unsafe_arena_release_page_token(); void unsafe_arena_set_allocated_page_token( ::std::string* page_token); // optional int32 page_size = 6; void clear_page_size(); static const int kPageSizeFieldNumber = 6; ::google::protobuf::int32 page_size() const; void set_page_size(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:google.genomics.v1.SearchAnnotationSetsRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::std::string> dataset_ids_; ::google::protobuf::RepeatedField<int> types_; mutable int _types_cached_byte_size_; ::google::protobuf::internal::ArenaStringPtr reference_set_id_; ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr page_token_; ::google::protobuf::int32 page_size_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<SearchAnnotationSetsRequest> SearchAnnotationSetsRequest_default_instance_; // ------------------------------------------------------------------- class SearchAnnotationSetsResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.SearchAnnotationSetsResponse) */ { public: SearchAnnotationSetsResponse(); virtual ~SearchAnnotationSetsResponse(); SearchAnnotationSetsResponse(const SearchAnnotationSetsResponse& from); inline SearchAnnotationSetsResponse& operator=(const SearchAnnotationSetsResponse& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const SearchAnnotationSetsResponse& default_instance(); static const SearchAnnotationSetsResponse* internal_default_instance(); void UnsafeArenaSwap(SearchAnnotationSetsResponse* other); void Swap(SearchAnnotationSetsResponse* other); // implements Message ---------------------------------------------- inline SearchAnnotationSetsResponse* New() const { return New(NULL); } SearchAnnotationSetsResponse* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SearchAnnotationSetsResponse& from); void MergeFrom(const SearchAnnotationSetsResponse& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SearchAnnotationSetsResponse* other); void UnsafeMergeFrom(const SearchAnnotationSetsResponse& from); protected: explicit SearchAnnotationSetsResponse(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated .google.genomics.v1.AnnotationSet annotation_sets = 1; int annotation_sets_size() const; void clear_annotation_sets(); static const int kAnnotationSetsFieldNumber = 1; const ::google::genomics::v1::AnnotationSet& annotation_sets(int index) const; ::google::genomics::v1::AnnotationSet* mutable_annotation_sets(int index); ::google::genomics::v1::AnnotationSet* add_annotation_sets(); ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::AnnotationSet >* mutable_annotation_sets(); const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::AnnotationSet >& annotation_sets() const; // optional string next_page_token = 2; void clear_next_page_token(); static const int kNextPageTokenFieldNumber = 2; const ::std::string& next_page_token() const; void set_next_page_token(const ::std::string& value); void set_next_page_token(const char* value); void set_next_page_token(const char* value, size_t size); ::std::string* mutable_next_page_token(); ::std::string* release_next_page_token(); void set_allocated_next_page_token(::std::string* next_page_token); ::std::string* unsafe_arena_release_next_page_token(); void unsafe_arena_set_allocated_next_page_token( ::std::string* next_page_token); // @@protoc_insertion_point(class_scope:google.genomics.v1.SearchAnnotationSetsResponse) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::AnnotationSet > annotation_sets_; ::google::protobuf::internal::ArenaStringPtr next_page_token_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<SearchAnnotationSetsResponse> SearchAnnotationSetsResponse_default_instance_; // ------------------------------------------------------------------- class CreateAnnotationRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.CreateAnnotationRequest) */ { public: CreateAnnotationRequest(); virtual ~CreateAnnotationRequest(); CreateAnnotationRequest(const CreateAnnotationRequest& from); inline CreateAnnotationRequest& operator=(const CreateAnnotationRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const CreateAnnotationRequest& default_instance(); static const CreateAnnotationRequest* internal_default_instance(); void UnsafeArenaSwap(CreateAnnotationRequest* other); void Swap(CreateAnnotationRequest* other); // implements Message ---------------------------------------------- inline CreateAnnotationRequest* New() const { return New(NULL); } CreateAnnotationRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const CreateAnnotationRequest& from); void MergeFrom(const CreateAnnotationRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(CreateAnnotationRequest* other); void UnsafeMergeFrom(const CreateAnnotationRequest& from); protected: explicit CreateAnnotationRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional .google.genomics.v1.Annotation annotation = 1; bool has_annotation() const; void clear_annotation(); static const int kAnnotationFieldNumber = 1; private: void _slow_mutable_annotation(); void _slow_set_allocated_annotation( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::Annotation** annotation); ::google::genomics::v1::Annotation* _slow_release_annotation(); public: const ::google::genomics::v1::Annotation& annotation() const; ::google::genomics::v1::Annotation* mutable_annotation(); ::google::genomics::v1::Annotation* release_annotation(); void set_allocated_annotation(::google::genomics::v1::Annotation* annotation); ::google::genomics::v1::Annotation* unsafe_arena_release_annotation(); void unsafe_arena_set_allocated_annotation( ::google::genomics::v1::Annotation* annotation); // @@protoc_insertion_point(class_scope:google.genomics.v1.CreateAnnotationRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::genomics::v1::Annotation* annotation_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<CreateAnnotationRequest> CreateAnnotationRequest_default_instance_; // ------------------------------------------------------------------- class BatchCreateAnnotationsRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.BatchCreateAnnotationsRequest) */ { public: BatchCreateAnnotationsRequest(); virtual ~BatchCreateAnnotationsRequest(); BatchCreateAnnotationsRequest(const BatchCreateAnnotationsRequest& from); inline BatchCreateAnnotationsRequest& operator=(const BatchCreateAnnotationsRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const BatchCreateAnnotationsRequest& default_instance(); static const BatchCreateAnnotationsRequest* internal_default_instance(); void UnsafeArenaSwap(BatchCreateAnnotationsRequest* other); void Swap(BatchCreateAnnotationsRequest* other); // implements Message ---------------------------------------------- inline BatchCreateAnnotationsRequest* New() const { return New(NULL); } BatchCreateAnnotationsRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const BatchCreateAnnotationsRequest& from); void MergeFrom(const BatchCreateAnnotationsRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(BatchCreateAnnotationsRequest* other); void UnsafeMergeFrom(const BatchCreateAnnotationsRequest& from); protected: explicit BatchCreateAnnotationsRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated .google.genomics.v1.Annotation annotations = 1; int annotations_size() const; void clear_annotations(); static const int kAnnotationsFieldNumber = 1; const ::google::genomics::v1::Annotation& annotations(int index) const; ::google::genomics::v1::Annotation* mutable_annotations(int index); ::google::genomics::v1::Annotation* add_annotations(); ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >* mutable_annotations(); const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >& annotations() const; // optional string request_id = 2; void clear_request_id(); static const int kRequestIdFieldNumber = 2; const ::std::string& request_id() const; void set_request_id(const ::std::string& value); void set_request_id(const char* value); void set_request_id(const char* value, size_t size); ::std::string* mutable_request_id(); ::std::string* release_request_id(); void set_allocated_request_id(::std::string* request_id); ::std::string* unsafe_arena_release_request_id(); void unsafe_arena_set_allocated_request_id( ::std::string* request_id); // @@protoc_insertion_point(class_scope:google.genomics.v1.BatchCreateAnnotationsRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation > annotations_; ::google::protobuf::internal::ArenaStringPtr request_id_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<BatchCreateAnnotationsRequest> BatchCreateAnnotationsRequest_default_instance_; // ------------------------------------------------------------------- class BatchCreateAnnotationsResponse_Entry : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.BatchCreateAnnotationsResponse.Entry) */ { public: BatchCreateAnnotationsResponse_Entry(); virtual ~BatchCreateAnnotationsResponse_Entry(); BatchCreateAnnotationsResponse_Entry(const BatchCreateAnnotationsResponse_Entry& from); inline BatchCreateAnnotationsResponse_Entry& operator=(const BatchCreateAnnotationsResponse_Entry& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const BatchCreateAnnotationsResponse_Entry& default_instance(); static const BatchCreateAnnotationsResponse_Entry* internal_default_instance(); void UnsafeArenaSwap(BatchCreateAnnotationsResponse_Entry* other); void Swap(BatchCreateAnnotationsResponse_Entry* other); // implements Message ---------------------------------------------- inline BatchCreateAnnotationsResponse_Entry* New() const { return New(NULL); } BatchCreateAnnotationsResponse_Entry* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const BatchCreateAnnotationsResponse_Entry& from); void MergeFrom(const BatchCreateAnnotationsResponse_Entry& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(BatchCreateAnnotationsResponse_Entry* other); void UnsafeMergeFrom(const BatchCreateAnnotationsResponse_Entry& from); protected: explicit BatchCreateAnnotationsResponse_Entry(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional .google.rpc.Status status = 1; bool has_status() const; void clear_status(); static const int kStatusFieldNumber = 1; private: void _slow_mutable_status(); ::google::rpc::Status* _slow_release_status(); public: const ::google::rpc::Status& status() const; ::google::rpc::Status* mutable_status(); ::google::rpc::Status* release_status(); void set_allocated_status(::google::rpc::Status* status); ::google::rpc::Status* unsafe_arena_release_status(); void unsafe_arena_set_allocated_status( ::google::rpc::Status* status); // optional .google.genomics.v1.Annotation annotation = 2; bool has_annotation() const; void clear_annotation(); static const int kAnnotationFieldNumber = 2; private: void _slow_mutable_annotation(); void _slow_set_allocated_annotation( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::Annotation** annotation); ::google::genomics::v1::Annotation* _slow_release_annotation(); public: const ::google::genomics::v1::Annotation& annotation() const; ::google::genomics::v1::Annotation* mutable_annotation(); ::google::genomics::v1::Annotation* release_annotation(); void set_allocated_annotation(::google::genomics::v1::Annotation* annotation); ::google::genomics::v1::Annotation* unsafe_arena_release_annotation(); void unsafe_arena_set_allocated_annotation( ::google::genomics::v1::Annotation* annotation); // @@protoc_insertion_point(class_scope:google.genomics.v1.BatchCreateAnnotationsResponse.Entry) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::rpc::Status* status_; ::google::genomics::v1::Annotation* annotation_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<BatchCreateAnnotationsResponse_Entry> BatchCreateAnnotationsResponse_Entry_default_instance_; // ------------------------------------------------------------------- class BatchCreateAnnotationsResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.BatchCreateAnnotationsResponse) */ { public: BatchCreateAnnotationsResponse(); virtual ~BatchCreateAnnotationsResponse(); BatchCreateAnnotationsResponse(const BatchCreateAnnotationsResponse& from); inline BatchCreateAnnotationsResponse& operator=(const BatchCreateAnnotationsResponse& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const BatchCreateAnnotationsResponse& default_instance(); static const BatchCreateAnnotationsResponse* internal_default_instance(); void UnsafeArenaSwap(BatchCreateAnnotationsResponse* other); void Swap(BatchCreateAnnotationsResponse* other); // implements Message ---------------------------------------------- inline BatchCreateAnnotationsResponse* New() const { return New(NULL); } BatchCreateAnnotationsResponse* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const BatchCreateAnnotationsResponse& from); void MergeFrom(const BatchCreateAnnotationsResponse& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(BatchCreateAnnotationsResponse* other); void UnsafeMergeFrom(const BatchCreateAnnotationsResponse& from); protected: explicit BatchCreateAnnotationsResponse(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- typedef BatchCreateAnnotationsResponse_Entry Entry; // accessors ------------------------------------------------------- // repeated .google.genomics.v1.BatchCreateAnnotationsResponse.Entry entries = 1; int entries_size() const; void clear_entries(); static const int kEntriesFieldNumber = 1; const ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry& entries(int index) const; ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry* mutable_entries(int index); ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry* add_entries(); ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry >* mutable_entries(); const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry >& entries() const; // @@protoc_insertion_point(class_scope:google.genomics.v1.BatchCreateAnnotationsResponse) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry > entries_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<BatchCreateAnnotationsResponse> BatchCreateAnnotationsResponse_default_instance_; // ------------------------------------------------------------------- class GetAnnotationRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.GetAnnotationRequest) */ { public: GetAnnotationRequest(); virtual ~GetAnnotationRequest(); GetAnnotationRequest(const GetAnnotationRequest& from); inline GetAnnotationRequest& operator=(const GetAnnotationRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const GetAnnotationRequest& default_instance(); static const GetAnnotationRequest* internal_default_instance(); void UnsafeArenaSwap(GetAnnotationRequest* other); void Swap(GetAnnotationRequest* other); // implements Message ---------------------------------------------- inline GetAnnotationRequest* New() const { return New(NULL); } GetAnnotationRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const GetAnnotationRequest& from); void MergeFrom(const GetAnnotationRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(GetAnnotationRequest* other); void UnsafeMergeFrom(const GetAnnotationRequest& from); protected: explicit GetAnnotationRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string annotation_id = 1; void clear_annotation_id(); static const int kAnnotationIdFieldNumber = 1; const ::std::string& annotation_id() const; void set_annotation_id(const ::std::string& value); void set_annotation_id(const char* value); void set_annotation_id(const char* value, size_t size); ::std::string* mutable_annotation_id(); ::std::string* release_annotation_id(); void set_allocated_annotation_id(::std::string* annotation_id); ::std::string* unsafe_arena_release_annotation_id(); void unsafe_arena_set_allocated_annotation_id( ::std::string* annotation_id); // @@protoc_insertion_point(class_scope:google.genomics.v1.GetAnnotationRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr annotation_id_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<GetAnnotationRequest> GetAnnotationRequest_default_instance_; // ------------------------------------------------------------------- class UpdateAnnotationRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.UpdateAnnotationRequest) */ { public: UpdateAnnotationRequest(); virtual ~UpdateAnnotationRequest(); UpdateAnnotationRequest(const UpdateAnnotationRequest& from); inline UpdateAnnotationRequest& operator=(const UpdateAnnotationRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const UpdateAnnotationRequest& default_instance(); static const UpdateAnnotationRequest* internal_default_instance(); void UnsafeArenaSwap(UpdateAnnotationRequest* other); void Swap(UpdateAnnotationRequest* other); // implements Message ---------------------------------------------- inline UpdateAnnotationRequest* New() const { return New(NULL); } UpdateAnnotationRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const UpdateAnnotationRequest& from); void MergeFrom(const UpdateAnnotationRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(UpdateAnnotationRequest* other); void UnsafeMergeFrom(const UpdateAnnotationRequest& from); protected: explicit UpdateAnnotationRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string annotation_id = 1; void clear_annotation_id(); static const int kAnnotationIdFieldNumber = 1; const ::std::string& annotation_id() const; void set_annotation_id(const ::std::string& value); void set_annotation_id(const char* value); void set_annotation_id(const char* value, size_t size); ::std::string* mutable_annotation_id(); ::std::string* release_annotation_id(); void set_allocated_annotation_id(::std::string* annotation_id); ::std::string* unsafe_arena_release_annotation_id(); void unsafe_arena_set_allocated_annotation_id( ::std::string* annotation_id); // optional .google.genomics.v1.Annotation annotation = 2; bool has_annotation() const; void clear_annotation(); static const int kAnnotationFieldNumber = 2; private: void _slow_mutable_annotation(); void _slow_set_allocated_annotation( ::google::protobuf::Arena* message_arena, ::google::genomics::v1::Annotation** annotation); ::google::genomics::v1::Annotation* _slow_release_annotation(); public: const ::google::genomics::v1::Annotation& annotation() const; ::google::genomics::v1::Annotation* mutable_annotation(); ::google::genomics::v1::Annotation* release_annotation(); void set_allocated_annotation(::google::genomics::v1::Annotation* annotation); ::google::genomics::v1::Annotation* unsafe_arena_release_annotation(); void unsafe_arena_set_allocated_annotation( ::google::genomics::v1::Annotation* annotation); // optional .google.protobuf.FieldMask update_mask = 3; bool has_update_mask() const; void clear_update_mask(); static const int kUpdateMaskFieldNumber = 3; private: void _slow_mutable_update_mask(); ::google::protobuf::FieldMask* _slow_release_update_mask(); public: const ::google::protobuf::FieldMask& update_mask() const; ::google::protobuf::FieldMask* mutable_update_mask(); ::google::protobuf::FieldMask* release_update_mask(); void set_allocated_update_mask(::google::protobuf::FieldMask* update_mask); ::google::protobuf::FieldMask* unsafe_arena_release_update_mask(); void unsafe_arena_set_allocated_update_mask( ::google::protobuf::FieldMask* update_mask); // @@protoc_insertion_point(class_scope:google.genomics.v1.UpdateAnnotationRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr annotation_id_; ::google::genomics::v1::Annotation* annotation_; ::google::protobuf::FieldMask* update_mask_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<UpdateAnnotationRequest> UpdateAnnotationRequest_default_instance_; // ------------------------------------------------------------------- class DeleteAnnotationRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.DeleteAnnotationRequest) */ { public: DeleteAnnotationRequest(); virtual ~DeleteAnnotationRequest(); DeleteAnnotationRequest(const DeleteAnnotationRequest& from); inline DeleteAnnotationRequest& operator=(const DeleteAnnotationRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const DeleteAnnotationRequest& default_instance(); static const DeleteAnnotationRequest* internal_default_instance(); void UnsafeArenaSwap(DeleteAnnotationRequest* other); void Swap(DeleteAnnotationRequest* other); // implements Message ---------------------------------------------- inline DeleteAnnotationRequest* New() const { return New(NULL); } DeleteAnnotationRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const DeleteAnnotationRequest& from); void MergeFrom(const DeleteAnnotationRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(DeleteAnnotationRequest* other); void UnsafeMergeFrom(const DeleteAnnotationRequest& from); protected: explicit DeleteAnnotationRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string annotation_id = 1; void clear_annotation_id(); static const int kAnnotationIdFieldNumber = 1; const ::std::string& annotation_id() const; void set_annotation_id(const ::std::string& value); void set_annotation_id(const char* value); void set_annotation_id(const char* value, size_t size); ::std::string* mutable_annotation_id(); ::std::string* release_annotation_id(); void set_allocated_annotation_id(::std::string* annotation_id); ::std::string* unsafe_arena_release_annotation_id(); void unsafe_arena_set_allocated_annotation_id( ::std::string* annotation_id); // @@protoc_insertion_point(class_scope:google.genomics.v1.DeleteAnnotationRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::internal::ArenaStringPtr annotation_id_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<DeleteAnnotationRequest> DeleteAnnotationRequest_default_instance_; // ------------------------------------------------------------------- class SearchAnnotationsRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.SearchAnnotationsRequest) */ { public: SearchAnnotationsRequest(); virtual ~SearchAnnotationsRequest(); SearchAnnotationsRequest(const SearchAnnotationsRequest& from); inline SearchAnnotationsRequest& operator=(const SearchAnnotationsRequest& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const SearchAnnotationsRequest& default_instance(); enum ReferenceCase { kReferenceId = 2, kReferenceName = 3, REFERENCE_NOT_SET = 0, }; static const SearchAnnotationsRequest* internal_default_instance(); void UnsafeArenaSwap(SearchAnnotationsRequest* other); void Swap(SearchAnnotationsRequest* other); // implements Message ---------------------------------------------- inline SearchAnnotationsRequest* New() const { return New(NULL); } SearchAnnotationsRequest* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SearchAnnotationsRequest& from); void MergeFrom(const SearchAnnotationsRequest& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SearchAnnotationsRequest* other); void UnsafeMergeFrom(const SearchAnnotationsRequest& from); protected: explicit SearchAnnotationsRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated string annotation_set_ids = 1; int annotation_set_ids_size() const; void clear_annotation_set_ids(); static const int kAnnotationSetIdsFieldNumber = 1; const ::std::string& annotation_set_ids(int index) const; ::std::string* mutable_annotation_set_ids(int index); void set_annotation_set_ids(int index, const ::std::string& value); void set_annotation_set_ids(int index, const char* value); void set_annotation_set_ids(int index, const char* value, size_t size); ::std::string* add_annotation_set_ids(); void add_annotation_set_ids(const ::std::string& value); void add_annotation_set_ids(const char* value); void add_annotation_set_ids(const char* value, size_t size); const ::google::protobuf::RepeatedPtrField< ::std::string>& annotation_set_ids() const; ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_annotation_set_ids(); // optional string reference_id = 2; private: bool has_reference_id() const; public: void clear_reference_id(); static const int kReferenceIdFieldNumber = 2; const ::std::string& reference_id() const; void set_reference_id(const ::std::string& value); void set_reference_id(const char* value); void set_reference_id(const char* value, size_t size); ::std::string* mutable_reference_id(); ::std::string* release_reference_id(); void set_allocated_reference_id(::std::string* reference_id); ::std::string* unsafe_arena_release_reference_id(); void unsafe_arena_set_allocated_reference_id( ::std::string* reference_id); // optional string reference_name = 3; private: bool has_reference_name() const; public: void clear_reference_name(); static const int kReferenceNameFieldNumber = 3; const ::std::string& reference_name() const; void set_reference_name(const ::std::string& value); void set_reference_name(const char* value); void set_reference_name(const char* value, size_t size); ::std::string* mutable_reference_name(); ::std::string* release_reference_name(); void set_allocated_reference_name(::std::string* reference_name); ::std::string* unsafe_arena_release_reference_name(); void unsafe_arena_set_allocated_reference_name( ::std::string* reference_name); // optional int64 start = 4; void clear_start(); static const int kStartFieldNumber = 4; ::google::protobuf::int64 start() const; void set_start(::google::protobuf::int64 value); // optional int64 end = 5; void clear_end(); static const int kEndFieldNumber = 5; ::google::protobuf::int64 end() const; void set_end(::google::protobuf::int64 value); // optional string page_token = 6; void clear_page_token(); static const int kPageTokenFieldNumber = 6; const ::std::string& page_token() const; void set_page_token(const ::std::string& value); void set_page_token(const char* value); void set_page_token(const char* value, size_t size); ::std::string* mutable_page_token(); ::std::string* release_page_token(); void set_allocated_page_token(::std::string* page_token); ::std::string* unsafe_arena_release_page_token(); void unsafe_arena_set_allocated_page_token( ::std::string* page_token); // optional int32 page_size = 7; void clear_page_size(); static const int kPageSizeFieldNumber = 7; ::google::protobuf::int32 page_size() const; void set_page_size(::google::protobuf::int32 value); ReferenceCase reference_case() const; // @@protoc_insertion_point(class_scope:google.genomics.v1.SearchAnnotationsRequest) private: inline void set_has_reference_id(); inline void set_has_reference_name(); inline bool has_reference() const; void clear_reference(); inline void clear_has_reference(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::std::string> annotation_set_ids_; ::google::protobuf::internal::ArenaStringPtr page_token_; ::google::protobuf::int64 start_; ::google::protobuf::int64 end_; ::google::protobuf::int32 page_size_; union ReferenceUnion { ReferenceUnion() {} ::google::protobuf::internal::ArenaStringPtr reference_id_; ::google::protobuf::internal::ArenaStringPtr reference_name_; } reference_; mutable int _cached_size_; ::google::protobuf::uint32 _oneof_case_[1]; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<SearchAnnotationsRequest> SearchAnnotationsRequest_default_instance_; // ------------------------------------------------------------------- class SearchAnnotationsResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.genomics.v1.SearchAnnotationsResponse) */ { public: SearchAnnotationsResponse(); virtual ~SearchAnnotationsResponse(); SearchAnnotationsResponse(const SearchAnnotationsResponse& from); inline SearchAnnotationsResponse& operator=(const SearchAnnotationsResponse& from) { CopyFrom(from); return *this; } inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const SearchAnnotationsResponse& default_instance(); static const SearchAnnotationsResponse* internal_default_instance(); void UnsafeArenaSwap(SearchAnnotationsResponse* other); void Swap(SearchAnnotationsResponse* other); // implements Message ---------------------------------------------- inline SearchAnnotationsResponse* New() const { return New(NULL); } SearchAnnotationsResponse* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SearchAnnotationsResponse& from); void MergeFrom(const SearchAnnotationsResponse& from); void Clear(); bool IsInitialized() const; size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SearchAnnotationsResponse* other); void UnsafeMergeFrom(const SearchAnnotationsResponse& from); protected: explicit SearchAnnotationsResponse(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated .google.genomics.v1.Annotation annotations = 1; int annotations_size() const; void clear_annotations(); static const int kAnnotationsFieldNumber = 1; const ::google::genomics::v1::Annotation& annotations(int index) const; ::google::genomics::v1::Annotation* mutable_annotations(int index); ::google::genomics::v1::Annotation* add_annotations(); ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >* mutable_annotations(); const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >& annotations() const; // optional string next_page_token = 2; void clear_next_page_token(); static const int kNextPageTokenFieldNumber = 2; const ::std::string& next_page_token() const; void set_next_page_token(const ::std::string& value); void set_next_page_token(const char* value); void set_next_page_token(const char* value, size_t size); ::std::string* mutable_next_page_token(); ::std::string* release_next_page_token(); void set_allocated_next_page_token(::std::string* next_page_token); ::std::string* unsafe_arena_release_next_page_token(); void unsafe_arena_set_allocated_next_page_token( ::std::string* next_page_token); // @@protoc_insertion_point(class_scope:google.genomics.v1.SearchAnnotationsResponse) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; friend class ::google::protobuf::Arena; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation > annotations_; ::google::protobuf::internal::ArenaStringPtr next_page_token_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AddDesc_google_2fgenomics_2fv1_2fannotations_2eproto_impl(); friend void protobuf_AssignDesc_google_2fgenomics_2fv1_2fannotations_2eproto(); friend void protobuf_ShutdownFile_google_2fgenomics_2fv1_2fannotations_2eproto(); void InitAsDefaultInstance(); }; extern ::google::protobuf::internal::ExplicitlyConstructed<SearchAnnotationsResponse> SearchAnnotationsResponse_default_instance_; // =================================================================== // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS // AnnotationSet // optional string id = 1; inline void AnnotationSet::clear_id() { id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& AnnotationSet::id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.AnnotationSet.id) return id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void AnnotationSet::set_id(const ::std::string& value) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.AnnotationSet.id) } inline void AnnotationSet::set_id(const char* value) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.AnnotationSet.id) } inline void AnnotationSet::set_id(const char* value, size_t size) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.AnnotationSet.id) } inline ::std::string* AnnotationSet::mutable_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.AnnotationSet.id) return id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::release_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.AnnotationSet.id) return id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::unsafe_arena_release_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.AnnotationSet.id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void AnnotationSet::set_allocated_id(::std::string* id) { if (id != NULL) { } else { } id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.AnnotationSet.id) } inline void AnnotationSet::unsafe_arena_set_allocated_id( ::std::string* id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (id != NULL) { } else { } id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.AnnotationSet.id) } // optional string dataset_id = 2; inline void AnnotationSet::clear_dataset_id() { dataset_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& AnnotationSet::dataset_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.AnnotationSet.dataset_id) return dataset_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void AnnotationSet::set_dataset_id(const ::std::string& value) { dataset_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.AnnotationSet.dataset_id) } inline void AnnotationSet::set_dataset_id(const char* value) { dataset_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.AnnotationSet.dataset_id) } inline void AnnotationSet::set_dataset_id(const char* value, size_t size) { dataset_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.AnnotationSet.dataset_id) } inline ::std::string* AnnotationSet::mutable_dataset_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.AnnotationSet.dataset_id) return dataset_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::release_dataset_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.AnnotationSet.dataset_id) return dataset_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::unsafe_arena_release_dataset_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.AnnotationSet.dataset_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return dataset_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void AnnotationSet::set_allocated_dataset_id(::std::string* dataset_id) { if (dataset_id != NULL) { } else { } dataset_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), dataset_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.AnnotationSet.dataset_id) } inline void AnnotationSet::unsafe_arena_set_allocated_dataset_id( ::std::string* dataset_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (dataset_id != NULL) { } else { } dataset_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), dataset_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.AnnotationSet.dataset_id) } // optional string reference_set_id = 3; inline void AnnotationSet::clear_reference_set_id() { reference_set_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& AnnotationSet::reference_set_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.AnnotationSet.reference_set_id) return reference_set_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void AnnotationSet::set_reference_set_id(const ::std::string& value) { reference_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.AnnotationSet.reference_set_id) } inline void AnnotationSet::set_reference_set_id(const char* value) { reference_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.AnnotationSet.reference_set_id) } inline void AnnotationSet::set_reference_set_id(const char* value, size_t size) { reference_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.AnnotationSet.reference_set_id) } inline ::std::string* AnnotationSet::mutable_reference_set_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.AnnotationSet.reference_set_id) return reference_set_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::release_reference_set_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.AnnotationSet.reference_set_id) return reference_set_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::unsafe_arena_release_reference_set_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.AnnotationSet.reference_set_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return reference_set_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void AnnotationSet::set_allocated_reference_set_id(::std::string* reference_set_id) { if (reference_set_id != NULL) { } else { } reference_set_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.AnnotationSet.reference_set_id) } inline void AnnotationSet::unsafe_arena_set_allocated_reference_set_id( ::std::string* reference_set_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (reference_set_id != NULL) { } else { } reference_set_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.AnnotationSet.reference_set_id) } // optional string name = 4; inline void AnnotationSet::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& AnnotationSet::name() const { // @@protoc_insertion_point(field_get:google.genomics.v1.AnnotationSet.name) return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void AnnotationSet::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.AnnotationSet.name) } inline void AnnotationSet::set_name(const char* value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.AnnotationSet.name) } inline void AnnotationSet::set_name(const char* value, size_t size) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.AnnotationSet.name) } inline ::std::string* AnnotationSet::mutable_name() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.AnnotationSet.name) return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::release_name() { // @@protoc_insertion_point(field_release:google.genomics.v1.AnnotationSet.name) return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.AnnotationSet.name) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void AnnotationSet::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.AnnotationSet.name) } inline void AnnotationSet::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (name != NULL) { } else { } name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.AnnotationSet.name) } // optional string source_uri = 5; inline void AnnotationSet::clear_source_uri() { source_uri_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& AnnotationSet::source_uri() const { // @@protoc_insertion_point(field_get:google.genomics.v1.AnnotationSet.source_uri) return source_uri_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void AnnotationSet::set_source_uri(const ::std::string& value) { source_uri_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.AnnotationSet.source_uri) } inline void AnnotationSet::set_source_uri(const char* value) { source_uri_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.AnnotationSet.source_uri) } inline void AnnotationSet::set_source_uri(const char* value, size_t size) { source_uri_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.AnnotationSet.source_uri) } inline ::std::string* AnnotationSet::mutable_source_uri() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.AnnotationSet.source_uri) return source_uri_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::release_source_uri() { // @@protoc_insertion_point(field_release:google.genomics.v1.AnnotationSet.source_uri) return source_uri_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* AnnotationSet::unsafe_arena_release_source_uri() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.AnnotationSet.source_uri) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return source_uri_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void AnnotationSet::set_allocated_source_uri(::std::string* source_uri) { if (source_uri != NULL) { } else { } source_uri_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_uri, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.AnnotationSet.source_uri) } inline void AnnotationSet::unsafe_arena_set_allocated_source_uri( ::std::string* source_uri) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (source_uri != NULL) { } else { } source_uri_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_uri, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.AnnotationSet.source_uri) } // optional .google.genomics.v1.AnnotationType type = 6; inline void AnnotationSet::clear_type() { type_ = 0; } inline ::google::genomics::v1::AnnotationType AnnotationSet::type() const { // @@protoc_insertion_point(field_get:google.genomics.v1.AnnotationSet.type) return static_cast< ::google::genomics::v1::AnnotationType >(type_); } inline void AnnotationSet::set_type(::google::genomics::v1::AnnotationType value) { type_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.AnnotationSet.type) } // map<string, .google.protobuf.ListValue> info = 17; inline int AnnotationSet::info_size() const { return info_.size(); } inline void AnnotationSet::clear_info() { info_.Clear(); } inline const ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >& AnnotationSet::info() const { // @@protoc_insertion_point(field_map:google.genomics.v1.AnnotationSet.info) return info_.GetMap(); } inline ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >* AnnotationSet::mutable_info() { // @@protoc_insertion_point(field_mutable_map:google.genomics.v1.AnnotationSet.info) return info_.MutableMap(); } inline const AnnotationSet* AnnotationSet::internal_default_instance() { return &AnnotationSet_default_instance_.get(); } // ------------------------------------------------------------------- // Annotation // optional string id = 1; inline void Annotation::clear_id() { id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Annotation::id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.id) return id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Annotation::set_id(const ::std::string& value) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.id) } inline void Annotation::set_id(const char* value) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.Annotation.id) } inline void Annotation::set_id(const char* value, size_t size) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.Annotation.id) } inline ::std::string* Annotation::mutable_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.Annotation.id) return id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::release_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.Annotation.id) return id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::unsafe_arena_release_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Annotation.id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void Annotation::set_allocated_id(::std::string* id) { if (id != NULL) { } else { } id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Annotation.id) } inline void Annotation::unsafe_arena_set_allocated_id( ::std::string* id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (id != NULL) { } else { } id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Annotation.id) } // optional string annotation_set_id = 2; inline void Annotation::clear_annotation_set_id() { annotation_set_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Annotation::annotation_set_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.annotation_set_id) return annotation_set_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Annotation::set_annotation_set_id(const ::std::string& value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.annotation_set_id) } inline void Annotation::set_annotation_set_id(const char* value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.Annotation.annotation_set_id) } inline void Annotation::set_annotation_set_id(const char* value, size_t size) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.Annotation.annotation_set_id) } inline ::std::string* Annotation::mutable_annotation_set_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.Annotation.annotation_set_id) return annotation_set_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::release_annotation_set_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.Annotation.annotation_set_id) return annotation_set_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::unsafe_arena_release_annotation_set_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Annotation.annotation_set_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return annotation_set_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void Annotation::set_allocated_annotation_set_id(::std::string* annotation_set_id) { if (annotation_set_id != NULL) { } else { } annotation_set_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Annotation.annotation_set_id) } inline void Annotation::unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (annotation_set_id != NULL) { } else { } annotation_set_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Annotation.annotation_set_id) } // optional string name = 3; inline void Annotation::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Annotation::name() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.name) return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Annotation::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.name) } inline void Annotation::set_name(const char* value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.Annotation.name) } inline void Annotation::set_name(const char* value, size_t size) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.Annotation.name) } inline ::std::string* Annotation::mutable_name() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.Annotation.name) return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::release_name() { // @@protoc_insertion_point(field_release:google.genomics.v1.Annotation.name) return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Annotation.name) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void Annotation::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Annotation.name) } inline void Annotation::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (name != NULL) { } else { } name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Annotation.name) } // optional string reference_id = 4; inline void Annotation::clear_reference_id() { reference_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Annotation::reference_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.reference_id) return reference_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Annotation::set_reference_id(const ::std::string& value) { reference_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.reference_id) } inline void Annotation::set_reference_id(const char* value) { reference_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.Annotation.reference_id) } inline void Annotation::set_reference_id(const char* value, size_t size) { reference_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.Annotation.reference_id) } inline ::std::string* Annotation::mutable_reference_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.Annotation.reference_id) return reference_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::release_reference_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.Annotation.reference_id) return reference_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::unsafe_arena_release_reference_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Annotation.reference_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return reference_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void Annotation::set_allocated_reference_id(::std::string* reference_id) { if (reference_id != NULL) { } else { } reference_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Annotation.reference_id) } inline void Annotation::unsafe_arena_set_allocated_reference_id( ::std::string* reference_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (reference_id != NULL) { } else { } reference_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Annotation.reference_id) } // optional string reference_name = 5; inline void Annotation::clear_reference_name() { reference_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Annotation::reference_name() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.reference_name) return reference_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Annotation::set_reference_name(const ::std::string& value) { reference_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.reference_name) } inline void Annotation::set_reference_name(const char* value) { reference_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.Annotation.reference_name) } inline void Annotation::set_reference_name(const char* value, size_t size) { reference_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.Annotation.reference_name) } inline ::std::string* Annotation::mutable_reference_name() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.Annotation.reference_name) return reference_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::release_reference_name() { // @@protoc_insertion_point(field_release:google.genomics.v1.Annotation.reference_name) return reference_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Annotation::unsafe_arena_release_reference_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Annotation.reference_name) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return reference_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void Annotation::set_allocated_reference_name(::std::string* reference_name) { if (reference_name != NULL) { } else { } reference_name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Annotation.reference_name) } inline void Annotation::unsafe_arena_set_allocated_reference_name( ::std::string* reference_name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (reference_name != NULL) { } else { } reference_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Annotation.reference_name) } // optional int64 start = 6; inline void Annotation::clear_start() { start_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 Annotation::start() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.start) return start_; } inline void Annotation::set_start(::google::protobuf::int64 value) { start_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.start) } // optional int64 end = 7; inline void Annotation::clear_end() { end_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 Annotation::end() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.end) return end_; } inline void Annotation::set_end(::google::protobuf::int64 value) { end_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.end) } // optional bool reverse_strand = 8; inline void Annotation::clear_reverse_strand() { reverse_strand_ = false; } inline bool Annotation::reverse_strand() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.reverse_strand) return reverse_strand_; } inline void Annotation::set_reverse_strand(bool value) { reverse_strand_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.reverse_strand) } // optional .google.genomics.v1.AnnotationType type = 9; inline void Annotation::clear_type() { type_ = 0; } inline ::google::genomics::v1::AnnotationType Annotation::type() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.type) return static_cast< ::google::genomics::v1::AnnotationType >(type_); } inline void Annotation::set_type(::google::genomics::v1::AnnotationType value) { type_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Annotation.type) } // optional .google.genomics.v1.VariantAnnotation variant = 10; inline bool Annotation::has_variant() const { return value_case() == kVariant; } inline void Annotation::set_has_variant() { _oneof_case_[0] = kVariant; } inline void Annotation::clear_variant() { if (has_variant()) { if (GetArenaNoVirtual() == NULL) { delete value_.variant_; } clear_has_value(); } } inline const ::google::genomics::v1::VariantAnnotation& Annotation::variant() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.variant) return has_variant() ? *value_.variant_ : ::google::genomics::v1::VariantAnnotation::default_instance(); } inline ::google::genomics::v1::VariantAnnotation* Annotation::mutable_variant() { if (!has_variant()) { clear_value(); set_has_variant(); value_.variant_ = ::google::protobuf::Arena::CreateMessage< ::google::genomics::v1::VariantAnnotation >( GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.Annotation.variant) return value_.variant_; } inline ::google::genomics::v1::VariantAnnotation* Annotation::release_variant() { // @@protoc_insertion_point(field_release:google.genomics.v1.Annotation.variant) if (has_variant()) { clear_has_value(); if (GetArenaNoVirtual() != NULL) { ::google::genomics::v1::VariantAnnotation* temp = new ::google::genomics::v1::VariantAnnotation(*value_.variant_); value_.variant_ = NULL; return temp; } else { ::google::genomics::v1::VariantAnnotation* temp = value_.variant_; value_.variant_ = NULL; return temp; } } else { return NULL; } } inline void Annotation::set_allocated_variant(::google::genomics::v1::VariantAnnotation* variant) { clear_value(); if (variant) { if (GetArenaNoVirtual() != NULL && ::google::protobuf::Arena::GetArena(variant) == NULL) { GetArenaNoVirtual()->Own(variant); } else if (GetArenaNoVirtual() != ::google::protobuf::Arena::GetArena(variant)) { ::google::genomics::v1::VariantAnnotation* new_variant = ::google::protobuf::Arena::CreateMessage< ::google::genomics::v1::VariantAnnotation >( GetArenaNoVirtual()); new_variant->CopyFrom(*variant); variant = new_variant; } set_has_variant(); value_.variant_ = variant; } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Annotation.variant) } inline ::google::genomics::v1::VariantAnnotation* Annotation::unsafe_arena_release_variant() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Annotation.variant) if (has_variant()) { clear_has_value(); ::google::genomics::v1::VariantAnnotation* temp = value_.variant_; value_.variant_ = NULL; return temp; } else { return NULL; } } inline void Annotation::unsafe_arena_set_allocated_variant(::google::genomics::v1::VariantAnnotation* variant) { clear_value(); if (variant) { set_has_variant(); value_.variant_ = variant; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Annotation.variant) } // optional .google.genomics.v1.Transcript transcript = 11; inline bool Annotation::has_transcript() const { return value_case() == kTranscript; } inline void Annotation::set_has_transcript() { _oneof_case_[0] = kTranscript; } inline void Annotation::clear_transcript() { if (has_transcript()) { if (GetArenaNoVirtual() == NULL) { delete value_.transcript_; } clear_has_value(); } } inline const ::google::genomics::v1::Transcript& Annotation::transcript() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Annotation.transcript) return has_transcript() ? *value_.transcript_ : ::google::genomics::v1::Transcript::default_instance(); } inline ::google::genomics::v1::Transcript* Annotation::mutable_transcript() { if (!has_transcript()) { clear_value(); set_has_transcript(); value_.transcript_ = ::google::protobuf::Arena::CreateMessage< ::google::genomics::v1::Transcript >( GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.Annotation.transcript) return value_.transcript_; } inline ::google::genomics::v1::Transcript* Annotation::release_transcript() { // @@protoc_insertion_point(field_release:google.genomics.v1.Annotation.transcript) if (has_transcript()) { clear_has_value(); if (GetArenaNoVirtual() != NULL) { ::google::genomics::v1::Transcript* temp = new ::google::genomics::v1::Transcript(*value_.transcript_); value_.transcript_ = NULL; return temp; } else { ::google::genomics::v1::Transcript* temp = value_.transcript_; value_.transcript_ = NULL; return temp; } } else { return NULL; } } inline void Annotation::set_allocated_transcript(::google::genomics::v1::Transcript* transcript) { clear_value(); if (transcript) { if (GetArenaNoVirtual() != NULL && ::google::protobuf::Arena::GetArena(transcript) == NULL) { GetArenaNoVirtual()->Own(transcript); } else if (GetArenaNoVirtual() != ::google::protobuf::Arena::GetArena(transcript)) { ::google::genomics::v1::Transcript* new_transcript = ::google::protobuf::Arena::CreateMessage< ::google::genomics::v1::Transcript >( GetArenaNoVirtual()); new_transcript->CopyFrom(*transcript); transcript = new_transcript; } set_has_transcript(); value_.transcript_ = transcript; } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Annotation.transcript) } inline ::google::genomics::v1::Transcript* Annotation::unsafe_arena_release_transcript() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Annotation.transcript) if (has_transcript()) { clear_has_value(); ::google::genomics::v1::Transcript* temp = value_.transcript_; value_.transcript_ = NULL; return temp; } else { return NULL; } } inline void Annotation::unsafe_arena_set_allocated_transcript(::google::genomics::v1::Transcript* transcript) { clear_value(); if (transcript) { set_has_transcript(); value_.transcript_ = transcript; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Annotation.transcript) } // map<string, .google.protobuf.ListValue> info = 12; inline int Annotation::info_size() const { return info_.size(); } inline void Annotation::clear_info() { info_.Clear(); } inline const ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >& Annotation::info() const { // @@protoc_insertion_point(field_map:google.genomics.v1.Annotation.info) return info_.GetMap(); } inline ::google::protobuf::Map< ::std::string, ::google::protobuf::ListValue >* Annotation::mutable_info() { // @@protoc_insertion_point(field_mutable_map:google.genomics.v1.Annotation.info) return info_.MutableMap(); } inline bool Annotation::has_value() const { return value_case() != VALUE_NOT_SET; } inline void Annotation::clear_has_value() { _oneof_case_[0] = VALUE_NOT_SET; } inline Annotation::ValueCase Annotation::value_case() const { return Annotation::ValueCase(_oneof_case_[0]); } inline const Annotation* Annotation::internal_default_instance() { return &Annotation_default_instance_.get(); } // ------------------------------------------------------------------- // VariantAnnotation_ClinicalCondition // repeated string names = 1; inline int VariantAnnotation_ClinicalCondition::names_size() const { return names_.size(); } inline void VariantAnnotation_ClinicalCondition::clear_names() { names_.Clear(); } inline const ::std::string& VariantAnnotation_ClinicalCondition::names(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) return names_.Get(index); } inline ::std::string* VariantAnnotation_ClinicalCondition::mutable_names(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) return names_.Mutable(index); } inline void VariantAnnotation_ClinicalCondition::set_names(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) names_.Mutable(index)->assign(value); } inline void VariantAnnotation_ClinicalCondition::set_names(int index, const char* value) { names_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) } inline void VariantAnnotation_ClinicalCondition::set_names(int index, const char* value, size_t size) { names_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) } inline ::std::string* VariantAnnotation_ClinicalCondition::add_names() { // @@protoc_insertion_point(field_add_mutable:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) return names_.Add(); } inline void VariantAnnotation_ClinicalCondition::add_names(const ::std::string& value) { names_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) } inline void VariantAnnotation_ClinicalCondition::add_names(const char* value) { names_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) } inline void VariantAnnotation_ClinicalCondition::add_names(const char* value, size_t size) { names_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& VariantAnnotation_ClinicalCondition::names() const { // @@protoc_insertion_point(field_list:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) return names_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* VariantAnnotation_ClinicalCondition::mutable_names() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.VariantAnnotation.ClinicalCondition.names) return &names_; } // repeated .google.genomics.v1.ExternalId external_ids = 2; inline int VariantAnnotation_ClinicalCondition::external_ids_size() const { return external_ids_.size(); } inline void VariantAnnotation_ClinicalCondition::clear_external_ids() { external_ids_.Clear(); } inline const ::google::genomics::v1::ExternalId& VariantAnnotation_ClinicalCondition::external_ids(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.ClinicalCondition.external_ids) return external_ids_.Get(index); } inline ::google::genomics::v1::ExternalId* VariantAnnotation_ClinicalCondition::mutable_external_ids(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.ClinicalCondition.external_ids) return external_ids_.Mutable(index); } inline ::google::genomics::v1::ExternalId* VariantAnnotation_ClinicalCondition::add_external_ids() { // @@protoc_insertion_point(field_add:google.genomics.v1.VariantAnnotation.ClinicalCondition.external_ids) return external_ids_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::ExternalId >* VariantAnnotation_ClinicalCondition::mutable_external_ids() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.VariantAnnotation.ClinicalCondition.external_ids) return &external_ids_; } inline const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::ExternalId >& VariantAnnotation_ClinicalCondition::external_ids() const { // @@protoc_insertion_point(field_list:google.genomics.v1.VariantAnnotation.ClinicalCondition.external_ids) return external_ids_; } // optional string concept_id = 3; inline void VariantAnnotation_ClinicalCondition::clear_concept_id() { concept_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& VariantAnnotation_ClinicalCondition::concept_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) return concept_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void VariantAnnotation_ClinicalCondition::set_concept_id(const ::std::string& value) { concept_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) } inline void VariantAnnotation_ClinicalCondition::set_concept_id(const char* value) { concept_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) } inline void VariantAnnotation_ClinicalCondition::set_concept_id(const char* value, size_t size) { concept_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) } inline ::std::string* VariantAnnotation_ClinicalCondition::mutable_concept_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) return concept_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation_ClinicalCondition::release_concept_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) return concept_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation_ClinicalCondition::unsafe_arena_release_concept_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return concept_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void VariantAnnotation_ClinicalCondition::set_allocated_concept_id(::std::string* concept_id) { if (concept_id != NULL) { } else { } concept_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), concept_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) } inline void VariantAnnotation_ClinicalCondition::unsafe_arena_set_allocated_concept_id( ::std::string* concept_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (concept_id != NULL) { } else { } concept_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), concept_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.VariantAnnotation.ClinicalCondition.concept_id) } // optional string omim_id = 4; inline void VariantAnnotation_ClinicalCondition::clear_omim_id() { omim_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& VariantAnnotation_ClinicalCondition::omim_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) return omim_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void VariantAnnotation_ClinicalCondition::set_omim_id(const ::std::string& value) { omim_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) } inline void VariantAnnotation_ClinicalCondition::set_omim_id(const char* value) { omim_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) } inline void VariantAnnotation_ClinicalCondition::set_omim_id(const char* value, size_t size) { omim_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) } inline ::std::string* VariantAnnotation_ClinicalCondition::mutable_omim_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) return omim_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation_ClinicalCondition::release_omim_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) return omim_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation_ClinicalCondition::unsafe_arena_release_omim_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return omim_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void VariantAnnotation_ClinicalCondition::set_allocated_omim_id(::std::string* omim_id) { if (omim_id != NULL) { } else { } omim_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), omim_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) } inline void VariantAnnotation_ClinicalCondition::unsafe_arena_set_allocated_omim_id( ::std::string* omim_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (omim_id != NULL) { } else { } omim_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), omim_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.VariantAnnotation.ClinicalCondition.omim_id) } inline const VariantAnnotation_ClinicalCondition* VariantAnnotation_ClinicalCondition::internal_default_instance() { return &VariantAnnotation_ClinicalCondition_default_instance_.get(); } // ------------------------------------------------------------------- // VariantAnnotation // optional .google.genomics.v1.VariantAnnotation.Type type = 1; inline void VariantAnnotation::clear_type() { type_ = 0; } inline ::google::genomics::v1::VariantAnnotation_Type VariantAnnotation::type() const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.type) return static_cast< ::google::genomics::v1::VariantAnnotation_Type >(type_); } inline void VariantAnnotation::set_type(::google::genomics::v1::VariantAnnotation_Type value) { type_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.type) } // optional .google.genomics.v1.VariantAnnotation.Effect effect = 2; inline void VariantAnnotation::clear_effect() { effect_ = 0; } inline ::google::genomics::v1::VariantAnnotation_Effect VariantAnnotation::effect() const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.effect) return static_cast< ::google::genomics::v1::VariantAnnotation_Effect >(effect_); } inline void VariantAnnotation::set_effect(::google::genomics::v1::VariantAnnotation_Effect value) { effect_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.effect) } // optional string alternate_bases = 3; inline void VariantAnnotation::clear_alternate_bases() { alternate_bases_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& VariantAnnotation::alternate_bases() const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.alternate_bases) return alternate_bases_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void VariantAnnotation::set_alternate_bases(const ::std::string& value) { alternate_bases_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.alternate_bases) } inline void VariantAnnotation::set_alternate_bases(const char* value) { alternate_bases_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.VariantAnnotation.alternate_bases) } inline void VariantAnnotation::set_alternate_bases(const char* value, size_t size) { alternate_bases_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.VariantAnnotation.alternate_bases) } inline ::std::string* VariantAnnotation::mutable_alternate_bases() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.alternate_bases) return alternate_bases_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation::release_alternate_bases() { // @@protoc_insertion_point(field_release:google.genomics.v1.VariantAnnotation.alternate_bases) return alternate_bases_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation::unsafe_arena_release_alternate_bases() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.VariantAnnotation.alternate_bases) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return alternate_bases_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void VariantAnnotation::set_allocated_alternate_bases(::std::string* alternate_bases) { if (alternate_bases != NULL) { } else { } alternate_bases_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), alternate_bases, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.VariantAnnotation.alternate_bases) } inline void VariantAnnotation::unsafe_arena_set_allocated_alternate_bases( ::std::string* alternate_bases) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (alternate_bases != NULL) { } else { } alternate_bases_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), alternate_bases, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.VariantAnnotation.alternate_bases) } // optional string gene_id = 4; inline void VariantAnnotation::clear_gene_id() { gene_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& VariantAnnotation::gene_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.gene_id) return gene_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void VariantAnnotation::set_gene_id(const ::std::string& value) { gene_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.gene_id) } inline void VariantAnnotation::set_gene_id(const char* value) { gene_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.VariantAnnotation.gene_id) } inline void VariantAnnotation::set_gene_id(const char* value, size_t size) { gene_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.VariantAnnotation.gene_id) } inline ::std::string* VariantAnnotation::mutable_gene_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.gene_id) return gene_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation::release_gene_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.VariantAnnotation.gene_id) return gene_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* VariantAnnotation::unsafe_arena_release_gene_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.VariantAnnotation.gene_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return gene_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void VariantAnnotation::set_allocated_gene_id(::std::string* gene_id) { if (gene_id != NULL) { } else { } gene_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), gene_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.VariantAnnotation.gene_id) } inline void VariantAnnotation::unsafe_arena_set_allocated_gene_id( ::std::string* gene_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (gene_id != NULL) { } else { } gene_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), gene_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.VariantAnnotation.gene_id) } // repeated string transcript_ids = 5; inline int VariantAnnotation::transcript_ids_size() const { return transcript_ids_.size(); } inline void VariantAnnotation::clear_transcript_ids() { transcript_ids_.Clear(); } inline const ::std::string& VariantAnnotation::transcript_ids(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.transcript_ids) return transcript_ids_.Get(index); } inline ::std::string* VariantAnnotation::mutable_transcript_ids(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.transcript_ids) return transcript_ids_.Mutable(index); } inline void VariantAnnotation::set_transcript_ids(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.transcript_ids) transcript_ids_.Mutable(index)->assign(value); } inline void VariantAnnotation::set_transcript_ids(int index, const char* value) { transcript_ids_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.genomics.v1.VariantAnnotation.transcript_ids) } inline void VariantAnnotation::set_transcript_ids(int index, const char* value, size_t size) { transcript_ids_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.VariantAnnotation.transcript_ids) } inline ::std::string* VariantAnnotation::add_transcript_ids() { // @@protoc_insertion_point(field_add_mutable:google.genomics.v1.VariantAnnotation.transcript_ids) return transcript_ids_.Add(); } inline void VariantAnnotation::add_transcript_ids(const ::std::string& value) { transcript_ids_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.genomics.v1.VariantAnnotation.transcript_ids) } inline void VariantAnnotation::add_transcript_ids(const char* value) { transcript_ids_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.genomics.v1.VariantAnnotation.transcript_ids) } inline void VariantAnnotation::add_transcript_ids(const char* value, size_t size) { transcript_ids_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.genomics.v1.VariantAnnotation.transcript_ids) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& VariantAnnotation::transcript_ids() const { // @@protoc_insertion_point(field_list:google.genomics.v1.VariantAnnotation.transcript_ids) return transcript_ids_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* VariantAnnotation::mutable_transcript_ids() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.VariantAnnotation.transcript_ids) return &transcript_ids_; } // repeated .google.genomics.v1.VariantAnnotation.ClinicalCondition conditions = 6; inline int VariantAnnotation::conditions_size() const { return conditions_.size(); } inline void VariantAnnotation::clear_conditions() { conditions_.Clear(); } inline const ::google::genomics::v1::VariantAnnotation_ClinicalCondition& VariantAnnotation::conditions(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.conditions) return conditions_.Get(index); } inline ::google::genomics::v1::VariantAnnotation_ClinicalCondition* VariantAnnotation::mutable_conditions(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.VariantAnnotation.conditions) return conditions_.Mutable(index); } inline ::google::genomics::v1::VariantAnnotation_ClinicalCondition* VariantAnnotation::add_conditions() { // @@protoc_insertion_point(field_add:google.genomics.v1.VariantAnnotation.conditions) return conditions_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::VariantAnnotation_ClinicalCondition >* VariantAnnotation::mutable_conditions() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.VariantAnnotation.conditions) return &conditions_; } inline const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::VariantAnnotation_ClinicalCondition >& VariantAnnotation::conditions() const { // @@protoc_insertion_point(field_list:google.genomics.v1.VariantAnnotation.conditions) return conditions_; } // optional .google.genomics.v1.VariantAnnotation.ClinicalSignificance clinical_significance = 7; inline void VariantAnnotation::clear_clinical_significance() { clinical_significance_ = 0; } inline ::google::genomics::v1::VariantAnnotation_ClinicalSignificance VariantAnnotation::clinical_significance() const { // @@protoc_insertion_point(field_get:google.genomics.v1.VariantAnnotation.clinical_significance) return static_cast< ::google::genomics::v1::VariantAnnotation_ClinicalSignificance >(clinical_significance_); } inline void VariantAnnotation::set_clinical_significance(::google::genomics::v1::VariantAnnotation_ClinicalSignificance value) { clinical_significance_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.VariantAnnotation.clinical_significance) } inline const VariantAnnotation* VariantAnnotation::internal_default_instance() { return &VariantAnnotation_default_instance_.get(); } // ------------------------------------------------------------------- // Transcript_Exon // optional int64 start = 1; inline void Transcript_Exon::clear_start() { start_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 Transcript_Exon::start() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.Exon.start) return start_; } inline void Transcript_Exon::set_start(::google::protobuf::int64 value) { start_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Transcript.Exon.start) } // optional int64 end = 2; inline void Transcript_Exon::clear_end() { end_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 Transcript_Exon::end() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.Exon.end) return end_; } inline void Transcript_Exon::set_end(::google::protobuf::int64 value) { end_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Transcript.Exon.end) } // optional .google.protobuf.Int32Value frame = 3; inline bool Transcript_Exon::has_frame() const { return this != internal_default_instance() && frame_ != NULL; } inline void Transcript_Exon::clear_frame() { if (GetArenaNoVirtual() == NULL && frame_ != NULL) delete frame_; frame_ = NULL; } inline const ::google::protobuf::Int32Value& Transcript_Exon::frame() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.Exon.frame) return frame_ != NULL ? *frame_ : *::google::protobuf::Int32Value::internal_default_instance(); } inline ::google::protobuf::Int32Value* Transcript_Exon::mutable_frame() { if (frame_ == NULL) { _slow_mutable_frame(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.Transcript.Exon.frame) return frame_; } inline ::google::protobuf::Int32Value* Transcript_Exon::release_frame() { // @@protoc_insertion_point(field_release:google.genomics.v1.Transcript.Exon.frame) if (GetArenaNoVirtual() != NULL) { return _slow_release_frame(); } else { ::google::protobuf::Int32Value* temp = frame_; frame_ = NULL; return temp; } } inline void Transcript_Exon::set_allocated_frame(::google::protobuf::Int32Value* frame) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete frame_; } if (frame != NULL) { _slow_set_allocated_frame(message_arena, &frame); } frame_ = frame; if (frame) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Transcript.Exon.frame) } inline const Transcript_Exon* Transcript_Exon::internal_default_instance() { return &Transcript_Exon_default_instance_.get(); } // ------------------------------------------------------------------- // Transcript_CodingSequence // optional int64 start = 1; inline void Transcript_CodingSequence::clear_start() { start_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 Transcript_CodingSequence::start() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.CodingSequence.start) return start_; } inline void Transcript_CodingSequence::set_start(::google::protobuf::int64 value) { start_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Transcript.CodingSequence.start) } // optional int64 end = 2; inline void Transcript_CodingSequence::clear_end() { end_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 Transcript_CodingSequence::end() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.CodingSequence.end) return end_; } inline void Transcript_CodingSequence::set_end(::google::protobuf::int64 value) { end_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.Transcript.CodingSequence.end) } inline const Transcript_CodingSequence* Transcript_CodingSequence::internal_default_instance() { return &Transcript_CodingSequence_default_instance_.get(); } // ------------------------------------------------------------------- // Transcript // optional string gene_id = 1; inline void Transcript::clear_gene_id() { gene_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Transcript::gene_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.gene_id) return gene_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Transcript::set_gene_id(const ::std::string& value) { gene_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.Transcript.gene_id) } inline void Transcript::set_gene_id(const char* value) { gene_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.Transcript.gene_id) } inline void Transcript::set_gene_id(const char* value, size_t size) { gene_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.Transcript.gene_id) } inline ::std::string* Transcript::mutable_gene_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.Transcript.gene_id) return gene_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Transcript::release_gene_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.Transcript.gene_id) return gene_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* Transcript::unsafe_arena_release_gene_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.Transcript.gene_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return gene_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void Transcript::set_allocated_gene_id(::std::string* gene_id) { if (gene_id != NULL) { } else { } gene_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), gene_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Transcript.gene_id) } inline void Transcript::unsafe_arena_set_allocated_gene_id( ::std::string* gene_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (gene_id != NULL) { } else { } gene_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), gene_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.Transcript.gene_id) } // repeated .google.genomics.v1.Transcript.Exon exons = 2; inline int Transcript::exons_size() const { return exons_.size(); } inline void Transcript::clear_exons() { exons_.Clear(); } inline const ::google::genomics::v1::Transcript_Exon& Transcript::exons(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.exons) return exons_.Get(index); } inline ::google::genomics::v1::Transcript_Exon* Transcript::mutable_exons(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.Transcript.exons) return exons_.Mutable(index); } inline ::google::genomics::v1::Transcript_Exon* Transcript::add_exons() { // @@protoc_insertion_point(field_add:google.genomics.v1.Transcript.exons) return exons_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Transcript_Exon >* Transcript::mutable_exons() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.Transcript.exons) return &exons_; } inline const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Transcript_Exon >& Transcript::exons() const { // @@protoc_insertion_point(field_list:google.genomics.v1.Transcript.exons) return exons_; } // optional .google.genomics.v1.Transcript.CodingSequence coding_sequence = 3; inline bool Transcript::has_coding_sequence() const { return this != internal_default_instance() && coding_sequence_ != NULL; } inline void Transcript::clear_coding_sequence() { if (GetArenaNoVirtual() == NULL && coding_sequence_ != NULL) delete coding_sequence_; coding_sequence_ = NULL; } inline const ::google::genomics::v1::Transcript_CodingSequence& Transcript::coding_sequence() const { // @@protoc_insertion_point(field_get:google.genomics.v1.Transcript.coding_sequence) return coding_sequence_ != NULL ? *coding_sequence_ : *::google::genomics::v1::Transcript_CodingSequence::internal_default_instance(); } inline ::google::genomics::v1::Transcript_CodingSequence* Transcript::mutable_coding_sequence() { if (coding_sequence_ == NULL) { _slow_mutable_coding_sequence(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.Transcript.coding_sequence) return coding_sequence_; } inline ::google::genomics::v1::Transcript_CodingSequence* Transcript::release_coding_sequence() { // @@protoc_insertion_point(field_release:google.genomics.v1.Transcript.coding_sequence) if (GetArenaNoVirtual() != NULL) { return _slow_release_coding_sequence(); } else { ::google::genomics::v1::Transcript_CodingSequence* temp = coding_sequence_; coding_sequence_ = NULL; return temp; } } inline void Transcript::set_allocated_coding_sequence(::google::genomics::v1::Transcript_CodingSequence* coding_sequence) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete coding_sequence_; } if (coding_sequence != NULL) { _slow_set_allocated_coding_sequence(message_arena, &coding_sequence); } coding_sequence_ = coding_sequence; if (coding_sequence) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.Transcript.coding_sequence) } inline const Transcript* Transcript::internal_default_instance() { return &Transcript_default_instance_.get(); } // ------------------------------------------------------------------- // ExternalId // optional string source_name = 1; inline void ExternalId::clear_source_name() { source_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& ExternalId::source_name() const { // @@protoc_insertion_point(field_get:google.genomics.v1.ExternalId.source_name) return source_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ExternalId::set_source_name(const ::std::string& value) { source_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.ExternalId.source_name) } inline void ExternalId::set_source_name(const char* value) { source_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.ExternalId.source_name) } inline void ExternalId::set_source_name(const char* value, size_t size) { source_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.ExternalId.source_name) } inline ::std::string* ExternalId::mutable_source_name() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.ExternalId.source_name) return source_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* ExternalId::release_source_name() { // @@protoc_insertion_point(field_release:google.genomics.v1.ExternalId.source_name) return source_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* ExternalId::unsafe_arena_release_source_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.ExternalId.source_name) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return source_name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void ExternalId::set_allocated_source_name(::std::string* source_name) { if (source_name != NULL) { } else { } source_name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.ExternalId.source_name) } inline void ExternalId::unsafe_arena_set_allocated_source_name( ::std::string* source_name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (source_name != NULL) { } else { } source_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.ExternalId.source_name) } // optional string id = 2; inline void ExternalId::clear_id() { id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& ExternalId::id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.ExternalId.id) return id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ExternalId::set_id(const ::std::string& value) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.ExternalId.id) } inline void ExternalId::set_id(const char* value) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.ExternalId.id) } inline void ExternalId::set_id(const char* value, size_t size) { id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.ExternalId.id) } inline ::std::string* ExternalId::mutable_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.ExternalId.id) return id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* ExternalId::release_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.ExternalId.id) return id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* ExternalId::unsafe_arena_release_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.ExternalId.id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void ExternalId::set_allocated_id(::std::string* id) { if (id != NULL) { } else { } id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.ExternalId.id) } inline void ExternalId::unsafe_arena_set_allocated_id( ::std::string* id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (id != NULL) { } else { } id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.ExternalId.id) } inline const ExternalId* ExternalId::internal_default_instance() { return &ExternalId_default_instance_.get(); } // ------------------------------------------------------------------- // CreateAnnotationSetRequest // optional .google.genomics.v1.AnnotationSet annotation_set = 1; inline bool CreateAnnotationSetRequest::has_annotation_set() const { return this != internal_default_instance() && annotation_set_ != NULL; } inline void CreateAnnotationSetRequest::clear_annotation_set() { if (GetArenaNoVirtual() == NULL && annotation_set_ != NULL) delete annotation_set_; annotation_set_ = NULL; } inline const ::google::genomics::v1::AnnotationSet& CreateAnnotationSetRequest::annotation_set() const { // @@protoc_insertion_point(field_get:google.genomics.v1.CreateAnnotationSetRequest.annotation_set) return annotation_set_ != NULL ? *annotation_set_ : *::google::genomics::v1::AnnotationSet::internal_default_instance(); } inline ::google::genomics::v1::AnnotationSet* CreateAnnotationSetRequest::mutable_annotation_set() { if (annotation_set_ == NULL) { _slow_mutable_annotation_set(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.CreateAnnotationSetRequest.annotation_set) return annotation_set_; } inline ::google::genomics::v1::AnnotationSet* CreateAnnotationSetRequest::release_annotation_set() { // @@protoc_insertion_point(field_release:google.genomics.v1.CreateAnnotationSetRequest.annotation_set) if (GetArenaNoVirtual() != NULL) { return _slow_release_annotation_set(); } else { ::google::genomics::v1::AnnotationSet* temp = annotation_set_; annotation_set_ = NULL; return temp; } } inline void CreateAnnotationSetRequest::set_allocated_annotation_set(::google::genomics::v1::AnnotationSet* annotation_set) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete annotation_set_; } if (annotation_set != NULL) { _slow_set_allocated_annotation_set(message_arena, &annotation_set); } annotation_set_ = annotation_set; if (annotation_set) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.CreateAnnotationSetRequest.annotation_set) } inline const CreateAnnotationSetRequest* CreateAnnotationSetRequest::internal_default_instance() { return &CreateAnnotationSetRequest_default_instance_.get(); } // ------------------------------------------------------------------- // GetAnnotationSetRequest // optional string annotation_set_id = 1; inline void GetAnnotationSetRequest::clear_annotation_set_id() { annotation_set_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& GetAnnotationSetRequest::annotation_set_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void GetAnnotationSetRequest::set_annotation_set_id(const ::std::string& value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) } inline void GetAnnotationSetRequest::set_annotation_set_id(const char* value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) } inline void GetAnnotationSetRequest::set_annotation_set_id(const char* value, size_t size) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) } inline ::std::string* GetAnnotationSetRequest::mutable_annotation_set_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* GetAnnotationSetRequest::release_annotation_set_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* GetAnnotationSetRequest::unsafe_arena_release_annotation_set_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return annotation_set_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void GetAnnotationSetRequest::set_allocated_annotation_set_id(::std::string* annotation_set_id) { if (annotation_set_id != NULL) { } else { } annotation_set_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) } inline void GetAnnotationSetRequest::unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (annotation_set_id != NULL) { } else { } annotation_set_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.GetAnnotationSetRequest.annotation_set_id) } inline const GetAnnotationSetRequest* GetAnnotationSetRequest::internal_default_instance() { return &GetAnnotationSetRequest_default_instance_.get(); } // ------------------------------------------------------------------- // UpdateAnnotationSetRequest // optional string annotation_set_id = 1; inline void UpdateAnnotationSetRequest::clear_annotation_set_id() { annotation_set_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& UpdateAnnotationSetRequest::annotation_set_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void UpdateAnnotationSetRequest::set_annotation_set_id(const ::std::string& value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) } inline void UpdateAnnotationSetRequest::set_annotation_set_id(const char* value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) } inline void UpdateAnnotationSetRequest::set_annotation_set_id(const char* value, size_t size) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) } inline ::std::string* UpdateAnnotationSetRequest::mutable_annotation_set_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* UpdateAnnotationSetRequest::release_annotation_set_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* UpdateAnnotationSetRequest::unsafe_arena_release_annotation_set_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return annotation_set_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void UpdateAnnotationSetRequest::set_allocated_annotation_set_id(::std::string* annotation_set_id) { if (annotation_set_id != NULL) { } else { } annotation_set_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) } inline void UpdateAnnotationSetRequest::unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (annotation_set_id != NULL) { } else { } annotation_set_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set_id) } // optional .google.genomics.v1.AnnotationSet annotation_set = 2; inline bool UpdateAnnotationSetRequest::has_annotation_set() const { return this != internal_default_instance() && annotation_set_ != NULL; } inline void UpdateAnnotationSetRequest::clear_annotation_set() { if (GetArenaNoVirtual() == NULL && annotation_set_ != NULL) delete annotation_set_; annotation_set_ = NULL; } inline const ::google::genomics::v1::AnnotationSet& UpdateAnnotationSetRequest::annotation_set() const { // @@protoc_insertion_point(field_get:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set) return annotation_set_ != NULL ? *annotation_set_ : *::google::genomics::v1::AnnotationSet::internal_default_instance(); } inline ::google::genomics::v1::AnnotationSet* UpdateAnnotationSetRequest::mutable_annotation_set() { if (annotation_set_ == NULL) { _slow_mutable_annotation_set(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set) return annotation_set_; } inline ::google::genomics::v1::AnnotationSet* UpdateAnnotationSetRequest::release_annotation_set() { // @@protoc_insertion_point(field_release:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set) if (GetArenaNoVirtual() != NULL) { return _slow_release_annotation_set(); } else { ::google::genomics::v1::AnnotationSet* temp = annotation_set_; annotation_set_ = NULL; return temp; } } inline void UpdateAnnotationSetRequest::set_allocated_annotation_set(::google::genomics::v1::AnnotationSet* annotation_set) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete annotation_set_; } if (annotation_set != NULL) { _slow_set_allocated_annotation_set(message_arena, &annotation_set); } annotation_set_ = annotation_set; if (annotation_set) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.UpdateAnnotationSetRequest.annotation_set) } // optional .google.protobuf.FieldMask update_mask = 3; inline bool UpdateAnnotationSetRequest::has_update_mask() const { return this != internal_default_instance() && update_mask_ != NULL; } inline void UpdateAnnotationSetRequest::clear_update_mask() { if (GetArenaNoVirtual() == NULL && update_mask_ != NULL) delete update_mask_; update_mask_ = NULL; } inline const ::google::protobuf::FieldMask& UpdateAnnotationSetRequest::update_mask() const { // @@protoc_insertion_point(field_get:google.genomics.v1.UpdateAnnotationSetRequest.update_mask) return update_mask_ != NULL ? *update_mask_ : *::google::protobuf::FieldMask::internal_default_instance(); } inline ::google::protobuf::FieldMask* UpdateAnnotationSetRequest::mutable_update_mask() { if (update_mask_ == NULL) { _slow_mutable_update_mask(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.UpdateAnnotationSetRequest.update_mask) return update_mask_; } inline ::google::protobuf::FieldMask* UpdateAnnotationSetRequest::release_update_mask() { // @@protoc_insertion_point(field_release:google.genomics.v1.UpdateAnnotationSetRequest.update_mask) if (GetArenaNoVirtual() != NULL) { return _slow_release_update_mask(); } else { ::google::protobuf::FieldMask* temp = update_mask_; update_mask_ = NULL; return temp; } } inline void UpdateAnnotationSetRequest::set_allocated_update_mask(::google::protobuf::FieldMask* update_mask) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete update_mask_; } if (update_mask != NULL) { if (message_arena != NULL) { message_arena->Own(update_mask); } } update_mask_ = update_mask; if (update_mask) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.UpdateAnnotationSetRequest.update_mask) } inline const UpdateAnnotationSetRequest* UpdateAnnotationSetRequest::internal_default_instance() { return &UpdateAnnotationSetRequest_default_instance_.get(); } // ------------------------------------------------------------------- // DeleteAnnotationSetRequest // optional string annotation_set_id = 1; inline void DeleteAnnotationSetRequest::clear_annotation_set_id() { annotation_set_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& DeleteAnnotationSetRequest::annotation_set_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void DeleteAnnotationSetRequest::set_annotation_set_id(const ::std::string& value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) } inline void DeleteAnnotationSetRequest::set_annotation_set_id(const char* value) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) } inline void DeleteAnnotationSetRequest::set_annotation_set_id(const char* value, size_t size) { annotation_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) } inline ::std::string* DeleteAnnotationSetRequest::mutable_annotation_set_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* DeleteAnnotationSetRequest::release_annotation_set_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) return annotation_set_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* DeleteAnnotationSetRequest::unsafe_arena_release_annotation_set_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return annotation_set_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void DeleteAnnotationSetRequest::set_allocated_annotation_set_id(::std::string* annotation_set_id) { if (annotation_set_id != NULL) { } else { } annotation_set_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) } inline void DeleteAnnotationSetRequest::unsafe_arena_set_allocated_annotation_set_id( ::std::string* annotation_set_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (annotation_set_id != NULL) { } else { } annotation_set_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.DeleteAnnotationSetRequest.annotation_set_id) } inline const DeleteAnnotationSetRequest* DeleteAnnotationSetRequest::internal_default_instance() { return &DeleteAnnotationSetRequest_default_instance_.get(); } // ------------------------------------------------------------------- // SearchAnnotationSetsRequest // repeated string dataset_ids = 1; inline int SearchAnnotationSetsRequest::dataset_ids_size() const { return dataset_ids_.size(); } inline void SearchAnnotationSetsRequest::clear_dataset_ids() { dataset_ids_.Clear(); } inline const ::std::string& SearchAnnotationSetsRequest::dataset_ids(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) return dataset_ids_.Get(index); } inline ::std::string* SearchAnnotationSetsRequest::mutable_dataset_ids(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) return dataset_ids_.Mutable(index); } inline void SearchAnnotationSetsRequest::set_dataset_ids(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) dataset_ids_.Mutable(index)->assign(value); } inline void SearchAnnotationSetsRequest::set_dataset_ids(int index, const char* value) { dataset_ids_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) } inline void SearchAnnotationSetsRequest::set_dataset_ids(int index, const char* value, size_t size) { dataset_ids_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) } inline ::std::string* SearchAnnotationSetsRequest::add_dataset_ids() { // @@protoc_insertion_point(field_add_mutable:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) return dataset_ids_.Add(); } inline void SearchAnnotationSetsRequest::add_dataset_ids(const ::std::string& value) { dataset_ids_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) } inline void SearchAnnotationSetsRequest::add_dataset_ids(const char* value) { dataset_ids_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) } inline void SearchAnnotationSetsRequest::add_dataset_ids(const char* value, size_t size) { dataset_ids_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& SearchAnnotationSetsRequest::dataset_ids() const { // @@protoc_insertion_point(field_list:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) return dataset_ids_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* SearchAnnotationSetsRequest::mutable_dataset_ids() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.SearchAnnotationSetsRequest.dataset_ids) return &dataset_ids_; } // optional string reference_set_id = 2; inline void SearchAnnotationSetsRequest::clear_reference_set_id() { reference_set_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& SearchAnnotationSetsRequest::reference_set_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) return reference_set_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SearchAnnotationSetsRequest::set_reference_set_id(const ::std::string& value) { reference_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) } inline void SearchAnnotationSetsRequest::set_reference_set_id(const char* value) { reference_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) } inline void SearchAnnotationSetsRequest::set_reference_set_id(const char* value, size_t size) { reference_set_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) } inline ::std::string* SearchAnnotationSetsRequest::mutable_reference_set_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) return reference_set_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsRequest::release_reference_set_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) return reference_set_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsRequest::unsafe_arena_release_reference_set_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return reference_set_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SearchAnnotationSetsRequest::set_allocated_reference_set_id(::std::string* reference_set_id) { if (reference_set_id != NULL) { } else { } reference_set_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) } inline void SearchAnnotationSetsRequest::unsafe_arena_set_allocated_reference_set_id( ::std::string* reference_set_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (reference_set_id != NULL) { } else { } reference_set_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_set_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationSetsRequest.reference_set_id) } // optional string name = 3; inline void SearchAnnotationSetsRequest::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& SearchAnnotationSetsRequest::name() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsRequest.name) return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SearchAnnotationSetsRequest::set_name(const ::std::string& value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationSetsRequest.name) } inline void SearchAnnotationSetsRequest::set_name(const char* value) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationSetsRequest.name) } inline void SearchAnnotationSetsRequest::set_name(const char* value, size_t size) { name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationSetsRequest.name) } inline ::std::string* SearchAnnotationSetsRequest::mutable_name() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationSetsRequest.name) return name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsRequest::release_name() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationSetsRequest.name) return name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsRequest::unsafe_arena_release_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationSetsRequest.name) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return name_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SearchAnnotationSetsRequest::set_allocated_name(::std::string* name) { if (name != NULL) { } else { } name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationSetsRequest.name) } inline void SearchAnnotationSetsRequest::unsafe_arena_set_allocated_name( ::std::string* name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (name != NULL) { } else { } name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationSetsRequest.name) } // repeated .google.genomics.v1.AnnotationType types = 4; inline int SearchAnnotationSetsRequest::types_size() const { return types_.size(); } inline void SearchAnnotationSetsRequest::clear_types() { types_.Clear(); } inline ::google::genomics::v1::AnnotationType SearchAnnotationSetsRequest::types(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsRequest.types) return static_cast< ::google::genomics::v1::AnnotationType >(types_.Get(index)); } inline void SearchAnnotationSetsRequest::set_types(int index, ::google::genomics::v1::AnnotationType value) { types_.Set(index, value); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationSetsRequest.types) } inline void SearchAnnotationSetsRequest::add_types(::google::genomics::v1::AnnotationType value) { types_.Add(value); // @@protoc_insertion_point(field_add:google.genomics.v1.SearchAnnotationSetsRequest.types) } inline const ::google::protobuf::RepeatedField<int>& SearchAnnotationSetsRequest::types() const { // @@protoc_insertion_point(field_list:google.genomics.v1.SearchAnnotationSetsRequest.types) return types_; } inline ::google::protobuf::RepeatedField<int>* SearchAnnotationSetsRequest::mutable_types() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.SearchAnnotationSetsRequest.types) return &types_; } // optional string page_token = 5; inline void SearchAnnotationSetsRequest::clear_page_token() { page_token_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& SearchAnnotationSetsRequest::page_token() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsRequest.page_token) return page_token_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SearchAnnotationSetsRequest::set_page_token(const ::std::string& value) { page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationSetsRequest.page_token) } inline void SearchAnnotationSetsRequest::set_page_token(const char* value) { page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationSetsRequest.page_token) } inline void SearchAnnotationSetsRequest::set_page_token(const char* value, size_t size) { page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationSetsRequest.page_token) } inline ::std::string* SearchAnnotationSetsRequest::mutable_page_token() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationSetsRequest.page_token) return page_token_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsRequest::release_page_token() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationSetsRequest.page_token) return page_token_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsRequest::unsafe_arena_release_page_token() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationSetsRequest.page_token) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return page_token_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SearchAnnotationSetsRequest::set_allocated_page_token(::std::string* page_token) { if (page_token != NULL) { } else { } page_token_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationSetsRequest.page_token) } inline void SearchAnnotationSetsRequest::unsafe_arena_set_allocated_page_token( ::std::string* page_token) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (page_token != NULL) { } else { } page_token_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationSetsRequest.page_token) } // optional int32 page_size = 6; inline void SearchAnnotationSetsRequest::clear_page_size() { page_size_ = 0; } inline ::google::protobuf::int32 SearchAnnotationSetsRequest::page_size() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsRequest.page_size) return page_size_; } inline void SearchAnnotationSetsRequest::set_page_size(::google::protobuf::int32 value) { page_size_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationSetsRequest.page_size) } inline const SearchAnnotationSetsRequest* SearchAnnotationSetsRequest::internal_default_instance() { return &SearchAnnotationSetsRequest_default_instance_.get(); } // ------------------------------------------------------------------- // SearchAnnotationSetsResponse // repeated .google.genomics.v1.AnnotationSet annotation_sets = 1; inline int SearchAnnotationSetsResponse::annotation_sets_size() const { return annotation_sets_.size(); } inline void SearchAnnotationSetsResponse::clear_annotation_sets() { annotation_sets_.Clear(); } inline const ::google::genomics::v1::AnnotationSet& SearchAnnotationSetsResponse::annotation_sets(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsResponse.annotation_sets) return annotation_sets_.Get(index); } inline ::google::genomics::v1::AnnotationSet* SearchAnnotationSetsResponse::mutable_annotation_sets(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationSetsResponse.annotation_sets) return annotation_sets_.Mutable(index); } inline ::google::genomics::v1::AnnotationSet* SearchAnnotationSetsResponse::add_annotation_sets() { // @@protoc_insertion_point(field_add:google.genomics.v1.SearchAnnotationSetsResponse.annotation_sets) return annotation_sets_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::AnnotationSet >* SearchAnnotationSetsResponse::mutable_annotation_sets() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.SearchAnnotationSetsResponse.annotation_sets) return &annotation_sets_; } inline const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::AnnotationSet >& SearchAnnotationSetsResponse::annotation_sets() const { // @@protoc_insertion_point(field_list:google.genomics.v1.SearchAnnotationSetsResponse.annotation_sets) return annotation_sets_; } // optional string next_page_token = 2; inline void SearchAnnotationSetsResponse::clear_next_page_token() { next_page_token_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& SearchAnnotationSetsResponse::next_page_token() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) return next_page_token_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SearchAnnotationSetsResponse::set_next_page_token(const ::std::string& value) { next_page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) } inline void SearchAnnotationSetsResponse::set_next_page_token(const char* value) { next_page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) } inline void SearchAnnotationSetsResponse::set_next_page_token(const char* value, size_t size) { next_page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) } inline ::std::string* SearchAnnotationSetsResponse::mutable_next_page_token() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) return next_page_token_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsResponse::release_next_page_token() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) return next_page_token_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationSetsResponse::unsafe_arena_release_next_page_token() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return next_page_token_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SearchAnnotationSetsResponse::set_allocated_next_page_token(::std::string* next_page_token) { if (next_page_token != NULL) { } else { } next_page_token_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), next_page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) } inline void SearchAnnotationSetsResponse::unsafe_arena_set_allocated_next_page_token( ::std::string* next_page_token) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (next_page_token != NULL) { } else { } next_page_token_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), next_page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationSetsResponse.next_page_token) } inline const SearchAnnotationSetsResponse* SearchAnnotationSetsResponse::internal_default_instance() { return &SearchAnnotationSetsResponse_default_instance_.get(); } // ------------------------------------------------------------------- // CreateAnnotationRequest // optional .google.genomics.v1.Annotation annotation = 1; inline bool CreateAnnotationRequest::has_annotation() const { return this != internal_default_instance() && annotation_ != NULL; } inline void CreateAnnotationRequest::clear_annotation() { if (GetArenaNoVirtual() == NULL && annotation_ != NULL) delete annotation_; annotation_ = NULL; } inline const ::google::genomics::v1::Annotation& CreateAnnotationRequest::annotation() const { // @@protoc_insertion_point(field_get:google.genomics.v1.CreateAnnotationRequest.annotation) return annotation_ != NULL ? *annotation_ : *::google::genomics::v1::Annotation::internal_default_instance(); } inline ::google::genomics::v1::Annotation* CreateAnnotationRequest::mutable_annotation() { if (annotation_ == NULL) { _slow_mutable_annotation(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.CreateAnnotationRequest.annotation) return annotation_; } inline ::google::genomics::v1::Annotation* CreateAnnotationRequest::release_annotation() { // @@protoc_insertion_point(field_release:google.genomics.v1.CreateAnnotationRequest.annotation) if (GetArenaNoVirtual() != NULL) { return _slow_release_annotation(); } else { ::google::genomics::v1::Annotation* temp = annotation_; annotation_ = NULL; return temp; } } inline void CreateAnnotationRequest::set_allocated_annotation(::google::genomics::v1::Annotation* annotation) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete annotation_; } if (annotation != NULL) { _slow_set_allocated_annotation(message_arena, &annotation); } annotation_ = annotation; if (annotation) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.CreateAnnotationRequest.annotation) } inline const CreateAnnotationRequest* CreateAnnotationRequest::internal_default_instance() { return &CreateAnnotationRequest_default_instance_.get(); } // ------------------------------------------------------------------- // BatchCreateAnnotationsRequest // repeated .google.genomics.v1.Annotation annotations = 1; inline int BatchCreateAnnotationsRequest::annotations_size() const { return annotations_.size(); } inline void BatchCreateAnnotationsRequest::clear_annotations() { annotations_.Clear(); } inline const ::google::genomics::v1::Annotation& BatchCreateAnnotationsRequest::annotations(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.BatchCreateAnnotationsRequest.annotations) return annotations_.Get(index); } inline ::google::genomics::v1::Annotation* BatchCreateAnnotationsRequest::mutable_annotations(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.BatchCreateAnnotationsRequest.annotations) return annotations_.Mutable(index); } inline ::google::genomics::v1::Annotation* BatchCreateAnnotationsRequest::add_annotations() { // @@protoc_insertion_point(field_add:google.genomics.v1.BatchCreateAnnotationsRequest.annotations) return annotations_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >* BatchCreateAnnotationsRequest::mutable_annotations() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.BatchCreateAnnotationsRequest.annotations) return &annotations_; } inline const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >& BatchCreateAnnotationsRequest::annotations() const { // @@protoc_insertion_point(field_list:google.genomics.v1.BatchCreateAnnotationsRequest.annotations) return annotations_; } // optional string request_id = 2; inline void BatchCreateAnnotationsRequest::clear_request_id() { request_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& BatchCreateAnnotationsRequest::request_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) return request_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void BatchCreateAnnotationsRequest::set_request_id(const ::std::string& value) { request_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) } inline void BatchCreateAnnotationsRequest::set_request_id(const char* value) { request_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) } inline void BatchCreateAnnotationsRequest::set_request_id(const char* value, size_t size) { request_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) } inline ::std::string* BatchCreateAnnotationsRequest::mutable_request_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) return request_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* BatchCreateAnnotationsRequest::release_request_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) return request_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* BatchCreateAnnotationsRequest::unsafe_arena_release_request_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return request_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void BatchCreateAnnotationsRequest::set_allocated_request_id(::std::string* request_id) { if (request_id != NULL) { } else { } request_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), request_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) } inline void BatchCreateAnnotationsRequest::unsafe_arena_set_allocated_request_id( ::std::string* request_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (request_id != NULL) { } else { } request_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), request_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.BatchCreateAnnotationsRequest.request_id) } inline const BatchCreateAnnotationsRequest* BatchCreateAnnotationsRequest::internal_default_instance() { return &BatchCreateAnnotationsRequest_default_instance_.get(); } // ------------------------------------------------------------------- // BatchCreateAnnotationsResponse_Entry // optional .google.rpc.Status status = 1; inline bool BatchCreateAnnotationsResponse_Entry::has_status() const { return this != internal_default_instance() && status_ != NULL; } inline void BatchCreateAnnotationsResponse_Entry::clear_status() { if (GetArenaNoVirtual() == NULL && status_ != NULL) delete status_; status_ = NULL; } inline const ::google::rpc::Status& BatchCreateAnnotationsResponse_Entry::status() const { // @@protoc_insertion_point(field_get:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.status) return status_ != NULL ? *status_ : *::google::rpc::Status::internal_default_instance(); } inline ::google::rpc::Status* BatchCreateAnnotationsResponse_Entry::mutable_status() { if (status_ == NULL) { _slow_mutable_status(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.status) return status_; } inline ::google::rpc::Status* BatchCreateAnnotationsResponse_Entry::release_status() { // @@protoc_insertion_point(field_release:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.status) if (GetArenaNoVirtual() != NULL) { return _slow_release_status(); } else { ::google::rpc::Status* temp = status_; status_ = NULL; return temp; } } inline void BatchCreateAnnotationsResponse_Entry::set_allocated_status(::google::rpc::Status* status) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete status_; } if (status != NULL) { if (message_arena != NULL) { message_arena->Own(status); } } status_ = status; if (status) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.status) } // optional .google.genomics.v1.Annotation annotation = 2; inline bool BatchCreateAnnotationsResponse_Entry::has_annotation() const { return this != internal_default_instance() && annotation_ != NULL; } inline void BatchCreateAnnotationsResponse_Entry::clear_annotation() { if (GetArenaNoVirtual() == NULL && annotation_ != NULL) delete annotation_; annotation_ = NULL; } inline const ::google::genomics::v1::Annotation& BatchCreateAnnotationsResponse_Entry::annotation() const { // @@protoc_insertion_point(field_get:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.annotation) return annotation_ != NULL ? *annotation_ : *::google::genomics::v1::Annotation::internal_default_instance(); } inline ::google::genomics::v1::Annotation* BatchCreateAnnotationsResponse_Entry::mutable_annotation() { if (annotation_ == NULL) { _slow_mutable_annotation(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.annotation) return annotation_; } inline ::google::genomics::v1::Annotation* BatchCreateAnnotationsResponse_Entry::release_annotation() { // @@protoc_insertion_point(field_release:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.annotation) if (GetArenaNoVirtual() != NULL) { return _slow_release_annotation(); } else { ::google::genomics::v1::Annotation* temp = annotation_; annotation_ = NULL; return temp; } } inline void BatchCreateAnnotationsResponse_Entry::set_allocated_annotation(::google::genomics::v1::Annotation* annotation) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete annotation_; } if (annotation != NULL) { _slow_set_allocated_annotation(message_arena, &annotation); } annotation_ = annotation; if (annotation) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.BatchCreateAnnotationsResponse.Entry.annotation) } inline const BatchCreateAnnotationsResponse_Entry* BatchCreateAnnotationsResponse_Entry::internal_default_instance() { return &BatchCreateAnnotationsResponse_Entry_default_instance_.get(); } // ------------------------------------------------------------------- // BatchCreateAnnotationsResponse // repeated .google.genomics.v1.BatchCreateAnnotationsResponse.Entry entries = 1; inline int BatchCreateAnnotationsResponse::entries_size() const { return entries_.size(); } inline void BatchCreateAnnotationsResponse::clear_entries() { entries_.Clear(); } inline const ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry& BatchCreateAnnotationsResponse::entries(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.BatchCreateAnnotationsResponse.entries) return entries_.Get(index); } inline ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry* BatchCreateAnnotationsResponse::mutable_entries(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.BatchCreateAnnotationsResponse.entries) return entries_.Mutable(index); } inline ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry* BatchCreateAnnotationsResponse::add_entries() { // @@protoc_insertion_point(field_add:google.genomics.v1.BatchCreateAnnotationsResponse.entries) return entries_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry >* BatchCreateAnnotationsResponse::mutable_entries() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.BatchCreateAnnotationsResponse.entries) return &entries_; } inline const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::BatchCreateAnnotationsResponse_Entry >& BatchCreateAnnotationsResponse::entries() const { // @@protoc_insertion_point(field_list:google.genomics.v1.BatchCreateAnnotationsResponse.entries) return entries_; } inline const BatchCreateAnnotationsResponse* BatchCreateAnnotationsResponse::internal_default_instance() { return &BatchCreateAnnotationsResponse_default_instance_.get(); } // ------------------------------------------------------------------- // GetAnnotationRequest // optional string annotation_id = 1; inline void GetAnnotationRequest::clear_annotation_id() { annotation_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& GetAnnotationRequest::annotation_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.GetAnnotationRequest.annotation_id) return annotation_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void GetAnnotationRequest::set_annotation_id(const ::std::string& value) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.GetAnnotationRequest.annotation_id) } inline void GetAnnotationRequest::set_annotation_id(const char* value) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.GetAnnotationRequest.annotation_id) } inline void GetAnnotationRequest::set_annotation_id(const char* value, size_t size) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.GetAnnotationRequest.annotation_id) } inline ::std::string* GetAnnotationRequest::mutable_annotation_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.GetAnnotationRequest.annotation_id) return annotation_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* GetAnnotationRequest::release_annotation_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.GetAnnotationRequest.annotation_id) return annotation_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* GetAnnotationRequest::unsafe_arena_release_annotation_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.GetAnnotationRequest.annotation_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return annotation_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void GetAnnotationRequest::set_allocated_annotation_id(::std::string* annotation_id) { if (annotation_id != NULL) { } else { } annotation_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.GetAnnotationRequest.annotation_id) } inline void GetAnnotationRequest::unsafe_arena_set_allocated_annotation_id( ::std::string* annotation_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (annotation_id != NULL) { } else { } annotation_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.GetAnnotationRequest.annotation_id) } inline const GetAnnotationRequest* GetAnnotationRequest::internal_default_instance() { return &GetAnnotationRequest_default_instance_.get(); } // ------------------------------------------------------------------- // UpdateAnnotationRequest // optional string annotation_id = 1; inline void UpdateAnnotationRequest::clear_annotation_id() { annotation_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& UpdateAnnotationRequest::annotation_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.UpdateAnnotationRequest.annotation_id) return annotation_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void UpdateAnnotationRequest::set_annotation_id(const ::std::string& value) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.UpdateAnnotationRequest.annotation_id) } inline void UpdateAnnotationRequest::set_annotation_id(const char* value) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.UpdateAnnotationRequest.annotation_id) } inline void UpdateAnnotationRequest::set_annotation_id(const char* value, size_t size) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.UpdateAnnotationRequest.annotation_id) } inline ::std::string* UpdateAnnotationRequest::mutable_annotation_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.UpdateAnnotationRequest.annotation_id) return annotation_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* UpdateAnnotationRequest::release_annotation_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.UpdateAnnotationRequest.annotation_id) return annotation_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* UpdateAnnotationRequest::unsafe_arena_release_annotation_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.UpdateAnnotationRequest.annotation_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return annotation_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void UpdateAnnotationRequest::set_allocated_annotation_id(::std::string* annotation_id) { if (annotation_id != NULL) { } else { } annotation_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.UpdateAnnotationRequest.annotation_id) } inline void UpdateAnnotationRequest::unsafe_arena_set_allocated_annotation_id( ::std::string* annotation_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (annotation_id != NULL) { } else { } annotation_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.UpdateAnnotationRequest.annotation_id) } // optional .google.genomics.v1.Annotation annotation = 2; inline bool UpdateAnnotationRequest::has_annotation() const { return this != internal_default_instance() && annotation_ != NULL; } inline void UpdateAnnotationRequest::clear_annotation() { if (GetArenaNoVirtual() == NULL && annotation_ != NULL) delete annotation_; annotation_ = NULL; } inline const ::google::genomics::v1::Annotation& UpdateAnnotationRequest::annotation() const { // @@protoc_insertion_point(field_get:google.genomics.v1.UpdateAnnotationRequest.annotation) return annotation_ != NULL ? *annotation_ : *::google::genomics::v1::Annotation::internal_default_instance(); } inline ::google::genomics::v1::Annotation* UpdateAnnotationRequest::mutable_annotation() { if (annotation_ == NULL) { _slow_mutable_annotation(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.UpdateAnnotationRequest.annotation) return annotation_; } inline ::google::genomics::v1::Annotation* UpdateAnnotationRequest::release_annotation() { // @@protoc_insertion_point(field_release:google.genomics.v1.UpdateAnnotationRequest.annotation) if (GetArenaNoVirtual() != NULL) { return _slow_release_annotation(); } else { ::google::genomics::v1::Annotation* temp = annotation_; annotation_ = NULL; return temp; } } inline void UpdateAnnotationRequest::set_allocated_annotation(::google::genomics::v1::Annotation* annotation) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete annotation_; } if (annotation != NULL) { _slow_set_allocated_annotation(message_arena, &annotation); } annotation_ = annotation; if (annotation) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.UpdateAnnotationRequest.annotation) } // optional .google.protobuf.FieldMask update_mask = 3; inline bool UpdateAnnotationRequest::has_update_mask() const { return this != internal_default_instance() && update_mask_ != NULL; } inline void UpdateAnnotationRequest::clear_update_mask() { if (GetArenaNoVirtual() == NULL && update_mask_ != NULL) delete update_mask_; update_mask_ = NULL; } inline const ::google::protobuf::FieldMask& UpdateAnnotationRequest::update_mask() const { // @@protoc_insertion_point(field_get:google.genomics.v1.UpdateAnnotationRequest.update_mask) return update_mask_ != NULL ? *update_mask_ : *::google::protobuf::FieldMask::internal_default_instance(); } inline ::google::protobuf::FieldMask* UpdateAnnotationRequest::mutable_update_mask() { if (update_mask_ == NULL) { _slow_mutable_update_mask(); } // @@protoc_insertion_point(field_mutable:google.genomics.v1.UpdateAnnotationRequest.update_mask) return update_mask_; } inline ::google::protobuf::FieldMask* UpdateAnnotationRequest::release_update_mask() { // @@protoc_insertion_point(field_release:google.genomics.v1.UpdateAnnotationRequest.update_mask) if (GetArenaNoVirtual() != NULL) { return _slow_release_update_mask(); } else { ::google::protobuf::FieldMask* temp = update_mask_; update_mask_ = NULL; return temp; } } inline void UpdateAnnotationRequest::set_allocated_update_mask(::google::protobuf::FieldMask* update_mask) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete update_mask_; } if (update_mask != NULL) { if (message_arena != NULL) { message_arena->Own(update_mask); } } update_mask_ = update_mask; if (update_mask) { } else { } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.UpdateAnnotationRequest.update_mask) } inline const UpdateAnnotationRequest* UpdateAnnotationRequest::internal_default_instance() { return &UpdateAnnotationRequest_default_instance_.get(); } // ------------------------------------------------------------------- // DeleteAnnotationRequest // optional string annotation_id = 1; inline void DeleteAnnotationRequest::clear_annotation_id() { annotation_id_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& DeleteAnnotationRequest::annotation_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.DeleteAnnotationRequest.annotation_id) return annotation_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void DeleteAnnotationRequest::set_annotation_id(const ::std::string& value) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.DeleteAnnotationRequest.annotation_id) } inline void DeleteAnnotationRequest::set_annotation_id(const char* value) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.DeleteAnnotationRequest.annotation_id) } inline void DeleteAnnotationRequest::set_annotation_id(const char* value, size_t size) { annotation_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.DeleteAnnotationRequest.annotation_id) } inline ::std::string* DeleteAnnotationRequest::mutable_annotation_id() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.DeleteAnnotationRequest.annotation_id) return annotation_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* DeleteAnnotationRequest::release_annotation_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.DeleteAnnotationRequest.annotation_id) return annotation_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* DeleteAnnotationRequest::unsafe_arena_release_annotation_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.DeleteAnnotationRequest.annotation_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return annotation_id_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void DeleteAnnotationRequest::set_allocated_annotation_id(::std::string* annotation_id) { if (annotation_id != NULL) { } else { } annotation_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.DeleteAnnotationRequest.annotation_id) } inline void DeleteAnnotationRequest::unsafe_arena_set_allocated_annotation_id( ::std::string* annotation_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (annotation_id != NULL) { } else { } annotation_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), annotation_id, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.DeleteAnnotationRequest.annotation_id) } inline const DeleteAnnotationRequest* DeleteAnnotationRequest::internal_default_instance() { return &DeleteAnnotationRequest_default_instance_.get(); } // ------------------------------------------------------------------- // SearchAnnotationsRequest // repeated string annotation_set_ids = 1; inline int SearchAnnotationsRequest::annotation_set_ids_size() const { return annotation_set_ids_.size(); } inline void SearchAnnotationsRequest::clear_annotation_set_ids() { annotation_set_ids_.Clear(); } inline const ::std::string& SearchAnnotationsRequest::annotation_set_ids(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) return annotation_set_ids_.Get(index); } inline ::std::string* SearchAnnotationsRequest::mutable_annotation_set_ids(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) return annotation_set_ids_.Mutable(index); } inline void SearchAnnotationsRequest::set_annotation_set_ids(int index, const ::std::string& value) { // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) annotation_set_ids_.Mutable(index)->assign(value); } inline void SearchAnnotationsRequest::set_annotation_set_ids(int index, const char* value) { annotation_set_ids_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) } inline void SearchAnnotationsRequest::set_annotation_set_ids(int index, const char* value, size_t size) { annotation_set_ids_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) } inline ::std::string* SearchAnnotationsRequest::add_annotation_set_ids() { // @@protoc_insertion_point(field_add_mutable:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) return annotation_set_ids_.Add(); } inline void SearchAnnotationsRequest::add_annotation_set_ids(const ::std::string& value) { annotation_set_ids_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) } inline void SearchAnnotationsRequest::add_annotation_set_ids(const char* value) { annotation_set_ids_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) } inline void SearchAnnotationsRequest::add_annotation_set_ids(const char* value, size_t size) { annotation_set_ids_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& SearchAnnotationsRequest::annotation_set_ids() const { // @@protoc_insertion_point(field_list:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) return annotation_set_ids_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* SearchAnnotationsRequest::mutable_annotation_set_ids() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.SearchAnnotationsRequest.annotation_set_ids) return &annotation_set_ids_; } // optional string reference_id = 2; inline bool SearchAnnotationsRequest::has_reference_id() const { return reference_case() == kReferenceId; } inline void SearchAnnotationsRequest::set_has_reference_id() { _oneof_case_[0] = kReferenceId; } inline void SearchAnnotationsRequest::clear_reference_id() { if (has_reference_id()) { reference_.reference_id_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_reference(); } } inline const ::std::string& SearchAnnotationsRequest::reference_id() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsRequest.reference_id) if (has_reference_id()) { return reference_.reference_id_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } inline void SearchAnnotationsRequest::set_reference_id(const ::std::string& value) { if (!has_reference_id()) { clear_reference(); set_has_reference_id(); reference_.reference_id_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } reference_.reference_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsRequest.reference_id) } inline void SearchAnnotationsRequest::set_reference_id(const char* value) { if (!has_reference_id()) { clear_reference(); set_has_reference_id(); reference_.reference_id_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } reference_.reference_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationsRequest.reference_id) } inline void SearchAnnotationsRequest::set_reference_id(const char* value, size_t size) { if (!has_reference_id()) { clear_reference(); set_has_reference_id(); reference_.reference_id_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } reference_.reference_id_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationsRequest.reference_id) } inline ::std::string* SearchAnnotationsRequest::mutable_reference_id() { if (!has_reference_id()) { clear_reference(); set_has_reference_id(); reference_.reference_id_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } return reference_.reference_id_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationsRequest.reference_id) } inline ::std::string* SearchAnnotationsRequest::release_reference_id() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationsRequest.reference_id) if (has_reference_id()) { clear_has_reference(); return reference_.reference_id_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } else { return NULL; } } inline ::std::string* SearchAnnotationsRequest::unsafe_arena_release_reference_id() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationsRequest.reference_id) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (has_reference_id()) { clear_has_reference(); return reference_.reference_id_.UnsafeArenaRelease( &::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } else { return NULL; } } inline void SearchAnnotationsRequest::set_allocated_reference_id(::std::string* reference_id) { if (!has_reference_id()) { reference_.reference_id_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } clear_reference(); if (reference_id != NULL) { set_has_reference_id(); reference_.reference_id_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_id, GetArenaNoVirtual()); } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationsRequest.reference_id) } inline void SearchAnnotationsRequest::unsafe_arena_set_allocated_reference_id(::std::string* reference_id) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (!has_reference_id()) { reference_.reference_id_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } clear_reference(); if (reference_id) { set_has_reference_id(); reference_.reference_id_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_id, GetArenaNoVirtual()); } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationsRequest.reference_id) } // optional string reference_name = 3; inline bool SearchAnnotationsRequest::has_reference_name() const { return reference_case() == kReferenceName; } inline void SearchAnnotationsRequest::set_has_reference_name() { _oneof_case_[0] = kReferenceName; } inline void SearchAnnotationsRequest::clear_reference_name() { if (has_reference_name()) { reference_.reference_name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); clear_has_reference(); } } inline const ::std::string& SearchAnnotationsRequest::reference_name() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsRequest.reference_name) if (has_reference_name()) { return reference_.reference_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } inline void SearchAnnotationsRequest::set_reference_name(const ::std::string& value) { if (!has_reference_name()) { clear_reference(); set_has_reference_name(); reference_.reference_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } reference_.reference_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsRequest.reference_name) } inline void SearchAnnotationsRequest::set_reference_name(const char* value) { if (!has_reference_name()) { clear_reference(); set_has_reference_name(); reference_.reference_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } reference_.reference_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationsRequest.reference_name) } inline void SearchAnnotationsRequest::set_reference_name(const char* value, size_t size) { if (!has_reference_name()) { clear_reference(); set_has_reference_name(); reference_.reference_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } reference_.reference_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationsRequest.reference_name) } inline ::std::string* SearchAnnotationsRequest::mutable_reference_name() { if (!has_reference_name()) { clear_reference(); set_has_reference_name(); reference_.reference_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } return reference_.reference_name_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationsRequest.reference_name) } inline ::std::string* SearchAnnotationsRequest::release_reference_name() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationsRequest.reference_name) if (has_reference_name()) { clear_has_reference(); return reference_.reference_name_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } else { return NULL; } } inline ::std::string* SearchAnnotationsRequest::unsafe_arena_release_reference_name() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationsRequest.reference_name) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (has_reference_name()) { clear_has_reference(); return reference_.reference_name_.UnsafeArenaRelease( &::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } else { return NULL; } } inline void SearchAnnotationsRequest::set_allocated_reference_name(::std::string* reference_name) { if (!has_reference_name()) { reference_.reference_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } clear_reference(); if (reference_name != NULL) { set_has_reference_name(); reference_.reference_name_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_name, GetArenaNoVirtual()); } // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationsRequest.reference_name) } inline void SearchAnnotationsRequest::unsafe_arena_set_allocated_reference_name(::std::string* reference_name) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (!has_reference_name()) { reference_.reference_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } clear_reference(); if (reference_name) { set_has_reference_name(); reference_.reference_name_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), reference_name, GetArenaNoVirtual()); } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationsRequest.reference_name) } // optional int64 start = 4; inline void SearchAnnotationsRequest::clear_start() { start_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 SearchAnnotationsRequest::start() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsRequest.start) return start_; } inline void SearchAnnotationsRequest::set_start(::google::protobuf::int64 value) { start_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsRequest.start) } // optional int64 end = 5; inline void SearchAnnotationsRequest::clear_end() { end_ = GOOGLE_LONGLONG(0); } inline ::google::protobuf::int64 SearchAnnotationsRequest::end() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsRequest.end) return end_; } inline void SearchAnnotationsRequest::set_end(::google::protobuf::int64 value) { end_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsRequest.end) } // optional string page_token = 6; inline void SearchAnnotationsRequest::clear_page_token() { page_token_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& SearchAnnotationsRequest::page_token() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsRequest.page_token) return page_token_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SearchAnnotationsRequest::set_page_token(const ::std::string& value) { page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsRequest.page_token) } inline void SearchAnnotationsRequest::set_page_token(const char* value) { page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationsRequest.page_token) } inline void SearchAnnotationsRequest::set_page_token(const char* value, size_t size) { page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationsRequest.page_token) } inline ::std::string* SearchAnnotationsRequest::mutable_page_token() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationsRequest.page_token) return page_token_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationsRequest::release_page_token() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationsRequest.page_token) return page_token_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationsRequest::unsafe_arena_release_page_token() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationsRequest.page_token) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return page_token_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SearchAnnotationsRequest::set_allocated_page_token(::std::string* page_token) { if (page_token != NULL) { } else { } page_token_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationsRequest.page_token) } inline void SearchAnnotationsRequest::unsafe_arena_set_allocated_page_token( ::std::string* page_token) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (page_token != NULL) { } else { } page_token_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationsRequest.page_token) } // optional int32 page_size = 7; inline void SearchAnnotationsRequest::clear_page_size() { page_size_ = 0; } inline ::google::protobuf::int32 SearchAnnotationsRequest::page_size() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsRequest.page_size) return page_size_; } inline void SearchAnnotationsRequest::set_page_size(::google::protobuf::int32 value) { page_size_ = value; // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsRequest.page_size) } inline bool SearchAnnotationsRequest::has_reference() const { return reference_case() != REFERENCE_NOT_SET; } inline void SearchAnnotationsRequest::clear_has_reference() { _oneof_case_[0] = REFERENCE_NOT_SET; } inline SearchAnnotationsRequest::ReferenceCase SearchAnnotationsRequest::reference_case() const { return SearchAnnotationsRequest::ReferenceCase(_oneof_case_[0]); } inline const SearchAnnotationsRequest* SearchAnnotationsRequest::internal_default_instance() { return &SearchAnnotationsRequest_default_instance_.get(); } // ------------------------------------------------------------------- // SearchAnnotationsResponse // repeated .google.genomics.v1.Annotation annotations = 1; inline int SearchAnnotationsResponse::annotations_size() const { return annotations_.size(); } inline void SearchAnnotationsResponse::clear_annotations() { annotations_.Clear(); } inline const ::google::genomics::v1::Annotation& SearchAnnotationsResponse::annotations(int index) const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsResponse.annotations) return annotations_.Get(index); } inline ::google::genomics::v1::Annotation* SearchAnnotationsResponse::mutable_annotations(int index) { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationsResponse.annotations) return annotations_.Mutable(index); } inline ::google::genomics::v1::Annotation* SearchAnnotationsResponse::add_annotations() { // @@protoc_insertion_point(field_add:google.genomics.v1.SearchAnnotationsResponse.annotations) return annotations_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >* SearchAnnotationsResponse::mutable_annotations() { // @@protoc_insertion_point(field_mutable_list:google.genomics.v1.SearchAnnotationsResponse.annotations) return &annotations_; } inline const ::google::protobuf::RepeatedPtrField< ::google::genomics::v1::Annotation >& SearchAnnotationsResponse::annotations() const { // @@protoc_insertion_point(field_list:google.genomics.v1.SearchAnnotationsResponse.annotations) return annotations_; } // optional string next_page_token = 2; inline void SearchAnnotationsResponse::clear_next_page_token() { next_page_token_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& SearchAnnotationsResponse::next_page_token() const { // @@protoc_insertion_point(field_get:google.genomics.v1.SearchAnnotationsResponse.next_page_token) return next_page_token_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SearchAnnotationsResponse::set_next_page_token(const ::std::string& value) { next_page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.genomics.v1.SearchAnnotationsResponse.next_page_token) } inline void SearchAnnotationsResponse::set_next_page_token(const char* value) { next_page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.genomics.v1.SearchAnnotationsResponse.next_page_token) } inline void SearchAnnotationsResponse::set_next_page_token(const char* value, size_t size) { next_page_token_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast<const char*>(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.genomics.v1.SearchAnnotationsResponse.next_page_token) } inline ::std::string* SearchAnnotationsResponse::mutable_next_page_token() { // @@protoc_insertion_point(field_mutable:google.genomics.v1.SearchAnnotationsResponse.next_page_token) return next_page_token_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationsResponse::release_next_page_token() { // @@protoc_insertion_point(field_release:google.genomics.v1.SearchAnnotationsResponse.next_page_token) return next_page_token_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline ::std::string* SearchAnnotationsResponse::unsafe_arena_release_next_page_token() { // @@protoc_insertion_point(field_unsafe_arena_release:google.genomics.v1.SearchAnnotationsResponse.next_page_token) GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); return next_page_token_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline void SearchAnnotationsResponse::set_allocated_next_page_token(::std::string* next_page_token) { if (next_page_token != NULL) { } else { } next_page_token_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), next_page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_allocated:google.genomics.v1.SearchAnnotationsResponse.next_page_token) } inline void SearchAnnotationsResponse::unsafe_arena_set_allocated_next_page_token( ::std::string* next_page_token) { GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); if (next_page_token != NULL) { } else { } next_page_token_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), next_page_token, GetArenaNoVirtual()); // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.genomics.v1.SearchAnnotationsResponse.next_page_token) } inline const SearchAnnotationsResponse* SearchAnnotationsResponse::internal_default_instance() { return &SearchAnnotationsResponse_default_instance_.get(); } #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // @@protoc_insertion_point(namespace_scope) } // namespace v1 } // namespace genomics } // namespace google #ifndef SWIG namespace google { namespace protobuf { template <> struct is_proto_enum< ::google::genomics::v1::VariantAnnotation_Type> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::google::genomics::v1::VariantAnnotation_Type>() { return ::google::genomics::v1::VariantAnnotation_Type_descriptor(); } template <> struct is_proto_enum< ::google::genomics::v1::VariantAnnotation_Effect> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::google::genomics::v1::VariantAnnotation_Effect>() { return ::google::genomics::v1::VariantAnnotation_Effect_descriptor(); } template <> struct is_proto_enum< ::google::genomics::v1::VariantAnnotation_ClinicalSignificance> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::google::genomics::v1::VariantAnnotation_ClinicalSignificance>() { return ::google::genomics::v1::VariantAnnotation_ClinicalSignificance_descriptor(); } template <> struct is_proto_enum< ::google::genomics::v1::AnnotationType> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::google::genomics::v1::AnnotationType>() { return ::google::genomics::v1::AnnotationType_descriptor(); } } // namespace protobuf } // namespace google #endif // SWIG // @@protoc_insertion_point(global_scope) #endif // PROTOBUF_google_2fgenomics_2fv1_2fannotations_2eproto__INCLUDED
43.569935
186
0.753594
[ "object" ]
5616b3dae44e9212990dffa2d7ea1e6e33d09912
467
h
C
include/Camera.h
M4T1A5/IndieSpeedRun2013
75b1adc4716c2e32f308289cce51a78a10681697
[ "Zlib" ]
null
null
null
include/Camera.h
M4T1A5/IndieSpeedRun2013
75b1adc4716c2e32f308289cce51a78a10681697
[ "Zlib" ]
null
null
null
include/Camera.h
M4T1A5/IndieSpeedRun2013
75b1adc4716c2e32f308289cce51a78a10681697
[ "Zlib" ]
null
null
null
#ifndef CAMERA_H #define CAMERA_H #include <Viewport.h> #include <Input.h> #include <EGEMath/Vector.h> namespace EGEMotor { class Camera { public: Camera(EGEMotor::Input& input, EGEMotor::Viewport& viewport, EGEMath::Vector mapSize); ~Camera(); void FollowMouse(const double& dt); void MoveTo(EGEMath::Vector MapCoordinate); private: Camera(Camera& camera); EGEMotor::Input* m_input; EGEMotor::Viewport* m_viewport; EGEMath::Vector m_mapSize; }; } #endif
17.296296
87
0.745182
[ "vector" ]
561bb4c54990aca35167ec25467f1881fe58b3a8
3,225
c
C
libjaus/src/type/jausGeometryPointXYZ.c
woshihuangrulin/openjaus.version33c
b3722c13c3a9286ec41eb43c47a8559acd3ba2ab
[ "BSD-3-Clause-Clear" ]
1
2020-08-13T14:26:03.000Z
2020-08-13T14:26:03.000Z
libjaus/src/type/jausGeometryPointXYZ.c
woshihuangrulin/openjaus.version33c
b3722c13c3a9286ec41eb43c47a8559acd3ba2ab
[ "BSD-3-Clause-Clear" ]
2
2020-01-07T23:14:35.000Z
2020-04-16T19:47:29.000Z
libjaus/src/type/jausGeometryPointXYZ.c
woshihuangrulin/openjaus.version33c
b3722c13c3a9286ec41eb43c47a8559acd3ba2ab
[ "BSD-3-Clause-Clear" ]
1
2020-04-16T12:54:21.000Z
2020-04-16T12:54:21.000Z
/***************************************************************************** * Copyright (c) 2009, OpenJAUS.com * All rights reserved. * * This file is part of OpenJAUS. OpenJAUS is distributed under the BSD * license. See the LICENSE file for details. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the University of Florida nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************/ // File Name: jausGeometryPointXYZ.c // // Written By: Danny Kent (jaus AT dannykent DOT com) // // Version: 3.3.0b // // Date: 09/08/09 // // Description: This file defines the functions of a JausGeometryPointXYZ Object #include <stdlib.h> #include "jaus.h" JausGeometryPointXYZ jausGeometryPointXYZCreate(void) { JausGeometryPointXYZ jausGeometryPointXYZ; jausGeometryPointXYZ = (JausGeometryPointXYZ)malloc(sizeof(JausGeometryPointXYZStruct)); if(jausGeometryPointXYZ) { jausGeometryPointXYZ->x = 0.0; jausGeometryPointXYZ->y = 0.0; jausGeometryPointXYZ->z = 0.0; return jausGeometryPointXYZ; } else return NULL; } void jausGeometryPointXYZDestroy(JausGeometryPointXYZ jausGeometryPointXYZ) { free(jausGeometryPointXYZ); } JAUS_EXPORT char* jausGeometryPointXYZToString(JausGeometryPointXYZ point) { char* buf = NULL; char* returnBuf = NULL; int bufSize = 50; buf = (char*)malloc(sizeof(char)*bufSize); strcpy(buf, "(X="); jausDoubleToString(point->x, buf+strlen(buf)); strcat(buf, ", Y="); jausDoubleToString(point->y, buf+strlen(buf)); strcat(buf, ", Z="); jausDoubleToString(point->z, buf+strlen(buf)); returnBuf = (char*)malloc(sizeof(char)*( strlen(buf)+1 )); strcpy(returnBuf, buf); free(buf); return returnBuf; }
35.43956
89
0.692403
[ "object" ]
561e88f7e7a15e5b4a04aef1b605d30db36379ae
11,209
h
C
service_apis/drive/google/drive_api/comment_reply.h
amyvmiwei/google-api-cpp-client
1a0a78b1f8f41085b91142f283690a07b474f0bc
[ "Apache-2.0" ]
1
2015-04-06T16:41:07.000Z
2015-04-06T16:41:07.000Z
service_apis/drive/google/drive_api/comment_reply.h
amyvmiwei/google-api-cpp-client
1a0a78b1f8f41085b91142f283690a07b474f0bc
[ "Apache-2.0" ]
null
null
null
service_apis/drive/google/drive_api/comment_reply.h
amyvmiwei/google-api-cpp-client
1a0a78b1f8f41085b91142f283690a07b474f0bc
[ "Apache-2.0" ]
null
null
null
// Copyright 2010 Google Inc. // // 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. // This code was generated by google-apis-code-generator 1.4.1 // Build date: 2013-08-07 19:00:49 UTC // on: 2013-08-12, 19:01:32 UTC // C++ generator version: // ---------------------------------------------------------------------------- // NOTE: This file is generated from Google APIs Discovery Service. // Service: // Drive API (drive/v2) // Generated from: // Version: v2 // Revision: 93 // Generated by: // Tool: google-apis-code-generator 1.4.1 // C++: 0.1 #ifndef GOOGLE_DRIVE_API_COMMENT_REPLY_H_ #define GOOGLE_DRIVE_API_COMMENT_REPLY_H_ #include <string> #include "googleapis/base/macros.h" #include "googleapis/client/data/jsoncpp_data.h" #include "googleapis/client/util/date_time.h" #include "googleapis/strings/stringpiece.h" #include "google/drive_api/user.h" namespace Json { class Value; } // namespace Json namespace google_drive_api { using namespace googleapis; /** * A JSON representation of a reply to a comment on a file in Google Drive. * * @ingroup DataObject */ class CommentReply : public client::JsonCppData { public: /** * Creates a new default instance. * * @return Ownership is passed back to the caller. */ static CommentReply* New(); /** * Standard constructor for an immutable data object instance. * * @param[in] storage The underlying data storage for this instance. */ explicit CommentReply(const Json::Value& storage); /** * Standard constructor for a mutable data object instance. * * @param[in] storage The underlying data storage for this instance. */ explicit CommentReply(Json::Value* storage); /** * Standard destructor. */ virtual ~CommentReply(); /** * Returns a string denoting the type of this data object. * * @return <code>google_drive_api::CommentReply</code> */ const StringPiece GetTypeName() const { return StringPiece("google_drive_api::CommentReply"); } /** * Determine if the '<code>author</code>' attribute was set. * * @return true if the '<code>author</code>' attribute was set. */ bool has_author() const { return Storage().isMember("author"); } /** * Clears the '<code>author</code>' attribute. */ void clear_author() { MutableStorage()->removeMember("author"); } /** * Get a reference to the value of the '<code>author</code>' attribute. */ const User get_author() const { return User(Storage("author")); } /** * Gets a reference to a mutable value of the '<code>author</code>' property. * * The user who wrote this reply. * * @return The result can be modified to change the attribute value. */ User mutable_author() { return User(MutableStorage("author")); } /** * Determine if the '<code>content</code>' attribute was set. * * @return true if the '<code>content</code>' attribute was set. */ bool has_content() const { return Storage().isMember("content"); } /** * Clears the '<code>content</code>' attribute. */ void clear_content() { MutableStorage()->removeMember("content"); } /** * Get the value of the '<code>content</code>' attribute. */ const StringPiece get_content() const { const Json::Value& v = Storage("content"); if (v == Json::Value::null) return StringPiece(""); return StringPiece(v.asCString()); } /** * Change the '<code>content</code>' attribute. * * The plain text content used to create this reply. This is not HTML safe and * should only be used as a starting point to make edits to a reply's content. * This field is required on inserts if no verb is specified (resolve/reopen). * * @param[in] value The new value. */ void set_content(const StringPiece& value) { *MutableStorage("content") = value.data(); } /** * Determine if the '<code>createdDate</code>' attribute was set. * * @return true if the '<code>createdDate</code>' attribute was set. */ bool has_createdDate() const { return Storage().isMember("createdDate"); } /** * Clears the '<code>createdDate</code>' attribute. */ void clear_createdDate() { MutableStorage()->removeMember("createdDate"); } /** * Get the value of the '<code>createdDate</code>' attribute. */ client::DateTime get_createdDate() const { const Json::Value& storage = Storage("createdDate"); return client::JsonValueToCppValueHelper<client::DateTime>(storage); } /** * Change the '<code>createdDate</code>' attribute. * * The date when this reply was first created. * * @param[in] value The new value. */ void set_createdDate(client::DateTime value) { client::SetJsonValueFromCppValueHelper<client::DateTime>( value, MutableStorage("createdDate")); } /** * Determine if the '<code>deleted</code>' attribute was set. * * @return true if the '<code>deleted</code>' attribute was set. */ bool has_deleted() const { return Storage().isMember("deleted"); } /** * Clears the '<code>deleted</code>' attribute. */ void clear_deleted() { MutableStorage()->removeMember("deleted"); } /** * Get the value of the '<code>deleted</code>' attribute. */ bool get_deleted() const { const Json::Value& storage = Storage("deleted"); return client::JsonValueToCppValueHelper<bool>(storage); } /** * Change the '<code>deleted</code>' attribute. * * Whether this reply has been deleted. If a reply has been deleted the * content will be cleared and this will only represent a reply that once * existed. * * @param[in] value The new value. */ void set_deleted(bool value) { client::SetJsonValueFromCppValueHelper<bool>( value, MutableStorage("deleted")); } /** * Determine if the '<code>htmlContent</code>' attribute was set. * * @return true if the '<code>htmlContent</code>' attribute was set. */ bool has_htmlContent() const { return Storage().isMember("htmlContent"); } /** * Clears the '<code>htmlContent</code>' attribute. */ void clear_htmlContent() { MutableStorage()->removeMember("htmlContent"); } /** * Get the value of the '<code>htmlContent</code>' attribute. */ const StringPiece get_htmlContent() const { const Json::Value& v = Storage("htmlContent"); if (v == Json::Value::null) return StringPiece(""); return StringPiece(v.asCString()); } /** * Change the '<code>htmlContent</code>' attribute. * * HTML formatted content for this reply. * * @param[in] value The new value. */ void set_htmlContent(const StringPiece& value) { *MutableStorage("htmlContent") = value.data(); } /** * Determine if the '<code>kind</code>' attribute was set. * * @return true if the '<code>kind</code>' attribute was set. */ bool has_kind() const { return Storage().isMember("kind"); } /** * Clears the '<code>kind</code>' attribute. */ void clear_kind() { MutableStorage()->removeMember("kind"); } /** * Get the value of the '<code>kind</code>' attribute. */ const StringPiece get_kind() const { const Json::Value& v = Storage("kind"); if (v == Json::Value::null) return StringPiece(""); return StringPiece(v.asCString()); } /** * Change the '<code>kind</code>' attribute. * * This is always drive#commentReply. * * @param[in] value The new value. */ void set_kind(const StringPiece& value) { *MutableStorage("kind") = value.data(); } /** * Determine if the '<code>modifiedDate</code>' attribute was set. * * @return true if the '<code>modifiedDate</code>' attribute was set. */ bool has_modifiedDate() const { return Storage().isMember("modifiedDate"); } /** * Clears the '<code>modifiedDate</code>' attribute. */ void clear_modifiedDate() { MutableStorage()->removeMember("modifiedDate"); } /** * Get the value of the '<code>modifiedDate</code>' attribute. */ client::DateTime get_modifiedDate() const { const Json::Value& storage = Storage("modifiedDate"); return client::JsonValueToCppValueHelper<client::DateTime>(storage); } /** * Change the '<code>modifiedDate</code>' attribute. * * The date when this reply was last modified. * * @param[in] value The new value. */ void set_modifiedDate(client::DateTime value) { client::SetJsonValueFromCppValueHelper<client::DateTime>( value, MutableStorage("modifiedDate")); } /** * Determine if the '<code>replyId</code>' attribute was set. * * @return true if the '<code>replyId</code>' attribute was set. */ bool has_replyId() const { return Storage().isMember("replyId"); } /** * Clears the '<code>replyId</code>' attribute. */ void clear_replyId() { MutableStorage()->removeMember("replyId"); } /** * Get the value of the '<code>replyId</code>' attribute. */ const StringPiece get_replyId() const { const Json::Value& v = Storage("replyId"); if (v == Json::Value::null) return StringPiece(""); return StringPiece(v.asCString()); } /** * Change the '<code>replyId</code>' attribute. * * The ID of the reply. * * @param[in] value The new value. */ void set_replyId(const StringPiece& value) { *MutableStorage("replyId") = value.data(); } /** * Determine if the '<code>verb</code>' attribute was set. * * @return true if the '<code>verb</code>' attribute was set. */ bool has_verb() const { return Storage().isMember("verb"); } /** * Clears the '<code>verb</code>' attribute. */ void clear_verb() { MutableStorage()->removeMember("verb"); } /** * Get the value of the '<code>verb</code>' attribute. */ const StringPiece get_verb() const { const Json::Value& v = Storage("verb"); if (v == Json::Value::null) return StringPiece(""); return StringPiece(v.asCString()); } /** * Change the '<code>verb</code>' attribute. * * The action this reply performed to the parent comment. When creating a new * reply this is the action to be perform to the parent comment. Possible * values are: * <dl> * <dt>"resolve" * <dd>To resolve a comment. * <dt>"reopen" * <dd>To reopen (un-resolve) a comment. * </dl> * * * @param[in] value The new value. */ void set_verb(const StringPiece& value) { *MutableStorage("verb") = value.data(); } private: void operator=(const CommentReply&); }; // CommentReply } // namespace google_drive_api #endif // GOOGLE_DRIVE_API_COMMENT_REPLY_H_
25.475
80
0.641092
[ "object" ]
56253092eece6dc47d24612d6c574a5e71334880
13,257
c
C
src/spiceqxl_inputs.c
shiqingd/xf86-video-qxl3
52c421c650f8813665b31890df691b31fabc366a
[ "MIT" ]
null
null
null
src/spiceqxl_inputs.c
shiqingd/xf86-video-qxl3
52c421c650f8813665b31890df691b31fabc366a
[ "MIT" ]
null
null
null
src/spiceqxl_inputs.c
shiqingd/xf86-video-qxl3
52c421c650f8813665b31890df691b31fabc366a
[ "MIT" ]
null
null
null
/* * Copyright 2011 Red Hat, Inc. * * 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 * on the rights to use, copy, modify, merge, publish, distribute, sub * license, 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 (including the next * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS 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. */ /* Handle inputs channel for spice, and register the X parts, * a mouse and a keyboard device pair. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <xf86Xinput.h> #include <exevents.h> #include <xserver-properties.h> #include <list.h> #include <input.h> #include <xkbsrv.h> #include <spice.h> #include "qxl.h" #include "spiceqxl_inputs.h" static int XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); static int XSpiceKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); static void XSpicePointerUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); static void XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); static char xspice_pointer_name[] = "xspice pointer"; static InputDriverRec XSPICE_POINTER = { 1, xspice_pointer_name, NULL, XSpicePointerPreInit, XSpicePointerUnInit, NULL, NULL /* defaults */ }; static char xspice_keyboard_name[] = "xspice keyboard"; static InputDriverRec XSPICE_KEYBOARD = { 1, xspice_keyboard_name, NULL, XSpiceKeyboardPreInit, XSpiceKeyboardUnInit, NULL, NULL }; #define BUTTONS 5 typedef struct XSpiceKbd { SpiceKbdInstance sin; uint8_t ledstate; InputInfoPtr pInfo; /* xf86 device handle to post events */ /* Note: spice sends some of the keys escaped by this. * This is supposed to be AT key codes, but I can't figure out where that * thing is defined after looking at xf86-input-keyboard. Ended up reverse * engineering a escaped table using xev. */ int escape; } XSpiceKbd; static int xspice_pointer_proc(DeviceIntPtr pDevice, int onoff) { DevicePtr pDev = (DevicePtr)pDevice; BYTE map[BUTTONS + 1]; Atom btn_labels[BUTTONS]; Atom axes_labels[2]; int i; switch (onoff) { case DEVICE_INIT: for (i = 0; i < BUTTONS + 1; i++) { map[i] = i; } btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); InitPointerDeviceStruct(pDev, map, BUTTONS,btn_labels,(PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), 2, axes_labels); break; case DEVICE_ON: pDev->on = TRUE; break; case DEVICE_OFF: pDev->on = FALSE; break; } return Success; } static void xspice_keyboard_bell(int percent, DeviceIntPtr device, pointer ctrl, int class_) { } #define CAPSFLAG 1 #define NUMFLAG 2 #define SCROLLFLAG 4 /* MODEFLAG and COMPOSEFLAG currently unused (reminder for future) */ #define MODEFLAG 8 #define COMPOSEFLAG 16 #define ArrayLength(a) (sizeof(a) / (sizeof((a)[0]))) static void xspice_keyboard_control(DeviceIntPtr device, KeybdCtrl *ctrl) { static struct { int xbit, code; } bits[] = { { CAPSFLAG, SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK }, { NUMFLAG, SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK }, { SCROLLFLAG, SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK }, /* TODO: there is no MODEFLAG nor COMPOSEFLAG in SPICE. */ }; XSpiceKbd *kbd; InputInfoPtr pInfo; int i; pInfo = device->public.devicePrivate; kbd = pInfo->private; kbd->ledstate = 0; for (i = 0; i < ArrayLength(bits); i++) { if (ctrl->leds & bits[i].xbit) { kbd->ledstate |= bits[i].code; } else { kbd->ledstate &= ~bits[i].code; } } } static char xspice_keyboard_rules[] = "evdev"; static char xspice_keyboard_model[] = "pc105"; static char xspice_keyboard_layout[] = "us"; static char xspice_keyboard_variant[] = ""; static char xspice_keyboard_options[] = ""; static int xspice_keyboard_proc(DeviceIntPtr pDevice, int onoff) { DevicePtr pDev = (DevicePtr)pDevice; XkbRMLVOSet rmlvo = { .rules = xspice_keyboard_rules, .model = xspice_keyboard_model, .layout = xspice_keyboard_layout, .variant = xspice_keyboard_variant, .options = xspice_keyboard_options, }; switch (onoff) { case DEVICE_INIT: InitKeyboardDeviceStruct( pDevice, &rmlvo, xspice_keyboard_bell, xspice_keyboard_control ); break; case DEVICE_ON: pDev->on = TRUE; break; case DEVICE_OFF: pDev->on = FALSE; break; } return Success; } /* from spice-input.c */ /* keyboard bits */ static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag); static uint8_t kbd_get_leds(SpiceKbdInstance *sin); static const SpiceKbdInterface kbd_interface = { .base.type = SPICE_INTERFACE_KEYBOARD, .base.description = "xspice keyboard", .base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR, .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR, .push_scan_freg = kbd_push_key, .get_leds = kbd_get_leds, }; /* spice sends AT scancodes (with a strange escape). * But xf86PostKeyboardEvent expects scancodes. Apparently most of the time * you just need to add MIN_KEYCODE, see xf86-input-keyboard/src/atKeynames * and xf86-input-keyboard/src/kbd.c:PostKbdEvent: * xf86PostKeyboardEvent(device, scanCode + MIN_KEYCODE, down); */ #define MIN_KEYCODE 8 static uint8_t escaped_map[256] = { [0x1c] = 104, //KEY_KP_Enter, [0x1d] = 105, //KEY_RCtrl, [0x2a] = 0,//KEY_LMeta, // REDKEY_FAKE_L_SHIFT [0x35] = 106,//KEY_KP_Divide, [0x36] = 0,//KEY_RMeta, // REDKEY_FAKE_R_SHIFT [0x37] = 107,//KEY_Print, [0x38] = 108,//KEY_AltLang, [0x46] = 127,//KEY_Break, [0x47] = 110,//KEY_Home, [0x48] = 111,//KEY_Up, [0x49] = 112,//KEY_PgUp, [0x4b] = 113,//KEY_Left, [0x4d] = 114,//KEY_Right, [0x4f] = 115,//KEY_End, [0x50] = 116,//KEY_Down, [0x51] = 117,//KEY_PgDown, [0x52] = 118,//KEY_Insert, [0x53] = 119,//KEY_Delete, [0x5b] = 133,//0, // REDKEY_LEFT_CMD, [0x5c] = 134,//0, // REDKEY_RIGHT_CMD, [0x5d] = 135,//KEY_Menu, }; static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag) { XSpiceKbd *kbd = container_of(sin, XSpiceKbd, sin); int is_down; if (frag == 224) { kbd->escape = frag; return; } is_down = frag & 0x80 ? FALSE : TRUE; frag = frag & 0x7f; if (kbd->escape == 224) { kbd->escape = 0; if (escaped_map[frag] == 0) { fprintf(stderr, "spiceqxl_inputs.c: kbd_push_key: escaped_map[%d] == 0\n", frag); } frag = escaped_map[frag]; } else { frag += MIN_KEYCODE; } xf86PostKeyboardEvent(kbd->pInfo->dev, frag, is_down); } static uint8_t kbd_get_leds(SpiceKbdInstance *sin) { XSpiceKbd *kbd = container_of(sin, XSpiceKbd, sin); return kbd->ledstate; } /* mouse bits */ typedef struct XSpicePointer { SpiceMouseInstance mouse; SpiceTabletInstance tablet; int width, height, x, y; Bool absolute; InputInfoPtr pInfo; /* xf86 device handle to post events */ } XSpicePointer; static XSpicePointer *g_xspice_pointer; static void mouse_motion(SpiceMouseInstance *sin, int dx, int dy, int dz, uint32_t buttons_state) { // TODO } static void mouse_buttons(SpiceMouseInstance *sin, uint32_t buttons_state) { // TODO } static const SpiceMouseInterface mouse_interface = { .base.type = SPICE_INTERFACE_MOUSE, .base.description = "xspice mouse", .base.major_version = SPICE_INTERFACE_MOUSE_MAJOR, .base.minor_version = SPICE_INTERFACE_MOUSE_MINOR, .motion = mouse_motion, .buttons = mouse_buttons, }; static void tablet_set_logical_size(SpiceTabletInstance* sin, int width, int height) { XSpicePointer *spice_pointer = container_of(sin, XSpicePointer, tablet); if (height < 16) { height = 16; } if (width < 16) { width = 16; } spice_pointer->width = width; spice_pointer->height = height; } void spiceqxl_tablet_position(int x, int y, uint32_t buttons_state) { // TODO: don't ignore buttons_state xf86PostMotionEvent(g_xspice_pointer->pInfo->dev, 1, 0, 2, x, y); } static void tablet_position(SpiceTabletInstance* sin, int x, int y, uint32_t buttons_state) { spiceqxl_tablet_position(x, y, buttons_state); } void spiceqxl_tablet_buttons(uint32_t buttons_state) { static uint32_t old_buttons_state = 0; int i; for (i = 0; i < BUTTONS; i++) { if ((buttons_state ^ old_buttons_state) & (1 << i)) { int action = (buttons_state & (1 << i)); xf86PostButtonEvent(g_xspice_pointer->pInfo->dev, 0, i + 1, action, 0, 0); } } old_buttons_state = buttons_state; } static void tablet_buttons(SpiceTabletInstance *sin, uint32_t buttons_state) { // For some reason spice switches the second and third button, undo that. // basically undo RED_MOUSE_STATE_TO_LOCAL buttons_state = (buttons_state & SPICE_MOUSE_BUTTON_MASK_LEFT) | ((buttons_state & SPICE_MOUSE_BUTTON_MASK_MIDDLE) << 1) | ((buttons_state & SPICE_MOUSE_BUTTON_MASK_RIGHT) >> 1) | (buttons_state & ~(SPICE_MOUSE_BUTTON_MASK_LEFT | SPICE_MOUSE_BUTTON_MASK_MIDDLE |SPICE_MOUSE_BUTTON_MASK_RIGHT)); spiceqxl_tablet_buttons(buttons_state); } static void tablet_wheel(SpiceTabletInstance* sin, int wheel, uint32_t buttons_state) { // convert wheel into fourth and fifth buttons tablet_buttons(sin, buttons_state | (wheel > 0 ? (1<<4) : 0) | (wheel < 0 ? (1<<3) : 0)); } static const SpiceTabletInterface tablet_interface = { .base.type = SPICE_INTERFACE_TABLET, .base.description = "xspice tablet", .base.major_version = SPICE_INTERFACE_TABLET_MAJOR, .base.minor_version = SPICE_INTERFACE_TABLET_MINOR, .set_logical_size = tablet_set_logical_size, .position = tablet_position, .wheel = tablet_wheel, .buttons = tablet_buttons, }; static char unknown_type_string[] = "UNKNOWN"; static int XSpiceKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { XSpiceKbd *kbd; kbd = calloc(sizeof(*kbd), 1); kbd->sin.base.sif = &kbd_interface.base; kbd->pInfo = pInfo; pInfo->private = kbd; pInfo->type_name = unknown_type_string; pInfo->device_control = xspice_keyboard_proc; pInfo->read_input = NULL; pInfo->switch_mode = NULL; spice_server_add_interface(xspice_get_spice_server(), &kbd->sin.base); return Success; } static int XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { XSpicePointer *spice_pointer; g_xspice_pointer = spice_pointer = calloc(sizeof(*spice_pointer), 1); spice_pointer->mouse.base.sif = &mouse_interface.base; spice_pointer->tablet.base.sif = &tablet_interface.base; spice_pointer->absolute = TRUE; spice_pointer->pInfo = pInfo; pInfo->private = NULL; pInfo->type_name = unknown_type_string; pInfo->device_control = xspice_pointer_proc; pInfo->read_input = NULL; pInfo->switch_mode = NULL; spice_server_add_interface(xspice_get_spice_server(), &spice_pointer->tablet.base); return Success; } static void XSpicePointerUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { } static void XSpiceKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { } void xspice_add_input_drivers(pointer module) { xf86AddInputDriver(&XSPICE_POINTER, module, 0); xf86AddInputDriver(&XSPICE_KEYBOARD, module, 0); }
31.046838
93
0.668703
[ "model" ]
5625f2d2af185fa2c90c360148ab0ad497cb29d5
369
h
C
Suppressing Operations/include/Shape.h
fatih-iver-2016400264/The-C-Plus-Plus-Programming-Language
dae68e933ba3f95faea65d5b681d1df4fb212f88
[ "MIT" ]
null
null
null
Suppressing Operations/include/Shape.h
fatih-iver-2016400264/The-C-Plus-Plus-Programming-Language
dae68e933ba3f95faea65d5b681d1df4fb212f88
[ "MIT" ]
null
null
null
Suppressing Operations/include/Shape.h
fatih-iver-2016400264/The-C-Plus-Plus-Programming-Language
dae68e933ba3f95faea65d5b681d1df4fb212f88
[ "MIT" ]
null
null
null
#ifndef SHAPE_H #define SHAPE_H class Shape { public: Shape(const Shape&) = delete; // no copy operations Shape& operator=(const Shape&) = delete; Shape(Shape&&) = delete; // no move operations Shape& operator=(Shape&&) = delete; virtual ~Shape(); protected: private: }; #endif // SHAPE_H
16.772727
60
0.552846
[ "shape" ]
5628eb77a86095d4153f125a27b74cc1f0033bb9
1,892
h
C
packager/media/base/decryptor_source.h
koln67/shaka-packager
5b9fd409a5de502e8af2e46ee12840bd2226874d
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1,288
2016-05-25T01:20:31.000Z
2022-03-02T23:56:56.000Z
packager/media/base/decryptor_source.h
koln67/shaka-packager
5b9fd409a5de502e8af2e46ee12840bd2226874d
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
894
2016-05-17T00:39:30.000Z
2022-03-02T18:46:21.000Z
packager/media/base/decryptor_source.h
koln67/shaka-packager
5b9fd409a5de502e8af2e46ee12840bd2226874d
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
400
2016-05-25T01:20:35.000Z
2022-03-03T02:12:00.000Z
// Copyright 2016 Google Inc. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd #ifndef PACKAGER_MEDIA_BASE_DECRYPTOR_SOURCE_H_ #define PACKAGER_MEDIA_BASE_DECRYPTOR_SOURCE_H_ #include <map> #include <memory> #include <vector> #include "packager/media/base/aes_decryptor.h" #include "packager/media/base/decrypt_config.h" #include "packager/media/base/key_source.h" namespace shaka { namespace media { /// DecryptorSource wraps KeySource and is responsible for decryptor management. class DecryptorSource { public: /// Constructs a DecryptorSource object. /// @param key_source points to the key source that contains the keys. explicit DecryptorSource(KeySource* key_source); ~DecryptorSource(); /// Decrypt encrypted buffer. /// @param decrypt_config contains decrypt configuration, e.g. protection /// scheme, subsample information etc. /// @param encrypted_buffer points to the encrypted buffer that is to be /// decrypted. It should not overlap with @a decrypted_buffer. /// @param buffer_size is the size of encrypted buffer and decrypted buffer. /// @param decrypted_buffer points to the decrypted buffer. It should not /// overlap with @a encrypted_buffer. /// @return true if success, false otherwise. bool DecryptSampleBuffer(const DecryptConfig* decrypt_config, const uint8_t* encrypted_buffer, size_t buffer_size, uint8_t* decrypted_buffer); private: KeySource* key_source_; std::map<std::vector<uint8_t>, std::unique_ptr<AesCryptor>> decryptor_map_; DISALLOW_COPY_AND_ASSIGN(DecryptorSource); }; } // namespace media } // namespace shaka #endif // PACKAGER_MEDIA_BASE_DECRYPTOR_SOURCE_H_
35.037037
80
0.729915
[ "object", "vector" ]
562cb4a2e477f75bfaea988525d32c44c6a3677b
10,763
h
C
tmp/out.h
willxujun/tensorflow
5c31a9c4a8aa94d2f41c60880bb3ca699c23328c
[ "Apache-2.0" ]
null
null
null
tmp/out.h
willxujun/tensorflow
5c31a9c4a8aa94d2f41c60880bb3ca699c23328c
[ "Apache-2.0" ]
null
null
null
tmp/out.h
willxujun/tensorflow
5c31a9c4a8aa94d2f41c60880bb3ca699c23328c
[ "Apache-2.0" ]
null
null
null
// Generated by tfcompile, the TensorFlow graph compiler. DO NOT EDIT! // // This header was generated via ahead-of-time compilation of a TensorFlow // graph. An object file corresponding to this header was also generated. // This header gives access to the functionality in that object file. // // clang-format off #ifndef TFCOMPILE_GENERATED_entry_H_ // NOLINT(build/header_guard) #define TFCOMPILE_GENERATED_entry_H_ // NOLINT(build/header_guard) #include "tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h" #include "tensorflow/core/platform/types.h" namespace Eigen { struct ThreadPoolDevice; } namespace xla { class ExecutableRunOptions; } // (Implementation detail) Entry point to the function in the object file. extern "C" void entry( void* result, const xla::ExecutableRunOptions* run_options, const void** args, void** temps, tensorflow::int64* profile_counters); // TmpComp represents a computation previously specified in a // TensorFlow graph, now compiled into executable code. This extends the generic // XlaCompiledCpuFunction class with statically type-safe arg and result // methods. Usage example: // // TmpComp computation; // // ...set args using computation.argN methods // CHECK(computation.Run()); // // ...inspect results using computation.resultN methods // // The Run method invokes the actual computation, with inputs read from arg // buffers, and outputs written to result buffers. Each Run call may also use // a set of temporary buffers for the computation. // // By default each instance of this class manages its own arg, result and temp // buffers. The AllocMode constructor parameter may be used to modify the // buffer allocation strategy. // // Under the default allocation strategy, this class is thread-compatible: // o Calls to non-const methods require exclusive access to the object. // o Concurrent calls to const methods are OK, if those calls are made while it // is guaranteed that no thread may call a non-const method. // // The logical function signature is: // (arg0: f32[2,2], arg1: f32[2,2]) -> (f32[2,2], f32[2,2]) // // Memory stats: // arg bytes total: 32 // arg bytes aligned: 128 // temp bytes total: 48 // temp bytes aligned: 192 class TmpComp : public tensorflow::XlaCompiledCpuFunction { public: // Number of input arguments for the compiled computation. static constexpr size_t kNumArgs = 2; // Byte size of each argument buffer. There are kNumArgs entries. static const ::tensorflow::int64 ArgSize(::tensorflow::int32 index) { return BufferInfos()[ArgIndexToBufferIndex()[index]].size(); } // Returns static data used to create an XlaCompiledCpuFunction. static const tensorflow::XlaCompiledCpuFunction::StaticData& StaticData() { static XlaCompiledCpuFunction::StaticData* kStaticData = [](){ XlaCompiledCpuFunction::StaticData* data = new XlaCompiledCpuFunction::StaticData; data->set_raw_function(entry); data->set_buffer_infos(BufferInfos()); data->set_num_buffers(kNumBuffers); data->set_arg_index_table(ArgIndexToBufferIndex()); data->set_num_args(kNumArgs); data->set_result_index(kResultIndex); data->set_arg_names(StaticArgNames()); data->set_result_names(StaticResultNames()); data->set_program_shape(StaticProgramShape()); data->set_hlo_profile_printer_data(StaticHloProfilePrinterData()); return data; }(); return *kStaticData; } TmpComp(AllocMode alloc_mode = AllocMode::ARGS_RESULTS_PROFILES_AND_TEMPS) : XlaCompiledCpuFunction(StaticData(), alloc_mode) {} TmpComp(const TmpComp&) = delete; TmpComp& operator=(const TmpComp&) = delete; // Arg methods for managing input buffers. Buffers are in row-major order. // There is a set of methods for each positional argument, with the following // general form: // // void set_argN_data(void* data) // Sets the buffer of type T for positional argument N. May be called in // any AllocMode. Must be called before Run to have an affect. Must be // called in AllocMode::RESULTS_PROFILES_AND_TEMPS_ONLY for each positional // argument, to set the argument buffers. // // T* argN_data() // Returns the buffer of type T for positional argument N. // // T& argN(...dim indices...) // Returns a reference to the value of type T for positional argument N, // with dim indices specifying which value. No bounds checking is performed // on dim indices. void set_arg0_data(void* data) { set_arg_data(0, data); } float* arg0_data() { return static_cast<float*>(arg_data(0)); } float& arg0(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( arg_data(0)))[dim0][dim1]; } const float* arg0_data() const { return static_cast<const float*>(arg_data(0)); } const float& arg0(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( arg_data(0)))[dim0][dim1]; } void set_arg_x_data(void* data) { set_arg_data(0, data); } float* arg_x_data() { return static_cast<float*>(arg_data(0)); } float& arg_x(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( arg_data(0)))[dim0][dim1]; } const float* arg_x_data() const { return static_cast<const float*>(arg_data(0)); } const float& arg_x(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( arg_data(0)))[dim0][dim1]; } void set_arg1_data(void* data) { set_arg_data(1, data); } float* arg1_data() { return static_cast<float*>(arg_data(1)); } float& arg1(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( arg_data(1)))[dim0][dim1]; } const float* arg1_data() const { return static_cast<const float*>(arg_data(1)); } const float& arg1(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( arg_data(1)))[dim0][dim1]; } void set_arg_y_data(void* data) { set_arg_data(1, data); } float* arg_y_data() { return static_cast<float*>(arg_data(1)); } float& arg_y(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( arg_data(1)))[dim0][dim1]; } const float* arg_y_data() const { return static_cast<const float*>(arg_data(1)); } const float& arg_y(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( arg_data(1)))[dim0][dim1]; } // Result methods for managing output buffers. Buffers are in row-major order. // Must only be called after a successful Run call. There is a set of methods // for each positional result, with the following general form: // // T* resultN_data() // Returns the buffer of type T for positional result N. // // T& resultN(...dim indices...) // Returns a reference to the value of type T for positional result N, // with dim indices specifying which value. No bounds checking is performed // on dim indices. // // Unlike the arg methods, there is no set_resultN_data method. The result // buffers are managed internally, and may change after each call to Run. float* result0_data() { return static_cast<float*>(result_data(0)); } float& result0(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( result_data(0)))[dim0][dim1]; } const float* result0_data() const { return static_cast<const float*>(result_data(0)); } const float& result0(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( result_data(0)))[dim0][dim1]; } float* result_x_y_prod_data() { return static_cast<float*>(result_data(0)); } float& result_x_y_prod(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( result_data(0)))[dim0][dim1]; } const float* result_x_y_prod_data() const { return static_cast<const float*>(result_data(0)); } const float& result_x_y_prod(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( result_data(0)))[dim0][dim1]; } float* result1_data() { return static_cast<float*>(result_data(1)); } float& result1(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( result_data(1)))[dim0][dim1]; } const float* result1_data() const { return static_cast<const float*>(result_data(1)); } const float& result1(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( result_data(1)))[dim0][dim1]; } float* result_x_y_sum_data() { return static_cast<float*>(result_data(1)); } float& result_x_y_sum(size_t dim0, size_t dim1) { return (*static_cast<float(*)[2][2]>( result_data(1)))[dim0][dim1]; } const float* result_x_y_sum_data() const { return static_cast<const float*>(result_data(1)); } const float& result_x_y_sum(size_t dim0, size_t dim1) const { return (*static_cast<const float(*)[2][2]>( result_data(1)))[dim0][dim1]; } private: // Number of buffers for the compiled computation. static constexpr size_t kNumBuffers = 5; static const ::tensorflow::cpu_function_runtime::BufferInfo* BufferInfos() { static const ::tensorflow::cpu_function_runtime::BufferInfo kBufferInfos[kNumBuffers] = { ::tensorflow::cpu_function_runtime::BufferInfo({65ULL, ~0ULL}), ::tensorflow::cpu_function_runtime::BufferInfo({65ULL, ~0ULL}), ::tensorflow::cpu_function_runtime::BufferInfo({65ULL, ~0ULL}), ::tensorflow::cpu_function_runtime::BufferInfo({66ULL, 0ULL}), ::tensorflow::cpu_function_runtime::BufferInfo({66ULL, 1ULL}) }; return kBufferInfos; } static const ::tensorflow::int32* ArgIndexToBufferIndex() { static constexpr ::tensorflow::int32 kArgIndexToBufferIndex[kNumArgs] = { 3, 4 }; return kArgIndexToBufferIndex; } // The 0-based index of the result tuple in the temporary buffers. static constexpr size_t kResultIndex = 2; // Array of names of each positional argument, terminated by nullptr. static const char** StaticArgNames() { return nullptr; } // Array of names of each positional result, terminated by nullptr. static const char** StaticResultNames() { return nullptr; } // Shape of the args and results. static const xla::ProgramShape* StaticProgramShape() { static const xla::ProgramShape* kShape = nullptr; return kShape; } // Metadata that can be used to pretty-print profile counters. static const xla::HloProfilePrinterData* StaticHloProfilePrinterData() { static const xla::HloProfilePrinterData* kHloProfilePrinterData = nullptr; return kHloProfilePrinterData; } }; #endif // TFCOMPILE_GENERATED_entry_H_ // clang-format on
34.060127
80
0.693022
[ "object", "shape" ]
562d84514424ab552975d632b70d2c4e485ff045
1,951
h
C
include/CppUtil/Engine/RTX_Renderer.h
huangx916/RenderLab
a0059705d5694146bbe51442e0cabdcbcd750fe7
[ "MIT" ]
1
2019-09-20T03:04:12.000Z
2019-09-20T03:04:12.000Z
include/CppUtil/Engine/RTX_Renderer.h
ishigami33/RenderLab
86c9ab48815adcbdc6afb39883337088fb019bc0
[ "MIT" ]
null
null
null
include/CppUtil/Engine/RTX_Renderer.h
ishigami33/RenderLab
86c9ab48815adcbdc6afb39883337088fb019bc0
[ "MIT" ]
null
null
null
#ifndef _ENGINE_RTX_RTX_RENDERER_H_ #define _ENGINE_RTX_RTX_RENDERER_H_ #include <CppUtil/Basic/HeapObj.h> #include <3rdParty/enum.h> #include <functional> #include <vector> #include <mutex> namespace CppUtil { namespace Basic { class Image; } namespace Engine { class Scene; class RayTracer; class BVHAccel; BETTER_ENUM(RendererState, int, Running, Stop) class RTX_Renderer : public Basic::HeapObj { public: RTX_Renderer(const std::function<Basic::Ptr<RayTracer>()> & generator); public: static const Basic::Ptr<RTX_Renderer> New(const std::function<Basic::Ptr<RayTracer>()> & generator) { return Basic::New<RTX_Renderer>(generator); } public: void Run(Basic::Ptr<Scene> scene, Basic::Ptr<Basic::Image> img); void Stop(); RendererState GetState() const { return state; } float ProgressRate(); public: volatile int maxLoop; private: class TileTask { public: void Init(int tileNum, int maxLoop) { this->tileNum = tileNum; this->maxLoop = maxLoop; curTile = 0; curLoop = 0; } public: struct Task { Task(bool hasTask, int tileID = -1, int curLoop = -1) : hasTask(hasTask), tileID(tileID), curLoop(curLoop) { } bool hasTask; int tileID; int curLoop; }; const Task GetTask() { if (curLoop == maxLoop) return Task(false); m.lock(); auto rst = Task(true, curTile, curLoop); curTile++; if (curTile == tileNum) { curTile = 0; curLoop += 1; } m.unlock(); return rst; } int GetCurLoop() const { return curLoop; } private: int tileNum; int curTile; int maxLoop; int curLoop; std::mutex m; }; private: std::function<Basic::Ptr<RayTracer>()> generator; RendererState state; const int threadNum; TileTask tileTask; Basic::Ptr<BVHAccel> bvhAccel; }; } } #endif//!_ENGINE_RTX_RTX_RENDERER_H_
18.580952
104
0.634034
[ "vector" ]
563b4342449d7a2eb652fc564b7982d1c774d098
1,838
h
C
Game/Source/Scene.h
Memory-Leakers/Platformer2D_Grup99
fe2e24d3f1affb11502add56e2de090cf5a8bf1a
[ "MIT" ]
4
2021-10-20T12:15:53.000Z
2022-01-30T16:15:35.000Z
Game/Source/Scene.h
Memory-Leakers/Platformer2D_Grup99
fe2e24d3f1affb11502add56e2de090cf5a8bf1a
[ "MIT" ]
null
null
null
Game/Source/Scene.h
Memory-Leakers/Platformer2D_Grup99
fe2e24d3f1affb11502add56e2de090cf5a8bf1a
[ "MIT" ]
null
null
null
#ifndef __SCENE_H__ #define __SCENE_H__ #include "App.h" #include "GameScene.h" #include "MenuScene.h" #include "GuiControl.h" struct SDL_Texture; enum background { Blue = 0, Brown, Gray, Green, Pink, Purple, Yellow }; enum class CScene { NONE = 0, GAMESCENE, MENUSCENE, GAMESCENELOAD }; struct Level { Level(int levelNum, SString file) { this->levelNum = levelNum; this->file = file; } ~Level() { } int levelNum; //Number of the level SString file; int camX = 0, camY = 0; }; class Scene : public Module { public: Scene(); // Destructor virtual ~Scene(); // Called before render is available bool Awake(pugi::xml_node& config); // Called before the first frame bool Start() ; // Called before all Updates bool PreUpdate() ; // Called each loop iteration bool Update(float dt) ; // Called before all Updates bool PostUpdate() ; // Called before quitting bool CleanUp(); bool SaveSettings(pugi::xml_node& config); void OnCollision(Collider* c1, Collider* c2) override; void WillCollision(Collider* c1, Collider* c2) override; bool LoadState(pugi::xml_node&) override; bool SaveState(pugi::xml_node&) const override; bool OnGuiMouseClickEvent(GuiControl* control); void changeScene(CScene scene = CScene::NONE); private: void bgSelector(); void drawBackground(); public: GameScene* gameScene = nullptr; MenuScene* menuScene = nullptr; CScene cScene = CScene::MENUSCENE; bool changeScenePetition = false; CScene nextScene; bool exitPetition = false; bool debugTiles = false; bool guiDebugTiles = false; int highScoreI = 0; uint buttonSFX = NULL; int soundL = 100; int musicL = 100; private: SDL_Texture* img; List<Level*> levelList; SDL_Texture* bgTex = nullptr; SString bg; int bgPivX = 0; int bgPivY = -128; }; #endif // __SCENE_H__
14.587302
57
0.700762
[ "render" ]
5644624a981d238dd94518dca045e592cca89d07
1,290
h
C
include/image_raw.h
ra1nb0w/arduino-heart
8c9d0f7bf49f478f37e18688bc372a0cecfa2949
[ "BSD-2-Clause" ]
null
null
null
include/image_raw.h
ra1nb0w/arduino-heart
8c9d0f7bf49f478f37e18688bc372a0cecfa2949
[ "BSD-2-Clause" ]
null
null
null
include/image_raw.h
ra1nb0w/arduino-heart
8c9d0f7bf49f478f37e18688bc372a0cecfa2949
[ "BSD-2-Clause" ]
null
null
null
/* * image_raw.h - Library to render raw file with UTFT * Created by Davide `rainbow` Gerhard * 12 May 2019 * For the license see LICENSE */ #ifndef _IMAGE_RAW_H #define _IMAGE_RAW_H #include "config.h" #include "vfs.h" /* * include display and touchscreen libs * * both from http://www.rinkydinkelectronics.com */ #include <UTFT.h> class ImageRaw { public: ImageRaw(); void init(UTFT *ptrUTFT); // from https://github.com/ghlawrence2000/UTFT_SdRaw/blob/master/src/UTFT_SdRaw.cpp // CC BY-NC-SA 3.0 license int load(int x, int y, int sx, int sy, char *filename, int bufmult, bool iswap); #if defined(__AVR__) int loadS(int x, int y, int sx, int sy, int bufmult, bool iswap); #elif defined(__arm__) int loadS(Serial_ port, int x, int y, int sx, int sy, int bufmult, bool iswap); int loadS(UARTClass port, int x, int y, int sx, int sy, int bufmult, bool iswap); #endif int loadcpld(int x, int y, int sx, int sy, char *filename, int writepage = 0, int bufmult = 1, bool iswap = 0); int pan(int x, int y, int sx, int sy, unsigned long offsetx, unsigned long offsety, unsigned long sizex, unsigned long sizey, char *filename, bool iswap = 0); private: UTFT *_UTFT; File dataFile; }; extern ImageRaw image_raw; #endif _IMAGE_RAW_H
28.043478
162
0.689922
[ "render" ]
5647290874022e84733225af448d723ee1fe5055
2,056
h
C
src/input/request_types.h
fh-tech/CFLOP
6df4bf40cf34b3b109adc18b622635f814b2f4f3
[ "MIT" ]
3
2018-04-30T21:48:04.000Z
2019-01-24T05:07:11.000Z
src/input/request_types.h
fh-tech/CFLOP
6df4bf40cf34b3b109adc18b622635f814b2f4f3
[ "MIT" ]
null
null
null
src/input/request_types.h
fh-tech/CFLOP
6df4bf40cf34b3b109adc18b622635f814b2f4f3
[ "MIT" ]
null
null
null
// // Created by daniel on 4/25/18. // #ifndef CFLOP_REQUEST_TYPES_H #define CFLOP_REQUEST_TYPES_H #include <iostream> #include <vector> #include "../../libs/json/single_include/nlohmann/json.hpp" using json = nlohmann::json; namespace input_lib { struct node { size_t id = 0; std::vector<size_t> edges{}; node() = default; node(size_t id, std::vector<size_t > &&vec) : id (id) , edges(std::move(vec)) {} }; static void to_json(json &j, const node& n) { j["id"] = n.id; j["edges"] = n.edges; } static void from_json(const json &j, node& n) { n.id = j.at("id").get<size_t>(); n.edges = j.at("edges").get<std::vector<size_t>>(); } struct edge { size_t id; size_t from; size_t to; std::string transition; }; static void to_json(json &j, const edge& e) { j["id"] = e.id; j["from"] = e.from; j["to"] = e.to; j["transition"] = e.transition; } static void from_json(const json &j, edge& e) { e.id = j.at("id").get<size_t>(); e.from = j.at("from").get<size_t>(); e.to = j.at("to").get<size_t>(); } //** NODES TYPES **// struct nodes_post_s {}; struct nodes_delete_s { size_t id; }; struct nodes_get_s { size_t id; }; struct nodes_put_start_s { size_t id; }; struct nodes_put_end_s { size_t id; }; //** EDGES TYPES **// struct edges_get_s { size_t id; }; struct edges_post_s { size_t to; size_t from; std::string transition; }; struct edges_delete_s { size_t id; }; //** STATE TYPES **// struct state_get_s {}; struct state_post_s { std::vector<node> nodes{}; std::vector<edge> edges{}; size_t active; size_t start; size_t end; }; struct state_put_s { std::string input; }; } #endif //CFLOP_REQUEST_TYPES_H
19.961165
59
0.519455
[ "vector" ]
5648e5aba09e3fd672d016ebbe79482db2358f8b
5,362
h
C
Sources/External/node/elastos/external/chromium_org/third_party/WebKit/Source/modules/modules_gyp/bindings/core/v8/V8Node.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
7
2017-07-13T10:34:54.000Z
2021-04-16T05:40:35.000Z
Sources/External/node/elastos/external/chromium_org/third_party/WebKit/Source/modules/modules_gyp/bindings/core/v8/V8Node.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
null
null
null
Sources/External/node/elastos/external/chromium_org/third_party/WebKit/Source/modules/modules_gyp/bindings/core/v8/V8Node.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
9
2017-07-13T12:33:20.000Z
2021-06-19T02:46:48.000Z
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! #ifndef V8Node_h #define V8Node_h #include "bindings/core/v8/V8EventTarget.h" #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8DOMWrapper.h" #include "bindings/v8/WrapperTypeInfo.h" #include "core/dom/Node.h" #include "platform/heap/Handle.h" namespace WebCore { class V8Node { public: static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*); static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Value>, v8::Isolate*); static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*); static Node* toNative(v8::Handle<v8::Object> object) { return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)); } static Node* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>); static const WrapperTypeInfo wrapperTypeInfo; static void derefObject(void*); static EventTarget* toEventTarget(v8::Handle<v8::Object>); static void insertBeforeMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); static void replaceChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); static void removeChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); static void appendChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); #if ENABLE(OILPAN) static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + 0; static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0 + 1; #else static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; #endif static inline void* toInternalPointer(Node* impl) { return V8EventTarget::toInternalPointer(impl); } static inline Node* fromInternalPointer(void* object) { return static_cast<Node*>(V8EventTarget::fromInternalPointer(object)); } static void installPerContextEnabledProperties(v8::Handle<v8::Object>, Node*, v8::Isolate*) { } static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*) { } private: friend v8::Handle<v8::Object> wrap(Node*, v8::Handle<v8::Object> creationContext, v8::Isolate*); static v8::Handle<v8::Object> createWrapper(PassRefPtrWillBeRawPtr<Node>, v8::Handle<v8::Object> creationContext, v8::Isolate*); }; v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*); inline v8::Handle<v8::Value> toV8(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) { if (UNLIKELY(!impl)) return v8::Null(isolate); v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<V8Node>(impl, isolate); if (!wrapper.IsEmpty()) return wrapper; return wrap(impl, creationContext, isolate); } template<typename CallbackInfo> inline void v8SetReturnValue(const CallbackInfo& callbackInfo, Node* impl) { if (UNLIKELY(!impl)) { v8SetReturnValueNull(callbackInfo); return; } if (DOMDataStore::setReturnValueFromWrapper<V8Node>(callbackInfo.GetReturnValue(), impl)) return; v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()); v8SetReturnValue(callbackInfo, wrapper); } template<typename CallbackInfo> inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, Node* impl) { ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld()); if (UNLIKELY(!impl)) { v8SetReturnValueNull(callbackInfo); return; } if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8Node>(callbackInfo.GetReturnValue(), impl)) return; v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()); v8SetReturnValue(callbackInfo, wrapper); } template<class CallbackInfo, class Wrappable> inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, Node* impl, Wrappable* wrappable) { if (UNLIKELY(!impl)) { v8SetReturnValueNull(callbackInfo); return; } if (DOMDataStore::setReturnValueFromWrapperFast<V8Node>(callbackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable)) return; v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()); v8SetReturnValue(callbackInfo, wrapper); } inline v8::Handle<v8::Value> toV8(PassRefPtrWillBeRawPtr<Node> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) { return toV8(impl.get(), creationContext, isolate); } template<class CallbackInfo> inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtrWillBeRawPtr<Node> impl) { v8SetReturnValue(callbackInfo, impl.get()); } template<class CallbackInfo> inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassRefPtrWillBeRawPtr<Node> impl) { v8SetReturnValueForMainWorld(callbackInfo, impl.get()); } template<class CallbackInfo, class Wrappable> inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtrWillBeRawPtr<Node> impl, Wrappable* wrappable) { v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); } } #endif // V8Node_h
39.426471
132
0.743939
[ "object" ]
7bce235842fa75b515202fb6b9913274bf294418
5,080
h
C
optimizer/ml_region_optimizer.h
klindworth/disparity_estimation
74759d35f7635ff725629a1ae555d313f3e9fb29
[ "BSD-2-Clause" ]
null
null
null
optimizer/ml_region_optimizer.h
klindworth/disparity_estimation
74759d35f7635ff725629a1ae555d313f3e9fb29
[ "BSD-2-Clause" ]
null
null
null
optimizer/ml_region_optimizer.h
klindworth/disparity_estimation
74759d35f7635ff725629a1ae555d313f3e9fb29
[ "BSD-2-Clause" ]
null
null
null
/* Copyright (c) 2014, Kai Klindworth All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ML_REGION_OPTIMIZER_H #define ML_REGION_OPTIMIZER_H #include "region_optimizer.h" #include "region_ground_truth.h" #include <memory> #include <vector> #include "neural_network/settings.h" class single_stereo_task; namespace neural_network { template<typename T> class network; } class ml_feature_calculator : public disparity_features_calculator { public: ml_feature_calculator(const region_container& left_regions, const region_container& right_regions) : disparity_features_calculator(left_regions, right_regions) {} void operator()(const disparity_region& baseRegion, short pot_trunc, const disparity_range& drange, std::vector<float>& result_vector); void update_result_vector(std::vector<float>& result_vector, const disparity_region& baseRegion, const disparity_range& drange); }; template<typename T> struct feature_vector { feature_vector(int vector_size, int vector_size_per_disp, int range_size, bool merged = false) : vector_size(vector_size), vector_size_per_disp(vector_size_per_disp), range_size(range_size), merged(false) { } std::size_t index(int disp) const { if(!merged) return vector_size_per_disp*std::abs(disp); else return vector_size_per_disp*2*std::abs(disp); } std::size_t index() const { return vector_size_per_disp; } std::vector<T> data; int vector_size, vector_size_per_disp, range_size; bool merged; }; class ml_region_optimizer_base : public region_optimizer { public: void run(region_container& left, region_container& right, const optimizer_settings& config, int refinement= 0) override; protected: std::vector<std::vector<float>> feature_vectors_left, feature_vectors_right; std::vector<std::vector<double>> samples_left, samples_right; std::vector<short> samples_gt_left, samples_gt_right; int training_iteration; std::string filename_left_prefix, filename_right_prefix; std::unique_ptr<neural_network::network<double>> nnet; result_eps_calculator total_diff_calc; virtual void refresh_base_optimization_vector(const region_container& base, const region_container& match, int delta); virtual void prepare_training_sample(std::vector<short>& dst_gt, std::vector<std::vector<double>>& dst_data, const std::vector<std::vector<float>>& base_optimization_vectors, const std::vector<std::vector<float>>& match_optimization_vectors, const region_container& base, const region_container& match, int delta) = 0; virtual void optimize_ml(region_container& base, const region_container& match, std::vector<std::vector<float>>& optimization_vectors_base, std::vector<std::vector<float>>& optimization_vectors_match, int delta, const std::string& filename) = 0; virtual void reset_internal() = 0; void set_range(int prange) {range = prange; } int range; }; class ml_region_optimizer : public ml_region_optimizer_base { public: ml_region_optimizer(); ~ml_region_optimizer(); void reset(const region_container& left, const region_container& right) override; void training() override; const static int vector_size_per_disp = 11 +8+2; const static int vector_size = 0;//8; const static int normalizer_size = vector_size+vector_size_per_disp; protected: void prepare_training_sample(std::vector<short>& dst_gt, std::vector<std::vector<double>>& dst_data, const std::vector<std::vector<float>>& base_optimization_vectors, const std::vector<std::vector<float>>& match_optimization_vectors, const region_container& base, const region_container& match, int delta); void optimize_ml(region_container& base, const region_container& match, std::vector<std::vector<float>>& optimization_vectors_base, std::vector<std::vector<float>>& optimization_vectors_match, int delta, const std::string& filename); void reset_internal(); neural_network::training_settings _settings; }; #endif
40.967742
319
0.799016
[ "vector" ]
7bdbe3d5e058cdbd053f873bbb98f94ba3fe9dad
2,483
h
C
bbmp_windows/src/bbmp_windows/bbmp/windows_handles.h
bebump/bbmp_coolth
0368746a87d41da6d0be3dbc6cb32f337d686a1e
[ "BSD-3-Clause" ]
6
2021-04-06T18:50:06.000Z
2021-12-06T15:11:44.000Z
bbmp_windows/src/bbmp_windows/bbmp/windows_handles.h
bebump/bbmp_coolth
0368746a87d41da6d0be3dbc6cb32f337d686a1e
[ "BSD-3-Clause" ]
2
2021-06-04T15:55:27.000Z
2021-08-03T21:36:50.000Z
bbmp_windows/src/bbmp_windows/bbmp/windows_handles.h
bebump/coolth
0368746a87d41da6d0be3dbc6cb32f337d686a1e
[ "BSD-3-Clause" ]
null
null
null
#pragma once #define NOMINMAX #define NOGDI #include <strsafe.h> #include <windows.h> #undef NOMINMAX #undef NOGDI #include <functional> #include <string> std::string GetLastErrorAsString(); /* * The (sad) reason for the templated approach: * * Some Win32 API functions return INVALID_HANDLE_VALUE (-1) to signal a failed * attempt. I actually have seen 0 returned by them as a valid, working handle. * * Others return NULL. */ template <int V_INVALID> class WindowsHandle final { public: WindowsHandle() : handle_(reinterpret_cast<HANDLE>(V_INVALID)) {} WindowsHandle(HANDLE raw_handle) : handle_(raw_handle) { ThrowIfHandleIsInvalid(); } WindowsHandle(const WindowsHandle<V_INVALID>& other) = delete; WindowsHandle(WindowsHandle<V_INVALID>&& other) { if (handle_ != reinterpret_cast<HANDLE>(V_INVALID)) { const auto success = CloseHandle(handle_); if (!success) { throw std::runtime_error("Failed to close WindowsHandle"); } } handle_ = other.Get(); other.handle_ = reinterpret_cast<HANDLE>(V_INVALID); } WindowsHandle& operator=(WindowsHandle<V_INVALID>&& other) { if (handle_ != reinterpret_cast<HANDLE>(V_INVALID)) { const auto success = CloseHandle(handle_); if (!success) { throw std::runtime_error("Failed to close WindowsHandle"); } } handle_ = other.Get(); other.handle_ = reinterpret_cast<HANDLE>(V_INVALID); return *this; } ~WindowsHandle() noexcept { // The handle can become invalid after a move operation if (handle_ != reinterpret_cast<HANDLE>(V_INVALID)) { const auto success = CloseHandle(handle_); if (!success) { // TODO: log error as we can't throw from destructor } } } HANDLE& Get() { ThrowIfHandleIsInvalid(); return handle_; } private: HANDLE handle_; void ThrowIfHandleIsInvalid() { if (handle_ == reinterpret_cast<HANDLE>(V_INVALID)) { throw std::runtime_error("Invalid handle encountered in WindowsHandle"); } } }; class ScopeGuard final { public: void Add(std::function<void()>&& deferred_function) noexcept { deferred_functions_.push_back(std::move(deferred_function)); } void CancelAll() noexcept { deferred_functions_.clear(); } ~ScopeGuard() noexcept { try { for (auto& f : deferred_functions_) { f(); } } catch (...) { } } private: std::vector<std::function<void()>> deferred_functions_; };
24.106796
79
0.67056
[ "vector" ]
7be61627c501f3caccbb41139737fcba6be9f124
1,193
c
C
@COT/Addons/scripts/4_World/cameras/COTCamera.c
maxkunes/DayZ-Mod-Projects
3bbf5cd553aff55af9302f2a7357b20207b9edb0
[ "MIT" ]
null
null
null
@COT/Addons/scripts/4_World/cameras/COTCamera.c
maxkunes/DayZ-Mod-Projects
3bbf5cd553aff55af9302f2a7357b20207b9edb0
[ "MIT" ]
null
null
null
@COT/Addons/scripts/4_World/cameras/COTCamera.c
maxkunes/DayZ-Mod-Projects
3bbf5cd553aff55af9302f2a7357b20207b9edb0
[ "MIT" ]
null
null
null
class COTCamera extends Camera { float SendUpdateAccumalator = 0.0; bool LookFreeze; bool MoveFreeze; Object SelectedTarget; vector TargetPosition; void COTCamera() { SetEventMask( EntityEvent.FRAME ); SelectedTarget( NULL ); } void SelectedTarget( Object target ) { SelectedTarget = target; if ( SelectedTarget ) { TargetPosition = target.GetPosition(); MoveFreeze = true; LookFreeze = true; } else { TargetPosition = "0 0 0"; MoveFreeze = false; LookFreeze = false; } } override void EOnFrame( IEntity other, float timeSlice ) { if ( SendUpdateAccumalator > 0.5 ) { GetRPCManager().SendRPC( "COT_Camera", "UpdateCameraNetworkBubble", new Param1<vector>( GetPosition() ), true ); GetGame().UpdateSpectatorPosition( GetPosition() ); SendUpdateAccumalator = 0; } SendUpdateAccumalator = SendUpdateAccumalator + timeSlice; OnUpdate( timeSlice ); } void OnUpdate( float timeslice ) { } }
22.092593
124
0.562448
[ "object", "vector" ]
7be83dfce2a7808e0d8927be01a1caa2d34772f9
2,806
h
C
RLFPS/Source/RLFPS/FragPlayerCollisionComponent.h
Verb-Noun-Studios/Symbiotic
d037b3bbe4925f2d4c97d4c44e45ec0abe88c237
[ "MIT" ]
3
2022-01-11T03:29:03.000Z
2022-02-03T03:46:44.000Z
RLFPS/Source/RLFPS/FragPlayerCollisionComponent.h
Verb-Noun-Studios/Symbiotic
d037b3bbe4925f2d4c97d4c44e45ec0abe88c237
[ "MIT" ]
27
2022-02-02T04:54:29.000Z
2022-03-27T18:58:15.000Z
RLFPS/Source/RLFPS/FragPlayerCollisionComponent.h
Verb-Noun-Studios/Symbiotic
d037b3bbe4925f2d4c97d4c44e45ec0abe88c237
[ "MIT" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "FragPlayerCollisionComponent.generated.h" class UFragMovementComponent; class AFragPlayer; UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RLFPS_API UFragPlayerCollisionComponent : public UActorComponent { GENERATED_BODY() public: UFragMovementComponent* MovementComponent; AFragPlayer* Player; // Sets default values for this component's properties UFragPlayerCollisionComponent(); // Called when the game starts virtual void BeginPlay() override; // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; public: float delta; FHitResult GroundTrace; public: /** The amount the collider has to travel before detecting the ground */ UPROPERTY(Category = "General Collision", EditAnywhere, BlueprintReadWrite) float GroundTraceDistance = 0.25f; UPROPERTY(Category = "General Collision", EditAnywhere, BlueprintReadWrite) float MinWalkNormal = 0.7f; UPROPERTY(Category = "General Collision", EditAnywhere, BlueprintReadWrite) float Overclip = 1.001f; // The amount of 'skin' the player has UPROPERTY(Category = "General Collision", EditAnywhere, BlueprintReadWrite) float Underclip = 0.1f; UPROPERTY(Category = "General Collision", EditAnywhere, BlueprintReadWrite) int32 MaxClipPlanes = 5; UPROPERTY(Category = "General Collision", EditAnywhere, BlueprintReadWrite) int32 MaxStepSize = 18; public: /** Is the player touching the ground. This includes steep slopes and such */ UPROPERTY(BlueprintReadOnly) bool IsGrounded; /** Determines whether the player can run or not */ bool CanGroundMove; private: /** Uses the player's collider to trace from start to end */ bool Trace(FHitResult& Result, FVector Start, FVector End); /** Moves a vector from Start to ENd, where Scale is the percent of movement (from 0.0 - 1.0) */ public: void VectorMA(FVector Start, float Scale, FVector End, FVector& Out); /** The following methods make changes to the player internally as their intended output. */ public: /** Auto traces ground */ void TraceGround(); /** Gets the trace's ending. If there's a hit, it will return the location of the hit, if there is no hit then the trace's ending will return. If the trace started in a collider then the resolution vector will be returned */ FVector TraceEnd(FHitResult& T); /** Attempts to solve a collision by sliding the player and clipping velocity */ bool SlideMove(bool Gravity); /** Same as SlideMove except it takes into account slopes and stairs */ void StepSlideMove(bool Gravity); void SolvePenetration(FHitResult& PenTrace); };
40.085714
122
0.77263
[ "vector" ]
7bea4b27bc6a844b174a6d1ab2e8ed4aad8ad328
519
h
C
cases/spherical_surfers/param/init/objects/surfer__us_1o0__surftimeconst_9o0__reorientationtime_1o5/orient/group/all/parameters.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
cases/spherical_surfers/param/init/objects/surfer__us_1o0__surftimeconst_9o0__reorientationtime_1o5/orient/group/all/parameters.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
cases/spherical_surfers/param/init/objects/surfer__us_1o0__surftimeconst_9o0__reorientationtime_1o5/orient/group/all/parameters.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
#ifndef C0P_PARAM_OBJECTS_SURFER__US_1O0__SURFTIMECONST_9O0__REORIENTATIONTIME_1O5_ORIENT_GROUP_ALL_PARAMETERS_H #define C0P_PARAM_OBJECTS_SURFER__US_1O0__SURFTIMECONST_9O0__REORIENTATIONTIME_1O5_ORIENT_GROUP_ALL_PARAMETERS_H #pragma once // app include #include "core/init/objects/object/init/group/all/prop.h" namespace c0p { // SurferUs1O0Surftimeconst9O0Reorientationtime1O5 orientation initialisation parameters struct InitSurferUs1O0Surftimeconst9O0Reorientationtime1O5OrientGroupAllParameters { }; } #endif
30.529412
112
0.895954
[ "object" ]
7bed9f92cd5f135a638065f870669808e91eade4
1,622
h
C
extensions/csa/switch/msaOptions.h
pauladbol/obs-microp4
92e3b53c52c7ebf8787ce2f6a7f946c1b73546ad
[ "Apache-2.0" ]
22
2020-08-03T18:28:39.000Z
2021-09-27T00:25:26.000Z
extensions/csa/switch/msaOptions.h
pauladbol/obs-microp4
92e3b53c52c7ebf8787ce2f6a7f946c1b73546ad
[ "Apache-2.0" ]
null
null
null
extensions/csa/switch/msaOptions.h
pauladbol/obs-microp4
92e3b53c52c7ebf8787ce2f6a7f946c1b73546ad
[ "Apache-2.0" ]
5
2020-08-20T02:53:31.000Z
2021-04-13T23:43:12.000Z
/* * Author: Hardik Soni * Email: hks57@cornell.edu */ #ifndef _EXTENSIONS_CSA_SWITCH_OPTIONS_H_ #define _EXTENSIONS_CSA_SWITCH_OPTIONS_H_ #include <getopt.h> #include "frontends/common/options.h" namespace CSA { class MSAOptions : public CompilerOptions { public: // file to output to cstring outputFile = nullptr; cstring targetArch = nullptr; cstring targetArchP4 = nullptr; std::vector<cstring> inputIRFiles; MSAOptions() { registerOption("-o", "outfile", [this](const char* arg) { outputFile = arg; return true; }, "Write output to outfile"); registerOption("--target-arch", "v1model or tna", [this](const char* arg) { targetArch = arg; return true; }, "Write output to outfile"); registerOption("--target-arch-p4", "absolute file path to .p4", [this](const char* arg) { targetArchP4 = arg; return true; }, "Target Architecture Definitions in P4, if --target-arch == tna, provide location of tna.p4 and put dependent .p4s in p4include directory"); registerOption("-l", "IRFile1[,IRFile2]", [this](const char* arg) { auto copy = strdup(arg); while (auto pass = strsep(&copy, ",")) { inputIRFiles.push_back(pass); } return true; }, "links IRFiles..."); } }; using CSAContext = P4CContextWithOptions<MSAOptions>; }; // namespace CSA #endif /* _EXTENSIONS_CSA_SWITCH_OPTIONS_H_ */
31.192308
156
0.577682
[ "vector" ]
7bfcbc757092a5931972755e8d4d833e3eb32496
4,298
h
C
inc/source_handler.h
Joco223/BVC
a0f2f2cc958dc2a593935137914edaedbb5b6f08
[ "MIT" ]
null
null
null
inc/source_handler.h
Joco223/BVC
a0f2f2cc958dc2a593935137914edaedbb5b6f08
[ "MIT" ]
null
null
null
inc/source_handler.h
Joco223/BVC
a0f2f2cc958dc2a593935137914edaedbb5b6f08
[ "MIT" ]
null
null
null
#pragma once #include <string> #include <iostream> #include <dirent.h> #include <vector> #include <fstream> #include <sys/types.h> #include <sys/stat.h> #include <ctime> #include "picosha2.h" struct config_data { std::vector<std::string> source_paths; std::vector<std::string> ignored_types; std::string destination_path = ""; }; struct file_entry { std::string name, full_path, root_path, hash; long long int creation_time, last_mod_time; long long int size; bool is_directory; std::vector<file_entry> child_files; }; void check_source(const char* path, std::vector<file_entry>& files, int& dir_num, int& file_num, std::vector<std::string>& ignored_types, std::string root_path, bool print) { struct dirent* entry; DIR* dir = opendir(path); if(dir == nullptr) { return; } while((entry = readdir(dir)) != nullptr) { std::string file_name = entry->d_name; if(file_name != "." && file_name != "..") { std::string file_path(path); file_path.append(entry->d_name); struct stat fileInfo; stat(file_path.c_str(), &fileInfo); std::ifstream in(file_path, std::ifstream::ate | std::ifstream::binary); long long int fs = in.tellg(); std::string temp = root_path + file_name; file_entry fe = {file_name, file_path, temp, "", fileInfo.st_ctime, fileInfo.st_mtime, fs, false}; switch(entry->d_type) { case DT_DIR: dir_num++; fe.full_path.append("/"); fe.is_directory = true; if(print) std::cout << "[ LOG ] Scanning path: " << fe.full_path << '\n'; fe.root_path.append("/"); check_source(fe.full_path.c_str(), fe.child_files, dir_num, file_num, ignored_types, fe.root_path, print); files.push_back(fe); break; case DT_REG: { bool ignore = false; for(auto& i : ignored_types) { if(fe.name.substr(fe.name.find_last_of(".") + 1) == i) { ignore = true; break; } } if(!ignore) { file_num++; std::ifstream f(fe.full_path, std::ios::binary); std::vector<unsigned char> s(picosha2::k_digest_size); picosha2::hash256(f, s.begin(), s.end()); std::string ss(s.begin(), s.end()); fe.hash = ss; files.push_back(fe); } break; } default: std::cout << "[WARNING] Unsupported file type - " << entry->d_name << '\n'; } } } closedir(dir); } void check_root(std::string file_path, std::vector<file_entry>& files, int& dir_num, int& file_num, std::vector<std::string>& ignored_types, bool print) { struct stat fileInfo; stat(file_path.c_str(), &fileInfo); std::ifstream in(file_path, std::ifstream::ate | std::ifstream::binary); long long int fs = in.tellg(); std::string name; std::string shortened = file_path.substr(0, file_path.length()-1); if(file_path[file_path.length()-1] == '/') { name = shortened.substr(shortened.find_last_of("/") + 1); }else{ name = file_path.substr(file_path.find_last_of("/") + 1); } file_entry fe = {name, file_path, name+"/", "", fileInfo.st_ctime, fileInfo.st_mtime, fs, false}; dir_num++; fe.is_directory = true; check_source(fe.full_path.c_str(), fe.child_files, dir_num, file_num, ignored_types, fe.root_path, print); files.push_back(fe); } config_data read_config(const char* path) { config_data cd; std::ifstream cFile(path); if(cFile.is_open()) { std::string line; while(getline(cFile, line)) { line.erase(std::remove_if(line.begin(), line.end(), isspace), line.end()); if(line[0] == '#' || line.empty()) continue; auto delimiterPos = line.find("="); auto name = line.substr(0, delimiterPos); auto value = line.substr(delimiterPos + 1); if(name == "source") { cd.source_paths.push_back(value); }else if(name == "destination") { if(cd.destination_path != "") { std::cout << "[WARNING] Destination path already provided, ignoring: " << name << " = " << value << '\n'; }else{ cd.destination_path = value; } }else if(name == "ignored") { cd.ignored_types.push_back(value); std::cout << "[ LOG ] Excluding: ." << value << " types.\n"; }else{ std::cout << "[WARNING] Skipping unkwnon parameter: " << name << " = " << value << '\n'; } } }else{ std::cerr << "[ ERROR ] Couldn't open config file for reading.\n"; } return cd; }
27.202532
174
0.631922
[ "vector" ]
d00a32a45a134da5b76a7061b9d6327ba2071c54
1,567
h
C
Cuda-GPU-Programming-CPP/MatrixMultiplicationGPU/DeviceArray.h
mejanvijay/CUDA-GPU-Programming
6418056acbf24b886407b0b4bcbf599e2cf6502e
[ "MIT" ]
1
2018-05-09T10:17:13.000Z
2018-05-09T10:17:13.000Z
Cuda-GPU-Programming-CPP/MatrixMultiplicationGPU/DeviceArray.h
mejanvijay/CUDA-GPU-Programming
6418056acbf24b886407b0b4bcbf599e2cf6502e
[ "MIT" ]
null
null
null
Cuda-GPU-Programming-CPP/MatrixMultiplicationGPU/DeviceArray.h
mejanvijay/CUDA-GPU-Programming
6418056acbf24b886407b0b4bcbf599e2cf6502e
[ "MIT" ]
null
null
null
#ifndef Device_Array #define Device_Array #include <bits/stdc++.h> #include <cuda_runtime.h> using namespace std; template<class T> class devArray { //private Functions private : void allocate(size_t size) { cudaError_t result = cudaMalloc((void**)&start_, size * sizeof(T)); if (result != cudaSuccess) { start_ = end_ = 0; throw runtime_error("Failed to allocate memory on Device"); } end_ = start_ + size; } void free() { if(start_ != 0) { cudaFree(start_); start_ = end_ = 0; } } //private Data members T* start_; T* end_; //public functions public : // Constructors explicit devArray() : start_(0), end_(0) { } explicit devArray(size_t size) { allocate(size); } // Destructor ~devArray() { free(); } // resize vector void resize(size_t size) { free(); allocate(size); } // get size of vector size_t getSize() const { return end_-start_; } // get Data const T* getData() const { return start_; } T* getData() { return start_; } // set void set(const T* src, size_t size) { size_t min_ = min(size, getSize()); cudaError_t result = cudaMemcpy(start_, src, min_*sizeof(T), cudaMemcpyHostToDevice ); if(result!=cudaSuccess) { throw runtime_error("Failed to copy to device memory."); } } //get void get(T* dest, size_t size) { size_t min_ = min(size, getSize()); cudaError_t result = cudaMemcpy(dest, start_, min_ * sizeof(T), cudaMemcpyDeviceToHost); if(result!=cudaSuccess) { throw runtime_error("Failed to copy to Host memory."); } } }; #endif
15.514851
90
0.649649
[ "vector" ]
d011a229281ff96d5e241dae3558a7dbe2238b1b
4,229
h
C
include/hexabitz/BOSMessage.h
HexabitzPlatform/HF1R0x-Firmware
c13c12e02533fd1955665bcbfef6cd0d9b3b4cbc
[ "MIT" ]
2
2020-03-04T14:44:34.000Z
2021-07-13T05:18:17.000Z
include/hexabitz/BOSMessage.h
HexabitzPlatform/HF1R0x-Firmware
c13c12e02533fd1955665bcbfef6cd0d9b3b4cbc
[ "MIT" ]
null
null
null
include/hexabitz/BOSMessage.h
HexabitzPlatform/HF1R0x-Firmware
c13c12e02533fd1955665bcbfef6cd0d9b3b4cbc
[ "MIT" ]
1
2020-04-05T15:16:26.000Z
2020-04-05T15:16:26.000Z
#ifndef BOSMESSAGE_H #define BOSMESSAGE_H #include "helper/BinaryStream.h" #include "helper/helper.h" #include "hexabitz/BOS.h" #include <stdint.h> #include <stddef.h> #include <stdbool.h> #include <stdarg.h> #include <ctype.h> #include <ostream> #include <iostream> #include <sstream> #include <map> /***********************************************/ // TODO: See if invalidating the object in destructor is good approach namespace hstd { typedef int uid_t; typedef int port_t; struct Addr_t { public: static bool isValidUID(uid_t id) { return id <= MAX_UID and id >= MIN_UID; } static bool isUIDed(uid_t id) { return id <= MAX_UID and id > MIN_UID; } static bool isValidPort(port_t p) { return p <= MAX_PORT and p >= MIN_PORT; } static bool isMaster(uid_t id) { return id == MASTER_UID; } public: bool hasValidUID(void) const { return uid <= MAX_UID and uid >= MIN_UID; } bool hasValidPort(void) const { return port <= MAX_PORT and port >= MIN_PORT; } bool isValid(void) const { return hasValidUID() and hasValidPort(); } bool isMaster(void) const { return uid == MASTER_UID; } public: uid_t getUID(void) const { return uid; } port_t getPort(void) const { return port; } void setUID(uid_t newID) { uid = newID; } void setPort(port_t newPort) { port = newPort; } public: Addr_t& operator=(const Addr_t& other) = default; Addr_t& operator=(Addr_t&& other) = default; public: Addr_t(void): uid(INVALID_UID), port(INVALID_PORT) { } Addr_t(uid_t uidIn): uid(uidIn), port(INVALID_PORT) { } Addr_t(uid_t uidIn, port_t portIn): uid(uidIn), port(portIn) { } Addr_t(const Addr_t& other) = default; Addr_t(Addr_t&& other) = default; ~Addr_t(void) = default; private: uid_t uid; port_t port; public: constexpr static uid_t ACCEPTALL_UID = 0; constexpr static uid_t MASTER_UID = 1; constexpr static uid_t MULTICAST_UID = 254; constexpr static uid_t BROADCAST_UID = 255; public: constexpr static uid_t MAX_UID = 255; constexpr static uid_t MIN_UID = 0; constexpr static port_t MAX_PORT = BOS::MAX_NUM_OF_PORTS; constexpr static port_t MIN_PORT = 1; constexpr static uid_t INVALID_UID = -1; constexpr static port_t INVALID_PORT = -1; }; struct Message { public: const Addr_t& getSource(void) const { return src_; } Addr_t& getSource(void) { return src_; } void setSource(Addr_t newSrc) { src_ = newSrc; } const Addr_t& getDest(void) const { return dest_; } Addr_t& getDest(void) { return dest_; } void setDest(Addr_t newDest) { dest_ = newDest; } uint16_t getCode(void) const { return code_; } void setCode(uint16_t newCode) { code_ = newCode; } void setMessOnlyFlag(bool flag) { setFlag("messonly", flag); } bool getMessOnlyFlag(void) { return getFlag("messonly"); } void setCLIOnlyFlag(bool flag) { setFlag("clionly", flag); } bool getCLIOnlyFlag(void) { return getFlag("clionly"); } void setTraceFlag(bool flag) { setFlag("trace", flag); } bool getTraceFlag(void) { return getFlag("trace"); } BinaryBuffer& getParams(void) { return param_; } const BinaryBuffer& getParams(void) const { return param_; } public: void setFlag(std::string name, bool value); bool getFlag(std::string name); public: void invalidate(void); public: friend std::ostream& operator<<(std::ostream& stream, Message& m) { stream << std::string(m) << std::endl; return stream; } operator std::string(void) { return to_string(); } std::string to_string(void) const; public: Message& operator=(const Message& other) = default; Message& operator=(Message&& other) = default; public: Message(void); Message(Addr_t dest, Addr_t src, uint16_t code); Message(uint8_t dest, uint8_t src, uint16_t code); Message(const Message& other) = default; Message(Message&& other) = default; ~Message(void) = default; private: Addr_t src_; Addr_t dest_; uint16_t code_; BinaryBuffer param_; std::map<std::string, bool> flags_; }; /***********************************************/ bool parseMessage(BinaryBuffer buffer, Message& msg); std::vector<Message> getSanitizedMessages(Message msg); Message buildMessage(uint8_t dst, uint8_t src, BinaryBuffer buffer); } #endif /* BOSMESSAGE_H */
25.172619
82
0.687633
[ "object", "vector" ]
d01609e17e980d6586f0ce3045257be2e1e8783c
836
h
C
aws-cpp-sdk-quicksight/include/aws/quicksight/model/ExceptionResourceType.h
lintonv/aws-sdk-cpp
15e19c265ffce19d2046b18aa1b7307fc5377e58
[ "Apache-2.0" ]
1
2022-02-12T08:09:30.000Z
2022-02-12T08:09:30.000Z
aws-cpp-sdk-quicksight/include/aws/quicksight/model/ExceptionResourceType.h
lintonv/aws-sdk-cpp
15e19c265ffce19d2046b18aa1b7307fc5377e58
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-quicksight/include/aws/quicksight/model/ExceptionResourceType.h
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2021-11-09T12:02:58.000Z
2021-11-09T12:02:58.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/quicksight/QuickSight_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> namespace Aws { namespace QuickSight { namespace Model { enum class ExceptionResourceType { NOT_SET, USER, GROUP, NAMESPACE, ACCOUNT_SETTINGS, IAMPOLICY_ASSIGNMENT, DATA_SOURCE, DATA_SET, VPC_CONNECTION, INGESTION }; namespace ExceptionResourceTypeMapper { AWS_QUICKSIGHT_API ExceptionResourceType GetExceptionResourceTypeForName(const Aws::String& name); AWS_QUICKSIGHT_API Aws::String GetNameForExceptionResourceType(ExceptionResourceType value); } // namespace ExceptionResourceTypeMapper } // namespace Model } // namespace QuickSight } // namespace Aws
21.435897
98
0.760766
[ "model" ]
d017b9c7df1ac356f1fcfeb31fe0fe4c3cfb02d1
6,117
h
C
tensorvis/tensorvisbase/include/inviwo/tensorvisbase/datastructures/hyperstreamlinetracer.h
JochenJankowai/modules
20c5c2df6af4fe5faaa87a9a61432406a6d750e0
[ "BSD-2-Clause" ]
null
null
null
tensorvis/tensorvisbase/include/inviwo/tensorvisbase/datastructures/hyperstreamlinetracer.h
JochenJankowai/modules
20c5c2df6af4fe5faaa87a9a61432406a6d750e0
[ "BSD-2-Clause" ]
null
null
null
tensorvis/tensorvisbase/include/inviwo/tensorvisbase/datastructures/hyperstreamlinetracer.h
JochenJankowai/modules
20c5c2df6af4fe5faaa87a9a61432406a6d750e0
[ "BSD-2-Clause" ]
null
null
null
/********************************************************************************* * * Inviwo - Interactive Visualization Workshop * * Copyright (c) 2016-2020 Inviwo Foundation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *********************************************************************************/ #pragma once #include <inviwo/tensorvisbase/tensorvisbasemoduledefine.h> #include <inviwo/core/common/inviwo.h> #include <modules/vectorfieldvisualization/datastructures/integralline.h> #include <modules/vectorfieldvisualization/properties/integrallineproperties.h> #include <inviwo/core/util/spatialsampler.h> namespace inviwo { namespace detail { template <typename V, typename H, typename M, typename P> P seedTransform(const M &m, const P &pIn) { auto p = m * H(pIn, 1.0f); return P(p) / p[SpatialSampler<3, 3, double>::DataDimensions]; } template <typename SpatialVector, typename DataVector, typename Sampler, typename F, typename DataMatrix> std::tuple<SpatialVector, DataVector, bool> hyperstep(const SpatialVector &oldPos, IntegralLineProperties::IntegrationScheme, F stepSize, const DataMatrix &invBasis, bool normalizeSamples, const Sampler &sampler, const bool prevFlipped) { auto normalize = [](auto v) { auto l = glm::length(v); if (l == 0) return v; return v / l; }; auto move = [&](auto pos, auto v, auto stepsize) { if (normalizeSamples) { v = normalize(v); } auto offset = (invBasis * (v * stepsize)); return pos + offset; }; auto k1 = sampler.sample(oldPos); if (prevFlipped) k1 = -k1; bool flipped{false}; auto k2 = sampler.sample(move(oldPos, k1, stepSize / 2)); if (std::acos(glm::dot(k1, k2) / (glm::length(k1) * glm::length(k2))) < 90) k2 = -k2; auto k3 = sampler.sample(move(oldPos, k2, stepSize / 2)); if (std::acos(glm::dot(k2, k3) / (glm::length(k2) * glm::length(k3))) < 90) k3 = -k3; auto k4 = sampler.sample(move(oldPos, k3, stepSize)); if (std::acos(glm::dot(k3, k4) / (glm::length(k3) * glm::length(k4))) < 90) { k4 = -k4; flipped = true; } auto K = k1 + k2 + k2 + k3 + k3 + k4; if (normalizeSamples) { K = normalize(K); } else { K = K / 6.0; } return {move(oldPos, K, stepSize), k1, flipped}; } } // namespace detail class IVW_MODULE_TENSORVISBASE_API HyperStreamLineTracer { public: struct Result { IntegralLine line; size_t seedIndex{0}; operator IntegralLine() const { return line; } }; /* * Various types used within this class */ using SpatialVector = Vector<SpatialSampler<3, 3, double>::SpatialDimensions, double>; using DataVector = Vector<SpatialSampler<3, 3, double>::DataDimensions, double>; using DataHomogenousVector = Vector<SpatialSampler<3, 3, double>::DataDimensions + 1, double>; using SpatialMatrix = Matrix<SpatialSampler<3, 3, double>::SpatialDimensions, double>; using DataMatrix = Matrix<SpatialSampler<3, 3, double>::DataDimensions, double>; using DataHomogenouSpatialMatrixrix = Matrix<SpatialSampler<3, 3, double>::DataDimensions + 1, double>; HyperStreamLineTracer(std::shared_ptr<const SpatialSampler<3, 3, double>> sampler, const IntegralLineProperties &properties); Result traceFrom(const SpatialVector &pIn); void addMetaDataSampler(const std::string &name, std::shared_ptr<const SpatialSampler<3, 3, double>> sampler); const DataHomogenouSpatialMatrixrix &getSeedTransformationMatrix() const; void setTransformOutputToWorldSpace(bool transform); bool isTransformingOutputToWorldSpace() const; private: bool addPoint(IntegralLine &line, const SpatialVector &pos); bool addPoint(IntegralLine &line, const SpatialVector &pos, const DataVector &worldVelocity); IntegralLine::TerminationReason integrate(size_t steps, SpatialVector pos, IntegralLine &line, bool fwd); IntegralLineProperties::IntegrationScheme integrationScheme_; int steps_; double stepSize_; IntegralLineProperties::Direction dir_; bool normalizeSamples_; std::shared_ptr<const SpatialSampler<3, 3, double>> sampler_; std::unordered_map<std::string, std::shared_ptr<const SpatialSampler<3, 3, double>>> metaSamplers_; DataMatrix invBasis_; DataHomogenouSpatialMatrixrix seedTransformation_; DataHomogenouSpatialMatrixrix toWorld_; bool transformOutputToWorldSpace_; }; } // namespace inviwo
37.993789
100
0.655223
[ "vector", "transform" ]
d02e64d26e0714199cda444549aa058ad00ab47f
84,032
h
C
include/pthreadpool.h
ma5ter/pthreadpool
4b4a8d42fc7d547b32914cfb90cbf5695dbd3267
[ "BSD-2-Clause" ]
241
2015-08-26T17:07:25.000Z
2022-03-19T10:15:16.000Z
include/pthreadpool.h
ma5ter/pthreadpool
4b4a8d42fc7d547b32914cfb90cbf5695dbd3267
[ "BSD-2-Clause" ]
18
2016-10-11T05:36:51.000Z
2022-02-22T05:33:16.000Z
include/pthreadpool.h
ma5ter/pthreadpool
4b4a8d42fc7d547b32914cfb90cbf5695dbd3267
[ "BSD-2-Clause" ]
91
2015-11-25T09:22:50.000Z
2022-03-29T08:31:42.000Z
#ifndef PTHREADPOOL_H_ #define PTHREADPOOL_H_ #include <stddef.h> #include <stdint.h> typedef struct pthreadpool* pthreadpool_t; typedef void (*pthreadpool_task_1d_t)(void*, size_t); typedef void (*pthreadpool_task_1d_tile_1d_t)(void*, size_t, size_t); typedef void (*pthreadpool_task_2d_t)(void*, size_t, size_t); typedef void (*pthreadpool_task_2d_tile_1d_t)(void*, size_t, size_t, size_t); typedef void (*pthreadpool_task_2d_tile_2d_t)(void*, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_3d_t)(void*, size_t, size_t, size_t); typedef void (*pthreadpool_task_3d_tile_1d_t)(void*, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_3d_tile_2d_t)(void*, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_4d_t)(void*, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_4d_tile_1d_t)(void*, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_4d_tile_2d_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_5d_t)(void*, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_5d_tile_1d_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_5d_tile_2d_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_6d_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_6d_tile_1d_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_6d_tile_2d_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_1d_with_id_t)(void*, uint32_t, size_t); typedef void (*pthreadpool_task_2d_tile_2d_with_id_t)(void*, uint32_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_3d_tile_2d_with_id_t)(void*, uint32_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_task_4d_tile_2d_with_id_t)(void*, uint32_t, size_t, size_t, size_t, size_t, size_t, size_t); /** * Disable support for denormalized numbers to the maximum extent possible for * the duration of the computation. * * Handling denormalized floating-point numbers is often implemented in * microcode, and incurs significant performance degradation. This hint * instructs the thread pool to disable support for denormalized numbers before * running the computation by manipulating architecture-specific control * registers, and restore the initial value of control registers after the * computation is complete. The thread pool temporary disables denormalized * numbers on all threads involved in the computation (i.e. the caller threads, * and potentially worker threads). * * Disabling denormalized numbers may have a small negative effect on results' * accuracy. As various architectures differ in capabilities to control * processing of denormalized numbers, using this flag may also hurt results' * reproducibility across different instruction set architectures. */ #define PTHREADPOOL_FLAG_DISABLE_DENORMALS 0x00000001 /** * Yield worker threads to the system scheduler after the operation is finished. * * Force workers to use kernel wait (instead of active spin-wait by default) for * new commands after this command is processed. This flag affects only the * immediate next operation on this thread pool. To make the thread pool always * use kernel wait, pass this flag to all parallelization functions. */ #define PTHREADPOOL_FLAG_YIELD_WORKERS 0x00000002 #ifdef __cplusplus extern "C" { #endif /** * Create a thread pool with the specified number of threads. * * @param threads_count the number of threads in the thread pool. * A value of 0 has special interpretation: it creates a thread pool with as * many threads as there are logical processors in the system. * * @returns A pointer to an opaque thread pool object if the call is * successful, or NULL pointer if the call failed. */ pthreadpool_t pthreadpool_create(size_t threads_count); /** * Query the number of threads in a thread pool. * * @param threadpool the thread pool to query. * * @returns The number of threads in the thread pool. */ size_t pthreadpool_get_threads_count(pthreadpool_t threadpool); /** * Process items on a 1D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range; i++) * function(context, i); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each item. * @param context the first argument passed to the specified function. * @param range the number of items on the 1D grid to process. The * specified function will be called once for each item. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_1d( pthreadpool_t threadpool, pthreadpool_task_1d_t function, void* context, size_t range, uint32_t flags); /** * Process items on a 1D grid using a microarchitecture-aware task function. * * The function implements a parallel version of the following snippet: * * uint32_t uarch_index = cpuinfo_initialize() ? * cpuinfo_get_current_uarch_index() : default_uarch_index; * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; * for (size_t i = 0; i < range; i++) * function(context, uarch_index, i); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If * threadpool is NULL, all items are processed serially on the calling * thread. * @param function the function to call for each item. * @param context the first argument passed to the specified * function. * @param default_uarch_index the microarchitecture index to use when * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, * or index returned by cpuinfo_get_current_uarch_index() exceeds the * max_uarch_index value. * @param max_uarch_index the maximum microarchitecture index expected by * the specified function. If the index returned by * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index * will be used instead. default_uarch_index can exceed max_uarch_index. * @param range the number of items on the 1D grid to process. * The specified function will be called once for each item. * @param flags a bitwise combination of zero or more optional * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or * PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_1d_with_uarch( pthreadpool_t threadpool, pthreadpool_task_1d_with_id_t function, void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range, uint32_t flags); /** * Process items on a 1D grid with specified maximum tile size. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range; i += tile) * function(context, i, min(range - i, tile)); * * When the call returns, all items have been processed and the thread pool is * ready for a new task. * * @note If multiple threads call this function with the same thread pool, * the calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range the number of items on the 1D grid to process. * @param tile the maximum number of items on the 1D grid to process in * one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_1d_tile_1d( pthreadpool_t threadpool, pthreadpool_task_1d_tile_1d_t function, void* context, size_t range, size_t tile, uint32_t flags); /** * Process items on a 2D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * function(context, i, j); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each item. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 2D grid. * @param range_j the number of items to process along the second dimension * of the 2D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_2d( pthreadpool_t threadpool, pthreadpool_task_2d_t function, void* context, size_t range_i, size_t range_j, uint32_t flags); /** * Process items on a 2D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j += tile_j) * function(context, i, j, min(range_j - j, tile_j)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 2D grid. * @param range_j the number of items to process along the second dimension * of the 2D grid. * @param tile_j the maximum number of items along the second dimension of * the 2D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_2d_tile_1d( pthreadpool_t threadpool, pthreadpool_task_2d_tile_1d_t function, void* context, size_t range_i, size_t range_j, size_t tile_j, uint32_t flags); /** * Process items on a 2D grid with the specified maximum tile size along each * grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i += tile_i) * for (size_t j = 0; j < range_j; j += tile_j) * function(context, i, j, * min(range_i - i, tile_i), min(range_j - j, tile_j)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 2D grid. * @param range_j the number of items to process along the second dimension * of the 2D grid. * @param tile_j the maximum number of items along the first dimension of * the 2D grid to process in one function call. * @param tile_j the maximum number of items along the second dimension of * the 2D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_2d_tile_2d( pthreadpool_t threadpool, pthreadpool_task_2d_tile_2d_t function, void* context, size_t range_i, size_t range_j, size_t tile_i, size_t tile_j, uint32_t flags); /** * Process items on a 2D grid with the specified maximum tile size along each * grid dimension using a microarchitecture-aware task function. * * The function implements a parallel version of the following snippet: * * uint32_t uarch_index = cpuinfo_initialize() ? * cpuinfo_get_current_uarch_index() : default_uarch_index; * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; * for (size_t i = 0; i < range_i; i += tile_i) * for (size_t j = 0; j < range_j; j += tile_j) * function(context, uarch_index, i, j, * min(range_i - i, tile_i), min(range_j - j, tile_j)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If * threadpool is NULL, all items are processed serially on the calling * thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified * function. * @param default_uarch_index the microarchitecture index to use when * pthreadpool is configured without cpuinfo, * cpuinfo initialization failed, or index returned * by cpuinfo_get_current_uarch_index() exceeds * the max_uarch_index value. * @param max_uarch_index the maximum microarchitecture index expected * by the specified function. If the index returned * by cpuinfo_get_current_uarch_index() exceeds this * value, default_uarch_index will be used instead. * default_uarch_index can exceed max_uarch_index. * @param range_i the number of items to process along the first * dimension of the 2D grid. * @param range_j the number of items to process along the second * dimension of the 2D grid. * @param tile_j the maximum number of items along the first * dimension of the 2D grid to process in one function call. * @param tile_j the maximum number of items along the second * dimension of the 2D grid to process in one function call. * @param flags a bitwise combination of zero or more optional * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or * PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_2d_tile_2d_with_uarch( pthreadpool_t threadpool, pthreadpool_task_2d_tile_2d_with_id_t function, void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, size_t range_j, size_t tile_i, size_t tile_j, uint32_t flags); /** * Process items on a 3D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * function(context, i, j, k); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 3D grid. * @param range_j the number of items to process along the second dimension * of the 3D grid. * @param range_k the number of items to process along the third dimension * of the 3D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_3d( pthreadpool_t threadpool, pthreadpool_task_3d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, uint32_t flags); /** * Process items on a 3D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k += tile_k) * function(context, i, j, k, min(range_k - k, tile_k)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 3D grid. * @param range_j the number of items to process along the second dimension * of the 3D grid. * @param range_k the number of items to process along the third dimension * of the 3D grid. * @param tile_k the maximum number of items along the third dimension of * the 3D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_3d_tile_1d( pthreadpool_t threadpool, pthreadpool_task_3d_tile_1d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t tile_k, uint32_t flags); /** * Process items on a 3D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j += tile_j) * for (size_t k = 0; k < range_k; k += tile_k) * function(context, i, j, k, * min(range_j - j, tile_j), min(range_k - k, tile_k)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 3D grid. * @param range_j the number of items to process along the second dimension * of the 3D grid. * @param range_k the number of items to process along the third dimension * of the 3D grid. * @param tile_j the maximum number of items along the second dimension of * the 3D grid to process in one function call. * @param tile_k the maximum number of items along the third dimension of * the 3D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_3d_tile_2d( pthreadpool_t threadpool, pthreadpool_task_3d_tile_2d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t tile_j, size_t tile_k, uint32_t flags); /** * Process items on a 3D grid with the specified maximum tile size along the * last two grid dimensions using a microarchitecture-aware task function. * * The function implements a parallel version of the following snippet: * * uint32_t uarch_index = cpuinfo_initialize() ? * cpuinfo_get_current_uarch_index() : default_uarch_index; * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j += tile_j) * for (size_t k = 0; k < range_k; k += tile_k) * function(context, uarch_index, i, j, k, * min(range_j - j, tile_j), min(range_k - k, tile_k)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If * threadpool is NULL, all items are processed serially on the calling * thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified * function. * @param default_uarch_index the microarchitecture index to use when * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, * or index returned by cpuinfo_get_current_uarch_index() exceeds the * max_uarch_index value. * @param max_uarch_index the maximum microarchitecture index expected by * the specified function. If the index returned by * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index * will be used instead. default_uarch_index can exceed max_uarch_index. * @param range_i the number of items to process along the first * dimension of the 3D grid. * @param range_j the number of items to process along the second * dimension of the 3D grid. * @param range_k the number of items to process along the third * dimension of the 3D grid. * @param tile_j the maximum number of items along the second * dimension of the 3D grid to process in one function call. * @param tile_k the maximum number of items along the third * dimension of the 3D grid to process in one function call. * @param flags a bitwise combination of zero or more optional * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or * PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_3d_tile_2d_with_uarch( pthreadpool_t threadpool, pthreadpool_task_3d_tile_2d_with_id_t function, void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, size_t range_j, size_t range_k, size_t tile_j, size_t tile_k, uint32_t flags); /** * Process items on a 4D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * function(context, i, j, k, l); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 4D grid. * @param range_j the number of items to process along the second dimension * of the 4D grid. * @param range_k the number of items to process along the third dimension * of the 4D grid. * @param range_l the number of items to process along the fourth dimension * of the 4D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_4d( pthreadpool_t threadpool, pthreadpool_task_4d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, uint32_t flags); /** * Process items on a 4D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l += tile_l) * function(context, i, j, k, l, min(range_l - l, tile_l)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 4D grid. * @param range_j the number of items to process along the second dimension * of the 4D grid. * @param range_k the number of items to process along the third dimension * of the 4D grid. * @param range_l the number of items to process along the fourth dimension * of the 4D grid. * @param tile_l the maximum number of items along the fourth dimension of * the 4D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_4d_tile_1d( pthreadpool_t threadpool, pthreadpool_task_4d_tile_1d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t tile_l, uint32_t flags); /** * Process items on a 4D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k += tile_k) * for (size_t l = 0; l < range_l; l += tile_l) * function(context, i, j, k, l, * min(range_k - k, tile_k), min(range_l - l, tile_l)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 4D grid. * @param range_j the number of items to process along the second dimension * of the 4D grid. * @param range_k the number of items to process along the third dimension * of the 4D grid. * @param range_l the number of items to process along the fourth dimension * of the 4D grid. * @param tile_k the maximum number of items along the third dimension of * the 4D grid to process in one function call. * @param tile_l the maximum number of items along the fourth dimension of * the 4D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_4d_tile_2d( pthreadpool_t threadpool, pthreadpool_task_4d_tile_2d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t tile_k, size_t tile_l, uint32_t flags); /** * Process items on a 4D grid with the specified maximum tile size along the * last two grid dimensions using a microarchitecture-aware task function. * * The function implements a parallel version of the following snippet: * * uint32_t uarch_index = cpuinfo_initialize() ? * cpuinfo_get_current_uarch_index() : default_uarch_index; * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k += tile_k) * for (size_t l = 0; l < range_l; l += tile_l) * function(context, uarch_index, i, j, k, l, * min(range_k - k, tile_k), min(range_l - l, tile_l)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If * threadpool is NULL, all items are processed serially on the calling * thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified * function. * @param default_uarch_index the microarchitecture index to use when * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, * or index returned by cpuinfo_get_current_uarch_index() exceeds the * max_uarch_index value. * @param max_uarch_index the maximum microarchitecture index expected by * the specified function. If the index returned by * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index * will be used instead. default_uarch_index can exceed max_uarch_index. * @param range_i the number of items to process along the first * dimension of the 4D grid. * @param range_j the number of items to process along the second * dimension of the 4D grid. * @param range_k the number of items to process along the third * dimension of the 4D grid. * @param range_l the number of items to process along the fourth * dimension of the 4D grid. * @param tile_k the maximum number of items along the third * dimension of the 4D grid to process in one function call. * @param tile_l the maximum number of items along the fourth * dimension of the 4D grid to process in one function call. * @param flags a bitwise combination of zero or more optional * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or * PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_4d_tile_2d_with_uarch( pthreadpool_t threadpool, pthreadpool_task_4d_tile_2d_with_id_t function, void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t tile_k, size_t tile_l, uint32_t flags); /** * Process items on a 5D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m++) * function(context, i, j, k, l, m); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 5D grid. * @param range_j the number of items to process along the second dimension * of the 5D grid. * @param range_k the number of items to process along the third dimension * of the 5D grid. * @param range_l the number of items to process along the fourth dimension * of the 5D grid. * @param range_m the number of items to process along the fifth dimension * of the 5D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_5d( pthreadpool_t threadpool, pthreadpool_task_5d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, uint32_t flags); /** * Process items on a 5D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m += tile_m) * function(context, i, j, k, l, m, min(range_m - m, tile_m)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 5D grid. * @param range_j the number of items to process along the second dimension * of the 5D grid. * @param range_k the number of items to process along the third dimension * of the 5D grid. * @param range_l the number of items to process along the fourth dimension * of the 5D grid. * @param range_m the number of items to process along the fifth dimension * of the 5D grid. * @param tile_m the maximum number of items along the fifth dimension of * the 5D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_5d_tile_1d( pthreadpool_t threadpool, pthreadpool_task_5d_tile_1d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t tile_m, uint32_t flags); /** * Process items on a 5D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l += tile_l) * for (size_t m = 0; m < range_m; m += tile_m) * function(context, i, j, k, l, m, * min(range_l - l, tile_l), min(range_m - m, tile_m)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 5D grid. * @param range_j the number of items to process along the second dimension * of the 5D grid. * @param range_k the number of items to process along the third dimension * of the 5D grid. * @param range_l the number of items to process along the fourth dimension * of the 5D grid. * @param range_m the number of items to process along the fifth dimension * of the 5D grid. * @param tile_l the maximum number of items along the fourth dimension of * the 5D grid to process in one function call. * @param tile_m the maximum number of items along the fifth dimension of * the 5D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_5d_tile_2d( pthreadpool_t threadpool, pthreadpool_task_5d_tile_2d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t tile_l, size_t tile_m, uint32_t flags); /** * Process items on a 6D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m++) * for (size_t n = 0; n < range_n; n++) * function(context, i, j, k, l, m, n); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 6D grid. * @param range_j the number of items to process along the second dimension * of the 6D grid. * @param range_k the number of items to process along the third dimension * of the 6D grid. * @param range_l the number of items to process along the fourth dimension * of the 6D grid. * @param range_m the number of items to process along the fifth dimension * of the 6D grid. * @param range_n the number of items to process along the sixth dimension * of the 6D grid. * @param tile_n the maximum number of items along the sixth dimension of * the 6D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_6d( pthreadpool_t threadpool, pthreadpool_task_6d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t range_n, uint32_t flags); /** * Process items on a 6D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m++) * for (size_t n = 0; n < range_n; n += tile_n) * function(context, i, j, k, l, m, n, min(range_n - n, tile_n)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 6D grid. * @param range_j the number of items to process along the second dimension * of the 6D grid. * @param range_k the number of items to process along the third dimension * of the 6D grid. * @param range_l the number of items to process along the fourth dimension * of the 6D grid. * @param range_m the number of items to process along the fifth dimension * of the 6D grid. * @param range_n the number of items to process along the sixth dimension * of the 6D grid. * @param tile_n the maximum number of items along the sixth dimension of * the 6D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_6d_tile_1d( pthreadpool_t threadpool, pthreadpool_task_6d_tile_1d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t range_n, size_t tile_n, uint32_t flags); /** * Process items on a 6D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m += tile_m) * for (size_t n = 0; n < range_n; n += tile_n) * function(context, i, j, k, l, m, n, * min(range_m - m, tile_m), min(range_n - n, tile_n)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param function the function to call for each tile. * @param context the first argument passed to the specified function. * @param range_i the number of items to process along the first dimension * of the 6D grid. * @param range_j the number of items to process along the second dimension * of the 6D grid. * @param range_k the number of items to process along the third dimension * of the 6D grid. * @param range_l the number of items to process along the fourth dimension * of the 6D grid. * @param range_m the number of items to process along the fifth dimension * of the 6D grid. * @param range_n the number of items to process along the sixth dimension * of the 6D grid. * @param tile_m the maximum number of items along the fifth dimension of * the 6D grid to process in one function call. * @param tile_n the maximum number of items along the sixth dimension of * the 6D grid to process in one function call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ void pthreadpool_parallelize_6d_tile_2d( pthreadpool_t threadpool, pthreadpool_task_6d_tile_2d_t function, void* context, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t range_n, size_t tile_m, size_t tile_n, uint32_t flags); /** * Terminates threads in the thread pool and releases associated resources. * * @warning Accessing the thread pool after a call to this function constitutes * undefined behaviour and may cause data corruption. * * @param[in,out] threadpool The thread pool to destroy. */ void pthreadpool_destroy(pthreadpool_t threadpool); #ifndef PTHREADPOOL_NO_DEPRECATED_API /* Legacy API for compatibility with pre-existing users (e.g. NNPACK) */ #if defined(__GNUC__) #define PTHREADPOOL_DEPRECATED __attribute__((__deprecated__)) #else #define PTHREADPOOL_DEPRECATED #endif typedef void (*pthreadpool_function_1d_t)(void*, size_t); typedef void (*pthreadpool_function_1d_tiled_t)(void*, size_t, size_t); typedef void (*pthreadpool_function_2d_t)(void*, size_t, size_t); typedef void (*pthreadpool_function_2d_tiled_t)(void*, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_function_3d_tiled_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t); typedef void (*pthreadpool_function_4d_tiled_t)(void*, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t); void pthreadpool_compute_1d( pthreadpool_t threadpool, pthreadpool_function_1d_t function, void* argument, size_t range) PTHREADPOOL_DEPRECATED; void pthreadpool_compute_1d_tiled( pthreadpool_t threadpool, pthreadpool_function_1d_tiled_t function, void* argument, size_t range, size_t tile) PTHREADPOOL_DEPRECATED; void pthreadpool_compute_2d( pthreadpool_t threadpool, pthreadpool_function_2d_t function, void* argument, size_t range_i, size_t range_j) PTHREADPOOL_DEPRECATED; void pthreadpool_compute_2d_tiled( pthreadpool_t threadpool, pthreadpool_function_2d_tiled_t function, void* argument, size_t range_i, size_t range_j, size_t tile_i, size_t tile_j) PTHREADPOOL_DEPRECATED; void pthreadpool_compute_3d_tiled( pthreadpool_t threadpool, pthreadpool_function_3d_tiled_t function, void* argument, size_t range_i, size_t range_j, size_t range_k, size_t tile_i, size_t tile_j, size_t tile_k) PTHREADPOOL_DEPRECATED; void pthreadpool_compute_4d_tiled( pthreadpool_t threadpool, pthreadpool_function_4d_tiled_t function, void* argument, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t tile_i, size_t tile_j, size_t tile_k, size_t tile_l) PTHREADPOOL_DEPRECATED; #endif /* PTHREADPOOL_NO_DEPRECATED_API */ #ifdef __cplusplus } /* extern "C" */ #endif #ifdef __cplusplus namespace libpthreadpool { namespace detail { namespace { template<class T> void call_wrapper_1d(void* arg, size_t i) { (*static_cast<const T*>(arg))(i); } template<class T> void call_wrapper_1d_tile_1d(void* arg, size_t range_i, size_t tile_i) { (*static_cast<const T*>(arg))(range_i, tile_i); } template<class T> void call_wrapper_2d(void* functor, size_t i, size_t j) { (*static_cast<const T*>(functor))(i, j); } template<class T> void call_wrapper_2d_tile_1d(void* functor, size_t i, size_t range_j, size_t tile_j) { (*static_cast<const T*>(functor))(i, range_j, tile_j); } template<class T> void call_wrapper_2d_tile_2d(void* functor, size_t range_i, size_t range_j, size_t tile_i, size_t tile_j) { (*static_cast<const T*>(functor))(range_i, range_j, tile_i, tile_j); } template<class T> void call_wrapper_3d(void* functor, size_t i, size_t j, size_t k) { (*static_cast<const T*>(functor))(i, j, k); } template<class T> void call_wrapper_3d_tile_1d(void* functor, size_t i, size_t j, size_t range_k, size_t tile_k) { (*static_cast<const T*>(functor))(i, j, range_k, tile_k); } template<class T> void call_wrapper_3d_tile_2d(void* functor, size_t i, size_t range_j, size_t range_k, size_t tile_j, size_t tile_k) { (*static_cast<const T*>(functor))(i, range_j, range_k, tile_j, tile_k); } template<class T> void call_wrapper_4d(void* functor, size_t i, size_t j, size_t k, size_t l) { (*static_cast<const T*>(functor))(i, j, k, l); } template<class T> void call_wrapper_4d_tile_1d(void* functor, size_t i, size_t j, size_t k, size_t range_l, size_t tile_l) { (*static_cast<const T*>(functor))(i, j, k, range_l, tile_l); } template<class T> void call_wrapper_4d_tile_2d(void* functor, size_t i, size_t j, size_t range_k, size_t range_l, size_t tile_k, size_t tile_l) { (*static_cast<const T*>(functor))(i, j, range_k, range_l, tile_k, tile_l); } template<class T> void call_wrapper_5d(void* functor, size_t i, size_t j, size_t k, size_t l, size_t m) { (*static_cast<const T*>(functor))(i, j, k, l, m); } template<class T> void call_wrapper_5d_tile_1d(void* functor, size_t i, size_t j, size_t k, size_t l, size_t range_m, size_t tile_m) { (*static_cast<const T*>(functor))(i, j, k, l, range_m, tile_m); } template<class T> void call_wrapper_5d_tile_2d(void* functor, size_t i, size_t j, size_t k, size_t range_l, size_t range_m, size_t tile_l, size_t tile_m) { (*static_cast<const T*>(functor))(i, j, k, range_l, range_m, tile_l, tile_m); } template<class T> void call_wrapper_6d(void* functor, size_t i, size_t j, size_t k, size_t l, size_t m, size_t n) { (*static_cast<const T*>(functor))(i, j, k, l, m, n); } template<class T> void call_wrapper_6d_tile_1d(void* functor, size_t i, size_t j, size_t k, size_t l, size_t m, size_t range_n, size_t tile_n) { (*static_cast<const T*>(functor))(i, j, k, l, m, range_n, tile_n); } template<class T> void call_wrapper_6d_tile_2d(void* functor, size_t i, size_t j, size_t k, size_t l, size_t range_m, size_t range_n, size_t tile_m, size_t tile_n) { (*static_cast<const T*>(functor))(i, j, k, l, range_m, range_n, tile_m, tile_n); } } /* namespace */ } /* namespace detail */ } /* namespace libpthreadpool */ /** * Process items on a 1D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range; i++) * functor(i); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each item. * @param range the number of items on the 1D grid to process. The * specified functor will be called once for each item. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_1d( pthreadpool_t threadpool, const T& functor, size_t range, uint32_t flags = 0) { pthreadpool_parallelize_1d( threadpool, &libpthreadpool::detail::call_wrapper_1d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range, flags); } /** * Process items on a 1D grid with specified maximum tile size. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range; i += tile) * functor(i, min(range - i, tile)); * * When the call returns, all items have been processed and the thread pool is * ready for a new task. * * @note If multiple threads call this function with the same thread pool, * the calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range the number of items on the 1D grid to process. * @param tile the maximum number of items on the 1D grid to process in * one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_1d_tile_1d( pthreadpool_t threadpool, const T& functor, size_t range, size_t tile, uint32_t flags = 0) { pthreadpool_parallelize_1d_tile_1d( threadpool, &libpthreadpool::detail::call_wrapper_1d_tile_1d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range, tile, flags); } /** * Process items on a 2D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * functor(i, j); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each item. * @param range_i the number of items to process along the first dimension * of the 2D grid. * @param range_j the number of items to process along the second dimension * of the 2D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_2d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, uint32_t flags = 0) { pthreadpool_parallelize_2d( threadpool, &libpthreadpool::detail::call_wrapper_2d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, flags); } /** * Process items on a 2D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j += tile_j) * functor(i, j, min(range_j - j, tile_j)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 2D grid. * @param range_j the number of items to process along the second dimension * of the 2D grid. * @param tile_j the maximum number of items along the second dimension of * the 2D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_2d_tile_1d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t tile_j, uint32_t flags = 0) { pthreadpool_parallelize_2d_tile_1d( threadpool, &libpthreadpool::detail::call_wrapper_2d_tile_1d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, tile_j, flags); } /** * Process items on a 2D grid with the specified maximum tile size along each * grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i += tile_i) * for (size_t j = 0; j < range_j; j += tile_j) * functor(i, j, * min(range_i - i, tile_i), min(range_j - j, tile_j)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 2D grid. * @param range_j the number of items to process along the second dimension * of the 2D grid. * @param tile_j the maximum number of items along the first dimension of * the 2D grid to process in one functor call. * @param tile_j the maximum number of items along the second dimension of * the 2D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_2d_tile_2d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t tile_i, size_t tile_j, uint32_t flags = 0) { pthreadpool_parallelize_2d_tile_2d( threadpool, &libpthreadpool::detail::call_wrapper_2d_tile_2d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, tile_i, tile_j, flags); } /** * Process items on a 3D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * functor(i, j, k); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 3D grid. * @param range_j the number of items to process along the second dimension * of the 3D grid. * @param range_k the number of items to process along the third dimension * of the 3D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_3d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, uint32_t flags = 0) { pthreadpool_parallelize_3d( threadpool, &libpthreadpool::detail::call_wrapper_3d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, flags); } /** * Process items on a 3D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k += tile_k) * functor(i, j, k, min(range_k - k, tile_k)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 3D grid. * @param range_j the number of items to process along the second dimension * of the 3D grid. * @param range_k the number of items to process along the third dimension * of the 3D grid. * @param tile_k the maximum number of items along the third dimension of * the 3D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_3d_tile_1d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t tile_k, uint32_t flags = 0) { pthreadpool_parallelize_3d_tile_1d( threadpool, &libpthreadpool::detail::call_wrapper_3d_tile_1d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, tile_k, flags); } /** * Process items on a 3D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j += tile_j) * for (size_t k = 0; k < range_k; k += tile_k) * functor(i, j, k, * min(range_j - j, tile_j), min(range_k - k, tile_k)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 3D grid. * @param range_j the number of items to process along the second dimension * of the 3D grid. * @param range_k the number of items to process along the third dimension * of the 3D grid. * @param tile_j the maximum number of items along the second dimension of * the 3D grid to process in one functor call. * @param tile_k the maximum number of items along the third dimension of * the 3D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_3d_tile_2d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t tile_j, size_t tile_k, uint32_t flags = 0) { pthreadpool_parallelize_3d_tile_2d( threadpool, &libpthreadpool::detail::call_wrapper_3d_tile_2d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, tile_j, tile_k, flags); } /** * Process items on a 4D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * functor(i, j, k, l); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 4D grid. * @param range_j the number of items to process along the second dimension * of the 4D grid. * @param range_k the number of items to process along the third dimension * of the 4D grid. * @param range_l the number of items to process along the fourth dimension * of the 4D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_4d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, uint32_t flags = 0) { pthreadpool_parallelize_4d( threadpool, &libpthreadpool::detail::call_wrapper_4d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, flags); } /** * Process items on a 4D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l += tile_l) * functor(i, j, k, l, min(range_l - l, tile_l)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 4D grid. * @param range_j the number of items to process along the second dimension * of the 4D grid. * @param range_k the number of items to process along the third dimension * of the 4D grid. * @param range_l the number of items to process along the fourth dimension * of the 4D grid. * @param tile_l the maximum number of items along the fourth dimension of * the 4D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_4d_tile_1d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t tile_l, uint32_t flags = 0) { pthreadpool_parallelize_4d_tile_1d( threadpool, &libpthreadpool::detail::call_wrapper_4d_tile_1d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, tile_l, flags); } /** * Process items on a 4D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k += tile_k) * for (size_t l = 0; l < range_l; l += tile_l) * functor(i, j, k, l, * min(range_k - k, tile_k), min(range_l - l, tile_l)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 4D grid. * @param range_j the number of items to process along the second dimension * of the 4D grid. * @param range_k the number of items to process along the third dimension * of the 4D grid. * @param range_l the number of items to process along the fourth dimension * of the 4D grid. * @param tile_k the maximum number of items along the third dimension of * the 4D grid to process in one functor call. * @param tile_l the maximum number of items along the fourth dimension of * the 4D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_4d_tile_2d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t tile_k, size_t tile_l, uint32_t flags = 0) { pthreadpool_parallelize_4d_tile_2d( threadpool, &libpthreadpool::detail::call_wrapper_4d_tile_2d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, tile_k, tile_l, flags); } /** * Process items on a 5D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m++) * functor(i, j, k, l, m); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 5D grid. * @param range_j the number of items to process along the second dimension * of the 5D grid. * @param range_k the number of items to process along the third dimension * of the 5D grid. * @param range_l the number of items to process along the fourth dimension * of the 5D grid. * @param range_m the number of items to process along the fifth dimension * of the 5D grid. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_5d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, uint32_t flags = 0) { pthreadpool_parallelize_5d( threadpool, &libpthreadpool::detail::call_wrapper_5d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, range_m, flags); } /** * Process items on a 5D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m += tile_m) * functor(i, j, k, l, m, min(range_m - m, tile_m)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 5D grid. * @param range_j the number of items to process along the second dimension * of the 5D grid. * @param range_k the number of items to process along the third dimension * of the 5D grid. * @param range_l the number of items to process along the fourth dimension * of the 5D grid. * @param range_m the number of items to process along the fifth dimension * of the 5D grid. * @param tile_m the maximum number of items along the fifth dimension of * the 5D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_5d_tile_1d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t tile_m, uint32_t flags = 0) { pthreadpool_parallelize_5d_tile_1d( threadpool, &libpthreadpool::detail::call_wrapper_5d_tile_1d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, range_m, tile_m, flags); } /** * Process items on a 5D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l += tile_l) * for (size_t m = 0; m < range_m; m += tile_m) * functor(i, j, k, l, m, * min(range_l - l, tile_l), min(range_m - m, tile_m)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 5D grid. * @param range_j the number of items to process along the second dimension * of the 5D grid. * @param range_k the number of items to process along the third dimension * of the 5D grid. * @param range_l the number of items to process along the fourth dimension * of the 5D grid. * @param range_m the number of items to process along the fifth dimension * of the 5D grid. * @param tile_l the maximum number of items along the fourth dimension of * the 5D grid to process in one functor call. * @param tile_m the maximum number of items along the fifth dimension of * the 5D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_5d_tile_2d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t tile_l, size_t tile_m, uint32_t flags = 0) { pthreadpool_parallelize_5d_tile_2d( threadpool, &libpthreadpool::detail::call_wrapper_5d_tile_2d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, range_m, tile_l, tile_m, flags); } /** * Process items on a 6D grid. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m++) * for (size_t n = 0; n < range_n; n++) * functor(i, j, k, l, m, n); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 6D grid. * @param range_j the number of items to process along the second dimension * of the 6D grid. * @param range_k the number of items to process along the third dimension * of the 6D grid. * @param range_l the number of items to process along the fourth dimension * of the 6D grid. * @param range_m the number of items to process along the fifth dimension * of the 6D grid. * @param range_n the number of items to process along the sixth dimension * of the 6D grid. * @param tile_n the maximum number of items along the sixth dimension of * the 6D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_6d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t range_n, uint32_t flags = 0) { pthreadpool_parallelize_6d( threadpool, &libpthreadpool::detail::call_wrapper_6d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, range_m, range_n, flags); } /** * Process items on a 6D grid with the specified maximum tile size along the * last grid dimension. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m++) * for (size_t n = 0; n < range_n; n += tile_n) * functor(i, j, k, l, m, n, min(range_n - n, tile_n)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 6D grid. * @param range_j the number of items to process along the second dimension * of the 6D grid. * @param range_k the number of items to process along the third dimension * of the 6D grid. * @param range_l the number of items to process along the fourth dimension * of the 6D grid. * @param range_m the number of items to process along the fifth dimension * of the 6D grid. * @param range_n the number of items to process along the sixth dimension * of the 6D grid. * @param tile_n the maximum number of items along the sixth dimension of * the 6D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_6d_tile_1d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t range_n, size_t tile_n, uint32_t flags = 0) { pthreadpool_parallelize_6d_tile_1d( threadpool, &libpthreadpool::detail::call_wrapper_6d_tile_1d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, range_m, range_n, tile_n, flags); } /** * Process items on a 6D grid with the specified maximum tile size along the * last two grid dimensions. * * The function implements a parallel version of the following snippet: * * for (size_t i = 0; i < range_i; i++) * for (size_t j = 0; j < range_j; j++) * for (size_t k = 0; k < range_k; k++) * for (size_t l = 0; l < range_l; l++) * for (size_t m = 0; m < range_m; m += tile_m) * for (size_t n = 0; n < range_n; n += tile_n) * functor(i, j, k, l, m, n, * min(range_m - m, tile_m), min(range_n - n, tile_n)); * * When the function returns, all items have been processed and the thread pool * is ready for a new task. * * @note If multiple threads call this function with the same thread pool, the * calls are serialized. * * @param threadpool the thread pool to use for parallelisation. If threadpool * is NULL, all items are processed serially on the calling thread. * @param functor the functor to call for each tile. * @param range_i the number of items to process along the first dimension * of the 6D grid. * @param range_j the number of items to process along the second dimension * of the 6D grid. * @param range_k the number of items to process along the third dimension * of the 6D grid. * @param range_l the number of items to process along the fourth dimension * of the 6D grid. * @param range_m the number of items to process along the fifth dimension * of the 6D grid. * @param range_n the number of items to process along the sixth dimension * of the 6D grid. * @param tile_m the maximum number of items along the fifth dimension of * the 6D grid to process in one functor call. * @param tile_n the maximum number of items along the sixth dimension of * the 6D grid to process in one functor call. * @param flags a bitwise combination of zero or more optional flags * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) */ template<class T> inline void pthreadpool_parallelize_6d_tile_2d( pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, size_t range_k, size_t range_l, size_t range_m, size_t range_n, size_t tile_m, size_t tile_n, uint32_t flags = 0) { pthreadpool_parallelize_6d_tile_2d( threadpool, &libpthreadpool::detail::call_wrapper_6d_tile_2d<const T>, const_cast<void*>(static_cast<const void*>(&functor)), range_i, range_j, range_k, range_l, range_m, range_n, tile_m, tile_n, flags); } #endif /* __cplusplus */ #endif /* PTHREADPOOL_H_ */
37.818182
119
0.701126
[ "object", "3d" ]
d0328864c924baad16ceaa0eeecfda503fbd1a4c
12,285
h
C
webkit/WebCore/css/CSSParser.h
s1rcheese/nintendo-3ds-internetbrowser-sourcecode
3dd05f035e0a5fc9723300623e9b9b359be64e11
[ "Unlicense" ]
15
2016-01-05T12:43:41.000Z
2022-03-15T10:34:47.000Z
webkit/WebCore/css/CSSParser.h
s1rcheese/nintendo-3ds-internetbrowser-sourcecode
3dd05f035e0a5fc9723300623e9b9b359be64e11
[ "Unlicense" ]
null
null
null
webkit/WebCore/css/CSSParser.h
s1rcheese/nintendo-3ds-internetbrowser-sourcecode
3dd05f035e0a5fc9723300623e9b9b359be64e11
[ "Unlicense" ]
2
2020-11-30T18:36:01.000Z
2021-02-05T23:20:24.000Z
/* * Copyright (C) 2003 Lars Knoll (knoll@kde.org) * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Eric Seidel <eric@webkit.org> * * This library 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. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef CSSParser_h #define CSSParser_h #include "AtomicString.h" #include "Color.h" #include "CSSParserValues.h" #include "CSSSelectorList.h" #include "MediaQuery.h" #include <wtf/HashSet.h> #include <wtf/Vector.h> namespace WebCore { class CSSMutableStyleDeclaration; class CSSPrimitiveValue; class CSSProperty; class CSSRule; class CSSRuleList; class CSSSelector; class CSSStyleSheet; class CSSValue; class CSSValueList; class CSSVariablesDeclaration; class Document; class MediaList; class MediaQueryExp; class StyleBase; class StyleList; class WebKitCSSKeyframeRule; class WebKitCSSKeyframesRule; class CSSParser { public: CSSParser(bool strictParsing = true); ~CSSParser(); void parseSheet(CSSStyleSheet*, const String&); PassRefPtr<CSSRule> parseRule(CSSStyleSheet*, const String&); PassRefPtr<CSSRule> parseKeyframeRule(CSSStyleSheet*, const String&); bool parseValue(CSSMutableStyleDeclaration*, int propId, const String&, bool important); static bool parseColor(RGBA32& color, const String&, bool strict = false); bool parseColor(CSSMutableStyleDeclaration*, const String&); bool parseDeclaration(CSSMutableStyleDeclaration*, const String&); bool parseMediaQuery(MediaList*, const String&); Document* document() const; void addProperty(int propId, PassRefPtr<CSSValue>, bool important); void rollbackLastProperties(int num); bool hasProperties() const { return m_numParsedProperties > 0; } bool parseValue(int propId, bool important); bool parseShorthand(int propId, const int* properties, int numProperties, bool important); bool parse4Values(int propId, const int* properties, bool important); bool parseContent(int propId, bool important); PassRefPtr<CSSValue> parseAttr(CSSParserValueList* args); PassRefPtr<CSSValue> parseBackgroundColor(); bool parseFillImage(RefPtr<CSSValue>&); PassRefPtr<CSSValue> parseFillPositionXY(bool& xFound, bool& yFound); void parseFillPosition(RefPtr<CSSValue>&, RefPtr<CSSValue>&); void parseFillRepeat(RefPtr<CSSValue>&, RefPtr<CSSValue>&); PassRefPtr<CSSValue> parseFillSize(int propId, bool &allowComma); bool parseFillProperty(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parseFillShorthand(int propId, const int* properties, int numProperties, bool important); void addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval); void addAnimationValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval); PassRefPtr<CSSValue> parseAnimationDelay(); PassRefPtr<CSSValue> parseAnimationDirection(); PassRefPtr<CSSValue> parseAnimationDuration(); PassRefPtr<CSSValue> parseAnimationIterationCount(); PassRefPtr<CSSValue> parseAnimationName(); PassRefPtr<CSSValue> parseAnimationPlayState(); PassRefPtr<CSSValue> parseAnimationProperty(); PassRefPtr<CSSValue> parseAnimationTimingFunction(); void parseTransformOriginShorthand(RefPtr<CSSValue>&, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parseTimingFunctionValue(CSSParserValueList*& args, double& result); bool parseAnimationProperty(int propId, RefPtr<CSSValue>&); bool parseTransitionShorthand(bool important); bool parseAnimationShorthand(bool important); bool parseDashboardRegions(int propId, bool important); bool parseShape(int propId, bool important); bool parseFont(bool important); PassRefPtr<CSSValueList> parseFontFamily(); bool parseCounter(int propId, int defaultValue, bool important); PassRefPtr<CSSValue> parseCounterContent(CSSParserValueList* args, bool counters); bool parseColorParameters(CSSParserValue*, int* colorValues, bool parseAlpha); bool parseHSLParameters(CSSParserValue*, double* colorValues, bool parseAlpha); PassRefPtr<CSSPrimitiveValue> parseColor(CSSParserValue* = 0); bool parseColorFromValue(CSSParserValue*, RGBA32&, bool = false); void parseSelector(const String&, Document* doc, CSSSelectorList&); static bool parseColor(const String&, RGBA32& rgb, bool strict); bool parseFontStyle(bool important); bool parseFontVariant(bool important); bool parseFontWeight(bool important); bool parseFontFaceSrc(); bool parseFontFaceUnicodeRange(); #if ENABLE(SVG) bool parseSVGValue(int propId, bool important); PassRefPtr<CSSValue> parseSVGPaint(); PassRefPtr<CSSValue> parseSVGColor(); PassRefPtr<CSSValue> parseSVGStrokeDasharray(); #endif // CSS3 Parsing Routines (for properties specific to CSS3) bool parseShadow(int propId, bool important); bool parseBorderImage(int propId, bool important, RefPtr<CSSValue>&); bool parseBorderRadius(int propId, bool important); bool parseReflect(int propId, bool important); // Image generators bool parseCanvas(RefPtr<CSSValue>&); bool parseGradient(RefPtr<CSSValue>&); PassRefPtr<CSSValueList> parseTransform(); bool parseTransformOrigin(int propId, int& propId1, int& propId2, int& propId3, RefPtr<CSSValue>&, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parsePerspectiveOrigin(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parseVariable(CSSVariablesDeclaration*, const String& variableName, const String& variableValue); void parsePropertyWithResolvedVariables(int propId, bool important, CSSMutableStyleDeclaration*, CSSParserValueList*); int yyparse(); CSSSelector* createFloatingSelector(); CSSSelector* sinkFloatingSelector(CSSSelector*); CSSParserValueList* createFloatingValueList(); CSSParserValueList* sinkFloatingValueList(CSSParserValueList*); CSSParserFunction* createFloatingFunction(); CSSParserFunction* sinkFloatingFunction(CSSParserFunction*); CSSParserValue& sinkFloatingValue(CSSParserValue&); MediaList* createMediaList(); CSSRule* createCharsetRule(const CSSParserString&); CSSRule* createImportRule(const CSSParserString&, MediaList*); WebKitCSSKeyframeRule* createKeyframeRule(CSSParserValueList*); WebKitCSSKeyframesRule* createKeyframesRule(); CSSRule* createMediaRule(MediaList*, CSSRuleList*); CSSRuleList* createRuleList(); CSSRule* createStyleRule(Vector<CSSSelector*>* selectors); CSSRule* createFontFaceRule(); CSSRule* createVariablesRule(MediaList*, bool variablesKeyword); MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, CSSParserValueList*); MediaQueryExp* sinkFloatingMediaQueryExp(MediaQueryExp*); Vector<MediaQueryExp*>* createFloatingMediaQueryExpList(); Vector<MediaQueryExp*>* sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>*); MediaQuery* createFloatingMediaQuery(MediaQuery::Restrictor, const String&, Vector<MediaQueryExp*>*); MediaQuery* createFloatingMediaQuery(Vector<MediaQueryExp*>*); MediaQuery* sinkFloatingMediaQuery(MediaQuery*); void addNamespace(const AtomicString& prefix, const AtomicString& uri); bool addVariable(const CSSParserString&, CSSParserValueList*); bool addVariableDeclarationBlock(const CSSParserString&); bool checkForVariables(CSSParserValueList*); void addUnresolvedProperty(int propId, bool important); Vector<CSSSelector*>* reusableSelectorVector() { return &m_reusableSelectorVector; } bool m_strict; bool m_important; int m_id; CSSStyleSheet* m_styleSheet; RefPtr<CSSRule> m_rule; RefPtr<CSSRule> m_keyframe; MediaQuery* m_mediaQuery; CSSParserValueList* m_valueList; CSSProperty** m_parsedProperties; CSSSelectorList* m_selectorListForParseSelector; unsigned m_numParsedProperties; unsigned m_maxParsedProperties; int m_inParseShorthand; int m_currentShorthand; bool m_implicitShorthand; bool m_hasFontFaceOnlyValues; Vector<String> m_variableNames; Vector<RefPtr<CSSValue> > m_variableValues; AtomicString m_defaultNamespace; // tokenizer methods and data int lex(void* yylval); int token() { return yyTok; } UChar* text(int* length); int lex(); private: void recheckAtKeyword(const UChar* str, int len); void clearProperties(); void setupParser(const char* prefix, const String&, const char* suffix); bool inShorthand() const { return m_inParseShorthand; } void checkForOrphanedUnits(); void clearVariables(); void deleteFontFaceOnlyValues(); UChar* m_data; UChar* yytext; UChar* yy_c_buf_p; UChar yy_hold_char; int yy_last_accepting_state; UChar* yy_last_accepting_cpos; int yyleng; int yyTok; int yy_start; bool m_allowImportRules; bool m_allowVariablesRules; bool m_allowNamespaceDeclarations; Vector<RefPtr<StyleBase> > m_parsedStyleObjects; Vector<RefPtr<CSSRuleList> > m_parsedRuleLists; HashSet<CSSSelector*> m_floatingSelectors; HashSet<CSSParserValueList*> m_floatingValueLists; HashSet<CSSParserFunction*> m_floatingFunctions; MediaQuery* m_floatingMediaQuery; MediaQueryExp* m_floatingMediaQueryExp; Vector<MediaQueryExp*>* m_floatingMediaQueryExpList; Vector<CSSSelector*> m_reusableSelectorVector; // defines units allowed for a certain property, used in parseUnit enum Units { FUnknown = 0x0000, FInteger = 0x0001, FNumber = 0x0002, // Real Numbers FPercent = 0x0004, FLength = 0x0008, FAngle = 0x0010, FTime = 0x0020, FFrequency = 0x0040, FRelative = 0x0100, FNonNeg = 0x0200 }; friend inline Units operator|(Units a, Units b) { return static_cast<Units>(static_cast<unsigned>(a) | static_cast<unsigned>(b)); } static bool validUnit(CSSParserValue*, Units, bool strict); friend class TransformOperationInfo; }; int cssPropertyID(const CSSParserString&); int cssPropertyID(const String&); int cssValueKeywordID(const CSSParserString&); class ShorthandScope : public FastAllocBase { public: ShorthandScope(CSSParser* parser, int propId) : m_parser(parser) { if (!(m_parser->m_inParseShorthand++)) m_parser->m_currentShorthand = propId; } ~ShorthandScope() { if (!(--m_parser->m_inParseShorthand)) m_parser->m_currentShorthand = 0; } private: CSSParser* m_parser; }; } // namespace WebCore #endif // CSSParser_h
38.632075
145
0.689459
[ "vector" ]
c63f37788ba9221b2c16764482e9bb4cbc166e45
10,793
h
C
src/compiler.h
chicchi0531/KScript2Compiler
d0aabc3314a346932e7b671163728a5ae31b7f85
[ "BSL-1.0" ]
null
null
null
src/compiler.h
chicchi0531/KScript2Compiler
d0aabc3314a346932e7b671163728a5ae31b7f85
[ "BSL-1.0" ]
null
null
null
src/compiler.h
chicchi0531/KScript2Compiler
d0aabc3314a346932e7b671163728a5ae31b7f85
[ "BSL-1.0" ]
null
null
null
#pragma once #include <string> #include <vector> #include <map> #include <iostream> #include <exception> #include <filesystem> #include <boost/filesystem.hpp> #include "ast.h" #include "symbols.h" #include "config.h" namespace kscript2 { using namespace parser; using namespace ast; namespace fs = std::filesystem; // エラーオブジェクト class CompilerErrorException : std::exception { public: CompilerErrorException(std::string str) : error_message(str){} std::string error_message; }; // 命令コード class VMCode { public: int op_; int arg1_; public: VMCode(int op) : op_(op), arg1_(0) {} VMCode(int op, int arg1) : op_(op), arg1_(arg1) {} /*int* Get(int* p) const { // ラベル以外を取得 // ラベルは命令として載せないのでスキップ if (op_ != VM_MAXCOMMAND) { *p++ = op_; if (size_ > 1) { *(int*)p = arg1_; p += 4; } } return p; }*/ }; //ラベル class Label { public: int index_; int pos_; public: Label(int index) : index_(index), pos_(0) { } }; // 変数テーブル class ValueTag { public: int addr_; int type_; int size_; bool global_; public: ValueTag(): addr_(-1), type_(TYPE_INTEGER), size_(1), global_(false) {} ValueTag(int addr, int type, int size, bool global) : addr_(addr), type_(type), size_(size), global_(global) {} }; class ValueTable { private: typedef std::map<std::string, ValueTag>::iterator iter; typedef std::map<std::string, ValueTag>::const_iterator const_iter; std::map<std::string, ValueTag> variables_; int addr_; bool global_; public: ValueTable(int start_addr=0): addr_(start_addr), global_(false) {} // スコープをグローバルに void set_global() { global_ = true; } bool isGlobal() { return global_; } // 変数追加 bool add(int type, const std::string& name, int size = 1) { std::pair<iter, bool> result = variables_.insert( { name, ValueTag(addr_, type, size, global_) } ); if (result.second) { addr_ += size; return true; } return false; } // 変数検索 const ValueTag* find(const std::string& name) const { const_iter it = variables_.find(name); if (it != variables_.end()) return &it->second; return nullptr; } // 引数追加 bool add_arg(int type, const std::string& name, int addr) { std::pair<iter, bool> result = variables_.insert( { name, ValueTag(addr, type, 1, false) } ); return result.second; } // 現在のテーブルサイズ int size() const { return addr_; } // テーブルクリア void clear() { variables_.clear(); addr_ = 0; } #ifdef _DEBUG void dump() const { std::cout << "--------------- value ---------------" << std::endl; for (auto const& it : variables_) { std::cout << it.first << ", addr = " << it.second.addr_ << ", type = " << it.second.type_ << ", size = " << it.second.size_ << ", global = " << it.second.global_ << std::endl; } } #endif }; class FunctionTag { private: enum { flag_declaration = 1 << 0, flag_definition = 1 << 1, flag_system = 1 << 2, }; int type_; int flags_; int index_; std::vector<int> args_; public: FunctionTag(int type) : type_(type), flags_(0), index_(0) {} void SetArg(int type) { args_.push_back((char)type); } void SetArgs(const ast::arg_def_list& args) { for (auto const& arg : args) { args_.push_back(arg.type); } } bool SetArgs(const char* args) { if (args) { for (int i = 0; args[i] != 0; i++) { switch (args[i]) { case 'I': case 'i': args_.push_back(TYPE_INTEGER); break; case 'S': case 's': args_.push_back(TYPE_STRING); break; default: return false; } } } return true; } void SetArgs(const std::vector<int>& args) { for (auto const& arg : args) { args_.push_back(arg); } } bool CheckArgList(const ast::arg_def_list& args) const { // 引数がない場合 if (args.empty()) return args_.empty(); // 引数の個数が異なる場合 if (args.size() != args_.size()) return false; // 全引数の型をチェック for (size_t i=0; i<args_.size(); i++) { if (args[i].type != args_[i]) return false; } return true; } bool CheckArgList(const std::vector<int>& args) const { // 引数がない場合 if (args.empty()) return args_.empty(); // 引数の個数が異なる if (args.size() != args_.size()) return false; // 全引数の型チェック for (size_t i = 0; i < args_.size(); i++) { if (args[i] != args_[i]) return false; } return true; } int GetArg(int index) const { return args_[index]; } int ArgSize() const { return (int)args_.size(); } void SetIndex(int index) { index_ = index; } void SetDeclaration() { flags_ |= flag_declaration; } void SetDefinition() { flags_ |= flag_definition; } void SetSystem() { flags_ |= flag_system; } int GetIndex() const { return index_; } int GetType() const { return type_; } bool IsDeclaration() const { return (flags_ & flag_declaration) != 0; } bool IsDefinition() const { return(flags_ & flag_definition) != 0; } bool IsSystem() const { return (flags_ & flag_system) != 0; } }; class FunctionTable { private: typedef std::map<std::string, FunctionTag>::iterator iter; typedef std::map<std::string, FunctionTag>::const_iterator const_iter; std::map<std::string, FunctionTag> functions_; public: FunctionTable(){} FunctionTag* add(const std::string& name, const FunctionTag& tag) { auto result = functions_.insert({ name, tag }); if (result.second) return &result.first->second; return nullptr; } const FunctionTag* find(const std::string& name) const { const_iter it = functions_.find(name); if (it != functions_.end()) return &it->second; return nullptr; } FunctionTag* find(const std::string& name) { iter it = functions_.find(name); if (it != functions_.end()) { return &it->second; } return nullptr; } void clear() { functions_.clear(); } }; struct VMVariableValue { int type; int ival; double fval; std::wstring sval; }; class compiler { private: FunctionTable functions; std::vector<std::string> systemcalls; std::vector<ValueTable> variables; std::vector<VMCode> program; std::vector<Label> labels; std::vector<std::wstring> text_table; std::vector<double> double_table; std::vector<VMVariableValue> global_variables_value; int break_index; int continue_index; int ast_return; // error handle int error_count; int warning_count; position_cache positions; std::string current_function_name; int current_function_type; int system_function_num; std::vector<std::filesystem::path> filepathes_; public: compiler(): break_index(-1), continue_index(-1), error_count(0), warning_count(0), ast_return(0), current_function_type(TYPE_INTEGER), positions(std::string("").begin(), std::string("").end()), system_function_num(0){ } void SetAstReturn(int value){ast_return = value;} int GetAstReturn()const{return ast_return;} bool compile(const fs::path& in_filepath, const fs::path& out_filepath); // 命令の発行 #define VM_CREATE #include "vm_code.h" #undef VM_CREATE #ifdef _DEBUG void debug_dump(); #endif // 変数宣言 void DefineValue(int type, const std::vector<ast::declarator>& node); // 関数宣言 void DeclFunction(int attr, int type, const std::string& name, const ast::arg_def_list& args, const ast::function_pre_def& ast); // 関数定義 void DefineFunction(int type, const std::string& name, const ast::arg_def_list& args, const ast::statements& block, const ast::function_def& ast); // 変数定義 void AddValue(int type, const std::string& name, const ast::declarator& ast); // 変数検索 const ValueTag* GetValueTag(const std::string& name) const { int size = (int)variables.size(); for (int i = size - 1; i >= 0; i--) { const ValueTag* tag = variables[i].find(name); if (tag) return tag; } return nullptr; } // 現在のスコープがグローバル領域か bool IsGlobalScope() { return variables.back().isGlobal(); } // グローバル変数の初期値を入れる場所 void SetGlobalValue(VMVariableValue value) { global_variables_value.push_back(value); } // 関数の検索 const FunctionTag* GetFunctionTag(const std::string& name) const { return functions.find(name); } // ステートメント処理 void BlockIn(); void BlockOut(); // Break分のジャンプ先設定 int SetBreakLabel(int label) { int old_index = break_index; break_index = label; return old_index; } // Continue文のジャンプ先設定 int SetContinueLabel(int label) { int old_index = continue_index; continue_index = label; return old_index; } // jmp命令 bool JmpBreakLabel(); bool JmpContinueLabel(); // label処理 int LabelSetting(); int MakeLabel(); void SetLabel(int label); void PushString(const std::wstring& name); void PushDouble(double value); int GetFunctionType() const { return current_function_type; } // ダミー命令生成(あとから置き換える) int DummyOp() { program.push_back(VMCode(-1)); return program.size()-1; } // 命令を置き換える void ReplaceOp(VMCode code, int index) { program[index] = code; } // 命令を削除する void EraseOp(int index) { program.erase(program.begin() + index); } // include命令 void Include(const std::string& filepath, const x3::position_tagged& ast); // 実行データを生成 bool CreateData(const fs::path& path); // error handling void error(const std::string& m, const x3::position_tagged& ast); void error(const std::string& m); void warning(const std::string& m, const x3::position_tagged& ast); void warning(const std::string& m); void info(const std::string& m, const x3::position_tagged& ast); void info(const std::string& m); private: // utf8-bomのbom部分のスキップ inline void skip_utf8_bom(std::ifstream& fs) { int dst[3]; for (auto& i : dst) i = fs.get(); constexpr int utf8[] = { 0xEF, 0xBB, 0xBF }; // bomがついていない場合は読み取り位置を先頭に戻す if (!std::equal(std::begin(dst), std::end(dst), utf8)) { info("ファイルフォーマット:utf8"); fs.seekg(0); } else { info("ファイルフォーマット:utf8 with bom"); } } // スクリプトファイルの読み出し std::string FileLoad(const fs::path& p) { //ファイルの存在チェック if(!fs::exists(p)) { throw CompilerErrorException(p.string() + " : ファイルが見つかりませんでした。パスが正しいか確認してください。"); } //ファイルを開く std::ifstream file(p); if (!file) { throw CompilerErrorException(p.string() + " : ファイルが開けませんでした。権限を確認してください。"); } // utf8 bomの処理 file.imbue(std::locale()); skip_utf8_bom(file); //stringに読み出す std::istreambuf_iterator<char> fbegin(file); std::istreambuf_iterator<char> fend; std::string contents(fbegin, fend); return contents; } // コンパイルのパース部分 bool parse(const fs::path& path, const x3::position_tagged& called_pos = x3::position_tagged()); }; }
20.249531
148
0.633837
[ "vector" ]
c65448eb3e839a5c6b0e612f182d0e1143e6e2e9
148,431
c
C
Mac/Modules/qd/Qdmodule.c
SaadBazaz/ChinesePython
800955539dda912d4a1621bcf5a700aaaddc012f
[ "CNRI-Python-GPL-Compatible" ]
3
2022-01-30T20:08:24.000Z
2022-02-12T08:51:12.000Z
Mac/Modules/qd/Qdmodule.c
SaadBazaz/ChinesePython
800955539dda912d4a1621bcf5a700aaaddc012f
[ "CNRI-Python-GPL-Compatible" ]
null
null
null
Mac/Modules/qd/Qdmodule.c
SaadBazaz/ChinesePython
800955539dda912d4a1621bcf5a700aaaddc012f
[ "CNRI-Python-GPL-Compatible" ]
null
null
null
/* =========================== Module Qd ============================ */ #include "Python.h" #include "macglue.h" #include "pymactoolbox.h" #ifdef WITHOUT_FRAMEWORKS #include <QuickDraw.h> #else #include <Carbon/Carbon.h> #endif #ifdef USE_TOOLBOX_OBJECT_GLUE extern PyObject *_GrafObj_New(GrafPtr); extern int _GrafObj_Convert(PyObject *, GrafPtr *); extern PyObject *_BMObj_New(BitMapPtr); extern int _BMObj_Convert(PyObject *, BitMapPtr *); extern PyObject *_QdRGB_New(RGBColorPtr); extern int _QdRGB_Convert(PyObject *, RGBColorPtr); #define GrafObj_New _GrafObj_New #define GrafObj_Convert _GrafObj_Convert #define BMObj_New _BMObj_New #define BMObj_Convert _BMObj_Convert #define QdRGB_New _QdRGB_New #define QdRGB_Convert _QdRGB_Convert #endif #if !ACCESSOR_CALLS_ARE_FUNCTIONS #define GetPortBitMapForCopyBits(port) ((const struct BitMap *)&((GrafPort *)(port))->portBits) #define GetPortPixMap(port) (((CGrafPtr)(port))->portPixMap) #define GetPortBounds(port, bounds) (*(bounds) = (port)->portRect, (bounds)) #define GetPortForeColor(port, color) (*(color) = (port)->rgbFgColor, (color)) #define GetPortBackColor(port, color) (*(color) = (port)->rgbBkColor, (color)) #define GetPortOpColor(port, color) (*(color) = (*(GVarHandle)((port)->grafVars))->rgbOpColor, (color)) #define GetPortHiliteColor(port, color) (*(color) = (*(GVarHandle)((port)->grafVars))->rgbHiliteColor, (color)) #define GetPortTextFont(port) ((port)->txFont) #define GetPortTextFace(port) ((port)->txFace) #define GetPortTextMode(port) ((port)->txMode) #define GetPortTextSize(port) ((port)->txSize) #define GetPortChExtra(port) ((port)->chExtra) #define GetPortFracHPenLocation(port) ((port)->pnLocHFrac) #define GetPortSpExtra(port) ((port)->spExtra) #define GetPortPenVisibility(port) ((port)->pnVis) #define GetPortVisibleRegion(port, rgn) ((rgn) = (port)->visRgn, (rgn)) #define GetPortClipRegion(port, rgn) ((rgn) = (port)->clipRgn, (rgn)) #define GetPortBackPixPat(port, pat) ((pat) = (port)->bkPixPat, (pat)) #define GetPortPenPixPat(port, pat) ((pat) = (port)->pnPixPat, (pat)) #define GetPortFillPixPat(port, pat) ((pat) = (port)->fillPixPat, (pat)) #define GetPortPenSize(port, pensize) (*(pensize) = (port)->pnSize, (pensize)) #define GetPortPenMode(port) ((port)->pnMode) #define GetPortPenLocation(port, location) ((*location) = (port)->pnLoc, (location)) #define IsPortRegionBeingDefined(port) (!!((port)->rgnSave)) #define IsPortPictureBeingDefined(port) (!!((port)->picSave)) /* #define IsPortOffscreen(port) */ /* #define IsPortColor(port) */ #define SetPortBounds(port, bounds) ((port)->portRect = *(bounds)) #define SetPortOpColor(port, color) ((*(GVarHandle)((port)->grafVars))->rgbOpColor = *(color)) #define SetPortVisibleRegion(port, rgn) ((port)->visRgn = (rgn)) #define SetPortClipRegion(port, rgn) ((port)->clipRgn = (rgn)) #define SetPortBackPixPat(port, pat) ((port)->bkPixPat = (pat)) #define SetPortPenPixPat(port, pat) ((port)->pnPixPat = (pat)) #define SetPortFillPixPat(port, pat) ((port)->fillPixPat = (pat)) #define SetPortPenSize(port, pensize) ((port)->pnSize = (pensize)) #define SetPortPenMode(port, mode) ((port)->pnMode = (mode)) #define SetPortFracHPenLocation(port, frac) ((port)->pnLocHFrac = (frac)) /* On pixmaps */ #define GetPixBounds(pixmap, rect) (*(rect) = (*(pixmap))->bounds, (rect)) #define GetPixDepth(pixmap) ((*(pixmap))->pixelSize) /* On regions */ #define GetRegionBounds(rgn, rect) (*(rect) = (*(rgn))->rgnBBox, (rect)) /* On QD Globals */ #define GetQDGlobalsRandomSeed() (qd.randSeed) #define GetQDGlobalsScreenBits(bits) (*(bits) = qd.screenBits, (bits)) #define GetQDGlobalsArrow(crsr) (*(crsr) = qd.arrow, (crsr)) #define GetQDGlobalsDarkGray(pat) (*(pat) = qd.dkGray, (pat)) #define GetQDGlobalsLightGray(pat) (*(pat) = qd.ltGray, (pat)) #define GetQDGlobalsGray(pat) (*(pat) = qd.gray, (pat)) #define GetQDGlobalsBlack(pat) (*(pat) = qd.black, (pat)) #define GetQDGlobalsWhite(pat) (*(pat) = qd.white, (pat)) #define GetQDGlobalsThePort() ((CGrafPtr)qd.thePort) #define SetQDGlobalsRandomSeed(seed) (qd.randSeed = (seed)) #define SetQDGlobalsArrow(crsr) (qd.arrow = *(crsr)) #endif /* ACCESSOR_CALLS_ARE_FUNCTIONS */ #if !TARGET_API_MAC_CARBON #define QDFlushPortBuffer(port, rgn) /* pass */ #define QDIsPortBufferDirty(port) 0 #define QDIsPortBuffered(port) 0 #endif /* !TARGET_API_MAC_CARBON */ staticforward PyObject *BMObj_NewCopied(BitMapPtr); /* ** Parse/generate RGB records */ PyObject *QdRGB_New(RGBColorPtr itself) { return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue); } QdRGB_Convert(PyObject *v, RGBColorPtr p_itself) { long red, green, blue; if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) ) return 0; p_itself->red = (unsigned short)red; p_itself->green = (unsigned short)green; p_itself->blue = (unsigned short)blue; return 1; } /* ** Generate FontInfo records */ static PyObject *QdFI_New(FontInfo *itself) { return Py_BuildValue("hhhh", itself->ascent, itself->descent, itself->widMax, itself->leading); } static PyObject *Qd_Error; /* ---------------------- Object type GrafPort ---------------------- */ PyTypeObject GrafPort_Type; #define GrafObj_Check(x) ((x)->ob_type == &GrafPort_Type) typedef struct GrafPortObject { PyObject_HEAD GrafPtr ob_itself; } GrafPortObject; PyObject *GrafObj_New(GrafPtr itself) { GrafPortObject *it; if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(GrafPortObject, &GrafPort_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } GrafObj_Convert(PyObject *v, GrafPtr *p_itself) { #if 1 { WindowRef win; if (WinObj_Convert(v, &win) && v) { *p_itself = (GrafPtr)GetWindowPort(win); return 1; } PyErr_Clear(); } #else if (DlgObj_Check(v)) { DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself; *p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg)); return 1; } if (WinObj_Check(v)) { WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself; *p_itself = (GrafPtr)GetWindowPort(win); return 1; } #endif if (!GrafObj_Check(v)) { PyErr_SetString(PyExc_TypeError, "GrafPort required"); return 0; } *p_itself = ((GrafPortObject *)v)->ob_itself; return 1; } static void GrafObj_dealloc(GrafPortObject *self) { /* Cleanup of self->ob_itself goes here */ PyMem_DEL(self); } static PyMethodDef GrafObj_methods[] = { {NULL, NULL, 0} }; PyMethodChain GrafObj_chain = { GrafObj_methods, NULL }; static PyObject *GrafObj_getattr(GrafPortObject *self, char *name) { #if !ACCESSOR_CALLS_ARE_FUNCTIONS { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; if ( strcmp(name, "data") == 0 ) return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort)); if ( (itself_color->portVersion&0xc000) == 0xc000 ) { /* Color-only attributes */ if ( strcmp(name, "portBits") == 0 ) /* XXXX Do we need HLock() stuff here?? */ return BMObj_New((BitMapPtr)*itself_color->portPixMap); if ( strcmp(name, "grafVars") == 0 ) return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn); if ( strcmp(name, "chExtra") == 0 ) return Py_BuildValue("h", itself_color->chExtra); if ( strcmp(name, "pnLocHFrac") == 0 ) return Py_BuildValue("h", itself_color->pnLocHFrac); if ( strcmp(name, "bkPixPat") == 0 ) return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat); if ( strcmp(name, "rgbFgColor") == 0 ) return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor); if ( strcmp(name, "rgbBkColor") == 0 ) return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor); if ( strcmp(name, "pnPixPat") == 0 ) return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat); if ( strcmp(name, "fillPixPat") == 0 ) return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat); } else { /* Mono-only attributes */ if ( strcmp(name, "portBits") == 0 ) return BMObj_New(&self->ob_itself->portBits); if ( strcmp(name, "bkPat") == 0 ) return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern)); if ( strcmp(name, "fillPat") == 0 ) return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern)); if ( strcmp(name, "pnPat") == 0 ) return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern)); } /* ** Accessible for both color/mono windows. ** portVersion is really color-only, but we put it here ** for convenience */ if ( strcmp(name, "portVersion") == 0 ) return Py_BuildValue("h", itself_color->portVersion); if ( strcmp(name, "device") == 0 ) return PyInt_FromLong((long)self->ob_itself->device); if ( strcmp(name, "portRect") == 0 ) return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect); if ( strcmp(name, "visRgn") == 0 ) return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn); if ( strcmp(name, "clipRgn") == 0 ) return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn); if ( strcmp(name, "pnLoc") == 0 ) return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc); if ( strcmp(name, "pnSize") == 0 ) return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize); if ( strcmp(name, "pnMode") == 0 ) return Py_BuildValue("h", self->ob_itself->pnMode); if ( strcmp(name, "pnVis") == 0 ) return Py_BuildValue("h", self->ob_itself->pnVis); if ( strcmp(name, "txFont") == 0 ) return Py_BuildValue("h", self->ob_itself->txFont); if ( strcmp(name, "txFace") == 0 ) return Py_BuildValue("h", (short)self->ob_itself->txFace); if ( strcmp(name, "txMode") == 0 ) return Py_BuildValue("h", self->ob_itself->txMode); if ( strcmp(name, "txSize") == 0 ) return Py_BuildValue("h", self->ob_itself->txSize); if ( strcmp(name, "spExtra") == 0 ) return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra); /* XXXX Add more, as needed */ /* This one is so we can compare grafports: */ if ( strcmp(name, "_id") == 0 ) return Py_BuildValue("l", (long)self->ob_itself); } #else { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; if ( strcmp(name, "portBits") == 0 ) return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color)); if ( strcmp(name, "chExtra") == 0 ) return Py_BuildValue("h", GetPortChExtra(itself_color)); if ( strcmp(name, "pnLocHFrac") == 0 ) return Py_BuildValue("h", GetPortFracHPenLocation(itself_color)); if ( strcmp(name, "bkPixPat") == 0 ) { PixPatHandle h=0; return Py_BuildValue("O&", ResObj_New, (Handle)GetPortBackPixPat(itself_color, h)); } if ( strcmp(name, "rgbFgColor") == 0 ) { RGBColor c; return Py_BuildValue("O&", QdRGB_New, GetPortForeColor(itself_color, &c)); } if ( strcmp(name, "rgbBkColor") == 0 ) { RGBColor c; return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c)); } if ( strcmp(name, "pnPixPat") == 0 ) { PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h)); } if ( strcmp(name, "fillPixPat") == 0 ) { PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h)); } if ( strcmp(name, "portRect") == 0 ) { Rect r; return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r)); } if ( strcmp(name, "visRgn") == 0 ) { RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h)); } if ( strcmp(name, "clipRgn") == 0 ) { RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h)); } if ( strcmp(name, "pnLoc") == 0 ) { Point p; return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenLocation(itself_color, &p)); } if ( strcmp(name, "pnSize") == 0 ) { Point p; return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenSize(itself_color, &p)); } if ( strcmp(name, "pnMode") == 0 ) return Py_BuildValue("h", GetPortPenMode(itself_color)); if ( strcmp(name, "pnVis") == 0 ) return Py_BuildValue("h", GetPortPenVisibility(itself_color)); if ( strcmp(name, "txFont") == 0 ) return Py_BuildValue("h", GetPortTextFont(itself_color)); if ( strcmp(name, "txFace") == 0 ) return Py_BuildValue("h", (short)GetPortTextFace(itself_color)); if ( strcmp(name, "txMode") == 0 ) return Py_BuildValue("h", GetPortTextMode(itself_color)); if ( strcmp(name, "txSize") == 0 ) return Py_BuildValue("h", GetPortTextSize(itself_color)); if ( strcmp(name, "spExtra") == 0 ) return Py_BuildValue("O&", PyMac_BuildFixed, GetPortSpExtra(itself_color)); /* XXXX Add more, as needed */ /* This one is so we can compare grafports: */ if ( strcmp(name, "_id") == 0 ) return Py_BuildValue("l", (long)self->ob_itself); } #endif return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name); } #define GrafObj_setattr NULL #define GrafObj_compare NULL #define GrafObj_repr NULL #define GrafObj_hash NULL PyTypeObject GrafPort_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "GrafPort", /*tp_name*/ sizeof(GrafPortObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) GrafObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc) GrafObj_getattr, /*tp_getattr*/ (setattrfunc) GrafObj_setattr, /*tp_setattr*/ (cmpfunc) GrafObj_compare, /*tp_compare*/ (reprfunc) GrafObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) GrafObj_hash, /*tp_hash*/ }; /* -------------------- End object type GrafPort -------------------- */ /* ----------------------- Object type BitMap ----------------------- */ PyTypeObject BitMap_Type; #define BMObj_Check(x) ((x)->ob_type == &BitMap_Type) typedef struct BitMapObject { PyObject_HEAD BitMapPtr ob_itself; PyObject *referred_object; BitMap *referred_bitmap; } BitMapObject; PyObject *BMObj_New(BitMapPtr itself) { BitMapObject *it; if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(BitMapObject, &BitMap_Type); if (it == NULL) return NULL; it->ob_itself = itself; it->referred_object = NULL; it->referred_bitmap = NULL; return (PyObject *)it; } BMObj_Convert(PyObject *v, BitMapPtr *p_itself) { if (!BMObj_Check(v)) { PyErr_SetString(PyExc_TypeError, "BitMap required"); return 0; } *p_itself = ((BitMapObject *)v)->ob_itself; return 1; } static void BMObj_dealloc(BitMapObject *self) { Py_XDECREF(self->referred_object); if (self->referred_bitmap) free(self->referred_bitmap); PyMem_DEL(self); } static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args) { PyObject *_res = NULL; int from, length; char *cp; if ( !PyArg_ParseTuple(_args, "ii", &from, &length) ) return NULL; cp = _self->ob_itself->baseAddr+from; return PyString_FromStringAndSize(cp, length); } static PyObject *BMObj_putdata(BitMapObject *_self, PyObject *_args) { PyObject *_res = NULL; int from, length; char *cp, *icp; if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) ) return NULL; cp = _self->ob_itself->baseAddr+from; memcpy(cp, icp, length); Py_INCREF(Py_None); return Py_None; } static PyMethodDef BMObj_methods[] = { {"getdata", (PyCFunction)BMObj_getdata, 1, "(int start, int size) -> string. Return bytes from the bitmap"}, {"putdata", (PyCFunction)BMObj_putdata, 1, "(int start, string data). Store bytes into the bitmap"}, {NULL, NULL, 0} }; PyMethodChain BMObj_chain = { BMObj_methods, NULL }; static PyObject *BMObj_getattr(BitMapObject *self, char *name) { if ( strcmp(name, "baseAddr") == 0 ) return PyInt_FromLong((long)self->ob_itself->baseAddr); if ( strcmp(name, "rowBytes") == 0 ) return PyInt_FromLong((long)self->ob_itself->rowBytes); if ( strcmp(name, "bounds") == 0 ) return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds); /* XXXX Add more, as needed */ if ( strcmp(name, "bitmap_data") == 0 ) return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap)); if ( strcmp(name, "pixmap_data") == 0 ) return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap)); return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name); } #define BMObj_setattr NULL #define BMObj_compare NULL #define BMObj_repr NULL #define BMObj_hash NULL PyTypeObject BitMap_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "BitMap", /*tp_name*/ sizeof(BitMapObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) BMObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc) BMObj_getattr, /*tp_getattr*/ (setattrfunc) BMObj_setattr, /*tp_setattr*/ (cmpfunc) BMObj_compare, /*tp_compare*/ (reprfunc) BMObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) BMObj_hash, /*tp_hash*/ }; /* --------------------- End object type BitMap --------------------- */ /* ------------------ Object type QDGlobalsAccess ------------------- */ staticforward PyTypeObject QDGlobalsAccess_Type; #define QDGA_Check(x) ((x)->ob_type == &QDGlobalsAccess_Type) typedef struct QDGlobalsAccessObject { PyObject_HEAD } QDGlobalsAccessObject; static PyObject *QDGA_New(void) { QDGlobalsAccessObject *it; it = PyObject_NEW(QDGlobalsAccessObject, &QDGlobalsAccess_Type); if (it == NULL) return NULL; return (PyObject *)it; } static void QDGA_dealloc(QDGlobalsAccessObject *self) { PyMem_DEL(self); } static PyMethodDef QDGA_methods[] = { {NULL, NULL, 0} }; static PyMethodChain QDGA_chain = { QDGA_methods, NULL }; static PyObject *QDGA_getattr(QDGlobalsAccessObject *self, char *name) { #if !ACCESSOR_CALLS_ARE_FUNCTIONS if ( strcmp(name, "arrow") == 0 ) return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow)); if ( strcmp(name, "black") == 0 ) return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black)); if ( strcmp(name, "white") == 0 ) return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white)); if ( strcmp(name, "gray") == 0 ) return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray)); if ( strcmp(name, "ltGray") == 0 ) return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray)); if ( strcmp(name, "dkGray") == 0 ) return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray)); if ( strcmp(name, "screenBits") == 0 ) return BMObj_New(&qd.screenBits); if ( strcmp(name, "thePort") == 0 ) return GrafObj_New(qd.thePort); if ( strcmp(name, "randSeed") == 0 ) return Py_BuildValue("l", &qd.randSeed); #else if ( strcmp(name, "arrow") == 0 ) { Cursor rv; GetQDGlobalsArrow(&rv); return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); } if ( strcmp(name, "black") == 0 ) { Pattern rv; GetQDGlobalsBlack(&rv); return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); } if ( strcmp(name, "white") == 0 ) { Pattern rv; GetQDGlobalsWhite(&rv); return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); } if ( strcmp(name, "gray") == 0 ) { Pattern rv; GetQDGlobalsGray(&rv); return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); } if ( strcmp(name, "ltGray") == 0 ) { Pattern rv; GetQDGlobalsLightGray(&rv); return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); } if ( strcmp(name, "dkGray") == 0 ) { Pattern rv; GetQDGlobalsDarkGray(&rv); return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); } if ( strcmp(name, "screenBits") == 0 ) { BitMap rv; GetQDGlobalsScreenBits(&rv); return BMObj_NewCopied(&rv); } if ( strcmp(name, "thePort") == 0 ) return GrafObj_New(GetQDGlobalsThePort()); if ( strcmp(name, "randSeed") == 0 ) return Py_BuildValue("l", GetQDGlobalsRandomSeed()); #endif return Py_FindMethodInChain(&QDGA_chain, (PyObject *)self, name); } #define QDGA_setattr NULL #define QDGA_compare NULL #define QDGA_repr NULL #define QDGA_hash NULL staticforward PyTypeObject QDGlobalsAccess_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "QDGlobalsAccess", /*tp_name*/ sizeof(QDGlobalsAccessObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) QDGA_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc) QDGA_getattr, /*tp_getattr*/ (setattrfunc) QDGA_setattr, /*tp_setattr*/ (cmpfunc) QDGA_compare, /*tp_compare*/ (reprfunc) QDGA_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) QDGA_hash, /*tp_hash*/ }; /* ---------------- End object type QDGlobalsAccess ----------------- */ static PyObject *Qd_MacSetPort(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; MacSetPort(port); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetPort(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GrafPtr port; if (!PyArg_ParseTuple(_args, "")) return NULL; GetPort(&port); _res = Py_BuildValue("O&", GrafObj_New, port); return _res; } static PyObject *Qd_GrafDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short device; if (!PyArg_ParseTuple(_args, "h", &device)) return NULL; GrafDevice(device); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMapPtr bm; if (!PyArg_ParseTuple(_args, "O&", BMObj_Convert, &bm)) return NULL; SetPortBits(bm); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PortSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short width; short height; if (!PyArg_ParseTuple(_args, "hh", &width, &height)) return NULL; PortSize(width, height); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MovePortTo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short leftGlobal; short topGlobal; if (!PyArg_ParseTuple(_args, "hh", &leftGlobal, &topGlobal)) return NULL; MovePortTo(leftGlobal, topGlobal); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetOrigin(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short h; short v; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; SetOrigin(h, v); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetClip(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; SetClip(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetClip(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; GetClip(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ClipRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; ClipRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_BackPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "s#", (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } BackPat(pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_InitCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; InitCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacSetCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Cursor *crsr__in__; int crsr__in_len__; if (!PyArg_ParseTuple(_args, "s#", (char **)&crsr__in__, &crsr__in_len__)) return NULL; if (crsr__in_len__ != sizeof(Cursor)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)"); goto crsr__error__; } MacSetCursor(crsr__in__); Py_INCREF(Py_None); _res = Py_None; crsr__error__: ; return _res; } static PyObject *Qd_HideCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; HideCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacShowCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; MacShowCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ObscureCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; ObscureCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_HidePen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; HidePen(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ShowPen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; ShowPen(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetPen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point pt; if (!PyArg_ParseTuple(_args, "")) return NULL; GetPen(&pt); _res = Py_BuildValue("O&", PyMac_BuildPoint, pt); return _res; } static PyObject *Qd_GetPenState(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PenState pnState__out__; if (!PyArg_ParseTuple(_args, "")) return NULL; GetPenState(&pnState__out__); _res = Py_BuildValue("s#", (char *)&pnState__out__, (int)sizeof(PenState)); pnState__error__: ; return _res; } static PyObject *Qd_SetPenState(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PenState *pnState__in__; int pnState__in_len__; if (!PyArg_ParseTuple(_args, "s#", (char **)&pnState__in__, &pnState__in_len__)) return NULL; if (pnState__in_len__ != sizeof(PenState)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)"); goto pnState__error__; } SetPenState(pnState__in__); Py_INCREF(Py_None); _res = Py_None; pnState__error__: ; return _res; } static PyObject *Qd_PenSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short width; short height; if (!PyArg_ParseTuple(_args, "hh", &width, &height)) return NULL; PenSize(width, height); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PenMode(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short mode; if (!PyArg_ParseTuple(_args, "h", &mode)) return NULL; PenMode(mode); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PenPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "s#", (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } PenPat(pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_PenNormal(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; PenNormal(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MoveTo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short h; short v; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; MoveTo(h, v); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_Move(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short dh; short dv; if (!PyArg_ParseTuple(_args, "hh", &dh, &dv)) return NULL; Move(dh, dv); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacLineTo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short h; short v; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; MacLineTo(h, v); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_Line(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short dh; short dv; if (!PyArg_ParseTuple(_args, "hh", &dh, &dv)) return NULL; Line(dh, dv); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ForeColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long color; if (!PyArg_ParseTuple(_args, "l", &color)) return NULL; ForeColor(color); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_BackColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long color; if (!PyArg_ParseTuple(_args, "l", &color)) return NULL; BackColor(color); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ColorBit(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short whichBit; if (!PyArg_ParseTuple(_args, "h", &whichBit)) return NULL; ColorBit(whichBit); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacSetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short left; short top; short right; short bottom; if (!PyArg_ParseTuple(_args, "hhhh", &left, &top, &right, &bottom)) return NULL; MacSetRect(&r, left, top, right, bottom); _res = Py_BuildValue("O&", PyMac_BuildRect, &r); return _res; } static PyObject *Qd_MacOffsetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &dh, &dv)) return NULL; MacOffsetRect(&r, dh, dv); _res = Py_BuildValue("O&", PyMac_BuildRect, &r); return _res; } static PyObject *Qd_MacInsetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &dh, &dv)) return NULL; MacInsetRect(&r, dh, dv); _res = Py_BuildValue("O&", PyMac_BuildRect, &r); return _res; } static PyObject *Qd_SectRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Rect src1; Rect src2; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &src1, PyMac_GetRect, &src2)) return NULL; _rv = SectRect(&src1, &src2, &dstRect); _res = Py_BuildValue("bO&", _rv, PyMac_BuildRect, &dstRect); return _res; } static PyObject *Qd_MacUnionRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect src1; Rect src2; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &src1, PyMac_GetRect, &src2)) return NULL; MacUnionRect(&src1, &src2, &dstRect); _res = Py_BuildValue("O&", PyMac_BuildRect, &dstRect); return _res; } static PyObject *Qd_MacEqualRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Rect rect1; Rect rect2; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &rect1, PyMac_GetRect, &rect2)) return NULL; _rv = MacEqualRect(&rect1, &rect2); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_EmptyRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; _rv = EmptyRect(&r); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_MacFrameRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; MacFrameRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PaintRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; PaintRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_EraseRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; EraseRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacInvertRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; MacInvertRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacFillRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&s#", PyMac_GetRect, &r, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } MacFillRect(&r, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_FrameOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; FrameOval(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PaintOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; PaintOval(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_EraseOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; EraseOval(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InvertOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; InvertOval(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&s#", PyMac_GetRect, &r, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } FillOval(&r, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_FrameRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short ovalWidth; short ovalHeight; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &ovalWidth, &ovalHeight)) return NULL; FrameRoundRect(&r, ovalWidth, ovalHeight); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PaintRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short ovalWidth; short ovalHeight; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &ovalWidth, &ovalHeight)) return NULL; PaintRoundRect(&r, ovalWidth, ovalHeight); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_EraseRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short ovalWidth; short ovalHeight; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &ovalWidth, &ovalHeight)) return NULL; EraseRoundRect(&r, ovalWidth, ovalHeight); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InvertRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short ovalWidth; short ovalHeight; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &ovalWidth, &ovalHeight)) return NULL; InvertRoundRect(&r, ovalWidth, ovalHeight); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short ovalWidth; short ovalHeight; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&hhs#", PyMac_GetRect, &r, &ovalWidth, &ovalHeight, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } FillRoundRect(&r, ovalWidth, ovalHeight, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_FrameArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short startAngle; short arcAngle; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &startAngle, &arcAngle)) return NULL; FrameArc(&r, startAngle, arcAngle); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PaintArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short startAngle; short arcAngle; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &startAngle, &arcAngle)) return NULL; PaintArc(&r, startAngle, arcAngle); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_EraseArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short startAngle; short arcAngle; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &startAngle, &arcAngle)) return NULL; EraseArc(&r, startAngle, arcAngle); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InvertArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short startAngle; short arcAngle; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &startAngle, &arcAngle)) return NULL; InvertArc(&r, startAngle, arcAngle); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short startAngle; short arcAngle; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&hhs#", PyMac_GetRect, &r, &startAngle, &arcAngle, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } FillArc(&r, startAngle, arcAngle, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_NewRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = NewRgn(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_OpenRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; OpenRgn(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_CloseRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &dstRgn)) return NULL; CloseRgn(dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_BitMapToRegion(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; OSErr _err; RgnHandle region; BitMapPtr bMap; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &region, BMObj_Convert, &bMap)) return NULL; _err = BitMapToRegion(region, bMap); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_DisposeRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; DisposeRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacCopyRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgn; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &srcRgn, ResObj_Convert, &dstRgn)) return NULL; MacCopyRgn(srcRgn, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetEmptyRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; SetEmptyRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacSetRectRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; short left; short top; short right; short bottom; if (!PyArg_ParseTuple(_args, "O&hhhh", ResObj_Convert, &rgn, &left, &top, &right, &bottom)) return NULL; MacSetRectRgn(rgn, left, top, right, bottom); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_RectRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; Rect r; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &rgn, PyMac_GetRect, &r)) return NULL; RectRgn(rgn, &r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacOffsetRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", ResObj_Convert, &rgn, &dh, &dv)) return NULL; MacOffsetRgn(rgn, dh, dv); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InsetRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", ResObj_Convert, &rgn, &dh, &dv)) return NULL; InsetRgn(rgn, dh, dv); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SectRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgnA; RgnHandle srcRgnB; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &srcRgnA, ResObj_Convert, &srcRgnB, ResObj_Convert, &dstRgn)) return NULL; SectRgn(srcRgnA, srcRgnB, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacUnionRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgnA; RgnHandle srcRgnB; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &srcRgnA, ResObj_Convert, &srcRgnB, ResObj_Convert, &dstRgn)) return NULL; MacUnionRgn(srcRgnA, srcRgnB, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_DiffRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgnA; RgnHandle srcRgnB; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &srcRgnA, ResObj_Convert, &srcRgnB, ResObj_Convert, &dstRgn)) return NULL; DiffRgn(srcRgnA, srcRgnB, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacXorRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgnA; RgnHandle srcRgnB; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &srcRgnA, ResObj_Convert, &srcRgnB, ResObj_Convert, &dstRgn)) return NULL; MacXorRgn(srcRgnA, srcRgnB, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_RectInRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Rect r; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &r, ResObj_Convert, &rgn)) return NULL; _rv = RectInRgn(&r, rgn); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_MacEqualRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; RgnHandle rgnA; RgnHandle rgnB; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &rgnA, ResObj_Convert, &rgnB)) return NULL; _rv = MacEqualRgn(rgnA, rgnB); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_EmptyRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; _rv = EmptyRgn(rgn); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_MacFrameRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; MacFrameRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacPaintRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; MacPaintRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_EraseRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; EraseRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacInvertRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; MacInvertRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacFillRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&s#", ResObj_Convert, &rgn, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } MacFillRgn(rgn, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_ScrollRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short dh; short dv; RgnHandle updateRgn; if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &r, &dh, &dv, ResObj_Convert, &updateRgn)) return NULL; ScrollRect(&r, dh, dv, updateRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_CopyBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMapPtr srcBits; BitMapPtr dstBits; Rect srcRect; Rect dstRect; short mode; RgnHandle maskRgn; if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&", BMObj_Convert, &srcBits, BMObj_Convert, &dstBits, PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect, &mode, OptResObj_Convert, &maskRgn)) return NULL; CopyBits(srcBits, dstBits, &srcRect, &dstRect, mode, maskRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_CopyMask(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMapPtr srcBits; BitMapPtr maskBits; BitMapPtr dstBits; Rect srcRect; Rect maskRect; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&", BMObj_Convert, &srcBits, BMObj_Convert, &maskBits, BMObj_Convert, &dstBits, PyMac_GetRect, &srcRect, PyMac_GetRect, &maskRect, PyMac_GetRect, &dstRect)) return NULL; CopyMask(srcBits, maskBits, dstBits, &srcRect, &maskRect, &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_OpenPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PicHandle _rv; Rect picFrame; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &picFrame)) return NULL; _rv = OpenPicture(&picFrame); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_PicComment(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short kind; short dataSize; Handle dataHandle; if (!PyArg_ParseTuple(_args, "hhO&", &kind, &dataSize, ResObj_Convert, &dataHandle)) return NULL; PicComment(kind, dataSize, dataHandle); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ClosePicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; ClosePicture(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_DrawPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PicHandle myPicture; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &myPicture, PyMac_GetRect, &dstRect)) return NULL; DrawPicture(myPicture, &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_KillPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PicHandle myPicture; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &myPicture)) return NULL; KillPicture(myPicture); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_OpenPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = OpenPoly(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_ClosePoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; ClosePoly(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_KillPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &poly)) return NULL; KillPoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_OffsetPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", ResObj_Convert, &poly, &dh, &dv)) return NULL; OffsetPoly(poly, dh, dv); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FramePoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &poly)) return NULL; FramePoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PaintPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &poly)) return NULL; PaintPoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ErasePoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &poly)) return NULL; ErasePoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InvertPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &poly)) return NULL; InvertPoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&s#", ResObj_Convert, &poly, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } FillPoly(poly, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_SetPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point pt; short h; short v; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; SetPt(&pt, h, v); _res = Py_BuildValue("O&", PyMac_BuildPoint, pt); return _res; } static PyObject *Qd_LocalToGlobal(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point pt; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &pt)) return NULL; LocalToGlobal(&pt); _res = Py_BuildValue("O&", PyMac_BuildPoint, pt); return _res; } static PyObject *Qd_GlobalToLocal(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point pt; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &pt)) return NULL; GlobalToLocal(&pt); _res = Py_BuildValue("O&", PyMac_BuildPoint, pt); return _res; } static PyObject *Qd_Random(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = Random(); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_MacGetPixel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; short h; short v; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; _rv = MacGetPixel(h, v); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_ScalePt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point pt; Rect srcRect; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&O&", PyMac_GetPoint, &pt, PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect)) return NULL; ScalePt(&pt, &srcRect, &dstRect); _res = Py_BuildValue("O&", PyMac_BuildPoint, pt); return _res; } static PyObject *Qd_MapPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point pt; Rect srcRect; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&O&", PyMac_GetPoint, &pt, PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect)) return NULL; MapPt(&pt, &srcRect, &dstRect); _res = Py_BuildValue("O&", PyMac_BuildPoint, pt); return _res; } static PyObject *Qd_MapRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; Rect srcRect; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&O&", PyMac_GetRect, &r, PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect)) return NULL; MapRect(&r, &srcRect, &dstRect); _res = Py_BuildValue("O&", PyMac_BuildRect, &r); return _res; } static PyObject *Qd_MapRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; Rect srcRect; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &rgn, PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect)) return NULL; MapRgn(rgn, &srcRect, &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MapPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; Rect srcRect; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &poly, PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect)) return NULL; MapPoly(poly, &srcRect, &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_StdBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMapPtr srcBits; Rect srcRect; Rect dstRect; short mode; RgnHandle maskRgn; if (!PyArg_ParseTuple(_args, "O&O&O&hO&", BMObj_Convert, &srcBits, PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect, &mode, OptResObj_Convert, &maskRgn)) return NULL; StdBits(srcBits, &srcRect, &dstRect, mode, maskRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_AddPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point src; Point dst; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &src, PyMac_GetPoint, &dst)) return NULL; AddPt(src, &dst); _res = Py_BuildValue("O&", PyMac_BuildPoint, dst); return _res; } static PyObject *Qd_EqualPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Point pt1; Point pt2; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &pt1, PyMac_GetPoint, &pt2)) return NULL; _rv = EqualPt(pt1, pt2); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_MacPtInRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Point pt; Rect r; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &pt, PyMac_GetRect, &r)) return NULL; _rv = MacPtInRect(pt, &r); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_Pt2Rect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point pt1; Point pt2; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &pt1, PyMac_GetPoint, &pt2)) return NULL; Pt2Rect(pt1, pt2, &dstRect); _res = Py_BuildValue("O&", PyMac_BuildRect, &dstRect); return _res; } static PyObject *Qd_PtToAngle(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; Point pt; short angle; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &r, PyMac_GetPoint, &pt)) return NULL; PtToAngle(&r, pt, &angle); _res = Py_BuildValue("h", angle); return _res; } static PyObject *Qd_SubPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point src; Point dst; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &src, PyMac_GetPoint, &dst)) return NULL; SubPt(src, &dst); _res = Py_BuildValue("O&", PyMac_BuildPoint, dst); return _res; } static PyObject *Qd_PtInRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Point pt; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &pt, ResObj_Convert, &rgn)) return NULL; _rv = PtInRgn(pt, rgn); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_NewPixMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixMapHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = NewPixMap(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_DisposePixMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixMapHandle pm; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) return NULL; DisposePixMap(pm); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_CopyPixMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixMapHandle srcPM; PixMapHandle dstPM; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &srcPM, ResObj_Convert, &dstPM)) return NULL; CopyPixMap(srcPM, dstPM); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_NewPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = NewPixPat(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_DisposePixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pp)) return NULL; DisposePixPat(pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_CopyPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle srcPP; PixPatHandle dstPP; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &srcPP, ResObj_Convert, &dstPP)) return NULL; CopyPixPat(srcPP, dstPP); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PenPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pp)) return NULL; PenPixPat(pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_BackPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pp)) return NULL; BackPixPat(pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle _rv; short patID; if (!PyArg_ParseTuple(_args, "h", &patID)) return NULL; _rv = GetPixPat(patID); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_MakeRGBPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle pp; RGBColor myColor; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &pp, QdRGB_Convert, &myColor)) return NULL; MakeRGBPat(pp, &myColor); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillCRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &r, ResObj_Convert, &pp)) return NULL; FillCRect(&r, pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillCOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &r, ResObj_Convert, &pp)) return NULL; FillCOval(&r, pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillCRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short ovalWidth; short ovalHeight; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &r, &ovalWidth, &ovalHeight, ResObj_Convert, &pp)) return NULL; FillCRoundRect(&r, ovalWidth, ovalHeight, pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillCArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short startAngle; short arcAngle; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &r, &startAngle, &arcAngle, ResObj_Convert, &pp)) return NULL; FillCArc(&r, startAngle, arcAngle, pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillCRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &rgn, ResObj_Convert, &pp)) return NULL; FillCRgn(rgn, pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillCPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; PixPatHandle pp; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &poly, ResObj_Convert, &pp)) return NULL; FillCPoly(poly, pp); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_RGBForeColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RGBColor color; if (!PyArg_ParseTuple(_args, "O&", QdRGB_Convert, &color)) return NULL; RGBForeColor(&color); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_RGBBackColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RGBColor color; if (!PyArg_ParseTuple(_args, "O&", QdRGB_Convert, &color)) return NULL; RGBBackColor(&color); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetCPixel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short h; short v; RGBColor cPix; if (!PyArg_ParseTuple(_args, "hhO&", &h, &v, QdRGB_Convert, &cPix)) return NULL; SetCPixel(h, v, &cPix); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortPix(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixMapHandle pm; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) return NULL; SetPortPix(pm); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetCPixel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short h; short v; RGBColor cPix; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; GetCPixel(h, v, &cPix); _res = Py_BuildValue("O&", QdRGB_New, &cPix); return _res; } static PyObject *Qd_GetForeColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RGBColor color; if (!PyArg_ParseTuple(_args, "")) return NULL; GetForeColor(&color); _res = Py_BuildValue("O&", QdRGB_New, &color); return _res; } static PyObject *Qd_GetBackColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RGBColor color; if (!PyArg_ParseTuple(_args, "")) return NULL; GetBackColor(&color); _res = Py_BuildValue("O&", QdRGB_New, &color); return _res; } static PyObject *Qd_OpColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RGBColor color; if (!PyArg_ParseTuple(_args, "O&", QdRGB_Convert, &color)) return NULL; OpColor(&color); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_HiliteColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RGBColor color; if (!PyArg_ParseTuple(_args, "O&", QdRGB_Convert, &color)) return NULL; HiliteColor(&color); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_DisposeCTable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CTabHandle cTable; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &cTable)) return NULL; DisposeCTable(cTable); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetCTable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CTabHandle _rv; short ctID; if (!PyArg_ParseTuple(_args, "h", &ctID)) return NULL; _rv = GetCTable(ctID); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetCCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CCrsrHandle _rv; short crsrID; if (!PyArg_ParseTuple(_args, "h", &crsrID)) return NULL; _rv = GetCCursor(crsrID); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_SetCCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CCrsrHandle cCrsr; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &cCrsr)) return NULL; SetCCursor(cCrsr); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_AllocCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; AllocCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_DisposeCCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CCrsrHandle cCrsr; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &cCrsr)) return NULL; DisposeCCursor(cCrsr); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetMaxDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle _rv; Rect globalRect; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &globalRect)) return NULL; _rv = GetMaxDevice(&globalRect); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetCTSeed(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetCTSeed(); _res = Py_BuildValue("l", _rv); return _res; } static PyObject *Qd_GetDeviceList(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetDeviceList(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetMainDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetMainDevice(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetNextDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle _rv; GDHandle curDevice; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &curDevice)) return NULL; _rv = GetNextDevice(curDevice); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_TestDeviceAttribute(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; GDHandle gdh; short attribute; if (!PyArg_ParseTuple(_args, "O&h", ResObj_Convert, &gdh, &attribute)) return NULL; _rv = TestDeviceAttribute(gdh, attribute); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_SetDeviceAttribute(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle gdh; short attribute; Boolean value; if (!PyArg_ParseTuple(_args, "O&hb", ResObj_Convert, &gdh, &attribute, &value)) return NULL; SetDeviceAttribute(gdh, attribute, value); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InitGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short qdRefNum; long mode; GDHandle gdh; if (!PyArg_ParseTuple(_args, "hlO&", &qdRefNum, &mode, ResObj_Convert, &gdh)) return NULL; InitGDevice(qdRefNum, mode, gdh); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_NewGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle _rv; short refNum; long mode; if (!PyArg_ParseTuple(_args, "hl", &refNum, &mode)) return NULL; _rv = NewGDevice(refNum, mode); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_DisposeGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle gdh; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &gdh)) return NULL; DisposeGDevice(gdh); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle gd; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &gd)) return NULL; SetGDevice(gd); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GDHandle _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetGDevice(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_Color2Index(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long _rv; RGBColor myColor; if (!PyArg_ParseTuple(_args, "O&", QdRGB_Convert, &myColor)) return NULL; _rv = Color2Index(&myColor); _res = Py_BuildValue("l", _rv); return _res; } static PyObject *Qd_Index2Color(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long index; RGBColor aColor; if (!PyArg_ParseTuple(_args, "l", &index)) return NULL; Index2Color(index, &aColor); _res = Py_BuildValue("O&", QdRGB_New, &aColor); return _res; } static PyObject *Qd_InvertColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RGBColor myColor; if (!PyArg_ParseTuple(_args, "")) return NULL; InvertColor(&myColor); _res = Py_BuildValue("O&", QdRGB_New, &myColor); return _res; } static PyObject *Qd_RealColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; RGBColor color; if (!PyArg_ParseTuple(_args, "O&", QdRGB_Convert, &color)) return NULL; _rv = RealColor(&color); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_GetSubTable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CTabHandle myColors; short iTabRes; CTabHandle targetTbl; if (!PyArg_ParseTuple(_args, "O&hO&", ResObj_Convert, &myColors, &iTabRes, ResObj_Convert, &targetTbl)) return NULL; GetSubTable(myColors, iTabRes, targetTbl); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MakeITable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CTabHandle cTabH; ITabHandle iTabH; short res; if (!PyArg_ParseTuple(_args, "O&O&h", ResObj_Convert, &cTabH, ResObj_Convert, &iTabH, &res)) return NULL; MakeITable(cTabH, iTabH, res); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetClientID(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short id; if (!PyArg_ParseTuple(_args, "h", &id)) return NULL; SetClientID(id); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ProtectEntry(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short index; Boolean protect; if (!PyArg_ParseTuple(_args, "hb", &index, &protect)) return NULL; ProtectEntry(index, protect); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ReserveEntry(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short index; Boolean reserve; if (!PyArg_ParseTuple(_args, "hb", &index, &reserve)) return NULL; ReserveEntry(index, reserve); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_QDError(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = QDError(); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_CopyDeepMask(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMapPtr srcBits; BitMapPtr maskBits; BitMapPtr dstBits; Rect srcRect; Rect maskRect; Rect dstRect; short mode; RgnHandle maskRgn; if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&", BMObj_Convert, &srcBits, BMObj_Convert, &maskBits, BMObj_Convert, &dstBits, PyMac_GetRect, &srcRect, PyMac_GetRect, &maskRect, PyMac_GetRect, &dstRect, &mode, OptResObj_Convert, &maskRgn)) return NULL; CopyDeepMask(srcBits, maskBits, dstBits, &srcRect, &maskRect, &dstRect, mode, maskRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetPattern(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PatHandle _rv; short patternID; if (!PyArg_ParseTuple(_args, "h", &patternID)) return NULL; _rv = GetPattern(patternID); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_MacGetCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CursHandle _rv; short cursorID; if (!PyArg_ParseTuple(_args, "h", &cursorID)) return NULL; _rv = MacGetCursor(cursorID); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PicHandle _rv; short pictureID; if (!PyArg_ParseTuple(_args, "h", &pictureID)) return NULL; _rv = GetPicture(pictureID); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_DeltaPoint(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long _rv; Point ptA; Point ptB; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &ptA, PyMac_GetPoint, &ptB)) return NULL; _rv = DeltaPoint(ptA, ptB); _res = Py_BuildValue("l", _rv); return _res; } static PyObject *Qd_ShieldCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect shieldRect; Point offsetPt; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &shieldRect, PyMac_GetPoint, &offsetPt)) return NULL; ShieldCursor(&shieldRect, offsetPt); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_ScreenRes(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short scrnHRes; short scrnVRes; if (!PyArg_ParseTuple(_args, "")) return NULL; ScreenRes(&scrnHRes, &scrnVRes); _res = Py_BuildValue("hh", scrnHRes, scrnVRes); return _res; } static PyObject *Qd_GetIndPattern(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern thePat__out__; short patternListID; short index; if (!PyArg_ParseTuple(_args, "hh", &patternListID, &index)) return NULL; GetIndPattern(&thePat__out__, patternListID, index); _res = Py_BuildValue("s#", (char *)&thePat__out__, (int)sizeof(Pattern)); thePat__error__: ; return _res; } static PyObject *Qd_SlopeFromAngle(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Fixed _rv; short angle; if (!PyArg_ParseTuple(_args, "h", &angle)) return NULL; _rv = SlopeFromAngle(angle); _res = Py_BuildValue("O&", PyMac_BuildFixed, _rv); return _res; } static PyObject *Qd_AngleFromSlope(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; Fixed slope; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFixed, &slope)) return NULL; _rv = AngleFromSlope(slope); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetPortPixMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixMapHandle _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortPixMap(port); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetPortBitMapForCopyBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; const BitMap * _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortBitMapForCopyBits(port); _res = Py_BuildValue("O&", BMObj_New, _rv); return _res; } static PyObject *Qd_GetPortBounds(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; Rect rect; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; GetPortBounds(port, &rect); _res = Py_BuildValue("O&", PyMac_BuildRect, &rect); return _res; } static PyObject *Qd_GetPortForeColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RGBColor foreColor; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; GetPortForeColor(port, &foreColor); _res = Py_BuildValue("O&", QdRGB_New, &foreColor); return _res; } static PyObject *Qd_GetPortBackColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RGBColor backColor; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; GetPortBackColor(port, &backColor); _res = Py_BuildValue("O&", QdRGB_New, &backColor); return _res; } static PyObject *Qd_GetPortOpColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RGBColor opColor; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; GetPortOpColor(port, &opColor); _res = Py_BuildValue("O&", QdRGB_New, &opColor); return _res; } static PyObject *Qd_GetPortHiliteColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RGBColor hiliteColor; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; GetPortHiliteColor(port, &hiliteColor); _res = Py_BuildValue("O&", QdRGB_New, &hiliteColor); return _res; } static PyObject *Qd_GetPortTextFont(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortTextFont(port); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetPortTextFace(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Style _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortTextFace(port); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_GetPortTextMode(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortTextMode(port); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetPortTextSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortTextSize(port); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetPortChExtra(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortChExtra(port); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetPortFracHPenLocation(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortFracHPenLocation(port); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetPortSpExtra(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Fixed _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortSpExtra(port); _res = Py_BuildValue("O&", PyMac_BuildFixed, _rv); return _res; } static PyObject *Qd_GetPortPenVisibility(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortPenVisibility(port); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetPortVisibleRegion(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle _rv; CGrafPtr port; RgnHandle visRgn; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &visRgn)) return NULL; _rv = GetPortVisibleRegion(port, visRgn); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetPortClipRegion(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle _rv; CGrafPtr port; RgnHandle clipRgn; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &clipRgn)) return NULL; _rv = GetPortClipRegion(port, clipRgn); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetPortBackPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle _rv; CGrafPtr port; PixPatHandle backPattern; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &backPattern)) return NULL; _rv = GetPortBackPixPat(port, backPattern); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetPortPenPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle _rv; CGrafPtr port; PixPatHandle penPattern; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &penPattern)) return NULL; _rv = GetPortPenPixPat(port, penPattern); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetPortFillPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixPatHandle _rv; CGrafPtr port; PixPatHandle fillPattern; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &fillPattern)) return NULL; _rv = GetPortFillPixPat(port, fillPattern); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_GetPortPenSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; Point penSize; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, PyMac_GetPoint, &penSize)) return NULL; GetPortPenSize(port, &penSize); _res = Py_BuildValue("O&", PyMac_BuildPoint, penSize); return _res; } static PyObject *Qd_GetPortPenMode(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; SInt32 _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = GetPortPenMode(port); _res = Py_BuildValue("l", _rv); return _res; } static PyObject *Qd_GetPortPenLocation(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; Point penLocation; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, PyMac_GetPoint, &penLocation)) return NULL; GetPortPenLocation(port, &penLocation); _res = Py_BuildValue("O&", PyMac_BuildPoint, penLocation); return _res; } static PyObject *Qd_IsPortRegionBeingDefined(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = IsPortRegionBeingDefined(port); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_IsPortPictureBeingDefined(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = IsPortPictureBeingDefined(port); _res = Py_BuildValue("b", _rv); return _res; } #if TARGET_API_MAC_CARBON static PyObject *Qd_IsPortOffscreen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = IsPortOffscreen(port); _res = Py_BuildValue("b", _rv); return _res; } #endif #if TARGET_API_MAC_CARBON static PyObject *Qd_IsPortColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = IsPortColor(port); _res = Py_BuildValue("b", _rv); return _res; } #endif static PyObject *Qd_SetPortBounds(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; Rect rect; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, PyMac_GetRect, &rect)) return NULL; SetPortBounds(port, &rect); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortOpColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RGBColor opColor; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, QdRGB_Convert, &opColor)) return NULL; SetPortOpColor(port, &opColor); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortVisibleRegion(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RgnHandle visRgn; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &visRgn)) return NULL; SetPortVisibleRegion(port, visRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortClipRegion(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RgnHandle clipRgn; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &clipRgn)) return NULL; SetPortClipRegion(port, clipRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortPenPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; PixPatHandle penPattern; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &penPattern)) return NULL; SetPortPenPixPat(port, penPattern); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortBackPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; PixPatHandle backPattern; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, ResObj_Convert, &backPattern)) return NULL; SetPortBackPixPat(port, backPattern); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortPenSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; Point penSize; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, PyMac_GetPoint, &penSize)) return NULL; SetPortPenSize(port, penSize); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortPenMode(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; SInt32 penMode; if (!PyArg_ParseTuple(_args, "O&l", GrafObj_Convert, &port, &penMode)) return NULL; SetPortPenMode(port, penMode); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPortFracHPenLocation(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; short pnLocHFrac; if (!PyArg_ParseTuple(_args, "O&h", GrafObj_Convert, &port, &pnLocHFrac)) return NULL; SetPortFracHPenLocation(port, pnLocHFrac); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetPixBounds(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PixMapHandle pixMap; Rect bounds; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pixMap)) return NULL; GetPixBounds(pixMap, &bounds); _res = Py_BuildValue("O&", PyMac_BuildRect, &bounds); return _res; } static PyObject *Qd_GetPixDepth(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; PixMapHandle pixMap; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pixMap)) return NULL; _rv = GetPixDepth(pixMap); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_GetQDGlobalsRandomSeed(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetQDGlobalsRandomSeed(); _res = Py_BuildValue("l", _rv); return _res; } static PyObject *Qd_GetQDGlobalsScreenBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMap screenBits; if (!PyArg_ParseTuple(_args, "")) return NULL; GetQDGlobalsScreenBits(&screenBits); _res = Py_BuildValue("O&", BMObj_NewCopied, &screenBits); return _res; } static PyObject *Qd_GetQDGlobalsArrow(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Cursor arrow__out__; if (!PyArg_ParseTuple(_args, "")) return NULL; GetQDGlobalsArrow(&arrow__out__); _res = Py_BuildValue("s#", (char *)&arrow__out__, (int)sizeof(Cursor)); arrow__error__: ; return _res; } static PyObject *Qd_GetQDGlobalsDarkGray(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern dkGray__out__; if (!PyArg_ParseTuple(_args, "")) return NULL; GetQDGlobalsDarkGray(&dkGray__out__); _res = Py_BuildValue("s#", (char *)&dkGray__out__, (int)sizeof(Pattern)); dkGray__error__: ; return _res; } static PyObject *Qd_GetQDGlobalsLightGray(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern ltGray__out__; if (!PyArg_ParseTuple(_args, "")) return NULL; GetQDGlobalsLightGray(&ltGray__out__); _res = Py_BuildValue("s#", (char *)&ltGray__out__, (int)sizeof(Pattern)); ltGray__error__: ; return _res; } static PyObject *Qd_GetQDGlobalsGray(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern gray__out__; if (!PyArg_ParseTuple(_args, "")) return NULL; GetQDGlobalsGray(&gray__out__); _res = Py_BuildValue("s#", (char *)&gray__out__, (int)sizeof(Pattern)); gray__error__: ; return _res; } static PyObject *Qd_GetQDGlobalsBlack(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern black__out__; if (!PyArg_ParseTuple(_args, "")) return NULL; GetQDGlobalsBlack(&black__out__); _res = Py_BuildValue("s#", (char *)&black__out__, (int)sizeof(Pattern)); black__error__: ; return _res; } static PyObject *Qd_GetQDGlobalsWhite(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Pattern white__out__; if (!PyArg_ParseTuple(_args, "")) return NULL; GetQDGlobalsWhite(&white__out__); _res = Py_BuildValue("s#", (char *)&white__out__, (int)sizeof(Pattern)); white__error__: ; return _res; } static PyObject *Qd_GetQDGlobalsThePort(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetQDGlobalsThePort(); _res = Py_BuildValue("O&", GrafObj_New, _rv); return _res; } static PyObject *Qd_SetQDGlobalsRandomSeed(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; long randomSeed; if (!PyArg_ParseTuple(_args, "l", &randomSeed)) return NULL; SetQDGlobalsRandomSeed(randomSeed); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetQDGlobalsArrow(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Cursor *arrow__in__; int arrow__in_len__; if (!PyArg_ParseTuple(_args, "s#", (char **)&arrow__in__, &arrow__in_len__)) return NULL; if (arrow__in_len__ != sizeof(Cursor)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)"); goto arrow__error__; } SetQDGlobalsArrow(arrow__in__); Py_INCREF(Py_None); _res = Py_None; arrow__error__: ; return _res; } static PyObject *Qd_GetRegionBounds(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle region; Rect bounds; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &region)) return NULL; GetRegionBounds(region, &bounds); _res = Py_BuildValue("O&", PyMac_BuildRect, &bounds); return _res; } #if TARGET_API_MAC_CARBON static PyObject *Qd_IsRegionRectangular(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; RgnHandle region; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &region)) return NULL; _rv = IsRegionRectangular(region); _res = Py_BuildValue("b", _rv); return _res; } #endif #if TARGET_API_MAC_CARBON static PyObject *Qd_CreateNewPort(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = CreateNewPort(); _res = Py_BuildValue("O&", GrafObj_New, _rv); return _res; } #endif #if TARGET_API_MAC_CARBON static PyObject *Qd_DisposePort(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; DisposePort(port); Py_INCREF(Py_None); _res = Py_None; return _res; } #endif #if TARGET_API_MAC_CARBON static PyObject *Qd_SetQDError(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; OSErr err; if (!PyArg_ParseTuple(_args, "h", &err)) return NULL; SetQDError(err); Py_INCREF(Py_None); _res = Py_None; return _res; } #endif static PyObject *Qd_QDIsPortBuffered(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = QDIsPortBuffered(port); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_QDIsPortBufferDirty(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; CGrafPtr port; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) return NULL; _rv = QDIsPortBufferDirty(port); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_QDFlushPortBuffer(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CGrafPtr port; RgnHandle region; if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, OptResObj_Convert, &region)) return NULL; QDFlushPortBuffer(port, region); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_TextFont(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short font; if (!PyArg_ParseTuple(_args, "h", &font)) return NULL; TextFont(font); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_TextFace(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; StyleParameter face; if (!PyArg_ParseTuple(_args, "h", &face)) return NULL; TextFace(face); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_TextMode(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short mode; if (!PyArg_ParseTuple(_args, "h", &mode)) return NULL; TextMode(mode); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_TextSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short size; if (!PyArg_ParseTuple(_args, "h", &size)) return NULL; TextSize(size); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SpaceExtra(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Fixed extra; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFixed, &extra)) return NULL; SpaceExtra(extra); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_DrawChar(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CharParameter ch; if (!PyArg_ParseTuple(_args, "h", &ch)) return NULL; DrawChar(ch); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_DrawString(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Str255 s; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, s)) return NULL; DrawString(s); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_MacDrawText(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; char *textBuf__in__; int textBuf__len__; int textBuf__in_len__; short firstByte; short byteCount; if (!PyArg_ParseTuple(_args, "s#hh", &textBuf__in__, &textBuf__in_len__, &firstByte, &byteCount)) return NULL; MacDrawText(textBuf__in__, firstByte, byteCount); Py_INCREF(Py_None); _res = Py_None; textBuf__error__: ; return _res; } static PyObject *Qd_CharWidth(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; CharParameter ch; if (!PyArg_ParseTuple(_args, "h", &ch)) return NULL; _rv = CharWidth(ch); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_StringWidth(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; Str255 s; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, s)) return NULL; _rv = StringWidth(s); _res = Py_BuildValue("h", _rv); return _res; } static PyObject *Qd_TextWidth(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; char *textBuf__in__; int textBuf__len__; int textBuf__in_len__; short firstByte; short byteCount; if (!PyArg_ParseTuple(_args, "s#hh", &textBuf__in__, &textBuf__in_len__, &firstByte, &byteCount)) return NULL; _rv = TextWidth(textBuf__in__, firstByte, byteCount); _res = Py_BuildValue("h", _rv); textBuf__error__: ; return _res; } static PyObject *Qd_GetFontInfo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; FontInfo info; if (!PyArg_ParseTuple(_args, "")) return NULL; GetFontInfo(&info); _res = Py_BuildValue("O&", QdFI_New, &info); return _res; } static PyObject *Qd_CharExtra(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Fixed extra; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFixed, &extra)) return NULL; CharExtra(extra); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetPort(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; GrafPtr thePort; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &thePort)) return NULL; SetPort(thePort); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_GetCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; CursHandle _rv; short cursorID; if (!PyArg_ParseTuple(_args, "h", &cursorID)) return NULL; _rv = GetCursor(cursorID); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } static PyObject *Qd_SetCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Cursor *crsr__in__; int crsr__in_len__; if (!PyArg_ParseTuple(_args, "s#", (char **)&crsr__in__, &crsr__in_len__)) return NULL; if (crsr__in_len__ != sizeof(Cursor)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)"); goto crsr__error__; } SetCursor(crsr__in__); Py_INCREF(Py_None); _res = Py_None; crsr__error__: ; return _res; } static PyObject *Qd_ShowCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; ShowCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_LineTo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short h; short v; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; LineTo(h, v); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short left; short top; short right; short bottom; if (!PyArg_ParseTuple(_args, "hhhh", &left, &top, &right, &bottom)) return NULL; SetRect(&r, left, top, right, bottom); _res = Py_BuildValue("O&", PyMac_BuildRect, &r); return _res; } static PyObject *Qd_OffsetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &dh, &dv)) return NULL; OffsetRect(&r, dh, dv); _res = Py_BuildValue("O&", PyMac_BuildRect, &r); return _res; } static PyObject *Qd_InsetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetRect, &r, &dh, &dv)) return NULL; InsetRect(&r, dh, dv); _res = Py_BuildValue("O&", PyMac_BuildRect, &r); return _res; } static PyObject *Qd_UnionRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect src1; Rect src2; Rect dstRect; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &src1, PyMac_GetRect, &src2)) return NULL; UnionRect(&src1, &src2, &dstRect); _res = Py_BuildValue("O&", PyMac_BuildRect, &dstRect); return _res; } static PyObject *Qd_EqualRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Rect rect1; Rect rect2; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &rect1, PyMac_GetRect, &rect2)) return NULL; _rv = EqualRect(&rect1, &rect2); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_FrameRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; FrameRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InvertRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; InvertRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&s#", PyMac_GetRect, &r, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } FillRect(&r, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_CopyRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgn; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &srcRgn, ResObj_Convert, &dstRgn)) return NULL; CopyRgn(srcRgn, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_SetRectRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; short left; short top; short right; short bottom; if (!PyArg_ParseTuple(_args, "O&hhhh", ResObj_Convert, &rgn, &left, &top, &right, &bottom)) return NULL; SetRectRgn(rgn, left, top, right, bottom); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_OffsetRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; short dh; short dv; if (!PyArg_ParseTuple(_args, "O&hh", ResObj_Convert, &rgn, &dh, &dv)) return NULL; OffsetRgn(rgn, dh, dv); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_UnionRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgnA; RgnHandle srcRgnB; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &srcRgnA, ResObj_Convert, &srcRgnB, ResObj_Convert, &dstRgn)) return NULL; UnionRgn(srcRgnA, srcRgnB, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_XorRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle srcRgnA; RgnHandle srcRgnB; RgnHandle dstRgn; if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &srcRgnA, ResObj_Convert, &srcRgnB, ResObj_Convert, &dstRgn)) return NULL; XorRgn(srcRgnA, srcRgnB, dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_EqualRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; RgnHandle rgnA; RgnHandle rgnB; if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &rgnA, ResObj_Convert, &rgnB)) return NULL; _rv = EqualRgn(rgnA, rgnB); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_FrameRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; FrameRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_PaintRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; PaintRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_InvertRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; InvertRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } static PyObject *Qd_FillRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; Pattern *pat__in__; int pat__in_len__; if (!PyArg_ParseTuple(_args, "O&s#", ResObj_Convert, &rgn, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) { PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } FillRgn(rgn, pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } static PyObject *Qd_GetPixel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; short h; short v; if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; _rv = GetPixel(h, v); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_PtInRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; Point pt; Rect r; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &pt, PyMac_GetRect, &r)) return NULL; _rv = PtInRect(pt, &r); _res = Py_BuildValue("b", _rv); return _res; } static PyObject *Qd_DrawText(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; char *textBuf__in__; int textBuf__len__; int textBuf__in_len__; short firstByte; short byteCount; if (!PyArg_ParseTuple(_args, "s#hh", &textBuf__in__, &textBuf__in_len__, &firstByte, &byteCount)) return NULL; DrawText(textBuf__in__, firstByte, byteCount); Py_INCREF(Py_None); _res = Py_None; textBuf__error__: ; return _res; } static PyObject *Qd_BitMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMap *ptr; PyObject *source; Rect bounds; int rowbytes; char *data; if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect, &bounds) ) return NULL; data = PyString_AsString(source); if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL ) return PyErr_NoMemory(); ptr->baseAddr = (Ptr)data; ptr->rowBytes = rowbytes; ptr->bounds = bounds; if ( (_res = BMObj_New(ptr)) == NULL ) { free(ptr); return NULL; } ((BitMapObject *)_res)->referred_object = source; Py_INCREF(source); ((BitMapObject *)_res)->referred_bitmap = ptr; return _res; } static PyObject *Qd_RawBitMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; BitMap *ptr; PyObject *source; if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) ) return NULL; if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) { PyErr_BadArgument(); return NULL; } ptr = (BitMapPtr)PyString_AsString(source); if ( (_res = BMObj_New(ptr)) == NULL ) { return NULL; } ((BitMapObject *)_res)->referred_object = source; Py_INCREF(source); return _res; } static PyMethodDef Qd_methods[] = { {"MacSetPort", (PyCFunction)Qd_MacSetPort, 1, "(GrafPtr port) -> None"}, {"GetPort", (PyCFunction)Qd_GetPort, 1, "() -> (GrafPtr port)"}, {"GrafDevice", (PyCFunction)Qd_GrafDevice, 1, "(short device) -> None"}, {"SetPortBits", (PyCFunction)Qd_SetPortBits, 1, "(BitMapPtr bm) -> None"}, {"PortSize", (PyCFunction)Qd_PortSize, 1, "(short width, short height) -> None"}, {"MovePortTo", (PyCFunction)Qd_MovePortTo, 1, "(short leftGlobal, short topGlobal) -> None"}, {"SetOrigin", (PyCFunction)Qd_SetOrigin, 1, "(short h, short v) -> None"}, {"SetClip", (PyCFunction)Qd_SetClip, 1, "(RgnHandle rgn) -> None"}, {"GetClip", (PyCFunction)Qd_GetClip, 1, "(RgnHandle rgn) -> None"}, {"ClipRect", (PyCFunction)Qd_ClipRect, 1, "(Rect r) -> None"}, {"BackPat", (PyCFunction)Qd_BackPat, 1, "(Pattern pat) -> None"}, {"InitCursor", (PyCFunction)Qd_InitCursor, 1, "() -> None"}, {"MacSetCursor", (PyCFunction)Qd_MacSetCursor, 1, "(Cursor crsr) -> None"}, {"HideCursor", (PyCFunction)Qd_HideCursor, 1, "() -> None"}, {"MacShowCursor", (PyCFunction)Qd_MacShowCursor, 1, "() -> None"}, {"ObscureCursor", (PyCFunction)Qd_ObscureCursor, 1, "() -> None"}, {"HidePen", (PyCFunction)Qd_HidePen, 1, "() -> None"}, {"ShowPen", (PyCFunction)Qd_ShowPen, 1, "() -> None"}, {"GetPen", (PyCFunction)Qd_GetPen, 1, "() -> (Point pt)"}, {"GetPenState", (PyCFunction)Qd_GetPenState, 1, "() -> (PenState pnState)"}, {"SetPenState", (PyCFunction)Qd_SetPenState, 1, "(PenState pnState) -> None"}, {"PenSize", (PyCFunction)Qd_PenSize, 1, "(short width, short height) -> None"}, {"PenMode", (PyCFunction)Qd_PenMode, 1, "(short mode) -> None"}, {"PenPat", (PyCFunction)Qd_PenPat, 1, "(Pattern pat) -> None"}, {"PenNormal", (PyCFunction)Qd_PenNormal, 1, "() -> None"}, {"MoveTo", (PyCFunction)Qd_MoveTo, 1, "(short h, short v) -> None"}, {"Move", (PyCFunction)Qd_Move, 1, "(short dh, short dv) -> None"}, {"MacLineTo", (PyCFunction)Qd_MacLineTo, 1, "(short h, short v) -> None"}, {"Line", (PyCFunction)Qd_Line, 1, "(short dh, short dv) -> None"}, {"ForeColor", (PyCFunction)Qd_ForeColor, 1, "(long color) -> None"}, {"BackColor", (PyCFunction)Qd_BackColor, 1, "(long color) -> None"}, {"ColorBit", (PyCFunction)Qd_ColorBit, 1, "(short whichBit) -> None"}, {"MacSetRect", (PyCFunction)Qd_MacSetRect, 1, "(short left, short top, short right, short bottom) -> (Rect r)"}, {"MacOffsetRect", (PyCFunction)Qd_MacOffsetRect, 1, "(Rect r, short dh, short dv) -> (Rect r)"}, {"MacInsetRect", (PyCFunction)Qd_MacInsetRect, 1, "(Rect r, short dh, short dv) -> (Rect r)"}, {"SectRect", (PyCFunction)Qd_SectRect, 1, "(Rect src1, Rect src2) -> (Boolean _rv, Rect dstRect)"}, {"MacUnionRect", (PyCFunction)Qd_MacUnionRect, 1, "(Rect src1, Rect src2) -> (Rect dstRect)"}, {"MacEqualRect", (PyCFunction)Qd_MacEqualRect, 1, "(Rect rect1, Rect rect2) -> (Boolean _rv)"}, {"EmptyRect", (PyCFunction)Qd_EmptyRect, 1, "(Rect r) -> (Boolean _rv)"}, {"MacFrameRect", (PyCFunction)Qd_MacFrameRect, 1, "(Rect r) -> None"}, {"PaintRect", (PyCFunction)Qd_PaintRect, 1, "(Rect r) -> None"}, {"EraseRect", (PyCFunction)Qd_EraseRect, 1, "(Rect r) -> None"}, {"MacInvertRect", (PyCFunction)Qd_MacInvertRect, 1, "(Rect r) -> None"}, {"MacFillRect", (PyCFunction)Qd_MacFillRect, 1, "(Rect r, Pattern pat) -> None"}, {"FrameOval", (PyCFunction)Qd_FrameOval, 1, "(Rect r) -> None"}, {"PaintOval", (PyCFunction)Qd_PaintOval, 1, "(Rect r) -> None"}, {"EraseOval", (PyCFunction)Qd_EraseOval, 1, "(Rect r) -> None"}, {"InvertOval", (PyCFunction)Qd_InvertOval, 1, "(Rect r) -> None"}, {"FillOval", (PyCFunction)Qd_FillOval, 1, "(Rect r, Pattern pat) -> None"}, {"FrameRoundRect", (PyCFunction)Qd_FrameRoundRect, 1, "(Rect r, short ovalWidth, short ovalHeight) -> None"}, {"PaintRoundRect", (PyCFunction)Qd_PaintRoundRect, 1, "(Rect r, short ovalWidth, short ovalHeight) -> None"}, {"EraseRoundRect", (PyCFunction)Qd_EraseRoundRect, 1, "(Rect r, short ovalWidth, short ovalHeight) -> None"}, {"InvertRoundRect", (PyCFunction)Qd_InvertRoundRect, 1, "(Rect r, short ovalWidth, short ovalHeight) -> None"}, {"FillRoundRect", (PyCFunction)Qd_FillRoundRect, 1, "(Rect r, short ovalWidth, short ovalHeight, Pattern pat) -> None"}, {"FrameArc", (PyCFunction)Qd_FrameArc, 1, "(Rect r, short startAngle, short arcAngle) -> None"}, {"PaintArc", (PyCFunction)Qd_PaintArc, 1, "(Rect r, short startAngle, short arcAngle) -> None"}, {"EraseArc", (PyCFunction)Qd_EraseArc, 1, "(Rect r, short startAngle, short arcAngle) -> None"}, {"InvertArc", (PyCFunction)Qd_InvertArc, 1, "(Rect r, short startAngle, short arcAngle) -> None"}, {"FillArc", (PyCFunction)Qd_FillArc, 1, "(Rect r, short startAngle, short arcAngle, Pattern pat) -> None"}, {"NewRgn", (PyCFunction)Qd_NewRgn, 1, "() -> (RgnHandle _rv)"}, {"OpenRgn", (PyCFunction)Qd_OpenRgn, 1, "() -> None"}, {"CloseRgn", (PyCFunction)Qd_CloseRgn, 1, "(RgnHandle dstRgn) -> None"}, {"BitMapToRegion", (PyCFunction)Qd_BitMapToRegion, 1, "(RgnHandle region, BitMapPtr bMap) -> None"}, {"DisposeRgn", (PyCFunction)Qd_DisposeRgn, 1, "(RgnHandle rgn) -> None"}, {"MacCopyRgn", (PyCFunction)Qd_MacCopyRgn, 1, "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"}, {"SetEmptyRgn", (PyCFunction)Qd_SetEmptyRgn, 1, "(RgnHandle rgn) -> None"}, {"MacSetRectRgn", (PyCFunction)Qd_MacSetRectRgn, 1, "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"}, {"RectRgn", (PyCFunction)Qd_RectRgn, 1, "(RgnHandle rgn, Rect r) -> None"}, {"MacOffsetRgn", (PyCFunction)Qd_MacOffsetRgn, 1, "(RgnHandle rgn, short dh, short dv) -> None"}, {"InsetRgn", (PyCFunction)Qd_InsetRgn, 1, "(RgnHandle rgn, short dh, short dv) -> None"}, {"SectRgn", (PyCFunction)Qd_SectRgn, 1, "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, {"MacUnionRgn", (PyCFunction)Qd_MacUnionRgn, 1, "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, {"DiffRgn", (PyCFunction)Qd_DiffRgn, 1, "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, {"MacXorRgn", (PyCFunction)Qd_MacXorRgn, 1, "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, {"RectInRgn", (PyCFunction)Qd_RectInRgn, 1, "(Rect r, RgnHandle rgn) -> (Boolean _rv)"}, {"MacEqualRgn", (PyCFunction)Qd_MacEqualRgn, 1, "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"}, {"EmptyRgn", (PyCFunction)Qd_EmptyRgn, 1, "(RgnHandle rgn) -> (Boolean _rv)"}, {"MacFrameRgn", (PyCFunction)Qd_MacFrameRgn, 1, "(RgnHandle rgn) -> None"}, {"MacPaintRgn", (PyCFunction)Qd_MacPaintRgn, 1, "(RgnHandle rgn) -> None"}, {"EraseRgn", (PyCFunction)Qd_EraseRgn, 1, "(RgnHandle rgn) -> None"}, {"MacInvertRgn", (PyCFunction)Qd_MacInvertRgn, 1, "(RgnHandle rgn) -> None"}, {"MacFillRgn", (PyCFunction)Qd_MacFillRgn, 1, "(RgnHandle rgn, Pattern pat) -> None"}, {"ScrollRect", (PyCFunction)Qd_ScrollRect, 1, "(Rect r, short dh, short dv, RgnHandle updateRgn) -> None"}, {"CopyBits", (PyCFunction)Qd_CopyBits, 1, "(BitMapPtr srcBits, BitMapPtr dstBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"}, {"CopyMask", (PyCFunction)Qd_CopyMask, 1, "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect) -> None"}, {"OpenPicture", (PyCFunction)Qd_OpenPicture, 1, "(Rect picFrame) -> (PicHandle _rv)"}, {"PicComment", (PyCFunction)Qd_PicComment, 1, "(short kind, short dataSize, Handle dataHandle) -> None"}, {"ClosePicture", (PyCFunction)Qd_ClosePicture, 1, "() -> None"}, {"DrawPicture", (PyCFunction)Qd_DrawPicture, 1, "(PicHandle myPicture, Rect dstRect) -> None"}, {"KillPicture", (PyCFunction)Qd_KillPicture, 1, "(PicHandle myPicture) -> None"}, {"OpenPoly", (PyCFunction)Qd_OpenPoly, 1, "() -> (PolyHandle _rv)"}, {"ClosePoly", (PyCFunction)Qd_ClosePoly, 1, "() -> None"}, {"KillPoly", (PyCFunction)Qd_KillPoly, 1, "(PolyHandle poly) -> None"}, {"OffsetPoly", (PyCFunction)Qd_OffsetPoly, 1, "(PolyHandle poly, short dh, short dv) -> None"}, {"FramePoly", (PyCFunction)Qd_FramePoly, 1, "(PolyHandle poly) -> None"}, {"PaintPoly", (PyCFunction)Qd_PaintPoly, 1, "(PolyHandle poly) -> None"}, {"ErasePoly", (PyCFunction)Qd_ErasePoly, 1, "(PolyHandle poly) -> None"}, {"InvertPoly", (PyCFunction)Qd_InvertPoly, 1, "(PolyHandle poly) -> None"}, {"FillPoly", (PyCFunction)Qd_FillPoly, 1, "(PolyHandle poly, Pattern pat) -> None"}, {"SetPt", (PyCFunction)Qd_SetPt, 1, "(short h, short v) -> (Point pt)"}, {"LocalToGlobal", (PyCFunction)Qd_LocalToGlobal, 1, "(Point pt) -> (Point pt)"}, {"GlobalToLocal", (PyCFunction)Qd_GlobalToLocal, 1, "(Point pt) -> (Point pt)"}, {"Random", (PyCFunction)Qd_Random, 1, "() -> (short _rv)"}, {"MacGetPixel", (PyCFunction)Qd_MacGetPixel, 1, "(short h, short v) -> (Boolean _rv)"}, {"ScalePt", (PyCFunction)Qd_ScalePt, 1, "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"}, {"MapPt", (PyCFunction)Qd_MapPt, 1, "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"}, {"MapRect", (PyCFunction)Qd_MapRect, 1, "(Rect r, Rect srcRect, Rect dstRect) -> (Rect r)"}, {"MapRgn", (PyCFunction)Qd_MapRgn, 1, "(RgnHandle rgn, Rect srcRect, Rect dstRect) -> None"}, {"MapPoly", (PyCFunction)Qd_MapPoly, 1, "(PolyHandle poly, Rect srcRect, Rect dstRect) -> None"}, {"StdBits", (PyCFunction)Qd_StdBits, 1, "(BitMapPtr srcBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"}, {"AddPt", (PyCFunction)Qd_AddPt, 1, "(Point src, Point dst) -> (Point dst)"}, {"EqualPt", (PyCFunction)Qd_EqualPt, 1, "(Point pt1, Point pt2) -> (Boolean _rv)"}, {"MacPtInRect", (PyCFunction)Qd_MacPtInRect, 1, "(Point pt, Rect r) -> (Boolean _rv)"}, {"Pt2Rect", (PyCFunction)Qd_Pt2Rect, 1, "(Point pt1, Point pt2) -> (Rect dstRect)"}, {"PtToAngle", (PyCFunction)Qd_PtToAngle, 1, "(Rect r, Point pt) -> (short angle)"}, {"SubPt", (PyCFunction)Qd_SubPt, 1, "(Point src, Point dst) -> (Point dst)"}, {"PtInRgn", (PyCFunction)Qd_PtInRgn, 1, "(Point pt, RgnHandle rgn) -> (Boolean _rv)"}, {"NewPixMap", (PyCFunction)Qd_NewPixMap, 1, "() -> (PixMapHandle _rv)"}, {"DisposePixMap", (PyCFunction)Qd_DisposePixMap, 1, "(PixMapHandle pm) -> None"}, {"CopyPixMap", (PyCFunction)Qd_CopyPixMap, 1, "(PixMapHandle srcPM, PixMapHandle dstPM) -> None"}, {"NewPixPat", (PyCFunction)Qd_NewPixPat, 1, "() -> (PixPatHandle _rv)"}, {"DisposePixPat", (PyCFunction)Qd_DisposePixPat, 1, "(PixPatHandle pp) -> None"}, {"CopyPixPat", (PyCFunction)Qd_CopyPixPat, 1, "(PixPatHandle srcPP, PixPatHandle dstPP) -> None"}, {"PenPixPat", (PyCFunction)Qd_PenPixPat, 1, "(PixPatHandle pp) -> None"}, {"BackPixPat", (PyCFunction)Qd_BackPixPat, 1, "(PixPatHandle pp) -> None"}, {"GetPixPat", (PyCFunction)Qd_GetPixPat, 1, "(short patID) -> (PixPatHandle _rv)"}, {"MakeRGBPat", (PyCFunction)Qd_MakeRGBPat, 1, "(PixPatHandle pp, RGBColor myColor) -> None"}, {"FillCRect", (PyCFunction)Qd_FillCRect, 1, "(Rect r, PixPatHandle pp) -> None"}, {"FillCOval", (PyCFunction)Qd_FillCOval, 1, "(Rect r, PixPatHandle pp) -> None"}, {"FillCRoundRect", (PyCFunction)Qd_FillCRoundRect, 1, "(Rect r, short ovalWidth, short ovalHeight, PixPatHandle pp) -> None"}, {"FillCArc", (PyCFunction)Qd_FillCArc, 1, "(Rect r, short startAngle, short arcAngle, PixPatHandle pp) -> None"}, {"FillCRgn", (PyCFunction)Qd_FillCRgn, 1, "(RgnHandle rgn, PixPatHandle pp) -> None"}, {"FillCPoly", (PyCFunction)Qd_FillCPoly, 1, "(PolyHandle poly, PixPatHandle pp) -> None"}, {"RGBForeColor", (PyCFunction)Qd_RGBForeColor, 1, "(RGBColor color) -> None"}, {"RGBBackColor", (PyCFunction)Qd_RGBBackColor, 1, "(RGBColor color) -> None"}, {"SetCPixel", (PyCFunction)Qd_SetCPixel, 1, "(short h, short v, RGBColor cPix) -> None"}, {"SetPortPix", (PyCFunction)Qd_SetPortPix, 1, "(PixMapHandle pm) -> None"}, {"GetCPixel", (PyCFunction)Qd_GetCPixel, 1, "(short h, short v) -> (RGBColor cPix)"}, {"GetForeColor", (PyCFunction)Qd_GetForeColor, 1, "() -> (RGBColor color)"}, {"GetBackColor", (PyCFunction)Qd_GetBackColor, 1, "() -> (RGBColor color)"}, {"OpColor", (PyCFunction)Qd_OpColor, 1, "(RGBColor color) -> None"}, {"HiliteColor", (PyCFunction)Qd_HiliteColor, 1, "(RGBColor color) -> None"}, {"DisposeCTable", (PyCFunction)Qd_DisposeCTable, 1, "(CTabHandle cTable) -> None"}, {"GetCTable", (PyCFunction)Qd_GetCTable, 1, "(short ctID) -> (CTabHandle _rv)"}, {"GetCCursor", (PyCFunction)Qd_GetCCursor, 1, "(short crsrID) -> (CCrsrHandle _rv)"}, {"SetCCursor", (PyCFunction)Qd_SetCCursor, 1, "(CCrsrHandle cCrsr) -> None"}, {"AllocCursor", (PyCFunction)Qd_AllocCursor, 1, "() -> None"}, {"DisposeCCursor", (PyCFunction)Qd_DisposeCCursor, 1, "(CCrsrHandle cCrsr) -> None"}, {"GetMaxDevice", (PyCFunction)Qd_GetMaxDevice, 1, "(Rect globalRect) -> (GDHandle _rv)"}, {"GetCTSeed", (PyCFunction)Qd_GetCTSeed, 1, "() -> (long _rv)"}, {"GetDeviceList", (PyCFunction)Qd_GetDeviceList, 1, "() -> (GDHandle _rv)"}, {"GetMainDevice", (PyCFunction)Qd_GetMainDevice, 1, "() -> (GDHandle _rv)"}, {"GetNextDevice", (PyCFunction)Qd_GetNextDevice, 1, "(GDHandle curDevice) -> (GDHandle _rv)"}, {"TestDeviceAttribute", (PyCFunction)Qd_TestDeviceAttribute, 1, "(GDHandle gdh, short attribute) -> (Boolean _rv)"}, {"SetDeviceAttribute", (PyCFunction)Qd_SetDeviceAttribute, 1, "(GDHandle gdh, short attribute, Boolean value) -> None"}, {"InitGDevice", (PyCFunction)Qd_InitGDevice, 1, "(short qdRefNum, long mode, GDHandle gdh) -> None"}, {"NewGDevice", (PyCFunction)Qd_NewGDevice, 1, "(short refNum, long mode) -> (GDHandle _rv)"}, {"DisposeGDevice", (PyCFunction)Qd_DisposeGDevice, 1, "(GDHandle gdh) -> None"}, {"SetGDevice", (PyCFunction)Qd_SetGDevice, 1, "(GDHandle gd) -> None"}, {"GetGDevice", (PyCFunction)Qd_GetGDevice, 1, "() -> (GDHandle _rv)"}, {"Color2Index", (PyCFunction)Qd_Color2Index, 1, "(RGBColor myColor) -> (long _rv)"}, {"Index2Color", (PyCFunction)Qd_Index2Color, 1, "(long index) -> (RGBColor aColor)"}, {"InvertColor", (PyCFunction)Qd_InvertColor, 1, "() -> (RGBColor myColor)"}, {"RealColor", (PyCFunction)Qd_RealColor, 1, "(RGBColor color) -> (Boolean _rv)"}, {"GetSubTable", (PyCFunction)Qd_GetSubTable, 1, "(CTabHandle myColors, short iTabRes, CTabHandle targetTbl) -> None"}, {"MakeITable", (PyCFunction)Qd_MakeITable, 1, "(CTabHandle cTabH, ITabHandle iTabH, short res) -> None"}, {"SetClientID", (PyCFunction)Qd_SetClientID, 1, "(short id) -> None"}, {"ProtectEntry", (PyCFunction)Qd_ProtectEntry, 1, "(short index, Boolean protect) -> None"}, {"ReserveEntry", (PyCFunction)Qd_ReserveEntry, 1, "(short index, Boolean reserve) -> None"}, {"QDError", (PyCFunction)Qd_QDError, 1, "() -> (short _rv)"}, {"CopyDeepMask", (PyCFunction)Qd_CopyDeepMask, 1, "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"}, {"GetPattern", (PyCFunction)Qd_GetPattern, 1, "(short patternID) -> (PatHandle _rv)"}, {"MacGetCursor", (PyCFunction)Qd_MacGetCursor, 1, "(short cursorID) -> (CursHandle _rv)"}, {"GetPicture", (PyCFunction)Qd_GetPicture, 1, "(short pictureID) -> (PicHandle _rv)"}, {"DeltaPoint", (PyCFunction)Qd_DeltaPoint, 1, "(Point ptA, Point ptB) -> (long _rv)"}, {"ShieldCursor", (PyCFunction)Qd_ShieldCursor, 1, "(Rect shieldRect, Point offsetPt) -> None"}, {"ScreenRes", (PyCFunction)Qd_ScreenRes, 1, "() -> (short scrnHRes, short scrnVRes)"}, {"GetIndPattern", (PyCFunction)Qd_GetIndPattern, 1, "(short patternListID, short index) -> (Pattern thePat)"}, {"SlopeFromAngle", (PyCFunction)Qd_SlopeFromAngle, 1, "(short angle) -> (Fixed _rv)"}, {"AngleFromSlope", (PyCFunction)Qd_AngleFromSlope, 1, "(Fixed slope) -> (short _rv)"}, {"GetPortPixMap", (PyCFunction)Qd_GetPortPixMap, 1, "(CGrafPtr port) -> (PixMapHandle _rv)"}, {"GetPortBitMapForCopyBits", (PyCFunction)Qd_GetPortBitMapForCopyBits, 1, "(CGrafPtr port) -> (const BitMap * _rv)"}, {"GetPortBounds", (PyCFunction)Qd_GetPortBounds, 1, "(CGrafPtr port) -> (Rect rect)"}, {"GetPortForeColor", (PyCFunction)Qd_GetPortForeColor, 1, "(CGrafPtr port) -> (RGBColor foreColor)"}, {"GetPortBackColor", (PyCFunction)Qd_GetPortBackColor, 1, "(CGrafPtr port) -> (RGBColor backColor)"}, {"GetPortOpColor", (PyCFunction)Qd_GetPortOpColor, 1, "(CGrafPtr port) -> (RGBColor opColor)"}, {"GetPortHiliteColor", (PyCFunction)Qd_GetPortHiliteColor, 1, "(CGrafPtr port) -> (RGBColor hiliteColor)"}, {"GetPortTextFont", (PyCFunction)Qd_GetPortTextFont, 1, "(CGrafPtr port) -> (short _rv)"}, {"GetPortTextFace", (PyCFunction)Qd_GetPortTextFace, 1, "(CGrafPtr port) -> (Style _rv)"}, {"GetPortTextMode", (PyCFunction)Qd_GetPortTextMode, 1, "(CGrafPtr port) -> (short _rv)"}, {"GetPortTextSize", (PyCFunction)Qd_GetPortTextSize, 1, "(CGrafPtr port) -> (short _rv)"}, {"GetPortChExtra", (PyCFunction)Qd_GetPortChExtra, 1, "(CGrafPtr port) -> (short _rv)"}, {"GetPortFracHPenLocation", (PyCFunction)Qd_GetPortFracHPenLocation, 1, "(CGrafPtr port) -> (short _rv)"}, {"GetPortSpExtra", (PyCFunction)Qd_GetPortSpExtra, 1, "(CGrafPtr port) -> (Fixed _rv)"}, {"GetPortPenVisibility", (PyCFunction)Qd_GetPortPenVisibility, 1, "(CGrafPtr port) -> (short _rv)"}, {"GetPortVisibleRegion", (PyCFunction)Qd_GetPortVisibleRegion, 1, "(CGrafPtr port, RgnHandle visRgn) -> (RgnHandle _rv)"}, {"GetPortClipRegion", (PyCFunction)Qd_GetPortClipRegion, 1, "(CGrafPtr port, RgnHandle clipRgn) -> (RgnHandle _rv)"}, {"GetPortBackPixPat", (PyCFunction)Qd_GetPortBackPixPat, 1, "(CGrafPtr port, PixPatHandle backPattern) -> (PixPatHandle _rv)"}, {"GetPortPenPixPat", (PyCFunction)Qd_GetPortPenPixPat, 1, "(CGrafPtr port, PixPatHandle penPattern) -> (PixPatHandle _rv)"}, {"GetPortFillPixPat", (PyCFunction)Qd_GetPortFillPixPat, 1, "(CGrafPtr port, PixPatHandle fillPattern) -> (PixPatHandle _rv)"}, {"GetPortPenSize", (PyCFunction)Qd_GetPortPenSize, 1, "(CGrafPtr port, Point penSize) -> (Point penSize)"}, {"GetPortPenMode", (PyCFunction)Qd_GetPortPenMode, 1, "(CGrafPtr port) -> (SInt32 _rv)"}, {"GetPortPenLocation", (PyCFunction)Qd_GetPortPenLocation, 1, "(CGrafPtr port, Point penLocation) -> (Point penLocation)"}, {"IsPortRegionBeingDefined", (PyCFunction)Qd_IsPortRegionBeingDefined, 1, "(CGrafPtr port) -> (Boolean _rv)"}, {"IsPortPictureBeingDefined", (PyCFunction)Qd_IsPortPictureBeingDefined, 1, "(CGrafPtr port) -> (Boolean _rv)"}, #if TARGET_API_MAC_CARBON {"IsPortOffscreen", (PyCFunction)Qd_IsPortOffscreen, 1, "(CGrafPtr port) -> (Boolean _rv)"}, #endif #if TARGET_API_MAC_CARBON {"IsPortColor", (PyCFunction)Qd_IsPortColor, 1, "(CGrafPtr port) -> (Boolean _rv)"}, #endif {"SetPortBounds", (PyCFunction)Qd_SetPortBounds, 1, "(CGrafPtr port, Rect rect) -> None"}, {"SetPortOpColor", (PyCFunction)Qd_SetPortOpColor, 1, "(CGrafPtr port, RGBColor opColor) -> None"}, {"SetPortVisibleRegion", (PyCFunction)Qd_SetPortVisibleRegion, 1, "(CGrafPtr port, RgnHandle visRgn) -> None"}, {"SetPortClipRegion", (PyCFunction)Qd_SetPortClipRegion, 1, "(CGrafPtr port, RgnHandle clipRgn) -> None"}, {"SetPortPenPixPat", (PyCFunction)Qd_SetPortPenPixPat, 1, "(CGrafPtr port, PixPatHandle penPattern) -> None"}, {"SetPortBackPixPat", (PyCFunction)Qd_SetPortBackPixPat, 1, "(CGrafPtr port, PixPatHandle backPattern) -> None"}, {"SetPortPenSize", (PyCFunction)Qd_SetPortPenSize, 1, "(CGrafPtr port, Point penSize) -> None"}, {"SetPortPenMode", (PyCFunction)Qd_SetPortPenMode, 1, "(CGrafPtr port, SInt32 penMode) -> None"}, {"SetPortFracHPenLocation", (PyCFunction)Qd_SetPortFracHPenLocation, 1, "(CGrafPtr port, short pnLocHFrac) -> None"}, {"GetPixBounds", (PyCFunction)Qd_GetPixBounds, 1, "(PixMapHandle pixMap) -> (Rect bounds)"}, {"GetPixDepth", (PyCFunction)Qd_GetPixDepth, 1, "(PixMapHandle pixMap) -> (short _rv)"}, {"GetQDGlobalsRandomSeed", (PyCFunction)Qd_GetQDGlobalsRandomSeed, 1, "() -> (long _rv)"}, {"GetQDGlobalsScreenBits", (PyCFunction)Qd_GetQDGlobalsScreenBits, 1, "() -> (BitMap screenBits)"}, {"GetQDGlobalsArrow", (PyCFunction)Qd_GetQDGlobalsArrow, 1, "() -> (Cursor arrow)"}, {"GetQDGlobalsDarkGray", (PyCFunction)Qd_GetQDGlobalsDarkGray, 1, "() -> (Pattern dkGray)"}, {"GetQDGlobalsLightGray", (PyCFunction)Qd_GetQDGlobalsLightGray, 1, "() -> (Pattern ltGray)"}, {"GetQDGlobalsGray", (PyCFunction)Qd_GetQDGlobalsGray, 1, "() -> (Pattern gray)"}, {"GetQDGlobalsBlack", (PyCFunction)Qd_GetQDGlobalsBlack, 1, "() -> (Pattern black)"}, {"GetQDGlobalsWhite", (PyCFunction)Qd_GetQDGlobalsWhite, 1, "() -> (Pattern white)"}, {"GetQDGlobalsThePort", (PyCFunction)Qd_GetQDGlobalsThePort, 1, "() -> (CGrafPtr _rv)"}, {"SetQDGlobalsRandomSeed", (PyCFunction)Qd_SetQDGlobalsRandomSeed, 1, "(long randomSeed) -> None"}, {"SetQDGlobalsArrow", (PyCFunction)Qd_SetQDGlobalsArrow, 1, "(Cursor arrow) -> None"}, {"GetRegionBounds", (PyCFunction)Qd_GetRegionBounds, 1, "(RgnHandle region) -> (Rect bounds)"}, #if TARGET_API_MAC_CARBON {"IsRegionRectangular", (PyCFunction)Qd_IsRegionRectangular, 1, "(RgnHandle region) -> (Boolean _rv)"}, #endif #if TARGET_API_MAC_CARBON {"CreateNewPort", (PyCFunction)Qd_CreateNewPort, 1, "() -> (CGrafPtr _rv)"}, #endif #if TARGET_API_MAC_CARBON {"DisposePort", (PyCFunction)Qd_DisposePort, 1, "(CGrafPtr port) -> None"}, #endif #if TARGET_API_MAC_CARBON {"SetQDError", (PyCFunction)Qd_SetQDError, 1, "(OSErr err) -> None"}, #endif {"QDIsPortBuffered", (PyCFunction)Qd_QDIsPortBuffered, 1, "(CGrafPtr port) -> (Boolean _rv)"}, {"QDIsPortBufferDirty", (PyCFunction)Qd_QDIsPortBufferDirty, 1, "(CGrafPtr port) -> (Boolean _rv)"}, {"QDFlushPortBuffer", (PyCFunction)Qd_QDFlushPortBuffer, 1, "(CGrafPtr port, RgnHandle region) -> None"}, {"TextFont", (PyCFunction)Qd_TextFont, 1, "(short font) -> None"}, {"TextFace", (PyCFunction)Qd_TextFace, 1, "(StyleParameter face) -> None"}, {"TextMode", (PyCFunction)Qd_TextMode, 1, "(short mode) -> None"}, {"TextSize", (PyCFunction)Qd_TextSize, 1, "(short size) -> None"}, {"SpaceExtra", (PyCFunction)Qd_SpaceExtra, 1, "(Fixed extra) -> None"}, {"DrawChar", (PyCFunction)Qd_DrawChar, 1, "(CharParameter ch) -> None"}, {"DrawString", (PyCFunction)Qd_DrawString, 1, "(Str255 s) -> None"}, {"MacDrawText", (PyCFunction)Qd_MacDrawText, 1, "(Buffer textBuf, short firstByte, short byteCount) -> None"}, {"CharWidth", (PyCFunction)Qd_CharWidth, 1, "(CharParameter ch) -> (short _rv)"}, {"StringWidth", (PyCFunction)Qd_StringWidth, 1, "(Str255 s) -> (short _rv)"}, {"TextWidth", (PyCFunction)Qd_TextWidth, 1, "(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"}, {"GetFontInfo", (PyCFunction)Qd_GetFontInfo, 1, "() -> (FontInfo info)"}, {"CharExtra", (PyCFunction)Qd_CharExtra, 1, "(Fixed extra) -> None"}, {"SetPort", (PyCFunction)Qd_SetPort, 1, "(GrafPtr thePort) -> None"}, {"GetCursor", (PyCFunction)Qd_GetCursor, 1, "(short cursorID) -> (CursHandle _rv)"}, {"SetCursor", (PyCFunction)Qd_SetCursor, 1, "(Cursor crsr) -> None"}, {"ShowCursor", (PyCFunction)Qd_ShowCursor, 1, "() -> None"}, {"LineTo", (PyCFunction)Qd_LineTo, 1, "(short h, short v) -> None"}, {"SetRect", (PyCFunction)Qd_SetRect, 1, "(short left, short top, short right, short bottom) -> (Rect r)"}, {"OffsetRect", (PyCFunction)Qd_OffsetRect, 1, "(Rect r, short dh, short dv) -> (Rect r)"}, {"InsetRect", (PyCFunction)Qd_InsetRect, 1, "(Rect r, short dh, short dv) -> (Rect r)"}, {"UnionRect", (PyCFunction)Qd_UnionRect, 1, "(Rect src1, Rect src2) -> (Rect dstRect)"}, {"EqualRect", (PyCFunction)Qd_EqualRect, 1, "(Rect rect1, Rect rect2) -> (Boolean _rv)"}, {"FrameRect", (PyCFunction)Qd_FrameRect, 1, "(Rect r) -> None"}, {"InvertRect", (PyCFunction)Qd_InvertRect, 1, "(Rect r) -> None"}, {"FillRect", (PyCFunction)Qd_FillRect, 1, "(Rect r, Pattern pat) -> None"}, {"CopyRgn", (PyCFunction)Qd_CopyRgn, 1, "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"}, {"SetRectRgn", (PyCFunction)Qd_SetRectRgn, 1, "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"}, {"OffsetRgn", (PyCFunction)Qd_OffsetRgn, 1, "(RgnHandle rgn, short dh, short dv) -> None"}, {"UnionRgn", (PyCFunction)Qd_UnionRgn, 1, "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, {"XorRgn", (PyCFunction)Qd_XorRgn, 1, "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"}, {"EqualRgn", (PyCFunction)Qd_EqualRgn, 1, "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"}, {"FrameRgn", (PyCFunction)Qd_FrameRgn, 1, "(RgnHandle rgn) -> None"}, {"PaintRgn", (PyCFunction)Qd_PaintRgn, 1, "(RgnHandle rgn) -> None"}, {"InvertRgn", (PyCFunction)Qd_InvertRgn, 1, "(RgnHandle rgn) -> None"}, {"FillRgn", (PyCFunction)Qd_FillRgn, 1, "(RgnHandle rgn, Pattern pat) -> None"}, {"GetPixel", (PyCFunction)Qd_GetPixel, 1, "(short h, short v) -> (Boolean _rv)"}, {"PtInRect", (PyCFunction)Qd_PtInRect, 1, "(Point pt, Rect r) -> (Boolean _rv)"}, {"DrawText", (PyCFunction)Qd_DrawText, 1, "(Buffer textBuf, short firstByte, short byteCount) -> None"}, {"BitMap", (PyCFunction)Qd_BitMap, 1, "Take (string, int, Rect) argument and create BitMap"}, {"RawBitMap", (PyCFunction)Qd_RawBitMap, 1, "Take string BitMap and turn into BitMap object"}, {NULL, NULL, 0} }; /* Like BMObj_New, but the original bitmap data structure is copied (and ** released when the object is released) */ PyObject *BMObj_NewCopied(BitMapPtr itself) { BitMapObject *it; BitMapPtr itself_copy; if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL) return PyErr_NoMemory(); *itself_copy = *itself; it = (BitMapObject *)BMObj_New(itself_copy); it->referred_bitmap = itself_copy; return (PyObject *)it; } void initQd(void) { PyObject *m; PyObject *d; PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New); PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert); PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New); PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert); PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New); PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert); m = Py_InitModule("Qd", Qd_methods); d = PyModule_GetDict(m); Qd_Error = PyMac_GetOSErrException(); if (Qd_Error == NULL || PyDict_SetItemString(d, "Error", Qd_Error) != 0) return; GrafPort_Type.ob_type = &PyType_Type; Py_INCREF(&GrafPort_Type); if (PyDict_SetItemString(d, "GrafPortType", (PyObject *)&GrafPort_Type) != 0) Py_FatalError("can't initialize GrafPortType"); BitMap_Type.ob_type = &PyType_Type; Py_INCREF(&BitMap_Type); if (PyDict_SetItemString(d, "BitMapType", (PyObject *)&BitMap_Type) != 0) Py_FatalError("can't initialize BitMapType"); QDGlobalsAccess_Type.ob_type = &PyType_Type; Py_INCREF(&QDGlobalsAccess_Type); if (PyDict_SetItemString(d, "QDGlobalsAccessType", (PyObject *)&QDGlobalsAccess_Type) != 0) Py_FatalError("can't initialize QDGlobalsAccessType"); { PyObject *o; o = QDGA_New(); if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0) return; } } /* ========================= End module Qd ========================== */
26.095464
146
0.630919
[ "object" ]
c654c7cdd284263a7cad2f81276ecb24bca55ecc
7,103
c
C
src/dataSubset.c
gonsie/ddcMD
d229248898b34630e166966bd00b0c4e0a1a2411
[ "MIT" ]
20
2020-07-28T01:14:22.000Z
2022-03-08T07:28:45.000Z
src/dataSubset.c
gonsie/ddcMD
d229248898b34630e166966bd00b0c4e0a1a2411
[ "MIT" ]
5
2020-07-29T06:55:57.000Z
2021-12-06T04:58:31.000Z
src/dataSubset.c
gonsie/ddcMD
d229248898b34630e166966bd00b0c4e0a1a2411
[ "MIT" ]
7
2020-07-28T08:01:32.000Z
2022-03-24T16:38:14.000Z
/* enum PRINTINFO_ENUM { PLENGTH,PMASS,PTIME,PCURRENT,PTEMPERATURE,PAMOUNT,PLUMINOUS_INTENSITY,PENERGY,PPRESSURE,PVOLUME,PFORCE,PENERGYFLUX,NUNITS}; static char *unitnames[] = { "LENGTH","MASS","TIME","CURRENT","TEMPERATURE","AMOUNT","LUMINOUS_INTENSITY","ENERGY","PRESSURE","VOLUME","FORCE","ENERGYFLUX"}; static char *unitDefaultValue[] = { "Ang", "amu", "fs", "e/fs", "K", "1", "1", "eV", "GPa", "Bohr^3","eV/Ang","ueV/Ang^2/fs"}; for (int i=0;i<NUNITS;i++) { printinfo->units[i].name=unitnames[i]; object_get((OBJECT*) printinfo,unitnames[i],&printinfo->units[i].value,STRING,1,unitDefaultValue[i]); } */ // accumulate a simple time average of the force on certain particles // append the values to an output file // #include "dataSubset.h" #include <stdlib.h> #include <string.h> #include <assert.h> //#include "box.h" #include "object.h" #include "pio.h" #include "io.h" #include "crc32.h" #include "ddcMalloc.h" #include "units.h" #include "mpiAlgorithm.h" #include "pinfo.h" #include "ioUtils.h" #include "system.h" #include "three_algebra.h" #include "mpiUtils.h" #include "format.h" int getRank(int); void dataSubset_clear(ANALYSIS* analysis); typedef double (* dataSubsetFunctionType)(COLLECTION*,int ) ; static char *scat512(char *a,char*b) { static char s[512]; snprintf(s,511,"%s(%s)",a,b); return s; } double particleEnergy(COLLECTION *collection, int i) { STATE *state= collection->state; double mass = ((ATOMTYPE_PARMS *)(state->species[i]->parm))->mass; double vx = state->vx[i]; double vy = state->vy[i]; double vz = state->vz[i]; double u = state->potentialEnergy[i]; double e = 0.5*mass*(vx*vx+vy*vy+vz*vz)+u; return e; } double particlePotential(COLLECTION *collection, int i) { STATE *state= collection->state; double u = state->potentialEnergy[i]; return u; } double particleKinetic(COLLECTION *collection, int i) { STATE * state= collection->state; double mass = ((ATOMTYPE_PARMS *)(state->species[i]->parm))->mass; double vx = state->vx[i]; double vy = state->vy[i]; double vz = state->vz[i]; double k = 0.5*mass*(vx*vx+vy*vy+vz*vz); return k; } enum fieldList { TIME, NSAMPLES, NPARTICLES, Etotal, Ekinetic, Epotential, Rx, Ry, Rz, Vx, Vy, Vz, Fx, Fy, Fz}; static char *_fieldNames[]= { "time", "nSamples","nParticles","Etotal", "Ekinetic", "Epotential", "Rx", "Ry", "Rz", "Vx", "Vy", "Vz", "Fx", "Fy", "Fz",NULL}; static char *_fieldUnits[]= { "fs" ,"1" , "1" ,"eV", "eV", "eV", "Ang", "Ang", "Ang", "Ang/fs", "Ang/fs", "Ang/fs", "eV/Ang", "eV/Ang", "eV/Ang",NULL}; static dataSubsetFunctionType _fieldFunctions[] = {NULL,NULL,NULL,particleEnergy,particleKinetic,particlePotential}; static char *_fieldFormat[] = {" %16.6f"," %16.0f"," %16.0f"," %16.12f"," %16.12f"," %16.12f"," %16.8f"," %16.12f", " %15.12f"}; static int fieldtype(char *name) { int i=0; while (_fieldNames[i] != NULL) { if (strcmp(name,_fieldNames[i])==0) return i; i++; } return -1; } DATASUBSET_PARMS *dataSubset_parms(ANALYSIS *analysis) { DATASUBSET_PARMS *parms = ddcMalloc(sizeof(DATASUBSET_PARMS)); OBJECT* obj = (OBJECT*) analysis; char *names[256]; char *species[256]; int nNames=object_get(obj, "fields", &names ,STRING, 256, "time nSamples nParticles Etotal Ekinetic Epotential"); int nSpecies=object_get(obj, "species", &species ,STRING, 256, ""); char *defaultFilename=ddcMalloc(strlen(analysis->name)+5); sprintf(defaultFilename,"%s.data",analysis->name); object_get(obj, "filename", &parms->filename ,STRING, 1,defaultFilename); assert(nNames < 256); assert(nSpecies< 256); parms->fields = ddcMalloc(nNames*sizeof(*parms->fields)); parms->nFields = nNames; char formatBuffer[64]; for (int i = 0;i<nNames;i++) { char *name=strtok(names[i]," ("); int type = fieldtype(name); assert(type != -1); char *units=strtok(NULL," )"); if (units == NULL) units = _fieldUnits[i]; char *format=strtok(NULL," %"); if (format == NULL) format = _fieldFormat[i]; else {sprintf(formatBuffer," %%%s",format); format = formatBuffer;} parms->fields[i].type = type; parms->fields[i].name = strdup(name); parms->fields[i].units = strdup(units); parms->fields[i].convert = units_convert(1.0,NULL,units); parms->fields[i].format = strdup(format); parms->fields[i].function = _fieldFunctions[i]; parms->fields[i].accumulatedValue = 0.0; parms->fields[i].nParticleSamples=0; } parms->nEvals=0; return parms; } //////////////////////////////////////////////////////////////////////// void dataSubset_eval(ANALYSIS* analysis) { DATASUBSET_PARMS* parms = (DATASUBSET_PARMS *)analysis->parms; SIMULATE* simulate =(SIMULATE *)analysis ->parent; COLLECTION *collection = simulate->system->collection; int nlocal = simulate->system->nlocal; parms->nEvals++; for (int j=0;j<parms->nFields;j++) { FIELD *field = parms->fields+j; if (field->type == TIME) { field->accumulatedValue += simulate->time; field->nParticleSamples+=1;continue; } if (field->type == NSAMPLES) { field->accumulatedValue += 1; field->nParticleSamples+=getSize(0);continue; } if (field->type == NPARTICLES) {field->accumulatedValue += nlocal; field->nParticleSamples=+1;continue; } field->nParticleSamples += nlocal; for (int i=0;i<nlocal;i++) { field->accumulatedValue += field->function(collection,i); } } return ; } //////////////////////////////////////////////////////////////////////// void dataSubset_output(ANALYSIS* analysis) { SIMULATE* simulate =(SIMULATE *)analysis->parent; DATASUBSET_PARMS* parms = (DATASUBSET_PARMS *)analysis->parms; FILE *file = parms->file; fprintf(file,loopFormat(),simulate->loop); for (int j=0;j<parms->nFields;j++) { FIELD *field = parms->fields+j; double scale = field->convert/field->nParticleSamples; fprintf(file,field->format,scale*field->accumulatedValue); } fprintf(file,"\n"); fflush(file); dataSubset_clear(analysis); } //////////////////////////////////////////////////////////////////////// void dataSubset_clear(ANALYSIS* analysis) { DATASUBSET_PARMS* parms = (DATASUBSET_PARMS *)analysis->parms; for (int i = 0;i<parms->nFields;i++) { parms->fields[i].accumulatedValue = 0.0; parms->fields[i].nParticleSamples=0; } parms->nEvals=0; } void dataSubset_startup(ANALYSIS* analysis) { DATASUBSET_PARMS* parms = (DATASUBSET_PARMS *)analysis->parms; parms->file = fopen(parms->filename,"a"); char fmt[8]; sprintf(fmt,"-%%%ds",loopFormatSize()); fprintf(parms->file,fmt,"#loop"); for (int i=0;i<parms->nFields;i++) { fprintf(parms->file," %16s",scat512(parms->fields[i].name, parms->fields[i].units)); } fprintf(parms->file,"\n"); dataSubset_clear(analysis); }
33.347418
172
0.6165
[ "object" ]
c661356d9dffde5c50f4126343ed03120676e514
2,135
h
C
src/engine/audio/sound_manager.h
robhendriks/city-defence
6567222087fc74bf374423d4aab5512cbe86ac07
[ "MIT" ]
null
null
null
src/engine/audio/sound_manager.h
robhendriks/city-defence
6567222087fc74bf374423d4aab5512cbe86ac07
[ "MIT" ]
null
null
null
src/engine/audio/sound_manager.h
robhendriks/city-defence
6567222087fc74bf374423d4aab5512cbe86ac07
[ "MIT" ]
1
2022-03-29T02:01:56.000Z
2022-03-29T02:01:56.000Z
// // Created by robbie on 5-11-2016. // #ifndef CITY_DEFENCE_SOUND_MANAGER_H #define CITY_DEFENCE_SOUND_MANAGER_H #include <string> #include <map> #include <SDL_mixer.h> #include <functional> #include <stack> #include <vector> #include "state.h" namespace engine { namespace audio { class sound_manager { public: sound_manager(); bool load(std::string file, std::string id); bool load_if(std::string file, std::string id); bool is_loaded(std::string id); int play(std::string id, std::function<void()> when_finished = NULL, int volume = 128, int fade_in = -1, int loops = 0); int play_if(std::string id, bool count_paused = true, std::function<void()> when_finished = NULL, int volume = 128, int fade_in = -1, int loops = 0); std::vector<int> get_channels(std::string id, bool count_paused = true) const; void set_volume(int channel, int volume); void set_volume_all(int volume); int get_volume(int channel) const; void pop_volume(int channel); std::stack<int> *get_volume_stack(int channel) const; void pause(int channel); void pause_all(std::string id); void pause_all(); void resume(int channel); void resume_all(std::string id); void resume_all(); void stop(int channel, int fade_out = -1); void stop_all(std::string id, int fade_out = -1); void stop_all(int fade_out = -1); void unload(std::string id); std::map<int, std::tuple<std::string, sound::state, std::stack<int>*>> *get_playing_sounds() const; ~sound_manager(); private: void sound_finished(int channel); void erase_playing_sound(int channel); std::map<int, std::tuple<std::string, sound::state, std::stack<int>*>> *m_playing_sounds; std::map<std::string, Mix_Chunk*> m_sounds; std::map<int, std::function<void()>> m_when_finished; }; } } #endif //CITY_DEFENCE_SOUND_MANAGER_H
38.125
161
0.603279
[ "vector" ]
c669eed44a249f466b3188e29b07794aa8724b35
1,047
h
C
NoiseTypes/Wavelet.h
sherrbss/ProceduralNoise
99162d9b00d52b50e33a64313911300406af0745
[ "MIT" ]
null
null
null
NoiseTypes/Wavelet.h
sherrbss/ProceduralNoise
99162d9b00d52b50e33a64313911300406af0745
[ "MIT" ]
null
null
null
NoiseTypes/Wavelet.h
sherrbss/ProceduralNoise
99162d9b00d52b50e33a64313911300406af0745
[ "MIT" ]
null
null
null
/** * Wavelet.h * Authors: Sheldon Taylor, Jiju Poovvancheri * * A Wavelet noise implementation. * * Implementation heavily based on "Wavelet Noise" by Cook & DeRose. * * Reference: https://graphics.pixar.com/library/WaveletNoise/paper.pdf */ #include "../HashFunctions.h" #include <iostream> #include <cstdlib> #include <ctime> #include <cmath> #include <glm/glm/glm.hpp> #ifndef _WAVELET_H_ #define _WAVELET_H_ class Wavelet { public: Wavelet(); ~Wavelet(); // Generates a Wavelet noise value, given some 3D coordinates (X, Y, Z). float noise(float sample_x, float sample_y, float sample_z); void downsample(float *from, float *to, int n, int stride); void upsample( float *from, float *to, int n, int stride); void generateNoiseTile( int n, int olap); int mod(int x, int n); // Generates a projected Wavelet noise value, given some 3D coordinates (X, Y, Z). float projectedNoise(float sample_x, float sample_y, float sample_z); float *noiseTileData; int noiseTileSize; }; #endif
24.348837
86
0.69532
[ "3d" ]
c6703cbd701e4e75f47352ec317ae3ed4f0f433b
8,975
c
C
firmware/bsl/lib-qpc/examples/80x86/dos/watcom/l/qhsmtst/qhsmtst.c
AmuletGroup/amulet-project
b37bc1a66ea084f6ef1e9e727043aa6416d781a6
[ "BSD-Source-Code" ]
20
2016-09-01T15:07:35.000Z
2022-02-10T15:47:39.000Z
firmware/bsl/lib-qpc/examples/80x86/dos/watcom/l/qhsmtst/qhsmtst.c
AmuletGroup/amulet-project
b37bc1a66ea084f6ef1e9e727043aa6416d781a6
[ "BSD-Source-Code" ]
null
null
null
firmware/bsl/lib-qpc/examples/80x86/dos/watcom/l/qhsmtst/qhsmtst.c
AmuletGroup/amulet-project
b37bc1a66ea084f6ef1e9e727043aa6416d781a6
[ "BSD-Source-Code" ]
4
2016-10-29T20:34:33.000Z
2022-02-10T15:45:40.000Z
/***************************************************************************** * Product: QHsmTst Example * Last Updated for Version: 4.5.00 * Date of the Last Update: May 18, 2012 * * Q u a n t u m L e a P s * --------------------------- * innovating embedded systems * * Copyright (C) 2002-2012 Quantum Leaps, LLC. All rights reserved. * * This program is open source 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. * * Alternatively, this program may be distributed and modified under the * terms of Quantum Leaps commercial licenses, which expressly supersede * the GNU General Public License and are specifically designed for * licensees interested in retaining the proprietary status of their code. * * 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/>. * * Contact information: * Quantum Leaps Web sites: http://www.quantum-leaps.com * http://www.state-machine.com * e-mail: info@quantum-leaps.com *****************************************************************************/ #include "qep_port.h" #include "qhsmtst.h" /* local-scope objects .....................................................*/ typedef struct QHsmTstTag { QHsm super; /* extend class QHsm */ uint8_t foo; /* extended state variable */ /* . . . */ } QHsmTst; /* HSM state handler functions: */ static QState QHsmTst_initial(QHsmTst *me, QEvt const *e); /* pseudostate */ static QState QHsmTst_s (QHsmTst *me, QEvt const *e); /* state-handler */ static QState QHsmTst_s1 (QHsmTst *me, QEvt const *e); /* state-handler */ static QState QHsmTst_s11 (QHsmTst *me, QEvt const *e); /* state-handler */ static QState QHsmTst_s2 (QHsmTst *me, QEvt const *e); /* state-handler */ static QState QHsmTst_s21 (QHsmTst *me, QEvt const *e); /* state-handler */ static QState QHsmTst_s211 (QHsmTst *me, QEvt const *e); /* state-handler */ static QHsmTst l_hsmtst; /* the sole instance of the state machine object */ /* global-scope definitions ------------------------------------------------*/ extern QHsm * const the_hsm = (QHsm *)&l_hsmtst; /* the opaque pointer */ /*..........................................................................*/ void QHsmTst_ctor(void) { QHsmTst *me = &l_hsmtst; QHsm_ctor(&me->super, (QStateHandler)&QHsmTst_initial); } /* HSM definition ----------------------------------------------------------*/ QState QHsmTst_initial(QHsmTst *me, QEvt const *e) { (void)e; /* suppress "e not used" compiler warning */ BSP_display("top-INIT;"); me->foo = 0; /* initialize extended state variable */ return Q_TRAN(&QHsmTst_s2); } /*..........................................................................*/ QState QHsmTst_s(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s-INIT;"); return Q_TRAN(&QHsmTst_s11); } case E_SIG: { BSP_display("s-E;"); return Q_TRAN(&QHsmTst_s11); } case I_SIG: { /* internal transition with a guard */ if (me->foo) { BSP_display("s-I;"); me->foo = 0; return Q_HANDLED(); } break; } case TERMINATE_SIG: { BSP_exit(); return Q_HANDLED(); } } return Q_SUPER(&QHsm_top); } /*..........................................................................*/ QState QHsmTst_s1(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s1-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s1-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s1-INIT;"); return Q_TRAN(&QHsmTst_s11); } case A_SIG: { BSP_display("s1-A;"); return Q_TRAN(&QHsmTst_s1); } case B_SIG: { BSP_display("s1-B;"); return Q_TRAN(&QHsmTst_s11); } case C_SIG: { BSP_display("s1-C;"); return Q_TRAN(&QHsmTst_s2); } case D_SIG: { /* transition with a gurad */ if (!me->foo) { BSP_display("s1-D;"); me->foo = 1; return Q_TRAN(&QHsmTst_s); } break; } case F_SIG: { BSP_display("s1-F;"); return Q_TRAN(&QHsmTst_s211); } case I_SIG: { /* internal transition */ BSP_display("s1-I;"); return Q_HANDLED(); } } return Q_SUPER(&QHsmTst_s); } /*..........................................................................*/ QState QHsmTst_s11(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s11-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s11-EXIT;"); return Q_HANDLED(); } case D_SIG: { /* transition with a gurad */ if (me->foo) { BSP_display("s11-D;"); me->foo = 0; return Q_TRAN(&QHsmTst_s1); } break; } case G_SIG: { BSP_display("s11-G;"); return Q_TRAN(&QHsmTst_s211); } case H_SIG: { BSP_display("s11-H;"); return Q_TRAN(&QHsmTst_s); } } return Q_SUPER(&QHsmTst_s1); } /*..........................................................................*/ QState QHsmTst_s2(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s2-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s2-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s2-INIT;"); return Q_TRAN(&QHsmTst_s211); } case C_SIG: { BSP_display("s2-C;"); return Q_TRAN(&QHsmTst_s1); } case F_SIG: { BSP_display("s2-F;"); return Q_TRAN(&QHsmTst_s11); } case I_SIG: { /* internal transition with a guard */ if (!me->foo) { BSP_display("s2-I;"); me->foo = (uint8_t)1; return Q_HANDLED(); } break; } } return Q_SUPER(&QHsmTst_s); } /*..........................................................................*/ QState QHsmTst_s21(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s21-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s21-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s21-INIT;"); return Q_TRAN(&QHsmTst_s211); } case A_SIG: { BSP_display("s21-A;"); return Q_TRAN(&QHsmTst_s21); } case B_SIG: { BSP_display("s21-B;"); return Q_TRAN(&QHsmTst_s211); } case G_SIG: { BSP_display("s21-G;"); return Q_TRAN(&QHsmTst_s1); } } return Q_SUPER(&QHsmTst_s2); } /*..........................................................................*/ QState QHsmTst_s211(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s211-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s211-EXIT;"); return Q_HANDLED(); } case D_SIG: { BSP_display("s211-D;"); return Q_TRAN(&QHsmTst_s21); } case H_SIG: { BSP_display("s211-H;"); return Q_TRAN(&QHsmTst_s); } } return Q_SUPER(&QHsmTst_s21); }
33.364312
78
0.466407
[ "object" ]
c6732bbb1037ed3ccaf69554c7ec0d0a7620bf9a
2,275
h
C
Studio/src/Visualization/PlaneWidget.h
SCIInstitute/shapeworks
cbd44fdeb83270179c2331f2ba8431cf7330a4ff
[ "MIT" ]
3
2016-04-26T15:29:58.000Z
2018-10-05T18:39:12.000Z
Studio/src/Visualization/PlaneWidget.h
SCIInstitute/shapeworks
cbd44fdeb83270179c2331f2ba8431cf7330a4ff
[ "MIT" ]
35
2015-05-22T18:26:16.000Z
2019-06-03T18:09:40.000Z
Studio/src/Visualization/PlaneWidget.h
SCIInstitute/shapeworks
cbd44fdeb83270179c2331f2ba8431cf7330a4ff
[ "MIT" ]
7
2015-06-18T18:56:12.000Z
2019-06-17T19:15:06.000Z
#include <Libs/Optimize/ParticleSystem/PlaneConstraint.h> #include <vtkSmartPointer.h> #include <vector> class vtkHandleWidget; class vtkSphereSource; class vtkPlaneSource; class vtkPolyDataMapper; class vtkActor; namespace shapeworks { class Viewer; class PlaneCallback; class StudioHandleWidget; //! PlaneWidget /*! * Widget to display and manipulate constraint planes * */ class PlaneWidget { public: PlaneWidget(Viewer* viewer); ~PlaneWidget(); //! Update the widget from shape data void update(); //! Store positions back to shape data (this is called by callback) void store_positions(); //! Update the sizes and detail of control spheres void update_glyph_properties(); //! Clear point handles and planes void clear_planes(); //! Handle a right click on a particular point void handle_right_click(int domain, int plane, int point); //! Delete a particular plane void delete_plane(int domain, int plane_id); //! Flip the normal for a given plane void flip_plane(int domain, int plane_id); //! Apply a plane from one shape to all others (e.g. copy and paste) void apply_plane(int domain, int plane_id); //! Set an offset for a given plane void set_plane_offset(int domain, int plane_id, int offset); //! Finalize the offset for a given plane void finalize_plane_offset(int domain, int plane_id); private: //! update the point handles void update_plane_points(); //! update the plane display actors void update_planes(); vtkSmartPointer<StudioHandleWidget> create_handle(); void assign_handle_to_domain(vtkSmartPointer<StudioHandleWidget> handle, int domain_id); int count_plane_points(); int count_complete_planes(); PlaneConstraint& get_plane_reference(int domain, int plane); double get_offset_scale(int domain_id); bool block_update_ = false; Viewer* viewer_ = nullptr; // control points vtkSmartPointer<vtkSphereSource> sphere_; std::vector<vtkSmartPointer<StudioHandleWidget>> handles_; // planes std::vector<vtkSmartPointer<vtkPlaneSource>> plane_sources_; std::vector<vtkSmartPointer<vtkPolyDataMapper>> plane_mappers_; std::vector<vtkSmartPointer<vtkActor>> plane_actors_; vtkSmartPointer<PlaneCallback> callback_; }; } // namespace shapeworks
24.462366
90
0.754286
[ "shape", "vector" ]
c67439d3155b30af7d282fd0957ee5ad47ec1d67
4,817
h
C
sss/ex/inc/ex_sss_objid.h
daveherron/plug-and-trust
898526f6a96bb44fe2cf379eaf1e261d902c5416
[ "BSD-3-Clause" ]
2
2020-06-02T21:23:09.000Z
2020-06-03T17:55:43.000Z
sss/ex/inc/ex_sss_objid.h
daveherron/plug-and-trust
898526f6a96bb44fe2cf379eaf1e261d902c5416
[ "BSD-3-Clause" ]
null
null
null
sss/ex/inc/ex_sss_objid.h
daveherron/plug-and-trust
898526f6a96bb44fe2cf379eaf1e261d902c5416
[ "BSD-3-Clause" ]
1
2020-08-17T05:25:11.000Z
2020-08-17T05:25:11.000Z
/* * Copyright 2019-2020 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /** @file * * ex_sss_objid.h: Reserved Object Identifiers * * Project: SecureIoTMW-Debug@simw-top-eclipse_x86 * * $Date: Mar 27, 2019 $ * $Author: ing05193 $ * $Revision$ */ #ifndef SSS_EX_INC_EX_SSS_OBJID_H_ #define SSS_EX_INC_EX_SSS_OBJID_H_ /* ***************************************************************************************************************** * Includes * ***************************************************************************************************************** */ /* ***************************************************************************************************************** * MACROS/Defines * ***************************************************************************************************************** */ /* clang-format off */ #define EX_SSS_OBJID_CUST_START 0x00000001u #define SE05X_OBJID_TP_MASK(X) (0xFFFFFFFC & (X)) #define EX_SSS_OBJID_CUST_END 0x7BFFFFFFu #define EX_SSS_OBJID_AKM_START 0x7C000000u #define EX_SSS_OBJID_AKM_END 0x7CFFFFFFu #define EX_SSS_OBJID_DEMO_START 0x7D000000u #define EX_SSS_OBJID_DEMO_SA_START 0x7D500000u #define EX_SSS_OBJID_DEMO_WIFI_START 0x7D51F000u /* doc:start:mif-kdf-start-keyid */ #define EX_SSS_OBJID_DEMO_MFDF_START 0x7D5DF000u /* doc:end:mif-kdf-start-keyid */ /////// EX_SSS_OBJID_DEMO_SA_END 0x7D5FFFFFu #define EX_SSS_OBJID_DEMO_AUTH_START 0x7DA00000u #define EX_SSS_OBJID_DEMO_AUTH_MASK(X) (0xFFFF0000u & (X)) /////// EX_SSS_OBJID_DEMO_AUTH_END 0x7DA0FFFFu #define EX_SSS_OBJID_DEMO_CLOUD_START 0x7DC00000u #define EX_SSS_OBJID_DEMO_CLOUD_IBM_START 0x7DC1B000u #define EX_SSS_OBJID_DEMO_CLOUD_GCP_START 0x7DC6C000u #define EX_SSS_OBJID_DEMO_CLOUD_AWS_START 0x7DCA5000u #define EX_SSS_OBJID_DEMO_CLOUD_AZURE_START 0x7DCAC000u /////// EX_SSS_OBJID_DEMO_CLOUD_END 0x7DCFFFFFu #define EX_SSS_OBJID_DEMO_END 0x7DFFFFFFu #define SE05X_OBJID_SE05X_APPLET_RES_START 0x7FFF0000u #define SE05X_OBJID_SE05X_APPLET_RES_MASK(X) \ (0xFFFF0000u & (X)) #define SE05X_OBJID_SE05X_APPLET_RES_END 0x7FFFFFFFu /* IoT Hub Managed */ #define SE05X_OBJID_IOT_HUB_M_START 0x80000000u #define SE05X_OBJID_IOT_HUB_M_END 0xEEFFFFFFu #define EX_SSS_OBJID_TEST_START 0xEF000000u #define EX_SSS_OBJID_TEST_END 0xEFFFFFFFu /* IoT Hub Access */ #define EX_SSS_OBJID_IOT_HUB_A_START 0xF0000000u #define EX_SSS_OBJID_IOT_HUB_A_MASK(X) (0xF0000000u & (X)) //Device Key and Certificate - ECC-256 #define EX_SSS_OBJID_TP_KEY_EC_D 0xF0000100 #define EX_SSS_OBJID_TP_CERT_EC_D 0xF0000101 //Gateway Key and Certificate - ECC-256 #define EX_SSS_OBJID_TP_KEY_EC_G 0xF0000102 #define EX_SSS_OBJID_TP_CERT_EC_G 0xF0000103 //Device Key and Certificate - RSA-2K #define EX_SSS_OBJID_TP_KEY_RSA2K_D 0xF0000110 #define EX_SSS_OBJID_TP_CERT_RSA2K_D 0xF0000111 //Gateway Key and Certificate - RSA-2K #define EX_SSS_OBJID_TP_KEY_RSA2K_G 0xF0000112 #define EX_SSS_OBJID_TP_CERT_RSA2K_G 0xF0000113 //Device Key and Certificate - RSA-4K #define EX_SSS_OBJID_TP_KEY_RSA4K_D 0xF0000120 #define EX_SSS_OBJID_TP_CERT_RSA4K_D 0xF0000121 //Gateway Key and Certificate - RSA-4K #define EX_SSS_OBJID_TP_KEY_RSA4K_G 0xF0000122 #define EX_SSS_OBJID_TP_CERT_RSA4K_G 0xF0000123 #define EX_SSS_OBJID_IOT_HUB_A_END 0xFFFFFFFFu /* clang-format on */ /* ***************************************************************************************************************** * Types/Structure Declarations * ***************************************************************************************************************** */ enum { kEX_SSS_ObjID_UserID_Auth = EX_SSS_OBJID_DEMO_AUTH_START + 1, kEX_SSS_ObjID_APPLETSCP03_Auth, kEX_SSS_objID_ECKEY_Auth, }; /* ***************************************************************************************************************** * Extern Variables * ***************************************************************************************************************** */ /* ***************************************************************************************************************** * Function Prototypes * ***************************************************************************************************************** */ #endif /* SSS_EX_INC_EX_SSS_OBJID_H_ */
42.254386
119
0.530413
[ "object" ]
c678268ff781a55ed09af96aa80aa0999853fa52
1,463
h
C
apps/my_app.h
jshaffar/Morse-Code-Communicator
ed79bb03cc9516377e33c627ac61620311a1618d
[ "MIT" ]
null
null
null
apps/my_app.h
jshaffar/Morse-Code-Communicator
ed79bb03cc9516377e33c627ac61620311a1618d
[ "MIT" ]
null
null
null
apps/my_app.h
jshaffar/Morse-Code-Communicator
ed79bb03cc9516377e33c627ac61620311a1618d
[ "MIT" ]
null
null
null
// Copyright (c) 2020 CS126SP20. All rights reserved. #ifndef FINALPROJECT_APPS_MYAPP_H_ #define FINALPROJECT_APPS_MYAPP_H_ #include <cinder/app/App.h> #include <mylibrary/constants.h> #include <mylibrary/transmitter.h> #include <mylibrary/receiver.h> #include <cinder/audio/Voice.h> #include <vector> namespace myapp { class MyApp : public cinder::app::App { public: MyApp(); ~MyApp() override; void setup() override; void update() override; void draw() override; void keyDown(cinder::app::KeyEvent) override; private: Constants constant_; bool in_menu_mode_; bool in_transmitter_mode_; bool in_receiver_mode_; bool is_on_; std::string input_; std::vector<std::string> coded_words_; std::vector<std::string> uncoded_words; std::vector<std::chrono::milliseconds>* time_point_changes_; bool did_start_; bool started_transmitting_; Code* code_; Transmitter transmitter_; Receiver receiver_; cinder::audio::VoiceRef sound_; bool is_finished_; std::string finished_message_; void SetUpTransmitterMode(); void SetUpReceiverMode(); void DecodeReceiver(); void DrawMenuUI() const; void DrawTransmitterUI() const; void DrawReceiverUI(); void DrawFinishedUI(); template <typename C> void PrintText(const std::string& text, const C& color, const cinder::ivec2& size, const cinder::vec2& loc, const float font_size_ = 100) const; }; } // namespace myapp #endif // FINALPROJECT_APPS_MYAPP_H_
24.79661
84
0.740943
[ "vector" ]
c683653242157755cfbfc03452daacba1dabd597
3,001
c
C
gumath/ext/ruby_gumath/util.c
xnd-project/xnd-ruby
ddecb88d3a6fa17ca314b6599aedf4f5a189b067
[ "BSD-3-Clause" ]
5
2019-05-29T06:36:23.000Z
2020-04-12T00:09:06.000Z
gumath/ext/ruby_gumath/util.c
xnd-project/xnd-ruby
ddecb88d3a6fa17ca314b6599aedf4f5a189b067
[ "BSD-3-Clause" ]
4
2019-06-04T09:00:51.000Z
2019-10-16T23:35:22.000Z
gumath/ext/ruby_gumath/util.c
xnd-project/xnd-ruby
ddecb88d3a6fa17ca314b6599aedf4f5a189b067
[ "BSD-3-Clause" ]
null
null
null
/* BSD 3-Clause License * * Copyright (c) 2018, Quansight and Sameer Deshmukh * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Utility functions for gumath. */ #include "ruby_gumath_internal.h" VALUE array_new(int64_t size) { #if SIZE_MAX < INT64_MAX size_t n = safe_downcast(size); return n < 0 ? NULL : rb_ary_new2(n); #else return rb_ary_new2(size); #endif } int xnd_exists(void) { return RTEST(rb_const_get(rb_cObject, rb_intern("XND"))); } int ndt_exists(void) { return RTEST(rb_const_get(rb_cObject, rb_intern("NDT"))); } /* Raise an error stored in $!. Clears it before raising. */ void raise_error(void) { VALUE exeception = rb_errinfo(); rb_set_errinfo(Qnil); rb_exc_raise(exeception); } /* Checks whether a given Ruby object is of a type using is_a? */ int rb_is_a(VALUE obj, VALUE klass) { return RTEST(rb_funcall(obj, rb_intern("is_a?"), 1, klass)); } int rb_klass_has_ancestor(VALUE klass, VALUE ancestor) { return RTEST( rb_funcall( rb_funcall(klass, rb_intern("ancestors"),0,NULL), rb_intern("include?"), 1, ancestor)); } int rb_ary_size(VALUE array) { Check_Type(array, T_ARRAY); return FIX2INT(rb_funcall(array, rb_intern("size"), 0, NULL)); } void rb_puts(VALUE v) { ID sym_puts = rb_intern("puts"); ID sym_inspect = rb_intern("inspect"); rb_funcall(rb_mKernel, sym_puts, 1, rb_funcall(v, sym_inspect, 0)); }
29.135922
81
0.708764
[ "object" ]
c6863b18847a19ccf03f4b3c113f929b368c655a
8,973
h
C
src/CCA/Components/Arches/TurbulenceModels/DynamicSmagorinskyHelper.h
abagusetty/Uintah
fa1bf819664fa6f09c5a7cd076870a40816d35c9
[ "MIT" ]
2
2021-12-17T05:50:44.000Z
2021-12-22T21:37:32.000Z
src/CCA/Components/Arches/TurbulenceModels/DynamicSmagorinskyHelper.h
abagusetty/Uintah
fa1bf819664fa6f09c5a7cd076870a40816d35c9
[ "MIT" ]
null
null
null
src/CCA/Components/Arches/TurbulenceModels/DynamicSmagorinskyHelper.h
abagusetty/Uintah
fa1bf819664fa6f09c5a7cd076870a40816d35c9
[ "MIT" ]
1
2020-11-30T04:46:05.000Z
2020-11-30T04:46:05.000Z
#ifndef Uintah_Component_Arches_DynamicSmagorinskyHelper_h #define Uintah_Component_Arches_DynamicSmagorinskyHelper_h #include <CCA/Components/Arches/GridTools.h> namespace Uintah { namespace ArchesCore { enum FILTER { THREEPOINTS, SIMPSON, BOX }; FILTER get_filter_from_string( const std::string & value ); struct BCFilter { void apply_BC_filter_rho( const Patch* patch, CCVariable<double>& var, CCVariable<double>& rho, constCCVariable<double>& vol_fraction){ std::vector<Patch::FaceType> bf; patch->getBoundaryFaces(bf); Patch::FaceIteratorType MEC = Patch::ExtraMinusEdgeCells; for( std::vector<Patch::FaceType>::const_iterator itr = bf.begin(); itr != bf.end(); ++itr ){ Patch::FaceType face = *itr; IntVector f_dir = patch->getFaceDirection(face); for( CellIterator iter=patch->getFaceIterator(face, MEC); !iter.done(); iter++) { IntVector c = *iter; var[c] = rho[c] ; } } } void apply_BC_rho( const Patch* patch, CCVariable<double>& var, constCCVariable<double>& rho, constCCVariable<double>& vol_fraction){ std::vector<Patch::FaceType> bf; patch->getBoundaryFaces(bf); Patch::FaceIteratorType MEC = Patch::ExtraMinusEdgeCells; for( std::vector<Patch::FaceType>::const_iterator itr = bf.begin(); itr != bf.end(); ++itr ){ Patch::FaceType face = *itr; IntVector f_dir = patch->getFaceDirection(face); for( CellIterator iter=patch->getFaceIterator(face, MEC); !iter.done(); iter++) { IntVector c = *iter; var[c] = vol_fraction[c]*0.5*(rho[c]+rho[c-f_dir])+(1.-vol_fraction[c])*rho[c-f_dir]; } } } void apply_zero_neumann( const Patch* patch, CCVariable<double>& var, constCCVariable<double>& vol_fraction ){ std::vector<Patch::FaceType> bf; patch->getBoundaryFaces(bf); Patch::FaceIteratorType MEC = Patch::ExtraMinusEdgeCells; for( std::vector<Patch::FaceType>::const_iterator itr = bf.begin(); itr != bf.end(); ++itr ){ Patch::FaceType face = *itr; IntVector f_dir = patch->getFaceDirection(face); for( CellIterator iter=patch->getFaceIterator(face, MEC); !iter.done(); iter++) { IntVector c = *iter; if ( vol_fraction[c] > 1e-10 ){ var[c] = var[c-f_dir]; } } } } template <typename T, typename CT> void apply_BC_rhou( const Patch* patch, T& var, CT& vel, constCCVariable<double>& rho, constCCVariable<double>& vol_fraction ){ std::vector<Patch::FaceType> bf; patch->getBoundaryFaces(bf); Patch::FaceIteratorType MEC = Patch::ExtraMinusEdgeCells; ArchesCore::VariableHelper<T> var_help; IntVector vDir(var_help.ioff, var_help.joff, var_help.koff); for( std::vector<Patch::FaceType>::const_iterator itr = bf.begin(); itr != bf.end(); ++itr ){ Patch::FaceType face = *itr; IntVector f_dir = patch->getFaceDirection(face); const double dot = vDir[0]*f_dir[0] + vDir[1]*f_dir[1] + vDir[2]*f_dir[2]; //The face normal and the velocity are in parallel if (dot == -1) { //Face + for( CellIterator iter=patch->getFaceIterator(face, MEC); !iter.done(); iter++) { IntVector c = *iter; if ( vol_fraction[c] > 1e-10 ){ var[c-f_dir] = vel[c-f_dir]*(rho[c-f_dir]+rho[c])/2.; var[c] = vel[c-f_dir]; } } } else { // Face - for( CellIterator iter=patch->getFaceIterator(face, MEC); !iter.done(); iter++) { IntVector c = *iter; if ( vol_fraction[c] > 1e-10 ){ var[c] = vel[c]*(rho[c-f_dir]+rho[c])/2.; } } } } } template <typename T> void apply_zero_neumann( const Patch* patch, T& var, constCCVariable<double>& vol_fraction ){ std::vector<Patch::FaceType> bf; patch->getBoundaryFaces(bf); Patch::FaceIteratorType MEC = Patch::ExtraMinusEdgeCells; ArchesCore::VariableHelper<T> var_help; IntVector vDir(var_help.ioff, var_help.joff, var_help.koff); for( std::vector<Patch::FaceType>::const_iterator itr = bf.begin(); itr != bf.end(); ++itr ){ Patch::FaceType face = *itr; IntVector f_dir = patch->getFaceDirection(face); const double dot = vDir[0]*f_dir[0] + vDir[1]*f_dir[1] + vDir[2]*f_dir[2]; //The face normal and the velocity are in parallel if (dot == -1) { //Face + for( CellIterator iter=patch->getFaceIterator(face, MEC); !iter.done(); iter++) { IntVector c = *iter; if ( vol_fraction[c] > 1e-10 ){ var[c-f_dir] = var[c-f_dir-f_dir]; var[c] = var[c-f_dir]; } } } else { // Face - for( CellIterator iter=patch->getFaceIterator(face, MEC); !iter.done(); iter++) { IntVector c = *iter; if ( vol_fraction[c] > 1e-10 ){ var[c] = var[c-f_dir]; } } } } } }; //---------------------------------------------------------------------------------------------------- struct TestFilter { void get_w(FILTER Type) { if (Type == THREEPOINTS ) { // Three points symmetric: eq. 2.49 : LES for compressible flows Garnier et al. for ( int m = -1; m <= 1; m++ ){ for ( int n = -1; n <= 1; n++ ){ for ( int l = -1; l <= 1; l++ ){ double my_value = abs(m) + abs(n) + abs(l)+3.0; w[m+1][n+1][l+1]= (1.0/std::pow(2.0,my_value)); } } } wt = 1.; } else if (Type == SIMPSON) { // Simpson integration rule: eq. 2.50 : LES for compressible flows Garnier et al. // ref shows 1D case. For 3D case filter 3 times with 1D filter . for ( int m = -1; m <= 1; m++ ){ for ( int n = -1; n <= 1; n++ ){ for ( int l = -1; l <= 1; l++ ){ double my_value = -abs(m) - abs(n) - abs(l)+3.0; w[m+1][n+1][l+1] = std::pow(4.0,my_value); } } } wt = std::pow(6.0,3.0); } else if (Type == BOX) { // Doing average on a box with three points for ( int m = -1; m <= 1; m++ ){ for ( int n = -1; n <= 1; n++ ){ for ( int l = -1; l <= 1; l++ ){ w[m+1][n+1][l+1] = 1.0; } } } wt = 27.; } else { throw InvalidValue("Error: Filter type not recognized. ", __FILE__, __LINE__); } } // rh*u filter template <typename V_T> void applyFilter(V_T& var, Array3<double>& Fvar, constCCVariable<double>& rho, constCCVariable<double>& eps, BlockRange range) { ArchesCore::VariableHelper<V_T> helper; const int i_n = helper.ioff; const int j_n = helper.joff; const int k_n = helper.koff; Uintah::parallel_for( range, [&](int i, int j, int k){ double F_var = 0.0; for ( int m = -1; m <= 1; m++ ){ for ( int n = -1; n <= 1; n++ ){ for ( int l = -1; l <= 1; l++ ){ double vf = std::floor((eps(i+m,j+n,k+l) + eps(i+m-i_n,j+n-j_n,k+l-k_n))/2.0); F_var += w[m+1][n+1][l+1]*(vf*var(i+m,j+n,k+l)* (rho(i+m,j+n,k+l)+rho(i+m-i_n,j+n-j_n,k+l-k_n))/2.); } } } F_var /= wt; F_var *= (eps(i,j,k)*eps(i-i_n,j-j_n,k-k_n)); Fvar(i,j,k) = F_var; }); } // This filter does not weight the intrusion cells instead c value is used. // used in density template <typename T> void applyFilter(T& var, Array3<double>& Fvar, BlockRange range, constCCVariable<double>& eps ) { Uintah::parallel_for( range, [&](int i, int j, int k){ double F_var = 0.0; for ( int m = -1; m <= 1; m++ ){ for ( int n = -1; n <= 1; n++ ){ for ( int l = -1; l <= 1; l++ ){ F_var += w[m+1][n+1][l+1]*(eps(i+m,j+n,k+l)*var(i+m,j+n,k+l) +(1.-eps(i+m,j+n,k+l))*var(i,j,k)); } } } F_var /= wt; Fvar(i,j,k) = F_var; }); } // scalar filter template <typename V_T> void applyFilter(V_T& var, Array3<double>& Fvar, constCCVariable<double>& eps, BlockRange range) { Uintah::parallel_for( range, [&](int i, int j, int k){ double F_var = 0.0; for ( int m = -1; m <= 1; m++ ){ for ( int n = -1; n <= 1; n++ ){ for ( int l = -1; l <= 1; l++ ){ F_var += w[m+1][n+1][l+1]* eps(i+m,j+n,k+l)*var(i+m,j+n,k+l); } } } F_var /= wt; Fvar(i,j,k) = F_var; }); } private: FILTER Type ; double w[3][3][3]; double wt; }; }} //namespace Uintah::ArchesCore #endif
31.819149
104
0.519893
[ "vector", "3d" ]
c68d06eb55966131f0bf7d0f4c673b308e920e7b
1,582
h
C
include/FeatureDetectorBase.h
b51/FeatureTracker
e4ffa75fced5e0b977cec830714ec164fb922a41
[ "MIT" ]
19
2019-10-25T13:55:15.000Z
2022-02-07T06:14:59.000Z
include/FeatureDetectorBase.h
b51/FeatureTracker
e4ffa75fced5e0b977cec830714ec164fb922a41
[ "MIT" ]
2
2020-07-07T03:47:41.000Z
2021-08-30T15:21:26.000Z
include/FeatureDetectorBase.h
b51/FeatureTracker
e4ffa75fced5e0b977cec830714ec164fb922a41
[ "MIT" ]
4
2020-02-02T06:26:27.000Z
2021-12-31T03:42:00.000Z
/************************************************************************* * * Author: b51 * Mail: b51live@gmail.com * FileName: FeatureDetectorBase.h * * Created On: Thu 27 Jun 2019 03:29:38 PM CST * Licensed under The MIT License [see LICENSE for details] * ************************************************************************/ #ifndef FEATURE_TRACKER_FEATURE_DETECTOR_BASE_H_ #define FEATURE_TRACKER_FEATURE_DETECTOR_BASE_H_ #include <Eigen/Core> #include <opencv2/opencv.hpp> #include "FeatureDescriptor.h" class FeatureDetectorBase { public: FeatureDetectorBase(){}; virtual ~FeatureDetectorBase(){}; virtual void Init(int width, int height, int max_number_of_features) = 0; virtual void Detect(const cv::Mat& image, Eigen::Matrix2Xd* current_measurements, std::vector<float>* current_feature_orientations, std::vector<float>* current_feature_scales, FeatureDescriptoru* current_feature_descriptors) {} virtual void Detect(const cv::Mat& image, Eigen::Matrix2Xf* current_measurements, FeatureDescriptorf* current_feature_descriptors) {} virtual bool IsInitialized() const = 0; virtual int GetHeight() const = 0; virtual int GetWidth() const = 0; virtual int GetMaxNumberOfFeatures() const = 0; private: FeatureDetectorBase(const FeatureDetectorBase& fd) = delete; FeatureDetectorBase& operator=(const FeatureDetectorBase& fd) = delete; }; #endif
32.958333
75
0.608091
[ "vector" ]
c69d3d1625288752c97ecf70902146ac4741e6f8
2,083
h
C
include/lens/Finalizer.h
lubyk/lens
05541de73c2df31680c6273a796a624323ac2c04
[ "MIT" ]
1
2016-01-21T22:07:58.000Z
2016-01-21T22:07:58.000Z
include/lens/Finalizer.h
lubyk/lens
05541de73c2df31680c6273a796a624323ac2c04
[ "MIT" ]
1
2015-11-21T13:56:01.000Z
2015-11-30T20:03:50.000Z
include/lens/Finalizer.h
lubyk/lens
05541de73c2df31680c6273a796a624323ac2c04
[ "MIT" ]
null
null
null
/* ============================================================================== This file is part of the LUBYK project (http://lubyk.org) Copyright (c) 2007-2014 by Gaspard Bucher (http://teti.ch). ------------------------------------------------------------------------------ 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. ============================================================================== */ #ifndef LUBYK_INCLUDE_LENS_FINALIZER_H_ #define LUBYK_INCLUDE_LENS_FINALIZER_H_ #include "dub/dub.h" namespace lens { /** The sole purpose of this class is to execute some cleanup operation * on garbage collection. The object calls "callback" when being garbage * collected. * * @dub push: dub_pushobject * destructor: 'finalize' */ class Finalizer : public dub::Thread { public: Finalizer() {} virtual ~Finalizer() {} void finalize() { if (dub_pushcallback("finalize")) { // ... <finalize> <self> dub_call(1, 0); } delete this; } }; } // lens #endif // LUBYK_INCLUDE_LENS_FINALIZER_H_
33.596774
80
0.645223
[ "object" ]
c69fc69bd45e274d9159726b453517513c20b2e8
11,450
c
C
programmer/stm32/usbd_cdc.c
jburks/vera-module
403b4179fb6ce2e6d454d9fd103823520889856d
[ "MIT" ]
23
2022-03-11T13:37:01.000Z
2022-03-29T08:06:17.000Z
programmer/stm32/usbd_cdc.c
jburks/vera-module
403b4179fb6ce2e6d454d9fd103823520889856d
[ "MIT" ]
2
2022-03-14T10:54:50.000Z
2022-03-28T05:59:25.000Z
programmer/stm32/usbd_cdc.c
fvdhoef/vera-module
403b4179fb6ce2e6d454d9fd103823520889856d
[ "MIT" ]
12
2022-03-11T08:46:43.000Z
2022-03-27T07:24:46.000Z
#include "usbd_cdc.h" #include "usbd_ctlreq.h" #include "usb.h" #define USB_CDC_CONFIG_DESC_SIZ (9 + /* CDC */ 9 + 5 + 5 + 4 + 5 + 7 + 9 + 7 + 7 /* Programmer */ + 9 + 7 + 7) // USB CDC device Configuration Descriptor static const alignas(4) uint8_t cdc_config_desc[USB_CDC_CONFIG_DESC_SIZ] = { // Configuration descriptor 0x09, // bLength: Configuration Descriptor size USB_DESC_TYPE_CONFIGURATION, // bDescriptorType: Configuration USB_CDC_CONFIG_DESC_SIZ, // wTotalLength:no of returned bytes 0x00, // 0x03, // bNumInterfaces: 3 interfaces 0x01, // bConfigurationValue: Configuration value 0x00, // iConfiguration: Index of string descriptor describing the configuration 0x80, // bmAttributes: bus powered 500 / 2, // MaxPower 0 mA // Interface descriptor 0x09, // bLength: Interface Descriptor size USB_DESC_TYPE_INTERFACE, // bDescriptorType: Interface 0x00, // bInterfaceNumber: Number of Interface 0x00, // bAlternateSetting: Alternate setting 0x01, // bNumEndpoints: One endpoints used 0x02, // bInterfaceClass: Communication Interface Class 0x02, // bInterfaceSubClass: Abstract Control Model 0x01, // bInterfaceProtocol: Common AT commands 0x00, // iInterface: // Class specific interface descriptor: Header Functional Descriptor 0x05, // bLength: Endpoint Descriptor size 0x24, // bDescriptorType: CS_INTERFACE 0x00, // bDescriptorSubtype: Header Func Desc 0x10, // bcdCDC: spec release number 0x01, // // Class specific interface descriptor: Call Management Functional Descriptor 0x05, // bFunctionLength 0x24, // bDescriptorType: CS_INTERFACE 0x01, // bDescriptorSubtype: Call Management Func Desc 0x00, // bmCapabilities: D0+D1 0x01, // bDataInterface: 1 // Class specific interface descriptor: ACM Functional Descriptor 0x04, // bFunctionLength 0x24, // bDescriptorType: CS_INTERFACE 0x02, // bDescriptorSubtype: Abstract Control Management desc 0x02, // bmCapabilities // Class specific interface descriptor: Union Functional Descriptor 0x05, // bFunctionLength 0x24, // bDescriptorType: CS_INTERFACE 0x06, // bDescriptorSubtype: Union func desc 0x00, // bMasterInterface: Communication class interface 0x01, // bSlaveInterface0: Data Class Interface // Endpoint 2 Descriptor 0x07, // bLength: Endpoint Descriptor size USB_DESC_TYPE_ENDPOINT, // bDescriptorType: Endpoint CDC_CMD_EP, // bEndpointAddress 0x03, // bmAttributes: Interrupt LOBYTE(CDC_CMD_EP_SIZE), // wMaxPacketSize: HIBYTE(CDC_CMD_EP_SIZE), // 0x10, // bInterval: // Data class interface descriptor 0x09, // bLength: Endpoint Descriptor size USB_DESC_TYPE_INTERFACE, // bDescriptorType: 0x01, // bInterfaceNumber: Number of Interface 0x00, // bAlternateSetting: Alternate setting 0x02, // bNumEndpoints: Two endpoints used 0x0A, // bInterfaceClass: CDC 0x00, // bInterfaceSubClass: 0x00, // bInterfaceProtocol: 0x00, // iInterface: // Endpoint OUT Descriptor 0x07, // bLength: Endpoint Descriptor size USB_DESC_TYPE_ENDPOINT, // bDescriptorType: Endpoint CDC_OUT_EP, // bEndpointAddress 0x02, // bmAttributes: Bulk LOBYTE(CDC_OUT_EP_SIZE), // wMaxPacketSize: HIBYTE(CDC_OUT_EP_SIZE), // 0x00, // bInterval: ignore for Bulk transfer // Endpoint IN Descriptor 0x07, // bLength: Endpoint Descriptor size USB_DESC_TYPE_ENDPOINT, // bDescriptorType: Endpoint CDC_IN_EP, // bEndpointAddress 0x02, // bmAttributes: Bulk LOBYTE(CDC_IN_EP_SIZE), // wMaxPacketSize: HIBYTE(CDC_IN_EP_SIZE), // 0x00, // bInterval: ignore for Bulk transfer // Extra programmer descriptors // Interface descriptor 0x09, // bLength: Interface Descriptor size USB_DESC_TYPE_INTERFACE, // bDescriptorType: Interface descriptor type 0x02, // bInterfaceNumber: Number of Interface 0x00, // bAlternateSetting: Alternate setting 0x02, // bNumEndpoints 0xFF, // bInterfaceClass 0x00, // bInterfaceSubClass 0x00, // nInterfaceProtocol 0, // iInterface: Index of string descriptor // 0x07, // bLength: Endpoint Descriptor size USB_DESC_TYPE_ENDPOINT, // bDescriptorType: CMD_EPIN_ADDR, // bEndpointAddress: Endpoint Address (IN) 0x02, // bmAttributes: Bulk endpoint LOBYTE(CMD_EPIN_SIZE), // wMaxPacketSize HIBYTE(CMD_EPIN_SIZE), // 0x00, // bInterval // 0x07, // bLength: Endpoint Descriptor size USB_DESC_TYPE_ENDPOINT, // bDescriptorType: CMD_EPOUT_ADDR, // bEndpointAddress: Endpoint Address (OUT) 0x02, // bmAttributes: Bulk endpoint LOBYTE(CMD_EPOUT_SIZE), // wMaxPacketSize HIBYTE(CMD_EPOUT_SIZE), // 0x00, // bInterval }; static uint8_t cdc_init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { USBD_LL_OpenEP(pdev, CDC_IN_EP, USBD_EP_TYPE_BULK, CDC_IN_EP_SIZE); USBD_LL_OpenEP(pdev, CDC_OUT_EP, USBD_EP_TYPE_BULK, CDC_OUT_EP_SIZE); USBD_LL_OpenEP(pdev, CDC_CMD_EP, USBD_EP_TYPE_INTR, CDC_CMD_EP_SIZE); pdev->pClassData = USBD_malloc(sizeof(struct cdc_handle)); assert(pdev->pClassData != NULL); struct cdc_handle *hcdc = (struct cdc_handle *)pdev->pClassData; // Init physical Interface components struct cdc_interface *cdcif = (struct cdc_interface *)pdev->pUserData; cdcif->init(); // Init Xfer states hcdc->tx_busy = false; // Prepare Out endpoint to receive next packet USBD_LL_PrepareReceive(pdev, CDC_OUT_EP, hcdc->rx_buffer, CDC_OUT_EP_SIZE); programmer_init(pdev, cfgidx); return 0; } static uint8_t cdc_deinit(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { USBD_LL_CloseEP(pdev, CDC_IN_EP); USBD_LL_CloseEP(pdev, CDC_OUT_EP); USBD_LL_CloseEP(pdev, CDC_CMD_EP); // Deinit physical interface components struct cdc_interface *cdcif = (struct cdc_interface *)pdev->pUserData; cdcif->deinit(); USBD_free(pdev->pClassData); pdev->pClassData = NULL; programmer_deinit(pdev, cfgidx); return 0; } static uint8_t cdc_setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) { struct cdc_handle * hcdc = (struct cdc_handle *)pdev->pClassData; struct cdc_interface *cdcif = (struct cdc_interface *)pdev->pUserData; static uint8_t ifalt = 0; switch (req->bmRequest & USB_REQ_TYPE_MASK) { case USB_REQ_TYPE_CLASS: if (req->wLength) { if (req->bmRequest & 0x80) { cdcif->control(req->bRequest, (uint8_t *)hcdc->ep0_data, req->wLength); USBD_CtlSendData(pdev, (uint8_t *)hcdc->ep0_data, req->wLength); } else { hcdc->cmd_opcode = req->bRequest; hcdc->cmd_length = req->wLength; USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->ep0_data, req->wLength); } } else { cdcif->control(req->bRequest, (uint8_t *)req, 0); } break; case USB_REQ_TYPE_STANDARD: switch (req->bRequest) { case USB_REQ_GET_INTERFACE: USBD_CtlSendData(pdev, &ifalt, 1); break; case USB_REQ_SET_INTERFACE: break; } default: break; } return USBD_OK; } static uint8_t cdc_data_in(USBD_HandleTypeDef *pdev, uint8_t epnum) { epnum &= 0xF; // printf("cdc_data_in %02x\n", epnum); if (epnum == (CDC_IN_EP & 0xF)) { struct cdc_handle *hcdc = (struct cdc_handle *)pdev->pClassData; hcdc->tx_busy = false; struct cdc_interface *cdcif = (struct cdc_interface *)pdev->pUserData; cdcif->transmit_done(); } else { return programmer_data_in(pdev, epnum); } return USBD_OK; } static uint8_t cdc_data_out(USBD_HandleTypeDef *pdev, uint8_t epnum) { struct cdc_interface *cdcif = (struct cdc_interface *)pdev->pUserData; epnum &= 0xF; // printf("cdc_data_out %02x\n", epnum); if (epnum == (CDC_IN_EP & 0xF)) { struct cdc_handle *hcdc = (struct cdc_handle *)pdev->pClassData; // Get the received data length uint32_t rx_length = USBD_LL_GetRxDataSize(pdev, epnum); cdcif->receive(hcdc->rx_buffer, rx_length); } else { return programmer_data_out(pdev, epnum); } return USBD_OK; } static uint8_t cdc_ep0_rx_ready(USBD_HandleTypeDef *pdev) { struct cdc_handle * hcdc = (struct cdc_handle *)pdev->pClassData; struct cdc_interface *cdcif = (struct cdc_interface *)pdev->pUserData; if (hcdc->cmd_opcode != 0xFF) { cdcif->control(hcdc->cmd_opcode, (uint8_t *)hcdc->ep0_data, hcdc->cmd_length); hcdc->cmd_opcode = 0xFF; } return USBD_OK; } static const uint8_t *cdc_get_cfg_desc(uint16_t *length) { *length = sizeof(cdc_config_desc); return cdc_config_desc; } void cdc_register_interface(USBD_HandleTypeDef *pdev, const struct cdc_interface *fops) { pdev->pUserData = (void *)fops; } bool cdc_transmit_packet(USBD_HandleTypeDef *pdev, uint8_t *buf, uint16_t length) { struct cdc_handle *hcdc = (struct cdc_handle *)pdev->pClassData; if (hcdc->tx_busy) { return false; } hcdc->tx_busy = true; USBD_LL_Transmit(pdev, CDC_IN_EP, buf, length); return true; } void cdc_receive_packet(USBD_HandleTypeDef *pdev) { struct cdc_handle *hcdc = (struct cdc_handle *)pdev->pClassData; // Prepare OUT endpoint to receive next packet USBD_LL_PrepareReceive(pdev, CDC_OUT_EP, hcdc->rx_buffer, sizeof(hcdc->rx_buffer)); } // CDC interface class callbacks structure const USBD_ClassTypeDef USBD_CDC = { .Init = cdc_init, .DeInit = cdc_deinit, .Setup = cdc_setup, .EP0_TxSent = NULL, .EP0_RxReady = cdc_ep0_rx_ready, .DataIn = cdc_data_in, .DataOut = cdc_data_out, .SOF = NULL, .IsoINIncomplete = NULL, .IsoOUTIncomplete = NULL, .GetHSConfigDescriptor = cdc_get_cfg_desc, .GetFSConfigDescriptor = cdc_get_cfg_desc, .GetOtherSpeedConfigDescriptor = cdc_get_cfg_desc, .GetDeviceQualifierDescriptor = NULL, };
38.813559
110
0.606201
[ "model" ]
c6a0c7afe207d145426efa1627b5416f00330261
344
h
C
include/WGL/interceptors.h
kbiElude/VKGL
fffabf412723a3612ba1c5bfeafe1da38062bd18
[ "MIT" ]
114
2018-08-05T16:26:53.000Z
2021-12-30T07:28:35.000Z
include/WGL/interceptors.h
kbiElude/VKGL
fffabf412723a3612ba1c5bfeafe1da38062bd18
[ "MIT" ]
5
2018-08-18T21:16:58.000Z
2018-11-22T21:50:48.000Z
include/WGL/interceptors.h
kbiElude/VKGL
fffabf412723a3612ba1c5bfeafe1da38062bd18
[ "MIT" ]
6
2018-08-05T22:32:28.000Z
2021-10-04T15:39:53.000Z
/* VKGL (c) 2018 Dominik Witczak * * This code is licensed under MIT license (see LICENSE.txt for details) */ #ifndef WGL_INTERCEPTORS_H #define WGL_INTERCEPTORS_H #include "Common/globals.h" #include <vector> namespace WGL { extern std::vector<VKGL::FunctionInterceptor> get_function_interceptors(); } #endif /* WGL_INTERCEPTORS_H */
21.5
78
0.752907
[ "vector" ]
c6abf39e6ffa89ec6f9e1bb9cf7144771ce9dcd0
8,149
c
C
QCA4020_SDK/target/quartz/mfg/OTP/src/app/app.c
r8d8/lastlock
78c02e5fbb129b1bc4147bd55eec2882267d7e87
[ "Apache-2.0" ]
null
null
null
QCA4020_SDK/target/quartz/mfg/OTP/src/app/app.c
r8d8/lastlock
78c02e5fbb129b1bc4147bd55eec2882267d7e87
[ "Apache-2.0" ]
null
null
null
QCA4020_SDK/target/quartz/mfg/OTP/src/app/app.c
r8d8/lastlock
78c02e5fbb129b1bc4147bd55eec2882267d7e87
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017 Qualcomm Technologies, Inc. * All Rights Reserved. */ // Copyright (c) 2018 Qualcomm Technologies, Inc. // All rights reserved. // Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) // provided that the following conditions are met: // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. // Neither the name of Qualcomm Technologies, Inc. nor the names of its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*------------------------------------------------------------------------- * Include Files *-----------------------------------------------------------------------*/ #include <stdio.h> #include <stdarg.h> #include "stringl.h" #include "otp_params.h" #include "app.h" /*------------------------------------------------------------------------- * Preprocessor Definitions and Constants *-----------------------------------------------------------------------*/ #define OTP_DBG_ENABLE 1 /*------------------------------------------------------------------------- * Static & global Variable Declarations *-----------------------------------------------------------------------*/ extern uint32_t kdf_enable; extern uint32_t secure_boot_enable; extern uint32_t firmware_region_write_disable; extern uint32_t model_id; extern uint8_t pk_hash[]; extern uint32_t pk_hash_size; extern uint8_t enc_key[]; extern uint32_t enc_key_size; extern uint32_t otp_profile; static PAL_Context_t PAL_Context; uint8_t Printf_Buffer[256]; /*------------------------------------------------------------------------- * Function Definitions *-----------------------------------------------------------------------*/ /** @brief This function handles transmit callbacks from the UART. @param Num_Bytes[in] is the number of bytes transmitted. @param CB_Data[in] is the application defined callback data. */ static void Uart_Tx_CB(uint32 Num_Bytes, void* CB_Data) { } /** @brief This function handles receive callbacks from the UART. @param Num_Bytes[in] is the number of bytes received. @param CB_Data[in] is the application defined callback data. In this case it is the index of the buffer received on. */ static void Uart_Rx_CB(uint32 Num_Bytes, void* CB_Data) { } qbool_t PAL_Uart_Init(int reinit_flag) { qapi_UART_Open_Config_t Uart_Config; uint8_t Ret_Val; uint32_t Index; Uart_Config.baud_Rate = 115200; Uart_Config.parity_Mode = QAPI_UART_NO_PARITY_E; Uart_Config.num_Stop_Bits = QAPI_UART_1_0_STOP_BITS_E; Uart_Config.bits_Per_Char = QAPI_UART_8_BITS_PER_CHAR_E; Uart_Config.enable_Loopback = FALSE; Uart_Config.enable_Flow_Ctrl = FALSE; Uart_Config.tx_CB_ISR = (qapi_UART_Callback_Fn_t) Uart_Tx_CB; Uart_Config.rx_CB_ISR = (qapi_UART_Callback_Fn_t) Uart_Rx_CB; PAL_Context.Uart_Enable = 1; if(qapi_UART_Open(&(PAL_Context.Console_UART), PAL_CONSOLE_PORT, &Uart_Config) == QAPI_OK) { /* Queue the receives. */ for(Index = 0; Index < PAL_RECIEVE_BUFFER_COUNT; Index ++) { qapi_UART_Receive(PAL_Context.Console_UART, (char *)(PAL_Context.Rx_Buffer[Index]), PAL_RECIEVE_BUFFER_SIZE, (void *)Index); } Ret_Val = true; } else { Ret_Val = false; } return(Ret_Val); } /** @brief This function is used to initialize the Platform, predominately the console port. @return - true if the platform was initialized successfully. - false if initialization failed. */ static qbool_t PAL_Initialize(void) { uint8_t Ret_Val; memset(&PAL_Context, 0, sizeof(PAL_Context)); PAL_Context.Rx_Buffers_Free = PAL_RECIEVE_BUFFER_COUNT; Ret_Val = PAL_Uart_Init(0); return(Ret_Val); } void OTP_Printf(const char *Format, ...){ int Length; va_list Arg_List; /* Print the string to the buffer. */ va_start(Arg_List, Format); Length = vsnprintf((char *)(Printf_Buffer), sizeof(Printf_Buffer), (char *)Format, Arg_List); va_end(Arg_List); /* Make sure the length is not greater than the buffer size (taking the NULL terminator into account). */ if(Length > sizeof(Printf_Buffer) - 1) { Length = sizeof(Printf_Buffer) - 1; } #if OTP_DBG_ENABLE == 1 PAL_Console_Write(Length, &(Printf_Buffer[0])); PAL_Console_Write(sizeof(PAL_OUTPUT_END_OF_LINE_STRING) - 1, PAL_OUTPUT_END_OF_LINE_STRING); #endif } /** @brief This function is used to write a buffer to the console. Note that when this function returns, all data from the buffer will be written to the console or buffered locally. @param Length is the length of the data to be written. @param Buffer is a pointer to the buffer to be written to the console. */ void PAL_Console_Write(uint32_t Length, const char *Buffer) { int i=0; if((Length) && (Buffer) && (PAL_Context.Uart_Enable)) { /* Transmit the data. */ qapi_UART_Transmit(PAL_Context.Console_UART, (char *)Buffer, Length, NULL); } /* Add delay to allow UART TX to complete */ while(i < 0x8000) i++; } void Display_Failure(char *info, uint32_t reason) { char *error_message[] ={ "success", "otp ops error", "enc key len error", "pk hash len error", "invalid otp profile setting", }; if( reason < OTP_STATUS_ERR_LAST) OTP_Printf("%s: %s\n", info, error_message[reason]); else OTP_Printf("%s: reason is invalid number\n", info); return; } /** @brief This function is the main entry point for the application. */ void app_start(qbool_t ColdBoot) { uint32_t rtn, tag; #if OTP_DBG_ENABLE == 1 PAL_Initialize(); #endif tag = 0; if( (rtn = OTP_set_kdf(kdf_enable, enc_key, enc_key_size )) != OTP_STATUS_SUCCESS ) { Display_Failure("Fail to set KDF", rtn); tag = 1; } if( (rtn = OTP_set_secure_boot(secure_boot_enable, pk_hash, pk_hash_size)) != OTP_STATUS_SUCCESS ) { Display_Failure("Fail to set secure boot", rtn); tag = 1; } if( (rtn = OTP_set_firmware_region_write_disable(firmware_region_write_disable)) != OTP_STATUS_SUCCESS ) { Display_Failure("Fail to set firmware region write enable", rtn); tag = 1; } if( (rtn = OTP_set_model_id(model_id)) != OTP_STATUS_SUCCESS ) { Display_Failure("Fail to set model id", rtn); tag = 1; } if( (rtn = OTP_set_profile(otp_profile)) != OTP_STATUS_SUCCESS ) { Display_Failure("Fail to set otp profile", rtn); tag = 1; } if( tag != 1 ) { OTP_Printf("OTP update success\n"); } otp_end: return; }
33.813278
151
0.638729
[ "model" ]
c6b13637b12d9de25e0c427d4f528f7700e0b986
1,268
h
C
Libraries/RobsJuceModules/romos/Algorithms/romos_Interpolation.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
34
2017-04-19T18:26:02.000Z
2022-02-15T17:47:26.000Z
Libraries/RobsJuceModules/romos/Algorithms/romos_Interpolation.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
307
2017-05-04T21:45:01.000Z
2022-02-03T00:59:01.000Z
Libraries/RobsJuceModules/romos/Algorithms/romos_Interpolation.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
4
2017-09-05T17:04:31.000Z
2021-12-15T21:24:28.000Z
#ifndef romos_Interpolation_h #define romos_Interpolation_h //namespace romos //{ //------------------------------------------------------------------------------------------------- // The following functions are for computing an intermediate data value that is in between the // known data samples (interpolation) /** Interpolates between the points (xL, yL), (xR, yR) that represent x- and y-coordinates to the left and right to the point x at which we want to obtain an interpolated data value. Assuming yR > yL, the curve drawn between the two points is an exponential growth function when "shape" is greater than 0, an (up-down flipped) exponential decay function when shape is less than 0 and a straight line when shape equals zero. Analogously, when yR < yL, the shape is an exponential decay for shape < 0 and a flipped exponential growth for shape > 0. The absolute value of "shape" determines how many exponential time constants occur between the endpoints of the curve. Values of shape < 0 draw curves that resemble the behaviour of analog (RC-type) envelope generators. References: -Moore: Elements of Computer Music, page 184 */ double interpolateExponentially(double x, double xL, double yL, double xR, double yR, double shape); //} #endif
46.962963
100
0.711356
[ "shape" ]
c6b5d485ee116d1e04ef51104bfdb26d644da626
1,291
h
C
src/planner.h
snicholas/CarND-Path-Planning-Project
3860bf19ab234fb32e85c41105f3b46a94b26a8b
[ "MIT" ]
null
null
null
src/planner.h
snicholas/CarND-Path-Planning-Project
3860bf19ab234fb32e85c41105f3b46a94b26a8b
[ "MIT" ]
null
null
null
src/planner.h
snicholas/CarND-Path-Planning-Project
3860bf19ab234fb32e85c41105f3b46a94b26a8b
[ "MIT" ]
null
null
null
/* * path_planner.h * * Created on: 09.11.2018 * Author: academy */ #ifndef SRC_PATH_PLANNER_H_ #define SRC_PATH_PLANNER_H_ #include <math.h> #include <iostream> #include <vector> #include "json.hpp" #include "spline.h" #include "helpers.h" #include "vehicle.h" using std::vector; using namespace std; class Planner { public: Vehicle car; vector<Vehicle> vehicles; int lane = 1; double ref_velocity = 0; json previous_path_x ; json previous_path_y ; // Previous path's end s and d values double end_path_s = 0.0; double end_path_d = 0.0; vector<double> wp_x; vector<double> wp_y; vector<double> wp_s; vector<double> wp_dx; vector<double> wp_dy; Planner(vector<double> map_waypoints_x, vector<double> map_waypoints_y, vector<double> map_waypoints_s, vector<double> map_waypoints_dx, vector<double> map_waypoints_dy); void updateSensorFusion(json data); double laneSpeed(int lane); int fastestLane(); double safetyDistance(double speed_mps); json path(); double centerLaneD(int lane); double safetyCosts(int lane); double wrappedDistance(double s1, double s2); }; #endif /* SRC_PATH_PLANNER_H_ */
20.822581
50
0.652982
[ "vector" ]
c6cf835a6b8e74b9de495196f7c8a4dba9870d98
69,300
c
C
src/FNA3D_Driver_ThreadedGL.c
melissasage/FNA3D
d23cd11d7322c3d6b6e1313c762f14278ed38138
[ "Zlib" ]
null
null
null
src/FNA3D_Driver_ThreadedGL.c
melissasage/FNA3D
d23cd11d7322c3d6b6e1313c762f14278ed38138
[ "Zlib" ]
null
null
null
src/FNA3D_Driver_ThreadedGL.c
melissasage/FNA3D
d23cd11d7322c3d6b6e1313c762f14278ed38138
[ "Zlib" ]
null
null
null
/* FNA3D - 3D Graphics Library for FNA * * Copyright (c) 2020 Ethan Lee * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from * the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a * product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. * * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com> * */ #if FNA3D_DRIVER_THREADEDGL #if !FNA3D_DRIVER_MODERNGL #error ThreadedGL requires ModernGL. Fix your build. #endif #include "FNA3D_Driver.h" #include <SDL.h> /* Internal Structures */ typedef struct GLThreadCommand GLThreadCommand; struct GLThreadCommand { uint8_t type; SDL_sem *semaphore; GLThreadCommand *next; #define COMMAND_CREATEDEVICE 0 #define COMMAND_BEGINFRAME 1 #define COMMAND_SWAPBUFFERS 2 #define COMMAND_SETPRESENTATIONINTERVAL 3 #define COMMAND_CLEAR 4 #define COMMAND_DRAWINDEXEDPRIMITIVES 5 #define COMMAND_DRAWINSTANCEDPRIMITIVES 6 #define COMMAND_DRAWPRIMITIVES 7 #define COMMAND_DRAWUSERINDEXEDPRIMITIVES 8 #define COMMAND_DRAWUSERPRIMITIVES 9 #define COMMAND_SETVIEWPORT 10 #define COMMAND_SETSCISSORRECT 11 #define COMMAND_GETBLENDFACTOR 12 #define COMMAND_SETBLENDFACTOR 13 #define COMMAND_GETMULTISAMPLEMASK 14 #define COMMAND_SETMULTISAMPLEMASK 15 #define COMMAND_GETREFERENCESTENCIL 16 #define COMMAND_SETREFERENCESTENCIL 17 #define COMMAND_SETBLENDSTATE 18 #define COMMAND_SETDEPTHSTENCILSTATE 19 #define COMMAND_APPLYRASTERIZERSTATE 20 #define COMMAND_VERIFYSAMPLER 21 #define COMMAND_APPLYVERTEXBUFFERBINDINGS 22 #define COMMAND_APPLYVERTEXDECLARATION 23 #define COMMAND_SETRENDERTARGETS 24 #define COMMAND_RESOLVETARGET 25 #define COMMAND_RESETBACKBUFFER 26 #define COMMAND_READBACKBUFFER 27 #define COMMAND_GETBACKBUFFERSIZE 28 #define COMMAND_GETBACKBUFFERSURFACEFORMAT 29 #define COMMAND_GETBACKBUFFERDEPTHFORMAT 30 #define COMMAND_GETBACKBUFFERMULTISAMPLECOUNT 31 #define COMMAND_CREATETEXTURE2D 32 #define COMMAND_CREATETEXTURE3D 33 #define COMMAND_CREATETEXTURECUBE 34 #define COMMAND_ADDDISPOSETEXTURE 35 #define COMMAND_SETTEXTUREDATA2D 36 #define COMMAND_SETTEXTUREDATA3D 37 #define COMMAND_SETTEXTUREDATACUBE 38 #define COMMAND_SETTEXTUREDATAYUV 39 #define COMMAND_GETTEXTUREDATA2D 40 #define COMMAND_GETTEXTUREDATA3D 41 #define COMMAND_GETTEXTUREDATACUBE 42 #define COMMAND_GENCOLORRENDERBUFFER 43 #define COMMAND_GENDEPTHSTENCILRENDERBUFFER 44 #define COMMAND_ADDDISPOSERENDERBUFFER 45 #define COMMAND_GENVERTEXBUFFER 46 #define COMMAND_ADDDISPOSEVERTEXBUFFER 47 #define COMMAND_SETVERTEXBUFFERDATA 48 #define COMMAND_GETVERTEXBUFFERDATA 49 #define COMMAND_GENINDEXBUFFER 50 #define COMMAND_ADDDISPOSEINDEXBUFFER 51 #define COMMAND_SETINDEXBUFFERDATA 52 #define COMMAND_GETINDEXBUFFERDATA 53 #define COMMAND_CREATEEFFECT 54 #define COMMAND_CLONEEFFECT 55 #define COMMAND_ADDDISPOSEEFFECT 56 #define COMMAND_SETEFFECTTECHNIQUE 57 #define COMMAND_APPLYEFFECT 58 #define COMMAND_BEGINPASSRESTORE 59 #define COMMAND_ENDPASSRESTORE 60 #define COMMAND_CREATEQUERY 61 #define COMMAND_ADDDISPOSEQUERY 62 #define COMMAND_QUERYBEGIN 63 #define COMMAND_QUERYEND 64 #define COMMAND_QUERYCOMPLETE 65 #define COMMAND_QUERYPIXELCOUNT 66 #define COMMAND_SUPPORTSDXT1 67 #define COMMAND_SUPPORTSS3TC 68 #define COMMAND_SUPPORTSHARDWAREINSTANCING 69 #define COMMAND_SUPPORTSNOOVERWRITE 70 #define COMMAND_GETMAXTEXTURESLOTS 71 #define COMMAND_GETMAXMULTISAMPLECOUNT 72 #define COMMAND_SETSTRINGMARKER 73 FNA3DNAMELESS union { struct { FNA3D_PresentationParameters *presentationParameters; uint8_t debugMode; } createDevice; /* Nothing to store for BeginFrame */ struct { FNA3D_Rect *sourceRectangle; FNA3D_Rect *destinationRectangle; void* overrideWindowHandle; } swapBuffers; struct { FNA3D_PresentInterval presentInterval; } setPresentationInterval; struct { FNA3D_ClearOptions options; FNA3D_Vec4 *color; float depth; int32_t stencil; } clear; struct { FNA3D_PrimitiveType primitiveType; int32_t baseVertex; int32_t minVertexIndex; int32_t numVertices; int32_t startIndex; int32_t primitiveCount; FNA3D_Buffer *indices; FNA3D_IndexElementSize indexElementSize; } drawIndexedPrimitives; struct { FNA3D_PrimitiveType primitiveType; int32_t baseVertex; int32_t minVertexIndex; int32_t numVertices; int32_t startIndex; int32_t primitiveCount; int32_t instanceCount; FNA3D_Buffer *indices; FNA3D_IndexElementSize indexElementSize; } drawInstancedPrimitives; struct { FNA3D_PrimitiveType primitiveType; int32_t vertexStart; int32_t primitiveCount; } drawPrimitives; struct { FNA3D_PrimitiveType primitiveType; void* vertexData; int32_t vertexOffset; int32_t numVertices; void* indexData; int32_t indexOffset; FNA3D_IndexElementSize indexElementSize; int32_t primitiveCount; } drawUserIndexedPrimitives; struct { FNA3D_PrimitiveType primitiveType; void* vertexData; int32_t vertexOffset; int32_t primitiveCount; } drawUserPrimitives; struct { FNA3D_Viewport *viewport; } setViewport; struct { FNA3D_Rect *scissor; } setScissorRect; struct { FNA3D_Color *blendFactor; } getBlendFactor; struct { FNA3D_Color *blendFactor; } setBlendFactor; struct { int32_t retval; } getMultiSampleMask; struct { int32_t mask; } setMultiSampleMask; struct { int32_t retval; } getReferenceStencil; struct { int32_t ref; } setReferenceStencil; struct { FNA3D_BlendState *blendState; } setBlendState; struct { FNA3D_DepthStencilState *depthStencilState; } setDepthStencilState; struct { FNA3D_RasterizerState *rasterizerState; } applyRasterizerState; struct { int32_t index; FNA3D_Texture *texture; FNA3D_SamplerState *sampler; } verifySampler; struct { FNA3D_VertexBufferBinding *bindings; int32_t numBindings; uint8_t bindingsUpdated; int32_t baseVertex; } applyVertexBufferBindings; struct { FNA3D_VertexDeclaration *vertexDeclaration; void* vertexData; int32_t vertexOffset; } applyVertexDeclaration; struct { FNA3D_RenderTargetBinding *renderTargets; int32_t numRenderTargets; FNA3D_Renderbuffer *depthStencilBuffer; FNA3D_DepthFormat depthFormat; } setRenderTargets; struct { FNA3D_RenderTargetBinding *target; } resolveTarget; struct { FNA3D_PresentationParameters *presentationParameters; } resetBackbuffer; struct { int32_t x; int32_t y; int32_t w; int32_t h; void* data; int32_t dataLength; } readBackbuffer; struct { int32_t *w; int32_t *h; } getBackbufferSize; struct { FNA3D_SurfaceFormat retval; } getBackbufferSurfaceFormat; struct { FNA3D_DepthFormat retval; } getBackbufferDepthFormat; struct { int32_t retval; } getBackbufferMultiSampleCount; struct { FNA3D_SurfaceFormat format; int32_t width; int32_t height; int32_t levelCount; uint8_t isRenderTarget; FNA3D_Texture *retval; } createTexture2D; struct { FNA3D_SurfaceFormat format; int32_t width; int32_t height; int32_t depth; int32_t levelCount; FNA3D_Texture *retval; } createTexture3D; struct { FNA3D_SurfaceFormat format; int32_t size; int32_t levelCount; uint8_t isRenderTarget; FNA3D_Texture *retval; } createTextureCube; struct { FNA3D_Texture *texture; } addDisposeTexture; struct { FNA3D_Texture *texture; FNA3D_SurfaceFormat format; int32_t x; int32_t y; int32_t w; int32_t h; int32_t level; void* data; int32_t dataLength; } setTextureData2D; struct { FNA3D_Texture *texture; FNA3D_SurfaceFormat format; int32_t x; int32_t y; int32_t z; int32_t w; int32_t h; int32_t d; int32_t level; void* data; int32_t dataLength; } setTextureData3D; struct { FNA3D_Texture *texture; FNA3D_SurfaceFormat format; int32_t x; int32_t y; int32_t w; int32_t h; FNA3D_CubeMapFace cubeMapFace; int32_t level; void* data; int32_t dataLength; } setTextureDataCube; struct { FNA3D_Texture *y; FNA3D_Texture *u; FNA3D_Texture *v; int32_t yWidth; int32_t yHeight; int32_t uvWidth; int32_t uvHeight; void* data; int32_t dataLength; } setTextureDataYUV; struct { FNA3D_Texture *texture; FNA3D_SurfaceFormat format; int32_t x; int32_t y; int32_t w; int32_t h; int32_t level; void* data; int32_t dataLength; } getTextureData2D; struct { FNA3D_Texture *texture; FNA3D_SurfaceFormat format; int32_t x; int32_t y; int32_t z; int32_t w; int32_t h; int32_t d; int32_t level; void* data; int32_t dataLength; } getTextureData3D; struct { FNA3D_Texture *texture; FNA3D_SurfaceFormat format; int32_t x; int32_t y; int32_t w; int32_t h; FNA3D_CubeMapFace cubeMapFace; int32_t level; void* data; int32_t dataLength; } getTextureDataCube; struct { int32_t width; int32_t height; FNA3D_SurfaceFormat format; int32_t multiSampleCount; FNA3D_Texture *texture; FNA3D_Renderbuffer *retval; } genColorRenderbuffer; struct { int32_t width; int32_t height; FNA3D_DepthFormat format; int32_t multiSampleCount; FNA3D_Renderbuffer *retval; } genDepthStencilRenderbuffer; struct { FNA3D_Renderbuffer *renderbuffer; } addDisposeRenderbuffer; struct { uint8_t dynamic; FNA3D_BufferUsage usage; int32_t vertexCount; int32_t vertexStride; FNA3D_Buffer *retval; } genVertexBuffer; struct { FNA3D_Buffer *buffer; } addDisposeVertexBuffer; struct { FNA3D_Buffer *buffer; int32_t offsetInBytes; void* data; int32_t elementCount; int32_t elementSizeInBytes; int32_t vertexStride; FNA3D_SetDataOptions options; } setVertexBufferData; struct { FNA3D_Buffer *buffer; int32_t offsetInBytes; void* data; int32_t elementCount; int32_t elementSizeInBytes; int32_t vertexStride; } getVertexBufferData; struct { uint8_t dynamic; FNA3D_BufferUsage usage; int32_t indexCount; FNA3D_IndexElementSize indexElementSize; FNA3D_Buffer *retval; } genIndexBuffer; struct { FNA3D_Buffer *buffer; } addDisposeIndexBuffer; struct { FNA3D_Buffer *buffer; int32_t offsetInBytes; void* data; int32_t dataLength; FNA3D_SetDataOptions options; } setIndexBufferData; struct { FNA3D_Buffer *buffer; int32_t offsetInBytes; void* data; int32_t dataLength; } getIndexBufferData; struct { uint8_t *effectCode; uint32_t effectCodeLength; FNA3D_Effect **effect; MOJOSHADER_effect **effectData; } createEffect; struct { FNA3D_Effect *cloneSource; FNA3D_Effect **effect; MOJOSHADER_effect **effectData; } cloneEffect; struct { FNA3D_Effect *effect; } addDisposeEffect; struct { FNA3D_Effect *effect; MOJOSHADER_effectTechnique *technique; } setEffectTechnique; struct { FNA3D_Effect *effect; uint32_t pass; MOJOSHADER_effectStateChanges *stateChanges; } applyEffect; struct { FNA3D_Effect *effect; MOJOSHADER_effectStateChanges *stateChanges; } beginPassRestore; struct { FNA3D_Effect *effect; } endPassRestore; struct { FNA3D_Query* retval; } createQuery; struct { FNA3D_Query *query; } addDisposeQuery; struct { FNA3D_Query *query; } queryBegin; struct { FNA3D_Query *query; } queryEnd; struct { FNA3D_Query *query; uint8_t retval; } queryComplete; struct { FNA3D_Query *query; int32_t retval; } queryPixelCount; struct { uint8_t retval; } supportsDXT1; struct { uint8_t retval; } supportsS3TC; struct { uint8_t retval; } supportsHardwareInstancing; struct { uint8_t retval; } supportsNoOverwrite; struct { int32_t retval; } getMaxTextureSlots; struct { int32_t retval; } getMaxMultiSampleCount; struct { const char *text; } setStringMarker; }; }; typedef struct ThreadedGLRenderer /* Cast FNA3D_Renderer* to this! */ { FNA3D_Device *actualDevice; GLThreadCommand *commands; SDL_mutex *commandsLock; SDL_sem *commandEvent; SDL_Thread *thread; uint8_t run; } ThreadedGLRenderer; /* The Graphics Thread */ static int GLRenderThread(void* data) { GLThreadCommand *cmd, *next; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) data; SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); while (renderer->run) { SDL_SemWait(renderer->commandEvent); SDL_LockMutex(renderer->commandsLock); cmd = renderer->commands; while (cmd != NULL) { switch (cmd->type) { case COMMAND_CREATEDEVICE: renderer->actualDevice = ModernGLDriver.CreateDevice( cmd->createDevice.presentationParameters, cmd->createDevice.debugMode ); break; case COMMAND_BEGINFRAME: renderer->actualDevice->BeginFrame( renderer->actualDevice->driverData ); break; case COMMAND_SWAPBUFFERS: renderer->actualDevice->SwapBuffers( renderer->actualDevice->driverData, cmd->swapBuffers.sourceRectangle, cmd->swapBuffers.destinationRectangle, cmd->swapBuffers.overrideWindowHandle ); break; case COMMAND_SETPRESENTATIONINTERVAL: renderer->actualDevice->SetPresentationInterval( renderer->actualDevice->driverData, cmd->setPresentationInterval.presentInterval ); break; case COMMAND_CLEAR: renderer->actualDevice->Clear( renderer->actualDevice->driverData, cmd->clear.options, cmd->clear.color, cmd->clear.depth, cmd->clear.stencil ); break; case COMMAND_DRAWINDEXEDPRIMITIVES: renderer->actualDevice->DrawIndexedPrimitives( renderer->actualDevice->driverData, cmd->drawIndexedPrimitives.primitiveType, cmd->drawIndexedPrimitives.baseVertex, cmd->drawIndexedPrimitives.minVertexIndex, cmd->drawIndexedPrimitives.numVertices, cmd->drawIndexedPrimitives.startIndex, cmd->drawIndexedPrimitives.primitiveCount, cmd->drawIndexedPrimitives.indices, cmd->drawIndexedPrimitives.indexElementSize ); break; case COMMAND_DRAWINSTANCEDPRIMITIVES: renderer->actualDevice->DrawInstancedPrimitives( renderer->actualDevice->driverData, cmd->drawInstancedPrimitives.primitiveType, cmd->drawInstancedPrimitives.baseVertex, cmd->drawInstancedPrimitives.minVertexIndex, cmd->drawInstancedPrimitives.numVertices, cmd->drawInstancedPrimitives.startIndex, cmd->drawInstancedPrimitives.primitiveCount, cmd->drawInstancedPrimitives.instanceCount, cmd->drawInstancedPrimitives.indices, cmd->drawInstancedPrimitives.indexElementSize ); break; case COMMAND_DRAWPRIMITIVES: renderer->actualDevice->DrawPrimitives( renderer->actualDevice->driverData, cmd->drawPrimitives.primitiveType, cmd->drawPrimitives.vertexStart, cmd->drawPrimitives.primitiveCount ); break; case COMMAND_DRAWUSERINDEXEDPRIMITIVES: renderer->actualDevice->DrawUserIndexedPrimitives( renderer->actualDevice->driverData, cmd->drawUserIndexedPrimitives.primitiveType, cmd->drawUserIndexedPrimitives.vertexData, cmd->drawUserIndexedPrimitives.vertexOffset, cmd->drawUserIndexedPrimitives.numVertices, cmd->drawUserIndexedPrimitives.indexData, cmd->drawUserIndexedPrimitives.indexOffset, cmd->drawUserIndexedPrimitives.indexElementSize, cmd->drawUserIndexedPrimitives.primitiveCount ); break; case COMMAND_DRAWUSERPRIMITIVES: renderer->actualDevice->DrawUserPrimitives( renderer->actualDevice->driverData, cmd->drawUserPrimitives.primitiveType, cmd->drawUserPrimitives.vertexData, cmd->drawUserPrimitives.vertexOffset, cmd->drawUserPrimitives.primitiveCount ); break; case COMMAND_SETVIEWPORT: renderer->actualDevice->SetViewport( renderer->actualDevice->driverData, cmd->setViewport.viewport ); break; case COMMAND_SETSCISSORRECT: renderer->actualDevice->SetScissorRect( renderer->actualDevice->driverData, cmd->setScissorRect.scissor ); break; case COMMAND_GETBLENDFACTOR: renderer->actualDevice->GetBlendFactor( renderer->actualDevice->driverData, cmd->getBlendFactor.blendFactor ); break; case COMMAND_SETBLENDFACTOR: renderer->actualDevice->SetBlendFactor( renderer->actualDevice->driverData, cmd->setBlendFactor.blendFactor ); break; case COMMAND_GETMULTISAMPLEMASK: cmd->getMultiSampleMask.retval = renderer->actualDevice->GetMultiSampleMask( renderer->actualDevice->driverData ); break; case COMMAND_SETMULTISAMPLEMASK: renderer->actualDevice->SetMultiSampleMask( renderer->actualDevice->driverData, cmd->setMultiSampleMask.mask ); break; case COMMAND_GETREFERENCESTENCIL: cmd->getReferenceStencil.retval = renderer->actualDevice->GetReferenceStencil( renderer->actualDevice->driverData ); break; case COMMAND_SETREFERENCESTENCIL: renderer->actualDevice->SetReferenceStencil( renderer->actualDevice->driverData, cmd->setReferenceStencil.ref ); break; case COMMAND_SETBLENDSTATE: renderer->actualDevice->SetBlendState( renderer->actualDevice->driverData, cmd->setBlendState.blendState ); break; case COMMAND_SETDEPTHSTENCILSTATE: renderer->actualDevice->SetDepthStencilState( renderer->actualDevice->driverData, cmd->setDepthStencilState.depthStencilState ); break; case COMMAND_APPLYRASTERIZERSTATE: renderer->actualDevice->ApplyRasterizerState( renderer->actualDevice->driverData, cmd->applyRasterizerState.rasterizerState ); break; case COMMAND_VERIFYSAMPLER: renderer->actualDevice->VerifySampler( renderer->actualDevice->driverData, cmd->verifySampler.index, cmd->verifySampler.texture, cmd->verifySampler.sampler ); break; case COMMAND_APPLYVERTEXBUFFERBINDINGS: renderer->actualDevice->ApplyVertexBufferBindings( renderer->actualDevice->driverData, cmd->applyVertexBufferBindings.bindings, cmd->applyVertexBufferBindings.numBindings, cmd->applyVertexBufferBindings.bindingsUpdated, cmd->applyVertexBufferBindings.baseVertex ); break; case COMMAND_APPLYVERTEXDECLARATION: renderer->actualDevice->ApplyVertexDeclaration( renderer->actualDevice->driverData, cmd->applyVertexDeclaration.vertexDeclaration, cmd->applyVertexDeclaration.vertexData, cmd->applyVertexDeclaration.vertexOffset ); break; case COMMAND_SETRENDERTARGETS: renderer->actualDevice->SetRenderTargets( renderer->actualDevice->driverData, cmd->setRenderTargets.renderTargets, cmd->setRenderTargets.numRenderTargets, cmd->setRenderTargets.depthStencilBuffer, cmd->setRenderTargets.depthFormat ); break; case COMMAND_RESOLVETARGET: renderer->actualDevice->ResolveTarget( renderer->actualDevice->driverData, cmd->resolveTarget.target ); break; case COMMAND_RESETBACKBUFFER: renderer->actualDevice->ResetBackbuffer( renderer->actualDevice->driverData, cmd->resetBackbuffer.presentationParameters ); break; case COMMAND_READBACKBUFFER: renderer->actualDevice->ReadBackbuffer( renderer->actualDevice->driverData, cmd->readBackbuffer.x, cmd->readBackbuffer.y, cmd->readBackbuffer.w, cmd->readBackbuffer.h, cmd->readBackbuffer.data, cmd->readBackbuffer.dataLength ); break; case COMMAND_GETBACKBUFFERSIZE: renderer->actualDevice->GetBackbufferSize( renderer->actualDevice->driverData, cmd->getBackbufferSize.w, cmd->getBackbufferSize.h ); break; case COMMAND_GETBACKBUFFERSURFACEFORMAT: cmd->getBackbufferSurfaceFormat.retval = renderer->actualDevice->GetBackbufferSurfaceFormat( renderer->actualDevice->driverData ); break; case COMMAND_GETBACKBUFFERDEPTHFORMAT: cmd->getBackbufferDepthFormat.retval = renderer->actualDevice->GetBackbufferDepthFormat( renderer->actualDevice->driverData ); break; case COMMAND_GETBACKBUFFERMULTISAMPLECOUNT: cmd->getBackbufferMultiSampleCount.retval = renderer->actualDevice->GetBackbufferMultiSampleCount( renderer->actualDevice->driverData ); break; case COMMAND_CREATETEXTURE2D: cmd->createTexture2D.retval = renderer->actualDevice->CreateTexture2D( renderer->actualDevice->driverData, cmd->createTexture2D.format, cmd->createTexture2D.width, cmd->createTexture2D.height, cmd->createTexture2D.levelCount, cmd->createTexture2D.isRenderTarget ); break; case COMMAND_CREATETEXTURE3D: cmd->createTexture3D.retval = renderer->actualDevice->CreateTexture3D( renderer->actualDevice->driverData, cmd->createTexture3D.format, cmd->createTexture3D.width, cmd->createTexture3D.height, cmd->createTexture3D.depth, cmd->createTexture3D.levelCount ); break; case COMMAND_CREATETEXTURECUBE: cmd->createTextureCube.retval = renderer->actualDevice->CreateTextureCube( renderer->actualDevice->driverData, cmd->createTextureCube.format, cmd->createTextureCube.size, cmd->createTextureCube.levelCount, cmd->createTextureCube.isRenderTarget ); break; case COMMAND_ADDDISPOSETEXTURE: renderer->actualDevice->AddDisposeTexture( renderer->actualDevice->driverData, cmd->addDisposeTexture.texture ); break; case COMMAND_SETTEXTUREDATA2D: renderer->actualDevice->SetTextureData2D( renderer->actualDevice->driverData, cmd->setTextureData2D.texture, cmd->setTextureData2D.format, cmd->setTextureData2D.x, cmd->setTextureData2D.y, cmd->setTextureData2D.w, cmd->setTextureData2D.h, cmd->setTextureData2D.level, cmd->setTextureData2D.data, cmd->setTextureData2D.dataLength ); break; case COMMAND_SETTEXTUREDATA3D: renderer->actualDevice->SetTextureData3D( renderer->actualDevice->driverData, cmd->setTextureData3D.texture, cmd->setTextureData3D.format, cmd->setTextureData3D.x, cmd->setTextureData3D.y, cmd->setTextureData3D.z, cmd->setTextureData3D.w, cmd->setTextureData3D.h, cmd->setTextureData3D.d, cmd->setTextureData3D.level, cmd->setTextureData3D.data, cmd->setTextureData3D.dataLength ); break; case COMMAND_SETTEXTUREDATACUBE: renderer->actualDevice->SetTextureDataCube( renderer->actualDevice->driverData, cmd->setTextureDataCube.texture, cmd->setTextureDataCube.format, cmd->setTextureDataCube.x, cmd->setTextureDataCube.y, cmd->setTextureDataCube.w, cmd->setTextureDataCube.h, cmd->setTextureDataCube.cubeMapFace, cmd->setTextureDataCube.level, cmd->setTextureDataCube.data, cmd->setTextureDataCube.dataLength ); break; case COMMAND_SETTEXTUREDATAYUV: renderer->actualDevice->SetTextureDataYUV( renderer->actualDevice->driverData, cmd->setTextureDataYUV.y, cmd->setTextureDataYUV.u, cmd->setTextureDataYUV.v, cmd->setTextureDataYUV.yWidth, cmd->setTextureDataYUV.yHeight, cmd->setTextureDataYUV.uvWidth, cmd->setTextureDataYUV.uvHeight, cmd->setTextureDataYUV.data, cmd->setTextureDataYUV.dataLength ); break; case COMMAND_GETTEXTUREDATA2D: renderer->actualDevice->GetTextureData2D( renderer->actualDevice->driverData, cmd->getTextureData2D.texture, cmd->getTextureData2D.format, cmd->getTextureData2D.x, cmd->getTextureData2D.y, cmd->getTextureData2D.w, cmd->getTextureData2D.h, cmd->getTextureData2D.level, cmd->getTextureData2D.data, cmd->getTextureData2D.dataLength ); break; case COMMAND_GETTEXTUREDATA3D: renderer->actualDevice->GetTextureData3D( renderer->actualDevice->driverData, cmd->getTextureData3D.texture, cmd->getTextureData3D.format, cmd->getTextureData3D.x, cmd->getTextureData3D.y, cmd->getTextureData3D.z, cmd->getTextureData3D.w, cmd->getTextureData3D.h, cmd->getTextureData3D.d, cmd->getTextureData3D.level, cmd->getTextureData3D.data, cmd->getTextureData3D.dataLength ); break; case COMMAND_GETTEXTUREDATACUBE: renderer->actualDevice->GetTextureDataCube( renderer->actualDevice->driverData, cmd->getTextureDataCube.texture, cmd->getTextureDataCube.format, cmd->getTextureDataCube.x, cmd->getTextureDataCube.y, cmd->getTextureDataCube.w, cmd->getTextureDataCube.h, cmd->getTextureDataCube.cubeMapFace, cmd->getTextureDataCube.level, cmd->getTextureDataCube.data, cmd->getTextureDataCube.dataLength ); break; case COMMAND_GENCOLORRENDERBUFFER: cmd->genColorRenderbuffer.retval = renderer->actualDevice->GenColorRenderbuffer( renderer->actualDevice->driverData, cmd->genColorRenderbuffer.width, cmd->genColorRenderbuffer.height, cmd->genColorRenderbuffer.format, cmd->genColorRenderbuffer.multiSampleCount, cmd->genColorRenderbuffer.texture ); break; case COMMAND_GENDEPTHSTENCILRENDERBUFFER: cmd->genDepthStencilRenderbuffer.retval = renderer->actualDevice->GenDepthStencilRenderbuffer( renderer->actualDevice->driverData, cmd->genDepthStencilRenderbuffer.width, cmd->genDepthStencilRenderbuffer.height, cmd->genDepthStencilRenderbuffer.format, cmd->genDepthStencilRenderbuffer.multiSampleCount ); break; case COMMAND_ADDDISPOSERENDERBUFFER: renderer->actualDevice->AddDisposeRenderbuffer( renderer->actualDevice->driverData, cmd->addDisposeRenderbuffer.renderbuffer ); break; case COMMAND_GENVERTEXBUFFER: cmd->genVertexBuffer.retval = renderer->actualDevice->GenVertexBuffer( renderer->actualDevice->driverData, cmd->genVertexBuffer.dynamic, cmd->genVertexBuffer.usage, cmd->genVertexBuffer.vertexCount, cmd->genVertexBuffer.vertexStride ); break; case COMMAND_ADDDISPOSEVERTEXBUFFER: renderer->actualDevice->AddDisposeVertexBuffer( renderer->actualDevice->driverData, cmd->addDisposeVertexBuffer.buffer ); break; case COMMAND_SETVERTEXBUFFERDATA: renderer->actualDevice->SetVertexBufferData( renderer->actualDevice->driverData, cmd->setVertexBufferData.buffer, cmd->setVertexBufferData.offsetInBytes, cmd->setVertexBufferData.data, cmd->setVertexBufferData.elementCount, cmd->setVertexBufferData.elementSizeInBytes, cmd->setVertexBufferData.vertexStride, cmd->setVertexBufferData.options ); break; case COMMAND_GETVERTEXBUFFERDATA: renderer->actualDevice->GetVertexBufferData( renderer->actualDevice->driverData, cmd->getVertexBufferData.buffer, cmd->getVertexBufferData.offsetInBytes, cmd->getVertexBufferData.data, cmd->getVertexBufferData.elementCount, cmd->getVertexBufferData.elementSizeInBytes, cmd->getVertexBufferData.vertexStride ); break; case COMMAND_GENINDEXBUFFER: cmd->genIndexBuffer.retval = renderer->actualDevice->GenIndexBuffer( renderer->actualDevice->driverData, cmd->genIndexBuffer.dynamic, cmd->genIndexBuffer.usage, cmd->genIndexBuffer.indexCount, cmd->genIndexBuffer.indexElementSize ); break; case COMMAND_ADDDISPOSEINDEXBUFFER: renderer->actualDevice->AddDisposeIndexBuffer( renderer->actualDevice->driverData, cmd->addDisposeIndexBuffer.buffer ); break; case COMMAND_SETINDEXBUFFERDATA: renderer->actualDevice->SetIndexBufferData( renderer->actualDevice->driverData, cmd->setIndexBufferData.buffer, cmd->setIndexBufferData.offsetInBytes, cmd->setIndexBufferData.data, cmd->setIndexBufferData.dataLength, cmd->setIndexBufferData.options ); break; case COMMAND_GETINDEXBUFFERDATA: renderer->actualDevice->GetIndexBufferData( renderer->actualDevice->driverData, cmd->getIndexBufferData.buffer, cmd->getIndexBufferData.offsetInBytes, cmd->getIndexBufferData.data, cmd->getIndexBufferData.dataLength ); break; case COMMAND_CREATEEFFECT: renderer->actualDevice->CreateEffect( renderer->actualDevice->driverData, cmd->createEffect.effectCode, cmd->createEffect.effectCodeLength, cmd->createEffect.effect, cmd->createEffect.effectData ); break; case COMMAND_CLONEEFFECT: renderer->actualDevice->CloneEffect( renderer->actualDevice->driverData, cmd->cloneEffect.cloneSource, cmd->cloneEffect.effect, cmd->cloneEffect.effectData ); break; case COMMAND_ADDDISPOSEEFFECT: renderer->actualDevice->AddDisposeEffect( renderer->actualDevice->driverData, cmd->addDisposeEffect.effect ); break; case COMMAND_SETEFFECTTECHNIQUE: renderer->actualDevice->SetEffectTechnique( renderer->actualDevice->driverData, cmd->setEffectTechnique.effect, cmd->setEffectTechnique.technique ); break; case COMMAND_APPLYEFFECT: renderer->actualDevice->ApplyEffect( renderer->actualDevice->driverData, cmd->applyEffect.effect, cmd->applyEffect.pass, cmd->applyEffect.stateChanges ); break; case COMMAND_BEGINPASSRESTORE: renderer->actualDevice->BeginPassRestore( renderer->actualDevice->driverData, cmd->beginPassRestore.effect, cmd->beginPassRestore.stateChanges ); break; case COMMAND_ENDPASSRESTORE: renderer->actualDevice->EndPassRestore( renderer->actualDevice->driverData, cmd->endPassRestore.effect ); break; case COMMAND_CREATEQUERY: cmd->createQuery.retval = renderer->actualDevice->CreateQuery( renderer->actualDevice->driverData ); break; case COMMAND_ADDDISPOSEQUERY: renderer->actualDevice->AddDisposeQuery( renderer->actualDevice->driverData, cmd->addDisposeQuery.query ); break; case COMMAND_QUERYBEGIN: renderer->actualDevice->QueryBegin( renderer->actualDevice->driverData, cmd->queryBegin.query ); break; case COMMAND_QUERYEND: renderer->actualDevice->QueryEnd( renderer->actualDevice->driverData, cmd->queryEnd.query ); break; case COMMAND_QUERYCOMPLETE: cmd->queryComplete.retval = renderer->actualDevice->QueryComplete( renderer->actualDevice->driverData, cmd->queryComplete.query ); break; case COMMAND_QUERYPIXELCOUNT: cmd->queryPixelCount.retval = renderer->actualDevice->QueryPixelCount( renderer->actualDevice->driverData, cmd->queryPixelCount.query ); break; case COMMAND_SUPPORTSDXT1: cmd->supportsDXT1.retval = renderer->actualDevice->SupportsDXT1( renderer->actualDevice->driverData ); break; case COMMAND_SUPPORTSS3TC: cmd->supportsS3TC.retval = renderer->actualDevice->SupportsS3TC( renderer->actualDevice->driverData ); break; case COMMAND_SUPPORTSHARDWAREINSTANCING: cmd->supportsHardwareInstancing.retval = renderer->actualDevice->SupportsHardwareInstancing( renderer->actualDevice->driverData ); break; case COMMAND_SUPPORTSNOOVERWRITE: cmd->supportsNoOverwrite.retval = renderer->actualDevice->SupportsNoOverwrite( renderer->actualDevice->driverData ); break; case COMMAND_GETMAXTEXTURESLOTS: cmd->getMaxTextureSlots.retval = renderer->actualDevice->GetMaxTextureSlots( renderer->actualDevice->driverData ); break; case COMMAND_GETMAXMULTISAMPLECOUNT: cmd->getMaxMultiSampleCount.retval = renderer->actualDevice->GetMaxMultiSampleCount( renderer->actualDevice->driverData ); break; case COMMAND_SETSTRINGMARKER: renderer->actualDevice->SetStringMarker( renderer->actualDevice->driverData, cmd->setStringMarker.text ); break; default: FNA3D_LogError("Unknown GLCommand: %X\n", cmd->type); break; } next = cmd->next; SDL_SemPost(cmd->semaphore); cmd = next; } renderer->commands = NULL; SDL_UnlockMutex(renderer->commandsLock); } renderer->actualDevice->DestroyDevice(renderer->actualDevice); return 0; } static inline void ForceToRenderThread( ThreadedGLRenderer *renderer, GLThreadCommand *command ) { GLThreadCommand *curr; command->semaphore = SDL_CreateSemaphore(0); SDL_LockMutex(renderer->commandsLock); LinkedList_Add(renderer->commands, command, curr); SDL_UnlockMutex(renderer->commandsLock); SDL_SemPost(renderer->commandEvent); SDL_SemWait(command->semaphore); SDL_DestroySemaphore(command->semaphore); } /* Quit */ static void THREADEDGL_DestroyDevice(FNA3D_Device *device) { ThreadedGLRenderer* renderer = (ThreadedGLRenderer*) device->driverData; renderer->run = 0; SDL_SemPost(renderer->commandEvent); SDL_WaitThread(renderer->thread, NULL); SDL_DestroyMutex(renderer->commandsLock); SDL_DestroySemaphore(renderer->commandEvent); SDL_free(renderer); SDL_free(device); } /* Begin/End Frame */ static void THREADEDGL_BeginFrame(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_BEGINFRAME; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SwapBuffers( FNA3D_Renderer *driverData, FNA3D_Rect *sourceRectangle, FNA3D_Rect *destinationRectangle, void* overrideWindowHandle ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SWAPBUFFERS; cmd.swapBuffers.sourceRectangle = sourceRectangle; cmd.swapBuffers.destinationRectangle = destinationRectangle; cmd.swapBuffers.overrideWindowHandle = overrideWindowHandle; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetPresentationInterval( FNA3D_Renderer *driverData, FNA3D_PresentInterval presentInterval ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETPRESENTATIONINTERVAL; cmd.setPresentationInterval.presentInterval = presentInterval; ForceToRenderThread(renderer, &cmd); } /* Drawing */ static void THREADEDGL_Clear( FNA3D_Renderer *driverData, FNA3D_ClearOptions options, FNA3D_Vec4 *color, float depth, int32_t stencil ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_CLEAR; cmd.clear.options = options; cmd.clear.color = color; cmd.clear.depth = depth; cmd.clear.stencil = stencil; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_DrawIndexedPrimitives( FNA3D_Renderer *driverData, FNA3D_PrimitiveType primitiveType, int32_t baseVertex, int32_t minVertexIndex, int32_t numVertices, int32_t startIndex, int32_t primitiveCount, FNA3D_Buffer *indices, FNA3D_IndexElementSize indexElementSize ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_DRAWINDEXEDPRIMITIVES; cmd.drawIndexedPrimitives.primitiveType = primitiveType; cmd.drawIndexedPrimitives.baseVertex = baseVertex; cmd.drawIndexedPrimitives.minVertexIndex = minVertexIndex; cmd.drawIndexedPrimitives.numVertices = numVertices; cmd.drawIndexedPrimitives.startIndex = startIndex; cmd.drawIndexedPrimitives.primitiveCount = primitiveCount; cmd.drawIndexedPrimitives.indices = indices; cmd.drawIndexedPrimitives.indexElementSize = indexElementSize; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_DrawInstancedPrimitives( FNA3D_Renderer *driverData, FNA3D_PrimitiveType primitiveType, int32_t baseVertex, int32_t minVertexIndex, int32_t numVertices, int32_t startIndex, int32_t primitiveCount, int32_t instanceCount, FNA3D_Buffer *indices, FNA3D_IndexElementSize indexElementSize ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_DRAWINSTANCEDPRIMITIVES; cmd.drawInstancedPrimitives.primitiveType = primitiveType; cmd.drawInstancedPrimitives.baseVertex = baseVertex; cmd.drawInstancedPrimitives.minVertexIndex = minVertexIndex; cmd.drawInstancedPrimitives.numVertices = numVertices; cmd.drawInstancedPrimitives.startIndex = startIndex; cmd.drawInstancedPrimitives.primitiveCount = primitiveCount; cmd.drawInstancedPrimitives.instanceCount = instanceCount; cmd.drawInstancedPrimitives.indices = indices; cmd.drawInstancedPrimitives.indexElementSize = indexElementSize; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_DrawPrimitives( FNA3D_Renderer *driverData, FNA3D_PrimitiveType primitiveType, int32_t vertexStart, int32_t primitiveCount ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_DRAWPRIMITIVES; cmd.drawPrimitives.primitiveType = primitiveType; cmd.drawPrimitives.vertexStart = vertexStart; cmd.drawPrimitives.primitiveCount = primitiveCount; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_DrawUserIndexedPrimitives( FNA3D_Renderer *driverData, FNA3D_PrimitiveType primitiveType, void* vertexData, int32_t vertexOffset, int32_t numVertices, void* indexData, int32_t indexOffset, FNA3D_IndexElementSize indexElementSize, int32_t primitiveCount ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_DRAWUSERINDEXEDPRIMITIVES; cmd.drawUserIndexedPrimitives.primitiveType = primitiveType; cmd.drawUserIndexedPrimitives.vertexData = vertexData; cmd.drawUserIndexedPrimitives.vertexOffset = vertexOffset; cmd.drawUserIndexedPrimitives.numVertices = numVertices; cmd.drawUserIndexedPrimitives.indexData = indexData; cmd.drawUserIndexedPrimitives.indexOffset = indexOffset; cmd.drawUserIndexedPrimitives.indexElementSize = indexElementSize; cmd.drawUserIndexedPrimitives.primitiveCount = primitiveCount; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_DrawUserPrimitives( FNA3D_Renderer *driverData, FNA3D_PrimitiveType primitiveType, void* vertexData, int32_t vertexOffset, int32_t primitiveCount ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_DRAWUSERPRIMITIVES; cmd.drawUserPrimitives.primitiveType = primitiveType; cmd.drawUserPrimitives.vertexData = vertexData; cmd.drawUserPrimitives.vertexOffset = vertexOffset; cmd.drawUserPrimitives.primitiveCount = primitiveCount; ForceToRenderThread(renderer, &cmd); } /* Mutable Render States */ static void THREADEDGL_SetViewport(FNA3D_Renderer *driverData, FNA3D_Viewport *viewport) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETVIEWPORT; cmd.setViewport.viewport = viewport; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetScissorRect(FNA3D_Renderer *driverData, FNA3D_Rect *scissor) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETSCISSORRECT; cmd.setScissorRect.scissor = scissor; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_GetBlendFactor( FNA3D_Renderer *driverData, FNA3D_Color *blendFactor ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETBLENDFACTOR; cmd.getBlendFactor.blendFactor = blendFactor; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetBlendFactor( FNA3D_Renderer *driverData, FNA3D_Color *blendFactor ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETBLENDFACTOR; cmd.setBlendFactor.blendFactor = blendFactor; ForceToRenderThread(renderer, &cmd); } static int32_t THREADEDGL_GetMultiSampleMask(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETMULTISAMPLEMASK; ForceToRenderThread(renderer, &cmd); return cmd.getMultiSampleMask.retval; } static void THREADEDGL_SetMultiSampleMask(FNA3D_Renderer *driverData, int32_t mask) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETMULTISAMPLEMASK; cmd.setMultiSampleMask.mask = mask; ForceToRenderThread(renderer, &cmd); } static int32_t THREADEDGL_GetReferenceStencil(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETREFERENCESTENCIL; ForceToRenderThread(renderer, &cmd); return cmd.getReferenceStencil.retval; } static void THREADEDGL_SetReferenceStencil(FNA3D_Renderer *driverData, int32_t ref) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETREFERENCESTENCIL; cmd.setReferenceStencil.ref = ref; ForceToRenderThread(renderer, &cmd); } /* Immutable Render States */ static void THREADEDGL_SetBlendState( FNA3D_Renderer *driverData, FNA3D_BlendState *blendState ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETBLENDSTATE; cmd.setBlendState.blendState = blendState; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetDepthStencilState( FNA3D_Renderer *driverData, FNA3D_DepthStencilState *depthStencilState ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETDEPTHSTENCILSTATE; cmd.setDepthStencilState.depthStencilState = depthStencilState; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_ApplyRasterizerState( FNA3D_Renderer *driverData, FNA3D_RasterizerState *rasterizerState ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_APPLYRASTERIZERSTATE; cmd.applyRasterizerState.rasterizerState = rasterizerState; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_VerifySampler( FNA3D_Renderer *driverData, int32_t index, FNA3D_Texture *texture, FNA3D_SamplerState *sampler ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_VERIFYSAMPLER; cmd.verifySampler.index = index; cmd.verifySampler.texture = texture; cmd.verifySampler.sampler = sampler; ForceToRenderThread(renderer, &cmd); } /* Vertex State */ static void THREADEDGL_ApplyVertexBufferBindings( FNA3D_Renderer *driverData, FNA3D_VertexBufferBinding *bindings, int32_t numBindings, uint8_t bindingsUpdated, int32_t baseVertex ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_APPLYVERTEXBUFFERBINDINGS; cmd.applyVertexBufferBindings.bindings = bindings; cmd.applyVertexBufferBindings.numBindings = numBindings; cmd.applyVertexBufferBindings.bindingsUpdated = bindingsUpdated; cmd.applyVertexBufferBindings.baseVertex = baseVertex; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_ApplyVertexDeclaration( FNA3D_Renderer *driverData, FNA3D_VertexDeclaration *vertexDeclaration, void* vertexData, int32_t vertexOffset ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_APPLYVERTEXDECLARATION; cmd.applyVertexDeclaration.vertexDeclaration = vertexDeclaration; cmd.applyVertexDeclaration.vertexData = vertexData; cmd.applyVertexDeclaration.vertexOffset = vertexOffset; ForceToRenderThread(renderer, &cmd); } /* Render Targets */ static void THREADEDGL_SetRenderTargets( FNA3D_Renderer *driverData, FNA3D_RenderTargetBinding *renderTargets, int32_t numRenderTargets, FNA3D_Renderbuffer *depthStencilBuffer, FNA3D_DepthFormat depthFormat ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETRENDERTARGETS; cmd.setRenderTargets.renderTargets = renderTargets; cmd.setRenderTargets.numRenderTargets = numRenderTargets; cmd.setRenderTargets.depthStencilBuffer = depthStencilBuffer; cmd.setRenderTargets.depthFormat = depthFormat; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_ResolveTarget( FNA3D_Renderer *driverData, FNA3D_RenderTargetBinding *target ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_RESOLVETARGET; cmd.resolveTarget.target = target; ForceToRenderThread(renderer, &cmd); } /* Backbuffer Functions */ static void THREADEDGL_ResetBackbuffer( FNA3D_Renderer *driverData, FNA3D_PresentationParameters *presentationParameters ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_RESETBACKBUFFER; cmd.resetBackbuffer.presentationParameters = presentationParameters; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_ReadBackbuffer( FNA3D_Renderer *driverData, int32_t x, int32_t y, int32_t w, int32_t h, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_READBACKBUFFER; cmd.readBackbuffer.x = x; cmd.readBackbuffer.y = y; cmd.readBackbuffer.w = w; cmd.readBackbuffer.h = h; cmd.readBackbuffer.data = data; cmd.readBackbuffer.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_GetBackbufferSize( FNA3D_Renderer *driverData, int32_t *w, int32_t *h ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETBACKBUFFERSIZE; cmd.getBackbufferSize.w = w; cmd.getBackbufferSize.h = h; ForceToRenderThread(renderer, &cmd); } static FNA3D_SurfaceFormat THREADEDGL_GetBackbufferSurfaceFormat( FNA3D_Renderer *driverData ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETBACKBUFFERSURFACEFORMAT; ForceToRenderThread(renderer, &cmd); return cmd.getBackbufferSurfaceFormat.retval; } static FNA3D_DepthFormat THREADEDGL_GetBackbufferDepthFormat( FNA3D_Renderer *driverData ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETBACKBUFFERDEPTHFORMAT; ForceToRenderThread(renderer, &cmd); return cmd.getBackbufferDepthFormat.retval; } static int32_t THREADEDGL_GetBackbufferMultiSampleCount( FNA3D_Renderer *driverData ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETBACKBUFFERMULTISAMPLECOUNT; ForceToRenderThread(renderer, &cmd); return cmd.getBackbufferMultiSampleCount.retval; } /* Textures */ static FNA3D_Texture* THREADEDGL_CreateTexture2D( FNA3D_Renderer *driverData, FNA3D_SurfaceFormat format, int32_t width, int32_t height, int32_t levelCount, uint8_t isRenderTarget ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_CREATETEXTURE2D; cmd.createTexture2D.format = format; cmd.createTexture2D.width = width; cmd.createTexture2D.height = height; cmd.createTexture2D.levelCount = levelCount; cmd.createTexture2D.isRenderTarget = isRenderTarget; ForceToRenderThread(renderer, &cmd); return cmd.createTexture2D.retval; } static FNA3D_Texture* THREADEDGL_CreateTexture3D( FNA3D_Renderer *driverData, FNA3D_SurfaceFormat format, int32_t width, int32_t height, int32_t depth, int32_t levelCount ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_CREATETEXTURE3D; cmd.createTexture3D.format = format; cmd.createTexture3D.width = width; cmd.createTexture3D.height = height; cmd.createTexture3D.depth = depth; cmd.createTexture3D.levelCount = levelCount; ForceToRenderThread(renderer, &cmd); return cmd.createTexture3D.retval; } static FNA3D_Texture* THREADEDGL_CreateTextureCube( FNA3D_Renderer *driverData, FNA3D_SurfaceFormat format, int32_t size, int32_t levelCount, uint8_t isRenderTarget ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_CREATETEXTURECUBE; cmd.createTextureCube.format = format; cmd.createTextureCube.size = size; cmd.createTextureCube.levelCount = levelCount; cmd.createTextureCube.isRenderTarget = isRenderTarget; ForceToRenderThread(renderer, &cmd); return cmd.createTextureCube.retval; } static void THREADEDGL_AddDisposeTexture( FNA3D_Renderer *driverData, FNA3D_Texture *texture ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_ADDDISPOSETEXTURE; cmd.addDisposeTexture.texture = texture; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetTextureData2D( FNA3D_Renderer *driverData, FNA3D_Texture *texture, FNA3D_SurfaceFormat format, int32_t x, int32_t y, int32_t w, int32_t h, int32_t level, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETTEXTUREDATA2D; cmd.setTextureData2D.texture = texture; cmd.setTextureData2D.format = format; cmd.setTextureData2D.x = x; cmd.setTextureData2D.y = y; cmd.setTextureData2D.w = w; cmd.setTextureData2D.h = h; cmd.setTextureData2D.level = level; cmd.setTextureData2D.data = data; cmd.setTextureData2D.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetTextureData3D( FNA3D_Renderer *driverData, FNA3D_Texture *texture, FNA3D_SurfaceFormat format, int32_t x, int32_t y, int32_t z, int32_t w, int32_t h, int32_t d, int32_t level, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETTEXTUREDATA3D; cmd.setTextureData3D.texture = texture; cmd.setTextureData3D.format = format; cmd.setTextureData3D.x = x; cmd.setTextureData3D.y = y; cmd.setTextureData3D.z = z; cmd.setTextureData3D.w = w; cmd.setTextureData3D.h = h; cmd.setTextureData3D.d = d; cmd.setTextureData3D.level = level; cmd.setTextureData3D.data = data; cmd.setTextureData3D.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetTextureDataCube( FNA3D_Renderer *driverData, FNA3D_Texture *texture, FNA3D_SurfaceFormat format, int32_t x, int32_t y, int32_t w, int32_t h, FNA3D_CubeMapFace cubeMapFace, int32_t level, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETTEXTUREDATACUBE; cmd.setTextureDataCube.texture = texture; cmd.setTextureDataCube.format = format; cmd.setTextureDataCube.x = x; cmd.setTextureDataCube.y = y; cmd.setTextureDataCube.w = w; cmd.setTextureDataCube.h = h; cmd.setTextureDataCube.cubeMapFace = cubeMapFace; cmd.setTextureDataCube.level = level; cmd.setTextureDataCube.data = data; cmd.setTextureDataCube.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetTextureDataYUV( FNA3D_Renderer *driverData, FNA3D_Texture *y, FNA3D_Texture *u, FNA3D_Texture *v, int32_t yWidth, int32_t yHeight, int32_t uvWidth, int32_t uvHeight, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETTEXTUREDATAYUV; cmd.setTextureDataYUV.y = y; cmd.setTextureDataYUV.u = u; cmd.setTextureDataYUV.v = v; cmd.setTextureDataYUV.yWidth = yWidth; cmd.setTextureDataYUV.yHeight = yHeight; cmd.setTextureDataYUV.uvWidth = uvWidth; cmd.setTextureDataYUV.uvHeight = uvHeight; cmd.setTextureDataYUV.data = data; cmd.setTextureDataYUV.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_GetTextureData2D( FNA3D_Renderer *driverData, FNA3D_Texture *texture, FNA3D_SurfaceFormat format, int32_t level, int32_t x, int32_t y, int32_t w, int32_t h, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETTEXTUREDATA2D; cmd.getTextureData2D.texture = texture; cmd.getTextureData2D.format = format; cmd.getTextureData2D.x = x; cmd.getTextureData2D.y = y; cmd.getTextureData2D.w = w; cmd.getTextureData2D.h = h; cmd.getTextureData2D.level = level; cmd.getTextureData2D.data = data; cmd.getTextureData2D.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_GetTextureData3D( FNA3D_Renderer *driverData, FNA3D_Texture *texture, FNA3D_SurfaceFormat format, int32_t x, int32_t y, int32_t z, int32_t w, int32_t h, int32_t d, int32_t level, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETTEXTUREDATA3D; cmd.getTextureData3D.texture = texture; cmd.getTextureData3D.format = format; cmd.getTextureData3D.x = x; cmd.getTextureData3D.y = y; cmd.getTextureData3D.z = z; cmd.getTextureData3D.w = w; cmd.getTextureData3D.h = h; cmd.getTextureData3D.d = d; cmd.getTextureData3D.level = level; cmd.getTextureData3D.data = data; cmd.getTextureData3D.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_GetTextureDataCube( FNA3D_Renderer *driverData, FNA3D_Texture *texture, FNA3D_SurfaceFormat format, int32_t x, int32_t y, int32_t w, int32_t h, FNA3D_CubeMapFace cubeMapFace, int32_t level, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETTEXTUREDATACUBE; cmd.getTextureDataCube.texture = texture; cmd.getTextureDataCube.format = format; cmd.getTextureDataCube.cubeMapFace = cubeMapFace; cmd.getTextureDataCube.level = level; cmd.getTextureDataCube.x = x; cmd.getTextureDataCube.y = y; cmd.getTextureDataCube.w = w; cmd.getTextureDataCube.h = h; cmd.getTextureDataCube.data = data; cmd.getTextureDataCube.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } /* Renderbuffers */ static FNA3D_Renderbuffer* THREADEDGL_GenColorRenderbuffer( FNA3D_Renderer *driverData, int32_t width, int32_t height, FNA3D_SurfaceFormat format, int32_t multiSampleCount, FNA3D_Texture *texture ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GENCOLORRENDERBUFFER; cmd.genColorRenderbuffer.width = width; cmd.genColorRenderbuffer.height = height; cmd.genColorRenderbuffer.format = format; cmd.genColorRenderbuffer.multiSampleCount = multiSampleCount; cmd.genColorRenderbuffer.texture = texture; ForceToRenderThread(renderer, &cmd); return cmd.genColorRenderbuffer.retval; } static FNA3D_Renderbuffer* THREADEDGL_GenDepthStencilRenderbuffer( FNA3D_Renderer *driverData, int32_t width, int32_t height, FNA3D_DepthFormat format, int32_t multiSampleCount ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GENDEPTHSTENCILRENDERBUFFER; cmd.genDepthStencilRenderbuffer.width = width; cmd.genDepthStencilRenderbuffer.height = height; cmd.genDepthStencilRenderbuffer.format = format; cmd.genDepthStencilRenderbuffer.multiSampleCount = multiSampleCount; ForceToRenderThread(renderer, &cmd); return cmd.genDepthStencilRenderbuffer.retval; } static void THREADEDGL_AddDisposeRenderbuffer( FNA3D_Renderer *driverData, FNA3D_Renderbuffer *renderbuffer ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_ADDDISPOSERENDERBUFFER; cmd.addDisposeRenderbuffer.renderbuffer = renderbuffer; ForceToRenderThread(renderer, &cmd); } /* Vertex Buffers */ static FNA3D_Buffer* THREADEDGL_GenVertexBuffer( FNA3D_Renderer *driverData, uint8_t dynamic, FNA3D_BufferUsage usage, int32_t vertexCount, int32_t vertexStride ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GENVERTEXBUFFER; cmd.genVertexBuffer.dynamic = dynamic; cmd.genVertexBuffer.usage = usage; cmd.genVertexBuffer.vertexCount = vertexCount; cmd.genVertexBuffer.vertexStride = vertexStride; ForceToRenderThread(renderer, &cmd); return cmd.genVertexBuffer.retval; } static void THREADEDGL_AddDisposeVertexBuffer( FNA3D_Renderer *driverData, FNA3D_Buffer *buffer ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_ADDDISPOSEVERTEXBUFFER; cmd.addDisposeVertexBuffer.buffer = buffer; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetVertexBufferData( FNA3D_Renderer *driverData, FNA3D_Buffer *buffer, int32_t offsetInBytes, void* data, int32_t elementCount, int32_t elementSizeInBytes, int32_t vertexStride, FNA3D_SetDataOptions options ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETVERTEXBUFFERDATA; cmd.setVertexBufferData.buffer = buffer; cmd.setVertexBufferData.offsetInBytes = offsetInBytes; cmd.setVertexBufferData.data = data; cmd.setVertexBufferData.elementCount = elementCount; cmd.setVertexBufferData.elementSizeInBytes = elementSizeInBytes; cmd.setVertexBufferData.vertexStride = vertexStride; cmd.setVertexBufferData.options = options; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_GetVertexBufferData( FNA3D_Renderer *driverData, FNA3D_Buffer *buffer, int32_t offsetInBytes, void* data, int32_t elementCount, int32_t elementSizeInBytes, int32_t vertexStride ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETVERTEXBUFFERDATA; cmd.getVertexBufferData.buffer = buffer; cmd.getVertexBufferData.offsetInBytes = offsetInBytes; cmd.getVertexBufferData.data = data; cmd.getVertexBufferData.elementCount = elementCount; cmd.getVertexBufferData.elementSizeInBytes = elementSizeInBytes; cmd.getVertexBufferData.vertexStride = vertexStride; ForceToRenderThread(renderer, &cmd); } /* Index Buffers */ static FNA3D_Buffer* THREADEDGL_GenIndexBuffer( FNA3D_Renderer *driverData, uint8_t dynamic, FNA3D_BufferUsage usage, int32_t indexCount, FNA3D_IndexElementSize indexElementSize ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GENINDEXBUFFER; cmd.genIndexBuffer.dynamic = dynamic; cmd.genIndexBuffer.usage = usage; cmd.genIndexBuffer.indexCount = indexCount; cmd.genIndexBuffer.indexElementSize = indexElementSize; ForceToRenderThread(renderer, &cmd); return cmd.genIndexBuffer.retval; } static void THREADEDGL_AddDisposeIndexBuffer( FNA3D_Renderer *driverData, FNA3D_Buffer *buffer ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_ADDDISPOSEINDEXBUFFER; cmd.addDisposeIndexBuffer.buffer = buffer; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetIndexBufferData( FNA3D_Renderer *driverData, FNA3D_Buffer *buffer, int32_t offsetInBytes, void* data, int32_t dataLength, FNA3D_SetDataOptions options ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETINDEXBUFFERDATA; cmd.setIndexBufferData.buffer = buffer; cmd.setIndexBufferData.offsetInBytes = offsetInBytes; cmd.setIndexBufferData.data = data; cmd.setIndexBufferData.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_GetIndexBufferData( FNA3D_Renderer *driverData, FNA3D_Buffer *buffer, int32_t offsetInBytes, void* data, int32_t dataLength ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETINDEXBUFFERDATA; cmd.getIndexBufferData.buffer = buffer; cmd.getIndexBufferData.offsetInBytes = offsetInBytes; cmd.getIndexBufferData.data = data; cmd.getIndexBufferData.dataLength = dataLength; ForceToRenderThread(renderer, &cmd); } /* Effects */ static void THREADEDGL_CreateEffect( FNA3D_Renderer *driverData, uint8_t *effectCode, uint32_t effectCodeLength, FNA3D_Effect **effect, MOJOSHADER_effect **effectData ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_CREATEEFFECT; cmd.createEffect.effectCode = effectCode; cmd.createEffect.effectCodeLength = effectCodeLength; cmd.createEffect.effect = effect; cmd.createEffect.effectData = effectData; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_CloneEffect( FNA3D_Renderer *driverData, FNA3D_Effect *cloneSource, FNA3D_Effect **effect, MOJOSHADER_effect **effectData ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_CLONEEFFECT; cmd.cloneEffect.cloneSource = cloneSource; cmd.cloneEffect.effect = effect; cmd.cloneEffect.effectData = effectData; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_AddDisposeEffect( FNA3D_Renderer *driverData, FNA3D_Effect *effect ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_ADDDISPOSEEFFECT; cmd.addDisposeEffect.effect = effect; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_SetEffectTechnique( FNA3D_Renderer *driverData, FNA3D_Effect *effect, MOJOSHADER_effectTechnique *technique ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETEFFECTTECHNIQUE; cmd.setEffectTechnique.effect = effect; cmd.setEffectTechnique.technique = technique; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_ApplyEffect( FNA3D_Renderer *driverData, FNA3D_Effect *effect, uint32_t pass, MOJOSHADER_effectStateChanges *stateChanges ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_APPLYEFFECT; cmd.applyEffect.effect = effect; cmd.applyEffect.pass = pass; cmd.applyEffect.stateChanges = stateChanges; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_BeginPassRestore( FNA3D_Renderer *driverData, FNA3D_Effect *effect, MOJOSHADER_effectStateChanges *stateChanges ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_BEGINPASSRESTORE; cmd.beginPassRestore.effect = effect; cmd.beginPassRestore.stateChanges = stateChanges; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_EndPassRestore( FNA3D_Renderer *driverData, FNA3D_Effect *effect ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_ENDPASSRESTORE; cmd.endPassRestore.effect = effect; ForceToRenderThread(renderer, &cmd); } /* Queries */ static FNA3D_Query* THREADEDGL_CreateQuery(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_CREATEQUERY; ForceToRenderThread(renderer, &cmd); return cmd.createQuery.retval; } static void THREADEDGL_AddDisposeQuery( FNA3D_Renderer *driverData, FNA3D_Query *query ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_ADDDISPOSEQUERY; cmd.addDisposeQuery.query = query; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_QueryBegin(FNA3D_Renderer *driverData, FNA3D_Query *query) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_QUERYBEGIN; cmd.queryBegin.query = query; ForceToRenderThread(renderer, &cmd); } static void THREADEDGL_QueryEnd(FNA3D_Renderer *driverData, FNA3D_Query *query) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_QUERYEND; cmd.queryEnd.query = query; ForceToRenderThread(renderer, &cmd); } static uint8_t THREADEDGL_QueryComplete( FNA3D_Renderer *driverData, FNA3D_Query *query ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_QUERYCOMPLETE; cmd.queryComplete.query = query; ForceToRenderThread(renderer, &cmd); return cmd.queryComplete.retval; } static int32_t THREADEDGL_QueryPixelCount( FNA3D_Renderer *driverData, FNA3D_Query *query ) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_QUERYPIXELCOUNT; cmd.queryPixelCount.query = query; ForceToRenderThread(renderer, &cmd); return cmd.queryPixelCount.retval; } /* Feature Queries */ static uint8_t THREADEDGL_SupportsDXT1(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SUPPORTSDXT1; ForceToRenderThread(renderer, &cmd); return cmd.supportsDXT1.retval; } static uint8_t THREADEDGL_SupportsS3TC(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SUPPORTSS3TC; ForceToRenderThread(renderer, &cmd); return cmd.supportsS3TC.retval; } static uint8_t THREADEDGL_SupportsHardwareInstancing(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SUPPORTSHARDWAREINSTANCING; ForceToRenderThread(renderer, &cmd); return cmd.supportsHardwareInstancing.retval; } static uint8_t THREADEDGL_SupportsNoOverwrite(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SUPPORTSNOOVERWRITE; ForceToRenderThread(renderer, &cmd); return cmd.supportsNoOverwrite.retval; } static int32_t THREADEDGL_GetMaxTextureSlots(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETMAXTEXTURESLOTS; ForceToRenderThread(renderer, &cmd); return cmd.getMaxTextureSlots.retval; } static int32_t THREADEDGL_GetMaxMultiSampleCount(FNA3D_Renderer *driverData) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_GETMAXMULTISAMPLECOUNT; ForceToRenderThread(renderer, &cmd); return cmd.getMaxMultiSampleCount.retval; } /* Debugging */ static void THREADEDGL_SetStringMarker(FNA3D_Renderer *driverData, const char *text) { GLThreadCommand cmd; ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) driverData; cmd.type = COMMAND_SETSTRINGMARKER; cmd.setStringMarker.text = text; ForceToRenderThread(renderer, &cmd); } /* Driver */ static uint8_t THREADEDGL_PrepareWindowAttributes(uint32_t *flags) { return ModernGLDriver.PrepareWindowAttributes(flags); } static void THREADEDGL_GetDrawableSize(void* window, int32_t *x, int32_t *y) { ModernGLDriver.GetDrawableSize(window, x, y); } static FNA3D_Device* THREADEDGL_CreateDevice( FNA3D_PresentationParameters *presentationParameters, uint8_t debugMode ) { FNA3D_Device *result; GLThreadCommand cmd; /* Initialize the Renderer first... */ ThreadedGLRenderer *renderer = (ThreadedGLRenderer*) SDL_malloc( sizeof(ThreadedGLRenderer) ); renderer->run = 1; renderer->commands = NULL; renderer->commandsLock = SDL_CreateMutex(); renderer->commandEvent = SDL_CreateSemaphore(0); /* Then allocate the end user's device... */ result = (FNA3D_Device*) SDL_malloc(sizeof(FNA3D_Device)); result->driverData = (FNA3D_Renderer*) renderer; ASSIGN_DRIVER(THREADEDGL) FNA3D_LogInfo("Using ThreadedGL!"); /* ... then start the thread, finally. */ renderer->thread = SDL_CreateThread( GLRenderThread, "GLRenderThread", renderer ); /* The first command is always device creation! */ cmd.type = COMMAND_CREATEDEVICE; cmd.createDevice.presentationParameters = presentationParameters; cmd.createDevice.debugMode = debugMode; ForceToRenderThread(renderer, &cmd); return result; } FNA3D_Driver ThreadedGLDriver = { "ThreadedGL", THREADEDGL_PrepareWindowAttributes, THREADEDGL_GetDrawableSize, THREADEDGL_CreateDevice }; #else extern int this_tu_is_empty; #endif /* FNA3D_DRIVER_THREADEDGL */ /* vim: set noexpandtab shiftwidth=8 tabstop=8: */
27.489092
102
0.773131
[ "render", "3d" ]
c6d1dea29f1fa212fbbabcdfac894ad51d7b21af
2,310
h
C
src/widgets/qtabbar.h
sandsmark/qt1
e62eef42291be80065a7f824530aa42b79917a8d
[ "Xnet", "X11" ]
18
2018-02-16T16:57:26.000Z
2022-02-10T21:23:47.000Z
src/widgets/qtabbar.h
sandsmark/qt1
e62eef42291be80065a7f824530aa42b79917a8d
[ "Xnet", "X11" ]
2
2018-08-12T12:46:38.000Z
2020-06-19T16:30:06.000Z
src/widgets/qtabbar.h
sandsmark/qt1
e62eef42291be80065a7f824530aa42b79917a8d
[ "Xnet", "X11" ]
7
2018-06-22T01:17:58.000Z
2021-09-02T21:05:28.000Z
/**************************************************************************** ** $Id: qtabbar.h,v 2.12.2.2 1998/09/03 20:14:48 hanord Exp $ ** ** Definition of QTabBar class ** ** Copyright (C) 1992-1999 Troll Tech AS. All rights reserved. ** ** This file is part of Qt Free Edition, version 1.45. ** ** See the file LICENSE included in the distribution for the usage ** and distribution terms, or http://www.troll.no/free-license.html. ** ** IMPORTANT NOTE: You may NOT copy this file or any part of it into ** your own programs or libraries. ** ** Please see http://www.troll.no/pricing.html for information about ** Qt Professional Edition, which is this same library but with a ** license which allows creation of commercial/proprietary software. ** *****************************************************************************/ #ifndef QTABBAR_H #define QTABBAR_H #ifndef QT_H #include "qwidget.h" #include "qpainter.h" #include "qlist.h" #endif // QT_H struct QTabPrivate; struct Q_EXPORT QTab { QTab(): enabled( TRUE ), id( 0 ) {} virtual ~QTab(); QString label; // the bounding rectangle of this - may overlap with others QRect r; bool enabled; int id; }; class Q_EXPORT QTabBar: public QWidget { Q_OBJECT public: QTabBar( QWidget * parent = 0, const char * name = 0 ); ~QTabBar(); enum Shape { RoundedAbove, RoundedBelow, TriangularAbove, TriangularBelow }; Shape shape() const; void setShape( Shape ); void show(); virtual int addTab( QTab * ); void setTabEnabled( int, bool ); bool isTabEnabled( int ) const; QSize sizeHint() const; int currentTab() const; int keyboardFocusTab() const; QTab * tab( int ); public slots: void setCurrentTab( int ); void setCurrentTab( QTab * ); signals: void selected( int ); protected: virtual void paint( QPainter *, QTab *, bool ) const; virtual QTab * selectTab( const QPoint & p ) const; void paintEvent( QPaintEvent * ); void mousePressEvent ( QMouseEvent * ); void mouseReleaseEvent ( QMouseEvent * ); void keyPressEvent( QKeyEvent * ); QListT<QTab> * tabList(); private: QListT<QTab> * l; QTabPrivate * d; void paintLabel( QPainter*, const QRect&, QTab*, bool ) const; }; #endif // QTABBAR_H
22.647059
78
0.620346
[ "shape" ]
0b40fcd8a9e8be30023ba2326fbe27aa9b2030a3
4,682
h
C
include/blons/graphics/pipeline/stage/shadow.h
tedle/blonstech
f5a221d1e08b408ccffcaee7f982ba00b497f4e0
[ "MIT" ]
3
2020-09-06T15:33:00.000Z
2021-06-28T08:37:14.000Z
include/blons/graphics/pipeline/stage/shadow.h
tedle/blonstech
f5a221d1e08b408ccffcaee7f982ba00b497f4e0
[ "MIT" ]
null
null
null
include/blons/graphics/pipeline/stage/shadow.h
tedle/blonstech
f5a221d1e08b408ccffcaee7f982ba00b497f4e0
[ "MIT" ]
1
2021-06-28T08:37:17.000Z
2021-06-28T08:37:17.000Z
//////////////////////////////////////////////////////////////////////////////// // blonstech // Copyright(c) 2017 Dominic Bowden // // 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. //////////////////////////////////////////////////////////////////////////////// #ifndef BLONSTECH_GRAPHICS_PIPELINE_STAGE_SHADOW_H_ #define BLONSTECH_GRAPHICS_PIPELINE_STAGE_SHADOW_H_ // Public Includes #include <blons/graphics/pipeline/scene.h> #include <blons/graphics/pipeline/stage/geometry.h> #include <blons/graphics/framebuffer.h> #include <blons/graphics/render/shader.h> namespace blons { namespace pipeline { namespace stage { //////////////////////////////////////////////////////////////////////////////// /// \brief Calculates cascading shadow maps and applys them to a scene //////////////////////////////////////////////////////////////////////////////// class Shadow { public: //////////////////////////////////////////////////////////////////////////////// /// \brief Used to specify which output of the stage to retrieve //////////////////////////////////////////////////////////////////////////////// enum Output { LIGHT_DEPTH, ///< 16-bit depth in the red channel and 16-bit depth squared in the green channel DIRECT_LIGHT ///< R8G8B8 direct lighting. Only provides light visibility mask }; public: //////////////////////////////////////////////////////////////////////////////// /// \brief Initializes a new Shadow stage /// /// \param perspective Screen dimensions and perspective information //////////////////////////////////////////////////////////////////////////////// Shadow(Perspective perspective); ~Shadow() {} //////////////////////////////////////////////////////////////////////////////// /// \brief Renders out the shadow map targets /// /// \param scene Contains scene information for rendering /// \param geometry Handle to the geometry buffer pass performed earlier in the /// frame /// \param view_matrix View matrix of the camera rendering the scene /// \param proj_matrix Perspective matrix for rendering the scene /// \param light_vp_matrix View projection matrix of the directional light /// providing shadow /// \param ortho_matrix Orthographic matrix bound to the screen dimensions //////////////////////////////////////////////////////////////////////////////// bool Render(const Scene& scene, const Geometry& geometry, Matrix view_matrix, Matrix proj_matrix, Matrix light_vp_matrix, Matrix ortho_matrix); //////////////////////////////////////////////////////////////////////////////// /// \brief Retrieves the rendering output from the pipeline stage /// /// \param buffer Shadow::Output target to retrieve /// \return Handle to the output target texture //////////////////////////////////////////////////////////////////////////////// const TextureResource* output(Output buffer) const; private: Matrix shadow_map_ortho_matrix_; std::unique_ptr<Shader> blur_shader_; std::unique_ptr<Shader> direct_light_shader_; std::unique_ptr<Shader> shadow_shader_; std::unique_ptr<Framebuffer> blur_buffer_; std::unique_ptr<Framebuffer> direct_light_buffer_; std::unique_ptr<Framebuffer> shadow_buffer_; }; } // namespace stage } // namespace pipeline } // namespace blons //////////////////////////////////////////////////////////////////////////////// /// \class blons::pipeline::stage::Shadow /// \ingroup pipeline //////////////////////////////////////////////////////////////////////////////// #endif // BLONSTECH_GRAPHICS_PIPELINE_STAGE_SHADOW_H_
45.019231
147
0.561939
[ "geometry", "render" ]
0b4131823b0cbf8225dd101bb0359efa0aeec0bc
3,238
h
C
ExePrj/src/Core/Window.h
BEASTSM96/Win-64-Base-Template
120e6710cf095ee18736c4acb0368a843ec490e9
[ "MIT" ]
1
2020-08-15T08:05:26.000Z
2020-08-15T08:05:26.000Z
ExePrj/src/Core/Window.h
BEASTSM96/Win-64-Base-Template
120e6710cf095ee18736c4acb0368a843ec490e9
[ "MIT" ]
null
null
null
ExePrj/src/Core/Window.h
BEASTSM96/Win-64-Base-Template
120e6710cf095ee18736c4acb0368a843ec490e9
[ "MIT" ]
null
null
null
/******************************************************************************************** * * * * * * * MIT License * * * * Copyright (c) 2021 BEAST * * * * 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 #include "Base.h" #include <string> #include <cstring> struct GLFWwindow; // Main Window class class Window { SINGLETON( Window ); Window(); ~Window(); public: void Refresh(); void Maximize(); void Minimize(); void Restore(); void SetTitle( const std::string& title ); void Render(); void* NativeWindow() const { return m_Window; } int Width() { return m_Width; } int Height() { return m_Height; } bool ShouldClose() { return m_PendingClose; } private: GLFWwindow* m_Window = nullptr; int m_Height = 720; int m_Width = 1200; std::string m_Title = "Win64-Base-Template"; bool m_Minimized = false; bool m_Maximized = false; bool m_Rendering = false; bool m_PendingClose = false; static void SizeCallback( GLFWwindow* wind, int h, int w ); };
39.975309
93
0.432366
[ "render" ]
0b41a76434ec298a349573e77bc75da4ecc095d1
474
h
C
AbstractMachine.h
donbrowne/brainfuck
bbacc85752a369c917666507c80b286538bee8ca
[ "Unlicense" ]
2
2015-06-17T13:10:51.000Z
2015-06-17T13:12:26.000Z
AbstractMachine.h
donbrowne/brainfuck
bbacc85752a369c917666507c80b286538bee8ca
[ "Unlicense" ]
null
null
null
AbstractMachine.h
donbrowne/brainfuck
bbacc85752a369c917666507c80b286538bee8ca
[ "Unlicense" ]
null
null
null
// // Created by Don Browne on 14/06/15. // #ifndef BF_STATE_H #define BF_STATE_H #include <memory> #include <vector> class AbstractMachine { private: std::unique_ptr<std::vector<unsigned char> > tape; size_t index; size_t size; public: AbstractMachine(size_t tape_length); ~AbstractMachine() {}; void next(); void prev(); void write(unsigned char val); unsigned char read(); void incr(); void decr(); }; #endif //BF_STATE_H
16.344828
54
0.654008
[ "vector" ]
0b4a6035f4b93ea9b1168243cdd0a19bc42be8a7
10,682
c
C
c++/libosc/oscdb.c
jessica-severin/ZENBU_2.11.1
694dd8fb178f3cbde2e058b8ee6a57e5a4c09cc7
[ "Unlicense" ]
null
null
null
c++/libosc/oscdb.c
jessica-severin/ZENBU_2.11.1
694dd8fb178f3cbde2e058b8ee6a57e5a4c09cc7
[ "Unlicense" ]
null
null
null
c++/libosc/oscdb.c
jessica-severin/ZENBU_2.11.1
694dd8fb178f3cbde2e058b8ee6a57e5a4c09cc7
[ "Unlicense" ]
null
null
null
#include <fcntl.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #include <string.h> #include <zlib.h> #include <sys/types.h> #include <sys/mman.h> #include <oscdb.h> /************************************* * internal prototypes *************************************/ osc_object_t* oscdb_parse_obj_line(oscdb_t* self, char* line, int line_len); void oscdb_mmap_idx(oscdb_t *self); /************************************* * now all the subroutines *************************************/ oscdb_t* oscdb_new(void) { oscdb_t *self; self = (oscdb_t*) malloc(sizeof(oscdb_t)); bzero(self, sizeof(oscdb_t)); self->max_lines = -1; self->debug = 0; self->startclock = clock(); self->idx_fildes = 0; return self; } void oscdb_init(oscdb_t *self, char* infile) { int readCount; self->file_path = infile; if(self->buffer == NULL) { self->buffer = (char*)malloc(BUFSIZE); self->readbuf = (char*)malloc(READ_BUF_SIZE); } bzero(self->buffer, BUFSIZE); if(self->data_fildes == 0) { self->data_fildes = open(self->file_path, O_RDONLY, 0x755); } // //prefill the buffers and get ready for processing // readCount = read(self->data_fildes, self->readbuf, READ_BUF_SIZE); self->buffer[0] = '\0'; strncat(self->buffer, self->readbuf, readCount); //printf("new buffer length : %d\n", strlen(buffer)); self->bufptr = self->buffer; self->bufend = self->buffer + strlen(self->buffer); /* points at the \0 added by strncat()*/ self->seek_pos = 0; self->next_obj_id = 1; //object ids start at 1 } /** * read the 'expression' file generated by the obj extraction process ***/ void oscdb_build_index(oscdb_t *self) { int readCount; FILE *fp_idx = NULL; long long byteCount=0, bufferCount=0, seek_pos; double runtime, rate; double mbytes; char *bufptr, *bufptr2, *bufend; int objcount = 1; char outpath[1024]; //time_t start_t = time(NULL); //makes sure everthing is initialized correctly lseek(self->data_fildes, 0, SEEK_SET); bzero(self->buffer, BUFSIZE); sprintf(outpath, "%s.eeidx", self->file_path); fp_idx = fopen(outpath, "w"); printf("long : %lu bytes\n", sizeof(bufferCount)); while(1) { readCount = read(self->data_fildes, self->readbuf, READ_BUF_SIZE); if(readCount<=0) { break; } bufferCount++; strncat(self->buffer, self->readbuf, readCount); //printf("new buffer length : %d\n", (int)strlen(self->buffer)); bufptr = self->buffer; bufptr2 = self->buffer; bufend = self->buffer + strlen(self->buffer); /* points at the \0 added by strncat()*/ while(bufptr2 < bufend) { while((bufptr2 < bufend) && (*bufptr2 != '\0') && (*bufptr2 != '\n')) { bufptr2++; } if(*bufptr2 == '\n') { *bufptr2 = '\0'; seek_pos = byteCount + (bufptr - self->buffer); //fprintf(fp_out, "%s\n", bufptr); //fprintf(fp_out, "%s\n", bufptr); if((*bufptr!='#')&&(*bufptr!='>')) { fwrite(&seek_pos, sizeof(seek_pos), 1, fp_idx); if(self->debug > 1) { printf("object %d => %lld offset :: %s \n", objcount, seek_pos, bufptr); } objcount++; } bufptr2 = bufptr2+1; bufptr = bufptr2; } } //bottom of the while(bufptr2<bufend){} loop //update the bytecount since we are done with this buffer //printf("end of buffer\nstarting byteCount:%lld, readCount:%d, bufend:%d, bufptr:%d\n", byteCount, readCount, (bufend-buffer), (bufptr-buffer)); byteCount = byteCount + (bufptr - self->buffer); if(bufferCount % 1000 == 0) { printf(" read %1.3f Mbytes\t%d objs\n", ((double)(byteCount))/(1024.0*1024.0), objcount); } /* not an end of line means we ran off the buffer so we need to shift the rest of the buffer to the beginning and break out to read more of the file */ strcpy(self->buffer, bufptr); //the end over, very efficient } //end of the while(1) loop lseek(self->data_fildes, 0, SEEK_SET); fclose(fp_idx); mbytes = ((double)(byteCount))/(1024.0*1024.0); runtime = (double)(clock() - self->startclock) / CLOCKS_PER_SEC; //runtime = (double)(time(NULL) - start_t); rate = objcount/runtime; printf("just read %d objects\n", objcount); printf("just read %1.3f Mbytes\n", mbytes); printf(" %1.3f secs\n", (float)runtime); if(rate>1000000.0) { printf(" %1.3f mega objs/sec\n", rate/1000000.0); } else if(rate>2000.0) { printf(" %1.3f kilo objs/sec\n", rate/1000.0); } else { printf(" %1.3f objs/sec\n", rate); } printf(" %1.3f mbytes/sec\n", mbytes/runtime); } void oscdb_mmap_idx(oscdb_t *self) { off_t idx_len; char outpath[1024]; void *mmap_addr; if(self->data_fildes == 0) { self->data_fildes = open(self->file_path, O_RDONLY, 0x755); } if(self->idx_fildes == 0) { sprintf(outpath, "%s.eeidx", self->file_path); self->idx_fildes = open(outpath, O_RDONLY, 0x755); } idx_len = lseek(self->idx_fildes, 0, SEEK_END); if(self->debug) { printf("index file %lld bytes long\n", (long long)idx_len); } lseek(self->idx_fildes, 0, SEEK_SET); mmap_addr = mmap(NULL, idx_len, PROT_READ, MAP_PRIVATE, self->idx_fildes, 0); self->idx_mmap = mmap_addr; self->max_id = (idx_len / sizeof(long long)); if(self->debug) { printf("index file max ID: %lld\n", (long long)self->max_id); } } /************************************************************* * * object access methods * *************************************************************/ /** * read the next object in the stream, probably already in the buffers ***/ osc_object_t* oscdb_next_object(oscdb_t *self) { int readCount, line_len; char *bufptr2; osc_object_t *obj = NULL; bufptr2 = self->bufptr; while(1) { while(bufptr2 < self->bufend) { while((bufptr2 < self->bufend) && (*bufptr2 != '\0') && (*bufptr2 != '\n')) { bufptr2++; } if(*bufptr2 == '\n') { *bufptr2 = '\0'; //fprintf(fp_out, "%s\n", bufptr); // // do things with the line buffer here // //printf("LINE %7lld : %10lld offset :: %s \n", self->next_obj_id, self->seek_pos, self->bufptr); line_len = (bufptr2 - self->bufptr) + 1; obj = oscdb_parse_obj_line(self, self->bufptr, line_len); self->seek_pos = self->seek_pos + line_len; self->bufptr = bufptr2+1; bufptr2 = bufptr2+1; if(obj) { //if(self->debug) { eedb_print_tag(self, obj); } return obj; } } } //bottom of the while(bufptr2<bufend){} loop /* we ran off the self->buffer so we need to shift the rest of the buffer to the beginning and then read more of the file */ strcpy(self->buffer, self->bufptr); //the end over with \0 char, very efficient readCount = read(self->data_fildes, self->readbuf, READ_BUF_SIZE); if(readCount<=0) { return NULL; } strncat(self->buffer, self->readbuf, readCount); //printf("new buffer length : %d\n", (int)strlen(self->buffer)); self->bufptr = self->buffer; bufptr2 = self->bufptr; self->bufend = self->buffer + strlen(self->buffer); /* points at the \0 added by strncat()*/ } return NULL; } /** * random access an object in the stream. * always does a seek and refills the buffers * before generating the object ***/ osc_object_t* oscdb_access_object(oscdb_t *self, long long id) { ssize_t readCount, line_len; char *bufptr2; osc_object_t *obj = NULL; if(self->idx_fildes == 0) { oscdb_mmap_idx(self); } if((id < 1) || (id > self->max_id)) { return NULL; } // // ok now the seek magick, got to love memory-mapped binary files // self->next_obj_id = id; self->seek_pos = self->idx_mmap[id-1]; if(self->debug>1) { printf("OBJECT %7lld : %10lld offset\n", id, self->seek_pos); } lseek(self->data_fildes, self->seek_pos, SEEK_SET); // // and now prepare the buffers // readCount = read(self->data_fildes, self->readbuf, 2048); self->buffer[0] = '\0'; strncat(self->buffer, self->readbuf, readCount); //printf("new buffer length : %d\n", strlen(buffer)); self->bufptr = self->buffer; self->bufend = self->buffer + strlen(self->buffer); /* points at the \0 added by strncat()*/ bufptr2 = self->buffer; while((bufptr2 < self->bufend) && (*bufptr2 != '\0') && (*bufptr2 != '\n')) { bufptr2++; } if(*bufptr2 == '\n') { *bufptr2 = '\0'; if(self->debug>1) { printf("LINE %7lld : %10lld offset :: %s \n", id, self->seek_pos, self->bufptr); } line_len = (bufptr2 - self->bufptr) + 1; obj = oscdb_parse_obj_line(self, self->bufptr, line_len); self->seek_pos = self->seek_pos + line_len; self->bufptr = bufptr2+1; } return obj; } /************************************************************* * * osc_object_t section: super class of all objects in the system * **************************************************************/ osc_object_t* oscdb_parse_obj_line(oscdb_t* self, char* line, int line_len) { osc_object_t *obj = NULL; char *ptr, *p1; int col=0; if(*line =='#') { return NULL; } if(*line =='>') { return NULL; } obj = (osc_object_t*)malloc(sizeof(osc_object_t)); bzero(obj, sizeof(*obj)); obj->id = self->next_obj_id++; obj->offset = self->seek_pos; obj->oscdb = self; obj->line_buffer =(char*)malloc(line_len+1); strcpy(obj->line_buffer, line); //segment the line into columns ptr = obj->line_buffer; p1 = ptr; obj->columns[col++] = p1; while(*ptr != '\0') { if(*ptr == '\t') { *ptr = '\0'; ptr++; p1 = ptr; obj->columns[col++] = p1; } else { ptr++; } } return obj; } /************************************* * * osc_object section * *************************************/ void osc_object_delete(osc_object_t *obj) { void *line; if(obj==NULL) { return; } line = obj->line_buffer; obj->line_buffer = NULL; free(line); free(obj); } void osc_object_parse_columns(osc_object_t *self) { } void osc_object_print(osc_object_t *self) { char *str; if(self == NULL) { return; } //printf("FEATURE(%lld) %s\n", ((osc_object_t*)self)->id, ((osc_object_t*)self)->line_buffer); str = osc_object_display_desc(self); printf("%s\n", str); free(str); } char* osc_object_display_desc(osc_object_t *self) { char *str = (char*)malloc(2048); snprintf(str, 2040, "OBJ(%15lld) [off:%15lld] %s", self->id, self->offset, self->line_buffer); return str; }
28.715054
150
0.581258
[ "object" ]
0b51f064f57191a27e90c3fadbdced565f4276cf
5,800
h
C
shared/SITordoff.h
TinyTheBrontosaurus/ScaleInvariantPtz
4b6975874e7f2995106b181baa84cbec2111ba89
[ "MIT" ]
null
null
null
shared/SITordoff.h
TinyTheBrontosaurus/ScaleInvariantPtz
4b6975874e7f2995106b181baa84cbec2111ba89
[ "MIT" ]
null
null
null
shared/SITordoff.h
TinyTheBrontosaurus/ScaleInvariantPtz
4b6975874e7f2995106b181baa84cbec2111ba89
[ "MIT" ]
null
null
null
#ifndef SITORDOFF_H #define SITORDOFF_H #include "types.h" #include "SIKalman.h" /************************************************************** * * SITordoff class * Description: Implements Kalman filter and other algorithms described * in Chapter 6 of Benjamin Tordoff's PhD dissertation. ************************************************************** */ class SITordoff { public: /****************************************** * ctor * Description: Sets defaults for all options. ****************************************** */ SITordoff(); /****************************************** * dtor ****************************************** */ ~SITordoff(); /****************************************** * init * Description: Initializes the class. ****************************************** */ void init(); /****************************************** * init * Description: Initializes the class. * Parameters: processNoise - The magnitude of the measurement noise * measurementNoise - The magnitude of the measurement noise * stateCovariance - The initial value of the state covariance ****************************************** */ void init( FLOAT processNoise, FLOAT measurementNoise, FLOAT myPsi, FLOAT myGamma1, FLOAT myGamma2, Matrix &stateCovariance); void init( FLOAT processNoise, FLOAT measurementNoise, FLOAT myPsi, FLOAT myGamma1, FLOAT myGamma2); /****************************************** * setMeasurement * Description: Registers a measurement corresponding to a frame. * Parameters: x - The error in of the object in the image in the * x-direction. -0.5 is the left edge, 0.5 is the * right edge. * controlX - The control input in the X-direction * y - The error in of the object in the image in the * y-direction. -0.5 is the top edge, 0.5 is the * bottom edge. * controlY - The control input in the Y-direction * zoom - The zoom magnification at the time * of measurement ****************************************** */ void setMeasurement(FLOAT x, FLOAT controlX, FLOAT y, FLOAT controlY, FLOAT zoom); /****************************************** * getCommands * Description: Retrieves the commands to be sent to the camera. * Parameters: x - The error in of the object in the image in the * x-direction. -0.5 is the left edge, 0.5 is the * right edge. * y - The error in of the object in the image in the * y-direction. -0.5 is the top edge, 0.5 is the * bottom edge. * zoom - The desired zoom magnification ********************************************************** */ void getCommands(FLOAT &pan, FLOAT &tilt, FLOAT &zoom, BOOL errOnZoomIn); protected: private: /****************************************** * chooseZoom * Description: Choose the next zoom magnification (Tordoff 150) * Returns: The desired focal length for the next iteration ****************************************** */ FLOAT chooseZoom(BOOL errOnZoomIn); /****************************************** * get2NormCovarianceSquared * Description: Get the squared 2-norm of the covariance (Tordoff 152) * Parameters: lastCov - The value of the covariance last iteration * gamma - The gamma value for calculation * newCov - The newly calculated covariance * eigValSquared - The 2-norm of the covariance squared * Returns: The squared 2-norm of the covariance of nu_k ****************************************** */ void get2NormCovarianceSquared( Matrix lastCov, FLOAT gamma, Matrix &newCov, FLOAT &normSquared ); private: //Keep track of the pan and tilt states and measurements SIKalman kfPan; SIKalman kfTilt; //Count the number of iterations corresponding to when setMeasrement is called UINT32 iteration; //The current zoom value FLOAT curZoom; //The values of nu for pan and tilt Matrix nu_k; //Different values for focal length selection FLOAT gamma1; FLOAT gamma2; FLOAT psi; //The covariance of nu in the previous iteration for various values //of gamma Matrix lastGamma1Cov; Matrix lastGamma2Cov; }; #endif // File: $Id: SITordoff.h,v 1.7 2005/09/07 18:44:04 edn2065 Exp $ // Author: Eric D Nelson // Revisions: // $Log: SITordoff.h,v $ // Revision 1.7 2005/09/07 18:44:04 edn2065 // Added options to make zoom more aggressive // // Revision 1.6 2005/08/05 22:09:40 edn2065 // Moved kalman functionality into SIKalman // // Revision 1.5 2005/08/03 02:34:54 edn2065 // Added tordoff psi and gammas to menu // // Revision 1.4 2005/08/03 01:43:26 edn2065 // Implemented focal length selection // // Revision 1.3 2005/07/29 00:11:14 edn2065 // Added menu options for Kalman filter and fixation gains // // Revision 1.2 2005/07/28 01:42:18 edn2065 // Made it so fixation was only calculated when p/t/z values were available // // Revision 1.1 2005/07/28 00:22:24 edn2065 // Added SITordoff to repository //
35.802469
87
0.498966
[ "object" ]
0b599ec3ccc80a49cd57f8d8cf922c6686a973d8
2,803
h
C
tensorflow/compiler/tf2xla/kernels/gpu_tf_kernel_custom_call.h
Stevanus-Christian/tensorflow
d44afcf5ca16c5d704c66f891b99eac804e7cd14
[ "Apache-2.0" ]
2
2016-09-27T05:37:33.000Z
2019-11-22T06:41:12.000Z
tensorflow/compiler/tf2xla/kernels/gpu_tf_kernel_custom_call.h
Stevanus-Christian/tensorflow
d44afcf5ca16c5d704c66f891b99eac804e7cd14
[ "Apache-2.0" ]
null
null
null
tensorflow/compiler/tf2xla/kernels/gpu_tf_kernel_custom_call.h
Stevanus-Christian/tensorflow
d44afcf5ca16c5d704c66f891b99eac804e7cd14
[ "Apache-2.0" ]
null
null
null
/* Copyright 2022 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_COMPILER_TF2XLA_KERNELS_GPU_TF_KERNEL_CUSTOM_CALL_H_ #define TENSORFLOW_COMPILER_TF2XLA_KERNELS_GPU_TF_KERNEL_CUSTOM_CALL_H_ #include <functional> #include "tensorflow/compiler/tf2xla/xla_op_kernel.h" #include "tensorflow/core/platform/status.h" namespace tensorflow { // Using std::map as the maps are presumed to be tiny, and we want a // deterministic iteration order. // // Dimension -> bound. using DimensionBoundsMap = std::map<int, int>; // Output -> dimension -> bound. using OutputDimensionBoundsMap = std::map<int, DimensionBoundsMap>; // Using XLA builder wrapped in XlaOpKernelContext to emit a custom call which // will call a TF kernel associated with `node_def`. // // Works only on GPU where the control is always on the host. // TODO(cheshire): Extend to work on CPU as well. Status CompileToCustomCallCallingTfKernel(int graph_def_version, const NodeDef& node_def, XlaOpKernelContext* ctx); // Generic kernel for registering TF2XLA kernels which call back into the TF // runtime to run a given kernel defined by the wrapped node. // // Cf. example usages in light_outside_compilation_kernels_for_test.cc. // // Currently does not support dynamic shape or resource variables. Currently // works only on GPU. class CallTfKernelOp : public XlaOpKernel { public: explicit CallTfKernelOp(OpKernelConstruction* context); void Compile(XlaOpKernelContext* ctx) override; // Override to provide statically known bounds on output in case of dynamic // shapes. virtual StatusOr<OutputDimensionBoundsMap> DynamicOutputDimensions( const NodeDef& ndef, XlaOpKernelContext* ctx) const { return OutputDimensionBoundsMap{}; } private: Status CompileToCustomCallCallingTfKernel(int graph_def_version, const NodeDef& node_def, XlaOpKernelContext* ctx) const; NodeDef def_; int graph_def_version_; }; } // namespace tensorflow #endif // TENSORFLOW_COMPILER_TF2XLA_KERNELS_GPU_TF_KERNEL_CUSTOM_CALL_H_
37.878378
80
0.719943
[ "shape" ]
0b5e2255c19acec07fbe8b2df41a6f91fac897c1
6,438
h
C
mesh.h
nezticle/MeshViewer
7c57f1c5df6169e98c11922acd132e8a1ec19bf0
[ "BSD-2-Clause" ]
1
2021-11-03T02:38:17.000Z
2021-11-03T02:38:17.000Z
mesh.h
nezticle/MeshViewer
7c57f1c5df6169e98c11922acd132e8a1ec19bf0
[ "BSD-2-Clause" ]
null
null
null
mesh.h
nezticle/MeshViewer
7c57f1c5df6169e98c11922acd132e8a1ec19bf0
[ "BSD-2-Clause" ]
1
2021-08-04T09:32:35.000Z
2021-08-04T09:32:35.000Z
/* * Copyright (c) 2020 Andy Nichols <nezticle@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef MESH_H #define MESH_H #include <QMatrix4x4> #include <QVector3D> #include <QVector> #include <QMap> class Mesh; class MeshFileTool { public: MeshFileTool(); QVector<Mesh *> loadMeshFile(const QString &meshFile); void saveMeshFile(const QString &meshFile, const QVector<Mesh *> meshes); private: struct MultiMeshInfo { quint32 fileId = 0; quint32 fileVersion = 0; QMap<quint32, quint64> meshEntires; bool isValid() { return fileId == 555777497 && fileVersion == 1; } }; }; class Mesh { public: struct MeshSubsetBounds { QVector3D min; QVector3D max; }; enum DrawMode { Points = 1, LineStrip, LineLoop, Lines, TriangleStrip, TriangleFan, Triangles, Patches }; enum WindingMode { Clockwise = 1, CounterClockwise }; class Subset { public: Subset(const Mesh &mesh, int subsetIndex); QVector<QVector3D> positions() const; QVector<QVector3D> normals() const; QMap<int, QVector<QVector2D> > uvs() const; QVector<QVector3D> tangents() const; QVector<QVector3D> binormals() const; QVector<QVector4D> colors() const; QVector<QVector4D> joints() const; QVector<QVector4D> weights() const; QMap<int, QVector<QVector3D> > morphTargetPositions() const; QMap<int, QVector<QVector3D> > morphTargetNormals() const; QMap<int, QVector<QVector3D> > morphTargetTangents() const; QMap<int, QVector<QVector3D> > morphTargetBinormals() const; QString name() const; MeshSubsetBounds bounds() const; WindingMode windingMode() const; DrawMode drawMode() const; int count() const; private: QString m_name; MeshSubsetBounds m_bounds; WindingMode m_windingMode; DrawMode m_drawMode; int m_count; // Attributes QVector<QVector3D> m_positions; QVector<QVector3D> m_normals; QMap<int, QVector<QVector2D>> m_uvs; QVector<QVector3D> m_tangents; QVector<QVector3D> m_binormals; QVector<QVector4D> m_colors; QVector<QVector4D> m_joints; QVector<QVector4D> m_weights; QMap<int, QVector<QVector3D>> m_morphTargetPositions; QMap<int, QVector<QVector3D>> m_morphTargetNormals; QMap<int, QVector<QVector3D>> m_morphTargetTangents; QMap<int, QVector<QVector3D>> m_morphTargetBinormals; }; Mesh(); ~Mesh(); QVector<Subset *> subsets() const { return m_subsets; } quint64 loadMesh(const QString &meshFile, quint64 offset); quint64 saveMesh(const QString &meshFile, quint64 offset); private: struct MeshDataHeader { quint32 fileId = 0; quint16 fileVersion = 0; quint16 headerFlags = 0; quint32 sizeInBytes = 0; bool isValid() { return fileId == 3365961549 && fileVersion == 3; } }; struct MeshOffsetTracker { quint32 startOffset = 0; quint32 byteCounter = 0; MeshOffsetTracker(int offset) : startOffset(offset) {} int offset() { return startOffset + byteCounter; } void alignedAdvance(int advanceAmount) { advance(advanceAmount); quint32 alignmentAmount = 4 - (byteCounter % 4); byteCounter += alignmentAmount; } void advance(int advanceAmount) { byteCounter += advanceAmount; } }; enum ComponentType { UnsignedInt8 = 1, Int8, UnsignedInt16, Int16, UnsignedInt32, Int32, UnsignedInt64, Int64, Float16, Float32, Float64 }; struct VertexBufferEntry { ComponentType componentType = ComponentType::Float32; quint32 numComponents = 0; quint32 firstItemOffset = 0; QByteArray name; }; struct VertexBuffer { quint32 stride = 0; QVector<VertexBufferEntry> entires; QByteArray data; }; struct IndexBuffer { ComponentType componentType = ComponentType::UnsignedInt32; QByteArray data; }; struct MeshSubset { struct MeshSubsetBounds { QVector3D min; QVector3D max; }; quint32 count = 0; quint32 offset = 0; MeshSubsetBounds bounds; QByteArray name; quint32 nameLength = 0; }; struct Joint { quint32 jointId = 0; quint32 parentId = 0; QMatrix4x4 invBindPos; QMatrix4x4 localToGlobalBoneSpace; }; MeshDataHeader m_meshInfo; VertexBuffer m_vertexBuffer; IndexBuffer m_indexBuffer; QVector<MeshSubset> m_meshSubsets; QVector<Joint> m_joints; DrawMode m_drawMode; WindingMode m_windingMode; // Easy to consume info: QVector<Subset *> m_subsets; }; #endif // MESH_H
27.630901
78
0.639329
[ "mesh" ]
0b63df316264ae0e7f2830f8414c6b9057aaedfb
1,655
h
C
code/utils/xrQSlim/src/MxStdSlim.h
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
58
2016-11-20T19:14:35.000Z
2021-12-27T21:03:35.000Z
code/utils/xrQSlim/src/MxStdSlim.h
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
59
2016-09-10T10:44:20.000Z
2018-09-03T19:07:30.000Z
code/utils/xrQSlim/src/MxStdSlim.h
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
39
2017-02-05T13:35:37.000Z
2022-03-14T11:00:12.000Z
#ifndef MXSTDSLIM_INCLUDED // -*- C++ -*- #define MXSTDSLIM_INCLUDED #if !defined(__GNUC__) #pragma once #endif /************************************************************************ Core simplification interface. The MxStdSlim class defines the interface which all simplification classes conform to. Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. $Id: MxStdSlim.h,v 1.4 1998/11/19 01:57:34 garland Exp $ ************************************************************************/ #include "MxStdModel.h" #include "MxHeap.h" #define MX_PLACE_ENDPOINTS 0 #define MX_PLACE_ENDORMID 1 #define MX_PLACE_LINE 2 #define MX_PLACE_OPTIMAL 3 #define MX_WEIGHT_UNIFORM 0 #define MX_WEIGHT_AREA 1 #define MX_WEIGHT_ANGLE 2 #define MX_WEIGHT_AVERAGE 3 #define MX_WEIGHT_AREA_AVG 4 #define MX_WEIGHT_RAWNORMALS 5 #define EDGE_BASE_ERROR 1.f class MxStdSlim { protected: MxStdModel* m; MxHeap heap; public: unsigned int valid_verts; unsigned int valid_faces; bool is_initialized; int placement_policy; int weighting_policy; bool will_join_only; double boundary_weight; double compactness_ratio; double meshing_penalty; double local_validity_threshold; unsigned int vertex_degree_limit; public: MxStdSlim(MxStdModel* m0); virtual void initialize() = 0; virtual bool decimate(unsigned int, float max_error, void* cb_params = 0) = 0; MxStdModel& model() { return *m; } public: void (*contraction_callback)(const MxPairContraction&, float, void*); }; // MXSTDSLIM_INCLUDED #endif
23.985507
83
0.645921
[ "model" ]
0b6d5ee3d2450a8a3b29998ea1904091b78216ff
2,056
h
C
Tools/MedusaExport/max9/include/strbasic.h
CarysT/medusa
8e79f7738534d8cf60577ec42ed86621533ac269
[ "MIT" ]
32
2016-05-22T23:09:19.000Z
2022-03-13T03:32:27.000Z
Tools/MedusaExport/max9/include/strbasic.h
CarysT/medusa
8e79f7738534d8cf60577ec42ed86621533ac269
[ "MIT" ]
2
2016-05-30T19:45:58.000Z
2018-01-24T22:29:51.000Z
Tools/MedusaExport/max9/include/strbasic.h
CarysT/medusa
8e79f7738534d8cf60577ec42ed86621533ac269
[ "MIT" ]
17
2016-05-27T11:01:42.000Z
2022-03-13T03:32:30.000Z
/******************************************************************* * * DESCRIPTION: Basic string definitions header file * * AUTHOR: Tom Hudson * * HISTORY: File created 9/6/94 * *******************************************************************/ #ifndef _STRBASICS_ #define _STRBASICS_ #define WIN95STUFF // To set up Max to use Unicode, define _UNICODE, and don't define _MBCS // To set up Max to use multi-byte character sets, define _MBCS and // don't define _UNICODE // To set up Max to use single-byte ANSI character strings, don't define // either _UNICODE or _MBCS // #define _UNICODE // turn on Unicode support #ifndef _MBCS #define _MBCS // if Unicode is off, turn on multi-byte character support #endif #ifdef _UNICODE #ifdef _MBCS #undef _MBCS // can't have both Unicode and MBCS at once -- Unicode wins #endif #undef UNICODE #define UNICODE #undef STRCONST #define STRCONST L //#define RWSTR RWWString //#define RWTOKENIZER RWWTokenizer // Here's a macro to get a const char * from a RWWString object -- It // temporarily constructs a RWCString object to hold the 1-byte wide // character string output by the toAcsii() operator. Don't store // this pointer! Copy it to a new allocation, because it might go // away. #undef NARROW #define NARROW(s) ((const char *)((s).toAscii())) #else //#define RWSTR RWCString //#define RWTOKENIZER RWCTokenizer //#define NARROW(s) (s) #endif // Bring in the generic international text header file #include <tchar.h> // Starting with VS2005 the default is to have wchar_t defined as a type, so that's // what we'll use as well (plus it coincides with the VS2005 Max9 release) typedef __wchar_t mwchar_t; // // MAX is not compiled in UNICODE (yet). TCHAR has been changed to MCHAR where // appropriate, so you can compile in UNICODE or not, and not have Max's headers // change. // #define MCHAR char #define LPCMSTR const MCHAR* #define _M(s) (s) #endif // _STRBASICS_
26.358974
83
0.645914
[ "object" ]
0b6f58d7a94afd6a65a7a7f3f640f1469376f3fe
47,327
h
C
talk/owt/sdk/include/cpp/owt/base/connectionstats.h
AoEiuV020/owt-client-native
7fc498347b20149fd1a4fd7ff84fa891548c9a84
[ "Apache-2.0" ]
1
2021-01-26T07:57:43.000Z
2021-01-26T07:57:43.000Z
talk/owt/sdk/include/cpp/owt/base/connectionstats.h
AoEiuV020/owt-client-native
7fc498347b20149fd1a4fd7ff84fa891548c9a84
[ "Apache-2.0" ]
1
2021-12-03T01:37:48.000Z
2021-12-03T01:56:17.000Z
talk/owt/sdk/include/cpp/owt/base/connectionstats.h
AoEiuV020/owt-client-native
7fc498347b20149fd1a4fd7ff84fa891548c9a84
[ "Apache-2.0" ]
null
null
null
// Copyright (C) <2018> Intel Corporation // // SPDX-License-Identifier: Apache-2.0 #ifndef OWT_BASE_CONNECTIONSTATS_H_ #define OWT_BASE_CONNECTIONSTATS_H_ #include <chrono> #include <map> #include <memory> #include <string> #include <vector> #include "owt/base/commontypes.h" #include "owt/base/network.h" namespace owt { namespace base { // RTC-spec compliant statistics interfaces. // https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate struct RTCDataChannelState { static const char* const kConnecting; static const char* const kOpen; static const char* const kClosing; static const char* const kClosed; }; // https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate struct RTCStatsIceCandidatePairState { static const char* const kFrozen; static const char* const kWaiting; static const char* const kInProgress; static const char* const kFailed; static const char* const kSucceeded; }; // https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum struct RTCIceCandidateType { static const char* const kHost; static const char* const kSrflx; static const char* const kPrflx; static const char* const kRelay; }; // https://w3c.github.io/webrtc-pc/#idl-def-rtcdtlstransportstate struct RTCDtlsTransportState { static const char* const kNew; static const char* const kConnecting; static const char* const kConnected; static const char* const kClosed; static const char* const kFailed; }; // |RTCMediaStreamTrackStats::kind| is not an enum in the spec but the only // valid values are "audio" and "video". // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-kind struct RTCMediaStreamTrackKind { static const char* const kAudio; static const char* const kVideo; }; // https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype struct RTCNetworkType { static const char* const kBluetooth; static const char* const kCellular; static const char* const kEthernet; static const char* const kWifi; static const char* const kWimax; static const char* const kVpn; static const char* const kUnknown; }; // https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason struct RTCQualityLimitationReason { static const char* const kNone; static const char* const kCpu; static const char* const kBandwidth; static const char* const kOther; }; // https://webrtc.org/experiments/rtp-hdrext/video-content-type/ struct RTCContentType { static const char* const kUnspecified; static const char* const kScreenshare; }; /*! * \sa https://w3c.github.io/webrtc-stats/#rtcstatstype-str* */ struct RTCStatsType { static const char* const kCodec; static const char* const kInboundRTP; static const char* const kOutboundRTP; static const char* const kRemoteInboundRTP; static const char* const kRemoteOutboundRTP; static const char* const kMediaSource; static const char* const kCsrc; static const char* const kPeerConnection; static const char* const kDataChannel; static const char* const kStream; static const char* const kTrack; static const char* const kTranseiver; static const char* const kSender; static const char* const kReceiver; static const char* const kTransport; static const char* const kSctpTransport; static const char* const kCandidatePair; static const char* const kLocalCandidate; static const char* const kRemoteCandidate; static const char* const kCertificate; static const char* const kIceServer; }; /*! * \sa https://w3c.github.io/webrtc-stats/#idl-def-rtcstats* */ class RTCStats { public: RTCStats(const std::string& type, const std::string& id, int64_t timestamp_us) : type(type), id(id), timestamp_us(timestamp_us) {} RTCStats(const RTCStats& other) { type = other.type; id = other.id; timestamp_us = other.timestamp_us; } virtual ~RTCStats() {} // Downcasts the stats object to an |RTCStats| subclass |T|. TODO: DCHECKs // that the object is of type |T|. template <typename T> const T& cast_to() const { return static_cast<const T&>(*this); } std::string type; std::string id; int64_t timestamp_us; }; class RTCStatsReport { public: RTCStatsReport() {} virtual ~RTCStatsReport() {} typedef std::map<std::string, std::unique_ptr<const owt::base::RTCStats>> StatsMap; class ConstIterator { public: ConstIterator(ConstIterator&& other); ~ConstIterator(); ConstIterator& operator++(); ConstIterator& operator++(int); const RTCStats& operator*() const; const RTCStats* operator->() const; bool operator==(const ConstIterator& other) const; bool operator!=(const ConstIterator& other) const; private: friend class owt::base::RTCStatsReport; ConstIterator(owt::base::RTCStatsReport* report, StatsMap::const_iterator it); StatsMap::const_iterator it_; }; void AddStats(std::unique_ptr<const owt::base::RTCStats> stats); const owt::base::RTCStats* Get(const std::string& id) const; size_t size() const { return stats_map.size(); } // Gets the stat object of type |T| by ID, where |T| is any class descending // from |RTCStats|. // Returns null if there is no stats object for the given ID or it is the // wrong type. template <typename T> const T* GetAs(const std::string& id) const { const RTCStats* stats = Get(id); if (!stats || stats->type != T::kType) { return nullptr; } return &stats->cast_to<const T>(); } // Removes the stats object from the report, returning ownership of it or null // if there is no object with |id|. std::unique_ptr<const owt::base::RTCStats> Take(const std::string& id); // Takes ownership of all the stats in |victim|, leaving it empty. void TakeMembersFrom(std::shared_ptr<owt::base::RTCStatsReport> victim); // Stats iterators. Stats are ordered lexicographically on |RTCStats::id|. ConstIterator begin() const; ConstIterator end() const; // Gets the subset of stats that are of type |T|, where |T| is any class // descending from |RTCStats|. template <typename T> std::vector<const T*> GetStatsOfType() const { std::vector<const T*> stats_of_type; for (const RTCStats& stats : *this) { if (stats.type == T::kType) stats_of_type.push_back(&stats.cast_to<const T>()); } return stats_of_type; } private: StatsMap stats_map; }; /*! * \sa https://w3c.github.io/webrtc-stats/#certificatestats-dict* */ class RTCCertificateStats : public RTCStats { public: RTCCertificateStats(const std::string& id, int64_t timestamp, const std::string& fingerprint, const std::string& fingerprint_algorithm, const std::string& base64_certificate, const std::string& issuer_certificate_id); RTCCertificateStats(const RTCCertificateStats& other); ~RTCCertificateStats(); std::string fingerprint; // The hash funciton used to calculate the certificate fingerprint. // For insance, "sha-256". std::string fingerprint_algorithm; // The DER-encoded based-64 rep of the certifcate. std::string base64_certificate; // The id of the stats object that contains the next certificate // in the certificate chain. std::string issuer_certificate_id; }; /*! * \sa https://w3c.github.io/webrtc-stats/#codec-dict* */ class RTCCodecStats final : public RTCStats { public: RTCCodecStats(const std::string& id, int64_t timestamp, uint32_t payload_type, const std::string& mime_type, uint32_t clock_rate, uint32_t channels, const std::string& sdp_fmtp_line); RTCCodecStats(const RTCCodecStats& other); ~RTCCodecStats() override; uint32_t payload_type; // Non-populated member: codec_type. Commonly it's both encode & decode // so by spec not included. // Non-populated member: transportId. By spec it referes to the id of // RTCTransportStats object which uses current codec. std::string mime_type; uint32_t clock_rate; uint32_t channels; std::string sdp_fmtp_line; }; /*! * \sa https://w3c.github.io/webrtc-stats/#dcstats-dict* */ class RTCDataChannelStats final : public RTCStats { public: RTCDataChannelStats(const std::string& id, int64_t timestamp, const std::string& label, const std::string& protocol, int32_t datachannelid, const std::string& state, uint32_t messages_sent, uint64_t bytes_sent, uint32_t messages_received, uint64_t bytes_received); RTCDataChannelStats(const RTCDataChannelStats& other); ~RTCDataChannelStats() override; // Label of the datachannel. std::string label; std::string protocol; // The "id" attribute ofthe datachannel int32_t datachannelid; // TODO: Support enum types? "RTCStatsMember<RTCDataChannelState>"? // The "readyState" of the DataChannel object std::string state; // The total number of API level message events sent. uint32_t messages_sent; // Total number of payload bytes sent, not including headers and paddings. uint64_t bytes_sent; // The total number of API level message events received. uint32_t messages_received; // The total number of payload bytes received, not including headers and // paddings uint64_t bytes_received; }; /*! * \sa https://w3c.github.io/webrtc-stats/#candidatepair-dict* */ class RTCIceCandidatePairStats final : public RTCStats { public: RTCIceCandidatePairStats(const std::string& id, int64_t timestamp, const std::string& transport_id, const std::string& local_candidate_id, const std::string& remote_candidate_id, const std::string& state, uint64_t priority, bool nominated, bool writable, bool readable, uint64_t bytes_sent, uint64_t bytes_received, double total_round_trip_time, double current_round_trip_time, double available_outgoing_bitrate, double avialable_incoming_bitrate, uint64_t requests_received, uint64_t requests_sent, uint64_t responses_received, uint64_t responses_sent, uint64_t retransmissions_received, uint64_t retransmissions_sent, uint64_t consent_requests_received, uint64_t consent_requests_sent, uint64_t consent_responses_received, uint64_t consent_responses_sent); RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other); ~RTCIceCandidatePairStats() override; // The uinque transportId of the RTCTransportStats associated with this // candidate pair. std::string transport_id; std::string local_candidate_id; std::string remote_candidate_id; std::string state; // obsoleted in latest spec. uint64_t priority; bool nominated; // Below two are not included in spec. You can ignore them. bool writable; bool readable; // TODO: by spec below we should populate thse two stats: // uint64_t packets_sent, uint64_t packets_received. // Total bytes sent on this candidate pair not including headers/paddings/ice // checks. uint64_t bytes_sent; // Total bytes received on this candidate pair not including // headers/paddings/ice checks. uint64_t bytes_received; // TODO: not populated: lastPacketSentTimestamp/lastPacketReceivedTimestamp // TODO: not populated: lastRequestTimestamp/lastResponseTimestamp // Sum of all roundtrip time measurements in seconds since beginning of the // session. Refer to spec on how to use this value to calculate the average // round trip time. double total_round_trip_time; // Latest round trip time measured in seconds, computed from STUN connectivity // checks. double current_round_trip_time; // The bandwidth estimation result for all the outgoing RTP streams using this // candidate pair. Implementation that does not support sender side BWE must // leave this value as undefined. double available_outgoing_bitrate; // Refer to spec for more details. double available_incoming_bitrate; // total number of connectivity check requests received. uint64_t requests_received; // total number of connectivity check requests sent. uint64_t requests_sent; // total number of connectivity check response received. uint64_t responses_received; // total number of connectivity check response sent. uint64_t responses_sent; // total number of connectivity check request retransmissions received. // TODO: Collect and populate this value. uint64_t retransmissions_received; // total number of connectivity check rquest retransmissions sent. // TODO: Collect and populate this value. uint64_t retransmissions_sent; // total number of consent requests/response received/sent. Spec does not // define the consent_requests_received and consent_response_received, but // define the consentRequestBytesSent/...), so the implementation is quite // different from spec. // TODO: Collect and populate this value. uint64_t consent_requests_received; uint64_t consent_requests_sent; // TODO: Collect and populate this value. uint64_t consent_responses_received; // TODO: Collect and populate this value. uint64_t consent_responses_sent; }; /*! * \sa https://w3c.github.io/webrtc-stats/#icecandidate-dict* */ // TODO: |RTCStatsCollector| only collects candidates that are part of // ice candidate pairs, but there could be candidates not paired with anything. // TODO: Add the stats of STUN binding requests (keepalives) and collect // them in the new PeerConnection::GetStats. class RTCIceCandidateStats : public RTCStats { public: RTCIceCandidateStats(const std::string& type, const std::string& id, int64_t timestamp, const std::string& transport_id, bool is_remote, const std::string& network_type, const std::string& ip, int32_t port, const std::string& protocol, const std::string& relay_protocol, const std::string& candidate_type, int32_t priority, const std::string& url, bool deleted); RTCIceCandidateStats(const RTCIceCandidateStats& other); ~RTCIceCandidateStats() override; // Transport id of the RTCTransportStats associated with this // candidate. std::string transport_id; bool is_remote; std::string network_type; std::string ip; int32_t port; std::string protocol; std::string relay_protocol; // TODO: Support enum types? "RTCStatsMember<RTCIceCandidateType>"? std::string candidate_type; int32_t priority; // TODO: Not collected by |RTCStatsCollector|. std::string url; // obsoleted in latest spec. bool deleted; // = false }; /*! * \sa https://w3c.github.io/webrtc-stats/#rtcstatstype-str* */ class RTCLocalIceCandidateStats final : RTCIceCandidateStats { public: RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp, const std::string& transport_id, bool is_remote, const std::string& network_type, const std::string& ip, int32_t port, const std::string& protocol, const std::string& relay_protocol, const std::string& candidate_type, int32_t priority, const std::string& url, bool deleted); RTCLocalIceCandidateStats(const RTCLocalIceCandidateStats& other); ~RTCLocalIceCandidateStats() override; }; /*! * \sa https://w3c.github.io/webrtc-stats/#rtcstatstype-str* */ class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats { public: RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp, const std::string& transport_id, bool is_remote, const std::string& network_type, const std::string& ip, int32_t port, const std::string& protocol, const std::string& relay_protocol, const std::string& candidate_type, int32_t priority, const std::string& url, bool deleted); RTCRemoteIceCandidateStats(const RTCRemoteIceCandidateStats& other); ~RTCRemoteIceCandidateStats() override; }; /*! * \sa https://w3c.github.io/webrtc-stats/#msstats-dict* */ // Obsoleted due to sender/receiver/transceiver stats being better // fits to describe the modern RTCPeerConnection model (unified plan). class RTCMediaStreamStats final : public RTCStats { public: RTCMediaStreamStats(const std::string& id, int64_t timestamp, const std::string& stream_identifier, const std::vector<std::string>& track_ids); RTCMediaStreamStats(const RTCMediaStreamStats& other); ~RTCMediaStreamStats() override; std::string stream_identifier; std::vector<std::string> track_ids; }; /*! * \sa https://w3c.github.io/webrtc-stats/#msstats-dict* */ // This is a combined implementation of RTCInboundRtpStreamStats // and RTCOutboundRtpStreamStats. class RTCMediaStreamTrackStats final : public RTCStats { public: RTCMediaStreamTrackStats(const std::string& id, int64_t timestamp, std::string track_identifier, std::string media_source_id, bool remote_source, bool ended, bool detached, std::string kind, double jitter_buffer_delay, uint64_t jitter_buffer_emitted_count, uint32_t frame_width, uint32_t frame_height, double frames_per_second, uint32_t frames_sent, uint32_t huge_frames_sent, uint32_t frames_received, uint32_t frames_decoded, uint32_t frames_dropped, uint32_t frames_corrupted, uint32_t partial_frames_lost, uint32_t full_frames_lost, double audio_level, double total_audio_energy, double echo_return_loss, double echo_return_loss_enhancement, uint64_t total_samples_received, double total_samples_duration, uint64_t concealed_samples, uint64_t silent_concealed_samples, uint64_t concealment_events, uint64_t inserted_samples_for_deceleration, uint64_t removed_samples_for_acceleration, uint64_t jitter_buffer_flushes, uint64_t delayed_packet_outage_samples, double relative_packet_arrival_delay, double jitter_buffer_target_delay, uint32_t interruption_count, double total_interruption_duration, uint32_t freeze_count, uint32_t pause_count, double total_freezes_duration, double total_pauses_duration, double total_frames_duration, double sum_squared_frame_durations); RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other); ~RTCMediaStreamTrackStats() override; std::string track_identifier; std::string media_source_id; bool remote_source; bool ended; // TODO: |RTCStatsCollector| does not return stats for detached tracks. bool detached; // See |RTCMediaStreamTrackKind| for valid values. std::string kind; double jitter_buffer_delay; uint64_t jitter_buffer_emitted_count; // Video-only members uint32_t frame_width; uint32_t frame_height; // TODO: Not collected by |RTCStatsCollector|. double frames_per_second; uint32_t frames_sent; uint32_t huge_frames_sent; uint32_t frames_received; uint32_t frames_decoded; uint32_t frames_dropped; // TODO: Not collected by |RTCStatsCollector|. uint32_t frames_corrupted; // TODO: Not collected by |RTCStatsCollector|. uint32_t partial_frames_lost; // TODO: Not collected by |RTCStatsCollector|. uint32_t full_frames_lost; // Audio-only members double audio_level; // Receive-only double total_audio_energy; // Receive-only double echo_return_loss; double echo_return_loss_enhancement; uint64_t total_samples_received; double total_samples_duration; // Receive-only uint64_t concealed_samples; uint64_t silent_concealed_samples; uint64_t concealment_events; uint64_t inserted_samples_for_deceleration; uint64_t removed_samples_for_acceleration; // Non-standard audio-only member // TODO: Add description to standard. uint64_t jitter_buffer_flushes; uint64_t delayed_packet_outage_samples; double relative_packet_arrival_delay; // Non-standard metric showing target delay of jitter buffer. // This value is increased by the target jitter buffer delay every time a // sample is emitted by the jitter buffer. The added target is the target // delay, in seconds, at the time that the sample was emitted from the jitter // buffer. // Currently it is implemented only for audio. // TODO: implement for video streams when will be requested. double jitter_buffer_target_delay; uint32_t interruption_count; double total_interruption_duration; // Non-standard video-only members. // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict* uint32_t freeze_count; uint32_t pause_count; double total_freezes_duration; double total_pauses_duration; double total_frames_duration; double sum_squared_frame_durations; }; /*! * \sa https://w3c.github.io/webrtc-stats/#pcstats-dict */ class RTCPeerConnectionStats final : public RTCStats { public: RTCPeerConnectionStats(const std::string& id, int64_t timestamp, uint32_t data_channels_opened, uint32_t data_channels_closed); RTCPeerConnectionStats(const RTCPeerConnectionStats& other); ~RTCPeerConnectionStats() override; uint32_t data_channels_opened; uint32_t data_channels_closed; // data_channels_requested & data_channels_accepted not populated. }; /*! * \sa https://w3c.github.io/webrtc-stats/#streamstats-dict* */ class RTCRTPStreamStats : public RTCStats { public: RTCRTPStreamStats(const std::string& type, const std::string& id, int64_t timestamp, uint32_t ssrc, bool is_remote, const std::string& media_type, const std::string& kind, const std::string& track_id, const std::string& transport_id, const std::string& codec_id, uint32_t fir_count, uint32_t pli_count, uint32_t nack_count, uint32_t sli_count, uint64_t qp_sum); RTCRTPStreamStats(const RTCRTPStreamStats& other); ~RTCRTPStreamStats() override; uint32_t ssrc; // TODO: Remote case not supported by |RTCStatsCollector|. bool is_remote; // = false std::string media_type; // renamed to kind. std::string kind; std::string track_id; std::string transport_id; std::string codec_id; // FIR and PLI counts are only defined for |media_type == "video"|. uint32_t fir_count; uint32_t pli_count; // TODO: NACK count should be collected by |RTCStatsCollector| for both // audio and video but is only defined in the "video" case. uint32_t nack_count; // SLI count is only defined for |media_type == "video"|. uint32_t sli_count; uint64_t qp_sum; }; /*! * \sa https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict* */ // TODO: Support the remote case |is_remote = true|. class RTCInboundRTPStreamStats final : public RTCRTPStreamStats { public: RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp, uint32_t ssrc, bool is_remote, const std::string& media_type, const std::string& kind, const std::string& track_id, const std::string& transport_id, const std::string& codec_id, uint32_t fir_count, uint32_t pli_count, uint32_t nack_count, uint32_t sli_count, uint64_t qp_sum, uint32_t packets_received, uint64_t fec_packets_received, uint64_t fec_packets_discarded, uint64_t bytes_received, uint64_t header_bytes_received, int32_t packets_lost, double last_packet_received_timestamp, double jitter, double round_trip_time, uint32_t packets_discarded, uint32_t packets_repaired, uint32_t burst_packets_lost, uint32_t burst_packets_discarded, uint32_t burst_loss_count, uint32_t burst_discard_count, double burst_loss_rate, double burst_discard_rate, double gap_loss_rate, double gap_discard_rate, uint32_t frames_decoded, uint32_t key_frames_decoded, double total_decode_time, double total_inter_frame_delay, double total_squared_inter_frame_delay, const std::string& content_type, double estimated_playout_timestamp, const std::string& decoder_implementation); RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other); ~RTCInboundRTPStreamStats() override; uint32_t packets_received; uint64_t fec_packets_received; uint64_t fec_packets_discarded; uint64_t bytes_received; uint64_t header_bytes_received; int32_t packets_lost; // Signed per RFC 3550 double last_packet_received_timestamp; // TODO: Collect and populate this value for both "audio" and "video", // currently not collected for "video". double jitter; // TODO: Collect and populate this value. double round_trip_time; // TODO: Collect and populate this value. uint32_t packets_discarded; // TODO: Collect and populate this value. uint32_t packets_repaired; // TODO: Collect and populate this value. uint32_t burst_packets_lost; // TODO: Collect and populate this value. uint32_t burst_packets_discarded; // TODO: Collect and populate this value. uint32_t burst_loss_count; // TODO: Collect and populate this value. uint32_t burst_discard_count; // TODO: Collect and populate this value. double burst_loss_rate; // TODO: Collect and populate this value. double burst_discard_rate; // TODO: Collect and populate this value. double gap_loss_rate; // TODO: Collect and populate this value. double gap_discard_rate; uint32_t frames_decoded; uint32_t key_frames_decoded; double total_decode_time; double total_inter_frame_delay; double total_squared_inter_frame_delay; // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype std::string content_type; // TODO: Currently only populated if audio/video sync is enabled. double estimated_playout_timestamp; // TODO: This is only implemented for video; implement it for audio as // well. std::string decoder_implementation; }; /*! * \sa https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict* */ // TODO: Support the remote case |is_remote = true|. class RTCOutboundRTPStreamStats final : public RTCRTPStreamStats { public: RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp, uint32_t ssrc, bool is_remote, const std::string& media_type, const std::string& kind, const std::string& track_id, const std::string& transport_id, const std::string& codec_id, uint32_t fir_count, uint32_t pli_count, uint32_t nack_count, uint32_t sli_count, uint64_t qp_sum, const std::string& media_source_id, const std::string& remote_id, uint32_t packets_sent, uint64_t retransmitted_packets_sent, uint64_t bytes_sent, uint64_t header_bytes_sent, uint64_t retransmitted_bytes_sent, double target_bitrate, uint32_t frames_encoded, uint32_t key_frames_encoded, double total_encode_time, uint64_t total_encoded_bytes_target, double total_packet_send_delay, const std::string& quality_limitation_reason, uint32_t quality_limitation_resolution_changes, const std::string& content_type, const std::string& encoder_implementation); RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other); ~RTCOutboundRTPStreamStats() override; std::string media_source_id; std::string remote_id; uint32_t packets_sent; uint64_t retransmitted_packets_sent; uint64_t bytes_sent; uint64_t header_bytes_sent; uint64_t retransmitted_bytes_sent; // TODO: Collect and populate this value. double target_bitrate; uint32_t frames_encoded; uint32_t key_frames_encoded; double total_encode_time; uint64_t total_encoded_bytes_target; // TODO: This is only implemented for video; // implement it for audio as well. double total_packet_send_delay; // Enum type RTCQualityLimitationReason // TODO: Also expose // qualityLimitationDurations. Requires RTCStatsMember support for // "record<DOMString, double>" std::string quality_limitation_reason; // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges uint32_t quality_limitation_resolution_changes; // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype std::string content_type; // TODO: This is only implemented for video; implement it for audio as // well. std::string encoder_implementation; }; /*! * \sa https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict* */ // TODO: Refactor the stats dictionaries to have // the same hierarchy as in the spec; implement RTCReceivedRtpStreamStats. // Several metrics are shared between "outbound-rtp", "remote-inbound-rtp", // "inbound-rtp" and "remote-outbound-rtp". In the spec there is a hierarchy of // dictionaries that minimizes defining the same metrics in multiple places. // From JavaScript this hierarchy is not observable and the spec's hierarchy is // purely editorial. In C++ non-final classes in the hierarchy could be used to // refer to different stats objects within the hierarchy. // https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict* // RTCRemoteInboundRtpStreamsStats represents the measurements by the remote // outgoing rtp stream at the sending endpoint. (By spec it should inherit // from RTCReceivedRtpStreamStats and include extra properties including // following: localId, roundTripTime, totalRoundTripTime, fractionLost, // reportsReceived & roundTripTimeMeasurements.) class RTCRemoteInboundRtpStreamStats final : public RTCStats { public: RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp, uint32_t ssrc, const std::string& kind, const std::string& transport_id, const std::string& codec_id, int32_t packets_lost, double jitter, const std::string& local_id, double round_trip_time); RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other); ~RTCRemoteInboundRtpStreamStats() override; // In the spec RTCRemoteInboundRtpStreamStats inherits from RTCRtpStreamStats // and RTCReceivedRtpStreamStats. The members here are listed based on where // they are defined in the spec. // RTCRtpStreamStats uint32_t ssrc; std::string kind; std::string transport_id; std::string codec_id; // RTCReceivedRtpStreamStats int32_t packets_lost; double jitter; // TODO: The following RTCReceivedRtpStreamStats metrics should also be // implemented: packetsReceived, packetsDiscarded, packetsRepaired, // burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount, // burstLossRate, burstDiscardRate, gapLossRate and gapDiscardRate. // RTCRemoteInboundRtpStreamStats std::string local_id; double round_trip_time; // TODO: The following RTCRemoteInboundRtpStreamStats metric should also // be implemented: fractionLost. }; /*! * \sa https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats */ class RTCMediaSourceStats : public RTCStats { public: RTCMediaSourceStats(const std::string& type, const std::string& id, int64_t timestamp, const std::string& track_identifier, const std::string& kind); RTCMediaSourceStats(const RTCMediaSourceStats& other); ~RTCMediaSourceStats() override; std::string track_identifier; std::string kind; }; /*! * \sa https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats */ class RTCAudioSourceStats final : public RTCMediaSourceStats { public: RTCAudioSourceStats(const std::string& id, int64_t timestamp, const std::string& track_identifier, const std::string& kind, double audio_level, double total_audio_engergy, double total_samples_duration); RTCAudioSourceStats(const RTCAudioSourceStats& other); ~RTCAudioSourceStats() override; double audio_level; double total_audio_energy; double total_samples_duration; }; /*! * \sa https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats */ class RTCVideoSourceStats final : public RTCMediaSourceStats { public: RTCVideoSourceStats(const std::string& id, int64_t timestamp, const std::string& track_identifier, const std::string& kind, uint32_t width, uint32_t height, uint32_t frames, uint32_t frames_per_second); RTCVideoSourceStats(const RTCVideoSourceStats& other); ~RTCVideoSourceStats() override; uint32_t width; uint32_t height; // TODO: Implement this metric. uint32_t frames; uint32_t frames_per_second; }; /*! * \sa https://w3c.github.io/webrtc-stats/#transportstats-dict* */ class RTCTransportStats final : public RTCStats { public: RTCTransportStats(const std::string& id, int64_t timestamp, uint64_t bytes_sent, uint64_t bytes_received, const std::string& rtcp_transport_stats_id, const std::string& dtls_state, const std::string& selected_candidate_pair_id, const std::string& local_certificate_id, const std::string& remote_certificate_id, const std::string& tls_version, const std::string& dtls_cipher, const std::string& srtp_cipher, uint32_t selected_candidate_pair_changes); RTCTransportStats(const RTCTransportStats& other); ~RTCTransportStats() override; uint64_t bytes_sent; uint64_t bytes_received; std::string rtcp_transport_stats_id; // TODO: Support enum types? "RTCStatsMember<RTCDtlsTransportState>"? std::string dtls_state; std::string selected_candidate_pair_id; std::string local_certificate_id; std::string remote_certificate_id; std::string tls_version; std::string dtls_cipher; std::string srtp_cipher; uint32_t selected_candidate_pair_changes; }; /// Define audio sender report struct AudioSenderReport { AudioSenderReport(int64_t bytes_sent, int32_t packets_sent, int32_t packets_lost, int64_t round_trip_time, std::string codec_name) : bytes_sent(bytes_sent), packets_sent(packets_sent), packets_lost(packets_lost) , round_trip_time(round_trip_time), codec_name(codec_name) {} /// Audio bytes sent int64_t bytes_sent; /// Audio packets sent int32_t packets_sent; /// Audio packets lost during sending int32_t packets_lost; /// RTT for audio sending with unit of millisecond int64_t round_trip_time; /// Audio codec name for sending std::string codec_name; }; /// Define audio receiver report struct AudioReceiverReport { AudioReceiverReport(int64_t bytes_rcvd, int32_t packets_rcvd, int32_t packets_lost, int32_t estimated_delay, std::string codec_name) : bytes_rcvd(bytes_rcvd), packets_rcvd(packets_rcvd), packets_lost(packets_lost) , estimated_delay(estimated_delay), codec_name(codec_name) {} /// Audio bytes received int64_t bytes_rcvd; /// Audio packets received int32_t packets_rcvd; /// Audio packets lost during receiving int32_t packets_lost; /// Audio delay estimated with unit of millisecond int32_t estimated_delay; /// Audio codec name for receiving std::string codec_name; }; /// Define video sender report struct VideoSenderReport { VideoSenderReport(int64_t bytes_sent, int32_t packets_sent, int32_t packets_lost, int32_t fir_count, int32_t pli_count, int32_t nack_count, int32_t sent_frame_height, int32_t sent_frame_width, int32_t framerate_sent, int32_t last_adapt_reason, int32_t adapt_changes, int64_t round_trip_time, std::string codec_name) : bytes_sent(bytes_sent), packets_sent(packets_sent), packets_lost(packets_lost) , fir_count(fir_count), pli_count(pli_count), nack_count(nack_count), frame_resolution_sent(Resolution(sent_frame_width, sent_frame_height)) , framerate_sent(framerate_sent), last_adapt_reason(last_adapt_reason) , adapt_changes(adapt_changes), round_trip_time(round_trip_time), codec_name(codec_name) {} /// Define adapt reason enum class AdaptReason : int32_t { kUnknown = 0, /// Adapt for CPU limitation kCpuLimitation = 1, /// Adapt for bandwidth limitation kBandwidthLimitation = 2, /// Adapt for view limitation kViewLimitation = 4, }; /// Video bytes sent int64_t bytes_sent; /// Video packets sent int32_t packets_sent; /// Video packets lost during sending int32_t packets_lost; /// Number of FIR received int32_t fir_count; /// Number of PLI received int32_t pli_count; /// Number of NACK received int32_t nack_count; /// Video frame resolution sent Resolution frame_resolution_sent; /// Video framerate sent int32_t framerate_sent; /// Video adapt reason int32_t last_adapt_reason; /// Video adapt changes int32_t adapt_changes; /// RTT for video sending with unit of millisecond int64_t round_trip_time; /// Video codec name for sending std::string codec_name; }; /// Define video receiver report struct VideoReceiverReport { VideoReceiverReport(int64_t bytes_rcvd, int32_t packets_rcvd, int32_t packets_lost, int32_t fir_count, int32_t pli_count, int32_t nack_count, int32_t rcvd_frame_height, int32_t rcvd_frame_width, int32_t framerate_rcvd, int32_t framerate_output, int32_t delay, std::string codec_name, int32_t jitter) : bytes_rcvd(bytes_rcvd), packets_rcvd(packets_rcvd), packets_lost(packets_lost) , fir_count(fir_count), pli_count(pli_count), nack_count(nack_count) , frame_resolution_rcvd(Resolution(rcvd_frame_width, rcvd_frame_height)), framerate_output(framerate_output) , delay(delay), codec_name(codec_name), jitter(jitter) {} /// Video bytes received int64_t bytes_rcvd; /// Video packets received int32_t packets_rcvd; /// Video packets lost during receiving int32_t packets_lost; /// Number of FIR sent int32_t fir_count; /// Number of PLI sent int32_t pli_count; /// Number of PLI sent int32_t nack_count; /// Video frame resolution received Resolution frame_resolution_rcvd; /// Video framerate received int32_t framerate_rcvd; /// Video framerate output int32_t framerate_output; /// Current video delay with unit of millisecond int32_t delay; /// Video codec name for receiving std::string codec_name; /// Packet Jitter measured in milliseconds int32_t jitter; }; /// Define video bandwidth statistoms struct VideoBandwidthStats { VideoBandwidthStats() : available_send_bandwidth(0), available_receive_bandwidth(0) , transmit_bitrate(0), retransmit_bitrate(0) , target_encoding_bitrate(0), actual_encoding_bitrate(0) {} /// Available video bandwidth for sending, unit: bps int32_t available_send_bandwidth; /// Available video bandwidth for receiving, unit: bps int32_t available_receive_bandwidth; /// Video bitrate of transmit, unit: bps int32_t transmit_bitrate; /// Video bitrate of retransmit, unit: bps int32_t retransmit_bitrate; /// Target encoding bitrate, unit: bps int32_t target_encoding_bitrate; /// Actual encoding bitrate, unit: bps int32_t actual_encoding_bitrate; }; /// Define ICE candidate report struct IceCandidateReport { IceCandidateReport(const std::string& id, const std::string& ip, const uint16_t port, TransportProtocolType protocol, IceCandidateType candidate_type, int32_t priority) : id(id), ip(ip), port(port), protocol(protocol), candidate_type(candidate_type), priority(priority) {} virtual ~IceCandidateReport() {} /// The ID of this report std::string id; /// The IP address of the candidate std::string ip; /// The port number of the candidate uint16_t port; /// Transport protocol. TransportProtocolType protocol; /// Candidate type IceCandidateType candidate_type; /// Calculated as defined in RFC5245 int32_t priority; }; /// Define ICE candidate pair report. struct IceCandidatePairReport { IceCandidatePairReport( const std::string& id, const bool is_active, std::shared_ptr<IceCandidateReport> local_ice_candidate, std::shared_ptr<IceCandidateReport> remote_ice_candidate) : id(id), is_active(is_active), local_ice_candidate(local_ice_candidate), remote_ice_candidate(remote_ice_candidate) {} /// The ID of this report. std::string id; /// Indicate whether transport is active. bool is_active; /// Local candidate of this pair. std::shared_ptr<IceCandidateReport> local_ice_candidate; /// Remote candidate of this pair. std::shared_ptr<IceCandidateReport> remote_ice_candidate; }; typedef std::unique_ptr<AudioSenderReport> AudioSenderReportPtr; typedef std::vector<AudioSenderReportPtr> AudioSenderReports; typedef std::unique_ptr<AudioReceiverReport> AudioReceiverReportPtr; typedef std::vector<AudioReceiverReportPtr> AudioReceiverReports; typedef std::unique_ptr<VideoSenderReport> VideoSenderReportPtr; typedef std::vector<VideoSenderReportPtr> VideoSenderReports; typedef std::unique_ptr<VideoReceiverReport> VideoReceiverReportPtr; typedef std::vector<VideoReceiverReportPtr> VideoReceiverReports; typedef std::shared_ptr<IceCandidateReport> IceCandidateReportPtr; typedef std::vector<IceCandidateReportPtr> IceCandidateReports; typedef std::shared_ptr<IceCandidatePairReport> IceCandidatePairPtr; typedef std::vector<IceCandidatePairPtr> IceCandidatePairReports; /// Connection statistoms struct ConnectionStats { ConnectionStats() {} /// Time stamp of connection statistics generation std::chrono::system_clock::time_point time_stamp = std::chrono::system_clock::now(); /// Video bandwidth statistoms VideoBandwidthStats video_bandwidth_stats; /// Audio sender reports AudioSenderReports audio_sender_reports; /// Audio receiver reports AudioReceiverReports audio_receiver_reports; /// Video sender reports VideoSenderReports video_sender_reports; /// Video receiver reports VideoReceiverReports video_receiver_reports; /// Local ICE candidate reports IceCandidateReports local_ice_candidate_reports; /// Remote ICE candidate reports IceCandidateReports remote_ice_candidate_reports; /// ICE candidate pair reports IceCandidatePairReports ice_candidate_pair_reports; }; } // namespace base } // namespace owt #endif // OWT_BASE_CONNECTIONSTATS_H_
39.04868
146
0.662624
[ "object", "vector", "model" ]
0b71259c822a9f2af8d0193c87c98bee3b81f44c
14,229
h
C
test/ring_buffer_test.h
snow1313113/pepper
3803164a5cd75ec9e44733561901828411d0b9f8
[ "MIT" ]
7
2018-07-02T17:32:15.000Z
2022-03-23T07:17:14.000Z
test/ring_buffer_test.h
snow1313113/pepper
3803164a5cd75ec9e44733561901828411d0b9f8
[ "MIT" ]
null
null
null
test/ring_buffer_test.h
snow1313113/pepper
3803164a5cd75ec9e44733561901828411d0b9f8
[ "MIT" ]
null
null
null
/* * * file name: ring_buffer_test.h * * description: ... * * author: snow * * create time:2019 6 01 * */ #ifndef _RING_BUFFER_TEST_H_ #define _RING_BUFFER_TEST_H_ #include <algorithm> #include <cstdlib> #include <iostream> #include <map> #include <set> #include <vector> #include "base_test_struct.h" #include "fixed_ring_buf.h" #include "gtest/gtest.h" #include "unfixed_ring_buf.h" using namespace pepper; using std::map; using std::set; using std::vector; TEST(RingBufferTest, fixed_ring_buffer_1024) { static const size_t MAX_SIZE = 1024; FixedRingBuf<TestNode, MAX_SIZE> ring_buf; ASSERT_TRUE(ring_buf.empty()); ASSERT_FALSE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), 0ul); EXPECT_EQ(ring_buf.capacity(), MAX_SIZE); uint32_t seed = MAX_SIZE; vector<uint32_t> index_2_node; for (size_t i = 1; i <= MAX_SIZE; ++i) { TestNode node; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; ASSERT_TRUE(ring_buf.push(node)); index_2_node.push_back(node.c); } ASSERT_TRUE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), MAX_SIZE); TestNode node; node.a = MAX_SIZE + 1; ASSERT_FALSE(ring_buf.push(node)); for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = ring_buf.front(i - 1); EXPECT_EQ(index_2_node[i - 1], node.c); } for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = ring_buf.back(i - 1); EXPECT_EQ(index_2_node[MAX_SIZE - i], node.c); } ASSERT_TRUE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), MAX_SIZE); for (size_t i = 0; i <= MAX_SIZE / 2; ++i) ring_buf.pop(); EXPECT_EQ(ring_buf.size(), MAX_SIZE - (MAX_SIZE / 2 + 1)); ring_buf.clear(); ASSERT_TRUE(ring_buf.empty()); EXPECT_EQ(ring_buf.size(), 0ul); // 测试循环push index_2_node.clear(); for (size_t i = 1; i <= 2 * MAX_SIZE; ++i) { TestNode node; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; ASSERT_TRUE(ring_buf.push(node, true)); index_2_node.push_back(node.c); } ASSERT_TRUE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), MAX_SIZE); size_t begin_index = index_2_node.size() - ring_buf.size(); for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = ring_buf.front(i - 1); EXPECT_EQ(index_2_node[begin_index + i - 1], node.c); } for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = ring_buf.back(i - 1); EXPECT_EQ(index_2_node[index_2_node.size() - i], node.c); } } // 特化版本的测试 TEST(RingBufferTest, fixed_ring_buffer_0) { static const size_t MAX_SIZE = 1024; FixedRingBuf<TestNode> ring_buf; size_t mem_size = FixedRingBuf<TestNode>::mem_size(MAX_SIZE); auto p = new uint8_t[mem_size]; ASSERT_TRUE(ring_buf.init(p, mem_size)); ASSERT_TRUE(ring_buf.empty()); ASSERT_FALSE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), 0ul); EXPECT_EQ(ring_buf.capacity(), MAX_SIZE); uint32_t seed = MAX_SIZE; vector<uint32_t> index_2_node; for (size_t i = 1; i <= MAX_SIZE; ++i) { TestNode node; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; ASSERT_TRUE(ring_buf.push(node)); index_2_node.push_back(node.c); } ASSERT_TRUE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), MAX_SIZE); TestNode node; node.a = MAX_SIZE + 1; ASSERT_FALSE(ring_buf.push(node)); for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = ring_buf.front(i - 1); EXPECT_EQ(index_2_node[i - 1], node.c); } for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = ring_buf.back(i - 1); EXPECT_EQ(index_2_node[MAX_SIZE - i], node.c); } ASSERT_TRUE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), MAX_SIZE); for (size_t i = 0; i <= MAX_SIZE / 2; ++i) ring_buf.pop(); EXPECT_EQ(ring_buf.size(), MAX_SIZE - (MAX_SIZE / 2 + 1)); ring_buf.clear(); ASSERT_TRUE(ring_buf.empty()); EXPECT_EQ(ring_buf.size(), 0ul); // 测试循环push index_2_node.clear(); for (size_t i = 1; i <= 2 * MAX_SIZE; ++i) { TestNode node; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; ASSERT_TRUE(ring_buf.push(node, true)); index_2_node.push_back(node.c); } ASSERT_TRUE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), MAX_SIZE); // 新的RingBuf对象,测试重新初始化的check参数 FixedRingBuf<TestNode> reinit_ring_buf; size_t new_mem_size = FixedRingBuf<TestNode>::mem_size(MAX_SIZE); ASSERT_TRUE(reinit_ring_buf.init(p, new_mem_size, true)); ASSERT_TRUE(reinit_ring_buf.full()); EXPECT_EQ(reinit_ring_buf.size(), MAX_SIZE); size_t begin_index = index_2_node.size() - reinit_ring_buf.size(); for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = reinit_ring_buf.front(i - 1); EXPECT_EQ(index_2_node[begin_index + i - 1], node.c); } for (size_t i = 1; i <= MAX_SIZE; ++i) { auto& node = reinit_ring_buf.back(i - 1); EXPECT_EQ(index_2_node[index_2_node.size() - i], node.c); } } // 测试不定长元素队列 TEST(RingBufferTest, un_fixed_ring_buffer_1024) { static const size_t MAX_SIZE = 1024; UnfixedRingBuf<MAX_SIZE> ring_buf; ASSERT_TRUE(ring_buf.empty()); ASSERT_FALSE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), 0ul); EXPECT_EQ(ring_buf.capacity(), MAX_SIZE); EXPECT_EQ(ring_buf.get_num(), 0ul); uint32_t seed = MAX_SIZE; vector<uint32_t> index_2_node; size_t max_num = 0; for (size_t i = 1; i <= MAX_SIZE; ++i) { if (i % 3 == 0) { TestNode node; node.base = i; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node)) == false) { max_num = i - 1; break; } index_2_node.push_back(node.c); } else { BaseNode node; node.base = i; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node)) == false) { max_num = i - 1; break; } index_2_node.push_back(0); } } EXPECT_EQ(ring_buf.get_num(), max_num); ASSERT_FALSE(ring_buf.empty()); // 测试front for (size_t i = 1; i <= max_num; ++i) { size_t len = 0; auto data = ring_buf.front(len, i - 1); if (i % 3 == 0) { EXPECT_EQ(len, sizeof(TestNode)); const TestNode* node = reinterpret_cast<const TestNode*>(data); EXPECT_EQ(node->base, node->a); EXPECT_EQ(node->base, i); EXPECT_EQ(index_2_node[i - 1], node->c); } else { EXPECT_EQ(len, sizeof(BaseNode)); const BaseNode* node = reinterpret_cast<const BaseNode*>(data); EXPECT_EQ(node->base, i); } } size_t len = 0; EXPECT_EQ(ring_buf.front(len, max_num), nullptr); for (size_t i = 0; i < (max_num + 1) / 2; ++i) ring_buf.pop(); EXPECT_EQ(ring_buf.get_num(), max_num - (max_num + 1) / 2); ring_buf.clear(); ASSERT_TRUE(ring_buf.empty()); EXPECT_EQ(ring_buf.size(), 0ul); EXPECT_EQ(ring_buf.get_num(), 0ul); // 测试循环push index_2_node.clear(); for (size_t i = 1; i <= 2 * MAX_SIZE; ++i) { if (i % 3 == 0) { TestNode node; node.base = i; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node), true) == false) { max_num = i - 1; break; } index_2_node.push_back(node.c); } else { BaseNode node; node.base = i; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node), true) == false) { max_num = i - 1; break; } index_2_node.push_back(0); } } size_t num = ring_buf.get_num(); size_t begin_index = index_2_node.size() - num; for (size_t i = 1; i <= num; ++i) { size_t len = 0; auto data = ring_buf.front(len, i - 1); if ((i + begin_index) % 3 == 0) { EXPECT_EQ(len, sizeof(TestNode)); const TestNode* node = reinterpret_cast<const TestNode*>(data); EXPECT_EQ(node->base, node->a); EXPECT_EQ(node->base, i + begin_index); EXPECT_EQ(index_2_node[begin_index + i - 1], node->c); } else { EXPECT_EQ(len, sizeof(BaseNode)); const BaseNode* node = reinterpret_cast<const BaseNode*>(data); EXPECT_EQ(node->base, i + begin_index); } } } // 测试不定长元素队列的特化版本 TEST(RingBufferTest, un_fixed_ring_buffer_0) { static const size_t MAX_SIZE = 1024; UnfixedRingBuf<> ring_buf; auto p = new uint8_t[MAX_SIZE]; ASSERT_TRUE(ring_buf.init(p, MAX_SIZE)); ASSERT_TRUE(ring_buf.empty()); ASSERT_FALSE(ring_buf.full()); EXPECT_EQ(ring_buf.size(), 0ul); ASSERT_TRUE(ring_buf.capacity() <= MAX_SIZE); EXPECT_EQ(ring_buf.get_num(), 0ul); uint32_t seed = MAX_SIZE; vector<uint32_t> index_2_node; size_t max_num = 0; for (size_t i = 1; i <= MAX_SIZE; ++i) { if (i % 3 == 0) { TestNode node; node.base = i; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node)) == false) { max_num = i - 1; break; } index_2_node.push_back(node.c); } else { BaseNode node; node.base = i; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node)) == false) { max_num = i - 1; break; } index_2_node.push_back(0); } } EXPECT_EQ(ring_buf.get_num(), max_num); ASSERT_FALSE(ring_buf.empty()); // 测试front for (size_t i = 1; i <= max_num; ++i) { size_t len = 0; auto data = ring_buf.front(len, i - 1); if (i % 3 == 0) { EXPECT_EQ(len, sizeof(TestNode)); const TestNode* node = reinterpret_cast<const TestNode*>(data); EXPECT_EQ(node->base, node->a); EXPECT_EQ(node->base, i); EXPECT_EQ(index_2_node[i - 1], node->c); } else { EXPECT_EQ(len, sizeof(BaseNode)); const BaseNode* node = reinterpret_cast<const BaseNode*>(data); EXPECT_EQ(node->base, i); } } size_t len = 0; EXPECT_EQ(ring_buf.front(len, max_num), nullptr); for (size_t i = 0; i < (max_num + 1) / 2; ++i) ring_buf.pop(); EXPECT_EQ(ring_buf.get_num(), max_num - (max_num + 1) / 2); ring_buf.clear(); ASSERT_TRUE(ring_buf.empty()); EXPECT_EQ(ring_buf.size(), 0ul); EXPECT_EQ(ring_buf.get_num(), 0ul); // 测试循环push index_2_node.clear(); for (size_t i = 1; i <= 2 * MAX_SIZE; ++i) { if (i % 3 == 0) { TestNode node; node.base = i; node.a = i; node.b = rand_r(&seed); node.c = node.a + node.b; node.d = 0; seed = node.b; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node), true) == false) { max_num = i - 1; break; } index_2_node.push_back(node.c); } else { BaseNode node; node.base = i; if (ring_buf.push(reinterpret_cast<uint8_t*>(&node), sizeof(node), true) == false) { max_num = i - 1; break; } index_2_node.push_back(0); } } size_t num = ring_buf.get_num(); size_t begin_index = index_2_node.size() - num; for (size_t i = 1; i <= num; ++i) { size_t len = 0; auto data = ring_buf.front(len, i - 1); if ((i + begin_index) % 3 == 0) { EXPECT_EQ(len, sizeof(TestNode)); const TestNode* node = reinterpret_cast<const TestNode*>(data); EXPECT_EQ(node->base, node->a); EXPECT_EQ(node->base, i + begin_index); EXPECT_EQ(index_2_node[begin_index + i - 1], node->c); } else { EXPECT_EQ(len, sizeof(BaseNode)); const BaseNode* node = reinterpret_cast<const BaseNode*>(data); EXPECT_EQ(node->base, i + begin_index); } } UnfixedRingBuf<> reinit_ring_buf; ASSERT_TRUE(reinit_ring_buf.init(p, MAX_SIZE, true)); EXPECT_EQ(reinit_ring_buf.get_num(), num); for (size_t i = 1; i <= num; ++i) { size_t len = 0; auto data = reinit_ring_buf.front(len, i - 1); if ((i + begin_index) % 3 == 0) { EXPECT_EQ(len, sizeof(TestNode)); const TestNode* node = reinterpret_cast<const TestNode*>(data); EXPECT_EQ(node->base, node->a); EXPECT_EQ(node->base, i + begin_index); EXPECT_EQ(index_2_node[begin_index + i - 1], node->c); } else { EXPECT_EQ(len, sizeof(BaseNode)); const BaseNode* node = reinterpret_cast<const BaseNode*>(data); EXPECT_EQ(node->base, i + begin_index); } } } #endif
27.363462
94
0.534753
[ "vector" ]
0b80270e966121b0ac784300c7bda77b7facc3de
3,476
h
C
valhalla/midgard/linesegment2.h
molind/valhalla
7d4cde8587d38fcb20f7a9ea9df34a8fc49bf68c
[ "BSD-2-Clause", "MIT" ]
79
2017-02-15T17:35:48.000Z
2022-03-30T06:16:10.000Z
valhalla/midgard/linesegment2.h
molind/valhalla
7d4cde8587d38fcb20f7a9ea9df34a8fc49bf68c
[ "BSD-2-Clause", "MIT" ]
null
null
null
valhalla/midgard/linesegment2.h
molind/valhalla
7d4cde8587d38fcb20f7a9ea9df34a8fc49bf68c
[ "BSD-2-Clause", "MIT" ]
12
2017-06-16T06:30:54.000Z
2021-12-16T00:43:12.000Z
#ifndef VALHALLA_MIDGARD_LINESEGMENT2_H_ #define VALHALLA_MIDGARD_LINESEGMENT2_H_ #include <math.h> #include <vector> #include <valhalla/midgard/point2.h> #include <valhalla/midgard/pointll.h> #include <valhalla/midgard/vector2.h> namespace valhalla { namespace midgard { /** * Line segment in 2D. Template class to work with Point2 (Euclidean x,y) * or PointLL (latitude,longitude). */ template <class coord_t> class LineSegment2 { public: /** * Default constructor. */ LineSegment2(); /** * Constructor given 2 points. * @param p1 First point of the segment. * @param p2 Second point of the segment. */ LineSegment2(const coord_t& p1, const coord_t& p2); /** * Get the first point of the segment. * @return Returns first point of the segment. */ coord_t a() const; /** * Get the second point of the segment. * @return Returns second point of the segment. */ coord_t b() const; /** * Finds the distance squared of a specified point from the line segment * and the closest point on the segment to the specified point. * @param p Test point. * @param closest (Return) Closest point on the segment to c. * @return Returns the distance squared from pt to the closest point on * the segment. */ float DistanceSquared(const coord_t& p, coord_t& closest) const; /** * Finds the distance of a specified point from the line segment * and the closest point on the segment to the specified point. * @param p Test point. * @param closest (Return) Closest point on the segment to c. * @return Returns the distance from p to the closest point on * the segment. */ float Distance(const coord_t& p, coord_t& closest) const; /** * Determines if the current segment intersects the specified segment. * If an intersect occurs the intersection is computed. Note: the * case where the lines overlap is not considered. * @param segment Segment to determine intersection with. * @param intersect (OUT) Intersection point. * @return Returns true if an intersection exists, false if not. */ bool Intersect(const LineSegment2<coord_t>& segment, coord_t& intersect) const; /** * Determines if the line segment intersects specified convex polygon. * Based on Cyrus-Beck clipping method. * @param poly A counter-clockwise oriented polygon. * @return Returns true if any part of the segment intersects the polygon, * false if no intersection. */ bool Intersect(const std::vector<coord_t>& poly) const; /** * Clips the line segment to a specified convex polygon. * Based on Cyrus-Beck clipping method. * @param poly A counter-clockwise oriented polygon. * @param clip_segment Returns the clipped segment. * @return Returns true if any part of the segment intersects the polygon, * false if no intersection. */ bool ClipToPolygon(const std::vector<coord_t>& poly, LineSegment2<coord_t>& clip_segment) const; /** * Tests if a point is to left, right, or on the line segment. * @param p Point to test * @return Returns >0 for point to the left, < 0 for point to the right, * and 0 for a point on the line */ float IsLeft(const coord_t& p) const; private: coord_t a_; coord_t b_; }; } } #endif // VALHALLA_MIDGARD_LINESEGMENT2_H_
30.761062
77
0.670598
[ "vector" ]
0b845208a69d2db1a307061814110fe18e2a7121
20,065
c
C
src/nvacq/lockcomm.c
DanIverson/OpenVnmrJ
0db324603dbd8f618a6a9526b9477a999c5a4cc3
[ "Apache-2.0" ]
32
2016-06-17T05:04:26.000Z
2022-03-28T17:54:44.000Z
src/nvacq/lockcomm.c
DanIverson/OpenVnmrJ
0db324603dbd8f618a6a9526b9477a999c5a4cc3
[ "Apache-2.0" ]
128
2016-07-13T17:09:02.000Z
2022-03-28T17:53:52.000Z
src/nvacq/lockcomm.c
DanIverson/OpenVnmrJ
0db324603dbd8f618a6a9526b9477a999c5a4cc3
[ "Apache-2.0" ]
102
2016-01-23T15:27:16.000Z
2022-03-20T05:41:54.000Z
/* * Copyright (C) 2015 University of Oregon * * You may distribute under the terms of either the GNU General Public * License or the Apache License, as specified in the LICENSE file. * * For more information, see the LICENSE file. */ /* */ /* modification history -------------------- 5-05-04,gmb created */ /* DESCRIPTION Lock communication functions */ #ifndef ALLREADY_POSIX #define _POSIX_SOURCE /* defined when source is to be POSIX-compliant */ #endif #include <string.h> #include <vxWorks.h> #include <stdioLib.h> #include <sysLib.h> #include <semLib.h> #include <rngLib.h> #include <msgQLib.h> #include "errorcodes.h" #include "instrWvDefines.h" #include "logMsgLib.h" #include "NDDS_Obj.h" #include "NDDS_PubFuncs.h" #include "NDDS_SubFuncs.h" #include "Lock_Cmd.h" #include "Lock_FID.h" #include "Lock_Stat.h" #ifdef RTI_NDDS_4x #include "Lock_CmdPlugin.h" #include "Lock_FIDPlugin.h" #include "Lock_StatPlugin.h" #include "Lock_CmdSupport.h" #include "Lock_FIDSupport.h" #include "Lock_StatSupport.h" #endif extern NDDS_ID NDDS_Domain; /* extern NDDS_ID pMonitorPub, pMonitorSub; */ /* subscriber to create subscriptions to contoller publications dynamicly */ /* haven't decide who will actually send lock commands host or master, but by using a subscriber and pattern match we can change on the fly */ #ifndef RTI_NDDS_4x static NDDSSubscriber LockCmdSubscriber; #endif /* subscriptions to controller publications */ NDDS_ID pLockCmdSubs[5]; /* Lock FID Pub */ NDDS_ID pLockFIDPub = NULL; Lock_FID *pLkFIDIssue = NULL; /* Lock status Pub */ NDDS_ID pLockStatPub = NULL; Lock_FID *pLkStatIssue = NULL; int numLockCmdSubs = 0; extern int DebugLevel; MSG_Q_ID pMsgesToLockParser = NULL; static int callbackParam = 0; /* * The NDDS callback routine, the routine is call when an issue of the subscribed topic * is delivered. * called with the context of the NDDS task n_rtu7400 * */ #ifndef RTI_NDDS_4x RTIBool Lock_CmdCallback(const NDDSRecvInfo *issue, NDDSInstance *instance, void *callBackRtnParam) { Lock_Cmd *recvIssue; void LockCmdParser(Lock_Cmd *issue); int *param; if (issue->status == NDDS_FRESH_DATA) { recvIssue = (Lock_Cmd *) instance; DPRINT5(-1,"Lock_Cmd CallBack: cmd: %d, arg1: %d, arg2: %d, arg3: %lf, arg4: %lf crc: 0x%lx\n", recvIssue->cmd,recvIssue->arg1, recvIssue->arg2, recvIssue->arg3, recvIssue->arg4); msgQSend(pMsgesToLockParser, (char*) recvIssue, sizeof(Lock_Cmd), NO_WAIT, MSG_PRI_NORMAL); /* LockCmdParser(recvIssue); */ } return RTI_TRUE; } #else /* RTI_NDDS_4x */ /* 4x callback */ void Lock_CmdCallback(void* listener_data, DDS_DataReader* reader) { Lock_Cmd *recvIssue; DDS_ReturnCode_t retcode; DDS_Boolean result; struct DDS_SampleInfoSeq info_seq = DDS_SEQUENCE_INITIALIZER; struct Lock_CmdSeq data_seq = DDS_SEQUENCE_INITIALIZER; struct DDS_SampleInfo* info = NULL; long i,numIssues; Lock_CmdDataReader *LockCmd_reader = NULL; DDS_TopicDescription *topicDesc; LockCmd_reader = Lock_CmdDataReader_narrow(pLockCmdSubs[0]->pDReader); if ( LockCmd_reader == NULL) { errLogRet(LOGIT,debugInfo, "Lock_CmdCallback: DataReader narrow error.\n"); return; } topicDesc = DDS_DataReader_get_topicdescription(reader); DPRINT2(-1,"Lock_CmdCallback; Type: '%s', Name: '%s'\n", DDS_TopicDescription_get_type_name(topicDesc), DDS_TopicDescription_get_name(topicDesc)); while(1) { // Given DDS_HANDLE_NIL as a parameter, take_next_instance returns // a sequence containing samples from only the next (in a well-determined // but unspecified order) un-taken instance. retcode = Lock_CmdDataReader_take_next_instance( LockCmd_reader, &data_seq, &info_seq, DDS_LENGTH_UNLIMITED, &DDS_HANDLE_NIL, DDS_ANY_SAMPLE_STATE, DDS_ANY_VIEW_STATE, DDS_ANY_INSTANCE_STATE); // retcode = Lock_CmdDataReader_take(LockCmd_reader, // &data_seq, &info_seq, // DDS_LENGTH_UNLIMITED, DDS_ANY_SAMPLE_STATE, // DDS_ANY_VIEW_STATE, DDS_ANY_INSTANCE_STATE); if (retcode == DDS_RETCODE_NO_DATA) { break ; // return; } else if (retcode != DDS_RETCODE_OK) { errLogRet(LOGIT,debugInfo, "Lock_CmdCallback: next instance error %d\n",retcode); break ; // return; } numIssues = Lock_CmdSeq_get_length(&data_seq); for (i=0; i < numIssues; i++) { info = DDS_SampleInfoSeq_get_reference(&info_seq, i); if ( info->valid_data) { recvIssue = Lock_CmdSeq_get_reference(&data_seq,i); DPRINT5(-1,"Lock_Cmd CallBack: cmd: %d, arg1: %d, arg2: %d, arg3: %lf, arg4: %lf crc: 0x%lx\n", recvIssue->cmd,recvIssue->arg1, recvIssue->arg2, recvIssue->arg3, recvIssue->arg4); msgQSend(pMsgesToLockParser, (char*) recvIssue, sizeof(Lock_Cmd), NO_WAIT, MSG_PRI_NORMAL); } } retcode = Lock_CmdDataReader_return_loan( LockCmd_reader, &data_seq, &info_seq); DDS_SampleInfoSeq_set_maximum(&info_seq, 0); } // while return; } #endif /* RTI_NDDS_4x */ #ifdef XXX /* * just initial routine to send cmds, not complete yet * not all structure member filled in * */ *LockCmdPub(int cmd,int arg1,int arg2,double arg3, double arg3) *{ * Lock_Cmd *issue; * issue = pLockCmdPub->instance; * issue->cmd = cmd; * issue->arg1 = arg1; * issue->arg2 = arg2; * issue->arg3 = arg3; * issue->arg4 = arg4; * nddsPublishData(pLockCmdPub); *} #endif tstLkMsgQ() { Lock_Cmd tstIssue; tstIssue.cmd = LK_SET_PHASE; tstIssue.arg1 = 180; tstIssue.arg2 = 0; tstIssue.arg3 = 0.0; tstIssue.arg4 = 0.0; msgQSend(pMsgesToLockParser, (char*) &tstIssue, sizeof(Lock_Cmd), NO_WAIT, MSG_PRI_NORMAL); } void LkParser() { Lock_Cmd cmdIssue; int ival; void LockCmdParser(Lock_Cmd *issue); FOREVER { ival = msgQReceive(pMsgesToLockParser,(char*) &cmdIssue,sizeof(Lock_Cmd),WAIT_FOREVER); DPRINT1( 2, "Lkparse: msgQReceive returned %d\n", ival ); if (ival == ERROR) { printf("LOCK PARSER Q ERROR\n"); return; } else { LockCmdParser(&cmdIssue); } } } /* * The LockCmdParser, this is the command interpreter for the lock controller * Any publication to star/lock/cmd pattern will be processed here. * Typical commands are to set the power,gain, phase and frequency. * * Author: Greg Brissey 5/05/04 */ /* static int cmdledtog = 0; */ void LockCmdParser(Lock_Cmd *issue) { int len; int cmd; DPRINT5(-2,"LockCmdParser cmd: %d, arg1: %d, arg2: %d, arg3: %lf, arg4: %lf\n", issue->cmd, issue->arg1,issue->arg2,issue->arg3,issue->arg4); #ifdef NEED_SOME_TOJUST_PULSE_THELED if (cmdledtog) { panelLedOn(2); cmdledtog = 0; } else { panelLedOff(2); cmdledtog = 1; } #endif switch( issue->cmd ) { case LK_SET_GAIN: { DPRINT(-1,"LK_SET_GAIN\n"); setLockGain(issue->arg1); } break; case LK_SET_POWER: { DPRINT(-1,"LK_SET_POWER\n"); setLockPower(issue->arg1); } break; case LK_SET_PHASE: { DPRINT(-1,"LK_SET_PHASE\n"); setLockPhase(issue->arg1); } break; case LK_ON: { DPRINT(-1,"LK_ON\n"); pulser_on(); } break; case LK_OFF: { DPRINT(-1,"LK_OFF\n"); pulser_off(); } break; case LKRATE: { DPRINT1(-1,"LKRATE @ %f",issue->arg3); /* -12 is used as a key, depending on the value of lockpower */ /* If lockpower is 0, use 0, else use 12.0 */ lockRate(issue->arg3,-12.0); } break; case LK_SET_RATE: { DPRINT(-1,"LK_SET_MODE\n"); /* lockRate(double hz, double duty) */ lockRate(issue->arg3, issue->arg4); } break; case LK_SET_FREQ: { DPRINT1(-1,"LK_SET_FREQ %f\n",issue->arg3); /* void setLockDDS(double freq) */ setLockDDS(issue->arg3*1e6); } break; /* was going to put autolock on lock controller, but many things are controller by master and it just makes it simplier at this point to put it on the master GMB 1/6/05 */ #ifdef AUTOLOCK_ON_LOCKCNTLR case LK_AUTOLOCK: { DPRINT3(-1,"LK_AUTOLOCK: Mode: %d, Max. Power: %d, Max. Gain: %d\n",issue->arg1, issue->arg2, (int) issue->arg3); /* do_autolock(mode,maxpower,maxgain); */ /* msgQSend( ); */ } break; #endif default: DPRINT1(-1,"Unknown command: %d\n",issue->cmd); break; } return; } #ifdef NOT_USED_HERE_BUT_IS_IN_MONITOR_C /* * Create a Publication Topic to communicate with the Lock * * Author Greg Brissey 5-06-04 */ NDDS_ID createLockCmdPub(NDDS_ID nddsId, char *topic, char *cntlrName) { int result; NDDS_ID pPubObj; char pubtopic[128]; Lock_Cmd *issue; /* Build Data type Object for both publication and subscription to Expproc */ /* ------- malloc space for data type object --------- */ if ( (pPubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL ) { return(NULL); } /* zero out structure */ memset(pPubObj,0,sizeof(NDDS_OBJ)); memcpy(pPubObj,nddsId,sizeof(NDDS_OBJ)); strcpy(pPubObj->topicName,topic); pPubObj->pubThreadId = 89; /* DEFAULT_PUB_THREADID; */ /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */ getLock_CmdInfo(pPubObj); DPRINT2(-1,"Create Pub topic: '%s' for Cntlr: '%s'\n",pPubObj->topicName,cntlrName); createPublication(pPubObj); issue = (Lock_Cmd *) pPubObj->instance; return(pPubObj); } #endif /* * Create a Subscription Topic to communicate with the Controllers/Master * * Author Greg Brissey 4-26-04 */ NDDS_ID createLockCmdSub(NDDS_ID nddsId, char *topic, void *callbackArg) { NDDS_ID pSubObj; char subtopic[128]; /* Build Data type Object for both publication and subscription to Expproc */ /* ------- malloc space for data type object --------- */ if ( (pSubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL ) { return(NULL); } /* zero out structure */ memset(pSubObj,0,sizeof(NDDS_OBJ)); memcpy(pSubObj,nddsId,sizeof(NDDS_OBJ)); strcpy(pSubObj->topicName,topic); /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */ getLock_CmdInfo(pSubObj); #ifndef RTI_NDDS_4x pSubObj->callBkRtn = Lock_CmdCallback; pSubObj->callBkRtnParam = callbackArg; #endif /* RTI_NDDS_4x */ pSubObj->MulticastSubIP[0] = 0; /* use UNICAST */ #ifdef RTI_NDDS_4x initSubscription(pSubObj); attachOnDataAvailableCallback(pSubObj,Lock_CmdCallback,&callbackArg); #endif /* RTI_NDDS_4x */ createSubscription(pSubObj); return ( pSubObj ); } #ifndef RTI_NDDS_4x /* * The Lock via NDDS uses this callback function to create Subscriptions to the * Host/MAster Lock Command Publications aimed at the Lock Controller * * Author Greg Brissey 5-05-04 */ NDDSSubscription Lock_CmdPatternSubCreate( const char *nddsTopic, const char *nddsType, void *callBackRtnParam) { NDDSSubscription pSub; DPRINT3(-1,"Lock_CmdPatternSubCreate(): Topic: '%s', Type: '%s', arg: 0x%lx\n", nddsTopic, nddsType, callBackRtnParam); DPRINT2(-1,"callbackParam: 0x%lx, callBackRtnParam: 0x%lx\n",&callbackParam,callBackRtnParam); pLockCmdSubs[numLockCmdSubs] = createLockCmdSub(NDDS_Domain, (char*) nddsTopic, (void *) &callbackParam ); pSub = pLockCmdSubs[numLockCmdSubs++]->subscription; return pSub; } /* * Lock creates a pattern subscriber, to dynamicly allow subscription creation * as host/master come on-line and publish to the Lock Parser * * Author Greg Brissey 5-06-04 */ lockCmdPubPatternSub() { LockCmdSubscriber = NddsSubscriberCreate(0); /* Lock subscribe to any publications from controllers */ /* star/lock/cmds */ NddsSubscriberPatternAdd(LockCmdSubscriber, LOCK_SUB_CMDS_PATTERN_TOPIC_STR, Lock_CmdNDDSType , Lock_CmdPatternSubCreate, (void *)callbackParam); } #endif /* RTI_NDDS_4x */ startLockParser(int priority, int taskoptions, int stacksize) { DPRINT1(-1,"sizeof(Lock_Cmd) = %d\n", sizeof(Lock_Cmd)); if (pMsgesToLockParser == NULL) pMsgesToLockParser = msgQCreate(300,sizeof(Lock_Cmd),MSG_Q_PRIORITY); if (pMsgesToLockParser == NULL) { errLogSysRet(LOGIT,debugInfo,"could not create Lock Parser MsgQ, "); return; } if (taskNameToId("tLkParser") == ERROR) taskSpawn("tLkParser",priority,0,stacksize,LkParser,pMsgesToLockParser, 2,3,4,5,6,7,8,9,10); } killLkParser() { int tid; if ((tid = taskNameToId("tLkParser")) != ERROR) taskDelete(tid); } void initialLockComm() { NDDS_ID createLockFIDPub(NDDS_ID nddsId, char *topic); NDDS_ID createLockStatPub(NDDS_ID nddsId, char *topic); #ifndef RTI_NDDS_4x lockCmdPubPatternSub(); #else /* RTI_NDDS_4x */ pLockCmdSubs[0] = createLockCmdSub(NDDS_Domain, LOCK_CMDS_TOPIC_STR, (void *) &callbackParam ); numLockCmdSubs = 1; #endif /* RTI_NDDS_4x */ pLockFIDPub = createLockFIDPub(NDDS_Domain,(char*) LOCK_PUB_FID_TOPIC_FORMAT_STR); pLkFIDIssue = pLockFIDPub->instance; pLockStatPub = createLockStatPub(NDDS_Domain,(char*) LOCK_PUB_STAT_TOPIC_FORMAT_STR); /* StatFilter(); test of ndds filtering */ pLkStatIssue = pLockStatPub->instance; } /* * Create a Best Effort Publication Topic to communicate the Lock FID * Information * * Author Greg Brissey 5-06-04 */ NDDS_ID createLockFIDPub(NDDS_ID nddsId, char *topic) { int result; NDDS_ID pPubObj; char pubtopic[128]; Lock_FID *issue; /* Build Data type Object for both publication and subscription to Expproc */ /* ------- malloc space for data type object --------- */ if ( (pPubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL ) { return(NULL); } /* zero out structure */ memset(pPubObj,0,sizeof(NDDS_OBJ)); memcpy(pPubObj,nddsId,sizeof(NDDS_OBJ)); strcpy(pPubObj->topicName,topic); pPubObj->pubThreadId = 83; /* DEFAULT_PUB_THREADID; */ /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */ getLock_FIDInfo(pPubObj); DPRINT1(-1,"createLockFIDPub: topic: '%s' \n",pPubObj->topicName); #ifndef RTI_NDDS_4x createBEPublication(pPubObj); /* issue = (Lock_FID *) pPubObj->instance; */ #else /* RTI_NDDS_4x */ initBEPublication(pPubObj); createPublication(pPubObj); #endif /* RTI_NDDS_4x */ return(pPubObj); } #ifndef RTI_NDDS_4x void pubLkFID() { if (pLockFIDPub != NULL) nddsPublishData(pLockFIDPub); } #else /* RTI_NDDS_4x */ int pubLkFID(short *pData, int sizeInShorts) { DDS_ReturnCode_t result; DDS_InstanceHandle_t instance_handle = DDS_HANDLE_NIL; Lock_FIDDataWriter *LockFID_writer = NULL; Lock_FID *issue; if (pLockFIDPub != NULL) { LockFID_writer = Lock_FIDDataWriter_narrow(pLockFIDPub->pDWriter); if (LockFID_writer == NULL) { errLogRet(LOGIT,debugInfo, "pubLkFID: DataReader narrow error.\n"); return -1; } issue = (Lock_FID*) pLockFIDPub->instance; // DDS_ShortSeq_from_array(&(issue->lkfid), pData, sizeInShorts); DDS_ShortSeq_set_maximum(&(issue->lkfid),0); DDS_ShortSeq_loan_contiguous(&(issue->lkfid), (short*) pData, sizeInShorts, sizeInShorts ); // DDS_ShortSeq_set_length(&(issue->lkfid), sizeInShorts); DPRINT(+4,"publish Lock_FID data\n"); result = Lock_FIDDataWriter_write(LockFID_writer, pLockFIDPub->instance,&instance_handle); if (result != DDS_RETCODE_OK) { errLogRet(LOGIT,debugInfo, "pubLkFID: write error %d\n",result); } DDS_ShortSeq_unloan(&(issue->lkfid)); } return 0; } tstLkFidPub() { short data[512]; int i; for(i=0;i<512;i++) data[i] = i; pubLkFID(data, 512); } #endif /* RTI_NDDS_4x */ /* * Create a Best Effort Publication Topic to communicate the Lock Stat * Information * */ NDDS_ID createLockStatPub(NDDS_ID nddsId, char *topic) { int result; NDDS_ID pPubObj; char pubtopic[128]; /* Build Data type Object for both publication and subscription to Expproc */ /* ------- malloc space for data type object --------- */ if ( (pPubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL ) { return(NULL); } /* zero out structure */ memset(pPubObj,0,sizeof(NDDS_OBJ)); memcpy(pPubObj,nddsId,sizeof(NDDS_OBJ)); strcpy(pPubObj->topicName,topic); pPubObj->pubThreadId = 97; /* DEFAULT_PUB_THREADID; */ /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */ getLock_StatInfo(pPubObj); DPRINT1(-1,"createLockStatPub: topic: '%s' \n",pPubObj->topicName); #ifndef RTI_NDDS_4x createBEPublication(pPubObj); #else /* RTI_NDDS_4x */ initBEPublication(pPubObj); createPublication(pPubObj); #endif /* RTI_NDDS_4x */ return(pPubObj); } #ifdef NDDS_SENDBEFORERTN_AFTERSENDRTN static ledtoggle = 0; RTIBool ledToggle(const char *nddsTopic, const char *nddsType, NDDSInstance *instance, void *beforeRtnParam) { int led; led = *((int *) beforeRtnParam); if (ledtoggle) { panelLedOn(2); ledtoggle = 0; } else { panelLedOff(2); ledtoggle = 1; } return RTI_TRUE; } static ledtog = 0; RTIBool led3Toggle(const char *nddsTopic, const char *nddsType, NDDSInstance *instance, void *beforeRtnParam) { if (ledtog) { panelLedOn(4); ledtog = 0; } else { panelLedOff(4); ledtog = 1; } return RTI_TRUE; } StatFilter() { NDDSPublicationListener listener; NddsPublicationListenerDefaultGet(&listener); listener.sendBeforeRtn = ledToggle; listener.afterSendRtn = led3Toggle; NddsPublicationListenerSet((pLockStatPub->publication), &listener); } #endif SEM_ID pSemLockStatPub; void startLockStatPub(int priority, int options, int stackSize) { void LockStatPublisher(); int LSP; if (pSemLockStatPub == 0) pSemLockStatPub = semBCreate(SEM_Q_FIFO,SEM_EMPTY); LSP = taskSpawn("LockStatPub",priority,options,stackSize, (void *)LockStatPublisher,0,0,0,0,0,0,0,0,0,0); if (LSP == ERROR) { perror("taskSpawn LSP"); semDelete(pSemLockStatPub); } } #ifdef RTI_NDDS_4x // helper function for routine below int pubLockStat(NDDS_ID pNDDS_Obj) { DDS_ReturnCode_t result; DDS_InstanceHandle_t instance_handle = DDS_HANDLE_NIL; Lock_StatDataWriter *LockStat_writer = NULL; if (pNDDS_Obj != NULL) { LockStat_writer = Lock_StatDataWriter_narrow(pNDDS_Obj->pDWriter); if (LockStat_writer == NULL) { errLogRet(LOGIT,debugInfo, "pubLockStat: DataReader narrow error.\n"); return -1; } result = Lock_StatDataWriter_write(LockStat_writer, pNDDS_Obj->instance,&instance_handle); if (result != DDS_RETCODE_OK) { errLogRet(LOGIT,debugInfo, "pubLockStat: write error %d\n",result); } } } #endif /* RTI_NDDS_4x */ void LockStatPublisher() { FOREVER { semTake(pSemLockStatPub, WAIT_FOREVER); if (pLockStatPub != NULL) #ifndef RTI_NDDS_4x nddsPublishData(pLockStatPub); #else /* RTI_NDDS_4x */ pubLockStat(pLockStatPub); #endif /* RTI_NDDS_4x */ } } void pubLkStat() { semGive(pSemLockStatPub); }
27.411202
125
0.650885
[ "object" ]
0b884d37e720c3f5bb8b16f4cabb4988909bdade
6,626
c
C
src/functions_cuda.c
rachtsingh/lgamma
d6db8585bd1471081b6111f9382648fcbd9eb347
[ "MIT" ]
24
2017-05-23T11:50:01.000Z
2020-07-15T03:20:07.000Z
src/functions_cuda.c
bringingjoy/lgamma
d6db8585bd1471081b6111f9382648fcbd9eb347
[ "MIT" ]
3
2017-05-26T17:50:50.000Z
2017-11-20T02:33:28.000Z
src/functions_cuda.c
bringingjoy/lgamma
d6db8585bd1471081b6111f9382648fcbd9eb347
[ "MIT" ]
6
2018-04-06T06:24:39.000Z
2021-08-29T03:08:04.000Z
#include <THC/THC.h> #include <stdbool.h> #include <stdio.h> #include "functions_cuda_kernel.h" #define real float extern THCState *state; int polygamma_cuda(int n, THCudaTensor *input, THCudaTensor *output) { float *input_data, *output_data; input_data = THCudaTensor_data(state, input); output_data = THCudaTensor_data(state, output); int input_strideHeight = THCudaTensor_stride(state, input, 0); int input_strideWidth = THCudaTensor_stride(state, input, 1); int output_strideHeight = THCudaTensor_stride(state, output, 0); int output_strideWidth = THCudaTensor_stride(state, output, 1); int height = THCudaTensor_size(state, input, 0); int width = THCudaTensor_size(state, input, 1); if (input->nDimension != 2) { printf("Warning: polygamma input is supposed to be 2-dimensional\n"); } int error = 0; error = polygamma_cuda_wrapped(n, input_strideHeight, input_strideWidth, output_strideHeight, output_strideWidth, height, width, input_data, output_data); if (error) { THError("aborting, cuda kernel failed.\n"); } return 0; } int polygamma_cuda_dbl(int n, THCudaDoubleTensor *input, THCudaDoubleTensor *output) { double *input_data, *output_data; input_data = THCudaDoubleTensor_data(state, input); output_data = THCudaDoubleTensor_data(state, output); int input_strideHeight = THCudaDoubleTensor_stride(state, input, 0); int input_strideWidth = THCudaDoubleTensor_stride(state, input, 1); int output_strideHeight = THCudaDoubleTensor_stride(state, output, 0); int output_strideWidth = THCudaDoubleTensor_stride(state, output, 1); int height = THCudaDoubleTensor_size(state, input, 0); int width = THCudaDoubleTensor_size(state, input, 1); if (input->nDimension != 2) { printf("Warning: polygamma input is supposed to be 2-dimensional\n"); } int error = 0; error = polygamma_cuda_dbl_wrapped(n, input_strideHeight, input_strideWidth, output_strideHeight, output_strideWidth, height, width, input_data, output_data); if (error) { THError("aborting, cuda kernel failed.\n"); } return 0; } int lgamma_cuda(THCudaTensor *input, THCudaTensor *output) { float *input_data, *output_data; input_data = THCudaTensor_data(state, input); output_data = THCudaTensor_data(state, output); int input_strideHeight = THCudaTensor_stride(state, input, 0); int input_strideWidth = THCudaTensor_stride(state, input, 1); int output_strideHeight = THCudaTensor_stride(state, output, 0); int output_strideWidth = THCudaTensor_stride(state, output, 1); int height = THCudaTensor_size(state, input, 0); int width = THCudaTensor_size(state, input, 1); if (input->nDimension != 2) { printf("Warning: polygamma input is supposed to be 2-dimensional\n"); } int error = 0; error = lgamma_cuda_wrapped(input_strideHeight, input_strideWidth, output_strideHeight, output_strideWidth, height, width, input_data, output_data); if (error) { THError("aborting, cuda kernel failed.\n"); } return 0; } int lgamma_cuda_dbl(THCudaDoubleTensor *input, THCudaDoubleTensor *output) { double *input_data, *output_data; input_data = THCudaDoubleTensor_data(state, input); output_data = THCudaDoubleTensor_data(state, output); int input_strideHeight = THCudaDoubleTensor_stride(state, input, 0); int input_strideWidth = THCudaDoubleTensor_stride(state, input, 1); int output_strideHeight = THCudaDoubleTensor_stride(state, output, 0); int output_strideWidth = THCudaDoubleTensor_stride(state, output, 1); int height = THCudaDoubleTensor_size(state, input, 0); int width = THCudaDoubleTensor_size(state, input, 1); if (input->nDimension != 2) { printf("Warning: polygamma input is supposed to be 2-dimensional\n"); } int error = 0; error = lgamma_cuda_dbl_wrapped(input_strideHeight, input_strideWidth, output_strideHeight, output_strideWidth, height, width, input_data, output_data); if (error) { THError("aborting, cuda kernel failed.\n"); } return 0; } int lbeta_cuda(THCudaTensor *a, THCudaTensor *b, THCudaTensor *output) { float *a_data, *b_data, *output_data; a_data = THCudaTensor_data(state, a); b_data = THCudaTensor_data(state, b); output_data = THCudaTensor_data(state, output); int a_strideHeight = THCudaTensor_stride(state, a, 0); int a_strideWidth = THCudaTensor_stride(state, a, 1); int b_strideHeight = THCudaTensor_stride(state, b, 0); int b_strideWidth = THCudaTensor_stride(state, b, 1); int output_strideHeight = THCudaTensor_stride(state, output, 0); int output_strideWidth = THCudaTensor_stride(state, output, 1); int height = THCudaTensor_size(state, a, 0); int width = THCudaTensor_size(state, a, 1); if (a->nDimension != 2 || b->nDimension != 2) { THError("Error: polygamma input is supposed to be 2-dimensional\n"); } if (THCudaTensor_size(state, b, 0) != height || THCudaTensor_size(state, b, 1) != width) { THError("Error: a and b are not the same shape.\n"); } int error = 0; error = lbeta_cuda_wrapped(a_strideHeight, a_strideWidth, b_strideHeight, b_strideWidth, output_strideHeight, output_strideWidth, height, width, a_data, b_data, output_data); if (error) { THError("aborting, cuda kernel failed.\n"); } return 0; } int lbeta_cuda_dbl(THCudaDoubleTensor *a, THCudaDoubleTensor *b, THCudaDoubleTensor *output) { double *a_data, *b_data, *output_data; a_data = THCudaDoubleTensor_data(state, a); b_data = THCudaDoubleTensor_data(state, b); output_data = THCudaDoubleTensor_data(state, output); int a_strideHeight = THCudaDoubleTensor_stride(state, a, 0); int a_strideWidth = THCudaDoubleTensor_stride(state, a, 1); int b_strideHeight = THCudaDoubleTensor_stride(state, b, 0); int b_strideWidth = THCudaDoubleTensor_stride(state, b, 1); int output_strideHeight = THCudaDoubleTensor_stride(state, output, 0); int output_strideWidth = THCudaDoubleTensor_stride(state, output, 1); int height = THCudaDoubleTensor_size(state, a, 0); int width = THCudaDoubleTensor_size(state, a, 1); if (a->nDimension != 2 || b->nDimension != 2) { THError("Error: polygamma input is supposed to be 2-dimensional\n"); } if (THCudaDoubleTensor_size(state, b, 0) != height || THCudaDoubleTensor_size(state, b, 1) != width) { THError("Error: a and b are not the same shape.\n"); } int error = 0; error = lbeta_cuda_dbl_wrapped(a_strideHeight, a_strideWidth, b_strideHeight, b_strideWidth, output_strideHeight, output_strideWidth, height, width, a_data, b_data, output_data); if (error) { THError("aborting, cuda kernel failed.\n"); } return 0; }
36.607735
180
0.741322
[ "shape" ]
0b8f00ac45c435eb72a87d1f587d3e50946b36c2
2,644
h
C
widgets/sqlcombobox.h
phetaduck/SqlViewGenerator
a0599cce5a2e378ef02c7ad60611ba668e43d6a4
[ "MIT" ]
null
null
null
widgets/sqlcombobox.h
phetaduck/SqlViewGenerator
a0599cce5a2e378ef02c7ad60611ba668e43d6a4
[ "MIT" ]
null
null
null
widgets/sqlcombobox.h
phetaduck/SqlViewGenerator
a0599cce5a2e378ef02c7ad60611ba668e43d6a4
[ "MIT" ]
null
null
null
#pragma once #include <QComboBox> #include <QSqlRelation> #include "utils/modelmanager.h" class SqlTableModel; /** * @class SqlComboBox * комбо бокс для работы с произвольной таблицей базы данных * работа настраивается через QSqlRelation * QSqlRelation::tableName() имя таблицы * QSqlRelation::indexColumn() столбец возвращаемого значения * QSqlRelation::displayColumn() стобец отображаемого значения */ class SqlComboBox : public QComboBox { Q_OBJECT Q_PROPERTY(QVariant data READ data WRITE setData); Q_PROPERTY(QSqlRelation sqlRelation READ sqlRelation WRITE setSqlRelation NOTIFY sqlRelationChanged) public: /** @brief Наследование конструкторов базового класса*/ using QComboBox::QComboBox; /** @brief Перегруженный метод базового класса*/ void setModel(QAbstractItemModel* model); /** @brief Выбранный элемент * @return индекс выбранного элемента */ virtual QModelIndex selectedIndex() const; /** @brief Выбранный элемент * @param column столбец на который будет указывать индекс * @return индекс выбранного элемента */ virtual QModelIndex selectedIndex(int column) const; /** @brief Выбранный элемент * @param fieldName название столбеца на который будет указывать индекс * @return индекс выбранного элемента */ virtual QModelIndex selectedIndex(const QString& fieldName) const; /** @brief Выбрать элемент * @param data данные которые нужно найти в таблице */ void setSelectedIndex(const QVariant& data); void setCurrentIndex(int index); void setCurrentText(const QString &text); /** @brief SQL Модель данных * @return SQL модель в возможностью поиска, может быть nullptr */ virtual SqlTableModel* sqlModel(); /** @brief getter отношения */ virtual auto sqlRelation() const -> const QSqlRelation&; /** @brief setter отношения и модели */ virtual void setSqlData(SqlTableModel* sqlModel, const QSqlRelation& sqlRelation); /** @brief getter Выбранный элемент */ virtual QVariant data(); /** @brief setter Выбранный элемент */ virtual void setData(const QVariant& data); void setSqlModel(SqlTableModel* sqlModel); public slots: void setSqlRelation(const QSqlRelation& sqlRelation); signals: void sqlRelationChanged(QSqlRelation sqlRelation); protected: QSqlRelation m_sqlRelation; ///< отношение в реляционной таблице SqlTableModel* m_sqlModel = nullptr; ///< SQL модель в возможностью поиска int m_lastSelectedIndex = -1; QString m_lastSelectedItem = {}; QVariant m_lastSelectedData = {}; };
29.707865
104
0.718608
[ "model" ]
0b8fc7120803e27d7e3309f72f38f5e83160cda4
815
h
C
kernel/include/graphics/SoftMaskDictionary.h
Hydrorastaman/PDFOut-SDK
329e08068f96c1623493ed4ddb292a333f668762
[ "MIT" ]
4
2021-03-23T15:04:08.000Z
2021-08-28T08:08:14.000Z
kernel/include/graphics/SoftMaskDictionary.h
Hydrorastaman/PDFOut-SDK
329e08068f96c1623493ed4ddb292a333f668762
[ "MIT" ]
null
null
null
kernel/include/graphics/SoftMaskDictionary.h
Hydrorastaman/PDFOut-SDK
329e08068f96c1623493ed4ddb292a333f668762
[ "MIT" ]
null
null
null
#pragma once #include <object/ObjectDictionary.h> namespace kernel{ enum SoftMaskDictionaryKey{ SoftMaskDictionaryKeyS, // Required SoftMaskDictionaryKeyG, // Required SoftMaskDictionaryKeyBC, // Optional SoftMaskDictionaryKeyTR // Optional }; class SoftMaskDictionary : public ObjectDictionary{ public: SoftMaskDictionary(void); ~SoftMaskDictionary(void); void addKey(SoftMaskDictionaryKey key, std::unique_ptr<Object> value); SoftMaskDictionary *clone(void) const; private: static std::unordered_map<SoftMaskDictionaryKey, std::pair<std::string, uint32_t>> mSoftMaskDictionaryMap; private: SoftMaskDictionary(SoftMaskDictionary const &obj); SoftMaskDictionary &operator=(SoftMaskDictionary const &) = delete; }; }
26.290323
111
0.722699
[ "object" ]