hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
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
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
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
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
02886c0d5b3d2ef911ea028d4e50894471323041
6,248
cpp
C++
platform-abstractions/tizen/resource-loader/resource-thread-image.cpp
pwisbey/dali-adaptor
21d5e77316e53285fa1e210a93b13cf9889e3b54
[ "Apache-2.0" ]
null
null
null
platform-abstractions/tizen/resource-loader/resource-thread-image.cpp
pwisbey/dali-adaptor
21d5e77316e53285fa1e210a93b13cf9889e3b54
[ "Apache-2.0" ]
null
null
null
platform-abstractions/tizen/resource-loader/resource-thread-image.cpp
pwisbey/dali-adaptor
21d5e77316e53285fa1e210a93b13cf9889e3b54
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * 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. * */ // CLASS HEADER #include "resource-thread-image.h" // EXTERNAL INCLUDES #include <dali/devel-api/common/ref-counted-dali-vector.h> #include <dali/integration-api/bitmap.h> #include <dali/integration-api/debug.h> #include <dali/integration-api/resource-cache.h> #include <dali/integration-api/resource-types.h> // INTERNAL INCLUDES #include "portable/file-closer.h" #include "image-loaders/image-loader.h" #include "network/file-download.h" using namespace Dali::Integration; namespace Dali { namespace TizenPlatform { namespace { // limit maximum image down load size to 50 MB const size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024 ; } ResourceThreadImage::ResourceThreadImage(ResourceLoader& resourceLoader) : ResourceThreadBase(resourceLoader) { } ResourceThreadImage::~ResourceThreadImage() { } void ResourceThreadImage::Load(const ResourceRequest& request) { DALI_LOG_TRACE_METHOD( mLogFilter ); DALI_LOG_INFO( mLogFilter, Debug::Verbose, "%s(%s)\n", __FUNCTION__, request.GetPath().c_str() ); LoadImageFromLocalFile(request); } void ResourceThreadImage::Download(const ResourceRequest& request) { bool succeeded; DALI_LOG_TRACE_METHOD( mLogFilter ); DALI_LOG_INFO( mLogFilter, Debug::Verbose, "%s(%s)\n", __FUNCTION__, request.GetPath().c_str() ); Dali::Vector<uint8_t> dataBuffer; size_t dataSize; succeeded = DownloadRemoteImageIntoMemory( request, dataBuffer, dataSize ); if( succeeded ) { DecodeImageFromMemory(static_cast<void*>(&dataBuffer[0]), dataBuffer.Size(), request); } } void ResourceThreadImage::Decode(const ResourceRequest& request) { DALI_LOG_TRACE_METHOD( mLogFilter ); DALI_LOG_INFO(mLogFilter, Debug::Verbose, "%s(%s)\n", __FUNCTION__, request.GetPath().c_str()); // Get the blob of binary data that we need to decode: DALI_ASSERT_DEBUG( request.GetResource() ); DALI_ASSERT_DEBUG( 0 != dynamic_cast<Dali::RefCountedVector<uint8_t>*>( request.GetResource().Get() ) && "Only blobs of binary data can be decoded." ); Dali::RefCountedVector<uint8_t>* const encodedBlob = reinterpret_cast<Dali::RefCountedVector<uint8_t>*>( request.GetResource().Get() ); if( 0 != encodedBlob ) { const size_t blobSize = encodedBlob->GetVector().Size(); uint8_t * const blobBytes = &(encodedBlob->GetVector()[0]); DecodeImageFromMemory(blobBytes, blobSize, request); } else { FailedResource resource(request.GetId(), FailureUnknown); mResourceLoader.AddFailedLoad(resource); } } bool ResourceThreadImage::DownloadRemoteImageIntoMemory(const Integration::ResourceRequest& request, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize) { bool ok = Network::DownloadRemoteFileIntoMemory( request.GetPath(), dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE ); if( !ok ) { FailedResource resource(request.GetId(), FailureUnknown); mResourceLoader.AddFailedLoad(resource); } return ok; } void ResourceThreadImage::LoadImageFromLocalFile(const Integration::ResourceRequest& request) { bool fileNotFound = false; BitmapPtr bitmap = 0; bool result = false; Dali::Internal::Platform::FileCloser fileCloser( request.GetPath().c_str(), "rb" ); FILE * const fp = fileCloser.GetFile(); if( NULL != fp ) { result = ImageLoader::ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, *this, bitmap ); // Last chance to interrupt a cancelled load before it is reported back to clients // which have already stopped tracking it: InterruptionPoint(); // Note: This can throw an exception. if( result && bitmap ) { // Construct LoadedResource and ResourcePointer for image data LoadedResource resource( request.GetId(), request.GetType()->id, ResourcePointer( bitmap.Get() ) ); // Queue the loaded resource mResourceLoader.AddLoadedResource( resource ); } else { DALI_LOG_WARNING( "Unable to decode %s\n", request.GetPath().c_str() ); } } else { DALI_LOG_WARNING( "Failed to open file to load \"%s\"\n", request.GetPath().c_str() ); fileNotFound = true; } if ( !bitmap ) { if( fileNotFound ) { FailedResource resource(request.GetId(), FailureFileNotFound ); mResourceLoader.AddFailedLoad(resource); } else { FailedResource resource(request.GetId(), FailureUnknown); mResourceLoader.AddFailedLoad(resource); } } } void ResourceThreadImage::DecodeImageFromMemory(void* blobBytes, size_t blobSize, const Integration::ResourceRequest& request) { BitmapPtr bitmap = 0; DALI_ASSERT_DEBUG( blobSize > 0U ); DALI_ASSERT_DEBUG( blobBytes != 0U ); if( blobBytes != 0 && blobSize > 0U ) { // Open a file handle on the memory buffer: Dali::Internal::Platform::FileCloser fileCloser( blobBytes, blobSize, "rb" ); FILE * const fp = fileCloser.GetFile(); if ( NULL != fp ) { bool result = ImageLoader::ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, StubbedResourceLoadingClient(), bitmap ); if ( result && bitmap ) { // Construct LoadedResource and ResourcePointer for image data LoadedResource resource( request.GetId(), request.GetType()->id, ResourcePointer( bitmap.Get() ) ); // Queue the loaded resource mResourceLoader.AddLoadedResource( resource ); } else { DALI_LOG_WARNING( "Unable to decode bitmap supplied as in-memory blob.\n" ); } } } if (!bitmap) { FailedResource resource(request.GetId(), FailureUnknown); mResourceLoader.AddFailedLoad(resource); } } } // namespace TizenPlatform } // namespace Dali
30.778325
153
0.711908
pwisbey
028e5ec97bbaec3a476e32481d2a4f6b93c99e52
5,701
cpp
C++
src/Settings/RunawaySourceTerms.cpp
chalmersplasmatheory/DREAM
715637ada94f5e35db16f23c2fd49bb7401f4a27
[ "MIT" ]
12
2020-09-07T11:19:10.000Z
2022-02-17T17:40:19.000Z
src/Settings/RunawaySourceTerms.cpp
chalmersplasmatheory/DREAM
715637ada94f5e35db16f23c2fd49bb7401f4a27
[ "MIT" ]
110
2020-09-02T15:29:24.000Z
2022-03-09T09:50:01.000Z
src/Settings/RunawaySourceTerms.cpp
chalmersplasmatheory/DREAM
715637ada94f5e35db16f23c2fd49bb7401f4a27
[ "MIT" ]
3
2021-05-21T13:24:31.000Z
2022-02-11T14:43:12.000Z
/** * Initialization of runaway source terms. */ #include "DREAM/Equations/Fluid/TritiumRateTerm.hpp" #include "DREAM/Equations/Fluid/HottailRateTermHighZ.hpp" #include "DREAM/Equations/Fluid/ExternalAvalancheTerm.hpp" #include "DREAM/Equations/RunawaySourceTerm.hpp" #include "DREAM/IO.hpp" #include "DREAM/Settings/SimulationGenerator.hpp" using namespace DREAM; RunawaySourceTermHandler *SimulationGenerator::ConstructRunawaySourceTermHandler( FVM::Grid *grid, FVM::Grid *hottailGrid, FVM::Grid *runawayGrid, FVM::Grid *fluidGrid, FVM::UnknownQuantityHandler *unknowns, RunawayFluid *REFluid, IonHandler *ions, AnalyticDistributionHottail *distHT, struct OtherQuantityHandler::eqn_terms *oqty_terms, Settings *s, bool signPositive ) { const std::string &mod = "eqsys/n_re"; std::string eqnSign = signPositive ? " + " : " - "; RunawaySourceTermHandler *rsth = new RunawaySourceTermHandler(); // Add avalanche growth rate: // - fluid mode, use analytical growth rate formula, // - kinetic mode, add those knockons which are created for p>pMax OptionConstants::eqterm_avalanche_mode ava_mode = (enum OptionConstants::eqterm_avalanche_mode)s->GetInteger(mod + "/avalanche"); // Add avalanche growth rate if (ava_mode == OptionConstants::EQTERM_AVALANCHE_MODE_FLUID || ava_mode == OptionConstants::EQTERM_AVALANCHE_MODE_FLUID_HESSLOW) rsth->AddSourceTerm(eqnSign + "n_re*Gamma_ava", new AvalancheGrowthTerm(grid, unknowns, REFluid, fluidGrid, -1.0) ); else if (ava_mode == OptionConstants::EQTERM_AVALANCHE_MODE_KINETIC) { if (hottailGrid || runawayGrid != nullptr) { // XXX: assume same momentum grid at all radii real_t pCut; if (hottailGrid != nullptr) pCut = hottailGrid->GetMomentumGrid(0)->GetP1_f(hottailGrid->GetNp1(0)); else if (runawayGrid != nullptr) pCut = runawayGrid->GetMomentumGrid(0)->GetP1_f(0); if (grid == runawayGrid) { rsth->AddSourceTerm(eqnSign + "external avalanche", new AvalancheSourceRP(grid, unknowns, pCut, -1.0, AvalancheSourceRP::RP_SOURCE_MODE_KINETIC, AvalancheSourceRP::RP_SOURCE_PITCH_POSITIVE) ); rsth->AddAvalancheNreNeg(new AvalancheSourceRP(grid, unknowns, pCut, +1.0, AvalancheSourceRP::RP_SOURCE_MODE_KINETIC, AvalancheSourceRP::RP_SOURCE_PITCH_POSITIVE)); rsth->AddAvalancheNreNegPos(new AvalancheSourceRP(grid, unknowns, pCut, -1.0, AvalancheSourceRP::RP_SOURCE_MODE_KINETIC, AvalancheSourceRP::RP_SOURCE_PITCH_NEGATIVE)); } else if (grid == fluidGrid){ if(runawayGrid == nullptr) // match external growth to fluid formula in E~<Eceff limit rsth->AddSourceTerm(eqnSign + "external avalanche", new ExternalAvalancheTerm(grid, pCut, -2.0, REFluid, unknowns, -1.0) ); else // use regular external RE growth (RP integrated over p>pCut) rsth->AddSourceTerm(eqnSign + "external avalanche", new AvalancheSourceRP(grid, unknowns, pCut, -1.0, AvalancheSourceRP::RP_SOURCE_MODE_FLUID) ); } } else DREAM::IO::PrintWarning(DREAM::IO::WARNING_KINETIC_AVALANCHE_NO_HOT_GRID, "A kinetic avalanche term is used, but the hot-tail grid is disabled. Ignoring avalanche source..."); } // Add Dreicer runaway rate enum OptionConstants::eqterm_dreicer_mode dm = (enum OptionConstants::eqterm_dreicer_mode)s->GetInteger(mod + "/dreicer"); switch (dm) { case OptionConstants::EQTERM_DREICER_MODE_CONNOR_HASTIE_NOCORR: rsth->AddSourceTerm(eqnSign + "dreicer (CH)", new DreicerRateTerm( grid, unknowns, REFluid, ions, DreicerRateTerm::CONNOR_HASTIE_NOCORR, -1.0 )); break; case OptionConstants::EQTERM_DREICER_MODE_CONNOR_HASTIE: rsth->AddSourceTerm(eqnSign + "dreicer (CH)", new DreicerRateTerm( grid, unknowns, REFluid, ions, DreicerRateTerm::CONNOR_HASTIE, -1.0 )); break; case OptionConstants::EQTERM_DREICER_MODE_NEURAL_NETWORK: rsth->AddSourceTerm(eqnSign + "dreicer (NN)", new DreicerRateTerm( grid, unknowns, REFluid, ions, DreicerRateTerm::NEURAL_NETWORK, -1.0 )); break; default: break; // Don't add Dreicer runaways } // Add compton source OptionConstants::eqterm_compton_mode compton_mode = (enum OptionConstants::eqterm_compton_mode)s->GetInteger(mod + "/compton/mode"); if (compton_mode == OptionConstants::EQTERM_COMPTON_MODE_FLUID) rsth->AddSourceTerm(eqnSign + "compton", new ComptonRateTerm(grid, unknowns, REFluid, fluidGrid, -1.0) ); // Add tritium source bool tritium_enabled = s->GetBool(mod + "/tritium"); if (tritium_enabled) { const len_t *ti = ions->GetTritiumIndices(); for (len_t i = 0; i < ions->GetNTritiumIndices(); i++) rsth->AddSourceTerm(eqnSign + "tritium", new TritiumRateTerm(grid, ions, unknowns, ti[i], REFluid, -1.0)); } // Add hottail source OptionConstants::eqterm_hottail_mode hottail_mode = (enum OptionConstants::eqterm_hottail_mode)s->GetInteger(mod + "/hottail"); if(distHT!=nullptr && hottail_mode == OptionConstants::EQTERM_HOTTAIL_MODE_ANALYTIC_ALT_PC){ oqty_terms->n_re_hottail_rate = new HottailRateTermHighZ( grid, distHT, unknowns, ions, REFluid->GetLnLambda(), -1.0 ); rsth->AddSourceTerm(eqnSign + "hottail", oqty_terms->n_re_hottail_rate); } return rsth; }
50.008772
208
0.6776
chalmersplasmatheory
028e7cbdf1e43feb8ada7ee6eef1eac47839e56c
13,358
cpp
C++
source/Bit/System/Bencode/BencodeValue.cpp
jimmiebergmann/Bit-Engine
39324a9e7fb5ab4b1cf3738f871470e0a9ef7575
[ "Zlib" ]
null
null
null
source/Bit/System/Bencode/BencodeValue.cpp
jimmiebergmann/Bit-Engine
39324a9e7fb5ab4b1cf3738f871470e0a9ef7575
[ "Zlib" ]
null
null
null
source/Bit/System/Bencode/BencodeValue.cpp
jimmiebergmann/Bit-Engine
39324a9e7fb5ab4b1cf3738f871470e0a9ef7575
[ "Zlib" ]
null
null
null
// Copyright (C) 2013 Jimmie Bergmann - [email protected] // // This software is provided 'as-is', without any express or // implied warranty. In no event will the authors be held // liable for any damages arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute // it freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; // you must not claim that you wrote the original software. // If you use this software in a product, an acknowledgment // in the product documentation would be appreciated but // is not required. // // 2. Altered source versions must be plainly marked as such, // and must not be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any // source distribution. // /////////////////////////////////////////////////////////////////////////// #include <Bit/System/Bencode/Value.hpp> #include <sstream> #include <Bit/System/MemoryLeak.hpp> namespace Bit { namespace Bencode { // Global varaibles static std::string g_EmptyString = ""; static std::string g_TemporaryString = ""; static std::string g_NilString = "[Nil]"; static std::string g_DictionaryString = "[Dictionary]"; static std::string g_ListString = "[List]"; // Static variable members const Value Value::NilValue( Nil ); Value Value::s_DefaultValue( Nil ); // Value definitions Value::Value( ) : m_Type( Nil ) { } Value::Value( eType p_Type ) : m_Type( p_Type ) { } Value::Value( const Value & p_Value ) { // Always clear the old data Clear( ); // Get this value's pointer Value * pValue = const_cast<Value *>( this ); // Copy the value CopyValue( p_Value, *pValue ); } Value::~Value( ) { Clear( ); } void Value::Clear( ) { switch( m_Type ) { case Integer: { m_Value.Integer = 0; } break; case String: { if( m_Value.String ) { delete m_Value.String; } } break; case List: { if( m_Value.List ) { // Delete all the values in the list for( ValueVector::iterator it = m_Value.List->begin( ); it != m_Value.List->end( ); it++ ) { delete *it; } delete m_Value.List; } } break; case Dictionary: { if( m_Value.Dictionary ) { // Go through the dictionary and delete all the values for( ValueMap::iterator it = m_Value.Dictionary->begin( ); it != m_Value.Dictionary->end( ); it++ ) { delete it->second; } // Delete the dictionary pointer. delete m_Value.Dictionary; } } break; default: break; } // Set the type to Nil. m_Type = Nil; } void Value::Append( const Value & p_Value ) { // The value is not a list, turn it into a list if( m_Type != List || !m_Value.List ) { // Clear the old data first Clear( ); m_Type = List; m_Value.List = new ValueVector; } // Create a new value Value * pValue = new Value; // Copy the value CopyValue( p_Value, *pValue ); // Push the new value value to the vector. m_Value.List->push_back( pValue ); } void Value::Append( const Int32 & p_Integer ) { // The value is not a list, turn it into a list if( m_Type != List || !m_Value.List ) { // Clear the old data first Clear( ); m_Type = List; m_Value.List = new ValueVector; } // Create a value and push it to the vector Value * pValue = new Value( Integer ); pValue->m_Value.Integer = p_Integer; m_Value.List->push_back( pValue ); } void Value::Append( const std::string & p_String ) { // The value is not a list, turn it into a list if( m_Type != List || !m_Value.List ) { // Clear the old data first Clear( ); m_Type = List; m_Value.List = new ValueVector; } // Create a new value Value * pValue = new Value( String ); pValue->m_Value.String = new std::string( ); // Set the string data for the new value. pValue->m_Value.String->reserve( p_String.size( ) ); pValue->m_Value.String->append( p_String ); // Push the new value value to the vector. m_Value.List->push_back( pValue ); } void Value::Erase( const SizeType & p_Index ) { // Make sure that this is a list. if( m_Type != List || !m_Value.List ) { return; } // Error check the size if( p_Index >= m_Value.List->size( ) ) { return; } // Delete the value Value * pValue = *(m_Value.List->begin( ) + p_Index); delete pValue; // Erase the item m_Value.List->erase( m_Value.List->begin( ) + p_Index ); } void Value::Erase( const std::string & p_Key ) { // Make sure that this is a dictionary. if( m_Type != Dictionary || !m_Value.Dictionary ) { return; } // Find the value ValueMap::iterator it = m_Value.Dictionary->find( p_Key ); // Could we find the value? if( it == m_Value.Dictionary->end( ) ) { return; } // Delete the value delete it->second; // Erase the value from the dictionary m_Value.Dictionary->erase( it ); } Value::eType Value::GetType( ) const { return m_Type; } Bool Value::IsNil( ) const { return m_Type == Nil; } Value & Value::Get( const std::string & p_Key, const Value & p_DefaultValue ) const { // This function only works for dictionaries if( m_Type != Dictionary ) { s_DefaultValue = p_DefaultValue; return s_DefaultValue; } // Find the key ValueMap::iterator it = m_Value.Dictionary->find( p_Key ); // Could not find the key if( it == m_Value.Dictionary->end( ) ) { s_DefaultValue = p_DefaultValue; return s_DefaultValue; } // Return the found value. return *(it->second); } Value & Value::Get( const std::string & p_Key, const Int32 & p_DefaultValue ) const { // This function only works for dictionaries if( m_Type != Dictionary ) { s_DefaultValue = p_DefaultValue; return s_DefaultValue; } // Find the key ValueMap::iterator it = m_Value.Dictionary->find( p_Key ); // Could not find the key if( it == m_Value.Dictionary->end( ) ) { s_DefaultValue = p_DefaultValue; return s_DefaultValue; } // Return the found value. return *(it->second); } Value & Value::Get( const std::string & p_Key, const std::string & p_DefaultValue ) const { // This function only works for dictionaries if( m_Type != Dictionary ) { s_DefaultValue = p_DefaultValue; return s_DefaultValue; } // Find the key ValueMap::iterator it = m_Value.Dictionary->find( p_Key ); // Could not find the key if( it == m_Value.Dictionary->end( ) ) { s_DefaultValue = p_DefaultValue; return s_DefaultValue; } // Return the found value. return *(it->second); } SizeType Value::GetSize( ) const { if( m_Type == Dictionary && m_Value.Dictionary ) { return static_cast<SizeType>( m_Value.Dictionary->size( ) ); } else if( m_Type == List && m_Value.List ) { return static_cast<SizeType>( m_Value.List->size( ) ); } return 0; } const std::string & Value::AsString( ) const { // Switch the type in order to know which method you // are going to use to convert the value into a string. switch( m_Type ) { case Nil: { return g_NilString; } break; case String: { // Return the string if it's allocated. return m_Value.String ? *m_Value.String : g_EmptyString; } break; case Integer: { std::stringstream ss; ss << m_Value.Integer; g_TemporaryString = ss.str( ); return g_TemporaryString; } break; case List: { return g_ListString; } break; case Dictionary: { return g_DictionaryString; } break; } return g_EmptyString; } Int32 Value::AsInt( ) const { // Switch the type in order to know which method you // are going to use to convert the value into a string. switch( m_Type ) { case Nil: { return 0; } break; case String: { if( !m_Value.String ) { return 0; } // Get the string as an int return atoi( m_Value.String->c_str( ) ); } break; case Integer: { return m_Value.Integer; } break; case List: { return 0; } break; case Dictionary: { return 0; } break; } return 0; } Value & Value::operator [ ] ( const std::string & p_Key ) { // This function only works for dictionaries. // Turn this value into a dictionary. if( m_Type != Dictionary ) { // Clear all the old data Clear( ); m_Type = Dictionary; m_Value.Dictionary = new ValueMap; } // Find the key ValueMap::iterator it = m_Value.Dictionary->find( p_Key ); // Could not find the key, add a Nil value to the dictionary. if( it == m_Value.Dictionary->end( ) ) { // Create a value Value * pValue = new Value( Nil ); (*m_Value.Dictionary)[ p_Key ] = pValue; // Return the nil value you just created. return *pValue; } // Return the found value. return *(it->second); } Value & Value::operator [ ] ( const SizeType & p_Index ) { // Make sure that the value is a list. if( m_Type != List ) { s_DefaultValue.Clear( ); return s_DefaultValue; } // Error check the index. if( p_Index > m_Value.List->size( ) ) { s_DefaultValue.Clear( ); return s_DefaultValue; } return *(*m_Value.List)[ p_Index ]; } Value & Value::operator = ( const Value & p_Value ) { // Always clear the old data Clear( ); // Get this value's pointer Value * pValue = const_cast<Value *>( this ); // Copy the value CopyValue( p_Value, *pValue ); // Return this value. return *pValue; } Value & Value::operator = ( const Int32 & p_Integer ) { // The value is not an integer, turn it into an integer value. if( m_Type != Integer ) { Clear( ); m_Type = Integer; } // Set the string data. m_Value.Integer = p_Integer; // Return this value. return *const_cast<Value *>( this ); } Value & Value::operator = ( const char * p_Characters ) { return Value::operator=( std::string( p_Characters ) ); } Value & Value::operator = ( const std::string & p_String ) { // The value is not a string, turn it into a string value. if( m_Type != String ) { Clear( ); m_Type = String; m_Value.String = new std::string( ); } // Set the string data. m_Value.String->reserve( p_String.size( ) ); m_Value.String->append( p_String ); // Return this value. return *const_cast<Value *>( this ); } bool Value::operator == ( const Value & p_Value ) const { return m_Type == p_Value.m_Type; } bool Value::operator != ( const Value & p_Value ) const { return m_Type != p_Value.m_Type; } // Private functions void Value::CopyValue( const Value & p_From, Value & p_To ) const { // Set the type p_To.m_Type = p_From.m_Type; // Set the data switch( p_From.m_Type ) { case Integer: { p_To.m_Type = Integer; p_To.m_Value.Integer = p_From.m_Value.Integer; } break; case String: { // Make sure that the string is valid. if( !p_From.m_Value.String ) { p_To.m_Type = Nil; break; } p_To.m_Type = String; p_To.m_Value.String = new std::string; p_To.m_Value.String->reserve( p_From.m_Value.String->size( ) ); p_To.m_Value.String->append( *p_From.m_Value.String ); } break; case List: { // Make sure that the list is valid. if( !p_From.m_Value.List ) { p_To.m_Type = Nil; break; } p_To.m_Type = List; p_To.m_Value.List = new ValueVector; // Go throguh all the values in the list, and make copies of them. for( ValueVector::iterator it = p_From.m_Value.List->begin( ); it != p_From.m_Value.List->end( ); it++ ) { // Create a new value Value * pValue = new Value( ); // Copy the value CopyValue( *(*(it)), * pValue ); // Add the new value to the target list p_To.m_Value.List->push_back( pValue ); } } break; case Dictionary: { // Make sure that the dictionary is valid. if( !p_From.m_Value.Dictionary ) { p_To.m_Type = Nil; break; } p_To.m_Type = Dictionary; p_To.m_Value.Dictionary = new ValueMap; // Go throguh all the values in the dictionary, and make copies of them. for( ValueMap::iterator it = p_From.m_Value.Dictionary->begin( ); it != p_From.m_Value.Dictionary->end( ); it++ ) { // Create a new value Value * pValue = new Value( ); // Copy the value CopyValue( *(it->second), * pValue ); // Add the new value to the target dictionary (*p_To.m_Value.Dictionary)[ it->first ] = pValue; } } break; default: // Nil value { p_To.m_Type = Nil; } break; } } } }
21.579968
118
0.59485
jimmiebergmann
029026b90ad7da546a8f342a6ffe4ea383f85c98
7,600
hpp
C++
Lab11/barista.hpp
NLaDuke/CSIII-Labs
8f2658d6fcf6cc838bbef17bc5110a10c742bf0e
[ "MIT" ]
null
null
null
Lab11/barista.hpp
NLaDuke/CSIII-Labs
8f2658d6fcf6cc838bbef17bc5110a10c742bf0e
[ "MIT" ]
null
null
null
Lab11/barista.hpp
NLaDuke/CSIII-Labs
8f2658d6fcf6cc838bbef17bc5110a10c742bf0e
[ "MIT" ]
null
null
null
#ifndef BARISTA_HPP #define BARISTA_HPP #include "drink.hpp" #include <string> #include <iostream> #include <unordered_set> #include <deque> #include <ctime> #include <algorithm> using std::cin; using std::cout; using std::string; using std::endl; //---------------------------- // File: barista.hpp // By: Nolan LaDuke // Date: 3/30/2021 //------------------------------------------------------------------------------ // Function: Observer Design Paradigm used for Coffee serving //------------------------------------------------------------------------------ // Forward class declaration of Customer class Customer; // Barista Class class Barista{ public: // Constructors: Barista(){srand(time(NULL));} virtual ~Barista(); // Function that takes in a new Customer-Drink pair and registers them void registerOrder(Customer*, Drink*); // Function that takes the first non-ready order and makes it ready virtual bool makeOrder(){ // Iterate through until an unprepared order is found auto completableOrder = std::find_if(orderQueue_.begin(), orderQueue_.end(), [](Drink* order){ return !order->getStatus(); }); // if one is found mark it as ready if(completableOrder != orderQueue_.end()){ (*completableOrder)->setReady(); cout << "Barista finished making order number " << (*completableOrder)->getID() << endl; return true; } return false; } // Function that takes the first ready order and announces to all registered Customers its ID bool serveOrder(); // Function that Customer initiates, deregisters + deletes Customer and matching Drink void pickupOrder(Customer*); // 50/50 Prepare or Serve order function void work(){ if(rand()%2){ if(makeOrder()) cout << endl; } else{ if(serveOrder()) cout << endl; } } // 50/50 Prepare + Serve or Take order function void workAlternate(); // Returns whether or not there are any more orders bool doneWorking(){ return (customers_.empty() && orderQueue_.empty()); } // Takes in a new order and returns it as a Drink* Drink* takeOrder(){ // Set up variables: char userInput; string custName; // Prompt user cout << "Welcome to Not_Starbucks, can I get a name for this order? "; cin >> custName; cout << "Hello " << custName << "!" << endl << "would you like a [l]arge, [m]edium, or [s]mall coffee? "; cin >> userInput; // Case for invalid inputs: while(userInput != 'l' && userInput != 'm' && userInput != 's'){ cout << "Sorry, the value you input is not valid, please try again:" << endl << "Can I get you a [l]arge, [m]edium, or [s]mall coffee? "; cin >> userInput; } // Set Drink type + cost based on input DrinkType size = userInput == 'l' ? DrinkType::large : (userInput == 'm' ? DrinkType::medium : DrinkType::small); int cost = userInput == 'l' ? 3 : (userInput == 'm' ? 2 : 1); // Set up base drink Drink* custDrink = new Drink(size, custName, cost); // Repeatedly prompt user for toppings until they give the 'n' input: cout << "Would you like to add [s]prinkles, [c]aramel, milk [f]oam, [i]ce or [n]othing? "; cin >> userInput; while(userInput != 'n'){ switch(userInput){ case('s'): custDrink = new sprinkles(custDrink); break; case('c'): custDrink = new caramel(custDrink); break; case('f'): custDrink = new milkFoam(custDrink); break; case('i'): custDrink = new ice(custDrink); break; default: // Default for invalid input: cout << "Sorry, the input you gave was not valid - please try again:" << endl; } cout << "Would you like to add [s]prinkles, [c]aramel, milk [f]oam, [i]ce or [n]othing? "; cin >> userInput; } cout << "Thank you, your order will be ready momentarily!" << endl << endl; return custDrink; } protected: std::deque<Customer*> customers_; std::deque<Drink*> orderQueue_; }; // Customer Class: class Customer{ public: // Constructors: Customer(Drink* order = nullptr, Barista* barista = nullptr, string name = "") : order_(order), barista_(barista), name_(name), orderNum_(-1){}; ~Customer(){} // order_ erased manually elsewhere // Setters: void setNumber(int orderNum){orderNum_ = orderNum;}; // Getters: string getName(){return name_;}; int getOrderNum(){return orderNum_;}; // Functions: void notifyOrder(Drink*); private: string name_; Drink* order_; Barista* barista_; int orderNum_; }; //=================== Implementation for Barista Class ========================= // Destructor implementation Barista::~Barista(){ std::for_each(customers_.begin(), customers_.end(), [](Customer* cust){delete cust;}); } // Register Order Implementation void Barista::registerOrder(Customer* cust, Drink* drnk){ static int orderNumber = 0; cust->setNumber(orderNumber); drnk->setID(orderNumber++); customers_.push_back(cust); orderQueue_.push_back(drnk); } // Serve Order implementaiton bool Barista::serveOrder(){ // Iterate through until a prepared order is found auto completedOrder = std::find_if(orderQueue_.begin(), orderQueue_.end(), [](Drink* order){ return order->getStatus(); }); // If an order was not found, return; otherwise, alert everyone if(completedOrder == orderQueue_.end()) return false; // Announce that the order is ready cout << "Order number " << (*completedOrder)->getID() << " is now ready for pickup!" << endl; for(auto cust : customers_){ cust->notifyOrder(*completedOrder); } // Erase and delete picked up order: Drink* delPtr = *completedOrder; orderQueue_.erase(completedOrder); delete delPtr; return true; } // Pickup Order implementation void Barista::pickupOrder(Customer* cust){ // Find Customer's Order auto custOrder = std::find_if(orderQueue_.begin(), orderQueue_.end(), [&cust](Drink* currentDrink){ return (cust->getOrderNum() == currentDrink->getID()) && currentDrink->getStatus(); }); // Error Case if(custOrder == orderQueue_.end()){ std::cerr << "ERROR: Customer attempted to pick up an invalid order [ID did not exist / order not ready]\n"; return; } // Print statement: cout << "Here you go " << cust->getName() << "!" << endl << "Your " << (*custOrder)->getSizeName() << " with " << (*custOrder)->getToppings() << " is ready." << endl << "Your total is $" << (*custOrder)->getPrice() << endl; // Erase and delete customer auto custRemoval = std::find_if(customers_.begin(), customers_.end(), [&cust](Customer* currentCust){ return (currentCust->getOrderNum() == cust->getOrderNum()); }); // Error Case if(custRemoval == customers_.end()){ std::cerr << "ERROR: Customer not found yet had drink in queue\n"; return; } Customer* forDeletion = *custRemoval; customers_.erase(custRemoval); delete forDeletion; } // Alternative Work implementation void Barista::workAlternate(){ if(rand()%2){ if(makeOrder() && serveOrder()) cout << endl; } else{ Drink* order = takeOrder(); Customer* cust = new Customer(order, this, order->getName()); registerOrder(cust, order); } } //==================== Implementation for Customer Class ======================= void Customer::notifyOrder(Drink* finishedOrder){ if(finishedOrder->getID() == orderNum_){ barista_->pickupOrder(this); } } #endif
28.04428
118
0.615263
NLaDuke
02975f410346e6c65299d093623b36bcdb28b09c
1,531
cpp
C++
BOJ_solve/5804.cpp
python-programmer1512/Code_of_gunwookim
e72e6724fb9ee6ccf2e1064583956fa954ba0282
[ "MIT" ]
4
2021-01-27T11:51:30.000Z
2021-01-30T17:02:55.000Z
BOJ_solve/5804.cpp
python-programmer1512/Code_of_gunwookim
e72e6724fb9ee6ccf2e1064583956fa954ba0282
[ "MIT" ]
null
null
null
BOJ_solve/5804.cpp
python-programmer1512/Code_of_gunwookim
e72e6724fb9ee6ccf2e1064583956fa954ba0282
[ "MIT" ]
5
2021-01-27T11:46:12.000Z
2021-05-06T05:37:47.000Z
#include <bits/stdc++.h> #define x first #define y second #define pb push_back #define all(v) v.begin(),v.end() #pragma gcc optimize("O3") #pragma gcc optimize("Ofast") #pragma gcc optimize("unroll-loops") using namespace std; const int INF = 1e9; const int TMX = 1 << 18; const long long llINF = 2e18; const long long mod = 1e9+7; const long long hashmod = 100003; const int MAXN = 100000; const int MAXM = 1000000; typedef long long ll; typedef long double ld; typedef pair <int,int> pi; typedef pair <ll,ll> pl; typedef vector <int> vec; typedef vector <pi> vecpi; typedef long long ll; ll a,b,c,d; pl add_gcd(ll x,ll y) { if(!y) return make_pair(1,0); ll g,nx,ny; pl N = add_gcd(y,x%y); nx = N.x, ny = N.y; return {ny,nx-(x/y)*ny}; } pl inverse(ll ax,ll by) { ll g,x,y; g = __gcd(ax,by); pl N = add_gcd(ax,by); return N; } int main() { int T; cin >> T; while(T--) { scanf("%lld/%lld",&c,&d); ll rc = c,rd = d; a = inverse(d,c).x, b = inverse(d,c).y; if(__gcd(c,d) != 1) { cout << c/__gcd(c,d) << '/' << d/__gcd(c,d) << '\n'; continue; } ll a2 = -a, b2 = -b; ll na = c/__gcd(d,c), nb = d/__gcd(d,c); ll op = (d-b-1)/nb,op2 = (d-b2-1)/nb; a -= op*na, b += op*nb, a2 -= op2*na, b2 += op2*nb; if(b < d&&b2 < d) { if(b == b2) cout << min(-a,-a2) << '/' << b << '\n'; else if(b > b2) cout << -a << '/' << b << '\n'; else cout << -a2 << '/' << b2 << '\n'; } else if(b < d) cout << -a << '/' << b << '\n'; else if(b2 < d) cout << -a2 << '/' << b2 << '\n'; else return -1; } }
23.553846
55
0.544089
python-programmer1512
029ab28c0d8d12a4cebdeb14483fe8731bda23ad
17,991
cxx
C++
SimModel_Python_API/simmodel_swig/SimModel_Dll_lib/framework/SimSpaceBoundary.cxx
EnEff-BIM/EnEffBIM-Framework
6328d39b498dc4065a60b5cc9370b8c2a9a1cddf
[ "MIT" ]
3
2016-05-30T15:12:16.000Z
2022-03-22T08:11:13.000Z
SimModel_Python_API/simmodel_swig/SimModel_Dll_lib/framework/SimSpaceBoundary.cxx
EnEff-BIM/EnEffBIM-Framework
6328d39b498dc4065a60b5cc9370b8c2a9a1cddf
[ "MIT" ]
21
2016-06-13T11:33:45.000Z
2017-05-23T09:46:52.000Z
SimModel_Python_API/simmodel_swig/SimModel_Dll_lib/framework/SimSpaceBoundary.cxx
EnEff-BIM/EnEffBIM-Framework
6328d39b498dc4065a60b5cc9370b8c2a9a1cddf
[ "MIT" ]
null
null
null
// Copyright (c) 2005-2014 Code Synthesis Tools CC // // This program was generated by CodeSynthesis XSD, an XML Schema to // C++ data binding compiler. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // 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 St, Fifth Floor, Boston, MA 02110-1301 USA // // In addition, as a special exception, Code Synthesis Tools CC gives // permission to link this program with the Xerces-C++ library (or with // modified versions of Xerces-C++ that use the same license as Xerces-C++), // and distribute linked combinations including the two. You must obey // the GNU General Public License version 2 in all respects for all of // the code used other than Xerces-C++. If you modify this copy of the // program, you may extend this exception to your version of the program, // but you are not obligated to do so. If you do not wish to do so, delete // this exception statement from your version. // // Furthermore, Code Synthesis Tools CC makes a special exception for // the Free/Libre and Open Source Software (FLOSS) which is described // in the accompanying FLOSSE file. // // Begin prologue. // // // End prologue. #include <xsd/cxx/pre.hxx> #include "SimSpaceBoundary.hxx" namespace schema { namespace simxml { namespace ResourcesGeneral { // SimSpaceBoundary // const SimSpaceBoundary::RelatingSpace_optional& SimSpaceBoundary:: RelatingSpace () const { return this->RelatingSpace_; } SimSpaceBoundary::RelatingSpace_optional& SimSpaceBoundary:: RelatingSpace () { return this->RelatingSpace_; } void SimSpaceBoundary:: RelatingSpace (const RelatingSpace_type& x) { this->RelatingSpace_.set (x); } void SimSpaceBoundary:: RelatingSpace (const RelatingSpace_optional& x) { this->RelatingSpace_ = x; } void SimSpaceBoundary:: RelatingSpace (::std::auto_ptr< RelatingSpace_type > x) { this->RelatingSpace_.set (x); } const SimSpaceBoundary::RelatedBuildingElement_optional& SimSpaceBoundary:: RelatedBuildingElement () const { return this->RelatedBuildingElement_; } SimSpaceBoundary::RelatedBuildingElement_optional& SimSpaceBoundary:: RelatedBuildingElement () { return this->RelatedBuildingElement_; } void SimSpaceBoundary:: RelatedBuildingElement (const RelatedBuildingElement_type& x) { this->RelatedBuildingElement_.set (x); } void SimSpaceBoundary:: RelatedBuildingElement (const RelatedBuildingElement_optional& x) { this->RelatedBuildingElement_ = x; } void SimSpaceBoundary:: RelatedBuildingElement (::std::auto_ptr< RelatedBuildingElement_type > x) { this->RelatedBuildingElement_.set (x); } const SimSpaceBoundary::ConnectionGeometry_optional& SimSpaceBoundary:: ConnectionGeometry () const { return this->ConnectionGeometry_; } SimSpaceBoundary::ConnectionGeometry_optional& SimSpaceBoundary:: ConnectionGeometry () { return this->ConnectionGeometry_; } void SimSpaceBoundary:: ConnectionGeometry (const ConnectionGeometry_type& x) { this->ConnectionGeometry_.set (x); } void SimSpaceBoundary:: ConnectionGeometry (const ConnectionGeometry_optional& x) { this->ConnectionGeometry_ = x; } void SimSpaceBoundary:: ConnectionGeometry (::std::auto_ptr< ConnectionGeometry_type > x) { this->ConnectionGeometry_.set (x); } const SimSpaceBoundary::PhysicalOrVirtualBoundary_optional& SimSpaceBoundary:: PhysicalOrVirtualBoundary () const { return this->PhysicalOrVirtualBoundary_; } SimSpaceBoundary::PhysicalOrVirtualBoundary_optional& SimSpaceBoundary:: PhysicalOrVirtualBoundary () { return this->PhysicalOrVirtualBoundary_; } void SimSpaceBoundary:: PhysicalOrVirtualBoundary (const PhysicalOrVirtualBoundary_type& x) { this->PhysicalOrVirtualBoundary_.set (x); } void SimSpaceBoundary:: PhysicalOrVirtualBoundary (const PhysicalOrVirtualBoundary_optional& x) { this->PhysicalOrVirtualBoundary_ = x; } void SimSpaceBoundary:: PhysicalOrVirtualBoundary (::std::auto_ptr< PhysicalOrVirtualBoundary_type > x) { this->PhysicalOrVirtualBoundary_.set (x); } const SimSpaceBoundary::InternalOrExternalBoundary_optional& SimSpaceBoundary:: InternalOrExternalBoundary () const { return this->InternalOrExternalBoundary_; } SimSpaceBoundary::InternalOrExternalBoundary_optional& SimSpaceBoundary:: InternalOrExternalBoundary () { return this->InternalOrExternalBoundary_; } void SimSpaceBoundary:: InternalOrExternalBoundary (const InternalOrExternalBoundary_type& x) { this->InternalOrExternalBoundary_.set (x); } void SimSpaceBoundary:: InternalOrExternalBoundary (const InternalOrExternalBoundary_optional& x) { this->InternalOrExternalBoundary_ = x; } void SimSpaceBoundary:: InternalOrExternalBoundary (::std::auto_ptr< InternalOrExternalBoundary_type > x) { this->InternalOrExternalBoundary_.set (x); } const SimSpaceBoundary::OthersideSpaceBoundary_optional& SimSpaceBoundary:: OthersideSpaceBoundary () const { return this->OthersideSpaceBoundary_; } SimSpaceBoundary::OthersideSpaceBoundary_optional& SimSpaceBoundary:: OthersideSpaceBoundary () { return this->OthersideSpaceBoundary_; } void SimSpaceBoundary:: OthersideSpaceBoundary (const OthersideSpaceBoundary_type& x) { this->OthersideSpaceBoundary_.set (x); } void SimSpaceBoundary:: OthersideSpaceBoundary (const OthersideSpaceBoundary_optional& x) { this->OthersideSpaceBoundary_ = x; } void SimSpaceBoundary:: OthersideSpaceBoundary (::std::auto_ptr< OthersideSpaceBoundary_type > x) { this->OthersideSpaceBoundary_.set (x); } const SimSpaceBoundary::ChildSpaceBoundaries_optional& SimSpaceBoundary:: ChildSpaceBoundaries () const { return this->ChildSpaceBoundaries_; } SimSpaceBoundary::ChildSpaceBoundaries_optional& SimSpaceBoundary:: ChildSpaceBoundaries () { return this->ChildSpaceBoundaries_; } void SimSpaceBoundary:: ChildSpaceBoundaries (const ChildSpaceBoundaries_type& x) { this->ChildSpaceBoundaries_.set (x); } void SimSpaceBoundary:: ChildSpaceBoundaries (const ChildSpaceBoundaries_optional& x) { this->ChildSpaceBoundaries_ = x; } void SimSpaceBoundary:: ChildSpaceBoundaries (::std::auto_ptr< ChildSpaceBoundaries_type > x) { this->ChildSpaceBoundaries_.set (x); } const SimSpaceBoundary::GrossSurfaceArea_optional& SimSpaceBoundary:: GrossSurfaceArea () const { return this->GrossSurfaceArea_; } SimSpaceBoundary::GrossSurfaceArea_optional& SimSpaceBoundary:: GrossSurfaceArea () { return this->GrossSurfaceArea_; } void SimSpaceBoundary:: GrossSurfaceArea (const GrossSurfaceArea_type& x) { this->GrossSurfaceArea_.set (x); } void SimSpaceBoundary:: GrossSurfaceArea (const GrossSurfaceArea_optional& x) { this->GrossSurfaceArea_ = x; } const SimSpaceBoundary::SurfaceNormal_optional& SimSpaceBoundary:: SurfaceNormal () const { return this->SurfaceNormal_; } SimSpaceBoundary::SurfaceNormal_optional& SimSpaceBoundary:: SurfaceNormal () { return this->SurfaceNormal_; } void SimSpaceBoundary:: SurfaceNormal (const SurfaceNormal_type& x) { this->SurfaceNormal_.set (x); } void SimSpaceBoundary:: SurfaceNormal (const SurfaceNormal_optional& x) { this->SurfaceNormal_ = x; } void SimSpaceBoundary:: SurfaceNormal (::std::auto_ptr< SurfaceNormal_type > x) { this->SurfaceNormal_.set (x); } } } } #include <xsd/cxx/xml/dom/parsing-source.hxx> #include <xsd/cxx/tree/type-factory-map.hxx> namespace _xsd { static const ::xsd::cxx::tree::type_factory_plate< 0, char > type_factory_plate_init; } namespace schema { namespace simxml { namespace ResourcesGeneral { // SimSpaceBoundary // SimSpaceBoundary:: SimSpaceBoundary () : ::schema::simxml::SimModelCore::SimResourceObject (), RelatingSpace_ (this), RelatedBuildingElement_ (this), ConnectionGeometry_ (this), PhysicalOrVirtualBoundary_ (this), InternalOrExternalBoundary_ (this), OthersideSpaceBoundary_ (this), ChildSpaceBoundaries_ (this), GrossSurfaceArea_ (this), SurfaceNormal_ (this) { } SimSpaceBoundary:: SimSpaceBoundary (const RefId_type& RefId) : ::schema::simxml::SimModelCore::SimResourceObject (RefId), RelatingSpace_ (this), RelatedBuildingElement_ (this), ConnectionGeometry_ (this), PhysicalOrVirtualBoundary_ (this), InternalOrExternalBoundary_ (this), OthersideSpaceBoundary_ (this), ChildSpaceBoundaries_ (this), GrossSurfaceArea_ (this), SurfaceNormal_ (this) { } SimSpaceBoundary:: SimSpaceBoundary (const SimSpaceBoundary& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::schema::simxml::SimModelCore::SimResourceObject (x, f, c), RelatingSpace_ (x.RelatingSpace_, f, this), RelatedBuildingElement_ (x.RelatedBuildingElement_, f, this), ConnectionGeometry_ (x.ConnectionGeometry_, f, this), PhysicalOrVirtualBoundary_ (x.PhysicalOrVirtualBoundary_, f, this), InternalOrExternalBoundary_ (x.InternalOrExternalBoundary_, f, this), OthersideSpaceBoundary_ (x.OthersideSpaceBoundary_, f, this), ChildSpaceBoundaries_ (x.ChildSpaceBoundaries_, f, this), GrossSurfaceArea_ (x.GrossSurfaceArea_, f, this), SurfaceNormal_ (x.SurfaceNormal_, f, this) { } SimSpaceBoundary:: SimSpaceBoundary (const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::schema::simxml::SimModelCore::SimResourceObject (e, f | ::xml_schema::flags::base, c), RelatingSpace_ (this), RelatedBuildingElement_ (this), ConnectionGeometry_ (this), PhysicalOrVirtualBoundary_ (this), InternalOrExternalBoundary_ (this), OthersideSpaceBoundary_ (this), ChildSpaceBoundaries_ (this), GrossSurfaceArea_ (this), SurfaceNormal_ (this) { if ((f & ::xml_schema::flags::base) == 0) { ::xsd::cxx::xml::dom::parser< char > p (e, true, false, true); this->parse (p, f); } } void SimSpaceBoundary:: parse (::xsd::cxx::xml::dom::parser< char >& p, ::xml_schema::flags f) { this->::schema::simxml::SimModelCore::SimResourceObject::parse (p, f); for (; p.more_content (); p.next_content (false)) { const ::xercesc::DOMElement& i (p.cur_element ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (i)); // RelatingSpace // if (n.name () == "RelatingSpace" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< RelatingSpace_type > r ( RelatingSpace_traits::create (i, f, this)); if (!this->RelatingSpace_) { this->RelatingSpace_.set (r); continue; } } // RelatedBuildingElement // if (n.name () == "RelatedBuildingElement" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< RelatedBuildingElement_type > r ( RelatedBuildingElement_traits::create (i, f, this)); if (!this->RelatedBuildingElement_) { this->RelatedBuildingElement_.set (r); continue; } } // ConnectionGeometry // if (n.name () == "ConnectionGeometry" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< ConnectionGeometry_type > r ( ConnectionGeometry_traits::create (i, f, this)); if (!this->ConnectionGeometry_) { this->ConnectionGeometry_.set (r); continue; } } // PhysicalOrVirtualBoundary // if (n.name () == "PhysicalOrVirtualBoundary" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< PhysicalOrVirtualBoundary_type > r ( PhysicalOrVirtualBoundary_traits::create (i, f, this)); if (!this->PhysicalOrVirtualBoundary_) { this->PhysicalOrVirtualBoundary_.set (r); continue; } } // InternalOrExternalBoundary // if (n.name () == "InternalOrExternalBoundary" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< InternalOrExternalBoundary_type > r ( InternalOrExternalBoundary_traits::create (i, f, this)); if (!this->InternalOrExternalBoundary_) { this->InternalOrExternalBoundary_.set (r); continue; } } // OthersideSpaceBoundary // if (n.name () == "OthersideSpaceBoundary" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< OthersideSpaceBoundary_type > r ( OthersideSpaceBoundary_traits::create (i, f, this)); if (!this->OthersideSpaceBoundary_) { this->OthersideSpaceBoundary_.set (r); continue; } } // ChildSpaceBoundaries // if (n.name () == "ChildSpaceBoundaries" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< ChildSpaceBoundaries_type > r ( ChildSpaceBoundaries_traits::create (i, f, this)); if (!this->ChildSpaceBoundaries_) { this->ChildSpaceBoundaries_.set (r); continue; } } // GrossSurfaceArea // if (n.name () == "GrossSurfaceArea" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { if (!this->GrossSurfaceArea_) { this->GrossSurfaceArea_.set (GrossSurfaceArea_traits::create (i, f, this)); continue; } } // SurfaceNormal // if (n.name () == "SurfaceNormal" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/ResourcesGeneral") { ::std::auto_ptr< SurfaceNormal_type > r ( SurfaceNormal_traits::create (i, f, this)); if (!this->SurfaceNormal_) { this->SurfaceNormal_.set (r); continue; } } break; } } SimSpaceBoundary* SimSpaceBoundary:: _clone (::xml_schema::flags f, ::xml_schema::container* c) const { return new class SimSpaceBoundary (*this, f, c); } SimSpaceBoundary& SimSpaceBoundary:: operator= (const SimSpaceBoundary& x) { if (this != &x) { static_cast< ::schema::simxml::SimModelCore::SimResourceObject& > (*this) = x; this->RelatingSpace_ = x.RelatingSpace_; this->RelatedBuildingElement_ = x.RelatedBuildingElement_; this->ConnectionGeometry_ = x.ConnectionGeometry_; this->PhysicalOrVirtualBoundary_ = x.PhysicalOrVirtualBoundary_; this->InternalOrExternalBoundary_ = x.InternalOrExternalBoundary_; this->OthersideSpaceBoundary_ = x.OthersideSpaceBoundary_; this->ChildSpaceBoundaries_ = x.ChildSpaceBoundaries_; this->GrossSurfaceArea_ = x.GrossSurfaceArea_; this->SurfaceNormal_ = x.SurfaceNormal_; } return *this; } SimSpaceBoundary:: ~SimSpaceBoundary () { } } } } #include <istream> #include <xsd/cxx/xml/sax/std-input-source.hxx> #include <xsd/cxx/tree/error-handler.hxx> namespace schema { namespace simxml { namespace ResourcesGeneral { } } } #include <xsd/cxx/post.hxx> // Begin epilogue. // // // End epilogue.
29.835821
132
0.617642
EnEff-BIM
029b4ad5e413faf728cfca0f64f0bf38fa38e055
1,003
cpp
C++
Codeforces/CF1618F.cpp
Nickel-Angel/Coding-Practice
6fb70e9c9542323f82a9a8714727cc668ff58567
[ "MIT" ]
null
null
null
Codeforces/CF1618F.cpp
Nickel-Angel/Coding-Practice
6fb70e9c9542323f82a9a8714727cc668ff58567
[ "MIT" ]
1
2021-11-18T15:10:29.000Z
2021-11-20T07:13:31.000Z
Codeforces/CF1618F.cpp
Nickel-Angel/ACM-and-OI
79d13fd008c3a1fe9ebf35329aceb1fcb260d5d9
[ "MIT" ]
null
null
null
/* * @author Nickel_Angel ([email protected]) * @copyright Copyright (c) 2021 */ #include <algorithm> #include <iostream> #include <cstdio> #include <cstring> #include <set> #include <string> using std::set; using std::string; long long x, y; string tar, ori; set<string> cur; void dfs(string s) { if (cur.count(s) || s.length() > 100) return; if (s == tar) { puts("YES"); exit(0); } cur.insert(s); auto it = s.rbegin(); while (it != s.rend() && *it == '0') ++it; string t; while (it != s.rend()) { t += *it; ++it; } dfs(t); std::reverse(s.begin(), s.end()); dfs("1" + s); } int main() { scanf("%lld%lld", &x, &y); while (y) { tar += '0' + (y & 1); y >>= 1; } std::reverse(tar.begin(), tar.end()); while (x) { ori += '0' + (x & 1); x >>= 1; } std::reverse(ori.begin(), ori.end()); dfs(ori); puts("NO"); return 0; }
16.177419
42
0.461615
Nickel-Angel
029f7862c89879897231d107e993919270bfa276
1,241
hpp
C++
src/Event/KeyboardEvent.hpp
billy4479/BillyEngine
df7d519f740d5862c4743872dbf89b3654eeb423
[ "MIT" ]
1
2021-09-05T20:50:59.000Z
2021-09-05T20:50:59.000Z
src/Event/KeyboardEvent.hpp
billy4479/sdl-tests
df7d519f740d5862c4743872dbf89b3654eeb423
[ "MIT" ]
null
null
null
src/Event/KeyboardEvent.hpp
billy4479/sdl-tests
df7d519f740d5862c4743872dbf89b3654eeb423
[ "MIT" ]
null
null
null
#pragma once #include "Event.hpp" #include "KeyCodes.hpp" namespace BillyEngine { class KeyboardEvent : public Event { public: KeyboardEvent(Key::KeyCode keyCode, Key::Mods::Mods mods) : m_Key(keyCode), m_Mods(mods) {} EVENT_CLASS_CATEGORY(EventCategory::Input | EventCategory::Keyboard) Key::KeyCode GetKeyCode() { return m_Key; } Key::Mods::Mods GetKeyMods() { return m_Mods; } protected: Key::KeyCode m_Key; Key::Mods::Mods m_Mods; }; class KeyPressedEvent : public KeyboardEvent { public: KeyPressedEvent(const Key::KeyCode keycode, const Key::Mods::Mods mods) : KeyboardEvent(keycode, mods) {} std::string ToString() const override { std::stringstream ss; ss << "KeyPressedEvent: " << m_Key; return ss.str(); } EVENT_CLASS_TYPE(KeyPressed) }; class KeyReleasedEvent : public KeyboardEvent { public: KeyReleasedEvent(const Key::KeyCode keycode, const Key::Mods::Mods mods) : KeyboardEvent(keycode, mods) {} std::string ToString() const override { std::stringstream ss; ss << "KeyReleasedEvent: " << m_Key; return ss.str(); } EVENT_CLASS_TYPE(KeyReleased) }; } // namespace BillyEngine
24.82
76
0.65834
billy4479
02a7a66dfb63a9527f9cb4ae8e89f1d70cb2a936
4,331
cpp
C++
lib/Parser/FunctionBuilder.cpp
scross99/locic
a24bb380e17f8af69e7389acf8ce354c91a2abf3
[ "MIT" ]
80
2015-02-19T21:38:57.000Z
2016-05-25T06:53:12.000Z
lib/Parser/FunctionBuilder.cpp
scross99/locic
a24bb380e17f8af69e7389acf8ce354c91a2abf3
[ "MIT" ]
8
2015-02-20T09:47:20.000Z
2015-11-13T07:49:17.000Z
lib/Parser/FunctionBuilder.cpp
scross99/locic
a24bb380e17f8af69e7389acf8ce354c91a2abf3
[ "MIT" ]
6
2015-02-20T11:26:19.000Z
2016-04-13T14:30:39.000Z
#include <locic/AST.hpp> #include <locic/Debug/SourcePosition.hpp> #include <locic/Parser/FunctionBuilder.hpp> #include <locic/Parser/TokenReader.hpp> namespace locic { namespace Parser { FunctionBuilder::FunctionBuilder(const TokenReader& reader) : reader_(reader) { } FunctionBuilder::~FunctionBuilder() { } AST::Node<AST::Function> FunctionBuilder::makeFunctionDecl(bool isVarArg, bool isStatic, AST::Node<AST::TypeDecl> returnType, AST::Node<Name> name, AST::Node<AST::VarList> parameters, AST::Node<AST::ConstSpecifier> constSpecifier, AST::Node<AST::RequireSpecifier> noexceptSpecifier, AST::Node<AST::RequireSpecifier> requireSpecifier, const Debug::SourcePosition& start) { const auto location = reader_.locationWithRangeFrom(start); std::unique_ptr<AST::Function> function(new AST::Function()); function->setIsVarArg(isVarArg); function->setIsStatic(isStatic); function->setNameDecl(std::move(name)); function->setReturnType(std::move(returnType)); function->setParameterDecls(std::move(parameters)); function->setConstSpecifier(std::move(constSpecifier)); function->setNoexceptSpecifier(std::move(noexceptSpecifier)); function->setRequireSpecifier(std::move(requireSpecifier)); return AST::makeNode(location, function.release()); } AST::Node<AST::Function> FunctionBuilder::makeFunctionDef(bool isVarArg, bool isStatic, AST::Node<AST::TypeDecl> returnType, AST::Node<Name> name, AST::Node<AST::VarList> parameters, AST::Node<AST::ConstSpecifier> constSpecifier, AST::Node<AST::RequireSpecifier> noexceptSpecifier, AST::Node<AST::RequireSpecifier> requireSpecifier, AST::Node<AST::Scope> scope, const Debug::SourcePosition& start) { const auto location = reader_.locationWithRangeFrom(start); std::unique_ptr<AST::Function> function(new AST::Function()); function->setIsVarArg(isVarArg); function->setIsStatic(isStatic); function->setNameDecl(std::move(name)); function->setReturnType(std::move(returnType)); function->setParameterDecls(std::move(parameters)); function->setConstSpecifier(std::move(constSpecifier)); function->setNoexceptSpecifier(std::move(noexceptSpecifier)); function->setRequireSpecifier(std::move(requireSpecifier)); function->setScope(std::move(scope)); return AST::makeNode(location, function.release()); } AST::Node<AST::Function> FunctionBuilder::makeDefaultMethod(bool isStatic, AST::Node<Name> name, AST::Node<AST::RequireSpecifier> requireSpecifier, const Debug::SourcePosition& start) { const auto location = reader_.locationWithRangeFrom(start); std::unique_ptr<AST::Function> function(new AST::Function()); function->setIsStatic(isStatic); function->setAutoGenerated(true); function->setNameDecl(std::move(name)); function->setRequireSpecifier(std::move(requireSpecifier)); return AST::makeNode(location, function.release()); } AST::Node<AST::Function> FunctionBuilder::makeDestructor(AST::Node<Name> name, AST::Node<AST::Scope> scope, const Debug::SourcePosition& start) { const auto location = reader_.locationWithRangeFrom(start); std::unique_ptr<AST::Function> function(new AST::Function()); function->setNameDecl(std::move(name)); function->setReturnType(AST::makeNode(scope.location(), AST::TypeDecl::Void())); function->setParameterDecls(AST::makeDefaultNode<AST::VarList>()); function->setScope(std::move(scope)); return AST::makeNode(location, function.release()); } AST::Node<Name> FunctionBuilder::makeName(Name name, const Debug::SourcePosition& start) { const auto location = reader_.locationWithRangeFrom(start); return AST::makeNode(location, new Name(std::move(name))); } } }
45.589474
94
0.641422
scross99
02aa9fbddd18b0f443fd9499e88de2f5ab907888
198
hh
C++
Include/Zion/Main.hh
zionmultiplayer/Client
291c027c4011cb1ab207c9b394fb5f4b1da8652c
[ "MIT" ]
4
2022-02-08T07:04:49.000Z
2022-02-09T23:43:49.000Z
Include/Zion/Main.hh
zionmultiplayer/Client
291c027c4011cb1ab207c9b394fb5f4b1da8652c
[ "MIT" ]
null
null
null
Include/Zion/Main.hh
zionmultiplayer/Client
291c027c4011cb1ab207c9b394fb5f4b1da8652c
[ "MIT" ]
null
null
null
#pragma once #include "Game/CPad.h" #include "Game/CPlayerPed.h" namespace Zion { class Main { public: static CPlayerPed *player; static CPad *pad; }; };
15.230769
38
0.560606
zionmultiplayer
02abbb2801446ddd72cdac1c1ee8d8876f2d97eb
1,018
hpp
C++
src/metal-driver/pseudo_operators.hpp
metalfs/metal_fs
f244d4125622849f36bd7846881a5f3a7efca188
[ "MIT" ]
12
2020-04-21T05:21:32.000Z
2022-02-19T11:27:18.000Z
src/metal-driver/pseudo_operators.hpp
metalfs/metal_fs
f244d4125622849f36bd7846881a5f3a7efca188
[ "MIT" ]
10
2019-02-10T17:10:16.000Z
2020-02-01T20:05:42.000Z
src/metal-driver/pseudo_operators.hpp
metalfs/metal_fs
f244d4125622849f36bd7846881a5f3a7efca188
[ "MIT" ]
4
2020-07-15T04:42:20.000Z
2022-02-19T11:27:19.000Z
#pragma once #include <stdint.h> #include <cxxopts.hpp> namespace metal { class OperatorAgent; class DatagenOperator { public: static std::string id() { return "datagen"; } static bool isDatagenAgent(const OperatorAgent &agent); static void validate(OperatorAgent &agent); static bool isProfilingEnabled(OperatorAgent &agent); static uint64_t datagenLength(OperatorAgent &agent); static void setInputFile(OperatorAgent &agent); protected: static cxxopts::ParseResult parseOptions(OperatorAgent &agent); }; class MetalCatOperator { public: static std::string id() { return "metal-cat"; } static bool isMetalCatAgent(const OperatorAgent &agent); static void validate(OperatorAgent &agent); static bool isProfilingEnabled(OperatorAgent &agent); static void setInputFile(OperatorAgent &agent); protected: static cxxopts::ParseResult parseOptions(OperatorAgent &agent); }; class DevNullFile { public: static bool isNullOutput(const OperatorAgent &agent); }; } // namespace metal
24.238095
65
0.764244
metalfs
02abf685440a7045f4f1884222d8248747a38684
1,424
cpp
C++
util/Bip39.cpp
velezladonna/mwc-qt-wallet
bd241b91d28350e17e52a10208e663fcb992d7cc
[ "Apache-2.0" ]
1
2020-03-19T10:02:16.000Z
2020-03-19T10:02:16.000Z
util/Bip39.cpp
velezladonna/mwc-qt-wallet
bd241b91d28350e17e52a10208e663fcb992d7cc
[ "Apache-2.0" ]
null
null
null
util/Bip39.cpp
velezladonna/mwc-qt-wallet
bd241b91d28350e17e52a10208e663fcb992d7cc
[ "Apache-2.0" ]
null
null
null
// Copyright 2019 The MWC Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "Bip39.h" #include <QApplication> #include "../control/messagebox.h" #include <QFile> #include <QTextStream> namespace util { static QSet<QString> bip39words; const QSet<QString> & getBip39words() { if (bip39words.empty()) { // load the words QFile file(":/txt/bip39_words.txt"); if (!file.open(QFile::ReadOnly)) { control::MessageBox::messageText(nullptr, "Fatal Error", "Unable to read bip39 dictionary from the resources"); QApplication::quit(); return bip39words; } QTextStream in(&file); while(!in.atEnd()) { QString line = in.readLine().trimmed(); if (line.isEmpty()) continue; bip39words += line; } file.close(); } return bip39words; } }
27.384615
123
0.643258
velezladonna
02ad6389b3ff30b8ad3461909f013803a088a115
1,575
hpp
C++
include/humanity/io/file.hpp
crimsonwoods/humanity
5c2cc601eb8823ca7c06a0bef5cde0122b4d067a
[ "MIT" ]
1
2019-04-16T16:06:05.000Z
2019-04-16T16:06:05.000Z
include/humanity/io/file.hpp
crimsonwoods/humanity
5c2cc601eb8823ca7c06a0bef5cde0122b4d067a
[ "MIT" ]
null
null
null
include/humanity/io/file.hpp
crimsonwoods/humanity
5c2cc601eb8823ca7c06a0bef5cde0122b4d067a
[ "MIT" ]
null
null
null
/** * ファイルを扱うためのクラス定義ファイル * @file file.hpp */ #ifndef HUMANITY_IO_FILE_H #define HUMANITY_IO_FILE_H #include <humanity/io/io.hpp> HUMANITY_IO_NS_BEGIN class path; /** * ファイルを扱うためのクラス */ class file { public: /** * ファイルのモードを表す定数値群 */ enum { FMODE_USER_READ = 0400, FMODE_USER_WRITE = 0200, FMODE_USER_EXEC = 0100, FMODE_USER_RW = FMODE_USER_READ | FMODE_USER_WRITE, FMODE_USER_RX = FMODE_USER_READ | FMODE_USER_EXEC, FMODE_USER_WX = FMODE_USER_WRITE | FMODE_USER_EXEC, FMODE_USER_RWX = FMODE_USER_READ | FMODE_USER_WRITE | FMODE_USER_EXEC, FMODE_GROUP_READ = 0040, FMODE_GROUP_WRITE = 0020, FMODE_GROUP_EXEC = 0010, FMODE_GROUP_RW = FMODE_GROUP_READ | FMODE_GROUP_WRITE, FMODE_GROUP_RX = FMODE_GROUP_READ | FMODE_GROUP_EXEC, FMODE_GROUP_WX = FMODE_GROUP_WRITE | FMODE_GROUP_EXEC, FMODE_GROUP_RWX = FMODE_GROUP_READ | FMODE_GROUP_WRITE | FMODE_GROUP_EXEC, FMODE_OTHER_READ = 0004, FMODE_OTHER_WRITE = 0002, FMODE_OTHER_EXEC = 0001, FMODE_OTHER_RW = FMODE_OTHER_READ | FMODE_OTHER_WRITE, FMODE_OTHER_RX = FMODE_OTHER_READ | FMODE_OTHER_EXEC, FMODE_OTHER_WX = FMODE_OTHER_WRITE | FMODE_OTHER_EXEC, FMODE_OTHER_RWX = FMODE_OTHER_READ | FMODE_OTHER_WRITE | FMODE_OTHER_EXEC, }; static bool is_link(path const &path); static bool is_exist(path const &path); static bool chmod(path const &path, uint16_t mode); static bool remove(path const &path); static bool rename(path const &src, path const &dst); }; HUMANITY_IO_NS_END #endif // end of HUMANITY_IO_FILE_H
27.155172
79
0.743492
crimsonwoods
02b389941a8f99833ac436c39a06ca1cd9194c53
72
cpp
C++
MailClient/sources/gui/Tasks.cpp
SRIIIXI/XDesk
4324763a7d981bb3c335d153ebf27a6ddf1cfc13
[ "BSD-2-Clause" ]
null
null
null
MailClient/sources/gui/Tasks.cpp
SRIIIXI/XDesk
4324763a7d981bb3c335d153ebf27a6ddf1cfc13
[ "BSD-2-Clause" ]
null
null
null
MailClient/sources/gui/Tasks.cpp
SRIIIXI/XDesk
4324763a7d981bb3c335d153ebf27a6ddf1cfc13
[ "BSD-2-Clause" ]
null
null
null
#include "Tasks.h" Tasks::Tasks(QWidget *parent) : QWidget(parent) { }
12
47
0.680556
SRIIIXI
02b6fd676b8055976f0aff9d4ac0daf6de01459b
16,979
cpp
C++
DocCluster/src/DCController.cpp
McGill-DMaS/FIHC
6928f6fdf62f0e0de004623a8f956e4ca3b3afa1
[ "Apache-2.0" ]
null
null
null
DocCluster/src/DCController.cpp
McGill-DMaS/FIHC
6928f6fdf62f0e0de004623a8f956e4ca3b3afa1
[ "Apache-2.0" ]
null
null
null
DocCluster/src/DCController.cpp
McGill-DMaS/FIHC
6928f6fdf62f0e0de004623a8f956e4ca3b3afa1
[ "Apache-2.0" ]
null
null
null
// DCController.cpp: implementation of the CDCController class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #if !defined(DCCONTROLLER_H) #include "DCController.h" #endif #if !defined(DCKMEANSMGR_H) #include "DCKMeansMgr.h" #endif #if !defined(DCCLUTOMGR_H) #include "DCClutoMgr.h" #endif #if !defined(BFFILEHELPER_H) #include "BFFileHelper.h" #endif char runningChars [] = {'-', '\\', '|', '/'}; CDCDebug* debugObject = new CDCDebug(); ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CDCController::CDCController() { } CDCController::~CDCController() { cleanup(); } BOOL CDCController::initialize(TDCAlgoMode algoMode) { if (!m_treeBuilder.initialize(&m_clusterMgr)) return FALSE; if (!m_evalMgr.initialize(algoMode, &m_docMgr, &m_clusterMgr)) return FALSE; if (!m_outputMgr.initialize(algoMode, &m_docMgr, &m_clusterMgr, &m_clusterMgr2)) return FALSE; return TRUE; } void CDCController::cleanup() { delete debugObject; debugObject = NULL; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- BOOL CDCController::runFreqItems(FLOAT globalSupport, FLOAT clusterSupport, int kClusters, LPCTSTR inputDir) { // Document Manager reads all the files CString docSetDirPath = inputDir; docSetDirPath += DC_DOCUMENTS_DIRECTORY; CString stopWordFilePath = inputDir; stopWordFilePath += DC_STOPWORDS_FILENAME; m_docMgr.setDocDirectory((LPCTSTR) docSetDirPath); m_docMgr.setStopWordFile(DC_STOPWORDS_FILENAME); m_docMgr.setMinSupport(globalSupport); m_docMgr.preProcess(); CDCDocuments* pAllDocs = NULL; m_docMgr.getAllDocs(pAllDocs); ASSERT(pAllDocs); CDCFreqItemsets * pF1 = NULL; m_docMgr.getF1Sets(pF1); ASSERT(pF1); DEBUGPrint(_T("********\n")); DEBUGPrint(_T("* FIHC *\n")); DEBUGPrint(_T("********\n")); CDCDebug::printTime(); // Frequent Item Manager mines the frequent itemset (Apriori) m_freqItemMgr.setMinGlobalSupport(globalSupport); if (!m_freqItemMgr.mineGlobalFreqItemsets(pAllDocs, pF1)) { ASSERT(FALSE); return FALSE; } CDCFreqItemsets* pGlobalFreqItemsets = NULL; m_freqItemMgr.getGlobalFreqItemsets(pGlobalFreqItemsets); ASSERT(pGlobalFreqItemsets); #ifdef _DEBUG_PRT_INFO DEBUGPrint("Global frequent itemsets\n"); debugObject->printFreqItemsets(*pGlobalFreqItemsets); #endif // Cluster Manager builds the clusters of documents CDCDebug::printTime(); if (TRUE) { // tree based clustering if (!m_clusterMgr.makeClusters(pAllDocs, pGlobalFreqItemsets, clusterSupport)) { ASSERT(FALSE); return FALSE; } } else { // linear clustering m_clusterMgr2.setAllDocs(pAllDocs); m_clusterMgr2.setClusterSupport(clusterSupport); TDCClusterOrderType orderType = ORDER_TYPE_GLOBAL_SUP; BOOL descOrAsc = TRUE; if(!m_clusterMgr2.produceClusters(pGlobalFreqItemsets, orderType, descOrAsc)) { ASSERT(FALSE); return FALSE; } } // Tree Builder constructs the topical tree CDCDebug::printTime(); if (!m_treeBuilder.buildTree()) { ASSERT(FALSE); return FALSE; } // Remove empty clusters CDCDebug::printTime(); if (!m_treeBuilder.removeEmptyClusters(FALSE)) { ASSERT(FALSE); return FALSE; } /* // Pruning clusters from tree if (!m_treeBuilder.pruneTree()) { ASSERT(FALSE); return FALSE; } */ if (TRUE) { // prune children based on inter-cluster similarity with parent if (!m_treeBuilder.pruneChildren()) { ASSERT(FALSE); return FALSE; } /* // Remove empty clusters if (!m_treeBuilder.removeEmptyClusters(TRUE)) { ASSERT(FALSE); return FALSE; } */ // inter-cluster similarity based pruning if (!m_treeBuilder.interSimPrune(kClusters)) { ASSERT(FALSE); return FALSE; } /* // similarity based pruning if (!m_treeBuilder.simBasedPrune(kClusters)) { ASSERT(FALSE); return FALSE; } */ // score based pruning if (!m_treeBuilder.interSimOverPrune(kClusters)) { ASSERT(FALSE); return FALSE; } } else { // score based pruning if (!m_treeBuilder.interSimOverPrune(kClusters)) { ASSERT(FALSE); return FALSE; } } // Evaluate clusters using overall similairty CDCDebug::printTime(); CDCClusterWH* pClusterWH = NULL; m_clusterMgr.getClusterWH(pClusterWH); CDCCluster* pRoot = NULL; if (!pClusterWH->getTreeRoot(pRoot)) { ASSERT(FALSE); return FALSE; } // Evaluate clusters using FMeasure FLOAT fMeasure = 0.0f; if (!m_evalMgr.evalFMeasure(pRoot, fMeasure)) { ASSERT(FALSE); return FALSE; } DEBUGPrint(_T("F-Measure = %f\n"), fMeasure); // Evaluate overall similarity FLOAT overallSim = 0.0f; if (!m_evalMgr.evalOverallSimilarity(pRoot, overallSim)) { ASSERT(FALSE); return FALSE; } //DEBUGPrint(_T("Overall similarity = %f\n"), overallSim); // Evaluate clusters using entropy FLOAT entropyH = 0.0f; if (!m_evalMgr.evalEntropyHierarchical(pRoot, entropyH)) { ASSERT(FALSE); return FALSE; } //DEBUGPrint(_T("Entropy (Hierarchical) = %f\n"), entropyH); FLOAT entropyF = 0.0f; if (!m_evalMgr.evalEntropyFlat(pRoot, entropyF)) { ASSERT(FALSE); return FALSE; } DEBUGPrint(_T("Entropy (Flat) = %f\n"), entropyF); // Output Manager organizes and displays the results to user CString inputDirStr = inputDir; CString prefixStr; int slashPos = inputDirStr.ReverseFind(TCHAR('\\')); if (slashPos == -1) prefixStr = DC_XML_FREQITEM_FILENAME; else prefixStr = inputDirStr.Mid(slashPos + 1); CString outFilePath = makeOutFilePath(_T(".."), (LPCTSTR) prefixStr, globalSupport, clusterSupport, kClusters, fMeasure, entropyF); if (!m_outputMgr.produceOutput((LPCTSTR) outFilePath, fMeasure, overallSim, entropyH, entropyF)) { ASSERT(FALSE); return FALSE; } DEBUGPrint(_T("Output file: %s\n"), outFilePath); CDCDebug::printTime(); return TRUE; } //--------------------------------------------------------------------------- // Run the K-Means algorithm //--------------------------------------------------------------------------- BOOL CDCController::runKMeans(int kClusters, LPCTSTR inputDir) { // Document Manager reads all the files CString docSetDirPath = inputDir; docSetDirPath += DC_DOCUMENTS_DIRECTORY; CString stopWordFilePath = inputDir; stopWordFilePath += DC_STOPWORDS_FILENAME; m_docMgr.setDocDirectory((LPCTSTR) docSetDirPath); m_docMgr.setStopWordFile(DC_STOPWORDS_FILENAME); m_docMgr.setMinSupport(0.0f); m_docMgr.preProcess(); CDCDocuments* pAllDocs = NULL; m_docMgr.getAllDocs(pAllDocs); ASSERT(pAllDocs); #ifdef DC_DOCVECTOR_CONVERTOR if (!writeVectorsFile(pAllDocs)) { ASSERT(FALSE); return FALSE; } return TRUE; #endif // Run the K-Means algorithm DEBUGPrint("***********\n"); DEBUGPrint("* K-Means *\n"); DEBUGPrint("***********\n"); CDCDebug::printTime(); CDCKMeansMgr kMeansMgr; if (!kMeansMgr.makeClusters(kClusters, pAllDocs)) { ASSERT(FALSE); return FALSE; } CDCDebug::printTime(); CDCCluster* pRoot = NULL; kMeansMgr.getRoot(pRoot); CDCClusters* pChildren = NULL; pRoot->getTreeChildren(pChildren); // Evaluate clusters using FMeasure FLOAT fMeasure = 0.0f; if (!m_evalMgr.evalFMeasure(pRoot, fMeasure)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("F-Measure = %f\n"), fMeasure); // Evaluate clusters using overall similairty FLOAT overallSim = 0.0f; if (!m_evalMgr.evalOverallSimilarity(pRoot, overallSim)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } //DEBUGPrint(_T("Overall similarity = %f\n"), overallSim); // Evaluate clusters using entropy FLOAT entropyH = 0.0f; if (!m_evalMgr.evalEntropyHierarchical(pRoot, entropyH)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("Entropy (Hierarchical) = %f\n"), entropyH); FLOAT entropyF = 0.0f; if (!m_evalMgr.evalEntropyFlat(pRoot, entropyF)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("Entropy (Flat) = %f\n"), entropyF); // Output Manager organizes and displays the results to user CString inputDirStr = inputDir; CString prefixStr = DC_XML_KMEANS_FILENAME; int slashPos = inputDirStr.ReverseFind(TCHAR('\\')); if (slashPos != -1) prefixStr += inputDirStr.Mid(slashPos + 1); CString outFilePath = makeOutFilePath(_T(".."), (LPCTSTR) prefixStr, 0.0f, 0.0f, kClusters, fMeasure, entropyF); if (!m_outputMgr.produceOutput((LPCTSTR) outFilePath, pRoot, fMeasure, overallSim, entropyH, entropyF)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("Output file: %s\n"), outFilePath); CDCDebug::printTime(); pChildren->cleanup(); return TRUE; } //--------------------------------------------------------------------------- // Run the Cluto evaluator //--------------------------------------------------------------------------- BOOL CDCController::runCluto(LPCTSTR solFile, LPCTSTR classFile) { DEBUGPrint("*******************\n"); DEBUGPrint("* Cluto Evaluator *\n"); DEBUGPrint("*******************\n"); CDCClutoMgr clutoMgr; if (!clutoMgr.makeClusters(solFile, classFile)) { ASSERT(FALSE); return FALSE; } CDCCluster* pRoot = NULL; clutoMgr.getRoot(pRoot); CDCClusters* pChildren = NULL; pRoot->getTreeChildren(pChildren); // Evaluate clusters using FMeasure FLOAT fMeasure = 0.0f; if (!m_evalMgr.evalFMeasure(pRoot, fMeasure)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("F-Measure = %f\n"), fMeasure); // Evaluate clusters using overall similairty FLOAT overallSim = 0.0f; if (!m_evalMgr.evalOverallSimilarity(pRoot, overallSim)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } //DEBUGPrint(_T("Overall similarity = %f\n"), overallSim); // Evaluate clusters using entropy FLOAT entropyH = 0.0f; if (!m_evalMgr.evalEntropyHierarchical(pRoot, entropyH)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("Entropy (Hierarchical) = %f\n"), entropyH); FLOAT entropyF = 0.0f; if (!m_evalMgr.evalEntropyFlat(pRoot, entropyF)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("Entropy (Flat) = %f\n"), entropyF); // get number of clusters CString drive, dir, fname, ext; CBFFileHelper::splitPath(solFile, drive, dir, fname, ext); ext = ext.Mid(1); int kClusters = StrToInt((LPCTSTR) ext); // Output Manager organizes and displays the results to user CString outFilePath = makeOutFilePath(drive + dir, DC_XML_CLUTO_FILENAME, 0.0f, 0.0f, kClusters, fMeasure, entropyF); if (!m_outputMgr.produceOutput((LPCTSTR) outFilePath, pRoot, fMeasure, overallSim, entropyH, entropyF)) { ASSERT(FALSE); pChildren->cleanup(); return FALSE; } DEBUGPrint(_T("Output file: %s\n"), outFilePath); pChildren->cleanup(); return TRUE; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- CString CDCController::makeOutFilePath(LPCTSTR dir, LPCTSTR fileNamePrefix, FLOAT globalSupport, FLOAT clusterSupport, int kClusters, FLOAT fm, FLOAT entropyF) { time_t ltime; time(&ltime); CString outFilePath = dir; if (outFilePath.Right(1) != _T("\\") && outFilePath.Right(1) != _T("/")) outFilePath += _T("\\"); outFilePath += fileNamePrefix; CString gsStr; int gsSupport = (int) (globalSupport * 100.5f); if (gsSupport >= 100) gsStr.Format(_T("%d"), gsSupport); else if (gsSupport >= 10) gsStr.Format(_T("0%d"), gsSupport); else gsStr.Format(_T("00%d"), gsSupport); gsStr = gsStr.Left(3); CString csStr; int csSupport = (int) (clusterSupport * 100.5f); if (csSupport >= 100) csStr.Format(_T("%d"), csSupport); else if (csSupport >= 10) csStr.Format(_T("0%d"), csSupport); else csStr.Format(_T("00%d"), csSupport); csStr = csStr.Left(3); CString kcStr; if (kClusters >= 100) kcStr.Format(_T("%d"), kClusters); else if (kClusters >= 10) kcStr.Format(_T("0%d"), kClusters); else kcStr.Format(_T("00%d"), kClusters); kcStr = kcStr.Left(3); CString fmStr; fmStr.Format(_T("_%f"), fm); CString entropyFStr; entropyFStr.Format(_T("_%f"), entropyF); CString timeStr; timeStr.Format(_T("_%ld"), ltime); outFilePath += gsStr + csStr + kcStr + fmStr + entropyFStr + DC_XML_EXT; return outFilePath; } //--------------------------------------------------------------------------- // Write vectors to the file //--------------------------------------------------------------------------- BOOL CDCController::writeVectorsFile(CDCDocuments* pAllDocs) { int nDocs = pAllDocs->GetSize(); if (nDocs == 0) return TRUE; CString vectorFileName = _T("vectors.mat"); CString classFileName = _T("vectors.mat.rclass"); CString labelFileName = _T("vectors.mat.clabel"); CStdioFile vectorFile, classFile, labelFile; if (!vectorFile.Open(vectorFileName, CFile::modeCreate | CFile::modeWrite)) { ASSERT(FALSE); return FALSE; } if (!classFile.Open(classFileName, CFile::modeCreate | CFile::modeWrite)) { ASSERT(FALSE); vectorFile.Close(); return FALSE; } // get number of nonzero entries int nonZeroEntry = 0; CDCDocument* pDoc = NULL; CDCDocVector* pDocVector = NULL; for (int i = 0; i < nDocs; ++i) { DEBUGPrint(_T("%d\r"), i); pDoc = pAllDocs->GetAt(i); pDoc->getDocVector(pDocVector); int vectorSize = pDocVector->GetSize(); for (int v = 0; v < vectorSize; ++v) { if ((*pDocVector)[v] > 0) { ++nonZeroEntry; } } } // # of docs, # of distinct words, # of nonzero entries CString outStr; ((CDCDocument*) pAllDocs->GetAt(0))->getDocVector(pDocVector); int vectorSize = pDocVector->GetSize(); outStr.Format(_T("%d %d %d\n"), nDocs, vectorSize, nonZeroEntry); vectorFile.WriteString(outStr); for (i = 0; i < nDocs; ++i) { DEBUGPrint(_T("%d\r"), i); pDoc = pAllDocs->GetAt(i); pDoc->getDocVector(pDocVector); vectorSize = pDocVector->GetSize(); outStr.Empty(); for (int v = 0; v < vectorSize; ++v) { if ((*pDocVector)[v] > 0) { CString temp; temp.Format(_T(" %d %d"), v + 1, (*pDocVector)[v]); outStr += temp; } } vectorFile.WriteString(outStr + _T("\n")); classFile.WriteString(pDoc->getClassName() + _T("\n")); } classFile.Close(); vectorFile.Close(); // write label file if (!labelFile.Open(labelFileName, CFile::modeCreate | CFile::modeWrite)) { ASSERT(FALSE); return FALSE; } CString labelStr; for (int v = 0; v < vectorSize; ++v) { if (!m_docMgr.getFreqTermFromID(v, labelStr)) { ASSERT(FALSE); return FALSE; } labelFile.WriteString(labelStr + _T("\n")); } labelFile.Close(); return TRUE; }
30.428315
160
0.566464
McGill-DMaS
02ba104c1168ba8820fcfeb2afa53da656a9db43
2,194
cpp
C++
Code/GUI/ProgressBar.cpp
BomjSoft/BCL
f6863035d987b3fad184db8533d395d73beaf601
[ "MIT" ]
null
null
null
Code/GUI/ProgressBar.cpp
BomjSoft/BCL
f6863035d987b3fad184db8533d395d73beaf601
[ "MIT" ]
null
null
null
Code/GUI/ProgressBar.cpp
BomjSoft/BCL
f6863035d987b3fad184db8533d395d73beaf601
[ "MIT" ]
null
null
null
//--------------------------------------------------------------------------- #include "ProgressBar.h" //--------------------------------------------------------------------------- namespace bcl { //--------------------------------------------------------------------------- CProgressBar::CProgressBar() : CComponent() { minValue = 0; maxValue = 100; } //--------------------------------------------------------------------------- CProgressBar::~CProgressBar() { } //--------------------------------------------------------------------------- void CProgressBar::CreateObject(HWND Parent, DWORD Id) { InitExtComponent(ICC_PROGRESS_CLASS); hwnd = CreateWindowEx(0, PROGRESS_CLASS, caption, WS_CHILD | (visible?WS_VISIBLE:0) | PBS_SMOOTH, left, top, width, height, Parent, HMENU(Id), GetModuleHandle(nullptr), nullptr); created = true; SendMessage(hwnd, PBM_SETRANGE, TRUE, MAKELPARAM(minValue, maxValue)); if (!enable) { SetEnable(false); } } //--------------------------------------------------------------------------- LRESULT CProgressBar::Message(UINT Type) { return 0; } //--------------------------------------------------------------------------- void CProgressBar::SetRange(int Min, int Max) { minValue = Min; maxValue = Max; if (created) { SendMessage(hwnd, PBM_SETRANGE, TRUE, MAKELPARAM(minValue, maxValue)); } } //--------------------------------------------------------------------------- void CProgressBar::SetPosition(int Value) { SendMessage(hwnd, PBM_SETPOS, Value, 0); } //--------------------------------------------------------------------------- void CProgressBar::SetStep(int Value) { SendMessage(hwnd, PBM_SETSTEP, Value, 0); } //--------------------------------------------------------------------------- void CProgressBar::Update(int StepCount) { SendMessage(hwnd, PBM_DELTAPOS, StepCount, 0); } //--------------------------------------------------------------------------- void CProgressBar::Update() { SendMessage(hwnd, PBM_STEPIT, 0, 0); } //--------------------------------------------------------------------------- }
30.472222
182
0.377393
BomjSoft
02babea15d1ecfd6da55df55bc1e7c4062d5c06d
1,124
cpp
C++
codeforces/659/c.cpp
udayan14/Competitive_Coding
79e23fdeb909b4161a193d88697a4fe5f4fbbdce
[ "MIT" ]
null
null
null
codeforces/659/c.cpp
udayan14/Competitive_Coding
79e23fdeb909b4161a193d88697a4fe5f4fbbdce
[ "MIT" ]
null
null
null
codeforces/659/c.cpp
udayan14/Competitive_Coding
79e23fdeb909b4161a193d88697a4fe5f4fbbdce
[ "MIT" ]
null
null
null
#include <iostream> #include <cassert> #include <cstring> #include <vector> #include <string> #include <set> #include <map> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t--){ int n; cin >> n; string a,b; cin >> a >> b; bool flag = true; map<char,set<int>> m; for(int i=0 ; i<n ; i++){ if(a[i] > b[i]){ flag = false; } if(a[i]==b[i]) continue; m[a[i]].insert(i); } if(!flag){ cout << -1 << "\n"; continue; } int output = 0; for(char c='a' ; c<='t' ; c++){ if(m[c].size()==0) continue; char temp = 'z'; for(auto ind : m[c]){ if(b[ind]<temp) temp=b[ind]; } for(auto ind : m[c]){ if(b[ind]==temp) continue; m[temp].insert(ind); } m[c].clear(); output++; } cout << output << "\n"; } return 0; }
21.615385
44
0.387011
udayan14
02bcd3a4e6afc4dd03196b29ddf3d91bf9e1ff1b
3,866
cc
C++
extern/glow-extras/material/glow-extras/material/IBL.cc
rovedit/Fort-Candle
445fb94852df56c279c71b95c820500e7fb33cf7
[ "MIT" ]
null
null
null
extern/glow-extras/material/glow-extras/material/IBL.cc
rovedit/Fort-Candle
445fb94852df56c279c71b95c820500e7fb33cf7
[ "MIT" ]
null
null
null
extern/glow-extras/material/glow-extras/material/IBL.cc
rovedit/Fort-Candle
445fb94852df56c279c71b95c820500e7fb33cf7
[ "MIT" ]
null
null
null
#include "IBL.hh" #include <glow/common/str_utils.hh> #include <glow/data/TextureData.hh> #include <glow/objects/Program.hh> #include <glow/objects/Texture2D.hh> #include <glow/objects/TextureCubeMap.hh> #include <glow/util/DefaultShaderParser.hh> #ifdef GLOW_EXTRAS_EMBED_SHADERS #include <glow-extras/generated/material_embed_shaders.hh> #endif #include <typed-geometry/tg.hh> #include "data/DefaultEnvmapData.hh" glow::SharedTexture2D glow::material::IBL::sEnvLutGGX = nullptr; glow::SharedTextureCubeMap glow::material::IBL::sDefaultEnvMap = nullptr; glow::SharedTexture2D glow::material::IBL::createEnvLutGGX(int width, int height) { // only one mip-map level auto tex = Texture2D::createStorageImmutable(width, height, GL_RG16F, 1); // setup { auto t = tex->bind(); t.setMinFilter(GL_LINEAR); t.setMagFilter(GL_LINEAR); t.setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); } // compute const int localSize = 4; auto shader = Program::createFromFile("glow-material/precalc-env-brdf-lut.csh"); { auto s = shader->use(); s.setImage(0, tex, GL_WRITE_ONLY); s.compute((width - 1) / localSize + 1, (height - 1) / localSize + 1); } return tex; } const glow::SharedTextureCubeMap& glow::material::IBL::getDefaultCubeMap() { if (!sDefaultEnvMap) { using namespace internal_embedded_files; sDefaultEnvMap = glow::TextureCubeMap::createFromData(glow::TextureData::createFromRawPngCube( defaultEnvPX, defaultEnvPXS, defaultEnvNX, defaultEnvNXS, defaultEnvPY, defaultEnvPYS, defaultEnvNY, defaultEnvNYS, defaultEnvPZ, defaultEnvPZS, defaultEnvNZ, defaultEnvNZS, glow::ColorSpace::Linear)); } return sDefaultEnvMap; } glow::SharedTextureCubeMap glow::material::IBL::createEnvMapGGX(const glow::SharedTextureCubeMap& envMap, int size) { // GL_RGB8 and GL_RGB16F are not supported! see https://www.opengl.org/sdk/docs/man/html/glBindImageTexture.xhtml auto tex = TextureCubeMap::createStorageImmutable(size, size, GL_RGBA16F); // setup { auto t = tex->bind(); t.setMinFilter(GL_LINEAR_MIPMAP_LINEAR); t.setMagFilter(GL_LINEAR); } // compute int const localSize = 4; auto shader = Program::createFromFile("glow-material/precalc-env-map.csh"); auto const maxLevel = (int)tg::floor(tg::log2((float)size)); { auto s = shader->use(); s.setTexture("uEnvMap", envMap); auto miplevel = 0; for (auto tsize = size; tsize > 0; tsize /= 2) { auto roughness = miplevel / (float)maxLevel; s.setUniform("uRoughness", roughness); s.setImage(0, tex, GL_WRITE_ONLY, miplevel); s.compute((tsize - 1) / localSize + 1, (tsize - 1) / localSize + 1, 6); ++miplevel; } } // we manually calculated all mipmaps tex->setMipmapsGenerated(true); { auto boundTex = tex->bind(); boundTex.setBaseLevel(0); boundTex.setMaxLevel(maxLevel); } return tex; } void glow::material::IBL::initShaderGGX(UsedProgram& shader, SharedTexture2D const& customLUT) { if (!customLUT && !sEnvLutGGX) sEnvLutGGX = createEnvLutGGX(); shader.setTexture("uGlowMaterialEnvLutGGX", customLUT ? customLUT : sEnvLutGGX); } void glow::material::IBL::prepareShaderGGX(UsedProgram& shader, SharedTextureCubeMap const& envMapGGX) { shader.setTexture("uGlowMaterialEnvMapGGX", envMapGGX); } void glow::material::IBL::GlobalInit() { #ifdef GLOW_EXTRAS_EMBED_SHADERS for (auto& virtualPair : internal_embedded_files::material_embed_shaders) DefaultShaderParser::addVirtualFile(virtualPair.first, virtualPair.second); #else DefaultShaderParser::addIncludePath(util::pathOf(__FILE__) + "/../../shader"); #endif }
30.68254
141
0.681324
rovedit
02be76086ccef99a5f863463431c62b50b535cad
1,209
hh
C++
examples/ScatteringExample/include/SEDetectorConstruction.hh
QTNM/Electron-Tracking
b9dff0232af5a99fd795fd504dbddde71f4dd31c
[ "MIT" ]
2
2022-03-16T22:30:19.000Z
2022-03-16T22:30:26.000Z
examples/ScatteringExample/include/SEDetectorConstruction.hh
QTNM/Electron-Tracking
b9dff0232af5a99fd795fd504dbddde71f4dd31c
[ "MIT" ]
18
2021-03-02T15:14:11.000Z
2022-02-14T08:12:20.000Z
examples/ScatteringExample/include/SEDetectorConstruction.hh
QTNM/Electron-Tracking
b9dff0232af5a99fd795fd504dbddde71f4dd31c
[ "MIT" ]
null
null
null
#ifndef SEDetectorConstruction_h #define SEDetectorConstruction_h 1 #include "G4Cache.hh" #include "G4GenericMessenger.hh" #include "G4VUserDetectorConstruction.hh" #include "globals.hh" class G4VPhysicalVolume; class G4GlobalMagFieldMessenger; class SEGasSD; class SEWatchSD; class SEDetectorConstruction : public G4VUserDetectorConstruction { public: SEDetectorConstruction(); ~SEDetectorConstruction(); public: virtual G4VPhysicalVolume* Construct(); virtual void ConstructSDandField(); void SetGeometry(const G4String& name); void SetDensity(G4double d); private: void DefineCommands(); void DefineMaterials(); G4VPhysicalVolume* SetupBaseline(); G4VPhysicalVolume* SetupBunches(); G4VPhysicalVolume* SetupShort(); G4GenericMessenger* fDetectorMessenger = nullptr; G4String fGeometryName = "baseline"; G4double fdensity; G4Cache<G4GlobalMagFieldMessenger*> fFieldMessenger = nullptr; G4Cache<SEGasSD*> fSD1 = nullptr; G4Cache<SEWatchSD*> fSD2 = nullptr; }; #endif
27.477273
76
0.659222
QTNM
02c6b4dbed15e710d6e9dbd33aee3f9119917f39
3,165
cpp
C++
GameDownloader/src/GameDownloader/Behavior/PostHookBehavior.cpp
ProtocolONE/cord.game-downloader
90950019937cd2974801ca2f53ed3b4ecd1d219b
[ "Apache-2.0" ]
1
2019-08-07T06:13:15.000Z
2019-08-07T06:13:15.000Z
GameDownloader/src/GameDownloader/Behavior/PostHookBehavior.cpp
ProtocolONE/cord.game-downloader
90950019937cd2974801ca2f53ed3b4ecd1d219b
[ "Apache-2.0" ]
null
null
null
GameDownloader/src/GameDownloader/Behavior/PostHookBehavior.cpp
ProtocolONE/cord.game-downloader
90950019937cd2974801ca2f53ed3b4ecd1d219b
[ "Apache-2.0" ]
null
null
null
#include <GameDownloader/Behavior/PostHookBehavior.h> #include <GameDownloader/ServiceState.h> #include <GameDownloader/GameDownloadService.h> #include <Core/Service.h> #include <QtConcurrent/QtConcurrentRun> namespace P1 { namespace GameDownloader { namespace Behavior { PostHookBehavior::PostHookBehavior(QObject *parent) : BaseBehavior(parent) { QObject::connect(this, SIGNAL(postHooksCompleted(P1::GameDownloader::ServiceState *, P1::GameDownloader::HookBase::HookResult)), SLOT(postHooksCompletedSlot(P1::GameDownloader::ServiceState *, P1::GameDownloader::HookBase::HookResult ))); } PostHookBehavior::~PostHookBehavior(void) { } void PostHookBehavior::start(P1::GameDownloader::ServiceState *state) { QtConcurrent::run(this, &PostHookBehavior::postHookLoop, state); } void PostHookBehavior::stop(P1::GameDownloader::ServiceState *state) { emit this->stopping(state); } void PostHookBehavior::postHookLoop(P1::GameDownloader::ServiceState *state) { Q_CHECK_PTR(state); Q_CHECK_PTR(state->service()); if (state->state() != ServiceState::Started) { emit this->postHooksCompleted(state, HookBase::Continue); // Походу надо будет урезать результаты хуков } const P1::Core::Service *service = state->service(); emit this->statusMessageChanged(state, QObject::tr("PRE_HOOK_DEFAULT_MESSAGE")); HookBase::HookResult result = HookBase::Continue; if(this->_afterDownloadHookMap.contains(service->id())) { Q_FOREACH(HookBase *hook, this->_afterDownloadHookMap[service->id()]) { if (state->state() != ServiceState::Started) { emit this->postHooksCompleted(state, HookBase::Continue); // Походу надо будет урезать результаты хуков return; } result = hook->afterDownload(this->_gameDownloadService, state); emit this->statusMessageChanged(state, QObject::tr("PRE_HOOK_DEFAULT_MESSAGE")); if (result != HookBase::Continue) break; } } emit this->postHooksCompleted(state, result); } void PostHookBehavior::postHooksCompletedSlot(ServiceState *state, HookBase::HookResult result) { // UNDONE Можно тут кстати обработать разные выходы с хуков и вызвать либо фейли либо разные выходы if (result == HookBase::Continue) emit this->next(Finished, state); else if (result == HookBase::CheckUpdate) emit this->next(ReturnToStart, state); else emit failed(state); } void PostHookBehavior::setGameDownloaderService(GameDownloadService *gameDownloadService) { this->_gameDownloadService = gameDownloadService; } void PostHookBehavior::registerHook(const QString& serviceId, int preHookPriority, HookBase *hook) { this->_afterDownloadHookMap[serviceId].insert(-preHookPriority, hook); } } } }
35.965909
137
0.64139
ProtocolONE
02c917b230168e05d5c19fecf4033164e612a287
1,149
hpp
C++
src/utils/DisplayConfiguration.hpp
bonnefoa/flowstats
64f3e2d4466596788174b508bc62838379162224
[ "MIT" ]
4
2020-07-21T12:34:26.000Z
2020-12-09T16:51:33.000Z
src/utils/DisplayConfiguration.hpp
bonnefoa/flowstats
64f3e2d4466596788174b508bc62838379162224
[ "MIT" ]
null
null
null
src/utils/DisplayConfiguration.hpp
bonnefoa/flowstats
64f3e2d4466596788174b508bc62838379162224
[ "MIT" ]
1
2020-07-21T12:34:31.000Z
2020-07-21T12:34:31.000Z
#pragma once #include "Field.hpp" #include "enum.h" #include <string> #include <vector> namespace flowstats { class DisplayConfiguration { public: DisplayConfiguration(); auto updateFieldSize(Field field, int delta) -> void; auto emptyFilter() { filter = ""; }; auto addFilterChar(int c) { filter.push_back(c); }; auto removeFilterChar() { filter.pop_back(); }; auto toggleMergedDirection() { mergeDirection = !mergeDirection; }; auto setMaxResults(int newMaxResults) { maxResults = newMaxResults; }; auto nextRateMode() -> void; auto previousRateMode() -> void; [[nodiscard]] auto getFieldToSize() const& { return fieldToSize; }; [[nodiscard]] auto getFilter() const& { return filter; }; [[nodiscard]] auto getMaxResults() const { return maxResults; }; [[nodiscard]] auto getMergeDirection() const { return mergeDirection; }; [[nodiscard]] auto getRateMode() const { return rateMode; }; private: std::vector<int> fieldToSize; std::string filter; bool mergeDirection = true; int maxResults = 1000; RateMode rateMode = +RateMode::AVG; }; } // namespace flowstats
27.357143
76
0.678851
bonnefoa
02caa5f3c7d730e77ef9a47742232d53e52cf02f
1,041
cpp
C++
UVA/DP/uva_10819_knapsack.cpp
raphasramos/competitive-programming
749b6726bd9d517d9143af7e9236d3e5e8cef49b
[ "MIT" ]
3
2020-05-15T17:15:10.000Z
2021-04-24T17:54:26.000Z
UVA/DP/uva_10819_knapsack.cpp
raphasramos/competitive-programming
749b6726bd9d517d9143af7e9236d3e5e8cef49b
[ "MIT" ]
null
null
null
UVA/DP/uva_10819_knapsack.cpp
raphasramos/competitive-programming
749b6726bd9d517d9143af7e9236d3e5e8cef49b
[ "MIT" ]
1
2019-06-24T18:41:49.000Z
2019-06-24T18:41:49.000Z
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define ll long long #define pq priority_queue #define mii map<int,int> typedef vector<int> vi; typedef pair<int,int> ii; typedef set<int> si; typedef vector<vi> vii; typedef vector<ii> vpi; typedef vector<ll> vll; int oo = (1e9) + 7; int tb[10205][105]; int m, n; int tmp; vi p, f; int dp(int money, int i) { if(money > tmp and money <= 2000 and i == n) return -oo; if(i == n or money == m) return 0; if(tb[money][i] != -1) return tb[money][i]; int ans = dp(money, i+1); if(money + p[i] <= m) ans = max(ans, dp(money + p[i], i+1) + f[i]); tb[money][i] = ans; return ans; } int main() { while(scanf("%d %d", &m, &n) != EOF) { p.assign(n+5, 0); f.assign(n+5, 0); for(int i = 0; i < n; i++) { scanf("%d %d", &p[i], &f[i]); } memset(tb, -1, sizeof tb); tmp = m; if(m + 200 > 2000) m += 200; printf("%d\n", dp(0, 0)); } }
20.82
71
0.513929
raphasramos
c4a82c434e58b321c715c96ac6bd83d5400cd1fe
5,802
cpp
C++
sdl2/sdlbird/Sprite.cpp
pdpdds/SDLGameProgramming
3af68e2133296f3e7bc3d7454d9301141bca2d5a
[ "BSD-2-Clause" ]
null
null
null
sdl2/sdlbird/Sprite.cpp
pdpdds/SDLGameProgramming
3af68e2133296f3e7bc3d7454d9301141bca2d5a
[ "BSD-2-Clause" ]
null
null
null
sdl2/sdlbird/Sprite.cpp
pdpdds/SDLGameProgramming
3af68e2133296f3e7bc3d7454d9301141bca2d5a
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (c) 2014, Wei Mingzhi <[email protected]>. * 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. The name of the author and contributors 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 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 WASABI SYSTEMS, INC * 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 "Sprite.h" CSprite::CSprite(SDL_Renderer *pRenderer, const char *szImageFileName, const char *szTxtFileName) { Load(pRenderer, szImageFileName, szTxtFileName); } CSprite::~CSprite() { if (m_pTexture != NULL) { SDL_DestroyTexture(m_pTexture); } } /** * This hash function has been taken from an Article in Dr Dobbs Journal. * This is normally a collision-free function, distributing keys evenly. * Collision can be avoided by comparing the key itself in last resort. */ inline unsigned int CalcTag(const char *sz) { unsigned int hash = 0; while (*sz) { hash += (unsigned short)*sz; hash += (hash << 10); hash ^= (hash >> 6); sz++; } hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); return hash; } void CSprite::Draw(SDL_Renderer *pRenderer, const char *szTag, int x, int y) { unsigned int uiTag = CalcTag(szTag); std::map<unsigned int, SpritePart_t>::iterator it = m_mapSpriteParts.find(uiTag); if (it != m_mapSpriteParts.end()) { SDL_Rect srcrect, dstrect; srcrect.x = it->second.X; srcrect.y = it->second.Y; srcrect.w = it->second.usWidth; srcrect.h = it->second.usHeight; dstrect.x = x; dstrect.y = y; dstrect.w = it->second.usWidth; dstrect.h = it->second.usHeight; SDL_RenderCopy(pRenderer, m_pTexture, &srcrect, &dstrect); } } void CSprite::DrawEx(SDL_Renderer *pRenderer, const char *szTag, int x, int y, double angle, SDL_RendererFlip flip) { unsigned int uiTag = CalcTag(szTag); std::map<unsigned int, SpritePart_t>::iterator it = m_mapSpriteParts.find(uiTag); if (it != m_mapSpriteParts.end()) { SDL_Rect srcrect, dstrect; srcrect.x = it->second.X; srcrect.y = it->second.Y; srcrect.w = it->second.usWidth; srcrect.h = it->second.usHeight; dstrect.x = x; dstrect.y = y; dstrect.w = it->second.usWidth; dstrect.h = it->second.usHeight; SDL_RenderCopyEx(pRenderer, m_pTexture, &srcrect, &dstrect, angle, NULL, flip); } } void CSprite::Load(SDL_Renderer *pRenderer, const char *szImageFileName, const char *szTxtFileName) { SDL_Surface *pSurface = SDL_LoadBMP(szImageFileName); if (pSurface == NULL) { fprintf(stderr, "CSprite::Load(): IMG_Load failed: %s\n", SDL_GetError()); return; } m_iTextureWidth = pSurface->w; m_iTextureHeight = pSurface->h; m_pTexture = SDL_CreateTextureFromSurface(pRenderer, pSurface); SDL_FreeSurface(pSurface); if (m_pTexture == NULL) { fprintf(stderr, "CSprite::Load(): SDL_CreateTextureFromSurface failed: %s\n", SDL_GetError()); return; } // Load txt file if (!LoadTxt(szTxtFileName)) { SDL_DestroyTexture(m_pTexture); m_pTexture = NULL; fprintf(stderr, "CSprite::Load(): LoadTxte failed\n"); return; } } bool CSprite::LoadTxt(const char *szTxtFileName) { SDL_RWops *rwops = SDL_RWFromFile(szTxtFileName, "r"); if (rwops == NULL) { return false; } char *pBuf = (char *)malloc(SDL_RWsize(rwops) + 1); if (pBuf == NULL) { SDL_RWclose(rwops); return false; } SDL_RWread(rwops, pBuf, 1, SDL_RWsize(rwops)); pBuf[SDL_RWsize(rwops)] = '\0'; SDL_RWclose(rwops); char *p = pBuf; while (p != NULL && *p != '\0') { char name[256]; int w, h; float x1, y1, x2, y2; if (sscanf(p, "%s %d %d %f %f %f %f", name, &w, &h, &x1, &y1, &x2, &y2) != 7) { p = strstr(p, "\n"); if (p != NULL) { while (*p == '\n') { p++; } } continue; } p = strstr(p, "\n"); if (p != NULL) { while (*p == '\n') { p++; } } SpritePart_t spritePart; spritePart.usWidth = w; spritePart.usHeight = h; spritePart.X = (unsigned short)(m_iTextureWidth * x1); spritePart.Y = (unsigned short)(m_iTextureHeight * y1); unsigned int uiTag = CalcTag(name); if (m_mapSpriteParts.find(uiTag) == m_mapSpriteParts.end()) { m_mapSpriteParts[uiTag] = spritePart; } else { fprintf(stderr, "CSprite::LoadTxt(): WARNING, duplicate tag: %s %u\n", name, uiTag); } } free(pBuf); return true; }
25.901786
115
0.647363
pdpdds
c4aafeaa4d72886d265d9ecdad97d91aaa482665
5,898
hpp
C++
src/util/rpc/client.hpp
EnrikoChavez/opencbdc-tx
3f4ebe9fa8296542158ff505b47fd8f277e313dd
[ "MIT" ]
652
2022-02-03T19:31:04.000Z
2022-03-31T17:45:29.000Z
src/util/rpc/client.hpp
EnrikoChavez/opencbdc-tx
3f4ebe9fa8296542158ff505b47fd8f277e313dd
[ "MIT" ]
50
2022-02-03T23:16:36.000Z
2022-03-31T19:50:19.000Z
src/util/rpc/client.hpp
EnrikoChavez/opencbdc-tx
3f4ebe9fa8296542158ff505b47fd8f277e313dd
[ "MIT" ]
116
2022-02-03T19:57:26.000Z
2022-03-20T17:23:47.000Z
// Copyright (c) 2021 MIT Digital Currency Initiative, // Federal Reserve Bank of Boston // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef OPENCBDC_TX_SRC_RPC_CLIENT_H_ #define OPENCBDC_TX_SRC_RPC_CLIENT_H_ #include "format.hpp" #include "messages.hpp" #include "util/serialization/util.hpp" #include <atomic> #include <cassert> #include <chrono> #include <functional> #include <optional> namespace cbdc::rpc { /// Generic RPC client. Handles serialization of requests and responses /// combined with a message header. Subclass to define actual remote /// communication logic. /// \tparam Request type for requests. /// \tparam Response type for responses. template<typename Request, typename Response> class client { public: client() = default; client(client&&) noexcept = default; auto operator=(client&&) noexcept -> client& = default; client(const client&) = delete; auto operator=(const client&) -> client& = delete; virtual ~client() = default; using request_type = request<Request>; using response_type = response<Response>; /// User-provided response callback function type for asynchronous /// requests. using response_callback_type = std::function<void(std::optional<Response>)>; /// Issues the given request with an optional timeout, then waits for /// and returns the response. Serializes the request data, calls /// call_raw() to transmit the data and get a response, and returns the /// deserialized response. Thread safe. /// \param request_payload payload for the RPC. /// \param timeout optional timeout in milliseconds. Zero indicates the /// call should not timeout. /// \return response from the RPC, or std::nullopt if the call timed out /// or produced an error. [[nodiscard]] auto call(Request request_payload, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) -> std::optional<Response> { auto [request_buf, request_id] = make_request(std::move(request_payload)); auto resp = call_raw(std::move(request_buf), request_id, timeout); if(!resp.has_value()) { return std::nullopt; } assert(resp.value().m_header.m_request_id == request_id); return resp.value().m_payload; } /// Issues an asynchronous request and registers the given callback to /// handle the response. Serializes the request data, then transmits it /// with call_raw(). Thread safe. /// \param request_payload payload for the RPC. /// \param response_callback function for the request handler to call /// when the response is available. /// \return true if the request was sent successfully. auto call(Request request_payload, response_callback_type response_callback) -> bool { auto [request_buf, request_id] = make_request(std::move(request_payload)); auto ret = call_raw( std::move(request_buf), request_id, [req_id = request_id, resp_cb = std::move(response_callback)]( std::optional<response_type> resp) { if(!resp.has_value()) { return; } assert(resp.value().m_header.m_request_id == req_id); resp_cb(std::move(resp.value().m_payload)); }); return ret; } protected: /// Deserializes a response object from the given buffer. /// \param response_buf buffer containing an RPC response. /// \return response object or std::nullopt if deserialization failed. auto deserialize_response(cbdc::buffer& response_buf) -> std::optional<response_type> { return from_buffer<response_type>(response_buf); } /// Response callback function type for handling an RPC response. using raw_callback_type = std::function<void(std::optional<response_type>)>; private: std::atomic<uint64_t> m_current_request_id{}; /// Subclasses must override this function to define the logic for /// call() to transmit a serialized RPC request and wait for a /// serialized response with an optional timeout. /// \param request_buf serialized request object. /// \param request_id identifier to match requests with responses. /// \param timeout timeout in milliseconds. Zero indicates the /// call should not timeout. /// \return response object, or std::nullopt if sending the request /// failed or the timeout expired while waiting for a response. virtual auto call_raw(cbdc::buffer request_buf, request_id_type request_id, std::chrono::milliseconds timeout) -> std::optional<response_type> = 0; virtual auto call_raw(cbdc::buffer request_buf, request_id_type request_id, raw_callback_type response_callback) -> bool = 0; auto make_request(Request request_payload) -> std::pair<cbdc::buffer, request_id_type> { auto request_id = m_current_request_id++; auto req = request_type{{request_id}, std::move(request_payload)}; return {make_buffer(req), request_id}; } }; } #endif
43.051095
80
0.604103
EnrikoChavez
c4ad43f15955cded255e777e45a2fb436ddd38ed
3,017
cpp
C++
example/frame/concept/alpha/src/alphawriter.cpp
joydit/solidframe
0539b0a1e77663ac4c701a88f56723d3e3688e8c
[ "BSL-1.0" ]
null
null
null
example/frame/concept/alpha/src/alphawriter.cpp
joydit/solidframe
0539b0a1e77663ac4c701a88f56723d3e3688e8c
[ "BSL-1.0" ]
null
null
null
example/frame/concept/alpha/src/alphawriter.cpp
joydit/solidframe
0539b0a1e77663ac4c701a88f56723d3e3688e8c
[ "BSL-1.0" ]
null
null
null
// alphawriter.cpp // // Copyright (c) 2007, 2008 Valentin Palade (vipalade @ gmail . com) // // This file is part of SolidFrame framework. // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. // #include "alphawriter.hpp" #include "alphaprotocolfilters.hpp" #include "alphaconnection.hpp" using namespace solid; namespace concept{ namespace alpha{ Writer::Writer( protocol::text::Logger *_plog ):protocol::text::Writer(_plog){ } Writer::~Writer(){ } void Writer::clear(){ tags.clear(); msgs.clear(); cassert(wpos == rpos); } bool isLiteralString(const char *_pb, unsigned _bl){ while(_bl--){ //if it's not quoted means its literal if(!QuotedFilter::check(*_pb)) return true; ++_pb; } return false; } /*static*/ int Writer::putAString(protocol::text::Writer &_rw, protocol::text::Parameter &_rp){ Writer &rw = static_cast<Writer&>(_rw); const char *ps = (const char*)_rp.a.p; if(_rp.b.u32 > 128 || isLiteralString(ps, _rp.b.u32)){ //right here i know for sure I can write safely (buflen - FlushLength) chars rw<<'{'<<_rp.b.u32; rw.putChar('}','\r','\n'); rw.fs.top().first = &Writer::putAtom; }else{//send quoted rw<<'\"'; protocol::text::Parameter ppp(_rp); rw.replace(&Writer::putChar, protocol::text::Parameter('\"')); rw.push(&Writer::putAtom, ppp); rw.push(&Writer::flush);//only try to do a flush } return Continue; } //NOTE: to be used by the above method /*static*/ /*int Writer::putQString(protocol::text::Writer &_rw, protocol::text::Parameter &_rp){ return Bad; }*/ /*static*/ int Writer::putStatus(protocol::text::Writer &_rw, protocol::text::Parameter &_rp){ Writer &rw = static_cast<Writer&>(_rw); protocol::text::Parameter rp = _rp; rw.replace(&Writer::clear); rw.push(&Writer::flushAll); rw.push(&Writer::putCrlf); if(rp.a.p){ rw.push(&Writer::putAtom, rp); }else{//send the msg rw.push(&Writer::putAtom, protocol::text::Parameter((void*)rw.msgs.data(), rw.msgs.size())); } //rw.push(&Writer::putChar, protocol::text::Parameter(' ')); if(rw.tags.size()){ rw.push(&Writer::putAtom, protocol::text::Parameter((void*)rw.tags.data(), rw.tags.size())); }else{ rw.push(&Writer::putChar, protocol::text::Parameter('*')); } return Continue; } /*static*/ int Writer::clear(protocol::text::Writer &_rw, protocol::text::Parameter &_rp){ Writer &rw = static_cast<Writer&>(_rw); rw.clear(); return Success; } /*static*/ int Writer::putCrlf(protocol::text::Writer &_rw, protocol::text::Parameter &_rp){ _rw.replace(&Writer::putChar, protocol::text::Parameter('\n')); _rw.push(&Writer::putChar, protocol::text::Parameter('\r')); return Continue; } int Writer::write(char *_pb, uint32 _bl){ // switch(rch.send(_pb, _bl)){ // case BAD: return Bad; // case OK: return Ok; // case NOK: return No; // } // cassert(false); // return Bad; return Connection::the().socketSend(_pb, _bl); } }//namespace alpha }//namespace concept
27.18018
97
0.672854
joydit
c4ae11028445ad1e97267d0264850775b57a6778
2,610
cpp
C++
Client/client/World/World.cpp
pinkmouse/SlayersWorld
53cdde28f3464ee9ada9b655f8c4df63f0e9389e
[ "MIT" ]
14
2019-03-05T10:03:59.000Z
2021-12-21T03:00:18.000Z
Client/client/World/World.cpp
pinkmouse/SlayersWorld
53cdde28f3464ee9ada9b655f8c4df63f0e9389e
[ "MIT" ]
1
2019-10-24T21:37:59.000Z
2019-10-24T21:37:59.000Z
Client/client/World/World.cpp
pinkmouse/SlayersWorld
53cdde28f3464ee9ada9b655f8c4df63f0e9389e
[ "MIT" ]
1
2020-12-06T21:07:52.000Z
2020-12-06T21:07:52.000Z
#include "World.hpp" #include "../Global.hpp" #include "WorldPacket.hpp" #include <vector> World::World() { g_Socket = new Socket(); m_Events = new Events(); g_Config = new ConfigHandler(); m_MapManager = new MapManager(m_Events); m_InterfaceManager = new InterfaceManager(m_Events); m_Graphics = new Graphics(m_MapManager, m_InterfaceManager, m_Events); m_PacketHandler = new PacketHandler(m_MapManager, m_InterfaceManager); m_Run = true; } World::~World() { } void World::SetIp(const std::string & p_Ip) { m_Ip = p_Ip; } bool World::InitializeConnection() { if (!g_Socket->Connection(m_Ip)) { m_InterfaceManager->SetSystemMsg("Connection failed"); return false; } g_Socket->setBlocking(false); g_Socket->SendAuth(m_Credentials.first, m_Credentials.second); return true; } bool World::InitializeWindow() { m_InterfaceManager->Initialize(); if (!m_Graphics->CreateWindow(X_WINDOW, Y_WINDOW, ZOOM_FACTOR)) return false; if (!m_Graphics->LoadFont()) return false; return true; } bool World::Initialize() { if (!g_Config->Initialize()) { printf("Config error\n"); return false; } m_Ip = g_Config->GetValue("IPserver"); if (!InitializeWindow()) return false; m_MapManager->InitializeMaps(); m_PacketHandler->LoadPacketHandlerMap(); return true; } void World::Login(const std::string& login, const std::string& password) { m_Credentials.first = login; m_Credentials.second = password; m_InterfaceManager->SetSystemMsg("Connection..."); //m_InterfaceManager->SetSystemMsg("Connection..."); } void World::Run() { while (m_Run) { if (!g_Socket->IsConnected()) InitializeConnection(); else if (!UpdateSocket()) { m_InterfaceManager->SetSystemMsg("Disconnected"); delete g_Player; g_Player = nullptr; } sf::Time l_Diff = m_Clock.restart(); if (m_PacketHandler->HasMinimalRequiered()) m_MapManager->Update(l_Diff); m_Graphics->UpdateWindow(l_Diff); m_Graphics->CheckEvent(); if (!m_Graphics->WindowIsOpen()) End(); } } bool World::UpdateSocket() { WorldPacket l_Packet; sf::Socket::Status l_SocketStatus; l_SocketStatus = g_Socket->Receive(l_Packet); if (l_SocketStatus == sf::Socket::Status::Done) ///< Reception OK m_PacketHandler->OperatePacket(l_Packet); if (l_SocketStatus == sf::Socket::Status::Disconnected) ///< Disconnecetd return false; return true; } void World::End() { m_Run = false; g_Socket->disconnect(); }
22.894737
74
0.6659
pinkmouse
c4aedb60a6b584cb8efb91d7df4431cd47cb86e0
483
hpp
C++
include/brimstone/Size.hpp
theJ8910/Brimstone
e28da7a995ab5533b78bf5e1664a59753d139fff
[ "MIT" ]
1
2015-12-31T05:49:39.000Z
2015-12-31T05:49:39.000Z
include/brimstone/Size.hpp
theJ8910/Brimstone
e28da7a995ab5533b78bf5e1664a59753d139fff
[ "MIT" ]
null
null
null
include/brimstone/Size.hpp
theJ8910/Brimstone
e28da7a995ab5533b78bf5e1664a59753d139fff
[ "MIT" ]
null
null
null
/* Size.hpp ----------------------- Copyright (c) 2014, theJ89 Description: Include this file for access to Size and its variations. Note: Since this file merely includes other files, there are no include guards necessary here. */ //Includes #include <brimstone/size/SizeN.hpp> #include <brimstone/size/Size2.hpp> #include <brimstone/size/Size3.hpp> #include <brimstone/size/Size4.hpp> //This macro isn't needed outside of the above files #undef BS_SIZE_DECLARE_METHODS
23
98
0.724638
theJ8910
c4b088cdd2eba4b2c63c98fff03c2b0e99b3275c
1,305
cpp
C++
codechef/SWAPPALI/Wrong Answer.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
1
2022-02-11T16:55:36.000Z
2022-02-11T16:55:36.000Z
codechef/SWAPPALI/Wrong Answer.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
codechef/SWAPPALI/Wrong Answer.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
/**************************************************************************************** * @author: kzvd4729 created: 29-02-2020 19:55:44 * solution_verdict: Wrong Answer language: C++14 * run_time: 0.00 sec memory_used: 0M * problem: https://www.codechef.com/LTIME81A/problems/SWAPPALI ****************************************************************************************/ #include<bits/stdc++.h> #define long long long using namespace std; const int N=1e6,inf=1e9; int n,dp[N+2];string s; int dfs(int i) { int j=n-1-i;if(j<=i)return 0; if(dp[i]!=-1)return dp[i]; int now=inf; if(s[i]==s[j])now=min(now,dfs(i+1)); if(i+1<j-1) { if(s[i+1]==s[j]&&s[i]==s[j-1]) now=min(now,1+dfs(i+2)); } if(i+1==j-1) { if(s[i]==s[i+1]||s[j]==s[j-1]) now=min(now,1+dfs(i+2)); } return dp[i]=now; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int t;cin>>t; while(t--) { cin>>n>>s; for(int i=0;i<=n;i++)dp[i]=-1; int ans=dfs(0);if(ans==inf)ans=-1; if(ans!=-1)cout<<"YES\n"<<ans<<"\n"; else cout<<"NO\n"; //cout<<endl; } return 0; }
29.659091
111
0.4
kzvd4729
c4b0cb7be0da45a9827665348569fe4bd3544efa
3,005
cpp
C++
unittests/timer/ExecutionDeferrerTest.cpp
zavadovsky/stingraykit
33e6587535325f08769bd8392381d70d4d316410
[ "0BSD" ]
24
2015-03-04T16:30:03.000Z
2022-02-04T15:03:42.000Z
unittests/timer/ExecutionDeferrerTest.cpp
zavadovsky/stingraykit
33e6587535325f08769bd8392381d70d4d316410
[ "0BSD" ]
null
null
null
unittests/timer/ExecutionDeferrerTest.cpp
zavadovsky/stingraykit
33e6587535325f08769bd8392381d70d4d316410
[ "0BSD" ]
7
2015-04-08T12:22:58.000Z
2018-06-14T09:58:45.000Z
#include <stingraykit/function/bind.h> #include <stingraykit/timer/Timer.h> #include <stingraykit/unique_ptr.h> #include <gtest/gtest.h> using namespace stingray; class ExecutionDeferrerTest : public testing::Test { protected: class DeferrerHolder { private: ExecutionDeferrer _deferrer; public: DeferrerHolder(Timer& timer, size_t timeout, const function<void ()>& func) : _deferrer(timer, TimeDuration(timeout)) { _deferrer.Defer(func); } ~DeferrerHolder() { _deferrer.Cancel(); } }; struct Counter { private: size_t _value; public: Counter() : _value(0) { } size_t GetValue() const { return _value; } void Increment() { ++_value; } }; struct ExecutionDeferrerTestDummy { }; STINGRAYKIT_DECLARE_PTR(ExecutionDeferrerTestDummy); protected: bool _finished; protected: ExecutionDeferrerTest() : _finished(false) { } static void DoNothing() { } void DoCancel(const ExecutionDeferrerWithTimerPtr& deferrer) { deferrer->Cancel(); } public: void DoTest(size_t testCount, size_t timeout, size_t sleepTimeout) { ExecutionDeferrerWithTimerPtr deferrer(new ExecutionDeferrerWithTimer("deferrerTestTimer")); ExecutionDeferrerWithTimerPtr cancelDeferrer(new ExecutionDeferrerWithTimer("deferrerCancelTestTimer")); for (size_t i = 0; i < testCount; ++i) { deferrer->Defer(Bind(&ExecutionDeferrerTest::DoCancel, this, deferrer), TimeDuration(timeout)); cancelDeferrer->Defer(Bind(&ExecutionDeferrerTest::DoCancel, this, deferrer), TimeDuration(timeout)); Thread::Sleep(sleepTimeout); } deferrer.reset(); cancelDeferrer.reset(); _finished = true; } }; TEST_F(ExecutionDeferrerTest, Cancel) { const size_t Timeout = 500; const size_t ObjectsCount = 1000; Timer timer("deferrerTestTimer"); Counter counter; for (size_t i = 0; i < ObjectsCount; ++i) { unique_ptr<DeferrerHolder> tmp(new DeferrerHolder(timer, Timeout, Bind(&Counter::Increment, wrap_ref(counter)))); tmp.reset(); } Thread::Sleep(2 * Timeout); ASSERT_EQ(counter.GetValue(), 0u); } TEST_F(ExecutionDeferrerTest, Defer) { const size_t EvenTimeout = 0; const size_t OddTimeout = 200; const size_t TestCount = 10000; ExecutionDeferrerWithTimer deferrer("deferrerTestTimer"); for (size_t i = 0; i < TestCount; ++i) { const size_t timeout = i % 2? OddTimeout : EvenTimeout; deferrer.Defer(&ExecutionDeferrerTest::DoNothing, TimeDuration(timeout)); } } TEST_F(ExecutionDeferrerTest, CancelDeadlock) { const size_t TestCount = 100; const size_t Timeout = 3; const size_t SleepTimeout = 50; static ExecutionDeferrerWithTimer deferrer("deadlockTestDeferrerTimer"); deferrer.Defer(Bind(&ExecutionDeferrerTest::DoTest, this, TestCount, Timeout, SleepTimeout), TimeDuration(0)); size_t elapsed = 0; while(elapsed < (TestCount * SleepTimeout * 2) && !_finished) { elapsed += SleepTimeout; Thread::Sleep(SleepTimeout); } if (!_finished) STINGRAYKIT_THROW("Cannot finish ExecutionDeferrerTest, possible there is a deadlock"); }
23.294574
115
0.738769
zavadovsky
c4b10ee02bb5e600696d5bd152526c61ae663e94
215
cpp
C++
Source/Common/MPIWrapper.cpp
sunkwei/CNTK
08691e97707538b110ca71bce4ad06c46d840517
[ "Intel" ]
6
2019-08-18T05:29:09.000Z
2021-01-19T09:58:45.000Z
Source/Common/MPIWrapper.cpp
Omar-Belghaouti/CNTK
422f710242c602b2660a634f2234abf5aaf5b337
[ "RSA-MD" ]
null
null
null
Source/Common/MPIWrapper.cpp
Omar-Belghaouti/CNTK
422f710242c602b2660a634f2234abf5aaf5b337
[ "RSA-MD" ]
1
2019-10-24T00:35:07.000Z
2019-10-24T00:35:07.000Z
#include "Include/Basics.h" #include "Include/MPIWrapper.h" int Microsoft::MSR::CNTK::MPIWrapper::s_myRank = -1; std::shared_ptr<Microsoft::MSR::CNTK::MPIWrapper> Microsoft::MSR::CNTK::MPIWrapper::s_mpi = nullptr;
35.833333
100
0.748837
sunkwei
c4b3615457b213dec9d96b0c8eaaf5b4af20be21
299
cpp
C++
Codeforces Online Judge Solve/dice.cpp
Remonhasan/programming-solve
5a4ac8c738dd361e1c974162e0eaebbaae72fd80
[ "Apache-2.0" ]
null
null
null
Codeforces Online Judge Solve/dice.cpp
Remonhasan/programming-solve
5a4ac8c738dd361e1c974162e0eaebbaae72fd80
[ "Apache-2.0" ]
null
null
null
Codeforces Online Judge Solve/dice.cpp
Remonhasan/programming-solve
5a4ac8c738dd361e1c974162e0eaebbaae72fd80
[ "Apache-2.0" ]
null
null
null
#include<bits/stdc++.h> using namespace std; #define ll long long int main () { ll m,n,k; cin>>n; while(n--) { cin>>m; if(m==2||m==3||m==4||m==5||m==6||m==7) cout<<"1"<<endl; else { k=m/2; cout<<k<<endl; } } }
16.611111
64
0.381271
Remonhasan
c4b3834a3ced9015f6db46be6e6f5fc176787725
1,234
cc
C++
src/platform/udp_server_test.cc
AnthonyBrunasso/test_games
31354d2bf95aae9a880e7292bc78ad8577b3f09c
[ "MIT" ]
null
null
null
src/platform/udp_server_test.cc
AnthonyBrunasso/test_games
31354d2bf95aae9a880e7292bc78ad8577b3f09c
[ "MIT" ]
null
null
null
src/platform/udp_server_test.cc
AnthonyBrunasso/test_games
31354d2bf95aae9a880e7292bc78ad8577b3f09c
[ "MIT" ]
2
2019-11-12T23:15:18.000Z
2020-01-15T17:49:27.000Z
#include "platform.cc" #include <cstdio> volatile bool running = true; s32 main(s32 argc, char** argv) { const char* ip = "127.0.0.1"; const char* port = "9845"; while (1) { s32 opt = platform_getopt(argc, argv, "i:p:"); if (opt == -1) break; switch (opt) { case 'i': ip = platform_optarg; break; case 'p': port = platform_optarg; break; }; } #define MAX_BUFFER 4 * 1024 u8 buffer[MAX_BUFFER]; udp::Init(); Udp4 location; if (!udp::GetAddr4(ip, port, &location)) { puts("fail GetAddr4"); exit(1); } printf("Server binding %s:%s\n", ip, port); if (!udp::Bind(location)) { puts("fail Bind"); exit(1); } while (running) { u16 received_bytes; Udp4 peer; if (!udp::ReceiveAny(location, MAX_BUFFER, buffer, &received_bytes, &peer)) { if (udp_errno) running = false; if (udp_errno) printf("udp_errno %d\n", udp_errno); continue; } // Echo bytes to peer printf("socket %d echo %d bytes\n", location.socket, received_bytes); if (!udp::SendTo(location, peer, buffer, received_bytes)) { puts("send failed"); } else { puts("send ok"); } } }
19.903226
73
0.559157
AnthonyBrunasso
c4b457a7d61ab62179e13416dda2f179f7be4a5e
1,663
hh
C++
modules/Tsp/TspParticle.hh
ElonKou/genetic
507f739b44399b8dbae1bde4523fbb718704e223
[ "MIT" ]
null
null
null
modules/Tsp/TspParticle.hh
ElonKou/genetic
507f739b44399b8dbae1bde4523fbb718704e223
[ "MIT" ]
null
null
null
modules/Tsp/TspParticle.hh
ElonKou/genetic
507f739b44399b8dbae1bde4523fbb718704e223
[ "MIT" ]
null
null
null
#pragma once #include "TspAlgorithmBase.hh" typedef struct SpeedItem { int x; int y; } SpeedItem; class TspParticle : public TspAlgorithmBase { public: std::vector<SpeedItem> m_personal; // cur:A -> his:B (current vs personal history) std::vector<SpeedItem> m_global; // cur:A -> bst:B (current and global history) std::vector<std::vector<int>> p_best_genes; // record all best genes for all personal gene history. std::vector<std::vector<SpeedItem>> m_speeds; // record particle's old speeds. float w; // keep current rate. float alpha; // move personal best rate. float beta; // move hsitory best rate. float gama; // move random. TspParticle(); TspParticle(int node_cnt, int agent_cnt, float w_, float alpha_, float beta_, float gama = 0.1); ~TspParticle(); void Init(); void SomeInit(); void RandomRemoveWorstParticles(); /** * Calculate velocity of all particles between two positions. */ void CalculateVelocity(std::vector<int>& cur_ori, const std::vector<int>& per, const std::vector<int>& glo, std::vector<SpeedItem>& cur_speed, std::vector<SpeedItem>& speed); /** * Calculate new position of all velocity and current position. */ void CalculatePosition(std::vector<int>& cur, std::vector<SpeedItem>& cur_speed); virtual void Step(); virtual void Predict(); virtual void GetCurrentBest(std::vector<int>& best, float& score); };
33.938776
178
0.595911
ElonKou
c4b686e364cd0d9b86a354df6e64cbbb8ab96071
343
hpp
C++
src/framework/forms/input/input.hpp
kevinaud/asm-dom-OO-counters
58ea010941b5e7ab860109b6ebbd6f3ca47fd4c6
[ "MIT" ]
9
2018-06-07T00:39:45.000Z
2021-06-28T18:26:51.000Z
src/framework/forms/input/input.hpp
kevinaud/asm-dom-OO-counters
58ea010941b5e7ab860109b6ebbd6f3ca47fd4c6
[ "MIT" ]
null
null
null
src/framework/forms/input/input.hpp
kevinaud/asm-dom-OO-counters
58ea010941b5e7ab860109b6ebbd6f3ca47fd4c6
[ "MIT" ]
2
2019-05-04T15:35:04.000Z
2019-09-24T12:11:45.000Z
#ifndef INPUT_H #define INPUT_H #include "../../component/component.hpp" #include "../../view-property/view-property.hpp" class Input : public Component { public: Input(Component* parent); Input(Component* parent, string initValue); VNode* render(); private: ViewProperty<string>* value; }; #endif
18.052632
51
0.641399
kevinaud
c4b86abbd7ac32192638543b82b05e5363f5706b
4,208
hpp
C++
src/CameraControl/EDSDK/EdsdkSourceDeviceImpl.hpp
vividos/RemotePhotoTool
d17ae2abbda531acbd0ec8e90ddc4856c4fdfa00
[ "BSD-2-Clause" ]
16
2015-03-26T02:32:43.000Z
2021-10-18T16:34:31.000Z
src/CameraControl/EDSDK/EdsdkSourceDeviceImpl.hpp
vividos/RemotePhotoTool
d17ae2abbda531acbd0ec8e90ddc4856c4fdfa00
[ "BSD-2-Clause" ]
7
2019-02-21T06:07:09.000Z
2022-01-01T10:00:50.000Z
src/CameraControl/EDSDK/EdsdkSourceDeviceImpl.hpp
vividos/RemotePhotoTool
d17ae2abbda531acbd0ec8e90ddc4856c4fdfa00
[ "BSD-2-Clause" ]
6
2019-05-07T09:21:15.000Z
2021-09-01T06:36:24.000Z
// // RemotePhotoTool - remote camera control software // Copyright (C) 2008-2017 Michael Fink // /// \file EdsdkSourceDeviceImpl.hpp EDSDK - SourceDevice impl // #pragma once // includes #include "SourceDevice.hpp" #include "EdsdkCameraFileSystemImpl.hpp" #include "EdsdkRemoteReleaseControlImpl.hpp" #include "EdsdkShutterCounterReader.hpp" namespace EDSDK { /// source device implementation for EDSDK class SourceDeviceImpl: public SourceDevice, public std::enable_shared_from_this<SourceDeviceImpl> { public: /// ctor SourceDeviceImpl(const Handle& hCamera, const EdsDeviceInfo& deviceInfo) :m_hCamera(hCamera), m_deviceInfo(deviceInfo) { } /// dtor virtual ~SourceDeviceImpl() { // Ugly workaround: EdsCloseSession() may lock up; call EdsGetEvent() to process internal events. // This should probably go into an Idle handler for the SDK. for(int i=0; i<100; i++) EdsGetEvent(); EdsError err = EdsCloseSession(m_hCamera); LOG_TRACE(_T("EdsCloseSession(ref = %08x) returned %08x\n"), m_hCamera.Get(), err); // note: don't check error here, as we're in dtor } virtual bool GetDeviceCapability(SourceDevice::T_enDeviceCapability enDeviceCapability) const override { switch (enDeviceCapability) { case SourceDevice::capRemoteReleaseControl: // supported on all camera models return true; case SourceDevice::capRemoteViewfinder: // supported on all camera models return true; case SourceDevice::capCameraFileSystem: // supported on all camera models return true; default: ATLASSERT(false); } return false; } virtual CString ModelName() const override { PropertyAccess p(m_hCamera); Variant v = p.Get(kEdsPropID_ProductName); return v.Get<CString>(); } virtual CString SerialNumber() const override { PropertyAccess p(m_hCamera); Variant v = p.Get(kEdsPropID_BodyIDEx); return v.Get<CString>(); } virtual std::vector<unsigned int> EnumDeviceProperties() const override { PropertyAccess p(m_hCamera); std::vector<unsigned int> vecDeviceIds; p.EnumDeviceIds(vecDeviceIds); return vecDeviceIds; } virtual DeviceProperty GetDeviceProperty(unsigned int uiPropertyId) const override { if (uiPropertyId == kEdsPropID_ShutterCounter) { ShutterCounterReader reader; unsigned int uiShutterCounter = 0; reader.Read(m_deviceInfo.szPortName, uiShutterCounter); Variant value; value.Set(uiShutterCounter); value.SetType(Variant::typeUInt32); return DeviceProperty(variantEdsdk, uiPropertyId, value, true); } // get value PropertyAccess p(m_hCamera); Variant value = p.Get(uiPropertyId); bool bReadOnly = p.IsReadOnly(uiPropertyId); DeviceProperty deviceProperty(variantEdsdk, uiPropertyId, value, bReadOnly); p.Enum(uiPropertyId, deviceProperty.ValidValues(), bReadOnly); return deviceProperty; } virtual std::shared_ptr<CameraFileSystem> GetFileSystem() override { std::shared_ptr<SourceDevice> spSourceDevice = shared_from_this(); return std::shared_ptr<CameraFileSystem>(new EDSDK::CameraFileSystemImpl(spSourceDevice, m_hCamera)); } virtual std::shared_ptr<RemoteReleaseControl> EnterReleaseControl() override { if (!GetDeviceCapability(capRemoteReleaseControl)) { // throw an error code of 7, which means "not supported" throw CameraException(_T("EDSDK::SourceDevice::EnterReleaseControl"), _T("Not supported"), EDS_ERR_NOT_SUPPORTED, __FILE__, __LINE__); } std::shared_ptr<SourceDevice> spSourceDevice = shared_from_this(); // there's no dedicated function to start "remote release control" mode, just add camera ref return std::shared_ptr<RemoteReleaseControl>(new RemoteReleaseControlImpl(spSourceDevice, m_hCamera)); } private: /// handle to camera object Handle m_hCamera; /// camera device info EdsDeviceInfo m_deviceInfo; }; } // namespace EDSDK
27.86755
108
0.689401
vividos
c4ba7b34dc3b3e66b9eec7f770a9565416ea41e9
474
hpp
C++
aech/src/resource_management/material_library.hpp
markomijolovic/aech
6e2ea36146596dff6f92e451a598aab535b03d3c
[ "BSD-3-Clause" ]
4
2021-05-25T13:58:30.000Z
2021-05-26T20:13:15.000Z
aech/src/resource_management/material_library.hpp
markomijolovic/aech
6e2ea36146596dff6f92e451a598aab535b03d3c
[ "BSD-3-Clause" ]
null
null
null
aech/src/resource_management/material_library.hpp
markomijolovic/aech
6e2ea36146596dff6f92e451a598aab535b03d3c
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include "material.hpp" #include <unordered_map> namespace aech::graphics { namespace material_library { inline std::unordered_map<std::string, material_t> default_materials{}; // creates default material objects auto generate_default_materials() noexcept -> void; // create a material from the given template [[nodiscard]] auto create_material(const std::string &from) noexcept -> material_t; } // namespace material_library } // namespace aech::graphics
26.333333
83
0.776371
markomijolovic
c4bbda3e53670c898370397ab10975570b59dde3
89
hpp
C++
openexr-c/abigen/imf_deeptiledoutputpart.hpp
vfx-rs/openexr-bind
ee4fd6010beedb0247737a39ee61ffb87c586448
[ "BSD-3-Clause" ]
7
2021-06-04T20:59:16.000Z
2022-02-11T01:00:42.000Z
openexr-c/abigen/imf_deeptiledoutputpart.hpp
vfx-rs/openexr-bind
ee4fd6010beedb0247737a39ee61ffb87c586448
[ "BSD-3-Clause" ]
35
2021-05-14T04:28:22.000Z
2021-12-30T12:08:40.000Z
openexr-c/abigen/imf_deeptiledoutputpart.hpp
vfx-rs/openexr-bind
ee4fd6010beedb0247737a39ee61ffb87c586448
[ "BSD-3-Clause" ]
5
2021-05-15T04:02:56.000Z
2021-07-02T05:38:01.000Z
#pragma once #include <ostream> void abi_gen_imf_deeptiledoutputpart(std::ostream& os);
17.8
55
0.797753
vfx-rs
c4bc3d397a4bb39caad3e5a4ec91485b71cad824
1,631
hpp
C++
source/hougfx/include/hou/gfx/gfx_exceptions.hpp
DavideCorradiDev/houzi-game-engine
d704aa9c5b024300578aafe410b7299c4af4fcec
[ "MIT" ]
2
2018-04-12T20:59:20.000Z
2018-07-26T16:04:07.000Z
source/hougfx/include/hou/gfx/gfx_exceptions.hpp
DavideCorradiDev/houzi-game-engine
d704aa9c5b024300578aafe410b7299c4af4fcec
[ "MIT" ]
null
null
null
source/hougfx/include/hou/gfx/gfx_exceptions.hpp
DavideCorradiDev/houzi-game-engine
d704aa9c5b024300578aafe410b7299c4af4fcec
[ "MIT" ]
null
null
null
// Houzi Game Engine // Copyright (c) 2018 Davide Corradi // Licensed under the MIT license. #ifndef HOU_GFX_GFX_EXCEPTIONS_HPP #define HOU_GFX_GFX_EXCEPTIONS_HPP #include "hou/cor/exception.hpp" #include "hou/gfx/gfx_config.hpp" namespace hou { /** Font creation error. * * This exception is thrown when creating a font object fails. * This normally means that the font data is corrupted or in a wrong format. */ class HOU_GFX_API font_creation_error : public exception { public: /** Constructor. * * \param path the path to the source file where the error happened. * * \param line the line where the error happened. * * \throws std::bad_alloc. */ font_creation_error(const std::string& path, uint line); }; /** Font destruction error. * * This exception is thrown when destructing a font object fails. */ class HOU_GFX_API font_destruction_error : public exception { public: /** Constructor. * * \param path the path to the source file where the error happened. * * \param line the line where the error happened. * * \throws std::bad_alloc. */ font_destruction_error(const std::string& path, uint line); }; /** Font operation error. * * This exception is thrown when an operation on a font object fails. */ class HOU_GFX_API font_operation_error : public exception { public: /** Constructor. * * \param path the path to the source file where the error happened. * * \param line the line where the error happened. * * \throws std::bad_alloc. */ font_operation_error(const std::string& path, uint line); }; } // namespace hou #endif
21.746667
76
0.702636
DavideCorradiDev
c4bf748586b523ee4d3eaa57641be1668e75e2b0
146,403
cc
C++
src/mavsdk_server/src/generated/camera_server/camera_server.pb.cc
hamishwillee/MAVSDK
e7f4e27bdd4442b91b623abf6ac86d1cbb188244
[ "BSD-3-Clause" ]
115
2018-07-11T00:18:12.000Z
2019-06-05T22:10:23.000Z
src/mavsdk_server/src/generated/camera_server/camera_server.pb.cc
hamishwillee/MAVSDK
e7f4e27bdd4442b91b623abf6ac86d1cbb188244
[ "BSD-3-Clause" ]
228
2018-07-09T12:03:21.000Z
2019-06-07T09:51:14.000Z
src/mavsdk_server/src/generated/camera_server/camera_server.pb.cc
hamishwillee/MAVSDK
e7f4e27bdd4442b91b623abf6ac86d1cbb188244
[ "BSD-3-Clause" ]
104
2018-07-19T09:45:16.000Z
2019-06-05T18:40:35.000Z
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: camera_server/camera_server.proto #include "camera_server/camera_server.pb.h" #include <algorithm> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // @@protoc_insertion_point(includes) #include <google/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG namespace _pb = ::PROTOBUF_NAMESPACE_ID; namespace _pbi = _pb::internal; namespace mavsdk { namespace rpc { namespace camera_server { PROTOBUF_CONSTEXPR SetInformationRequest::SetInformationRequest( ::_pbi::ConstantInitialized) : information_(nullptr){} struct SetInformationRequestDefaultTypeInternal { PROTOBUF_CONSTEXPR SetInformationRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SetInformationRequestDefaultTypeInternal() {} union { SetInformationRequest _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SetInformationRequestDefaultTypeInternal _SetInformationRequest_default_instance_; PROTOBUF_CONSTEXPR SetInformationResponse::SetInformationResponse( ::_pbi::ConstantInitialized) : camera_server_result_(nullptr){} struct SetInformationResponseDefaultTypeInternal { PROTOBUF_CONSTEXPR SetInformationResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SetInformationResponseDefaultTypeInternal() {} union { SetInformationResponse _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SetInformationResponseDefaultTypeInternal _SetInformationResponse_default_instance_; PROTOBUF_CONSTEXPR SetInProgressRequest::SetInProgressRequest( ::_pbi::ConstantInitialized) : in_progress_(false){} struct SetInProgressRequestDefaultTypeInternal { PROTOBUF_CONSTEXPR SetInProgressRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SetInProgressRequestDefaultTypeInternal() {} union { SetInProgressRequest _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SetInProgressRequestDefaultTypeInternal _SetInProgressRequest_default_instance_; PROTOBUF_CONSTEXPR SetInProgressResponse::SetInProgressResponse( ::_pbi::ConstantInitialized) : camera_server_result_(nullptr){} struct SetInProgressResponseDefaultTypeInternal { PROTOBUF_CONSTEXPR SetInProgressResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SetInProgressResponseDefaultTypeInternal() {} union { SetInProgressResponse _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SetInProgressResponseDefaultTypeInternal _SetInProgressResponse_default_instance_; PROTOBUF_CONSTEXPR SubscribeTakePhotoRequest::SubscribeTakePhotoRequest( ::_pbi::ConstantInitialized){} struct SubscribeTakePhotoRequestDefaultTypeInternal { PROTOBUF_CONSTEXPR SubscribeTakePhotoRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SubscribeTakePhotoRequestDefaultTypeInternal() {} union { SubscribeTakePhotoRequest _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SubscribeTakePhotoRequestDefaultTypeInternal _SubscribeTakePhotoRequest_default_instance_; PROTOBUF_CONSTEXPR TakePhotoResponse::TakePhotoResponse( ::_pbi::ConstantInitialized) : index_(0){} struct TakePhotoResponseDefaultTypeInternal { PROTOBUF_CONSTEXPR TakePhotoResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~TakePhotoResponseDefaultTypeInternal() {} union { TakePhotoResponse _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TakePhotoResponseDefaultTypeInternal _TakePhotoResponse_default_instance_; PROTOBUF_CONSTEXPR RespondTakePhotoRequest::RespondTakePhotoRequest( ::_pbi::ConstantInitialized) : capture_info_(nullptr) , take_photo_feedback_(0) {} struct RespondTakePhotoRequestDefaultTypeInternal { PROTOBUF_CONSTEXPR RespondTakePhotoRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~RespondTakePhotoRequestDefaultTypeInternal() {} union { RespondTakePhotoRequest _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RespondTakePhotoRequestDefaultTypeInternal _RespondTakePhotoRequest_default_instance_; PROTOBUF_CONSTEXPR RespondTakePhotoResponse::RespondTakePhotoResponse( ::_pbi::ConstantInitialized) : camera_server_result_(nullptr){} struct RespondTakePhotoResponseDefaultTypeInternal { PROTOBUF_CONSTEXPR RespondTakePhotoResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~RespondTakePhotoResponseDefaultTypeInternal() {} union { RespondTakePhotoResponse _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RespondTakePhotoResponseDefaultTypeInternal _RespondTakePhotoResponse_default_instance_; PROTOBUF_CONSTEXPR Information::Information( ::_pbi::ConstantInitialized) : vendor_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , model_name_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , firmware_version_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , definition_file_uri_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , focal_length_mm_(0) , horizontal_sensor_size_mm_(0) , vertical_sensor_size_mm_(0) , horizontal_resolution_px_(0u) , vertical_resolution_px_(0u) , lens_id_(0u) , definition_file_version_(0u){} struct InformationDefaultTypeInternal { PROTOBUF_CONSTEXPR InformationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~InformationDefaultTypeInternal() {} union { Information _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InformationDefaultTypeInternal _Information_default_instance_; PROTOBUF_CONSTEXPR Position::Position( ::_pbi::ConstantInitialized) : latitude_deg_(0) , longitude_deg_(0) , absolute_altitude_m_(0) , relative_altitude_m_(0){} struct PositionDefaultTypeInternal { PROTOBUF_CONSTEXPR PositionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~PositionDefaultTypeInternal() {} union { Position _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 PositionDefaultTypeInternal _Position_default_instance_; PROTOBUF_CONSTEXPR Quaternion::Quaternion( ::_pbi::ConstantInitialized) : w_(0) , x_(0) , y_(0) , z_(0){} struct QuaternionDefaultTypeInternal { PROTOBUF_CONSTEXPR QuaternionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~QuaternionDefaultTypeInternal() {} union { Quaternion _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 QuaternionDefaultTypeInternal _Quaternion_default_instance_; PROTOBUF_CONSTEXPR CaptureInfo::CaptureInfo( ::_pbi::ConstantInitialized) : file_url_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , position_(nullptr) , attitude_quaternion_(nullptr) , time_utc_us_(uint64_t{0u}) , is_success_(false) , index_(0){} struct CaptureInfoDefaultTypeInternal { PROTOBUF_CONSTEXPR CaptureInfoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CaptureInfoDefaultTypeInternal() {} union { CaptureInfo _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CaptureInfoDefaultTypeInternal _CaptureInfo_default_instance_; PROTOBUF_CONSTEXPR CameraServerResult::CameraServerResult( ::_pbi::ConstantInitialized) : result_str_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}) , result_(0) {} struct CameraServerResultDefaultTypeInternal { PROTOBUF_CONSTEXPR CameraServerResultDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CameraServerResultDefaultTypeInternal() {} union { CameraServerResult _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CameraServerResultDefaultTypeInternal _CameraServerResult_default_instance_; } // namespace camera_server } // namespace rpc } // namespace mavsdk static ::_pb::Metadata file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[13]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_camera_5fserver_2fcamera_5fserver_2eproto[2]; static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_camera_5fserver_2fcamera_5fserver_2eproto = nullptr; const uint32_t TableStruct_camera_5fserver_2fcamera_5fserver_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInformationRequest, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInformationRequest, information_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInformationResponse, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInformationResponse, camera_server_result_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInProgressRequest, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInProgressRequest, in_progress_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInProgressResponse, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SetInProgressResponse, camera_server_result_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::SubscribeTakePhotoRequest, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::TakePhotoResponse, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::TakePhotoResponse, index_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::RespondTakePhotoRequest, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::RespondTakePhotoRequest, take_photo_feedback_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::RespondTakePhotoRequest, capture_info_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::RespondTakePhotoResponse, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::RespondTakePhotoResponse, camera_server_result_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, vendor_name_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, model_name_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, firmware_version_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, focal_length_mm_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, horizontal_sensor_size_mm_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, vertical_sensor_size_mm_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, horizontal_resolution_px_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, vertical_resolution_px_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, lens_id_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, definition_file_version_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Information, definition_file_uri_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Position, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Position, latitude_deg_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Position, longitude_deg_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Position, absolute_altitude_m_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Position, relative_altitude_m_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Quaternion, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Quaternion, w_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Quaternion, x_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Quaternion, y_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::Quaternion, z_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CaptureInfo, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CaptureInfo, position_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CaptureInfo, attitude_quaternion_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CaptureInfo, time_utc_us_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CaptureInfo, is_success_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CaptureInfo, index_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CaptureInfo, file_url_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CameraServerResult, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CameraServerResult, result_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::camera_server::CameraServerResult, result_str_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::mavsdk::rpc::camera_server::SetInformationRequest)}, { 7, -1, -1, sizeof(::mavsdk::rpc::camera_server::SetInformationResponse)}, { 14, -1, -1, sizeof(::mavsdk::rpc::camera_server::SetInProgressRequest)}, { 21, -1, -1, sizeof(::mavsdk::rpc::camera_server::SetInProgressResponse)}, { 28, -1, -1, sizeof(::mavsdk::rpc::camera_server::SubscribeTakePhotoRequest)}, { 34, -1, -1, sizeof(::mavsdk::rpc::camera_server::TakePhotoResponse)}, { 41, -1, -1, sizeof(::mavsdk::rpc::camera_server::RespondTakePhotoRequest)}, { 49, -1, -1, sizeof(::mavsdk::rpc::camera_server::RespondTakePhotoResponse)}, { 56, -1, -1, sizeof(::mavsdk::rpc::camera_server::Information)}, { 73, -1, -1, sizeof(::mavsdk::rpc::camera_server::Position)}, { 83, -1, -1, sizeof(::mavsdk::rpc::camera_server::Quaternion)}, { 93, -1, -1, sizeof(::mavsdk::rpc::camera_server::CaptureInfo)}, { 105, -1, -1, sizeof(::mavsdk::rpc::camera_server::CameraServerResult)}, }; static const ::_pb::Message* const file_default_instances[] = { &::mavsdk::rpc::camera_server::_SetInformationRequest_default_instance_._instance, &::mavsdk::rpc::camera_server::_SetInformationResponse_default_instance_._instance, &::mavsdk::rpc::camera_server::_SetInProgressRequest_default_instance_._instance, &::mavsdk::rpc::camera_server::_SetInProgressResponse_default_instance_._instance, &::mavsdk::rpc::camera_server::_SubscribeTakePhotoRequest_default_instance_._instance, &::mavsdk::rpc::camera_server::_TakePhotoResponse_default_instance_._instance, &::mavsdk::rpc::camera_server::_RespondTakePhotoRequest_default_instance_._instance, &::mavsdk::rpc::camera_server::_RespondTakePhotoResponse_default_instance_._instance, &::mavsdk::rpc::camera_server::_Information_default_instance_._instance, &::mavsdk::rpc::camera_server::_Position_default_instance_._instance, &::mavsdk::rpc::camera_server::_Quaternion_default_instance_._instance, &::mavsdk::rpc::camera_server::_CaptureInfo_default_instance_._instance, &::mavsdk::rpc::camera_server::_CameraServerResult_default_instance_._instance, }; const char descriptor_table_protodef_camera_5fserver_2fcamera_5fserver_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n!camera_server/camera_server.proto\022\030mav" "sdk.rpc.camera_server\032\024mavsdk_options.pr" "oto\"S\n\025SetInformationRequest\022:\n\013informat" "ion\030\001 \001(\0132%.mavsdk.rpc.camera_server.Inf" "ormation\"d\n\026SetInformationResponse\022J\n\024ca" "mera_server_result\030\001 \001(\0132,.mavsdk.rpc.ca" "mera_server.CameraServerResult\"+\n\024SetInP" "rogressRequest\022\023\n\013in_progress\030\001 \001(\010\"c\n\025S" "etInProgressResponse\022J\n\024camera_server_re" "sult\030\001 \001(\0132,.mavsdk.rpc.camera_server.Ca" "meraServerResult\"\033\n\031SubscribeTakePhotoRe" "quest\"\"\n\021TakePhotoResponse\022\r\n\005index\030\001 \001(" "\005\"\240\001\n\027RespondTakePhotoRequest\022H\n\023take_ph" "oto_feedback\030\001 \001(\0162+.mavsdk.rpc.camera_s" "erver.TakePhotoFeedback\022;\n\014capture_info\030" "\002 \001(\0132%.mavsdk.rpc.camera_server.Capture" "Info\"f\n\030RespondTakePhotoResponse\022J\n\024came" "ra_server_result\030\001 \001(\0132,.mavsdk.rpc.came" "ra_server.CameraServerResult\"\276\002\n\013Informa" "tion\022\023\n\013vendor_name\030\001 \001(\t\022\022\n\nmodel_name\030" "\002 \001(\t\022\030\n\020firmware_version\030\003 \001(\t\022\027\n\017focal" "_length_mm\030\004 \001(\002\022!\n\031horizontal_sensor_si" "ze_mm\030\005 \001(\002\022\037\n\027vertical_sensor_size_mm\030\006" " \001(\002\022 \n\030horizontal_resolution_px\030\007 \001(\r\022\036" "\n\026vertical_resolution_px\030\010 \001(\r\022\017\n\007lens_i" "d\030\t \001(\r\022\037\n\027definition_file_version\030\n \001(\r" "\022\033\n\023definition_file_uri\030\013 \001(\t\"q\n\010Positio" "n\022\024\n\014latitude_deg\030\001 \001(\001\022\025\n\rlongitude_deg" "\030\002 \001(\001\022\033\n\023absolute_altitude_m\030\003 \001(\002\022\033\n\023r" "elative_altitude_m\030\004 \001(\002\"8\n\nQuaternion\022\t" "\n\001w\030\001 \001(\002\022\t\n\001x\030\002 \001(\002\022\t\n\001y\030\003 \001(\002\022\t\n\001z\030\004 \001" "(\002\"\320\001\n\013CaptureInfo\0224\n\010position\030\001 \001(\0132\".m" "avsdk.rpc.camera_server.Position\022A\n\023atti" "tude_quaternion\030\002 \001(\0132$.mavsdk.rpc.camer" "a_server.Quaternion\022\023\n\013time_utc_us\030\003 \001(\004" "\022\022\n\nis_success\030\004 \001(\010\022\r\n\005index\030\005 \001(\005\022\020\n\010f" "ile_url\030\006 \001(\t\"\263\002\n\022CameraServerResult\022C\n\006" "result\030\001 \001(\01623.mavsdk.rpc.camera_server." "CameraServerResult.Result\022\022\n\nresult_str\030" "\002 \001(\t\"\303\001\n\006Result\022\022\n\016RESULT_UNKNOWN\020\000\022\022\n\016" "RESULT_SUCCESS\020\001\022\026\n\022RESULT_IN_PROGRESS\020\002" "\022\017\n\013RESULT_BUSY\020\003\022\021\n\rRESULT_DENIED\020\004\022\020\n\014" "RESULT_ERROR\020\005\022\022\n\016RESULT_TIMEOUT\020\006\022\031\n\025RE" "SULT_WRONG_ARGUMENT\020\007\022\024\n\020RESULT_NO_SYSTE" "M\020\010*\216\001\n\021TakePhotoFeedback\022\037\n\033TAKE_PHOTO_" "FEEDBACK_UNKNOWN\020\000\022\032\n\026TAKE_PHOTO_FEEDBAC" "K_OK\020\001\022\034\n\030TAKE_PHOTO_FEEDBACK_BUSY\020\002\022\036\n\032" "TAKE_PHOTO_FEEDBACK_FAILED\020\0032\211\004\n\023CameraS" "erverService\022y\n\016SetInformation\022/.mavsdk." "rpc.camera_server.SetInformationRequest\032" "0.mavsdk.rpc.camera_server.SetInformatio" "nResponse\"\004\200\265\030\001\022v\n\rSetInProgress\022..mavsd" "k.rpc.camera_server.SetInProgressRequest" "\032/.mavsdk.rpc.camera_server.SetInProgres" "sResponse\"\004\200\265\030\001\022~\n\022SubscribeTakePhoto\0223." "mavsdk.rpc.camera_server.SubscribeTakePh" "otoRequest\032+.mavsdk.rpc.camera_server.Ta" "kePhotoResponse\"\004\200\265\030\0000\001\022\177\n\020RespondTakePh" "oto\0221.mavsdk.rpc.camera_server.RespondTa" "kePhotoRequest\0322.mavsdk.rpc.camera_serve" "r.RespondTakePhotoResponse\"\004\200\265\030\001B,\n\027io.m" "avsdk.camera_serverB\021CameraServerProtob\006" "proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_deps[1] = { &::descriptor_table_mavsdk_5foptions_2eproto, }; static ::_pbi::once_flag descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto = { false, false, 2486, descriptor_table_protodef_camera_5fserver_2fcamera_5fserver_2eproto, "camera_server/camera_server.proto", &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_deps, 1, 13, schemas, file_default_instances, TableStruct_camera_5fserver_2fcamera_5fserver_2eproto::offsets, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto, file_level_enum_descriptors_camera_5fserver_2fcamera_5fserver_2eproto, file_level_service_descriptors_camera_5fserver_2fcamera_5fserver_2eproto, }; PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter() { return &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto; } // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_camera_5fserver_2fcamera_5fserver_2eproto(&descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto); namespace mavsdk { namespace rpc { namespace camera_server { const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CameraServerResult_Result_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto); return file_level_enum_descriptors_camera_5fserver_2fcamera_5fserver_2eproto[0]; } bool CameraServerResult_Result_IsValid(int value) { switch (value) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: return true; default: return false; } } #if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr CameraServerResult_Result CameraServerResult::RESULT_UNKNOWN; constexpr CameraServerResult_Result CameraServerResult::RESULT_SUCCESS; constexpr CameraServerResult_Result CameraServerResult::RESULT_IN_PROGRESS; constexpr CameraServerResult_Result CameraServerResult::RESULT_BUSY; constexpr CameraServerResult_Result CameraServerResult::RESULT_DENIED; constexpr CameraServerResult_Result CameraServerResult::RESULT_ERROR; constexpr CameraServerResult_Result CameraServerResult::RESULT_TIMEOUT; constexpr CameraServerResult_Result CameraServerResult::RESULT_WRONG_ARGUMENT; constexpr CameraServerResult_Result CameraServerResult::RESULT_NO_SYSTEM; constexpr CameraServerResult_Result CameraServerResult::Result_MIN; constexpr CameraServerResult_Result CameraServerResult::Result_MAX; constexpr int CameraServerResult::Result_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* TakePhotoFeedback_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto); return file_level_enum_descriptors_camera_5fserver_2fcamera_5fserver_2eproto[1]; } bool TakePhotoFeedback_IsValid(int value) { switch (value) { case 0: case 1: case 2: case 3: return true; default: return false; } } // =================================================================== class SetInformationRequest::_Internal { public: static const ::mavsdk::rpc::camera_server::Information& information(const SetInformationRequest* msg); }; const ::mavsdk::rpc::camera_server::Information& SetInformationRequest::_Internal::information(const SetInformationRequest* msg) { return *msg->information_; } SetInformationRequest::SetInformationRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.SetInformationRequest) } SetInformationRequest::SetInformationRequest(const SetInformationRequest& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_information()) { information_ = new ::mavsdk::rpc::camera_server::Information(*from.information_); } else { information_ = nullptr; } // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.SetInformationRequest) } inline void SetInformationRequest::SharedCtor() { information_ = nullptr; } SetInformationRequest::~SetInformationRequest() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.SetInformationRequest) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void SetInformationRequest::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete information_; } void SetInformationRequest::SetCachedSize(int size) const { _cached_size_.Set(size); } void SetInformationRequest::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.SetInformationRequest) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaForAllocation() == nullptr && information_ != nullptr) { delete information_; } information_ = nullptr; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* SetInformationRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .mavsdk.rpc.camera_server.Information information = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_information(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* SetInformationRequest::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.SetInformationRequest) uint32_t cached_has_bits = 0; (void) cached_has_bits; // .mavsdk.rpc.camera_server.Information information = 1; if (this->_internal_has_information()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::information(this), _Internal::information(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.SetInformationRequest) return target; } size_t SetInformationRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.SetInformationRequest) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // .mavsdk.rpc.camera_server.Information information = 1; if (this->_internal_has_information()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *information_); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SetInformationRequest::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, SetInformationRequest::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SetInformationRequest::GetClassData() const { return &_class_data_; } void SetInformationRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<SetInformationRequest *>(to)->MergeFrom( static_cast<const SetInformationRequest &>(from)); } void SetInformationRequest::MergeFrom(const SetInformationRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.SetInformationRequest) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_has_information()) { _internal_mutable_information()->::mavsdk::rpc::camera_server::Information::MergeFrom(from._internal_information()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void SetInformationRequest::CopyFrom(const SetInformationRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.SetInformationRequest) if (&from == this) return; Clear(); MergeFrom(from); } bool SetInformationRequest::IsInitialized() const { return true; } void SetInformationRequest::InternalSwap(SetInformationRequest* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(information_, other->information_); } ::PROTOBUF_NAMESPACE_ID::Metadata SetInformationRequest::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[0]); } // =================================================================== class SetInformationResponse::_Internal { public: static const ::mavsdk::rpc::camera_server::CameraServerResult& camera_server_result(const SetInformationResponse* msg); }; const ::mavsdk::rpc::camera_server::CameraServerResult& SetInformationResponse::_Internal::camera_server_result(const SetInformationResponse* msg) { return *msg->camera_server_result_; } SetInformationResponse::SetInformationResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.SetInformationResponse) } SetInformationResponse::SetInformationResponse(const SetInformationResponse& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_camera_server_result()) { camera_server_result_ = new ::mavsdk::rpc::camera_server::CameraServerResult(*from.camera_server_result_); } else { camera_server_result_ = nullptr; } // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.SetInformationResponse) } inline void SetInformationResponse::SharedCtor() { camera_server_result_ = nullptr; } SetInformationResponse::~SetInformationResponse() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.SetInformationResponse) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void SetInformationResponse::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete camera_server_result_; } void SetInformationResponse::SetCachedSize(int size) const { _cached_size_.Set(size); } void SetInformationResponse::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.SetInformationResponse) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaForAllocation() == nullptr && camera_server_result_ != nullptr) { delete camera_server_result_; } camera_server_result_ = nullptr; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* SetInformationResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_camera_server_result(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* SetInformationResponse::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.SetInformationResponse) uint32_t cached_has_bits = 0; (void) cached_has_bits; // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; if (this->_internal_has_camera_server_result()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::camera_server_result(this), _Internal::camera_server_result(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.SetInformationResponse) return target; } size_t SetInformationResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.SetInformationResponse) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; if (this->_internal_has_camera_server_result()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *camera_server_result_); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SetInformationResponse::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, SetInformationResponse::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SetInformationResponse::GetClassData() const { return &_class_data_; } void SetInformationResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<SetInformationResponse *>(to)->MergeFrom( static_cast<const SetInformationResponse &>(from)); } void SetInformationResponse::MergeFrom(const SetInformationResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.SetInformationResponse) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_has_camera_server_result()) { _internal_mutable_camera_server_result()->::mavsdk::rpc::camera_server::CameraServerResult::MergeFrom(from._internal_camera_server_result()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void SetInformationResponse::CopyFrom(const SetInformationResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.SetInformationResponse) if (&from == this) return; Clear(); MergeFrom(from); } bool SetInformationResponse::IsInitialized() const { return true; } void SetInformationResponse::InternalSwap(SetInformationResponse* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(camera_server_result_, other->camera_server_result_); } ::PROTOBUF_NAMESPACE_ID::Metadata SetInformationResponse::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[1]); } // =================================================================== class SetInProgressRequest::_Internal { public: }; SetInProgressRequest::SetInProgressRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.SetInProgressRequest) } SetInProgressRequest::SetInProgressRequest(const SetInProgressRequest& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); in_progress_ = from.in_progress_; // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.SetInProgressRequest) } inline void SetInProgressRequest::SharedCtor() { in_progress_ = false; } SetInProgressRequest::~SetInProgressRequest() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.SetInProgressRequest) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void SetInProgressRequest::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void SetInProgressRequest::SetCachedSize(int size) const { _cached_size_.Set(size); } void SetInProgressRequest::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.SetInProgressRequest) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; in_progress_ = false; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* SetInProgressRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // bool in_progress = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { in_progress_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* SetInProgressRequest::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.SetInProgressRequest) uint32_t cached_has_bits = 0; (void) cached_has_bits; // bool in_progress = 1; if (this->_internal_in_progress() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_in_progress(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.SetInProgressRequest) return target; } size_t SetInProgressRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.SetInProgressRequest) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // bool in_progress = 1; if (this->_internal_in_progress() != 0) { total_size += 1 + 1; } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SetInProgressRequest::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, SetInProgressRequest::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SetInProgressRequest::GetClassData() const { return &_class_data_; } void SetInProgressRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<SetInProgressRequest *>(to)->MergeFrom( static_cast<const SetInProgressRequest &>(from)); } void SetInProgressRequest::MergeFrom(const SetInProgressRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.SetInProgressRequest) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_in_progress() != 0) { _internal_set_in_progress(from._internal_in_progress()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void SetInProgressRequest::CopyFrom(const SetInProgressRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.SetInProgressRequest) if (&from == this) return; Clear(); MergeFrom(from); } bool SetInProgressRequest::IsInitialized() const { return true; } void SetInProgressRequest::InternalSwap(SetInProgressRequest* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(in_progress_, other->in_progress_); } ::PROTOBUF_NAMESPACE_ID::Metadata SetInProgressRequest::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[2]); } // =================================================================== class SetInProgressResponse::_Internal { public: static const ::mavsdk::rpc::camera_server::CameraServerResult& camera_server_result(const SetInProgressResponse* msg); }; const ::mavsdk::rpc::camera_server::CameraServerResult& SetInProgressResponse::_Internal::camera_server_result(const SetInProgressResponse* msg) { return *msg->camera_server_result_; } SetInProgressResponse::SetInProgressResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.SetInProgressResponse) } SetInProgressResponse::SetInProgressResponse(const SetInProgressResponse& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_camera_server_result()) { camera_server_result_ = new ::mavsdk::rpc::camera_server::CameraServerResult(*from.camera_server_result_); } else { camera_server_result_ = nullptr; } // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.SetInProgressResponse) } inline void SetInProgressResponse::SharedCtor() { camera_server_result_ = nullptr; } SetInProgressResponse::~SetInProgressResponse() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.SetInProgressResponse) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void SetInProgressResponse::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete camera_server_result_; } void SetInProgressResponse::SetCachedSize(int size) const { _cached_size_.Set(size); } void SetInProgressResponse::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.SetInProgressResponse) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaForAllocation() == nullptr && camera_server_result_ != nullptr) { delete camera_server_result_; } camera_server_result_ = nullptr; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* SetInProgressResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_camera_server_result(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* SetInProgressResponse::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.SetInProgressResponse) uint32_t cached_has_bits = 0; (void) cached_has_bits; // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; if (this->_internal_has_camera_server_result()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::camera_server_result(this), _Internal::camera_server_result(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.SetInProgressResponse) return target; } size_t SetInProgressResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.SetInProgressResponse) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; if (this->_internal_has_camera_server_result()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *camera_server_result_); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SetInProgressResponse::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, SetInProgressResponse::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SetInProgressResponse::GetClassData() const { return &_class_data_; } void SetInProgressResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<SetInProgressResponse *>(to)->MergeFrom( static_cast<const SetInProgressResponse &>(from)); } void SetInProgressResponse::MergeFrom(const SetInProgressResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.SetInProgressResponse) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_has_camera_server_result()) { _internal_mutable_camera_server_result()->::mavsdk::rpc::camera_server::CameraServerResult::MergeFrom(from._internal_camera_server_result()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void SetInProgressResponse::CopyFrom(const SetInProgressResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.SetInProgressResponse) if (&from == this) return; Clear(); MergeFrom(from); } bool SetInProgressResponse::IsInitialized() const { return true; } void SetInProgressResponse::InternalSwap(SetInProgressResponse* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(camera_server_result_, other->camera_server_result_); } ::PROTOBUF_NAMESPACE_ID::Metadata SetInProgressResponse::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[3]); } // =================================================================== class SubscribeTakePhotoRequest::_Internal { public: }; SubscribeTakePhotoRequest::SubscribeTakePhotoRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) { // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.SubscribeTakePhotoRequest) } SubscribeTakePhotoRequest::SubscribeTakePhotoRequest(const SubscribeTakePhotoRequest& from) : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.SubscribeTakePhotoRequest) } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SubscribeTakePhotoRequest::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl, ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl, }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SubscribeTakePhotoRequest::GetClassData() const { return &_class_data_; } ::PROTOBUF_NAMESPACE_ID::Metadata SubscribeTakePhotoRequest::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[4]); } // =================================================================== class TakePhotoResponse::_Internal { public: }; TakePhotoResponse::TakePhotoResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.TakePhotoResponse) } TakePhotoResponse::TakePhotoResponse(const TakePhotoResponse& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); index_ = from.index_; // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.TakePhotoResponse) } inline void TakePhotoResponse::SharedCtor() { index_ = 0; } TakePhotoResponse::~TakePhotoResponse() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.TakePhotoResponse) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void TakePhotoResponse::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void TakePhotoResponse::SetCachedSize(int size) const { _cached_size_.Set(size); } void TakePhotoResponse::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.TakePhotoResponse) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; index_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* TakePhotoResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // int32 index = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* TakePhotoResponse::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.TakePhotoResponse) uint32_t cached_has_bits = 0; (void) cached_has_bits; // int32 index = 1; if (this->_internal_index() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_index(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.TakePhotoResponse) return target; } size_t TakePhotoResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.TakePhotoResponse) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // int32 index = 1; if (this->_internal_index() != 0) { total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_index()); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData TakePhotoResponse::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, TakePhotoResponse::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*TakePhotoResponse::GetClassData() const { return &_class_data_; } void TakePhotoResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<TakePhotoResponse *>(to)->MergeFrom( static_cast<const TakePhotoResponse &>(from)); } void TakePhotoResponse::MergeFrom(const TakePhotoResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.TakePhotoResponse) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_index() != 0) { _internal_set_index(from._internal_index()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void TakePhotoResponse::CopyFrom(const TakePhotoResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.TakePhotoResponse) if (&from == this) return; Clear(); MergeFrom(from); } bool TakePhotoResponse::IsInitialized() const { return true; } void TakePhotoResponse::InternalSwap(TakePhotoResponse* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(index_, other->index_); } ::PROTOBUF_NAMESPACE_ID::Metadata TakePhotoResponse::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[5]); } // =================================================================== class RespondTakePhotoRequest::_Internal { public: static const ::mavsdk::rpc::camera_server::CaptureInfo& capture_info(const RespondTakePhotoRequest* msg); }; const ::mavsdk::rpc::camera_server::CaptureInfo& RespondTakePhotoRequest::_Internal::capture_info(const RespondTakePhotoRequest* msg) { return *msg->capture_info_; } RespondTakePhotoRequest::RespondTakePhotoRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.RespondTakePhotoRequest) } RespondTakePhotoRequest::RespondTakePhotoRequest(const RespondTakePhotoRequest& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_capture_info()) { capture_info_ = new ::mavsdk::rpc::camera_server::CaptureInfo(*from.capture_info_); } else { capture_info_ = nullptr; } take_photo_feedback_ = from.take_photo_feedback_; // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.RespondTakePhotoRequest) } inline void RespondTakePhotoRequest::SharedCtor() { ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&capture_info_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&take_photo_feedback_) - reinterpret_cast<char*>(&capture_info_)) + sizeof(take_photo_feedback_)); } RespondTakePhotoRequest::~RespondTakePhotoRequest() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.RespondTakePhotoRequest) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void RespondTakePhotoRequest::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete capture_info_; } void RespondTakePhotoRequest::SetCachedSize(int size) const { _cached_size_.Set(size); } void RespondTakePhotoRequest::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.RespondTakePhotoRequest) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaForAllocation() == nullptr && capture_info_ != nullptr) { delete capture_info_; } capture_info_ = nullptr; take_photo_feedback_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* RespondTakePhotoRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .mavsdk.rpc.camera_server.TakePhotoFeedback take_photo_feedback = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); _internal_set_take_photo_feedback(static_cast<::mavsdk::rpc::camera_server::TakePhotoFeedback>(val)); } else goto handle_unusual; continue; // .mavsdk.rpc.camera_server.CaptureInfo capture_info = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { ptr = ctx->ParseMessage(_internal_mutable_capture_info(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* RespondTakePhotoRequest::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.RespondTakePhotoRequest) uint32_t cached_has_bits = 0; (void) cached_has_bits; // .mavsdk.rpc.camera_server.TakePhotoFeedback take_photo_feedback = 1; if (this->_internal_take_photo_feedback() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( 1, this->_internal_take_photo_feedback(), target); } // .mavsdk.rpc.camera_server.CaptureInfo capture_info = 2; if (this->_internal_has_capture_info()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(2, _Internal::capture_info(this), _Internal::capture_info(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.RespondTakePhotoRequest) return target; } size_t RespondTakePhotoRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.RespondTakePhotoRequest) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // .mavsdk.rpc.camera_server.CaptureInfo capture_info = 2; if (this->_internal_has_capture_info()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *capture_info_); } // .mavsdk.rpc.camera_server.TakePhotoFeedback take_photo_feedback = 1; if (this->_internal_take_photo_feedback() != 0) { total_size += 1 + ::_pbi::WireFormatLite::EnumSize(this->_internal_take_photo_feedback()); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData RespondTakePhotoRequest::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, RespondTakePhotoRequest::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*RespondTakePhotoRequest::GetClassData() const { return &_class_data_; } void RespondTakePhotoRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<RespondTakePhotoRequest *>(to)->MergeFrom( static_cast<const RespondTakePhotoRequest &>(from)); } void RespondTakePhotoRequest::MergeFrom(const RespondTakePhotoRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.RespondTakePhotoRequest) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_has_capture_info()) { _internal_mutable_capture_info()->::mavsdk::rpc::camera_server::CaptureInfo::MergeFrom(from._internal_capture_info()); } if (from._internal_take_photo_feedback() != 0) { _internal_set_take_photo_feedback(from._internal_take_photo_feedback()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void RespondTakePhotoRequest::CopyFrom(const RespondTakePhotoRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.RespondTakePhotoRequest) if (&from == this) return; Clear(); MergeFrom(from); } bool RespondTakePhotoRequest::IsInitialized() const { return true; } void RespondTakePhotoRequest::InternalSwap(RespondTakePhotoRequest* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(RespondTakePhotoRequest, take_photo_feedback_) + sizeof(RespondTakePhotoRequest::take_photo_feedback_) - PROTOBUF_FIELD_OFFSET(RespondTakePhotoRequest, capture_info_)>( reinterpret_cast<char*>(&capture_info_), reinterpret_cast<char*>(&other->capture_info_)); } ::PROTOBUF_NAMESPACE_ID::Metadata RespondTakePhotoRequest::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[6]); } // =================================================================== class RespondTakePhotoResponse::_Internal { public: static const ::mavsdk::rpc::camera_server::CameraServerResult& camera_server_result(const RespondTakePhotoResponse* msg); }; const ::mavsdk::rpc::camera_server::CameraServerResult& RespondTakePhotoResponse::_Internal::camera_server_result(const RespondTakePhotoResponse* msg) { return *msg->camera_server_result_; } RespondTakePhotoResponse::RespondTakePhotoResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.RespondTakePhotoResponse) } RespondTakePhotoResponse::RespondTakePhotoResponse(const RespondTakePhotoResponse& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_camera_server_result()) { camera_server_result_ = new ::mavsdk::rpc::camera_server::CameraServerResult(*from.camera_server_result_); } else { camera_server_result_ = nullptr; } // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.RespondTakePhotoResponse) } inline void RespondTakePhotoResponse::SharedCtor() { camera_server_result_ = nullptr; } RespondTakePhotoResponse::~RespondTakePhotoResponse() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.RespondTakePhotoResponse) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void RespondTakePhotoResponse::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete camera_server_result_; } void RespondTakePhotoResponse::SetCachedSize(int size) const { _cached_size_.Set(size); } void RespondTakePhotoResponse::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.RespondTakePhotoResponse) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaForAllocation() == nullptr && camera_server_result_ != nullptr) { delete camera_server_result_; } camera_server_result_ = nullptr; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* RespondTakePhotoResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_camera_server_result(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* RespondTakePhotoResponse::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.RespondTakePhotoResponse) uint32_t cached_has_bits = 0; (void) cached_has_bits; // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; if (this->_internal_has_camera_server_result()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::camera_server_result(this), _Internal::camera_server_result(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.RespondTakePhotoResponse) return target; } size_t RespondTakePhotoResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.RespondTakePhotoResponse) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // .mavsdk.rpc.camera_server.CameraServerResult camera_server_result = 1; if (this->_internal_has_camera_server_result()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *camera_server_result_); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData RespondTakePhotoResponse::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, RespondTakePhotoResponse::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*RespondTakePhotoResponse::GetClassData() const { return &_class_data_; } void RespondTakePhotoResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<RespondTakePhotoResponse *>(to)->MergeFrom( static_cast<const RespondTakePhotoResponse &>(from)); } void RespondTakePhotoResponse::MergeFrom(const RespondTakePhotoResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.RespondTakePhotoResponse) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_has_camera_server_result()) { _internal_mutable_camera_server_result()->::mavsdk::rpc::camera_server::CameraServerResult::MergeFrom(from._internal_camera_server_result()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void RespondTakePhotoResponse::CopyFrom(const RespondTakePhotoResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.RespondTakePhotoResponse) if (&from == this) return; Clear(); MergeFrom(from); } bool RespondTakePhotoResponse::IsInitialized() const { return true; } void RespondTakePhotoResponse::InternalSwap(RespondTakePhotoResponse* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(camera_server_result_, other->camera_server_result_); } ::PROTOBUF_NAMESPACE_ID::Metadata RespondTakePhotoResponse::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[7]); } // =================================================================== class Information::_Internal { public: }; Information::Information(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.Information) } Information::Information(const Information& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); vendor_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING vendor_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_vendor_name().empty()) { vendor_name_.Set(from._internal_vendor_name(), GetArenaForAllocation()); } model_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING model_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_model_name().empty()) { model_name_.Set(from._internal_model_name(), GetArenaForAllocation()); } firmware_version_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING firmware_version_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_firmware_version().empty()) { firmware_version_.Set(from._internal_firmware_version(), GetArenaForAllocation()); } definition_file_uri_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING definition_file_uri_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_definition_file_uri().empty()) { definition_file_uri_.Set(from._internal_definition_file_uri(), GetArenaForAllocation()); } ::memcpy(&focal_length_mm_, &from.focal_length_mm_, static_cast<size_t>(reinterpret_cast<char*>(&definition_file_version_) - reinterpret_cast<char*>(&focal_length_mm_)) + sizeof(definition_file_version_)); // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.Information) } inline void Information::SharedCtor() { vendor_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING vendor_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING model_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING model_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING firmware_version_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING firmware_version_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING definition_file_uri_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING definition_file_uri_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&focal_length_mm_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&definition_file_version_) - reinterpret_cast<char*>(&focal_length_mm_)) + sizeof(definition_file_version_)); } Information::~Information() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.Information) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void Information::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); vendor_name_.Destroy(); model_name_.Destroy(); firmware_version_.Destroy(); definition_file_uri_.Destroy(); } void Information::SetCachedSize(int size) const { _cached_size_.Set(size); } void Information::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.Information) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; vendor_name_.ClearToEmpty(); model_name_.ClearToEmpty(); firmware_version_.ClearToEmpty(); definition_file_uri_.ClearToEmpty(); ::memset(&focal_length_mm_, 0, static_cast<size_t>( reinterpret_cast<char*>(&definition_file_version_) - reinterpret_cast<char*>(&focal_length_mm_)) + sizeof(definition_file_version_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Information::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string vendor_name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_vendor_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, "mavsdk.rpc.camera_server.Information.vendor_name")); } else goto handle_unusual; continue; // string model_name = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_model_name(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, "mavsdk.rpc.camera_server.Information.model_name")); } else goto handle_unusual; continue; // string firmware_version = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { auto str = _internal_mutable_firmware_version(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, "mavsdk.rpc.camera_server.Information.firmware_version")); } else goto handle_unusual; continue; // float focal_length_mm = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 37)) { focal_length_mm_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; // float horizontal_sensor_size_mm = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 45)) { horizontal_sensor_size_mm_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; // float vertical_sensor_size_mm = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 53)) { vertical_sensor_size_mm_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; // uint32 horizontal_resolution_px = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) { horizontal_resolution_px_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // uint32 vertical_resolution_px = 8; case 8: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 64)) { vertical_resolution_px_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // uint32 lens_id = 9; case 9: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 72)) { lens_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // uint32 definition_file_version = 10; case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) { definition_file_version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // string definition_file_uri = 11; case 11: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 90)) { auto str = _internal_mutable_definition_file_uri(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, "mavsdk.rpc.camera_server.Information.definition_file_uri")); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* Information::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.Information) uint32_t cached_has_bits = 0; (void) cached_has_bits; // string vendor_name = 1; if (!this->_internal_vendor_name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_vendor_name().data(), static_cast<int>(this->_internal_vendor_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "mavsdk.rpc.camera_server.Information.vendor_name"); target = stream->WriteStringMaybeAliased( 1, this->_internal_vendor_name(), target); } // string model_name = 2; if (!this->_internal_model_name().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_model_name().data(), static_cast<int>(this->_internal_model_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "mavsdk.rpc.camera_server.Information.model_name"); target = stream->WriteStringMaybeAliased( 2, this->_internal_model_name(), target); } // string firmware_version = 3; if (!this->_internal_firmware_version().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_firmware_version().data(), static_cast<int>(this->_internal_firmware_version().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "mavsdk.rpc.camera_server.Information.firmware_version"); target = stream->WriteStringMaybeAliased( 3, this->_internal_firmware_version(), target); } // float focal_length_mm = 4; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_focal_length_mm = this->_internal_focal_length_mm(); uint32_t raw_focal_length_mm; memcpy(&raw_focal_length_mm, &tmp_focal_length_mm, sizeof(tmp_focal_length_mm)); if (raw_focal_length_mm != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(4, this->_internal_focal_length_mm(), target); } // float horizontal_sensor_size_mm = 5; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_horizontal_sensor_size_mm = this->_internal_horizontal_sensor_size_mm(); uint32_t raw_horizontal_sensor_size_mm; memcpy(&raw_horizontal_sensor_size_mm, &tmp_horizontal_sensor_size_mm, sizeof(tmp_horizontal_sensor_size_mm)); if (raw_horizontal_sensor_size_mm != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(5, this->_internal_horizontal_sensor_size_mm(), target); } // float vertical_sensor_size_mm = 6; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_vertical_sensor_size_mm = this->_internal_vertical_sensor_size_mm(); uint32_t raw_vertical_sensor_size_mm; memcpy(&raw_vertical_sensor_size_mm, &tmp_vertical_sensor_size_mm, sizeof(tmp_vertical_sensor_size_mm)); if (raw_vertical_sensor_size_mm != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(6, this->_internal_vertical_sensor_size_mm(), target); } // uint32 horizontal_resolution_px = 7; if (this->_internal_horizontal_resolution_px() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(7, this->_internal_horizontal_resolution_px(), target); } // uint32 vertical_resolution_px = 8; if (this->_internal_vertical_resolution_px() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(8, this->_internal_vertical_resolution_px(), target); } // uint32 lens_id = 9; if (this->_internal_lens_id() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(9, this->_internal_lens_id(), target); } // uint32 definition_file_version = 10; if (this->_internal_definition_file_version() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt32ToArray(10, this->_internal_definition_file_version(), target); } // string definition_file_uri = 11; if (!this->_internal_definition_file_uri().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_definition_file_uri().data(), static_cast<int>(this->_internal_definition_file_uri().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "mavsdk.rpc.camera_server.Information.definition_file_uri"); target = stream->WriteStringMaybeAliased( 11, this->_internal_definition_file_uri(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.Information) return target; } size_t Information::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.Information) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // string vendor_name = 1; if (!this->_internal_vendor_name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_vendor_name()); } // string model_name = 2; if (!this->_internal_model_name().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_model_name()); } // string firmware_version = 3; if (!this->_internal_firmware_version().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_firmware_version()); } // string definition_file_uri = 11; if (!this->_internal_definition_file_uri().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_definition_file_uri()); } // float focal_length_mm = 4; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_focal_length_mm = this->_internal_focal_length_mm(); uint32_t raw_focal_length_mm; memcpy(&raw_focal_length_mm, &tmp_focal_length_mm, sizeof(tmp_focal_length_mm)); if (raw_focal_length_mm != 0) { total_size += 1 + 4; } // float horizontal_sensor_size_mm = 5; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_horizontal_sensor_size_mm = this->_internal_horizontal_sensor_size_mm(); uint32_t raw_horizontal_sensor_size_mm; memcpy(&raw_horizontal_sensor_size_mm, &tmp_horizontal_sensor_size_mm, sizeof(tmp_horizontal_sensor_size_mm)); if (raw_horizontal_sensor_size_mm != 0) { total_size += 1 + 4; } // float vertical_sensor_size_mm = 6; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_vertical_sensor_size_mm = this->_internal_vertical_sensor_size_mm(); uint32_t raw_vertical_sensor_size_mm; memcpy(&raw_vertical_sensor_size_mm, &tmp_vertical_sensor_size_mm, sizeof(tmp_vertical_sensor_size_mm)); if (raw_vertical_sensor_size_mm != 0) { total_size += 1 + 4; } // uint32 horizontal_resolution_px = 7; if (this->_internal_horizontal_resolution_px() != 0) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_horizontal_resolution_px()); } // uint32 vertical_resolution_px = 8; if (this->_internal_vertical_resolution_px() != 0) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_vertical_resolution_px()); } // uint32 lens_id = 9; if (this->_internal_lens_id() != 0) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_lens_id()); } // uint32 definition_file_version = 10; if (this->_internal_definition_file_version() != 0) { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_definition_file_version()); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Information::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, Information::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Information::GetClassData() const { return &_class_data_; } void Information::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<Information *>(to)->MergeFrom( static_cast<const Information &>(from)); } void Information::MergeFrom(const Information& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.Information) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_vendor_name().empty()) { _internal_set_vendor_name(from._internal_vendor_name()); } if (!from._internal_model_name().empty()) { _internal_set_model_name(from._internal_model_name()); } if (!from._internal_firmware_version().empty()) { _internal_set_firmware_version(from._internal_firmware_version()); } if (!from._internal_definition_file_uri().empty()) { _internal_set_definition_file_uri(from._internal_definition_file_uri()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_focal_length_mm = from._internal_focal_length_mm(); uint32_t raw_focal_length_mm; memcpy(&raw_focal_length_mm, &tmp_focal_length_mm, sizeof(tmp_focal_length_mm)); if (raw_focal_length_mm != 0) { _internal_set_focal_length_mm(from._internal_focal_length_mm()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_horizontal_sensor_size_mm = from._internal_horizontal_sensor_size_mm(); uint32_t raw_horizontal_sensor_size_mm; memcpy(&raw_horizontal_sensor_size_mm, &tmp_horizontal_sensor_size_mm, sizeof(tmp_horizontal_sensor_size_mm)); if (raw_horizontal_sensor_size_mm != 0) { _internal_set_horizontal_sensor_size_mm(from._internal_horizontal_sensor_size_mm()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_vertical_sensor_size_mm = from._internal_vertical_sensor_size_mm(); uint32_t raw_vertical_sensor_size_mm; memcpy(&raw_vertical_sensor_size_mm, &tmp_vertical_sensor_size_mm, sizeof(tmp_vertical_sensor_size_mm)); if (raw_vertical_sensor_size_mm != 0) { _internal_set_vertical_sensor_size_mm(from._internal_vertical_sensor_size_mm()); } if (from._internal_horizontal_resolution_px() != 0) { _internal_set_horizontal_resolution_px(from._internal_horizontal_resolution_px()); } if (from._internal_vertical_resolution_px() != 0) { _internal_set_vertical_resolution_px(from._internal_vertical_resolution_px()); } if (from._internal_lens_id() != 0) { _internal_set_lens_id(from._internal_lens_id()); } if (from._internal_definition_file_version() != 0) { _internal_set_definition_file_version(from._internal_definition_file_version()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Information::CopyFrom(const Information& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.Information) if (&from == this) return; Clear(); MergeFrom(from); } bool Information::IsInitialized() const { return true; } void Information::InternalSwap(Information* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &vendor_name_, lhs_arena, &other->vendor_name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &model_name_, lhs_arena, &other->model_name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &firmware_version_, lhs_arena, &other->firmware_version_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &definition_file_uri_, lhs_arena, &other->definition_file_uri_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Information, definition_file_version_) + sizeof(Information::definition_file_version_) - PROTOBUF_FIELD_OFFSET(Information, focal_length_mm_)>( reinterpret_cast<char*>(&focal_length_mm_), reinterpret_cast<char*>(&other->focal_length_mm_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Information::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[8]); } // =================================================================== class Position::_Internal { public: }; Position::Position(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.Position) } Position::Position(const Position& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&latitude_deg_, &from.latitude_deg_, static_cast<size_t>(reinterpret_cast<char*>(&relative_altitude_m_) - reinterpret_cast<char*>(&latitude_deg_)) + sizeof(relative_altitude_m_)); // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.Position) } inline void Position::SharedCtor() { ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&latitude_deg_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&relative_altitude_m_) - reinterpret_cast<char*>(&latitude_deg_)) + sizeof(relative_altitude_m_)); } Position::~Position() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.Position) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void Position::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void Position::SetCachedSize(int size) const { _cached_size_.Set(size); } void Position::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.Position) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; ::memset(&latitude_deg_, 0, static_cast<size_t>( reinterpret_cast<char*>(&relative_altitude_m_) - reinterpret_cast<char*>(&latitude_deg_)) + sizeof(relative_altitude_m_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Position::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // double latitude_deg = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 9)) { latitude_deg_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr); ptr += sizeof(double); } else goto handle_unusual; continue; // double longitude_deg = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 17)) { longitude_deg_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr); ptr += sizeof(double); } else goto handle_unusual; continue; // float absolute_altitude_m = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 29)) { absolute_altitude_m_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; // float relative_altitude_m = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 37)) { relative_altitude_m_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* Position::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.Position) uint32_t cached_has_bits = 0; (void) cached_has_bits; // double latitude_deg = 1; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_latitude_deg = this->_internal_latitude_deg(); uint64_t raw_latitude_deg; memcpy(&raw_latitude_deg, &tmp_latitude_deg, sizeof(tmp_latitude_deg)); if (raw_latitude_deg != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteDoubleToArray(1, this->_internal_latitude_deg(), target); } // double longitude_deg = 2; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_longitude_deg = this->_internal_longitude_deg(); uint64_t raw_longitude_deg; memcpy(&raw_longitude_deg, &tmp_longitude_deg, sizeof(tmp_longitude_deg)); if (raw_longitude_deg != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteDoubleToArray(2, this->_internal_longitude_deg(), target); } // float absolute_altitude_m = 3; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_absolute_altitude_m = this->_internal_absolute_altitude_m(); uint32_t raw_absolute_altitude_m; memcpy(&raw_absolute_altitude_m, &tmp_absolute_altitude_m, sizeof(tmp_absolute_altitude_m)); if (raw_absolute_altitude_m != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(3, this->_internal_absolute_altitude_m(), target); } // float relative_altitude_m = 4; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_relative_altitude_m = this->_internal_relative_altitude_m(); uint32_t raw_relative_altitude_m; memcpy(&raw_relative_altitude_m, &tmp_relative_altitude_m, sizeof(tmp_relative_altitude_m)); if (raw_relative_altitude_m != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(4, this->_internal_relative_altitude_m(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.Position) return target; } size_t Position::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.Position) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // double latitude_deg = 1; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_latitude_deg = this->_internal_latitude_deg(); uint64_t raw_latitude_deg; memcpy(&raw_latitude_deg, &tmp_latitude_deg, sizeof(tmp_latitude_deg)); if (raw_latitude_deg != 0) { total_size += 1 + 8; } // double longitude_deg = 2; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_longitude_deg = this->_internal_longitude_deg(); uint64_t raw_longitude_deg; memcpy(&raw_longitude_deg, &tmp_longitude_deg, sizeof(tmp_longitude_deg)); if (raw_longitude_deg != 0) { total_size += 1 + 8; } // float absolute_altitude_m = 3; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_absolute_altitude_m = this->_internal_absolute_altitude_m(); uint32_t raw_absolute_altitude_m; memcpy(&raw_absolute_altitude_m, &tmp_absolute_altitude_m, sizeof(tmp_absolute_altitude_m)); if (raw_absolute_altitude_m != 0) { total_size += 1 + 4; } // float relative_altitude_m = 4; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_relative_altitude_m = this->_internal_relative_altitude_m(); uint32_t raw_relative_altitude_m; memcpy(&raw_relative_altitude_m, &tmp_relative_altitude_m, sizeof(tmp_relative_altitude_m)); if (raw_relative_altitude_m != 0) { total_size += 1 + 4; } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Position::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, Position::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Position::GetClassData() const { return &_class_data_; } void Position::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<Position *>(to)->MergeFrom( static_cast<const Position &>(from)); } void Position::MergeFrom(const Position& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.Position) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_latitude_deg = from._internal_latitude_deg(); uint64_t raw_latitude_deg; memcpy(&raw_latitude_deg, &tmp_latitude_deg, sizeof(tmp_latitude_deg)); if (raw_latitude_deg != 0) { _internal_set_latitude_deg(from._internal_latitude_deg()); } static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_longitude_deg = from._internal_longitude_deg(); uint64_t raw_longitude_deg; memcpy(&raw_longitude_deg, &tmp_longitude_deg, sizeof(tmp_longitude_deg)); if (raw_longitude_deg != 0) { _internal_set_longitude_deg(from._internal_longitude_deg()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_absolute_altitude_m = from._internal_absolute_altitude_m(); uint32_t raw_absolute_altitude_m; memcpy(&raw_absolute_altitude_m, &tmp_absolute_altitude_m, sizeof(tmp_absolute_altitude_m)); if (raw_absolute_altitude_m != 0) { _internal_set_absolute_altitude_m(from._internal_absolute_altitude_m()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_relative_altitude_m = from._internal_relative_altitude_m(); uint32_t raw_relative_altitude_m; memcpy(&raw_relative_altitude_m, &tmp_relative_altitude_m, sizeof(tmp_relative_altitude_m)); if (raw_relative_altitude_m != 0) { _internal_set_relative_altitude_m(from._internal_relative_altitude_m()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Position::CopyFrom(const Position& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.Position) if (&from == this) return; Clear(); MergeFrom(from); } bool Position::IsInitialized() const { return true; } void Position::InternalSwap(Position* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Position, relative_altitude_m_) + sizeof(Position::relative_altitude_m_) - PROTOBUF_FIELD_OFFSET(Position, latitude_deg_)>( reinterpret_cast<char*>(&latitude_deg_), reinterpret_cast<char*>(&other->latitude_deg_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Position::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[9]); } // =================================================================== class Quaternion::_Internal { public: }; Quaternion::Quaternion(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.Quaternion) } Quaternion::Quaternion(const Quaternion& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); ::memcpy(&w_, &from.w_, static_cast<size_t>(reinterpret_cast<char*>(&z_) - reinterpret_cast<char*>(&w_)) + sizeof(z_)); // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.Quaternion) } inline void Quaternion::SharedCtor() { ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&w_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&z_) - reinterpret_cast<char*>(&w_)) + sizeof(z_)); } Quaternion::~Quaternion() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.Quaternion) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void Quaternion::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } void Quaternion::SetCachedSize(int size) const { _cached_size_.Set(size); } void Quaternion::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.Quaternion) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; ::memset(&w_, 0, static_cast<size_t>( reinterpret_cast<char*>(&z_) - reinterpret_cast<char*>(&w_)) + sizeof(z_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* Quaternion::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // float w = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 13)) { w_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; // float x = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 21)) { x_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; // float y = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 29)) { y_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; // float z = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 37)) { z_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* Quaternion::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.Quaternion) uint32_t cached_has_bits = 0; (void) cached_has_bits; // float w = 1; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_w = this->_internal_w(); uint32_t raw_w; memcpy(&raw_w, &tmp_w, sizeof(tmp_w)); if (raw_w != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(1, this->_internal_w(), target); } // float x = 2; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_x = this->_internal_x(); uint32_t raw_x; memcpy(&raw_x, &tmp_x, sizeof(tmp_x)); if (raw_x != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(2, this->_internal_x(), target); } // float y = 3; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_y = this->_internal_y(); uint32_t raw_y; memcpy(&raw_y, &tmp_y, sizeof(tmp_y)); if (raw_y != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(3, this->_internal_y(), target); } // float z = 4; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_z = this->_internal_z(); uint32_t raw_z; memcpy(&raw_z, &tmp_z, sizeof(tmp_z)); if (raw_z != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteFloatToArray(4, this->_internal_z(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.Quaternion) return target; } size_t Quaternion::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.Quaternion) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // float w = 1; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_w = this->_internal_w(); uint32_t raw_w; memcpy(&raw_w, &tmp_w, sizeof(tmp_w)); if (raw_w != 0) { total_size += 1 + 4; } // float x = 2; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_x = this->_internal_x(); uint32_t raw_x; memcpy(&raw_x, &tmp_x, sizeof(tmp_x)); if (raw_x != 0) { total_size += 1 + 4; } // float y = 3; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_y = this->_internal_y(); uint32_t raw_y; memcpy(&raw_y, &tmp_y, sizeof(tmp_y)); if (raw_y != 0) { total_size += 1 + 4; } // float z = 4; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_z = this->_internal_z(); uint32_t raw_z; memcpy(&raw_z, &tmp_z, sizeof(tmp_z)); if (raw_z != 0) { total_size += 1 + 4; } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Quaternion::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, Quaternion::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Quaternion::GetClassData() const { return &_class_data_; } void Quaternion::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<Quaternion *>(to)->MergeFrom( static_cast<const Quaternion &>(from)); } void Quaternion::MergeFrom(const Quaternion& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.Quaternion) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_w = from._internal_w(); uint32_t raw_w; memcpy(&raw_w, &tmp_w, sizeof(tmp_w)); if (raw_w != 0) { _internal_set_w(from._internal_w()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_x = from._internal_x(); uint32_t raw_x; memcpy(&raw_x, &tmp_x, sizeof(tmp_x)); if (raw_x != 0) { _internal_set_x(from._internal_x()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_y = from._internal_y(); uint32_t raw_y; memcpy(&raw_y, &tmp_y, sizeof(tmp_y)); if (raw_y != 0) { _internal_set_y(from._internal_y()); } static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size."); float tmp_z = from._internal_z(); uint32_t raw_z; memcpy(&raw_z, &tmp_z, sizeof(tmp_z)); if (raw_z != 0) { _internal_set_z(from._internal_z()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Quaternion::CopyFrom(const Quaternion& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.Quaternion) if (&from == this) return; Clear(); MergeFrom(from); } bool Quaternion::IsInitialized() const { return true; } void Quaternion::InternalSwap(Quaternion* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Quaternion, z_) + sizeof(Quaternion::z_) - PROTOBUF_FIELD_OFFSET(Quaternion, w_)>( reinterpret_cast<char*>(&w_), reinterpret_cast<char*>(&other->w_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Quaternion::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[10]); } // =================================================================== class CaptureInfo::_Internal { public: static const ::mavsdk::rpc::camera_server::Position& position(const CaptureInfo* msg); static const ::mavsdk::rpc::camera_server::Quaternion& attitude_quaternion(const CaptureInfo* msg); }; const ::mavsdk::rpc::camera_server::Position& CaptureInfo::_Internal::position(const CaptureInfo* msg) { return *msg->position_; } const ::mavsdk::rpc::camera_server::Quaternion& CaptureInfo::_Internal::attitude_quaternion(const CaptureInfo* msg) { return *msg->attitude_quaternion_; } CaptureInfo::CaptureInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.CaptureInfo) } CaptureInfo::CaptureInfo(const CaptureInfo& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); file_url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING file_url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_file_url().empty()) { file_url_.Set(from._internal_file_url(), GetArenaForAllocation()); } if (from._internal_has_position()) { position_ = new ::mavsdk::rpc::camera_server::Position(*from.position_); } else { position_ = nullptr; } if (from._internal_has_attitude_quaternion()) { attitude_quaternion_ = new ::mavsdk::rpc::camera_server::Quaternion(*from.attitude_quaternion_); } else { attitude_quaternion_ = nullptr; } ::memcpy(&time_utc_us_, &from.time_utc_us_, static_cast<size_t>(reinterpret_cast<char*>(&index_) - reinterpret_cast<char*>(&time_utc_us_)) + sizeof(index_)); // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.CaptureInfo) } inline void CaptureInfo::SharedCtor() { file_url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING file_url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&position_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&index_) - reinterpret_cast<char*>(&position_)) + sizeof(index_)); } CaptureInfo::~CaptureInfo() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.CaptureInfo) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void CaptureInfo::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); file_url_.Destroy(); if (this != internal_default_instance()) delete position_; if (this != internal_default_instance()) delete attitude_quaternion_; } void CaptureInfo::SetCachedSize(int size) const { _cached_size_.Set(size); } void CaptureInfo::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.CaptureInfo) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; file_url_.ClearToEmpty(); if (GetArenaForAllocation() == nullptr && position_ != nullptr) { delete position_; } position_ = nullptr; if (GetArenaForAllocation() == nullptr && attitude_quaternion_ != nullptr) { delete attitude_quaternion_; } attitude_quaternion_ = nullptr; ::memset(&time_utc_us_, 0, static_cast<size_t>( reinterpret_cast<char*>(&index_) - reinterpret_cast<char*>(&time_utc_us_)) + sizeof(index_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* CaptureInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .mavsdk.rpc.camera_server.Position position = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_position(), ptr); CHK_(ptr); } else goto handle_unusual; continue; // .mavsdk.rpc.camera_server.Quaternion attitude_quaternion = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { ptr = ctx->ParseMessage(_internal_mutable_attitude_quaternion(), ptr); CHK_(ptr); } else goto handle_unusual; continue; // uint64 time_utc_us = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { time_utc_us_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // bool is_success = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) { is_success_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // int32 index = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) { index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // string file_url = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) { auto str = _internal_mutable_file_url(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, "mavsdk.rpc.camera_server.CaptureInfo.file_url")); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* CaptureInfo::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.CaptureInfo) uint32_t cached_has_bits = 0; (void) cached_has_bits; // .mavsdk.rpc.camera_server.Position position = 1; if (this->_internal_has_position()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::position(this), _Internal::position(this).GetCachedSize(), target, stream); } // .mavsdk.rpc.camera_server.Quaternion attitude_quaternion = 2; if (this->_internal_has_attitude_quaternion()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(2, _Internal::attitude_quaternion(this), _Internal::attitude_quaternion(this).GetCachedSize(), target, stream); } // uint64 time_utc_us = 3; if (this->_internal_time_utc_us() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteUInt64ToArray(3, this->_internal_time_utc_us(), target); } // bool is_success = 4; if (this->_internal_is_success() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteBoolToArray(4, this->_internal_is_success(), target); } // int32 index = 5; if (this->_internal_index() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteInt32ToArray(5, this->_internal_index(), target); } // string file_url = 6; if (!this->_internal_file_url().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_file_url().data(), static_cast<int>(this->_internal_file_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "mavsdk.rpc.camera_server.CaptureInfo.file_url"); target = stream->WriteStringMaybeAliased( 6, this->_internal_file_url(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.CaptureInfo) return target; } size_t CaptureInfo::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.CaptureInfo) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // string file_url = 6; if (!this->_internal_file_url().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_file_url()); } // .mavsdk.rpc.camera_server.Position position = 1; if (this->_internal_has_position()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *position_); } // .mavsdk.rpc.camera_server.Quaternion attitude_quaternion = 2; if (this->_internal_has_attitude_quaternion()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *attitude_quaternion_); } // uint64 time_utc_us = 3; if (this->_internal_time_utc_us() != 0) { total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_time_utc_us()); } // bool is_success = 4; if (this->_internal_is_success() != 0) { total_size += 1 + 1; } // int32 index = 5; if (this->_internal_index() != 0) { total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_index()); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CaptureInfo::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, CaptureInfo::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CaptureInfo::GetClassData() const { return &_class_data_; } void CaptureInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<CaptureInfo *>(to)->MergeFrom( static_cast<const CaptureInfo &>(from)); } void CaptureInfo::MergeFrom(const CaptureInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.CaptureInfo) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_file_url().empty()) { _internal_set_file_url(from._internal_file_url()); } if (from._internal_has_position()) { _internal_mutable_position()->::mavsdk::rpc::camera_server::Position::MergeFrom(from._internal_position()); } if (from._internal_has_attitude_quaternion()) { _internal_mutable_attitude_quaternion()->::mavsdk::rpc::camera_server::Quaternion::MergeFrom(from._internal_attitude_quaternion()); } if (from._internal_time_utc_us() != 0) { _internal_set_time_utc_us(from._internal_time_utc_us()); } if (from._internal_is_success() != 0) { _internal_set_is_success(from._internal_is_success()); } if (from._internal_index() != 0) { _internal_set_index(from._internal_index()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void CaptureInfo::CopyFrom(const CaptureInfo& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.CaptureInfo) if (&from == this) return; Clear(); MergeFrom(from); } bool CaptureInfo::IsInitialized() const { return true; } void CaptureInfo::InternalSwap(CaptureInfo* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &file_url_, lhs_arena, &other->file_url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(CaptureInfo, index_) + sizeof(CaptureInfo::index_) - PROTOBUF_FIELD_OFFSET(CaptureInfo, position_)>( reinterpret_cast<char*>(&position_), reinterpret_cast<char*>(&other->position_)); } ::PROTOBUF_NAMESPACE_ID::Metadata CaptureInfo::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[11]); } // =================================================================== class CameraServerResult::_Internal { public: }; CameraServerResult::CameraServerResult(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); // @@protoc_insertion_point(arena_constructor:mavsdk.rpc.camera_server.CameraServerResult) } CameraServerResult::CameraServerResult(const CameraServerResult& from) : ::PROTOBUF_NAMESPACE_ID::Message() { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); result_str_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING result_str_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_result_str().empty()) { result_str_.Set(from._internal_result_str(), GetArenaForAllocation()); } result_ = from.result_; // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.camera_server.CameraServerResult) } inline void CameraServerResult::SharedCtor() { result_str_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING result_str_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING result_ = 0; } CameraServerResult::~CameraServerResult() { // @@protoc_insertion_point(destructor:mavsdk.rpc.camera_server.CameraServerResult) if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { (void)arena; return; } SharedDtor(); } inline void CameraServerResult::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); result_str_.Destroy(); } void CameraServerResult::SetCachedSize(int size) const { _cached_size_.Set(size); } void CameraServerResult::Clear() { // @@protoc_insertion_point(message_clear_start:mavsdk.rpc.camera_server.CameraServerResult) uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; result_str_.ClearToEmpty(); result_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* CameraServerResult::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .mavsdk.rpc.camera_server.CameraServerResult.Result result = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); _internal_set_result(static_cast<::mavsdk::rpc::camera_server::CameraServerResult_Result>(val)); } else goto handle_unusual; continue; // string result_str = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_result_str(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, "mavsdk.rpc.camera_server.CameraServerResult.result_str")); } else goto handle_unusual; continue; default: goto handle_unusual; } // switch handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto message_done; } ptr = UnknownFieldParse( tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); } // while message_done: return ptr; failure: ptr = nullptr; goto message_done; #undef CHK_ } uint8_t* CameraServerResult::_InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:mavsdk.rpc.camera_server.CameraServerResult) uint32_t cached_has_bits = 0; (void) cached_has_bits; // .mavsdk.rpc.camera_server.CameraServerResult.Result result = 1; if (this->_internal_result() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( 1, this->_internal_result(), target); } // string result_str = 2; if (!this->_internal_result_str().empty()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_result_str().data(), static_cast<int>(this->_internal_result_str().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "mavsdk.rpc.camera_server.CameraServerResult.result_str"); target = stream->WriteStringMaybeAliased( 2, this->_internal_result_str(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:mavsdk.rpc.camera_server.CameraServerResult) return target; } size_t CameraServerResult::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:mavsdk.rpc.camera_server.CameraServerResult) size_t total_size = 0; uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // string result_str = 2; if (!this->_internal_result_str().empty()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_result_str()); } // .mavsdk.rpc.camera_server.CameraServerResult.Result result = 1; if (this->_internal_result() != 0) { total_size += 1 + ::_pbi::WireFormatLite::EnumSize(this->_internal_result()); } return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CameraServerResult::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, CameraServerResult::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CameraServerResult::GetClassData() const { return &_class_data_; } void CameraServerResult::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from) { static_cast<CameraServerResult *>(to)->MergeFrom( static_cast<const CameraServerResult &>(from)); } void CameraServerResult::MergeFrom(const CameraServerResult& from) { // @@protoc_insertion_point(class_specific_merge_from_start:mavsdk.rpc.camera_server.CameraServerResult) GOOGLE_DCHECK_NE(&from, this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_result_str().empty()) { _internal_set_result_str(from._internal_result_str()); } if (from._internal_result() != 0) { _internal_set_result(from._internal_result()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void CameraServerResult::CopyFrom(const CameraServerResult& from) { // @@protoc_insertion_point(class_specific_copy_from_start:mavsdk.rpc.camera_server.CameraServerResult) if (&from == this) return; Clear(); MergeFrom(from); } bool CameraServerResult::IsInitialized() const { return true; } void CameraServerResult::InternalSwap(CameraServerResult* other) { using std::swap; auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &result_str_, lhs_arena, &other->result_str_, rhs_arena ); swap(result_, other->result_); } ::PROTOBUF_NAMESPACE_ID::Metadata CameraServerResult::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_getter, &descriptor_table_camera_5fserver_2fcamera_5fserver_2eproto_once, file_level_metadata_camera_5fserver_2fcamera_5fserver_2eproto[12]); } // @@protoc_insertion_point(namespace_scope) } // namespace camera_server } // namespace rpc } // namespace mavsdk PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::SetInformationRequest* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::SetInformationRequest >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::SetInformationRequest >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::SetInformationResponse* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::SetInformationResponse >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::SetInformationResponse >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::SetInProgressRequest* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::SetInProgressRequest >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::SetInProgressRequest >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::SetInProgressResponse* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::SetInProgressResponse >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::SetInProgressResponse >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::SubscribeTakePhotoRequest* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::SubscribeTakePhotoRequest >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::SubscribeTakePhotoRequest >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::TakePhotoResponse* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::TakePhotoResponse >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::TakePhotoResponse >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::RespondTakePhotoRequest* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::RespondTakePhotoRequest >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::RespondTakePhotoRequest >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::RespondTakePhotoResponse* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::RespondTakePhotoResponse >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::RespondTakePhotoResponse >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::Information* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::Information >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::Information >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::Position* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::Position >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::Position >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::Quaternion* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::Quaternion >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::Quaternion >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::CaptureInfo* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::CaptureInfo >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::CaptureInfo >(arena); } template<> PROTOBUF_NOINLINE ::mavsdk::rpc::camera_server::CameraServerResult* Arena::CreateMaybeMessage< ::mavsdk::rpc::camera_server::CameraServerResult >(Arena* arena) { return Arena::CreateMessageInternal< ::mavsdk::rpc::camera_server::CameraServerResult >(arena); } PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) #include <google/protobuf/port_undef.inc>
40.331405
192
0.744459
hamishwillee
c4c097d367481bfdb40a6fdfc522bb94a6b33db3
13,071
cpp
C++
data/627.cpp
TianyiChen/rdcpp-data
75c6868c876511e3ce143fdc3c08ddd74c7aa4ea
[ "MIT" ]
null
null
null
data/627.cpp
TianyiChen/rdcpp-data
75c6868c876511e3ce143fdc3c08ddd74c7aa4ea
[ "MIT" ]
null
null
null
data/627.cpp
TianyiChen/rdcpp-data
75c6868c876511e3ce143fdc3c08ddd74c7aa4ea
[ "MIT" ]
null
null
null
int AJ,vaBae ,//y38 uvxYkLF , x94ea , u1, u5//D ,JtNU ,/*Q*/ UR , ajM0, Fuz /*bOM*/, A, otxhG,ny ,/*DFb*/wLF /*gk*/,V,Ol ,w2s, Tf ,/**/SI7, Ae4Z ,kw, l1, f,aVQR ,WwiI , md, z3BV8p ,Ko9i//6b ,FBUU9 ,SI2Uo ,//te CMoBR,B3Jr , WKM, GOTsm/**/, Ks2 ,R , //X Bjd ,Tmd /*D*/ , RDy9d , Z2eEw ,pJ7 , ULa3J ,k9d , QKvV , VF5E4N ; void f_f0() {volatile int o9 ,RbZ/*Pmc*/ ,PV, NaMa , bg ;if( true ) if( true ) {{if(true ) {{int ticc, V9 ;volatile int X7r/*I*/,cke , yN ; if( true)V9 = yN + X7r ;else ticc= cke; } }else ; {{ return ; } }/*Af4y*/{ int k5fL ; volatile int m,xO1, sls;if//w ( true/*4f*/ ) if ( true) if//B (true){ }else return ; else ;else ;for/*pa4Y*/ (int i=1; i<1 ;++i ) k5fL= sls/**///8u + m+xO1 ;{ { }}return ;}{//YcjP ; { { /*C*/} { } } { }}} for // (int i=1 ;i<// 2 ;++i//Fw40 ){ volatile int MoZ0 , UT ,Y; if( true ) ;/*FZtK*/ else//vu8c { int LNri; volatile int gZUho , dRH , V6z ;return ; LNri = V6z +gZUho/*w*/ + dRH ; } VF5E4N //BGc = Y + //a8aa MoZ0+ UT ; }for(int i=1;i< 3//j ;++i ) { volatile int xR7E ,nisr ,bGd ,lz , LM5 ;if( true) for (int i=1;i<4;++i) return ; else AJ= LM5+ //qd xR7E +nisr +bGd+lz; { {{ } {{}} { }} return ;};}}else return ;else vaBae = bg + o9 + RbZ + PV + NaMa; {{ return ; return ; } for (int i=1; i< 5 ;++i )return ;/*a*//*VWi*/; {{//Bup //w volatile int uiY6,Sgk , /**/EuPh ,//iA Lm ; { //XRvPV } uvxYkLF = Lm /*tE*/+uiY6+ /*y*/Sgk+ EuPh ;{} for(int i=1 ; i< 6//5k8C ;++i) { ; } }{{ volatile int//i5N ha4/*IF*/, nNh ,s50b ; { }/**/ x94ea =s50b +ha4+ nNh//JL9 ;}for(int i=1 ; i< 7 //j ;++i)return ; } {{ if ( true ){}else{ }{for (int i=1; i< 8 ;++i/*X*/ )//r for(int i=1 ;i< //KhdC 9;++i )return /*Umbrx*/ ;} } }if( true ) { for (int i=1; i<//8ET 10 ;++i)//7J //iU2 ; if ( true ){{ return ;}{ } }else return //cD ; } else { /*cpE*/volatile int NfLMr , j0iC; ;u1 =j0iC + NfLMr ; { }}} }; for (int //gv //blu i=1 ; i<11 ;++i ) { {; {for (int i=1; i<12;++i ){ //Ruy2 { } }for (int i=1//RqE ; i<13 ;++i );{ return ;} }{{} }} return ; return//Dv2 ; { {volatile int fX , VejTz; for(int i=1 ; i< 14 ;++i);return ; { } return ; if(true ) if ( true) { ; } else u5 = VejTz + fX/*1*/ ;else return ;};}}return ; }void f_f1(){ volatile int w3n , rc4 ,QtaQ, A8 ,EwE , r9 ;for /*Q*/(int i=1/*z3*/ ;i<15;++i ) {int eA2m ; volatile int oDETT, Ne, UP ,Vg/*5*/ , Fc,S , Ma0Y ,x3OJc6 ,Gfq0 ; { {{}/*y*/ { }/*GFyS*/{; { } return/**/ ;} for/*eA*/ (int i=1 ;i<16 ;++i)return ; {} } { if (true) { if/*h*//*hiAGz*/(true ) // return ;//ZaF else { {} } } else {}{} { {volatile int nPZ ;{}if (/*f*/ true) ; else JtNU = nPZ ;}}{volatile int HMf,Z,//v jeg; UR =jeg + HMf +Z ;} { } } for(int //no i=1//a ; /*Gk*/ i< 17;++i )return ; { {} } /*8*/} ajM0=//8n7 Gfq0+ oDETT +Ne+ UP+Vg ; for(int i=1 ; i< 18;++i ) {volatile int GY,ZCt//E1 , //JG KGF5 ,SxK ;if ( true ) Fuz =SxK + GY+//9 ZCt+KGF5;else/*asVQ*/ {; for(int i=1;i<19 ;++i ) { {}{{ } if (true) {}else{}}} }if (true ) for(int i=1; i<20/*48v*/ ;++i )/*s*/for (int i=1;i< //q 21;++i ) if ( true ) return ;else{ int I47 , KS ; // volatile int O ,Xh, kodB , GooBuNt ;KS = GooBuNt+ O; I47 //W = Xh//EfzL /*2uba*/+ kodB ;{ { } { { }{ volatile int urt;for(int i=1 ; /*ELO0*/i< 22 ;++i) A =urt ;//gQsh7 } }return ;} } else{int MG/*fUs*/; volatile int byApK , vg4mD,Gjzp , VVX ;for (int i=1; i<23;++i ){/*KY*/{ } }MG =VVX+ byApK+vg4mD+/*70*/ Gjzp ;return /*2DJ*/ ;} }{ for//aw (int i=1 ; i<24 ;++i) return ; for//a08E (int i=1 ;i< 25 ;++i ) { for (int i=1;i<26;++i)// { {} }}} {//07Z ;; return ;} eA2m = Fc + S +Ma0Y +x3OJc6 ; } { volatile int //H gI4, Paukv, l/*p*/, /*kuD*/T, Ki ;/*Q*/ return ;otxhG = Ki +gI4//NWo + Paukv +l +T ; return ; { volatile int T5D , FTS,/*ZziVK*/PEJ ; ny = PEJ+ /*iZ1H*/ T5D//gyU +FTS ; ;{{ int gH3//SR ;//8 volatile int HxQH, //vd fn , TckB ; gH3= TckB/*os*/ + //0 HxQH+fn; for(int i=1;i< // 27 ;++i ) return ;{ }}; { for(int i=1;i< 28 ;++i ) { } }{int UY;volatile int Aw,in//Mn ;//TUF { //7rW /*x*/} for (int i=1 ;i</*Enw*/29;++i)UY= in+ Aw ;} } }{ volatile int ubOEWn,X, v33l, Gn ; wLF = Gn+ ubOEWn + X +v33l;;{ //c {}{ }; ;} } } { volatile int LgNjUb ,iJz, v/*1p*/,z ; { ;return ; { { return ;} {;} { //k } }} { volatile int/*zc*/ cn//dcdo , /*N1m*/Ck ,Y91A, HVF; {{ volatile int FiZh; V= FiZh;//XfS }} for(int i=1; i< 30 ;++i) Ol /*G*/ =HVF+ cn //GzzF +//lk Ck + Y91A;{ int Tw; volatile int Knp , f3h//T5u ,SaO, Vf , AJr ,/**/RD6// ; {} Tw= RD6 + Knp /*gvP*/+f3h;{; } w2s=SaO + Vf +AJr//G ;} for(int i=1; i< 31;++i);} {{ {/*Fd*/ {}}}return ; }Tf =z+ LgNjUb +iJz+ v ; {{ for (int i=1 ; i<32//2N ;++i ) for/*Q*/(int i=1 ;i< 33 ;++i){ ;} } {volatile int Rv, rdV3,Q0U; SI7 =Q0U + Rv +rdV3 ;{ } } { return ; return ; { { } ;return ;/*uD*/{ }}} {{ }{/*5F*/{ { } /*niC*/}} }} { {/*7vy*/;} {/**/for(int i=1 ;i<34 ;++i) ; } for(int i=1 ;i< /*b7g35*/35;++i){{ int zkjR ;volatile int YF, HVN2O2z;zkjR // = HVN2O2z +YF; for (int i=1 ;i<36;++i) {}for (int i=1 ;/*T*/ i< 37;++i ) { }{ }}for(int /*vd*/ i=1 ; i<38;++i)if(true ) return/*VY*/ ;else ; { }} }} {{ { {{}} //GoKfwy ; { }}for(int i=1 ; //AWK6 /**/i< 39 ;++i )if( true ) { { }//Acp } else ; } { {{; {} } } for(int i=1 ; i<40 ;++i) {int Q8WA ;volatile int/*Stv*/ M0wk0, gz,FLnW/*Vf*/, z9K,/*qs*/ o5Tme/*uW4*/ , YZ ; /*E*/Ae4Z= YZ+//yVp M0wk0 + gz ; if ( true ) ; // else for(int i=1 ; i<41;++i ) {} Q8WA=FLnW +z9K + /*T*/ o5Tme; } }for (int i=1; i<42 ;++i) {{ return ;/*Kg*/ }{int QF3jR ;volatile int ce62, hD8S ; {} for//ZVcof (int i=1 ;i<43 ;++i) ;QF3jR =hD8S +ce62 ;}}if ( true) {for (int i=1; i< 44 ;++i ) //t ; {{}/*hv*/ { {;{} return ; }} } } else if(true) { //7 volatile int/*loF*/ Nr , B99lL, m0qN , gk; { { for/*JFK*//*vSCh*/ (int i=1; i<45;++i){//KtP //0 }} { } }if(true ){ //S7Jw for (int i=1//e8 ;i< 46 ;++i) {volatile int/*71*/ MJWY , Yh8L ,// eJe;if ( true) /*Wx*/ { }/*k*/else ;kw= eJe + MJWY+Yh8L ; } {for(int i=1 ; i< 47;++i ) if (true )/*s*/ if ( true) return ;else{ for(int i=1 ;i<48 //SA ;++i)/*j*/ { } } else {}{{}} }/**/} else l1 =gk +//X Nr+ B99lL+ m0qN ;{ /*M*/if/**/ ( true ){int Q7sa; volatile int/**/ e5,XojCf ; { } if( true)Q7sa= XojCf + e5 ; else for(int i=1;i<49 ;++i ) return ; } else for(int i=1 ; i<50;++i) { }}} else { volatile int l0k,zaQZ,jqbHg2;//W5s {if ( true ); else if (true){ }else {{ }/*Hc*/} //M {{{ } } }} for//8aYZ (int /*gY*/i=1; i< 51 ;++i ) f/**/= jqbHg2+ l0k+zaQZ/*8j*/ ; for(int i=1;i< 52 //Bh ;++i){{{ } } if ( true )for (int i=1; i< 53 ;++i/*z*/ ) {//uOp /*u*/{}}else {volatile int BGbu , Waeb;aVQR = Waeb +BGbu ; } {// { } } } }} WwiI = r9+w3n+ rc4 + QtaQ + A8+ EwE; return ; return ; }void f_f2(){volatile int lo ,fkF , rMz, OQt,nSgRK8 ; md= nSgRK8 + lo//MUy + fkF + rMz +OQt ; { ; {{for (int i=1 ; i< 54;++i ) { if (true //4l ) {} else /*1L1*/ return ; return ; return ;} }{;{; {} if(/*B*/true ){volatile int wdi, PPg ; return ; z3BV8p = //E PPg/*Q9d*/+/*m29*/ wdi ;} else //I {} } }return ; /*i*/ return ;}for(int i=1;i< 55;++i) {volatile int//8f pud,iWfNS, khP/*b2I*/, sPu05Wo ; {; ; {{ }for(int i=1;i<56 ;++i) {/*m*/} {}{{ } ;} }} return ;for (int /*k*/i=1 ;i< 57 //sfl ;++i ){volatile int b7 ,O0nEm,ILPJU; { int B0 ;volatile int /**/ hUlV, L , lP3zc; B0= lP3zc+ hUlV +L ; return ; }Ko9i= /*8o*/ILPJU +b7+O0nEm ; ;{}} { int sKOZ ;volatile int CqsXp , GReG,b ;sKOZ = b + CqsXp+GReG ;{ return ;} } /**/ FBUU9 = sPu05Wo /*So*/+ pud +iWfNS +khP;} if(true)/*9p8*//*T*/{ { int pRS; volatile int h4 ,G2 ;pRS//3 = G2 + h4 /*MM6*/ ; return ; } if(true)return ; /*A*/else if(true) {{for //Z (int i=1 ;i< //l8BZ 58;++i) { } }for (int i=1 ; i<59;++i ) { } }else for (int i=1 ; i< 60;++i ){{ { } } {/*UU*/volatile int F31 ;SI2Uo =F31;}} } else return ; } { if//44jbl8y ( /*YlE*/true) { for(int i=1 ;i< 61 ;++i/*EE6*/) { { {volatile int uq, V6; for (int /**/i=1 ; i< 62;++i ) { for (int i=1 ; i<63;++i) return ; }CMoBR //o = V6 +uq;}}{ { //dh }} { { return ; { } ;}} } { int ey ;volatile int gN , tpIMK//XeC , cQ3I, OGU ; ey =OGU + gN + tpIMK + cQ3I ; return ;}/*EL*/{{ for/*rEV*/ (int // i=1 ;i<64/*Yysn*/;++i) ;/*C2i*/}{ for (int i=1; i< 65 ;++i ) { }/*HPf*/} for (int i=1//a ; i</*Z*/ 66;++i ) { }{ int S6M9 ;volatile int au /**/ , s ;{ } if ( true ) S6M9 = s+ au ;else {}}}{for//kHl (int i=1 ; i<67 ;++i) { if( true ) ;else{} }}}else{{ int SVN7; volatile int MFz , hS3J ,RS2 ; if( /*xVAU*/true ){ }else if(true){{ { if( true ) { }else/*Vy*/ if( true ) return ;//G else{} } //kz } } else ;SVN7 =// RS2 + MFz +hS3J; }//cK { if( true ){ /*mr1*/int GafAJ; volatile int kZ,Fihkt, e3rU ,Q; GafAJ=Q+kZ+Fihkt//RJ +e3rU ; }else for(int i=1 ; i< 68;++i) {/*FCE*/volatile int FU7B ,BcB , F1Zq ;B3Jr=F1Zq +FU7B /*ei*/+ BcB /*h*/; }//jGy {;} { {}//ty } /*lX3*/}} return ;{ if// (true ) ; else{ return ;} //32 if(true){ {} { { /*tg6D*/ } //c /*xj4m*/if (true ) if ( true )return ; else{} else {}} } else ;{ if (true//vs1Q ) return ;else{ { } }}} } ;return ; } int//m main (){ volatile int XSj,//i g, //V NtL//Ujb ,ph , yl ; { {/*cBMQ*/int XnvYZ ; volatile int z5bB,UU, q,//MDN qp , jiw, Gb ,sF ; {{ { }// } //R //m { if ( true ) ; //gM /*qm*/else{//xGn }/*zs*/{int ik;volatile int e;{ } ik = e; }}//W return 930134187 // ; }{ volatile int kb78P , ZVNKO /**/; if ( true) //5 WKM = ZVNKO+ kb78P//GkqYBn ;else/*4l*/ return 478038699;}//pJ GOTsm= sF +z5bB+UU +q ;if// (true) /*jbc*/XnvYZ/*LCKh*/=qp +jiw+ Gb ;else{volatile int Zj , KGszh,Mz, Xe ;{} { } Ks2/*tP*/=Xe +Zj +KGszh+// Mz ;} }{/**/ for (int i=1 ;i< 69;++i//vPV ){ volatile int MJ6 , kO1xn6 ; {volatile int m7mS4//fvZ , A2; for (int i=1 ;i< 70 ;++i){{}for(int i=1//3D ; i< 71//VH ;++i ) return 46971695 ;} if ( true ) { ; } else if( true ) R/*Q48d*/ /*5TwJ2*/ = A2 + m7mS4; else/*a*/{ } {{} } } Bjd/**/=kO1xn6 +MJ6; return 1482348458;}for(int i=1 ;i<72;++i) {//t int Aca ; volatile int FN2i,Pii8 , Li0DW ,G5 ; { { int p;/*Ic*/volatile int lu1,gPe , BNJ4;return 293325026 ;if (true )p =/*P*/ BNJ4 ;else if ( true) for (int i=1;i< 73 ;++i ){ }else Tmd/*G8g*/= lu1 + gPe ; } } Aca =G5+ FN2i +Pii8+ Li0DW ;} if(true ){{ { if( true);else {} { } } }} else if ( true ){//xPIo if( true) return/*IT*/ 1538199053; else { {{{}} }} { } } else { { }/*g7*/}}for (int i=1;i<74;++i ) { if/**/( true) { int aB ;volatile int mN3 ,GLt; aB=GLt +mN3 ;}else if (true )if (true ) {volatile int N10 ,/*YK*/ wU0d , n2Q , NMIB ; RDy9d=NMIB +N10 +wU0d+ n2Q;{ { //4 { }{} if(true ) {} else ; } } ; }else {for(int //DXj i=1 ; i<75;++i ) {/*9b8*/return 2095662402 ; if(true )if ( true )// ;else return 1018612394 ; else for (int //z i=1 ;i<76 ;++i ) { { }}}} else //v return 1774500152 ; {//yZQ /*rd*/;}return 785199703 ;}/*TBA*/} ;{ int iJu ; volatile int Rid28a, dD ,lawf, jwO8Pc; { int hz;/*C*/ volatile int jp ,//jTa o,XoF, lY /**/; hz=lY+ jp +o +XoF; {{ } { }for (int i=1; i<77 ;++i) { ; { int sf5w,Pvekk67 ; volatile int MBU2 ,// IDI, hvM; for(int i=1;i< 78;++i//9Q )Pvekk67 =hvM ; sf5w = //lg //k MBU2+ IDI;; } if( true) if ( true)return //DF 1232281831 ; else for(int i=1 //k ;i<79 ;++i/*QAGq*/ ) { }else {}//tKU } } } //N { int G ; volatile int Niedt, tDAb , pba;return 92264665 //u2 ; if (true) { for(int i=1 ; i< 80 ;++i/*oA*/){volatile int lO0p ; Z2eEw =lO0p; }} else G =pba+Niedt+tDAb ; ;//c /*fg*/}if( true )if( true )for (int i=1//L ; i</*btyamH*/ 81;++i)/*Z3M*/ { {{ { }{ {}return 327558265 ; } ;/**/ } }return 1572568547;} else iJu = jwO8Pc + Rid28a+ dD +lawf ;else for (int i=1 ; i< 82 //U ;++i ){return 159735872//vag //ep ; ;} return 551747984 ; { { { { } ;{;} {} }if( //mD true); else { // { }/*2oG*/}{ return 1790378835; { ; }}} {for (int i=1; i< 83;++i){ } } { for(int /*5*/ /*dO*/i=1 ;i<84 ;++i ){ } if( true/*C4N*/ ) { { } ;{ } } else{ {/*qopE*/ }{ }// } }{/*p8Uk*/ for(int i=1 ; i<85 ;++i )/*09q*/;//n1FN } {//TRf volatile int lBG , Cq , cmPES ; for (int i=1 ;// i< 86 ;++i //zhb )pJ7 = cmPES + lBG + /*Z*/ Cq; }if (true ) {//e9fY1H ;} else //sz { { {} }}// } } ULa3J = yl +XSj +g+ NtL + ph;{volatile int kl, IBy6,lD2u6QI,RsfHt ,KQ,VT ,//T Qb, SCY ; /*KZ*//*IObjc*/k9d/*1*/=SCY+ kl + /*7T6*/IBy6+ lD2u6QI; QKvV= RsfHt+KQ + VT + Qb/**/ ; ;/*6*/} }
11.366087
66
0.461633
TianyiChen
c4c3479200066b5e42319d90e068c50b6b0cf80d
14,588
cpp
C++
libs/fnd/cctype/test/src/unit_test_fnd_cctype_isgraph.cpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
4
2018-06-10T13:35:32.000Z
2021-06-03T14:27:41.000Z
libs/fnd/cctype/test/src/unit_test_fnd_cctype_isgraph.cpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
566
2017-01-31T05:36:09.000Z
2022-02-09T05:04:37.000Z
libs/fnd/cctype/test/src/unit_test_fnd_cctype_isgraph.cpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
1
2018-07-05T04:40:53.000Z
2018-07-05T04:40:53.000Z
/** * @file unit_test_fnd_cctype_isgraph.cpp * * @brief isgraph のテスト * * @author myoukaku */ #include <bksge/fnd/cctype/isgraph.hpp> #include <bksge/fnd/config.hpp> #include <gtest/gtest.h> #include "constexpr_test.hpp" namespace bksge_cctype_test { namespace isgraph_test { GTEST_TEST(CCTypeTest, IsGraphTest) { BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x00)); // control codes (NUL, etc.) BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x08)); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x09)); // tab (\t) BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x0A)); // whitespaces (\n, \v, \f, \r) BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x0D)); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x0E)); // control codes BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x1F)); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x20)); // space BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x21)); // !"#$%&'()*+,-./ BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x2F)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x30)); // 0123456789 BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x39)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x3A)); // :;<=>?@ BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x40)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x41)); // ABCDEF BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x46)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x47)); // GHIJKLMNOPQRSTUVWXYZ BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x5A)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x5B)); // [\]^_` BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x60)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x61)); // abcdef BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x66)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x67)); // ghijklmnopqrstuvwxyz BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x7A)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x7B)); // {|}~ BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(0x7E)); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(0x7F)); // backspace character (DEL) BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(EOF)); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(WEOF)); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('0')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('1')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('2')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('3')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('4')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('5')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('6')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('7')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('8')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('9')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('A')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('B')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('C')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('D')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('E')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('F')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('G')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('H')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('I')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('J')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('K')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('L')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('M')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('N')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('O')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('P')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('Q')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('R')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('S')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('T')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('U')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('V')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('W')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('X')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('Y')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('Z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('a')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('b')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('c')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('d')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('e')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('f')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('g')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('h')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('i')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('j')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('k')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('l')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('m')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('n')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('o')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('p')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('q')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('r')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('s')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('t')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('u')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('v')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('w')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('x')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('y')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('!')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('"')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('#')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('$')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('%')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('&')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('\'')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('(')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(')')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('*')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('+')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(',')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('-')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('.')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('/')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(':')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(';')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('<')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('=')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('>')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('?')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('@')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('[')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('\\')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(']')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('^')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('_')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('`')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('{')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('|')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('}')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph('~')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(' ')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph('\f')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph('\n')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph('\r')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph('\t')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph('\v')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'0')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'1')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'2')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'3')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'4')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'5')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'6')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'7')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'8')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'9')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'A')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'B')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'C')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'D')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'E')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'F')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'G')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'H')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'I')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'J')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'K')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'L')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'M')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'N')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'O')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'P')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'Q')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'R')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'S')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'T')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'U')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'V')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'W')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'X')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'Y')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'Z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'a')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'b')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'c')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'd')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'e')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'f')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'g')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'h')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'i')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'j')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'k')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'l')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'm')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'n')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'o')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'p')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'q')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'r')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L's')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L't')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'u')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'v')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'w')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'x')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'y')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'!')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'"')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'#')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'$')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'%')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'&')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'\'')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'(')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L')')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'*')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'+')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L',')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'-')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'.')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'/')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L':')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L';')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'<')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'=')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'>')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'?')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'@')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'[')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'\\')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L']')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'^')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'_')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'`')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'{')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'|')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'}')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(L'~')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(L' ')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(L'\f')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(L'\n')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(L'\r')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(L'\t')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(L'\v')); #if defined(BKSGE_HAS_CXX20_CHAR8_T) BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u8'0')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u8'9')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u8'A')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u8'Z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u8'a')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u8'z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u8'!')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(u8' ')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(u8'\n')); #endif #if defined(BKSGE_HAS_CXX11_CHAR16_T) BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u'0')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u'9')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u'A')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u'Z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u'a')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u'z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(u'!')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(u' ')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(u'\n')); #endif #if defined(BKSGE_HAS_CXX11_CHAR32_T) BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(U'0')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(U'9')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(U'A')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(U'Z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(U'a')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(U'z')); BKSGE_CONSTEXPR_EXPECT_TRUE (bksge::isgraph(U'!')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(U' ')); BKSGE_CONSTEXPR_EXPECT_FALSE(bksge::isgraph(U'\n')); #endif } } // namespace isgraph_test } // namespace bksge_cctype_test
48.304636
85
0.751234
myoukaku
c4c386ed6ec04217de9acf9177b5619084e84b1f
1,612
cpp
C++
BOJ_solve/16583.cpp
python-programmer1512/Code_of_gunwookim
e72e6724fb9ee6ccf2e1064583956fa954ba0282
[ "MIT" ]
4
2021-01-27T11:51:30.000Z
2021-01-30T17:02:55.000Z
BOJ_solve/16583.cpp
python-programmer1512/Code_of_gunwookim
e72e6724fb9ee6ccf2e1064583956fa954ba0282
[ "MIT" ]
null
null
null
BOJ_solve/16583.cpp
python-programmer1512/Code_of_gunwookim
e72e6724fb9ee6ccf2e1064583956fa954ba0282
[ "MIT" ]
5
2021-01-27T11:46:12.000Z
2021-05-06T05:37:47.000Z
#include <bits/stdc++.h> #define x first #define y second #define pb push_back #define all(v) v.begin(),v.end() #pragma gcc optimize("O3") #pragma gcc optimize("Ofast") #pragma gcc optimize("unroll-loops") using namespace std; const int INF = 1e9; const int TMX = 1 << 18; const long long llINF = 5e18; const long long mod = 1e9+7; const long long hmod1 = 1e9+409; const long long hmod2 = 1e9+433; const long long base = 257; typedef long long ll; typedef long double ld; typedef pair <int,int> pi; typedef pair <ll,ll> pl; typedef vector <int> vec; typedef vector <pi> vecpi; typedef long long ll; int n,m,c[200005]; int p[200005],o[200005],g; vec v[200005]; struct Ans {int x,y,z;}; vector <Ans> ans; int Find(int x) {return (p[x]^x ? p[x] = Find(p[x]) : x);} int dfs(int x,int pr) { int st = 0; c[x] = 1; for(int i : v[x]) { if(i == pr) continue; int tmp = dfs(i,x); if(tmp) { if(st) ans.pb({o[st],o[x],o[i]}), st = 0; else st = i; } } if(st&&pr != -1) { ans.pb({o[st],o[x],o[pr]}); return 0; } return 1; } int main() { ios_base::sync_with_stdio(false), cin.tie(0); cin >> n >> m; g = n; for(int i = 1;i <= n;i++) p[i] = o[i] = i; for(int i = 1;i <= m;i++) { int x,y; cin >> x >> y; if(Find(x)^Find(y)) v[x].pb(y), v[y].pb(x), p[Find(y)] = Find(x); else v[x].pb(++g), v[g].pb(x), o[g] = y; } for(int i = 1;i <= g;i++) { if(!c[i]) dfs(i,-1); } cout << ans.size() << '\n'; for(Ans i : ans) cout << i.x << ' ' << i.y << ' ' << i.z << '\n'; }
24.424242
73
0.519231
python-programmer1512
c4c42acc715932ef9b303cad4b0597f08c75f643
1,142
cpp
C++
Stack/Stack_01_IMPLEMENT_USING_ARRAY.cpp
compl3xX/ROAD-TO-DSA
2261c112135a51d9d88c4b57e6f062f6b32550a7
[ "MIT" ]
null
null
null
Stack/Stack_01_IMPLEMENT_USING_ARRAY.cpp
compl3xX/ROAD-TO-DSA
2261c112135a51d9d88c4b57e6f062f6b32550a7
[ "MIT" ]
null
null
null
Stack/Stack_01_IMPLEMENT_USING_ARRAY.cpp
compl3xX/ROAD-TO-DSA
2261c112135a51d9d88c4b57e6f062f6b32550a7
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; #define MAX 1000 class Stack { int top; public: int a[MAX]; Stack() { top = -1; } void push(int x); int pop(); int peek(); bool isempty(); }; void Stack::push(int x) { if (top >= (MAX - 1)) { cout << "Stack Overflow"; } else { a[++top] = x; cout << x << "Pushed into Stack\n"; } } int Stack::pop() { if (top < 0) { cout << "Stack is Empty"; return 0; } else { int x = a[top--]; return x; } } int Stack::peek() { if (top < 0) { cout << "Stack is Empty"; return 0; } else { int x = a[top]; return x; } } bool Stack::isempty() { return (top < 0); } int main() { class Stack s; s.push(10); s.push(20); s.push(30); cout << s.pop() << " Popped from the stack\n "; cout << "Elements present in the stack "; while (!s.isempty()) { cout << s.peek() << " "; s.pop(); } return 0; }
15.226667
52
0.408056
compl3xX
c4c4e01696c18cdeaa7407ac894763a2ce5802da
3,552
hpp
C++
apps/Cocles/old_src/ledger/internal/Database.hpp
tybl/tybl
cc74416d3d982177d46b89c0ca44f3a8e1cf00d6
[ "Unlicense" ]
1
2022-02-11T21:25:53.000Z
2022-02-11T21:25:53.000Z
apps/Cocles/old_src/ledger/internal/Database.hpp
tybl/tybl
cc74416d3d982177d46b89c0ca44f3a8e1cf00d6
[ "Unlicense" ]
15
2021-08-21T13:41:29.000Z
2022-03-08T14:13:43.000Z
apps/Cocles/old_src/ledger/internal/Database.hpp
tybl/tybl
cc74416d3d982177d46b89c0ca44f3a8e1cf00d6
[ "Unlicense" ]
null
null
null
// License: The Unlicense (https://unlicense.org) #ifndef COCLES_LEDGER_INTERNAL_DATABASE_HPP #define COCLES_LEDGER_INTERNAL_DATABASE_HPP #include "AccountEntry.hpp" #include "AccountTypeEntry.hpp" #include "AdjustmentEntry.hpp" #include "FilteredTableView.hpp" #include "RecordKeeper.hpp" #include "TransactionEntry.hpp" template <typename TYPE> struct TableView; struct Database { Database(); // Methods for querying AccountTypes TableView<AccountType> get_account_type_table() const; const std::string& get_name(AccountTypeEntry record) const; AccountTypeEntry find_account_type_by_name(const std::string& name) const; // Methods for interacting with Accounts TableView<Account> get_account_table() const; AccountEntry new_account(); AccountEntry new_account(const std::string& name, AccountTypeEntry type); void clear_account_table(); void delete_account(AccountEntry record); const std::string& get_name(AccountEntry record) const; void set_name(AccountEntry record, const std::string& name); AccountEntry find_account_by_name(const std::string& name) const; AccountTypeEntry get_type(AccountEntry record) const; void set_type(AccountEntry record, AccountTypeEntry type); // TODO(tybl): find_account_by_type should be able to return many AccountEntrys FilteredTableView<Account> find_account_by_type(AccountTypeEntry type) const; // Methods for interacting with Transactions TableView<Transaction> get_transaction_table() const; TransactionEntry new_transaction(); TransactionEntry new_transaction(const date::year_month_day& date, const std::string& memo); void clear_transaction_table(); void delete_transaction(TransactionEntry record); const date::year_month_day get_date(TransactionEntry record) const; void set_date(TransactionEntry record, const date::year_month_day& date); // TODO(tybl): find_transaction_by_date should be able to return many TransactionEntrys FilteredTableView<Transaction> find_transaction_by_date(const date::year_month_day& date) const; const std::string& get_memo(TransactionEntry record) const; void set_memo(TransactionEntry record, const std::string& memo); TransactionEntry find_transaction_by_memo(const std::string& memo) const; // Methods for interacting with Adjustments TableView<Adjustment> get_adjustment_table() const; AdjustmentEntry new_adjustment(); AdjustmentEntry new_adjustment(AccountEntry account, TransactionEntry transaction); void clear_adjustment_table(); void delete_adjustment(AdjustmentEntry record); AccountEntry get_account(AdjustmentEntry record) const; void set_account(AdjustmentEntry record, AccountEntry account); // TODO(tybl): find_adjustment_by_account shoule be able to return many AdjustmentEntrys AdjustmentEntry find_adjustment_by_account(AccountEntry account) const; TransactionEntry get_transaction(AdjustmentEntry record) const; void set_transaction(AdjustmentEntry record, TransactionEntry transaction); // TODO(tybl): find_adjustment_by_transaction should be able to return many AdjustmentEntrys AdjustmentEntry find_adjustment_by_transaction(TransactionEntry transaction) const; private: ledger::internal::RecordKeeper<Account> account_table; ledger::internal::RecordKeeper<AccountType> account_type_table; ledger::internal::RecordKeeper<Adjustment> adjustment_table; ledger::internal::RecordKeeper<Transaction> transaction_table; }; #endif // COCLES_LEDGER_INTERNAL_DATABASE_HPP
33.509434
99
0.798142
tybl
c4c5967a1fdc234c240577ee2dc274dfb50c5df2
9,922
cpp
C++
OcularCore/src/Scene/Routines/FreeFlyController.cpp
ssell/OcularEngine
c80cc4fcdb7dd7ce48d3af330bd33d05312076b1
[ "Apache-2.0" ]
8
2017-01-27T01:06:06.000Z
2020-11-05T20:23:19.000Z
OcularCore/src/Scene/Routines/FreeFlyController.cpp
ssell/OcularEngine
c80cc4fcdb7dd7ce48d3af330bd33d05312076b1
[ "Apache-2.0" ]
39
2016-06-03T02:00:36.000Z
2017-03-19T17:47:39.000Z
OcularCore/src/Scene/Routines/FreeFlyController.cpp
ssell/OcularEngine
c80cc4fcdb7dd7ce48d3af330bd33d05312076b1
[ "Apache-2.0" ]
4
2019-05-22T09:13:36.000Z
2020-12-01T03:17:45.000Z
/** * Copyright 2014-2017 Steven T Sell ([email protected]) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "Scene/Routines/FreeFlyController.hpp" #include "Scene/SceneObject.hpp" #include "Events/Events/KeyboardInputEvent.hpp" #include "Math/Matrix3x3.hpp" #include "OcularEngine.hpp" OCULAR_REGISTER_ROUTINE(Ocular::Core::FreeFlyController, "FreeFlyController") namespace { const float StaticSensitivityScale = 0.001f; ///< Default scaling applied to mouse looking, as even a sensitivity of 1.0 is extremely high. } //------------------------------------------------------------------------------------------ namespace Ocular { namespace Core { //---------------------------------------------------------------------------------- // CONSTRUCTORS //---------------------------------------------------------------------------------- FreeFlyController::FreeFlyController() : ARoutine("FreeFlyController", "FreeFlyController"), m_LookSensitivity(1.0f), m_MovementSpeed(1.0f), m_BurstModifier(5.0f), m_PreventRoll(true), m_IsInBurst(false) { OcularEvents->registerListener(this, Priority::Medium); OCULAR_EXPOSE(m_LookSensitivity); OCULAR_EXPOSE(m_MovementSpeed); OCULAR_EXPOSE(m_BurstModifier); OCULAR_EXPOSE(m_BurstModifier); OCULAR_EXPOSE(m_IsInBurst); } FreeFlyController::~FreeFlyController() { OcularEvents->unregisterListener(this); } //---------------------------------------------------------------------------------- // PUBLIC METHODS //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Inherited Methods //---------------------------------------------------------------------------------- void FreeFlyController::onUpdate(float const delta) { ARoutine::onUpdate(delta); if(m_Parent) { handleMovement(delta); handleMouseRotation(); } } bool FreeFlyController::onEvent(std::shared_ptr<AEvent> event) { if(event->isType<KeyboardInputEvent>()) { KeyboardInputEvent* inputEvent = dynamic_cast<KeyboardInputEvent*>(event.get()); switch(inputEvent->key) { case KeyboardKeys::W: case KeyboardKeys::UpArrow: { if(inputEvent->state == KeyState::Pressed) { m_MovementVector.z = -1.0f; } else { m_MovementVector.z = 0.0f; } break; } case KeyboardKeys::A: case KeyboardKeys::LeftArrow: { if(inputEvent->state == KeyState::Pressed) { m_MovementVector.x = -1.0f; } else { m_MovementVector.x = 0.0f; } break; } case KeyboardKeys::S: case KeyboardKeys::DownArrow: { if(inputEvent->state == KeyState::Pressed) { m_MovementVector.z = 1.0f; } else { m_MovementVector.z = 0.0f; } break; } case KeyboardKeys::D: case KeyboardKeys::RightArrow: { if(inputEvent->state == KeyState::Pressed) { m_MovementVector.x = 1.0f; } else { m_MovementVector.x = 0.0f; } break; } case KeyboardKeys::Q: { if(inputEvent->state == KeyState::Pressed) { m_MovementVector.y = 1.0f; } else { m_MovementVector.y = 0.0f; } break; } case KeyboardKeys::Z: { if(inputEvent->state == KeyState::Pressed) { m_MovementVector.y = -1.0f; } else { m_MovementVector.y = 0.0f; } break; } case KeyboardKeys::ShiftLeft: { if(inputEvent->state == KeyState::Pressed) { m_IsInBurst = true; } else { m_IsInBurst = false; } break; } case KeyboardKeys::Space: { if(inputEvent->state == KeyState::Released) { if(m_Parent) { m_Euler.x = 0.0f; m_Euler.y = 0.0f; m_Parent->resetRotation(); } } break; } default: break; } } return true; } //---------------------------------------------------------------------------------- // Controller Specific Methods //---------------------------------------------------------------------------------- void FreeFlyController::setLookSensitivity(float sensitivity) { m_LookSensitivity = sensitivity; } float FreeFlyController::getLookSensitivity() const { return m_LookSensitivity; } void FreeFlyController::setMovementSpeed(float speed) { m_MovementSpeed = speed; } float FreeFlyController::getMovementSpeed() const { return m_MovementSpeed; } void FreeFlyController::setBurstSpeedModifier(float modifier) { m_BurstModifier = modifier; } float FreeFlyController::getBurstSpeedModifier() const { return m_BurstModifier; } void FreeFlyController::setPreventRoll(bool prevent) { m_PreventRoll = prevent; } bool FreeFlyController::getPreventRoll() const { return m_PreventRoll; } //---------------------------------------------------------------------------------- // PROTECTED METHODS //---------------------------------------------------------------------------------- void FreeFlyController::handleMovement(float delta) { float speed = m_MovementSpeed; if(m_IsInBurst) { speed *= m_BurstModifier; } m_Parent->translate(m_MovementVector * speed * delta); } void FreeFlyController::handleMouseRotation() { const Math::Vector2i currentMousePos = OcularInput->getMousePosition(); if(currentMousePos != m_LastMousePos) { const float dX = (static_cast<float>(currentMousePos.x) - static_cast<float>(m_LastMousePos.x)) * (StaticSensitivityScale * m_LookSensitivity); const float dY = (static_cast<float>(currentMousePos.y) - static_cast<float>(m_LastMousePos.y)) * (StaticSensitivityScale * m_LookSensitivity); if(m_PreventRoll) { m_Euler.x += -dY; m_Euler.y += -dX; m_Parent->setRotation(Math::Quaternion(m_Euler)); } else { Math::Quaternion rotation = Math::Quaternion(Math::Vector3f(-dX, dY, 0.0f)); m_Parent->rotate(rotation); Math::Quaternion rotX = Math::Quaternion(Math::Vector3f(-dX, 0.0f, 0.0f)); Math::Quaternion rotY = Math::Quaternion(Math::Vector3f(0.0f, dY, 0.0f)); m_Parent->rotate(rotY); m_Parent->rotate(rotX); } m_LastMousePos = currentMousePos; } } //---------------------------------------------------------------------------------- // PRIVATE METHODS //---------------------------------------------------------------------------------- } }
31.398734
159
0.395586
ssell
c4cc1dc3cdae8ced08454b7bd6976ab3a3f096e7
809
cpp
C++
Documents/RacimoAire/Libreria/Prueba3PMS/mainwindow.cpp
JoseSalamancaCoy/RACIMO_AIRE
628d6ff184a30af0efd25bff675b0006500d4ba2
[ "MIT" ]
null
null
null
Documents/RacimoAire/Libreria/Prueba3PMS/mainwindow.cpp
JoseSalamancaCoy/RACIMO_AIRE
628d6ff184a30af0efd25bff675b0006500d4ba2
[ "MIT" ]
null
null
null
Documents/RacimoAire/Libreria/Prueba3PMS/mainwindow.cpp
JoseSalamancaCoy/RACIMO_AIRE
628d6ff184a30af0efd25bff675b0006500d4ba2
[ "MIT" ]
null
null
null
#include "mainwindow.h" #include "ui_mainwindow.h" #define GPIOSet 16 #define GPIOReSet 12 #define GPIORX 26 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); GPIO = new Crpigpio; PMSSensor = new PMS(GPIO,GPIOSet, GPIOReSet, GPIORX); connect(PMSSensor, SIGNAL(newData(uint16_t,uint16_t,uint16_t)),this, SLOT(newDataPMS(uint16_t,uint16_t,uint16_t))); } MainWindow::~MainWindow() { PMSSensor->sleep(); delete PMSSensor; delete GPIO, delete ui; } void MainWindow::newDataPMS(uint16_t PM_1_0, uint16_t PM_2_5, uint16_t PM_10) { QString comando= "clear"; system(qPrintable(comando)); qDebug() << "Data PM1 ="<< PM_1_0; qDebug() << "Data PM2.5 ="<< PM_2_5; qDebug() << "Data PM10 ="<< PM_10; }
23.794118
119
0.677379
JoseSalamancaCoy
c4d46b3df02f299b3d31c1640d207587e516ceb8
6,094
cpp
C++
examples/imgui/main.cpp
jayrulez/LLGI
a0836e6db18e444d4534deb8eedb18263439fc4c
[ "Zlib" ]
166
2019-06-19T19:51:45.000Z
2022-03-24T13:03:29.000Z
examples/imgui/main.cpp
jayrulez/LLGI
a0836e6db18e444d4534deb8eedb18263439fc4c
[ "Zlib" ]
312
2019-06-13T19:39:25.000Z
2022-03-02T18:37:22.000Z
examples/imgui/main.cpp
jayrulez/LLGI
a0836e6db18e444d4534deb8eedb18263439fc4c
[ "Zlib" ]
23
2019-10-04T11:02:21.000Z
2021-12-24T16:34:52.000Z
#ifdef _WIN32 #define GLFW_EXPOSE_NATIVE_WIN32 1 #endif #ifdef __APPLE__ #define GLFW_EXPOSE_NATIVE_COCOA 1 #endif #ifdef __linux__ #define GLFW_EXPOSE_NATIVE_X11 1 #undef Always #endif #include <GLFW/glfw3.h> #include <GLFW/glfw3native.h> #ifdef __linux__ #undef Always #endif #include <LLGI.CommandList.h> #include <LLGI.Graphics.h> #include <LLGI.Platform.h> #include <LLGI.Texture.h> #ifdef _WIN32 #pragma comment(lib, "d3dcompiler.lib") #elif __APPLE__ #endif // Use a library to use imgui with LLGI #include <ImGuiPlatform.h> #ifdef _WIN32 #include <ImGuiPlatformDX12.h> #elif __APPLE__ #include <ImGuiPlatformMetal.h> #endif #ifdef ENABLE_VULKAN #include <ImGuiPlatformVulkan.h> #endif #include <imgui_impl_glfw.h> class LLGIWindow : public LLGI::Window { GLFWwindow* window_ = nullptr; public: LLGIWindow(GLFWwindow* window) : window_(window) {} bool OnNewFrame() override { return glfwWindowShouldClose(window_) == GL_FALSE; } void* GetNativePtr(int32_t index) override { #ifdef _WIN32 if (index == 0) { return glfwGetWin32Window(window_); } return (HINSTANCE)GetModuleHandle(0); #endif #ifdef __APPLE__ return glfwGetCocoaWindow(window_); #endif #ifdef __linux__ if (index == 0) { return glfwGetX11Display(); } return reinterpret_cast<void*>(glfwGetX11Window(window_)); #endif } LLGI::Vec2I GetWindowSize() const override { int w, h; glfwGetWindowSize(window_, &w, &h); return LLGI::Vec2I(w, h); } LLGI::Vec2I GetFrameBufferSize() const override { int w, h; glfwGetFramebufferSize(window_, &w, &h); return LLGI::Vec2I(w, h); } }; static void glfw_error_callback(int error, const char* description) { fprintf(stderr, "Glfw Error %d: %s\n", error, description); } int main() { glfwInit(); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); auto window = glfwCreateWindow(1280, 720, "Example imgui", nullptr, nullptr); auto llgiwindow = new LLGIWindow(window); LLGI::DeviceType deviceType = LLGI::DeviceType::Default; #ifdef ENABLE_VULKAN deviceType = LLGI::DeviceType::Vulkan; #endif LLGI::PlatformParameter platformParam; platformParam.Device = deviceType; auto platform = LLGI::CreatePlatform(platformParam, llgiwindow); auto graphics = platform->CreateGraphics(); auto sfMemoryPool = graphics->CreateSingleFrameMemoryPool(1024 * 1024, 128); auto commandList = graphics->CreateCommandList(sfMemoryPool); LLGI::Color8 color; color.R = 50; color.G = 50; color.B = 50; color.A = 255; // Create simple texture LLGI::TextureInitializationParameter textureParam; textureParam.Size = LLGI::Vec2I(256, 256); auto texture = LLGI::CreateSharedPtr(graphics->CreateTexture(textureParam)); { auto ptr = static_cast<LLGI::Color8*>(texture->Lock()); if (ptr != nullptr) { for (size_t y = 0; y < 256; y++) { for (size_t x = 0; x < 256; x++) { ptr[x + y * 256].R = static_cast<uint8_t>(x); ptr[x + y * 256].G = static_cast<uint8_t>(y); ptr[x + y * 256].B = 0; ptr[x + y * 256].A = 255; } } texture->Unlock(); } } LLGI::RenderTextureInitializationParameter textureParam2; textureParam2.Size = LLGI::Vec2I(256, 256); auto texture2 = LLGI::CreateSharedPtr(graphics->CreateRenderTexture(textureParam2)); { auto ptr = static_cast<LLGI::Color8*>(texture2->Lock()); if (ptr != nullptr) { for (size_t y = 0; y < 256; y++) { for (size_t x = 0; x < 256; x++) { ptr[x + y * 256].R = static_cast<uint8_t>(x); ptr[x + y * 256].G = static_cast<uint8_t>(y); ptr[x + y * 256].B = 0; ptr[x + y * 256].A = 255; } } texture2->Unlock(); } } // Setup Dear ImGui context ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; // io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls // io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls // Setup Dear ImGui style ImGui::StyleColorsDark(); // ImGui::StyleColorsClassic(); // Setup Platform/Renderer bindings ImGui_ImplGlfw_InitForVulkan(window, true); std::shared_ptr<ImguiPlatform> imguiPlatform; #ifdef ENABLE_VULKAN if (deviceType == LLGI::DeviceType::Vulkan) { imguiPlatform = std::make_shared<ImguiPlatformVulkan>(graphics, platform); } #endif if (imguiPlatform == nullptr) { #if defined(_WIN32) imguiPlatform = std::make_shared<ImguiPlatformDX12>(graphics); #elif defined(__APPLE__) imguiPlatform = std::make_shared<ImguiPlatformMetal>(graphics); #endif } while (glfwWindowShouldClose(window) == GL_FALSE) { platform->SetWindowSize(llgiwindow->GetWindowSize()); if (!platform->NewFrame()) break; sfMemoryPool->NewFrame(); auto renderPass = platform->GetCurrentScreen(color, true); imguiPlatform->NewFrame(renderPass); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); { ImGui::Begin("Window"); ImGui::Text("Hello, Altseed"); { auto texturePtr = imguiPlatform->GetTextureIDToRender(texture.get(), commandList); if (texturePtr != nullptr) { ImGui::Image(texturePtr, ImVec2(256, 256)); } } { auto texturePtr = imguiPlatform->GetTextureIDToRender(texture2.get(), commandList); if (texturePtr != nullptr) { ImGui::Image(texturePtr, ImVec2(256, 256)); } } ImGui::End(); } // It need to create a command buffer between NewFrame and Present. // Because get current screen returns other values by every frame. commandList->Begin(); commandList->BeginRenderPass(renderPass); // imgui ImGui::Render(); imguiPlatform->RenderDrawData(ImGui::GetDrawData(), commandList); commandList->EndRenderPass(); commandList->End(); graphics->Execute(commandList); platform->Present(); // glfwSwapBuffers(window); glfwPollEvents(); } graphics->WaitFinish(); imguiPlatform.reset(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); LLGI::SafeRelease(sfMemoryPool); LLGI::SafeRelease(commandList); LLGI::SafeRelease(graphics); LLGI::SafeRelease(platform); delete llgiwindow; glfwDestroyWindow(window); glfwTerminate(); return 0; }
21.233449
131
0.698392
jayrulez
c4d55018ad52bb8e87654d41fe73702b41dde485
717
cpp
C++
src/Utility.cpp
kmc7468/IceScript
b11ea9dce5507949badfaeffa337c780cdf6ec5e
[ "MIT" ]
null
null
null
src/Utility.cpp
kmc7468/IceScript
b11ea9dce5507949badfaeffa337c780cdf6ec5e
[ "MIT" ]
null
null
null
src/Utility.cpp
kmc7468/IceScript
b11ea9dce5507949badfaeffa337c780cdf6ec5e
[ "MIT" ]
null
null
null
#include <ice/Utility.hpp> namespace ice { std::string Format(const std::string& format, const std::vector<std::string>& arguments) { std::string result; std::size_t begin = 0; std::size_t percent; std::size_t index = 0; while ((percent = format.find('%', begin)) != std::string::npos) { result.insert(result.end(), format.begin() + begin, format.begin() + percent); if (percent + 1 < format.size() && format[percent + 1] == '%') { result.push_back('%'); begin = percent + 2; } else { result.append(arguments[index++]); begin = percent + 1; } } if (begin < format.size()) { result.insert(result.end(), format.begin() + begin, format.end()); } return result; } }
25.607143
91
0.606695
kmc7468
c4d5a0b731a7a1ba3e6610fa55646d0dfe4163a8
8,275
cpp
C++
Iron/opening/macroitem.cpp
biug/titan
aacb4e2dc4d55601abd45cb8321d8e5160851eec
[ "MIT" ]
null
null
null
Iron/opening/macroitem.cpp
biug/titan
aacb4e2dc4d55601abd45cb8321d8e5160851eec
[ "MIT" ]
null
null
null
Iron/opening/macroitem.cpp
biug/titan
aacb4e2dc4d55601abd45cb8321d8e5160851eec
[ "MIT" ]
null
null
null
#include "macroitem.h" #include <regex> namespace iron { int GetIntFromString(const string & s) { stringstream ss(s); int a = 0; ss >> a; return a; } // Make a Type string look pretty for the UI string NiceTypeName(const string & s) { string inputName(s); replace(inputName.begin(), inputName.end(), '_', ' '); transform(inputName.begin(), inputName.end(), inputName.begin(), ::tolower); return inputName; } MacroLocation MacroItem::GetMacroLocationFromString(string & s) { if (s == "natural") { return MacroLocation::Natural; } if (s == "main") { return MacroLocation::Main; } return MacroLocation::Anywhere; } MacroItem::MacroItem() : m_type(MacroItems::Default) , m_race(Races::None) , m_macroLocation(MacroLocation::Anywhere) { } // Create a MacroItem from its name, like "drone" or "hatchery @ minonly". // String comparison here is case-insensitive. MacroItem::MacroItem(const string & name) : m_type(MacroItems::Default) , m_race(Races::None) , m_macroLocation(MacroLocation::Anywhere) { string inputName(NiceTypeName(name)); // Commands like "go gas until 100". 100 is the amount. if (inputName.substr(0, 3) == string("go ")) { for (const MacroCommandType t : MacroCommand::AllCommandTypes()) { string commandName = MacroCommand::GetName(t); if (MacroCommand::HasArgument(t)) { // There's an argument. Match the command name and parse out the argument. regex commandWithArgRegex(commandName + " (\\d+)"); smatch m; if (regex_match(inputName, m, commandWithArgRegex)) { int amount = GetIntFromString(m[1].str()); if (amount >= 0) { *this = MacroItem(t, amount); return; } } } else { // No argument. Just compare for equality. if (commandName == inputName) { *this = MacroItem(t); return; } } } } MacroLocation specifiedMacroLocation(MacroLocation::Anywhere); // the default // Buildings can specify a location, like "hatchery @ expo". // It's meaningless and ignored for anything except a building. // Here we parse out the building and its location. // Since buildings are units, only UnitType below sets _macroLocation. regex macroLocationRegex("([a-z_ ]+[a-z])\\s*\\@\\s*([a-z][a-z ]+)"); smatch m; if (regex_match(inputName, m, macroLocationRegex)) { specifiedMacroLocation = GetMacroLocationFromString(m[2].str()); // Don't change inputName before using the results from the regex. // Fix via gnuborg, who credited it to jaj22. inputName = m[1].str(); } for (const UnitType & unitType : UnitTypes::allUnitTypes()) { // check to see if the names match exactly string typeName(NiceTypeName(unitType.getName())); if (typeName == inputName) { *this = MacroItem(UnitType(unitType)); m_macroLocation = specifiedMacroLocation; return; } // check to see if the names match without the race prefix string raceName = unitType.getRace().getName(); transform(raceName.begin(), raceName.end(), raceName.begin(), ::tolower); if ((typeName.length() > raceName.length()) && (typeName.compare(raceName.length() + 1, typeName.length(), inputName) == 0)) { *this = MacroItem(UnitType(unitType)); m_macroLocation = specifiedMacroLocation; return; } } for (const TechType & techType : TechTypes::allTechTypes()) { string typeName(NiceTypeName(techType.getName())); if (typeName == inputName) { *this = MacroItem(techType); return; } } for (const UpgradeType & upgradeType : UpgradeTypes::allUpgradeTypes()) { string typeName(NiceTypeName(upgradeType.getName())); if (typeName == inputName) { *this = MacroItem(upgradeType); return; } } m_name = GetName(); } MacroItem::MacroItem(UnitType t) : m_unitType(t) , m_type(MacroItems::Unit) , m_race(t.getRace()) , m_macroLocation(MacroLocation::Anywhere) { m_name = GetName(); } MacroItem::MacroItem(UnitType t, MacroLocation loc) : m_unitType(t) , m_type(MacroItems::Unit) , m_race(t.getRace()) , m_macroLocation(loc) { m_name = GetName(); } MacroItem::MacroItem(TechType t) : m_techType(t) , m_type(MacroItems::Tech) , m_race(t.getRace()) , m_macroLocation(MacroLocation::Anywhere) { m_name = GetName(); } MacroItem::MacroItem(UpgradeType t) : m_upgradeType(t) , m_type(MacroItems::Upgrade) , m_race(t.getRace()) , m_macroLocation(MacroLocation::Anywhere) { m_name = GetName(); } MacroItem::MacroItem(MacroCommandType t) : m_macroCommandType(t) , m_type(MacroItems::Command) , m_race(Races::Terran) , m_macroLocation(MacroLocation::Anywhere) { m_name = GetName(); } MacroItem::MacroItem(MacroCommandType t, int amount) : m_macroCommandType(t, amount) , m_type(MacroItems::Command) , m_race(Races::Terran) // irrelevant , m_macroLocation(MacroLocation::Anywhere) { m_name = GetName(); } const size_t & MacroItem::type() const { return m_type; } bool MacroItem::IsUnit() const { return m_type == MacroItems::Unit; } bool MacroItem::IsTech() const { return m_type == MacroItems::Tech; } bool MacroItem::IsUpgrade() const { return m_type == MacroItems::Upgrade; } bool MacroItem::IsCommand() const { return m_type == MacroItems::Command; } const Race & MacroItem::GetRace() const { return m_race; } bool MacroItem::IsBuilding() const { return m_type == MacroItems::Unit && m_unitType.isBuilding(); } bool MacroItem::IsBuildingAddon() const { return m_type == MacroItems::Unit && m_unitType.isAddon(); } bool MacroItem::IsRefinery() const { return m_type == MacroItems::Unit && m_unitType.isRefinery(); } // The standard supply unit, ignoring the hatchery (which provides 1 supply). bool MacroItem::IsSupply() const { return IsUnit() && (m_unitType == Terran_Supply_Depot || m_unitType == Protoss_Pylon || m_unitType == Zerg_Overlord); } const UnitType & MacroItem::GetUnitType() const { return m_unitType; } const TechType & MacroItem::GetTechType() const { return m_techType; } const UpgradeType & MacroItem::GetUpgradeType() const { return m_upgradeType; } const MacroCommand MacroItem::GetCommandType() const { return m_macroCommandType; } const MacroLocation MacroItem::GetMacroLocation() const { return m_macroLocation; } int MacroItem::supplyRequired() const { if (IsUnit()) { return m_unitType.supplyRequired(); } return 0; } // NOTE Because upgrades vary in price with level, this is context dependent. int MacroItem::mineralPrice() const { if (IsCommand()) { return 0; } if (IsUnit()) { return m_unitType.mineralPrice(); } if (IsTech()) { return m_techType.mineralPrice(); } if (IsUpgrade()) { if (m_upgradeType.maxRepeats() > 1 && Broodwar->self()->getUpgradeLevel(m_upgradeType) > 0) { return m_upgradeType.mineralPrice(1 + Broodwar->self()->getUpgradeLevel(m_upgradeType)); } return m_upgradeType.mineralPrice(); } return 0; } // NOTE Because upgrades vary in price with level, this is context dependent. int MacroItem::gasPrice() const { if (IsCommand()) { return 0; } if (IsUnit()) { return m_unitType.gasPrice(); } if (IsTech()) { return m_techType.gasPrice(); } if (IsUpgrade()) { if (m_upgradeType.maxRepeats() > 1 && Broodwar->self()->getUpgradeLevel(m_upgradeType) > 0) { return m_upgradeType.gasPrice(1 + Broodwar->self()->getUpgradeLevel(m_upgradeType)); } return m_upgradeType.gasPrice(); } return 0; } UnitType MacroItem::whatBuilds() const { if (IsCommand()) { return UnitTypes::None; } UnitType buildType = IsUnit() ? m_unitType.whatBuilds().first : (IsTech() ? m_techType.whatResearches() : m_upgradeType.whatUpgrades()); return buildType; } string MacroItem::GetName() const { if (IsUnit()) { return m_unitType.getName(); } if (IsUpgrade()) { return m_upgradeType.getName(); } if (IsTech()) { return m_techType.getName(); } if (IsCommand()) { return m_macroCommandType.GetName(); } return "error"; } }
22.364865
138
0.659698
biug
c4d971e6fb2c5248bb1da7022e68c69e5c2cf5b9
2,378
hpp
C++
boost/actor/policy/sequential_invoke.hpp
syoummer/boost.actor
58f35499bac8871b8f5b0b024246a467b63c6fb0
[ "BSL-1.0" ]
2
2015-03-20T21:11:16.000Z
2020-01-20T08:05:41.000Z
boost/actor/policy/sequential_invoke.hpp
syoummer/boost.actor
58f35499bac8871b8f5b0b024246a467b63c6fb0
[ "BSL-1.0" ]
null
null
null
boost/actor/policy/sequential_invoke.hpp
syoummer/boost.actor
58f35499bac8871b8f5b0b024246a467b63c6fb0
[ "BSL-1.0" ]
null
null
null
/******************************************************************************\ * * * ____ _ _ _ * * | __ ) ___ ___ ___| |_ / \ ___| |_ ___ _ __ * * | _ \ / _ \ / _ \/ __| __| / _ \ / __| __/ _ \| '__| * * | |_) | (_) | (_) \__ \ |_ _ / ___ \ (__| || (_) | | * * |____/ \___/ \___/|___/\__(_)_/ \_\___|\__\___/|_| * * * * * * * * Copyright (C) 2011 - 2014 * * Dominik Charousset <[email protected]> * * * * Distributed under the Boost Software License, Version 1.0. See * * accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt * \******************************************************************************/ #ifndef BOOST_ACTOR_THREADLESS_HPP #define BOOST_ACTOR_THREADLESS_HPP #include "boost/actor/atom.hpp" #include "boost/actor/behavior.hpp" #include "boost/actor/duration.hpp" #include "boost/actor/policy/invoke_policy.hpp" namespace boost { namespace actor { namespace policy { /** * @brief An actor that is scheduled or otherwise managed. */ class sequential_invoke : public invoke_policy<sequential_invoke> { public: inline bool hm_should_skip(mailbox_element*) { return false; } template<class Actor> inline mailbox_element* hm_begin(Actor* self, mailbox_element* node) { auto previous = self->current_node(); self->current_node(node); return previous; } template<class Actor> inline void hm_cleanup(Actor* self, mailbox_element*) { self->current_node(self->dummy_node()); } template<class Actor> inline void hm_revert(Actor* self, mailbox_element* previous) { self->current_node(previous); } }; } } // namespace actor } // namespace boost::policy #endif // BOOST_ACTOR_THREADLESS_HPP
36.584615
80
0.433558
syoummer
c4dd6a879e608c28f2d3f92a4b6213cee9eef290
1,577
cpp
C++
tutorial_publisher/src/talker.cpp
ryo4432/ros2_tutorial_collection
4e7ed30e35009f07bd219c762d68b4b8022d4d9d
[ "Apache-2.0" ]
null
null
null
tutorial_publisher/src/talker.cpp
ryo4432/ros2_tutorial_collection
4e7ed30e35009f07bd219c762d68b4b8022d4d9d
[ "Apache-2.0" ]
null
null
null
tutorial_publisher/src/talker.cpp
ryo4432/ros2_tutorial_collection
4e7ed30e35009f07bd219c762d68b4b8022d4d9d
[ "Apache-2.0" ]
null
null
null
/* # Copyright 2019 Open Source Robotics Foundation, 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. */ #include <chrono> #include <cstdio> #include <memory> #include <string> #include "rclcpp/rclcpp.hpp" #include "std_msgs/msg/string.hpp" using namespace std::chrono_literals; class Talker : public rclcpp::Node { private: rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_; rclcpp::TimerBase::SharedPtr timer_; public: Talker(const std::string & node_name, const std::string & topic_name) : Node(node_name) { pub_ = this->create_publisher<std_msgs::msg::String>(topic_name, 10); auto msg_ = std_msgs::msg::String(); msg_.data = "Hello world"; auto publish_message = [this, msg_]() -> void { RCLCPP_INFO(this->get_logger(), "%s", msg_.data.c_str()); this->pub_->publish(msg_); }; timer_ = create_wall_timer(100ms, publish_message); } }; int main(int argc, char * argv[]) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared<Talker>("talker", "topic")); rclcpp::shutdown(); return 0; }
26.728814
74
0.700063
ryo4432
c4dec47b393ea9fc4c51411e2fe9a8ac4f702c79
2,596
hpp
C++
include/drag/detail/utils.hpp
bigno78/drag
a7fc1ff77a0e743bbe9a9e72a310a015f6f3b098
[ "BSD-3-Clause" ]
3
2020-07-29T19:38:51.000Z
2022-01-28T05:13:55.000Z
include/drag/detail/utils.hpp
bigno78/drag
a7fc1ff77a0e743bbe9a9e72a310a015f6f3b098
[ "BSD-3-Clause" ]
2
2020-09-05T19:59:15.000Z
2021-12-05T20:50:41.000Z
include/drag/detail/utils.hpp
bigno78/drag
a7fc1ff77a0e743bbe9a9e72a310a015f6f3b098
[ "BSD-3-Clause" ]
2
2020-07-29T19:44:52.000Z
2022-01-28T05:13:59.000Z
#pragma once #include <string> #include <vector> #include <drag/vec2.hpp> #include <drag/types.hpp> namespace drag { template <typename T> T sgn(T val) { return ( T(0) < val ) - ( val < T(0) ); } template<typename T> struct range { T r_start; T r_end; int step; range(T start, T end, int step = 1) : r_start(start), r_end(end), step(step) {} struct iterator { T val; int step; iterator(T val, int step) : val(val), step(step) {} T operator*() { return val; } friend bool operator==(const iterator& lhs, const iterator& rhs) { return lhs.val == rhs.val; } friend bool operator!=(const iterator& lhs, const iterator& rhs) { return !(lhs == rhs); } iterator& operator++() { val += step; return *this; } }; iterator begin() const { return iterator(r_start, step); } iterator end() const { return iterator(r_end, step); } }; template<typename T> struct chain_range { const T& first; const T& second; chain_range(const T& first, const T& second) : first(first), second(second) {} struct iterator { using It = typename T::const_iterator; It curr; It st_end; It nd_beg; iterator(It curr, It st_end, It nd_beg) : curr(curr) , st_end(st_end) , nd_beg(nd_beg) { if (curr == st_end) { this->curr = nd_beg; } } typename T::value_type operator*() { return *curr; } friend bool operator==(const iterator& lhs, const iterator& rhs) { return lhs.curr == rhs.curr; } friend bool operator!=(const iterator& lhs, const iterator& rhs) { return !(lhs == rhs); } iterator& operator++() { if (++curr == st_end) { curr = nd_beg; } return *this; } }; iterator begin() { return iterator( std::begin(first), std::end(first), std::begin(second) ); } iterator begin() const { return iterator( std::begin(first), std::end(first), std::begin(second) ); } iterator end() { return iterator( std::end(second), std::end(first), std::begin(second) ); } iterator end() const { return iterator( std::end(second), std::end(first), std::begin(second) ); } }; template<typename T> std::ostream& operator<<(std::ostream& out, const std::vector<T>& vec) { const char* sep = ""; for (const auto& x : vec) { out << sep << x; sep = ", "; } return out; } } //namespace drag
26.222222
105
0.547766
bigno78
c4df2d75c14d83b0119c74cd216535da3a4d9c9e
3,001
hpp
C++
masterui/display.hpp
rickfoosusa/dnp
ec17eb20817db32cc6356139afd2daaa1803576f
[ "BSD-2-Clause-FreeBSD" ]
1
2017-09-19T16:37:59.000Z
2017-09-19T16:37:59.000Z
masterui/display.hpp
rickfoosusa/dnp
ec17eb20817db32cc6356139afd2daaa1803576f
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
masterui/display.hpp
rickfoosusa/dnp
ec17eb20817db32cc6356139afd2daaa1803576f
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
// // $Id$ // // Copyright (C) 2007 Turner Technolgoies Inc. http://www.turner.ca // // 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 DISPLAY_H #define DISPLAY_H #include <QString> #include <QWidget> #include <QDateTime> #include "common.hpp" #include "event_interface.hpp" class QGroupBox; class QTreeView; class QAbstractItemModel; class DataDisplay : public QWidget { Q_OBJECT public: DataDisplay(); // returns true if it is a Change Of State (COS) virtual bool updateData( QString name, EventInterface::PointType_t pointType, int value, DnpTime_t timestamp=0); virtual void createDataModel(); protected: virtual void addRow( QString name, EventInterface::PointType_t pointType, int value, DnpTime_t timestamp=0); void addParent( EventInterface::PointType_t pointType); QAbstractItemModel *dataModel; QGroupBox *dataGroupBox; QTreeView *dataView; static const QString ptNames[EventInterface::NUM_POINT_TYPES]; }; class CosDisplay : public DataDisplay { Q_OBJECT public: CosDisplay(); public: virtual void createDataModel(); // return value shuold not be used // it is the callers responsibility not to call this method if it // it not an event bool updateData( QString name, EventInterface::PointType_t pointType, int value, DnpTime_t timestamp=0); private: void addRow( QString name, EventInterface::PointType_t, int value, DnpTime_t timestamp=0); QDateTime dateTime; }; #endif
29.712871
71
0.626458
rickfoosusa
c4e04900cf25da6cc065194c8b82d97bfd57337c
1,925
cpp
C++
src/private/PZGBeaconData.cpp
ruurdadema/zg_choir
6de0e8be497974c0e56bb87139b18f0d6f5b4ee3
[ "BSD-3-Clause" ]
null
null
null
src/private/PZGBeaconData.cpp
ruurdadema/zg_choir
6de0e8be497974c0e56bb87139b18f0d6f5b4ee3
[ "BSD-3-Clause" ]
null
null
null
src/private/PZGBeaconData.cpp
ruurdadema/zg_choir
6de0e8be497974c0e56bb87139b18f0d6f5b4ee3
[ "BSD-3-Clause" ]
null
null
null
#include "zg/private/PZGBeaconData.h" namespace zg_private { void PZGBeaconData :: Flatten(uint8 *buffer) const { const uint32 numItems = _dbis.GetNumItems(); const uint32 dbiFlatSize = PZGDatabaseStateInfo::FlattenedSize(); muscleCopyOut(buffer, B_HOST_TO_LENDIAN_INT32(numItems)); buffer += sizeof(uint32); for (uint32 i=0; i<numItems; i++) {_dbis[i].Flatten(buffer); buffer += dbiFlatSize;} } status_t PZGBeaconData :: Unflatten(const uint8 *buf, uint32 size) { if (size < sizeof(uint32)) return B_BAD_DATA; const uint32 itemFlatSize = PZGDatabaseStateInfo::FlattenedSize(); const uint32 newNumItems = B_LENDIAN_TO_HOST_INT32(muscleCopyIn<uint32>(buf)); buf += sizeof(uint32); size -= sizeof(uint32); if (size < (newNumItems*itemFlatSize)) return B_BAD_DATA; MRETURN_ON_ERROR(_dbis.EnsureSize(newNumItems, true)); for (uint32 i=0; i<newNumItems; i++) { MRETURN_ON_ERROR(_dbis[i].Unflatten(buf, itemFlatSize)); buf += itemFlatSize; size -= itemFlatSize; } return B_NO_ERROR; } PZGBeaconDataRef GetBeaconDataFromPool() { static ObjectPool<PZGBeaconData> _infoListPool; return PZGBeaconDataRef(_infoListPool.ObtainObject()); } uint32 PZGBeaconData :: CalculateChecksum() const { const uint32 numItems = _dbis.GetNumItems(); uint32 ret = numItems; for (uint32 i=0; i<numItems; i++) ret += (i+1)*(_dbis[i].CalculateChecksum()); return ret; } void PZGBeaconData :: PrintToStream() const { puts(ToString()()); } String PZGBeaconData :: ToString() const { String ret; char buf[128]; for (uint32 i=0; i<_dbis.GetNumItems(); i++) { muscleSprintf(buf, " DBI #" UINT32_FORMAT_SPEC ": ", i); ret += buf; ret += _dbis[i].ToString(); ret += '\n'; } return ret; } bool PZGBeaconData :: operator == (const PZGBeaconData & rhs) const { return (_dbis == rhs._dbis); } }; // end namespace zg_private
26.013514
129
0.686753
ruurdadema
c4e1c2f5ec6fb5b8c322d1497c5992c18e382612
402
cpp
C++
AIC/AIC'20 - Level 1 Training Contests/Contest #6 (Online)/H.cpp
MaGnsio/CP-Problems
a7f518a20ba470f554b6d54a414b84043bf209c5
[ "Unlicense" ]
3
2020-11-01T06:31:30.000Z
2022-02-21T20:37:51.000Z
AIC/AIC'20 - Level 1 Training Contests/Contest #6 (Online)/H.cpp
MaGnsio/CP-Problems
a7f518a20ba470f554b6d54a414b84043bf209c5
[ "Unlicense" ]
null
null
null
AIC/AIC'20 - Level 1 Training Contests/Contest #6 (Online)/H.cpp
MaGnsio/CP-Problems
a7f518a20ba470f554b6d54a414b84043bf209c5
[ "Unlicense" ]
1
2021-05-05T18:56:31.000Z
2021-05-05T18:56:31.000Z
//https://codeforces.com/group/aDFQm4ed6d/contest/274872/problem/H #include <bits/stdc++.h> using namespace std; #define F first #define S second typedef long long ll; typedef long double ld; ll mod = 1e9 + 7; int main () { ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0); ll k, n, s, p; cin >> k >> n >> s >> p; ll x = (n + s - 1) / s; cout << ((k * x) + p - 1) / p; }
21.157895
66
0.577114
MaGnsio
c4e3b64788f0256a3afac60415999e1650d2725b
1,191
cpp
C++
1142/a.cpp
vladshablinsky/algo
815392708d00dc8d3159b4866599de64fa9d34fa
[ "MIT" ]
1
2021-10-24T00:46:37.000Z
2021-10-24T00:46:37.000Z
1142/a.cpp
vladshablinsky/algo
815392708d00dc8d3159b4866599de64fa9d34fa
[ "MIT" ]
null
null
null
1142/a.cpp
vladshablinsky/algo
815392708d00dc8d3159b4866599de64fa9d34fa
[ "MIT" ]
null
null
null
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } void solve(long long a, long long b, long long len, long long &mn, long long &mx) { long long step; if (a > b) { step = len - (a - b); } else { step = b - a; } // cout << "a = " << a << ", b = " << b << ", step = " << step << endl; // if (step == 0) { // mn = 1; // mx = len; // return; // } long long res = len / gcd(len, step); // cout << "len = " << len << ", step = " << step << ", res = " << res << endl; mn = min(mn, res); mx = max(mx, res); } int main() { long long n, k; long long a, b; cin >> n >> k; cin >> a >> b; if (n == 1 && k == 1) { cout << 1 << " " << 1 << "\n"; return 0; } long long mn = 1e18; long long mx = 1; for (long long cur_b = b, cur_next_b = k - b; cur_b < n * k; cur_b += k, cur_next_b += k) { // cout << "cur_b = " << cur_b << ", cur_next_b = " << cur_next_b << endl; solve(a, cur_b, n * k, mn, mx); solve(k - a, cur_b, n * k, mn, mx); } cout << mn << " " << mx << "\n"; return 0; }
19.85
93
0.455919
vladshablinsky
c4e625a98b552cf6e92bf5fc7f2d46aed001c7a0
520
cpp
C++
source/ItemShotgun.cpp
fgrehm/pucrs-doom2d
edea7d5d762f427a5a8c944d36819009eb514429
[ "MIT" ]
1
2016-08-15T16:11:40.000Z
2016-08-15T16:11:40.000Z
source/ItemShotgun.cpp
fgrehm/pucrs-doom2d
edea7d5d762f427a5a8c944d36819009eb514429
[ "MIT" ]
null
null
null
source/ItemShotgun.cpp
fgrehm/pucrs-doom2d
edea7d5d762f427a5a8c944d36819009eb514429
[ "MIT" ]
null
null
null
#include "ItemShotgun.h" ItemShotgun::ItemShotgun(int _x, int _y): x(_x), y(_y) { sprite = new cgf::Sprite(); sprite->load("data/img/shotgun.png"); sprite->scale(1.2, 1.2); sf::Vector2f vpos = sf::Vector2f(); vpos.x = x; vpos.y = y; sprite->setPosition(vpos); } ItemShotgun::~ItemShotgun(){ if (sprite){ delete sprite; } } void ItemShotgun::visit(Inventory *iv) { iv->addShotgun(); } void ItemShotgun::draw(cgf::Game* game){ game->getScreen()->draw(*sprite); }
16.25
41
0.6
fgrehm
c4eabc24d27ea35b73a8be559fea0a51971629d2
1,327
cc
C++
src/dictionaries/node_webrtc/rtc_offer_options.cc
elofun/node-webrtc
be63c8c007402c25962df9e30c9813ba70b8a17b
[ "Apache-2.0" ]
1,302
2018-11-26T03:29:51.000Z
2022-03-31T23:38:34.000Z
src/dictionaries/node_webrtc/rtc_offer_options.cc
elofun/node-webrtc
be63c8c007402c25962df9e30c9813ba70b8a17b
[ "Apache-2.0" ]
311
2018-11-26T14:22:19.000Z
2022-03-28T09:47:38.000Z
src/dictionaries/node_webrtc/rtc_offer_options.cc
elofun/node-webrtc
be63c8c007402c25962df9e30c9813ba70b8a17b
[ "Apache-2.0" ]
233
2018-11-26T18:08:11.000Z
2022-03-30T01:29:50.000Z
#include "src/dictionaries/node_webrtc/rtc_offer_options.h" #include "src/functional/maybe.h" #include "src/functional/validation.h" namespace node_webrtc { #define RTC_OFFER_OPTIONS_FN CreateRTCOfferOptions static Validation<RTC_OFFER_OPTIONS> RTC_OFFER_OPTIONS_FN( const bool voiceActivityDetection, const bool iceRestart, const Maybe<bool> offerToReceiveAudio, const Maybe<bool> offerToReceiveVideo) { webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options; options.ice_restart = iceRestart; options.voice_activity_detection = voiceActivityDetection; options.offer_to_receive_audio = offerToReceiveAudio.Map([](auto boolean) { return boolean ? webrtc::PeerConnectionInterface::RTCOfferAnswerOptions::kOfferToReceiveMediaTrue : 0; }).FromMaybe(webrtc::PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined); options.offer_to_receive_video = offerToReceiveVideo.Map([](auto boolean) { return boolean ? webrtc::PeerConnectionInterface::RTCOfferAnswerOptions::kOfferToReceiveMediaTrue : 0; }).FromMaybe(webrtc::PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined); return Pure(RTC_OFFER_OPTIONS(options)); } } // namespace node_webrtc #define DICT(X) RTC_OFFER_OPTIONS ## X #include "src/dictionaries/macros/impls.h" #undef DICT
36.861111
90
0.788244
elofun
c4f5838d7ff632354152537fc38e2044a64591d6
418
cpp
C++
Challenges - Sorting & Searching/Winning CB Scholarship.cpp
helewrer3/CB_Launchpad
cda17f62a25e15cb914982d1cc24f7ba0e2f7a67
[ "Unlicense" ]
3
2019-10-04T13:24:16.000Z
2020-01-22T05:07:02.000Z
Challenges - Sorting & Searching/Winning CB Scholarship.cpp
helewrer3/CB_Launchpad
cda17f62a25e15cb914982d1cc24f7ba0e2f7a67
[ "Unlicense" ]
null
null
null
Challenges - Sorting & Searching/Winning CB Scholarship.cpp
helewrer3/CB_Launchpad
cda17f62a25e15cb914982d1cc24f7ba0e2f7a67
[ "Unlicense" ]
null
null
null
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll N, M, X, Y, r_cpn, c_cpn, ans = INT_MIN; cin >> N >> M >> X >> Y; ll st = 1, ed = N; ll mid = (st+ed)/2; while(st <= ed){ mid = (st+ed)/2; r_cpn = mid*X; c_cpn = M + (N-mid)*Y; if(r_cpn > c_cpn) ed = mid-1; else if(r_cpn <= c_cpn){ ans = max(ans, mid); st = mid+1; } } cout << ans; return 0; }
14.413793
44
0.502392
helewrer3
c4f71328bc68fc79f731aa6cb23abc7869f33e4d
400
cpp
C++
practice/algorithms/birthday-cake-candles.cpp
geezardo/hackerrank
c3dd829ba803bd21ec3f432f419e40415cf6a6a8
[ "MIT" ]
null
null
null
practice/algorithms/birthday-cake-candles.cpp
geezardo/hackerrank
c3dd829ba803bd21ec3f432f419e40415cf6a6a8
[ "MIT" ]
null
null
null
practice/algorithms/birthday-cake-candles.cpp
geezardo/hackerrank
c3dd829ba803bd21ec3f432f419e40415cf6a6a8
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; #define endl '\n' int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a (n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); auto lb = lower_bound(a.begin(), a.end(), a[n - 1]); int sum = 0; for (auto it = lb; it != a.end(); it++) sum++; cout << sum << endl; return 0; }
14.814815
54
0.5175
geezardo
c4f73ea2e0c7a774f1a8ce6f901f00efd9361853
2,146
cpp
C++
src/widgets/outlineprovider.cpp
l1422586361/vnote
606dcef16f882350cc2be2fd108625894d13143b
[ "MIT" ]
8,054
2016-10-19T14:59:52.000Z
2020-10-11T06:21:15.000Z
src/widgets/outlineprovider.cpp
micalstanley/vnote-1
606dcef16f882350cc2be2fd108625894d13143b
[ "MIT" ]
1,491
2017-03-06T02:31:32.000Z
2020-10-11T02:14:32.000Z
src/widgets/outlineprovider.cpp
micalstanley/vnote-1
606dcef16f882350cc2be2fd108625894d13143b
[ "MIT" ]
986
2017-02-14T05:45:13.000Z
2020-10-10T07:42:31.000Z
#include "outlineprovider.h" using namespace vnotex; void Outline::clear() { m_headings.clear(); } bool Outline::operator==(const Outline &p_a) const { return m_headings == p_a.m_headings; } bool Outline::isEmpty() const { return m_headings.isEmpty(); } Outline::Heading::Heading(const QString &p_name, int p_level) : m_name(p_name), m_level(p_level) { } bool Outline::Heading::operator==(const Outline::Heading &p_a) const { return m_level == p_a.m_level && m_name == p_a.m_name; } OutlineProvider::OutlineProvider(QObject *p_parent) : QObject(p_parent) { } OutlineProvider::~OutlineProvider() { } void OutlineProvider::setOutline(const QSharedPointer<Outline> &p_outline) { m_outline = p_outline; m_currentHeadingIndex = -1; emit outlineChanged(); } const QSharedPointer<Outline> &OutlineProvider::getOutline() const { return m_outline; } int OutlineProvider::getCurrentHeadingIndex() const { return m_currentHeadingIndex; } void OutlineProvider::setCurrentHeadingIndex(int p_idx) { if (m_currentHeadingIndex == p_idx) { return; } m_currentHeadingIndex = p_idx; emit currentHeadingChanged(); } void OutlineProvider::increaseSectionNumber(SectionNumber &p_sectionNumber, int p_level, int p_baseLevel) { Q_ASSERT(p_level >= 1 && p_level < p_sectionNumber.size()); if (p_level < p_baseLevel) { p_sectionNumber.fill(0); return; } ++p_sectionNumber[p_level]; for (int i = p_level + 1; i < p_sectionNumber.size(); ++i) { p_sectionNumber[i] = 0; } } QString OutlineProvider::joinSectionNumber(const SectionNumber &p_sectionNumber, bool p_endingDot) { QString res; for (auto sec : p_sectionNumber) { if (sec != 0) { if (res.isEmpty()) { res = QString::number(sec); } else { res += '.' + QString::number(sec); } } else if (res.isEmpty()) { continue; } else { break; } } if (p_endingDot && !res.isEmpty()) { return res + '.'; } else { return res; } }
20.634615
105
0.632805
l1422586361
c4fbc70e4741770df8cd09eb41601131ae677538
3,090
hpp
C++
include/SSVStart/Assets/Internal/Loader.hpp
vittorioromeo/SSVStart
ba604007e54462df30346d9c0545ba3274850f49
[ "AFL-3.0" ]
11
2015-01-27T09:45:11.000Z
2017-10-05T17:14:40.000Z
include/SSVStart/Assets/Internal/Loader.hpp
vittorioromeo/SSVStart
ba604007e54462df30346d9c0545ba3274850f49
[ "AFL-3.0" ]
2
2019-12-16T00:24:29.000Z
2019-12-17T13:57:42.000Z
include/SSVStart/Assets/Internal/Loader.hpp
vittorioromeo/SSVStart
ba604007e54462df30346d9c0545ba3274850f49
[ "AFL-3.0" ]
7
2015-01-29T17:05:52.000Z
2020-08-12T22:59:47.000Z
// Copyright (c) 2013-2015 Vittorio Romeo // License: Academic Free License ("AFL") v. 3.0 // AFL License page: http://opensource.org/licenses/AFL-3.0 #pragma once #include "SSVStart/BitmapText/BitmapText.hpp" #include "SSVStart/Tileset/Tileset.hpp" #include "SSVStart/Assets/Internal/Helper.hpp" #include <SSVUtils/Core/FileSystem/Path.hpp> #include <cstddef> namespace ssvs::Impl { template <typename T> struct Loader // Most resources can be loaded only from Path, Memory or // Stream { template <typename... TArgs> static auto load(TArgs&&... mArgs) { return Helper<Mode::Load, T>::load(mArgs...); } }; template <> struct Loader<sf::Texture> // Texture can also be loaded from Image { using T = sf::Texture; static auto load(const ssvu::FileSystem::Path& mPath) { return Helper<Mode::Load, T>::load(mPath); } static auto load(const void* mData, std::size_t mSize) { return Helper<Mode::Load, T>::load(mData, mSize); } static auto load(sf::InputStream& mStream) { return Helper<Mode::Load, T>::load(mStream); } static auto load(const sf::Image& mImage) { return Helper<Mode::Image, T>::load(mImage); } }; template <> struct Loader<sf::SoundBuffer> // SoundBuffer can also be loaded from // samples { using T = sf::SoundBuffer; static auto load(const ssvu::FileSystem::Path& mPath) { return Helper<Mode::Load, T>::load(mPath); } static auto load(const void* mData, std::size_t mSize) { return Helper<Mode::Load, T>::load(mData, mSize); } static auto load(sf::InputStream& mStream) { return Helper<Mode::Load, T>::load(mStream); } static auto load(const sf::Int16* mSamples, std::size_t mSampleCount, unsigned int mChannelCount, unsigned int mSampleRate) { return Helper<Mode::Samples, T>::load( mSamples, mSampleCount, mChannelCount, mSampleRate); } }; template <> struct Loader<sf::Music> // Music can be opened from Path, Memory or // StreamloadFromFile { using T = sf::Music; template <typename... TArgs> static auto load(TArgs&&... mArgs) { return Helper<Mode::Open, T>::load(FWD(mArgs)...); } }; template <> struct Loader<sf::Shader> // Shader has unique syntax { using T = sf::Shader; template <typename... TArgs> static auto load(TArgs&&... mArgs) { return Helper<Mode::Shader, T>::load(FWD(mArgs)...); } }; template <> struct Loader<BitmapFont> // BitmapFont has unique syntax { using T = BitmapFont; template <typename... TArgs> static auto load(TArgs&&... mArgs) { return Helper<Mode::BitmapFont, T>::load(FWD(mArgs)...); } }; template <> struct Loader<Tileset> // Tileset has unique syntax { using T = Tileset; template <typename... TArgs> static auto load(TArgs&&... mArgs) { return Helper<Mode::Tileset, T>::load(FWD(mArgs)...); } }; } // namespace ssvs::Impl
23.769231
73
0.615858
vittorioromeo
c4fe06d0e89af85642f74102c029023403bba445
917
hpp
C++
src/Jogo/Resources/TexturesHolder.hpp
MatheusKunnen/Jogo-TecProg
66f4320e51e42d12da74e487cc8552377ce865bb
[ "MIT" ]
null
null
null
src/Jogo/Resources/TexturesHolder.hpp
MatheusKunnen/Jogo-TecProg
66f4320e51e42d12da74e487cc8552377ce865bb
[ "MIT" ]
null
null
null
src/Jogo/Resources/TexturesHolder.hpp
MatheusKunnen/Jogo-TecProg
66f4320e51e42d12da74e487cc8552377ce865bb
[ "MIT" ]
null
null
null
// // TexturesHolder.hpp // Jogo-SFML // // Created by Matheus Kunnen Ledesma on 10/6/19. // Copyright © 2019 Matheus Kunnen Ledesma. All rights reserved. // #ifndef TexturesHolder_hpp #define TexturesHolder_hpp #include "../base_includes.hpp" #include "ResourcesHolder.hpp" namespace Game { namespace Resources{ namespace Textures { enum ID {bg_menu, bg_config, bg_ranking, bg_fase, bg_game, bg_pause, jogador_a, jogador_b, narcotraficante, desmatador, narcotraficante_desmatador, planta_venenosa, pedra, espinhos, projetil}; } class TextureHolder : public ResourceHolder<sf::Texture, Textures::ID>{ private: // Attributes static map<Textures::ID, string> default_filenames; // Const static const string DEFAULT_NOT_FILE; public: TextureHolder(); ~TextureHolder(); // Methods static const string& getFilename(Textures::ID id); }; };}; #endif /* TexturesHolder_hpp */
26.2
196
0.730643
MatheusKunnen
f203968e1899e726d69b2e8a57e506a629b2fe7c
712
cpp
C++
Week 6/Lab/Old/Week 6 Sample Programs/Pr9-8.cpp
sugamkarki/NAMI-Year-II-Term-I-Software_Engineering
39182816b670dcb75ec322e24b346a4cfeb80be0
[ "Apache-2.0" ]
null
null
null
Week 6/Lab/Old/Week 6 Sample Programs/Pr9-8.cpp
sugamkarki/NAMI-Year-II-Term-I-Software_Engineering
39182816b670dcb75ec322e24b346a4cfeb80be0
[ "Apache-2.0" ]
null
null
null
Week 6/Lab/Old/Week 6 Sample Programs/Pr9-8.cpp
sugamkarki/NAMI-Year-II-Term-I-Software_Engineering
39182816b670dcb75ec322e24b346a4cfeb80be0
[ "Apache-2.0" ]
null
null
null
// This program uses the address of each element in the array. #include <iostream> #include <iomanip> using namespace std; int main() { const int NUM_COINS = 5; double coins[NUM_COINS] = {0.05, 0.1, 0.25, 0.5, 1.0}; double *doublePtr; // Pointer to a double int count; // Array index // Use the pointer to display the values in the array. cout << "Here are the values in the coins array:\n"; for (count = 0; count < NUM_COINS; count++) { // Get the address of an array element. doublePtr = &coins[count]; // Display the contents of the element. cout << *doublePtr << " "; } cout << endl; system("PAUSE"); return 0; }
27.384615
63
0.592697
sugamkarki
f20a3e12339a04abdf34db7fda92ed68117f4f5e
1,331
cpp
C++
C_CPP/final/KMP.cpp
dengchongsen/study_codes
29d74c05d340117f76aafcc320766248a0f8386b
[ "MulanPSL-1.0" ]
null
null
null
C_CPP/final/KMP.cpp
dengchongsen/study_codes
29d74c05d340117f76aafcc320766248a0f8386b
[ "MulanPSL-1.0" ]
null
null
null
C_CPP/final/KMP.cpp
dengchongsen/study_codes
29d74c05d340117f76aafcc320766248a0f8386b
[ "MulanPSL-1.0" ]
null
null
null
#include <iostream> using namespace std; const int maxn = 1000005; char s[maxn]; char p[maxn]; int nex[maxn]; int pl, ml; int ans = 0; void init() { pl = 0; ml = 0; int i = 0, j = 0; while (s[i] != '\0') s[i++] = '\0'; while (p[j] != '\0') p[j++] = '\0'; } // 获取窗口滑动位置 void getnex() { nex[0] = -1; for (int i = 0, j = -1; i < pl;) { if (j == -1 || p[i] == p[j]) nex[++i] = ++j; else j = nex[j]; } } int Kmp() { getnex(); int i = 0, j = 0; while (i <= ml && j <= pl) { // 当前位置匹配 if (j == -1 || s[i] == p[j]) { if (j == pl - 1) { //匹配成功 int index = i - pl + 1; ans++; j = 0; i = index + 1; // cout<<"chengong"<<endl; } // 主串跟模式串指针同时移向下一位 i++; j++; } // 失配则j回到next[j]的位置 else { j = nex[j]; } } return -1; } void getlen() { ml = 0; int i = 0; while (s[i++] != '\0') ml++; } int main() { init(); while (cin >> s) { getlen(); int n; cin >> n; while (n--) { int j = 0; while (p[j] != '\0') { p[j++] = '\0'; }; cin >> p; pl = 0; int jj = 0; while (p[jj++] != '\0') pl++; ans = 0; Kmp(); cout << p << ":" << ans << endl; } } return 0; }
13.581633
38
0.352367
dengchongsen
f2102881aec08af853984f88ca90789b059c05e0
21,007
cpp
C++
source/game_state.cpp
Craig-J/RhythMIR
37165688b5bf925a1570ed1daf6e1b21892456b2
[ "MIT" ]
null
null
null
source/game_state.cpp
Craig-J/RhythMIR
37165688b5bf925a1570ed1daf6e1b21892456b2
[ "MIT" ]
3
2016-07-17T15:26:12.000Z
2016-07-17T15:32:38.000Z
source/game_state.cpp
Craig-J/RhythMIR
37165688b5bf925a1570ed1daf6e1b21892456b2
[ "MIT" ]
null
null
null
#include "game_state.h" #include "app_state_machine.h" #include "menu_state.h" #include <SFML_Extensions/global.h> namespace { sf::Vector2f window_centre; sf::Vector2f window_size; float path_start_y; float path_end_y; float path_x; float path_x_offset; float note_length; bool interpolate_beats; sf::Time beat_interval; sf::Time beat_time; const int performance_statistic_count = 10; const int performance_y_offset = 24.0f; } GameState::GameState(AppStateMachine& _state_machine, UniqueStatePtr<AppState>& _state, BeatmapPtr _beatmap, GameSettings _settings) : AppState(_state_machine, _state), beatmap_(std::move(_beatmap)), settings_(std::move(_settings)), play_clock_(), paused_(false), finished_(false), hit_counters_(true), current_section_(nullptr) { } void GameState::InitializeState() { textures_ = sfx::TextureFileVector { { machine_.background_texture_, "skins/default/play_background.png" }, { pause_background_texture_, "skins/default/pause_background.png" }, { white_circle_texture_, "skins/default/circle_white.png", }, { beat_texture_, "skins/default/beat.png" } }; sfx::Global::TextureManager.Load(textures_); machine_.background_.setTexture(*machine_.background_texture_); sounds_ = sfx::SoundFileVector { { deep_hit_sound_, "skins/default/deep_hit.wav" }, { soft_hit_sound_, "skins/default/soft_hit.wav" }, { miss_sound_, "skins/default/combobreak.wav" } }; sfx::Global::AudioManager.Load(sounds_); window_centre = sf::Vector2f(machine_.window_.getSize().x * 0.5, machine_.window_.getSize().y * 0.5); window_size = sf::Vector2f(machine_.window_.getSize()); pause_background_ = sfx::Sprite(window_centre, pause_background_texture_); // Clock text initialization clock_text_.setFont(machine_.font_); clock_text_.setCharacterSize(45); clock_text_.setColor(sf::Color::Color(255, 69, 0)); clock_text_.setPosition(sf::Vector2f(window_size.x, 0.0f)); // Countdown text initialization countdown_text_.setFont(machine_.font_); countdown_text_.setCharacterSize(120); countdown_text_.setColor(sf::Color::Color(255, 69, 0)); countdown_text_.setPosition(window_centre); // Score initialization score_text_.setFont(machine_.font_); score_text_.setCharacterSize(60); score_text_.setColor(sf::Color::Color(255, 69, 0)); score_text_.setPosition(sf::Vector2f(window_size.x, 0.0f)); score_ = 0; // Hit counters initialization performance_text_.setFont(machine_.font_); performance_text_.setCharacterSize(30); performance_text_.setPosition(sf::Vector2f(5.0f, window_size.y - performance_y_offset * 10 - 5.0f)); perfect_hits_ = 0; great_hits_ = 0; good_hits_ = 0; misses_ = 0; hit_combo_ = 0; max_combo_ = 0; average_hit_ = 0.0f; unstable_rate_ = 0.0f; earliest_hit_ = -300; latest_hit_ = 300; hits_.clear(); // Beatmap initialization sections_ = beatmap_->CopyTimingSections(); interpolate_beats = false; switch (settings_.beat_style) { case GameSettings::HIDDEN: break; case GameSettings::INTERPOLATED: if (sections_.front().BPM != 0.0f && sections_.front().offset != sf::Time::Zero) { interpolate_beats = true; beat_interval = sf::milliseconds(1000 * 60 / sections_.front().BPM); beat_time = beat_interval; } break; case GameSettings::GENERATED: beatqueue_ = beatmap_->CopyBeats(); break; } if (!beatmap_->music_) beatmap_->LoadMusic(); beatmap_->music_->setPlayingOffset(sf::Time::Zero); srand(time(0)); machine_.settings_.limit_framerate_ = false; machine_.settings_.display_hud_ = false; switch (beatmap_->play_mode_) { case VISUALIZATION: settings_.path_count = sections_.front().notes.size(); InitializeVisualizationMode(); break; case SINGLE: InitializeFourKeyMode(); break; case FOURKEY: InitializeFourKeyMode(); break; } } void GameState::TerminateState() { sfx::Global::TextureManager.Unload(textures_); textures_.clear(); sfx::Global::AudioManager.Unload(sounds_); sounds_.clear(); } bool GameState::Update(const float _delta_time) { if (finished_) { if (sfx::Global::Input.KeyPressed(sf::Keyboard::BackSpace)) { ChangeState<MenuState>(std::move(beatmap_)); return true; } if (sfx::Global::Input.KeyPressed(sf::Keyboard::Return)) { ChangeState<GameState>(std::move(beatmap_), std::move(settings_)); return true; } if (!PauseMenu()) { return true; } } else { if (sfx::Global::Input.KeyPressed(sf::Keyboard::Escape)) { paused_ = !paused_; } if (settings_.music_volume != beatmap_->music_->getVolume()) beatmap_->music_->setVolume(settings_.music_volume); if (paused_) { play_clock_.Stop(); if (beatmap_->music_->getStatus() == sf::Music::Playing) beatmap_->music_->pause(); if (sfx::Global::Input.KeyPressed(sf::Keyboard::BackSpace)) { ChangeState<MenuState>(std::move(beatmap_)); return true; } if (sfx::Global::Input.KeyPressed(sf::Keyboard::Return)) { ChangeState<GameState>(std::move(beatmap_), std::move(settings_)); return true; } if (!PauseMenu()) { return true; } } else { play_clock_.Start(); auto time_elapsed = play_clock_.GetTimeElapsed(); // If more than the play offset (intro time) seconds and // less than the duration of the music + play offset seconds has elapsed then... if (time_elapsed > settings_.countdown_time && time_elapsed < beatmap_->music_->getDuration() + settings_.countdown_time) { auto current_offset = time_elapsed - settings_.countdown_time + settings_.play_offset; auto current_approach_offset = current_offset + settings_.approach_time; // Play music if it's not already playing if (beatmap_->music_->getStatus() != sf::Music::Playing) beatmap_->music_->play(); // If sections isn't empty if (!sections_.empty()) { // See if the next one's offset is less than the current approach offset auto next_section = sections_.front(); if (current_approach_offset > next_section.offset) { current_section_.reset(new TimingSection(next_section)); sections_.pop(); SpawnBeat(); } } if (current_section_) { if (!interpolate_beats) { if (beatqueue_) { if (!beatqueue_->empty()) { auto next_beat_offset = beatqueue_->front().offset; if (current_approach_offset - settings_.play_offset > next_beat_offset) { SpawnBeat(); beatqueue_->pop(); } } } } else { beat_time -= sf::seconds(_delta_time); if (beat_time < sf::Time::Zero) { SpawnBeat(); beat_time += beat_interval; } } if (!current_section_->notes.empty()) { for (auto notequeue = current_section_->notes.begin(); notequeue != current_section_->notes.end(); ++notequeue) { int index = notequeue - current_section_->notes.begin(); // If there are any notes remaining in the current section if (!notequeue->empty()) { // Get the next one auto next_onset_offset = notequeue->front().offset; // If the next notes offset is less than the current approach offset if (current_approach_offset > next_onset_offset) { // Just spawn a random note if (settings_.duncan_factor) SpawnNote(note_paths_[rand() % note_paths_.size()]); else SpawnNote(note_paths_[index]); notequeue->pop(); } } } } else { Log::Error("Notequeue vector is empty."); } if (!settings_.auto_play) { for (int index = 0; index < note_paths_.size(); ++index) { if (sfx::Global::Input.KeyPressed(settings_.keybinds[index])) { AttemptNoteHit(note_paths_[index]); } } } for (auto &beat : beats_) { beat.UpdatePosition(_delta_time); beat.offset_from_perfect -= sf::seconds(_delta_time); } while (!beats_.empty() && beats_.front().offset_from_perfect < sf::Time::Zero) { beats_.erase(beats_.begin()); } // Update note positions and remove offscreen notes for (auto &path : note_paths_) { for (auto &note : path.notes) { note.UpdatePosition(_delta_time); note.offset_from_perfect -= sf::seconds(_delta_time); if (!note.VerifyPosition(machine_.window_)) { // Note went offscreen, so it's a miss if (hit_combo_ > 10) PlayMissSound(); hit_combo_ = 0; misses_++; } if (settings_.auto_play && note.offset_from_perfect < sf::Time::Zero) { AttemptNoteHit(path); } } auto path_index = path.notes.begin(); while (path_index != path.notes.end()) { if (path_index->visibility() == false) { path_index = path.notes.erase(path_index); } else ++path_index; } } } } else if (time_elapsed > beatmap_->music_->getDuration() + settings_.countdown_time) { beatmap_->music_->stop(); play_clock_.Stop(); finished_ = true; } } if (!active_sounds_.empty()) { for (auto iterator = active_sounds_.begin(); iterator != active_sounds_.end();) { if ((*iterator)->getStatus() == sf::Sound::Stopped) { iterator = active_sounds_.erase(iterator); } if (iterator != active_sounds_.end()) iterator++; } } } return true; } void GameState::Render(const float _delta_time) { for (auto beat : beats_) { machine_.window_.draw(beat); } for (auto path : note_paths_) { machine_.window_.draw(path.target); for (auto note : path.notes) { machine_.window_.draw(note); } } auto time_elapsed = play_clock_.GetTimeElapsed(); if (time_elapsed < settings_.countdown_time) { countdown_text_.setString("Countdown: " + agn::to_string_precise(settings_.countdown_time.asSeconds() - time_elapsed.asSeconds(), 1)); countdown_text_.setPosition(sf::Vector2f(0.0f, window_centre.y)); machine_.window_.draw(countdown_text_); } switch (settings_.progress_bar_position) { case GameSettings::TOPRIGHT: ImGui::SetNextWindowPos(ImVec2(window_size.x * 0.9f, 120)); ImGui::SetNextWindowSize(ImVec2(window_size.x * 0.1f, 10)); break; case GameSettings::ALONGTOP: ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(window_size.x, 10)); break; case GameSettings::ALONGBOTTOM: ImGui::SetNextWindowPos(ImVec2(0, window_size.y - 30)); ImGui::SetNextWindowSize(ImVec2(window_size.x , 10)); break; } if (!ImGui::Begin("Progress", &settings_.show_progress_bar, ImVec2(0.0f, 0.0f), 0.3f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings)) { ImGui::End(); return; } ImGui::ProgressBar(time_elapsed / beatmap_->music_->getDuration()); ImGui::End(); score_text_.setString("Score: " + std::to_string(score_)); score_text_.move(-(score_text_.getGlobalBounds().width + 15.0f), (score_text_.getGlobalBounds().top)); machine_.window_.draw(score_text_); score_text_.move((score_text_.getGlobalBounds().width + 15.0f), -(score_text_.getGlobalBounds().top)); clock_text_.setString(agn::to_string_precise(play_clock_.GetTimeElapsed().asSeconds(), 3) + "s"); clock_text_.move(-(clock_text_.getGlobalBounds().width + 15.0f), (score_text_.getLocalBounds().height)); machine_.window_.draw(clock_text_); clock_text_.move((clock_text_.getGlobalBounds().width + 15.0f), -(score_text_.getLocalBounds().height)); performance_text_.setPosition(sf::Vector2f(5.0f, window_size.y - performance_y_offset * 15 - 5.0f)); for (int index = 0; index < performance_statistic_count; ++index) { switch (index) { case 0: performance_text_.setString("Combo: " + std::to_string(hit_combo_)); performance_text_.setColor(sf::Color::White); break; case 1: performance_text_.setString("Max Combo: " + std::to_string(max_combo_)); performance_text_.setColor(sf::Color::White); performance_text_.move(0.0f, (performance_y_offset)); break; case 2: performance_text_.setString("Hits: " + std::to_string(hits_.size())); performance_text_.setColor(sf::Color::White); break; case 3: performance_text_.setString("Perfect: " + std::to_string(perfect_hits_)); performance_text_.setColor(sf::Color::Cyan); break; case 4: performance_text_.setString("Great: " + std::to_string(great_hits_)); performance_text_.setColor(sf::Color::Green); break; case 5: performance_text_.setString("Good: " + std::to_string(good_hits_)); performance_text_.setColor(sf::Color::Yellow); break; case 6: performance_text_.setString("Miss: " + std::to_string(misses_)); performance_text_.setColor(sf::Color::Red); break; case 7: performance_text_.setString("-" + std::to_string(std::abs(earliest_hit_)) + "ms ~ +" + std::to_string(std::abs(latest_hit_)) + "ms"); performance_text_.setColor(sf::Color::White); performance_text_.move(0.0f, (performance_y_offset)); break; case 8: performance_text_.setString("Average: " + agn::to_string_precise(average_hit_, 2)); performance_text_.setColor(sf::Color::White); break; case 9: performance_text_.setString("Deviation: " + agn::to_string_precise(unstable_rate_, 2)); performance_text_.setColor(sf::Color::White); break; } machine_.window_.draw(performance_text_); performance_text_.move(0.0f, (performance_y_offset)); } if (paused_) { machine_.window_.draw(pause_background_); } } void GameState::ProcessEvent(sf::Event& _event) { switch (_event.type) { case sf::Event::Resized: window_size = sf::Vector2f(_event.size.width, _event.size.height); break; } } void GameState::ReloadSkin() {} bool GameState::PauseMenu() { ImGui::SetNextWindowPos(ImVec2(window_centre.x - window_size.x * 0.2f, window_centre.y)); ImGui::SetNextWindowSize(ImVec2(window_size.x * 0.4f, 400)); if (!ImGui::Begin("Pause Menu", nullptr, ImVec2(0, 0), -1.f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings)) { // Early out if the window is collapsed, as an optimization. ImGui::End(); return true; } if (!finished_) { if (ImGui::Button("Resume (Escape)", ImVec2(ImGui::GetWindowContentRegionWidth(), 60))) { paused_ = false; ImGui::End(); return true; } } if (ImGui::Button("Restart (Enter)", ImVec2(ImGui::GetWindowContentRegionWidth(), 60))) { ChangeState<GameState>(std::move(beatmap_), std::move(settings_)); ImGui::End(); return false; } if (ImGui::Button("Quit (Backspace)", ImVec2(ImGui::GetWindowContentRegionWidth(), 60))) { ChangeState<MenuState>(std::move(beatmap_)); ImGui::End(); return false; } ImGui::Spacing(); ImGui::Separator(); ImGui::Spacing(); const char* hitsounds[] = { "None", "Soft", "Deep" }; ImGui::Combo("Hitsound", &settings_.hitsound, hitsounds, 3); ImGui::SliderFloat("Music Volume", &settings_.music_volume, 0, 100); ImGui::SliderFloat("SFX Volume", &settings_.sfx_volume, 0, 100); ImGui::Spacing(); const char* barpositions[] = { "Top Right", "Along Top", "Along Bottom" }; ImGui::Combo("Progress Bar Position", &settings_.progress_bar_position, barpositions, 3); ImGui::End(); return true; } void GameState::SpawnBeat() { if (beatmap_->play_mode_ == VISUALIZATION) { beats_.emplace_back(NoteObject(sf::Vector2f(path_x + window_size.x * 0.4f, path_start_y), sf::Vector2f(path_x + window_size.x * 0.4f, path_end_y), settings_.approach_time, beat_texture_, sf::Color(255, 69, 0, 128))); beats_.back().SetDimensions(sf::Vector2f(window_size.x * 0.8f, 5.0f)); } else { beats_.emplace_back(NoteObject(sf::Vector2f(path_x + window_size.x * 0.15f, path_start_y), sf::Vector2f(path_x + window_size.x * 0.15f, path_end_y), settings_.approach_time, beat_texture_, sf::Color(255, 69, 0, 128))); beats_.back().SetDimensions(sf::Vector2f(window_size.x * 0.4f, 5.0f)); } } void GameState::SpawnNote(NotePath& _path) { _path.notes.emplace_back(NoteObject(_path.start_position, _path.target_position, _path.approach_time, _path.note_texture, _path.note_color)); if (settings_.path_count > 6) _path.notes.back().SetDimensions(sf::Vector2f(note_length, note_length)); } void GameState::AttemptNoteHit(NotePath& _path) { if (!_path.notes.empty()) { auto& note = _path.notes.front(); // Note offset is the time (in ms) that the note is offset from a perfect hit int note_offset = note.offset_from_perfect.asMilliseconds(); int abs_note_offset = abs(note.offset_from_perfect.asMilliseconds()); // Ignore press when the offset is more than 300ms if (abs_note_offset < 300) { if (abs_note_offset < 30) { perfect_hits_++; hit_combo_++; score_ += hit_combo_ * 300; PlayHitSound(); } else if (abs_note_offset < 60) { great_hits_++; hit_combo_++; score_ += hit_combo_ * 100; PlayHitSound(); } else if (abs_note_offset < 120) { good_hits_++; hit_combo_++; score_ += hit_combo_ * 50; PlayHitSound(); } else { misses_++; if (hit_combo_ > max_combo_) max_combo_ = hit_combo_; if(hit_combo_ > 10) PlayMissSound(); hit_combo_ = 0; } if (hit_combo_ > max_combo_) max_combo_ = hit_combo_; if (note_offset < latest_hit_) latest_hit_ = note_offset; if (note_offset > earliest_hit_) earliest_hit_ = note_offset; hits_.emplace_back(note_offset); auto mean = int(); for (auto hit : hits_) { mean += hit; } average_hit_ = (float)mean / (float)hits_.size(); std::vector<float> sqdiffs; for (auto hit : hits_) { auto sqdiff = float(); sqdiff = std::pow((float)hit - average_hit_, 2); sqdiffs.push_back(sqdiff); } for (auto v : sqdiffs) { unstable_rate_ += v; } unstable_rate_ /= sqdiffs.size(); unstable_rate_ = std::sqrt(unstable_rate_); // Set not visible (will get erased at end of update) note.SetVisibility(false); } } } void GameState::InitializeFourKeyMode() { // NotePath initialization note_paths_.reserve(settings_.path_count); if (settings_.flipped) { path_start_y = window_size.y; path_end_y = window_size.y * 0.1f; } else { path_start_y = 0.0f; path_end_y = window_size.y * 0.9f; } path_x = window_size.x * 0.2f; path_x_offset = window_size.x * 0.1f; for (int index = 0; index < settings_.path_count; ++index) { sf::Color note_color; switch (index) { case 0: note_color = sf::Color::Green; break; case 1: note_color = sf::Color::Red; break; case 2: note_color = sf::Color::Cyan; break; case 3: note_color = sf::Color(255, 69, 0); break; } note_paths_.emplace_back(NotePath(sf::Vector2f(path_x + path_x_offset * index, path_start_y), sf::Vector2f(path_x + path_x_offset * index, path_end_y), settings_.approach_time, 1, white_circle_texture_, note_color)); } } void GameState::InitializeVisualizationMode() { // NotePath initialization note_paths_.reserve(settings_.path_count); if (settings_.flipped) { path_start_y = window_size.y; path_end_y = window_size.y * 0.1f; } else { path_start_y = 0.0f; path_end_y = window_size.y * 0.9f; } path_x = window_size.x * 0.1f; path_x_offset = window_size.x * 0.8f / settings_.path_count; if(settings_.path_count > 5) note_length = path_x_offset * 0.75f; else if(settings_.path_count > 10) note_length = path_x_offset - 5; for (int index = 0; index < settings_.path_count; ++index) { int hue = (int)(((float)index / (float)settings_.path_count) * 360.0f); sf::Color note_color(sfx::HSL(hue, 100, 50).HSLToRGB()); note_paths_.emplace_back(NotePath(sf::Vector2f(path_x + path_x_offset * index, path_start_y), sf::Vector2f(path_x + path_x_offset * index, path_end_y), settings_.approach_time, 1, white_circle_texture_, note_color)); if (settings_.path_count > 5) note_paths_.back().target.SetDimensions(sf::Vector2f(note_length, note_length)); } } void GameState::PlayHitSound() { sf::Sound* hitsound; switch (settings_.hitsound) { case GameSettings::SOFT: hitsound = new sf::Sound(*soft_hit_sound_); break; case GameSettings::DEEP: hitsound = new sf::Sound(*deep_hit_sound_); break; } if (!settings_.hitsound == GameSettings::NONE) { hitsound->setVolume(settings_.sfx_volume); hitsound->play(); active_sounds_.emplace_back(hitsound); } } void GameState::PlayMissSound() { if (!settings_.hitsound == GameSettings::NONE) { sf::Sound* hitsound = new sf::Sound(*miss_sound_); hitsound->setVolume(settings_.sfx_volume); hitsound->play(); active_sounds_.emplace_back(hitsound); } }
26.794643
205
0.674347
Craig-J
f21222388a6463740758275ff3ae120e631f9a15
638
cpp
C++
src/RE/BSLightingShaderMaterialFacegenTint.cpp
powerof3/CommonLibVR
c84cd2c63ccba0cc88a212fe9cf86b5470b10a4f
[ "MIT" ]
null
null
null
src/RE/BSLightingShaderMaterialFacegenTint.cpp
powerof3/CommonLibVR
c84cd2c63ccba0cc88a212fe9cf86b5470b10a4f
[ "MIT" ]
null
null
null
src/RE/BSLightingShaderMaterialFacegenTint.cpp
powerof3/CommonLibVR
c84cd2c63ccba0cc88a212fe9cf86b5470b10a4f
[ "MIT" ]
null
null
null
#include "RE/BSLightingShaderMaterialFacegenTint.h" #include "RE/Offsets.h" #include "REL/Relocation.h" namespace RE { BSLightingShaderMaterialFacegenTint* BSLightingShaderMaterialFacegenTint::CreateMaterial() { auto material = malloc<BSLightingShaderMaterialFacegenTint>(); material->ctor(); material->tintColor = NiColor(1.0f, 1.0f, 1.0f); return material; } BSLightingShaderMaterialFacegenTint* BSLightingShaderMaterialFacegenTint::ctor() { using func_t = decltype(&BSLightingShaderMaterialFacegenTint::ctor); REL::Offset<func_t> func(Offset::BSLightingShaderMaterialFacegenTint::Ctor); return func(this); } }
25.52
91
0.783699
powerof3
f212eb472a77987f912edc19f46952d9c5e71b96
1,979
cpp
C++
src/cookie.cpp
kamchatka-volcano/hot_teacup
ef894b6f333364f9768f1d2477580604affada87
[ "MS-PL" ]
null
null
null
src/cookie.cpp
kamchatka-volcano/hot_teacup
ef894b6f333364f9768f1d2477580604affada87
[ "MS-PL" ]
null
null
null
src/cookie.cpp
kamchatka-volcano/hot_teacup
ef894b6f333364f9768f1d2477580604affada87
[ "MS-PL" ]
null
null
null
#include <hot_teacup/cookie.h> #include <sfun/string_utils.h> namespace http{ namespace str = sfun::string_utils; Cookie::Cookie(std::string name, std::string value, int maxAgeSec, std::string domain, std::string path) : header_("Set-Cookie", "") , name_(std::move(name)) , value_(std::move(value)) { header_.setParam(name_, value_); if (maxAgeSec >= 0) header_.setParam("Max-Age", std::to_string(maxAgeSec)); if (!domain.empty()) header_.setParam("Domain", std::move(domain)); if (!path.empty()) header_.setParam("Path", std::move(path)); header_.setParam("Version", "1"); } const std::string& Cookie::name() const { return name_; } const std::string& Cookie::value() const { return value_; } void Cookie::setDomain(std::string domain) { if (!domain.empty()) header_.setParam("Domain", std::move(domain)); } void Cookie::setPath(std::string path) { if (!path.empty()) header_.setParam("Path", std::move(path)); } void Cookie::setMaxAge(int maxAgeSec) { if (maxAgeSec >= 0) header_.setParam("Max-Age", std::to_string(maxAgeSec)); } void Cookie::remove() { header_.setParam("Expires", "Fri, 01-Jan-1971 01:00:00 GMT"); } void Cookie::secure() { header_.setParam("Secure", ""); } std::string Cookie::toString() const { return header_.toString(); } bool Cookie::operator==(const Cookie& other) const { return name_ == other.name_ && value_ == other.value_; } Cookies cookiesFromString(std::string_view input) { auto result = Cookies{}; std::vector<std::string> cookies = str::split(input, ";"); for(const std::string& cookie : cookies){ auto name = str::before(cookie, "="); auto value = str::after(cookie, "="); if (!name.empty() && !value.empty()) result.emplace_back(str::trim(name), str::trim(value)); } return result; } }
22.488636
67
0.605356
kamchatka-volcano
f2167268765ffe76e761cc6761bc607ce690351d
7,801
cpp
C++
src/nnfusion/core/operators/generic_op/generic_op_define/MaxPool.cpp
nox-410/nnfusion
0777e297299c4e7a5071dc2ee97b87adcd22840e
[ "MIT" ]
639
2020-09-05T10:00:59.000Z
2022-03-30T08:42:39.000Z
src/nnfusion/core/operators/generic_op/generic_op_define/MaxPool.cpp
QPC-database/nnfusion
99ada47c50f355ca278001f11bc752d1c7abcee2
[ "MIT" ]
252
2020-09-09T05:35:36.000Z
2022-03-29T04:58:41.000Z
src/nnfusion/core/operators/generic_op/generic_op_define/MaxPool.cpp
QPC-database/nnfusion
99ada47c50f355ca278001f11bc752d1c7abcee2
[ "MIT" ]
104
2020-09-05T10:01:08.000Z
2022-03-23T10:59:13.000Z
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #include "nnfusion/core/operators/generic_op/generic_op.hpp" REGISTER_OP(MaxPool) .infershape(nnfusion::op::infershape::unimplemented_and_not_used) /* .translate([](std::shared_ptr<graph::GNode> curr) -> std::string { auto _op = static_pointer_cast<nnfusion::op::MaxPool>(curr->get_op_ptr()); NNFUSION_CHECK_NOT_NULLPTR(_op) << "Node type is not " << curr->get_op_ptr()->get_op_type(); const auto& kernel = _op->get_window_shape(); const auto& stride = _op->get_window_movement_strides(); const auto& padding_below = _op->get_padding_below(); const auto& padding_above = _op->get_padding_above(); uint64_t padding[] = { padding_below[1], padding_below[0], padding_above[1], padding_above[0]}; return op::create_code_from_template( R"( - input("input0", @input_shape@); output(@output_shape@, topi=topi.nn.pool(args("input0"), kernel=@kernel@, stride=@stride@, padding=@padding@, pool_type="max")); )", {{"input_shape", vector_to_string(curr->get_input_shape(0))}, {"output_shape", vector_to_string(curr->get_output_shape(0))}, {"kernel", vector_to_string(kernel)}, {"stride", vector_to_string(stride)}, {"padding", vector_to_string(padding)}}); }) */ .translate_v2([](std::shared_ptr<graph::GNode> curr) -> std::string { auto _op = static_pointer_cast<nnfusion::op::MaxPool>(curr->get_op_ptr()); auto& input_shape = curr->get_input_shape(0); auto& output_shape = curr->get_output_shape(0); auto& dtype = curr->get_element_type(); bool is_1d = (output_shape.size() == 3); const bool is_nchw = _op->get_data_format() == "NCHW" ? true : false; auto& m_strides = _op->get_window_movement_strides(); auto& strides = _op->get_window_shape(); auto& padding_below = _op->get_padding_below(); auto& padding_above = _op->get_padding_above(); if (!(padding_below.size() == padding_above.size())) { return std::string(); } if (!(padding_below.size() >= 1)) { return std::string(); } if (!is_1d) { if (!(padding_below.size() == 2)) { return std::string(); } } auto expression_template = R"( @output0@@output0_layout@ >=! @input0@@input0_layout@@conditions@; )"; std::string conditions; std::string when_condition; std::string where_condition; auto output_layout = std::vector<std::string>{"N"}; auto input_layout = std::vector<std::string>{"N"}; if (is_nchw) { output_layout.push_back("C"); input_layout.push_back("C"); output_layout.push_back("HO"); input_layout.push_back("HO * " + to_string(m_strides[0]) + " + KH - " + to_string(padding_below[0])); if (padding_below[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[2] + " >=0"; } if (padding_above[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[2] + " < " + to_string(input_shape[2]); } where_condition += (where_condition.empty() ? "" : " , ") + output_layout[2] + " in " + to_string(output_shape[2]) + ", KH in " + to_string(strides[0]); if (!is_1d) { output_layout.push_back("WO"); input_layout.push_back("WO * " + to_string(m_strides[1]) + " + KW - " + to_string(padding_below[1])); if (padding_below[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[3] + " >=0"; } if (padding_above[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[3] + " < " + to_string(input_shape[3]); } where_condition += (where_condition.empty() ? "" : " , ") + output_layout[3] + " in " + to_string(output_shape[3]) + ", KW in " + to_string(strides[1]); } } else { output_layout.push_back("HO"); input_layout.push_back("HO * " + to_string(m_strides[0]) + " + KH - " + to_string(padding_below[0])); if (padding_below[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[1] + " >=0"; } if (padding_above[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[1] + " < " + to_string(input_shape[1]); } where_condition += (where_condition.empty() ? "" : " , ") + output_layout[1] + " in " + to_string(output_shape[1]) + ", KH in " + to_string(strides[0]); if (!is_1d) { output_layout.push_back("WO"); input_layout.push_back("WO * " + to_string(m_strides[1]) + " + KW - " + to_string(padding_below[1])); if (padding_below[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[2] + " >=0"; } if (padding_above[0] > 0) { when_condition += (when_condition.empty() ? "" : " , ") + input_layout[2] + " < " + to_string(input_shape[2]); } where_condition += (where_condition.empty() ? "" : " , ") + output_layout[2] + " in " + to_string(output_shape[2]) + ", KW in " + to_string(strides[1]); } output_layout.push_back("C"); input_layout.push_back("C"); } if (!when_condition.empty()) { std::string min_value; if (dtype == nnfusion::element::f32) { min_value = "-3.4e38"; } else if (dtype == nnfusion::element::f16) { min_value = "-6.55e4"; } else if (dtype == nnfusion::element::i8) { min_value = "-128"; } else { NNFUSION_LOG(INFO) << "not support padding with data type " << dtype << " yet, fallback"; return std::string(); } when_condition = ".when([" + when_condition + "], " + min_value + ")"; } if (!where_condition.empty()) { where_condition = " where " + where_condition; } conditions = when_condition + where_condition; op::OpConfig::any config; config["conditions"] = conditions; config["output0_layout"] = vector_to_string<std::vector<std::string>>(output_layout); config["input0_layout"] = vector_to_string<std::vector<std::string>>(input_layout); auto expression_code = op::create_code_from_template(expression_template, config); return expression_code; });
43.099448
182
0.483912
nox-410
f217aaea17f8a57ecb3b96c89935b9862d806b2b
2,485
cpp
C++
src/blinkit/blink/renderer/platform/shared_buffer.cpp
titilima/blink
2de70073edfe0e1e0aaf2bb22b5d6abd9b776fad
[ "MIT" ]
13
2020-04-21T13:14:00.000Z
2021-11-13T14:55:12.000Z
src/blinkit/blink/renderer/platform/shared_buffer.cpp
titilima/blink
2de70073edfe0e1e0aaf2bb22b5d6abd9b776fad
[ "MIT" ]
null
null
null
src/blinkit/blink/renderer/platform/shared_buffer.cpp
titilima/blink
2de70073edfe0e1e0aaf2bb22b5d6abd9b776fad
[ "MIT" ]
4
2020-04-21T13:15:43.000Z
2021-11-13T14:55:00.000Z
// ------------------------------------------------- // BlinKit - BlinKit Library // ------------------------------------------------- // File Name: shared_buffer.cpp // Description: SharedBuffer Class // Author: Ziming Li // Created: 2019-09-29 // ------------------------------------------------- // Copyright (C) 2019 MingYang Software Technology. // ------------------------------------------------- #include "./SharedBuffer.h" #include "third_party/zed/include/zed/memory.hpp" namespace blink { SharedBuffer::SharedBuffer(const char *data, size_t length) { if (length > 0) append(data, length); } std::shared_ptr<SharedBuffer> SharedBuffer::adoptVector(std::vector<char> &v) { auto ret = create(); if (ret) ret->m_data.swap(v); return ret; } void SharedBuffer::append(const char *data, size_t length) { ASSERT(length > 0); size_t oldLength = m_data.size(); m_data.resize(oldLength + length); memcpy(m_data.data() + oldLength, data, length); } std::shared_ptr<SharedBuffer> SharedBuffer::create(void) { return zed::wrap_shared(new SharedBuffer); } std::shared_ptr<SharedBuffer> SharedBuffer::create(const char *data, size_t length) { return zed::wrap_shared(new SharedBuffer(data, length)); } std::shared_ptr<SharedBuffer> SharedBuffer::create(const unsigned char* data, size_t length) { return zed::wrap_shared(new SharedBuffer(reinterpret_cast<const char *>(data), length)); } size_t SharedBuffer::getSomeData(const char *&data, size_t position) const { if (position >= m_data.size()) { data = nullptr; return 0; } ASSERT(position < m_data.size()); data = m_data.data(); return m_data.size(); } bool SharedBuffer::isLocked(void) const { return true; // BKTODO: Check the logic. } #ifdef BLINKIT_UI_ENABLED PassRefPtr<SkData> SharedBuffer::getAsSkData() const { size_t bufferLength = size(); SkData *data = SkData::NewUninitialized(bufferLength); char *buffer = static_cast<char *>(data->writable_data()); const char *segment = nullptr; size_t position = 0; while (size_t segmentSize = getSomeData(segment, position)) { memcpy(buffer + position, segment, segmentSize); position += segmentSize; } if (position != bufferLength) { ASSERT_NOT_REACHED(); // Don't return the incomplete SkData. return nullptr; } return adoptRef(data); } #endif } // namespace blink
24.85
92
0.616901
titilima
35eb358a8aa5bf3c0da7d1e0e8f6f987445bfe82
1,081
hxx
C++
time.hxx
Arcoth/VTMPL
d83e4c6ab2e931bce60761997c782d6679a7cba4
[ "BSL-1.0" ]
null
null
null
time.hxx
Arcoth/VTMPL
d83e4c6ab2e931bce60761997c782d6679a7cba4
[ "BSL-1.0" ]
null
null
null
time.hxx
Arcoth/VTMPL
d83e4c6ab2e931bce60761997c782d6679a7cba4
[ "BSL-1.0" ]
null
null
null
/* Copyright (c) Arcoth, 2013-2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef TIME_HXX_INCLUDED #define TIME_HXX_INCLUDED #include "string.hxx" #include "parsers.hxx" namespace vtmpl { template <typename format = VTMPL_STRING("HhMmSs")> constexpr std::uintmax_t time() { using str = VTMPL_STRING( __TIME__ ); auto const Hh = parse_unsigned<str>().first; auto const Mm = parse_unsigned<str>(3).first; auto const Ss = parse_unsigned<str>(6).first; std::uintmax_t rval = 0; for (auto c : format::array) { rval *= 10; if( isdigit(c) ) rval += c - '0'; else switch(c) { case 'H': rval += Hh / 10; break; case 'h': rval += Hh % 10; break; case 'M': rval += Mm / 10; break; case 'm': rval += Mm % 10; break; case 'S': rval += Ss / 10; break; case 's': rval += Ss % 10; break; default: vtmpl::assert(0, "Invalid time format string!"); } } return rval; } } #endif // TIME_HXX_INCLUDED
20.788462
91
0.629047
Arcoth
35f767f33774d158c13387495c68f16022c9407f
209
cpp
C++
src/module_args/args_args.cpp
Sonotsugipaa/csono
7e08734b982bc22758ee76fc09ade46f67195e8a
[ "MIT" ]
null
null
null
src/module_args/args_args.cpp
Sonotsugipaa/csono
7e08734b982bc22758ee76fc09ade46f67195e8a
[ "MIT" ]
null
null
null
src/module_args/args_args.cpp
Sonotsugipaa/csono
7e08734b982bc22758ee76fc09ade46f67195e8a
[ "MIT" ]
null
null
null
#include <csono/args.hpp> namespace csono { Argument::Argument(): a_value(), a_position(-1) { } Argument::Argument(std::string val, unsigned pos): a_value(std::move(val)), a_position(pos) { } }
13.933333
52
0.650718
Sonotsugipaa
35ffc9324e782737a9bb66b6ab459d3809c006d4
720
cpp
C++
src/ext/openexr/Contrib/Photoshop/src/framework/PSAutoBuffer.cpp
tomoya5296/pbrt-cv
f5078db1e42bb8305aa386bda1ba26c528dec489
[ "BSD-2-Clause" ]
21
2016-12-14T09:46:27.000Z
2021-12-28T10:05:04.000Z
src/ext/openexr/Contrib/Photoshop/src/framework/PSAutoBuffer.cpp
tomoya5296/pbrt-cv
f5078db1e42bb8305aa386bda1ba26c528dec489
[ "BSD-2-Clause" ]
2
2015-10-09T19:13:25.000Z
2018-12-25T17:16:54.000Z
src/ext/openexr/Contrib/Photoshop/src/framework/PSAutoBuffer.cpp
tomoya5296/pbrt-cv
f5078db1e42bb8305aa386bda1ba26c528dec489
[ "BSD-2-Clause" ]
15
2015-02-23T16:35:28.000Z
2022-03-25T13:40:33.000Z
// =========================================================================== // PSAutoBuffer.cp Part of OpenEXR // =========================================================================== // #if MSWindows #pragma warning (disable: 161) #endif #include "PSAutoBuffer.h" #include <new> PSAutoBuffer::PSAutoBuffer ( int32 inSize, BufferProcs* inProcs ) { OSErr err; mBufferID = 0; mProcs = inProcs; err = mProcs->allocateProc (inSize, &mBufferID); if (err != noErr) { throw std::bad_alloc(); } } PSAutoBuffer::~PSAutoBuffer () { if (mBufferID != 0) { mProcs->freeProc (mBufferID); mBufferID = 0; } } Ptr PSAutoBuffer::Lock () { return mProcs->lockProc (mBufferID, false); }
15.319149
78
0.506944
tomoya5296
c402b271c528f3f30ac1d07b1a9ade6e3719f17d
1,291
cpp
C++
ml_belowzerosrc/src/sys/_windows/msys_debugOS.cpp
mudlord/demos
359bada56a27ddbd4fcb846c0ff34bc474cb7f05
[ "Unlicense" ]
20
2017-12-12T16:37:25.000Z
2022-02-19T10:35:46.000Z
ml_noisecorpsesrc/src/sys/_windows/msys_debugOS.cpp
mudlord/demos
359bada56a27ddbd4fcb846c0ff34bc474cb7f05
[ "Unlicense" ]
null
null
null
ml_noisecorpsesrc/src/sys/_windows/msys_debugOS.cpp
mudlord/demos
359bada56a27ddbd4fcb846c0ff34bc474cb7f05
[ "Unlicense" ]
7
2017-12-29T23:19:18.000Z
2021-08-17T09:53:15.000Z
//--------------------------------------------------------------------------// // iq . 2003/2008 . code for 64 kb intros by RGBA // //--------------------------------------------------------------------------// #ifdef DEBUG #include <windows.h> #include <stdio.h> #include <stdarg.h> #include "../msys_debug.h" static FILE *fp; int msys_debugInit( void ) { fp = fopen( "debug.txt", "wt" ); if( !fp ) return( 0 ); fprintf( fp, "debug file\n" ); fprintf( fp, "-------------------------\n" ); fflush( fp ); return( 1 ); } void msys_debugEnd( void ) { fprintf( fp, "-------------------------\n" ); fflush( fp ); fclose( fp ); } void msys_debugPrintf( char *format, ... ) { va_list arglist; va_start( arglist, format ); vfprintf( fp, format, arglist ); fflush( fp ); va_end( arglist ); } void msys_debugCheckfor( bool expression, char *format, ... ) { char str[1024]; if( !expression ) { va_list arglist; va_start( arglist, format ); vsprintf( str, format, arglist ); va_end( arglist ); msys_debugHaltProgram( str ); } } void msys_debugHaltProgram( char *str ) { MessageBox( 0, str, "error", MB_OK ); DebugBreak(); } #endif
19.861538
78
0.464756
mudlord
c404f608c89c74c706284a3c2458289f6764d91d
1,021
hpp
C++
files/src/app-helpers/cpp/ezored/helpers/MapHelper.hpp
Leo-Neves/ezored
924a6c10bdedd9d3115b31cb56c81c671f524c49
[ "MIT" ]
null
null
null
files/src/app-helpers/cpp/ezored/helpers/MapHelper.hpp
Leo-Neves/ezored
924a6c10bdedd9d3115b31cb56c81c671f524c49
[ "MIT" ]
null
null
null
files/src/app-helpers/cpp/ezored/helpers/MapHelper.hpp
Leo-Neves/ezored
924a6c10bdedd9d3115b31cb56c81c671f524c49
[ "MIT" ]
null
null
null
#pragma once #include <iostream> #include <sstream> #include <string> #include <unordered_map> #include <vector> #include "rapidjson/document.h" using std::string; using std::unordered_map; using std::vector; using rapidjson::Document; namespace ezored { namespace helpers { class MapHelper { public: virtual ~MapHelper() {} static Document toJson(const string &data); static string toString(const Document &json); static string toJsonString(const unordered_map<string, string> &data); static unordered_map<string, string> fromJsonString(const string &data); static string getValue(const string &key, const unordered_map<string, string> &data, const string &defaultValue); static string getString(const string key, const Document &data); static int getInt(const string &key, const Document &data); static double getDouble(const string &key, const Document &data); static bool getBool(const string &key, const Document &data); }; } // namespace helpers } // namespace ezored
26.179487
117
0.742409
Leo-Neves
c40c540782938c034f29377cfd660fbb877bbc01
394
cpp
C++
Solutions/CF1543D1.cpp
SamuNatsu/icpc-solution
17facc464a042026ff117ab33b439e87615de74b
[ "MIT" ]
null
null
null
Solutions/CF1543D1.cpp
SamuNatsu/icpc-solution
17facc464a042026ff117ab33b439e87615de74b
[ "MIT" ]
null
null
null
Solutions/CF1543D1.cpp
SamuNatsu/icpc-solution
17facc464a042026ff117ab33b439e87615de74b
[ "MIT" ]
null
null
null
#include <cstdio> int t, n, k, r; int main() { scanf("%d", &t); while (t--) { scanf("%d%d", &n, &k); int q = 0, lst = 0; for (int i = 0; i < n; ++i) { q = lst ^ i; lst ^= q; printf("%d\n", q); fflush(stdout); scanf("%d", &r); if (r) break; } } return 0; }
17.909091
37
0.307107
SamuNatsu
c40d812bb32a7fde40a87b21fa899cad836e5948
348
cc
C++
leetcode/leetcode_218.cc
math715/arts
ff73ccb7d67f7f7c87150204e15aeb46047f0e02
[ "MIT" ]
null
null
null
leetcode/leetcode_218.cc
math715/arts
ff73ccb7d67f7f7c87150204e15aeb46047f0e02
[ "MIT" ]
null
null
null
leetcode/leetcode_218.cc
math715/arts
ff73ccb7d67f7f7c87150204e15aeb46047f0e02
[ "MIT" ]
null
null
null
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <map> using namespace std; vector<pair<int, int>> getSkyline(vector<vector<int>>& buildings) { vector<pair<int, int>> result; int buildings idx = 0; while (true) { } return result; } int main( int argc, char *argv[] ) { return 0; }
15.818182
67
0.637931
math715
c4165c13cd4a8bee3f87127c8beddb720f43bd98
12,157
hpp
C++
src/framework/shared/inc/private/common/fxirp.hpp
IT-Enthusiast-Nepal/Windows-Driver-Frameworks
bfee6134f30f92a90dbf96e98d54582ecb993996
[ "MIT" ]
994
2015-03-18T21:37:07.000Z
2019-04-26T04:04:14.000Z
src/framework/shared/inc/private/common/fxirp.hpp
IT-Enthusiast-Nepal/Windows-Driver-Frameworks
bfee6134f30f92a90dbf96e98d54582ecb993996
[ "MIT" ]
9
2015-03-19T08:40:01.000Z
2019-03-24T22:54:51.000Z
src/framework/shared/inc/private/common/fxirp.hpp
IT-Enthusiast-Nepal/Windows-Driver-Frameworks
bfee6134f30f92a90dbf96e98d54582ecb993996
[ "MIT" ]
350
2015-03-19T04:29:46.000Z
2019-05-05T23:26:50.000Z
/*++ Copyright (c) Microsoft Corporation Module Name: FxIrp.hpp Abstract: This module implements a class for handling irps. Author: Environment: Both kernel and user mode Revision History: // A function for when not assigning MdIrp GetIrp( VOID ); VOID CompleteRequest( __in_opt CCHAR PriorityBoost=IO_NO_INCREMENT ); NTSTATUS CallDriver( __in MdDeviceObject DeviceObject ); NTSTATUS PoCallDriver( __in MdDeviceObject DeviceObject ); VOID StartNextPowerIrp( ); MdCompletionRoutine GetNextCompletionRoutine( VOID ); VOID SetCompletionRoutine( __in MdCompletionRoutine CompletionRoutine, __in PVOID Context, __in BOOLEAN InvokeOnSuccess = TRUE, __in BOOLEAN InvokeOnError = TRUE, __in BOOLEAN InvokeOnCancel = TRUE ); VOID SetCompletionRoutineEx( __in MdDeviceObject DeviceObject, __in MdCompletionRoutine CompletionRoutine, __in PVOID Context, __in BOOLEAN InvokeOnSuccess = TRUE, __in BOOLEAN InvokeOnError = TRUE, __in BOOLEAN InvokeOnCancel = TRUE ); MdCancelRoutine SetCancelRoutine( __in_opt MdCancelRoutine CancelRoutine ); // // SendIrpSynchronously achieves synchronous behavior by waiting on an // event after submitting the IRP. The event creation can fail in UM, but // not in KM. Hence, in UM the return code could either indicate event // creation failure or it could indicate the status set on the IRP by the // lower driver. In KM, the return code only indicates the status set on // the IRP by the lower lower, because event creation cannot fail. // CHECK_RETURN_IF_USER_MODE NTSTATUS SendIrpSynchronously( __in MdDeviceObject DeviceObject ); VOID CopyCurrentIrpStackLocationToNext( VOID ); VOID CopyToNextIrpStackLocation( __in PIO_STACK_LOCATION Stack ); VOID SetNextIrpStackLocation( VOID ); UCHAR GetMajorFunction( VOID ); UCHAR GetMinorFunction( VOID ); UCHAR GetCurrentStackFlags( VOID ); MdFileObject GetCurrentStackFileObject( VOID ); KPROCESSOR_MODE GetRequestorMode( VOID ); VOID SetContext( __in ULONG Index, __in PVOID Value ); VOID SetSystemBuffer( __in PVOID Value ); VOID SetUserBuffer( __in PVOID Value ); VOID SetMdlAddress( __in PMDL Value ); VOID SetFlags( __in ULONG Flags ); PVOID GetContext( __in ULONG Index ); ULONG GetFlags( VOID ); PIO_STACK_LOCATION GetCurrentIrpStackLocation( VOID ); PIO_STACK_LOCATION GetNextIrpStackLocation( VOID ); static PIO_STACK_LOCATION _GetAndClearNextStackLocation( __in MdIrp Irp ); VOID SkipCurrentIrpStackLocation( VOID ); VOID MarkIrpPending( ); BOOLEAN PendingReturned( ); VOID PropagatePendingReturned( VOID ); VOID SetStatus( __in NTSTATUS Status ); NTSTATUS GetStatus( ); BOOLEAN Cancel( VOID ); VOID SetCancel( __in BOOLEAN Cancel ); BOOLEAN IsCanceled( ); KIRQL GetCancelIrql( ); VOID SetInformation( __in ULONG_PTR Information ); ULONG_PTR GetInformation( ); CCHAR GetCurrentIrpStackLocationIndex( ); CCHAR GetStackCount( ); PLIST_ENTRY ListEntry( ); PVOID GetSystemBuffer( ); PVOID GetOutputBuffer( ); PMDL GetMdl( ); PMDL* GetMdlAddressPointer( ); PVOID GetUserBuffer( ); VOID Reuse( __in NTSTATUS Status = STATUS_SUCCESS ); // // Methods for IO_STACK_LOCATION members // VOID SetMajorFunction( __in UCHAR MajorFunction ); VOID SetMinorFunction( __in UCHAR MinorFunction ); // // Get Methods for IO_STACK_LOCATION.Parameters.Power // SYSTEM_POWER_STATE_CONTEXT GetParameterPowerSystemPowerStateContext( ); POWER_STATE_TYPE GetParameterPowerType( ); POWER_STATE GetParameterPowerState( ); DEVICE_POWER_STATE GetParameterPowerStateDeviceState( ); SYSTEM_POWER_STATE GetParameterPowerStateSystemState( ); POWER_ACTION GetParameterPowerShutdownType( ); MdFileObject GetFileObject( VOID ); // // Get/Set Method for IO_STACK_LOCATION.Parameters.QueryDeviceRelations // DEVICE_RELATION_TYPE GetParameterQDRType( ); VOID SetParameterQDRType( __in DEVICE_RELATION_TYPE DeviceRelation ); // // Get/Set Methods for IO_STACK_LOCATION.Parameters.DeviceCapabilities // PDEVICE_CAPABILITIES GetParameterDeviceCapabilities( ); VOID SetCurrentDeviceObject( __in MdDeviceObject DeviceObject ); MdDeviceObject GetDeviceObject( VOID ); VOID SetParameterDeviceCapabilities( __in PDEVICE_CAPABILITIES DeviceCapabilities ); // // Get/Set Methods for IO_STACK_LOCATION.Parameters.Write.ByteOffset.QuadPart // LONGLONG GetParameterWriteByteOffsetQuadPart( ); VOID SetNextParameterWriteByteOffsetQuadPart( __in LONGLONG DeviceOffset ); // // Get/Set Methods for IO_STACK_LOCATION.Parameters.Write.Length // ULONG GetCurrentParameterWriteLength( ); VOID SetNextParameterWriteLength( __in ULONG IoLength ); PVOID* GetNextStackParameterOthersArgument1Pointer( ); VOID SetNextStackParameterOthersArgument1( __in PVOID Argument1 ); PVOID* GetNextStackParameterOthersArgument2Pointer( ); PVOID* GetNextStackParameterOthersArgument4Pointer( ); // // Get/Set Methods for IO_STACK_LOCATION.Parameters.StartDevice // PCM_RESOURCE_LIST GetParameterAllocatedResources( ); VOID SetParameterAllocatedResources( __in PCM_RESOURCE_LIST AllocatedResources ); PCM_RESOURCE_LIST GetParameterAllocatedResourcesTranslated( ); VOID SetParameterAllocatedResourcesTranslated( __in PCM_RESOURCE_LIST AllocatedResourcesTranslated ); // // Get Method for IO_STACK_LOCATION.Parameters.QueryDeviceText // LCID GetParameterQueryDeviceTextLocaleId( ); DEVICE_TEXT_TYPE GetParameterQueryDeviceTextType( ); // // Get Method for IO_STACK_LOCATION.Parameters.SetLock // BOOLEAN GetParameterSetLockLock( ); // // Get Method for IO_STACK_LOCATION.Parameters.QueryId // BUS_QUERY_ID_TYPE GetParameterQueryIdType( ); // // Get/Set Methods for IO_STACK_LOCATION.Parameters.QueryInterface // PINTERFACE GetParameterQueryInterfaceInterface( ); const GUID* GetParameterQueryInterfaceType( ); USHORT GetParameterQueryInterfaceVersion( ); USHORT GetParameterQueryInterfaceSize( ); PVOID GetParameterQueryInterfaceInterfaceSpecificData( ); VOID SetParameterQueryInterfaceInterface( __in PINTERFACE Interface ); VOID SetParameterQueryInterfaceType( __in const GUID* InterfaceType ); VOID SetParameterQueryInterfaceVersion( __in USHORT Version ); VOID SetParameterQueryInterfaceSize( __in USHORT Size ); VOID SetParameterQueryInterfaceInterfaceSpecificData( __in PVOID InterfaceSpecificData ); // // Get Method for IO_STACK_LOCATION.Parameters.UsageNotification // DEVICE_USAGE_NOTIFICATION_TYPE GetParameterUsageNotificationType( ); BOOLEAN GetParameterUsageNotificationInPath( ); VOID SetParameterUsageNotificationInPath( __in BOOLEAN InPath ); BOOLEAN GetNextStackParameterUsageNotificationInPath( ); ULONG GetParameterIoctlCode( VOID ); ULONG GetParameterIoctlCodeBufferMethod( VOID ); ULONG GetParameterIoctlInputBufferLength( VOID ); ULONG GetParameterIoctlOutputBufferLength( VOID ); PVOID GetParameterIoctlType3InputBuffer( VOID ); // // Set Methods for IO_STACK_LOCATION.Parameters.DeviceControl members // VOID SetParameterIoctlCode( __in ULONG DeviceIoControlCode ); VOID SetParameterIoctlInputBufferLength( __in ULONG InputBufferLength ); VOID SetParameterIoctlOutputBufferLength( __in ULONG OutputBufferLength ); VOID SetParameterIoctlType3InputBuffer( __in PVOID Type3InputBuffer ); ULONG GetParameterReadLength( VOID ); ULONG GetParameterWriteLength( VOID ); VOID SetNextStackFlags( __in UCHAR Flags ); VOID SetNextStackFileObject( _In_ MdFileObject FileObject ); PVOID GetCurrentParametersPointer( VOID ); // // Methods for IO_STACK_LOCATION // VOID ClearNextStack( VOID ); VOID ClearNextStackLocation( VOID ); VOID InitNextStackUsingStack( __in FxIrp* Irp ); ULONG GetCurrentFlags( VOID ); VOID FreeIrp( VOID ); MdEThread GetThread( VOID ); BOOLEAN Is32bitProcess( VOID ); private: static NTSTATUS _IrpSynchronousCompletion( __in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp, __in PVOID Context ); public: _Must_inspect_result_ static MdIrp AllocateIrp( _In_ CCHAR StackSize, _In_opt_ FxDevice* Device = NULL ); static MdIrp GetIrpFromListEntry( __in PLIST_ENTRY Ple ); _Must_inspect_result_ static NTSTATUS RequestPowerIrp( __in MdDeviceObject DeviceObject, __in UCHAR MinorFunction, __in POWER_STATE PowerState, __in MdRequestPowerComplete CompletionFunction, __in PVOID Context ); PIO_STATUS_BLOCK GetStatusBlock( VOID ); PVOID GetDriverContext( ); ULONG GetDriverContextSize( ); VOID CopyParameters( _Out_ PWDF_REQUEST_PARAMETERS Parameters ); VOID CopyStatus( _Out_ PIO_STATUS_BLOCK StatusBlock ); BOOLEAN HasStack( _In_ UCHAR StackCount ); BOOLEAN IsCurrentIrpStackLocationValid( VOID ); #if (FX_CORE_MODE == FX_CORE_USER_MODE) IWudfIoIrp* GetIoIrp( VOID ); IWudfIoIrp2* GetIoIrp2( VOID ); IWudfPnpIrp* GetPnpIrp( VOID ); #endif }; // // FxAutoIrp adds value to FxIrp by automatically freeing the associated MdIrp // when it goes out of scope // struct FxAutoIrp : public FxIrp { FxAutoIrp( __in_opt MdIrp Irp = NULL ) : FxIrp(Irp) { } ~FxAutoIrp(); }; #endif // _FXIRP_H_
14.302353
81
0.591182
IT-Enthusiast-Nepal
c41a5ca1692f2e46445f7554bebb80107923a3a9
2,571
cpp
C++
AliceEngine/ALC/Rendering/Camera.cpp
ARAMODODRAGON/Project-Alice
49d3189ba065911c8495cfb04761a2050d3a0702
[ "MIT" ]
null
null
null
AliceEngine/ALC/Rendering/Camera.cpp
ARAMODODRAGON/Project-Alice
49d3189ba065911c8495cfb04761a2050d3a0702
[ "MIT" ]
null
null
null
AliceEngine/ALC/Rendering/Camera.cpp
ARAMODODRAGON/Project-Alice
49d3189ba065911c8495cfb04761a2050d3a0702
[ "MIT" ]
null
null
null
/* * MIT License * * Copyright (c) 2021 Domara Shlimon * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "Camera.hpp" #include <glm\gtc\matrix_transform.hpp> #include "../SceneManager.hpp" namespace ALC { Camera::Camera() : m_position(0.0f), m_size(0.0f) { m_size = SceneManager::GetWindow()->GetScreenSize(); } Camera::~Camera() { } vec2 Camera::GetPosition() { return m_position; } void Camera::SetPosition(const vec2& position_) { m_position = position_; } vec2 Camera::GetCameraSize() const { return m_size; } void Camera::SetCameraSize(const vec2& size_) { m_size = size_; } mat4 Camera::GetTransform() const { mat4 transform(1.0f); // create the view transform = glm::translate(transform, -vec3(m_position, 0.0f)); // create the ortho vec2 halfsize = m_size * 0.5f; transform = transform * glm::ortho(-halfsize.x, halfsize.x, -halfsize.y, halfsize.y); // return the transform return transform; } mat4 Camera::GetScreenToWorld() const { return GetScreenToWorld(SceneManager::GetWindow()->GetScreenSize()); } mat4 Camera::GetScreenToWorld(const vec2& screensize) const { mat4 screen = glm::ortho(0.0f, screensize.x, 0.0f, screensize.y); return glm::inverse(GetTransform()) * screen; } mat4 Camera::GetWorldToScreen() const { return GetWorldToScreen(SceneManager::GetWindow()->GetScreenSize()); } mat4 Camera::GetWorldToScreen(const vec2& screensize) const { mat4 screen = glm::ortho(0.0f, screensize.x, 0.0f, screensize.y); return glm::inverse(screen) * GetTransform(); } }
30.607143
87
0.731622
ARAMODODRAGON
c41b278b7639f741d3c23c2ca68c682efbed0483
248
cpp
C++
work/desenet-sensor/src/common/platform/nucleo-stm32l476rg/board/display/eplib/hal/gpio.cpp
MacherelR/DeSemProject_20212022
7314e5787a3ff2ca5bf95c6de7fbbee9598b98ea
[ "MIT" ]
null
null
null
work/desenet-sensor/src/common/platform/nucleo-stm32l476rg/board/display/eplib/hal/gpio.cpp
MacherelR/DeSemProject_20212022
7314e5787a3ff2ca5bf95c6de7fbbee9598b98ea
[ "MIT" ]
null
null
null
work/desenet-sensor/src/common/platform/nucleo-stm32l476rg/board/display/eplib/hal/gpio.cpp
MacherelR/DeSemProject_20212022
7314e5787a3ff2ca5bf95c6de7fbbee9598b98ea
[ "MIT" ]
null
null
null
#include "gpio.h" namespace ep { /** * @brief Construct a new GPIO object * * @param p1 Pin Number * @param port Port Name */ Gpio::Gpio(GPIO_TypeDef * port, uint32_t pin) : port(port), pin(pin) { } } // namespace ep
13.052632
48
0.580645
MacherelR
c421c8527b0bdf126b1a2b03027c289b903f9398
13,627
cxx
C++
test/font_test/font_test.cxx
henne90gen/cgv
31995e9f09d093f9997980093452a5424d0c1319
[ "BSD-3-Clause" ]
null
null
null
test/font_test/font_test.cxx
henne90gen/cgv
31995e9f09d093f9997980093452a5424d0c1319
[ "BSD-3-Clause" ]
null
null
null
test/font_test/font_test.cxx
henne90gen/cgv
31995e9f09d093f9997980093452a5424d0c1319
[ "BSD-3-Clause" ]
null
null
null
#include <cgv/base/node.h> #include <cgv/base/register.h> #include <cgv/gui/event_handler.h> #include <cgv/gui/provider.h> #include <cgv/gui/key_event.h> #include <cgv/gui/mouse_event.h> #include <cgv/utils/file.h> #include <cgv/utils/dir.h> #include <cgv/render/drawable.h> #include <cgv/render/attribute_array_binding.h> #include <cgv_gl/gl/gl.h> #include <cgv_gl/rectangle_renderer.h> #include <cgv/math/ftransform.h> #include <cgv/media/image/image_writer.h> #include <cgv/media/color_scale.h> #include <libs/tt_gl_font/tt_gl_font.h> // include self reflection helpers of used types (here vec3 & rgb) #include <libs/cgv_reflect_types/math/fvec.h> #include <libs/cgv_reflect_types/media/color.h> class font_test : public cgv::base::node, public cgv::render::drawable, public cgv::base::argument_handler, public cgv::gui::event_handler, public cgv::gui::provider { protected: /// helper member to support loading individual truetype files std::string font_file_name; /// helper member to support scanning of specific font directories std::string font_directory; /// currently chosen font int font_idx; /// pointer to current font cgv::tt_gl_font_ptr font_ptr; /// font face selector cgv::media::font::FontFaceAttributes ffa; /// pointer to current font face cgv::tt_gl_font_face_ptr font_face_ptr; /// rasterization size of font float font_size; /// whether to use blending during font rendering bool use_blending; /// render style for drawing font onto cube cgv::render::rectangle_render_style rrs; /// to be drawn text std::string text; /// whether to use per character colors when drawing text bool use_colors; /// screen location in pixel coordinates ivec2 pixel_position; /// subpixel offset that allows to debug font rendering results if texels and pixels are not aligned vec2 subpixel_offset; /// whether to show lines bool show_lines; /// y-pixel coordinate to start drawing lines int fst_line; /// y-pixel offset between successive lines unsigned line_delta; /// whether to show cube bool show_cube; void render_textured_quads(cgv::render::context& ctx, cgv::render::rectangle_render_style& _rrs, const std::vector<cgv::render::textured_rectangle>& Q, const std::vector<rgba>* colors_ptr = 0, const std::vector<vec3>* translations_ptr = 0, const std::vector<quat>* rotations_ptr = 0) { auto& rr = cgv::render::ref_rectangle_renderer(ctx); rr.set_render_style(_rrs); rr.set_textured_rectangle_array(ctx, Q); font_face_ptr->ref_texture(ctx).enable(ctx); if (colors_ptr) rr.set_color_array(ctx, *colors_ptr); if (translations_ptr) rr.set_translation_array(ctx, *translations_ptr); if (rotations_ptr) rr.set_rotation_array(ctx, *rotations_ptr); GLboolean blend; GLenum blend_src, blend_dst, depth; if (use_blending) { blend = glIsEnabled(GL_BLEND); glEnable(GL_BLEND); glGetIntegerv(GL_BLEND_DST, reinterpret_cast<GLint*>(&blend_dst)); glGetIntegerv(GL_BLEND_SRC, reinterpret_cast<GLint*>(&blend_src)); glGetIntegerv(GL_DEPTH_FUNC, reinterpret_cast<GLint*>(&depth)); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthFunc(GL_LEQUAL); } rr.render(ctx, 0, Q.size()); if (use_blending) { if (!blend) glDisable(GL_BLEND); glDepthFunc(depth); glBlendFunc(blend_src, blend_dst); } font_face_ptr->ref_texture(ctx).disable(ctx); } public: font_test() : node("font test") { font_idx = 0; ffa = cgv::media::font::FFA_REGULAR; font_size = 32.0f; use_blending = true; on_set(&font_idx); // ensure that font and font face pointers are set text = "This demo shows how to render text with the tt_gl_font library including <�������>!"; pixel_position = ivec2(100, 100); use_colors = true; subpixel_offset = vec2(0.0f); show_lines = true; fst_line = 100; line_delta = 40; show_cube = true; rrs.surface_color = rgba(1, 0, 1, 1); rrs.pixel_blend = 0.0f; rrs.texture_mode = 1; rrs.default_depth_offset = -0.0000001f; rrs.border_color = rgba(0, 0, 0, 0); rrs.map_color_to_material = cgv::render::CM_COLOR_AND_OPACITY; rrs.illumination_mode = cgv::render::IM_OFF; } void on_set(void* member_ptr) { if (member_ptr == &font_file_name) read_font(font_file_name); if (member_ptr == &font_directory) { cgv::scan_fonts(font_directory); font_idx = 0; on_set(&font_idx); post_recreate_gui(); } if (member_ptr == &ffa) font_face_ptr = font_ptr->get_font_face(ffa).up_cast<cgv::tt_gl_font_face>(); if (member_ptr == &font_idx) { font_ptr = cgv::find_font(cgv::get_font_names()[font_idx]); font_ptr->set_font_size(font_size); bool first = true; std::string ffa_enum; static const char* ffa_names[4] = { "regular","bold","italic","bolditalic" }; for (int _ffa = 0; _ffa < 4; ++_ffa) { if (font_ptr->supports_font_face(_ffa)) { if (first) first = false; else ffa_enum += ','; ffa_enum += ffa_names[_ffa]; } } if (find_control(ffa)) find_control(ffa)->set("enums", ffa_enum); while (!font_ptr->supports_font_face(ffa)) ffa = cgv::media::font::FontFaceAttributes(((int)ffa + 1) % 4); update_member(&ffa); font_face_ptr = font_ptr->get_font_face(ffa).up_cast<cgv::tt_gl_font_face>(); } if (font_ptr) { if (member_ptr == &font_size) { font_ptr->set_font_size(font_size); } } update_member(member_ptr); post_redraw(); } bool read_font(const std::string& file_name) { cgv::tt_gl_font_face_ptr new_font_face_ptr = new cgv::tt_gl_font_face(file_name, font_size); if (new_font_face_ptr->is_valid()) { font_face_ptr = new_font_face_ptr; return true; } return false; } void handle_args(std::vector<std::string>& args) { for (auto a : args) { if (cgv::utils::file::exists(a)) { font_file_name = a; on_set(&font_file_name); } else if (cgv::utils::dir::exists(a)) { font_directory = a; on_set(&font_directory); } } // clear args vector as all args have been processed args.clear(); post_redraw(); } void stream_help(std::ostream& os) { os << "font test: toggle use_<B>lending, use_<C>olor, show_<L>ines, select font|size with left,right|up,down" << std::endl; } void stream_stats(std::ostream& os) { os << "font name = " << (font_ptr ? font_ptr->get_name() : "<empty>") << std::endl; } bool handle(cgv::gui::event& e) { if (e.get_kind() == cgv::gui::EID_KEY) { cgv::gui::key_event& ke = reinterpret_cast<cgv::gui::key_event&>(e); if (ke.get_action() == cgv::gui::KA_RELEASE) return false; switch (ke.get_key()) { case 'L': show_lines = !show_lines; on_set(&show_lines); break; case 'B': use_blending = !use_blending; on_set(&use_blending); break; case 'C': use_colors = !use_colors; on_set(&use_colors); break; case cgv::gui::KEY_Up: if (ke.get_modifiers() == 0) { font_size *= 1.2f; on_set(&font_size); return true; } break; case cgv::gui::KEY_Down: if (ke.get_modifiers() == 0) { font_size /= 1.2f; on_set(&font_size); return true; } break; case cgv::gui::KEY_Right: if (ke.get_modifiers() == 0) { if (font_idx + 1 < cgv::get_font_names().size()) { ++font_idx; on_set(&font_idx); } return true; } break; case cgv::gui::KEY_Left: if (ke.get_modifiers() == 0) { if (font_idx > 0) { --font_idx; on_set(&font_idx); } return true; } break; } } return false; } std::string get_type_name() const { return "font_test"; } bool self_reflect(cgv::reflect::reflection_handler& rh) { return rh.reflect_member("font_idx", font_idx) && rh.reflect_member("text", text) && rh.reflect_member("use_blending", use_blending) && rh.reflect_member("rrs", rrs) && rh.reflect_member("font_file_name", font_file_name) && rh.reflect_member("font_directory", font_directory) && rh.reflect_member("font_size", font_size); } bool init(cgv::render::context& ctx) { cgv::render::ref_rectangle_renderer(ctx, 1); return true; } void clear(cgv::render::context& ctx) { cgv::render::ref_rectangle_renderer(ctx, -1); } void draw(cgv::render::context& ctx) { if (show_cube) { // render cube first auto& surf_prog = ctx.ref_surface_shader_program(); surf_prog.enable(ctx); ctx.tesselate_unit_cube(true); surf_prog.disable(ctx); // then render numbers onto sides if (font_face_ptr) { std::vector<cgv::render::textured_rectangle> Q; vec2 p(0.0f); box2 R; std::vector<vec3> positions; std::vector<quat> rotations; std::vector<rgba> colors; for (int i = 0; i < 6; ++i) { std::string t(1, (char)('1' + i)); font_face_ptr->text_to_quads(p, t, Q); Q.back().rectangle.translate(-Q.back().rectangle.get_center()); R.add_axis_aligned_box(Q.back().rectangle); // select z axis and offset as well as other axes int z_axis = i / 2; int delta = 2 * (i % 2) - 1; int x_axis = (z_axis + 1) % 3; int y_axis = (z_axis + 2) % 3; // define color rgba col(0.5f, 0.5f, 0.5f, 1.0f); col[z_axis] = 0.5f * (delta+1); colors.push_back(col); // define position in center of cube face vec3 pos(0.0f); pos[z_axis] = (float)delta; positions.push_back(pos); // define rotation of x and y axes onto cube face mat3 rot; rot.zeros(); rot(x_axis, 0) = 1.0f; rot(y_axis, 1) = 1.0f; rot(z_axis, 2) = 1.0f; rotations.push_back(quat(rot)); } // scale down quads to fit cube face float scale = 1.6f / R.get_extent()[R.get_max_extent_coord_index()]; for (auto& q : Q) q.rectangle.scale(scale); render_textured_quads(ctx, rrs, Q, &colors, &positions, & rotations); } } ctx.push_pixel_coords(); if (show_lines) { std::vector<vec3> P; std::vector<rgb> C; int y = fst_line; while (y < int(ctx.get_height())) { P.push_back(vec3(0.0f, float(y), 0.0f)); C.push_back(rgb(1, 1, 1)); P.push_back(vec3(float(ctx.get_width()), float(y), 0.0f)); C.push_back(rgb(1, 1, 1)); y += line_delta; } auto& prog = ctx.ref_default_shader_program(); cgv::render::attribute_array_binding::set_global_attribute_array(ctx, prog.get_position_index(), P); cgv::render::attribute_array_binding::set_global_attribute_array(ctx, prog.get_color_index(), C); cgv::render::attribute_array_binding::enable_global_array(ctx, prog.get_position_index()); cgv::render::attribute_array_binding::enable_global_array(ctx, prog.get_color_index()); prog.enable(ctx); glDrawArrays(GL_LINES, 0, (GLsizei)P.size()); prog.disable(ctx); cgv::render::attribute_array_binding::disable_global_array(ctx, prog.get_position_index()); cgv::render::attribute_array_binding::disable_global_array(ctx, prog.get_color_index()); } if (font_face_ptr) { ctx.mul_modelview_matrix(cgv::math::translate4<float>(subpixel_offset[0], subpixel_offset[1], 0.0f)); // default approach to draw text in single color if (!use_colors) { vec2 p = pixel_position; ctx.set_color(rrs.surface_color); font_face_ptr->enable(&ctx, font_size); font_face_ptr->draw_text(p[0], p[1], text); } else { // otherwise convert to textured rectangles std::vector<cgv::render::textured_rectangle> Q; vec2 fpix_pos(pixel_position); font_face_ptr->text_to_quads(fpix_pos, text, Q); if (!Q.empty()) { // define color array std::vector<rgba> C(Q.size()); for (size_t i = 0; i < C.size(); ++i) { float v = (float)i / (C.size() - 1); C[i] = cgv::media::color_scale(v, cgv::media::CS_HUE); } // render with default rectangle render style render_textured_quads(ctx, cgv::ref_rectangle_render_style(), Q, &C); } } } ctx.pop_pixel_coords(); } void create_gui() { add_decorator("font test", "heading", "level=1"); add_gui("font_file_name", font_file_name, "file_name"); add_gui("font_directory", font_directory, "directory"); add_member_control(this, "font", (cgv::type::DummyEnum&)font_idx, "dropdown", cgv::get_font_enum_declaration()); add_member_control(this, "font face", ffa, "dropdown", "enums='regular,bold,italic,bold+italic'"); add_member_control(this, "font_size", font_size, "value_slider", "min=6;max=128;log=true;ticks=true"); add_decorator("text", "heading", "level=2"); add_member_control(this, "use_colors", use_colors, "toggle"); add_member_control(this, "text", text); add_member_control(this, "default_text_color", rrs.surface_color); add_gui("pixel_position", pixel_position, "vector", "options='min=0;step=0.01;max=300;ticks=true'"); add_gui("subpixel_offset", subpixel_offset, "vector", "options='min=0;step=0.001;max=1;ticks=true'"); add_decorator("lines", "heading", "level=2"); add_member_control(this, "show_lines", show_lines, "toggle"); add_member_control(this, "fst_line", fst_line, "value_slider", "min=-1;max=128;ticks=true"); add_member_control(this, "line_delta", line_delta, "value_slider", "min=5;max=128;ticks=true"); add_decorator("cube", "heading", "level=2"); add_member_control(this, "show_cube", show_cube, "toggle"); add_member_control(this, "use_blending", use_blending, "toggle"); if (begin_tree_node("rectangle", rrs, true)) { align("\a"); add_gui("rectangle", rrs); align("\b"); end_tree_node(rrs); } } }; #include <cgv/base/register.h> cgv::base::object_registration<font_test> reg_font_test(""); #ifdef CGV_FORCE_STATIC cgv::base::registration_order_definition ro_def("stereo_view_interactor;font_test"); #endif
31.764569
125
0.676965
henne90gen
c422e32063934f810d7ba085a9650364c9f7c1d4
1,155
cpp
C++
luogu/P3478.cpp
delphi122/knowledge_planet
e86cb8f9aa47ef8918cde0e814984a6535023c21
[ "Apache-2.0" ]
1
2020-07-24T03:07:08.000Z
2020-07-24T03:07:08.000Z
luogu/P3478.cpp
delphi122/knowledge_planet
e86cb8f9aa47ef8918cde0e814984a6535023c21
[ "Apache-2.0" ]
null
null
null
luogu/P3478.cpp
delphi122/knowledge_planet
e86cb8f9aa47ef8918cde0e814984a6535023c21
[ "Apache-2.0" ]
null
null
null
// // Created by yangtao on 20-11-27. // #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const int N = 1e6 + 5; ll h[N], e[N*2], ne[N*2], size[N], dep[N], dp[N]; int n, idx; void add(int u, int v) { e[idx] = v, ne[idx] = h[u], h[u] = idx++; } void dfs1(int u, int f) { size[u] = 1, dep[u] = dep[f] + 1; for(int i = h[u]; ~i; i = ne[i] ) { int v = e[i]; if(v == f) continue; dfs1(v, u); size[u] += size[v]; } } void dfs2(int u, int f) { for(int i = h[u]; ~i ; i = ne[i]) { int v = e[i]; if(v == f) continue; dp[v] = dp[u] - size[v] + n - size[v]; dfs2(v, u); } } int main() { cin >> n; memset(h, -1 , sizeof(h)); for(int i = 1; i < n; i++) { int u, v; scanf("%d%d", &u, &v); add(u, v), add(v, u); } dfs1(1, 0); for(int i = 1; i <= n; i++) dp[1] += size[i]; dfs2(1, 0); ll ans = 0, mmax = 0; for(int i = 1; i <= n; i++) { if(dp[i] > mmax) { ans = i, mmax = dp[i]; } } cout << ans; return 0; }
20.625
49
0.423377
delphi122
c424bb1d9916145c4ecfbcf3106ff97b6794b842
809
cpp
C++
mp2/main.cpp
Atrifex/ECE-438
fbf2c3f51291bfa347abaa06f843e2d20d5239f6
[ "MIT" ]
2
2019-04-25T00:24:55.000Z
2019-04-25T04:35:05.000Z
mp2/main.cpp
Atrifex/ECE-438
fbf2c3f51291bfa347abaa06f843e2d20d5239f6
[ "MIT" ]
null
null
null
mp2/main.cpp
Atrifex/ECE-438
fbf2c3f51291bfa347abaa06f843e2d20d5239f6
[ "MIT" ]
1
2020-10-02T21:32:34.000Z
2020-10-02T21:32:34.000Z
#include <iostream> #include <utility> #include <thread> #include <chrono> #include <functional> #include <atomic> #include "ls_router.h" using std::thread; using std::ref; void announceToNeighbors(LS_Router & router) { router.announceToNeighbors(); } void generateLSP(LS_Router & router) { router.generateLSP(); } int main(int argc, char** argv) { if(argc != 4) { fprintf(stderr, "Usage: %s mynodeid initialcostsfile logfile\n\n", argv[0]); exit(1); } // Parse input and initialize router LS_Router router(atoi(argv[1]), argv[2], argv[3]); // start announcing thread announcer(announceToNeighbors, ref(router)); // start generating lsps thread lspGenerator(generateLSP, ref(router)); // start listening router.listenForNeighbors(); }
19.731707
84
0.672435
Atrifex
c42540e5c27ad1cc5aea128573f1731dc0b40771
3,385
cc
C++
stig/rpc/msg.cc
ctidder/stigdb
d9ef3eb117d46542745ca98c55df13ec71447091
[ "Apache-2.0" ]
5
2018-04-24T12:36:50.000Z
2020-03-25T00:37:17.000Z
stig/rpc/msg.cc
ctidder/stigdb
d9ef3eb117d46542745ca98c55df13ec71447091
[ "Apache-2.0" ]
null
null
null
stig/rpc/msg.cc
ctidder/stigdb
d9ef3eb117d46542745ca98c55df13ec71447091
[ "Apache-2.0" ]
2
2018-04-24T12:39:24.000Z
2020-03-25T00:45:08.000Z
/* <stig/rpc/msg.cc> Implements <stig/rpc/msg.h>. Copyright 2010-2014 Tagged Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <stig/rpc/msg.h> #include <stdexcept> #include <io/endian.h> using namespace std; using namespace Io; using namespace Stig::Rpc; void TMsg::Send(TSafeTransceiver *xver, int sock_fd) { assert(this); assert(xver); /* Measure up our blob. */ size_t block_count, byte_count; Blob.GetCounts(block_count, byte_count); block_count += 3; /* We'll need to send the kind, the request id, and the byte count as well as the blocks in the blob itself, so order up some iovecs. */ auto *vecs = xver->GetIoVecs(block_count), *limit = vecs + block_count; /* The first iovec holds the kind. That's just one byte, so we don't need to worry about network byte order. */ vecs->iov_base = &Kind; vecs->iov_len = sizeof(Kind); ++vecs; /* The second iovec holds the request id, in NBO. */ auto nbo_req_id = SwapEnds(ReqId); vecs->iov_base = &nbo_req_id; vecs->iov_len = sizeof(nbo_req_id); ++vecs; /* The second iovec holds the number of bytes in the blob, in NBO. */ auto nbo_byte_count = SwapEnds(static_cast<TByteCount>(byte_count)); vecs->iov_base = &nbo_byte_count; vecs->iov_len = sizeof(nbo_byte_count); ++vecs; /* The rest of the iovecs hold the blob's data blocks. Fill them in and fire away. */ Blob.InitIoVecs(vecs, limit); xver->Send(sock_fd); } TMsg TMsg::Recv(TBufferPool *buffer_pool, TSafeTransceiver *xver, int sock_fd) { assert(buffer_pool); assert(xver); /* We'll start by receiving a kind, a request id, and the number of bytes in the incoming blob. */ TKind kind; TReqId req_id; TByteCount byte_count; auto *vecs = xver->GetIoVecs(3); vecs->iov_base = &kind; vecs->iov_len = sizeof(kind); ++vecs; vecs->iov_base = &req_id; vecs->iov_len = sizeof(req_id); ++vecs; vecs->iov_base = &byte_count; vecs->iov_len = sizeof(byte_count); xver->Recv(sock_fd); /* The request id and the byte count arrived in network byte order, so it's time to do the endian dance. */ req_id = SwapEnds(req_id); byte_count = SwapEnds(byte_count); /* Check the kind we receiver to make sure it's valid. */ switch (kind) { case TKind::Request: case TKind::NormalReply: case TKind::ErrorReply: { break; } default: { throw invalid_argument("Stig RPC message arrived with unknown kind"); } } /* Make a buffer space large enough, then receive the blob into it. */ size_t block_count = (byte_count + BlockSize - 1) / BlockSize; TBlob blob(buffer_pool, byte_count); vecs = xver->GetIoVecs(block_count); auto *limit = vecs + block_count; blob.InitIoVecs(vecs, limit); xver->Recv(sock_fd); /* Construct a new message and return it. */ return move(TMsg(kind, req_id, move(blob))); }
32.864078
109
0.690694
ctidder
c4269bf3b0e39b55290bc4a407ffcc9b0cdc5a8c
641
cpp
C++
src/Evel/UdpSocket_WF.cpp
hleclerc/Evel
c607adda555f417dfc9fb4de310c07c48ea3642f
[ "Apache-2.0" ]
null
null
null
src/Evel/UdpSocket_WF.cpp
hleclerc/Evel
c607adda555f417dfc9fb4de310c07c48ea3642f
[ "Apache-2.0" ]
null
null
null
src/Evel/UdpSocket_WF.cpp
hleclerc/Evel
c607adda555f417dfc9fb4de310c07c48ea3642f
[ "Apache-2.0" ]
null
null
null
#include "UdpSocket_WF.h" namespace Evel { UdpSocket_WF::~UdpSocket_WF() { if ( f_close ) f_close( this ); } void UdpSocket_WF::on_rdy() { if ( f_rdy ) f_rdy( this ); } void UdpSocket_WF::parse( const InetAddress &src, char **data, unsigned size ) { if ( f_parse ) f_parse( this, src, data, size ); } void *UdpSocket_WF::allocate( size_t inp_buf_size ) { return f_allocate ? f_allocate( this, inp_buf_size ) : UdpSocket::allocate( inp_buf_size ); } void UdpSocket_WF::on_bind_error( const char *msg ) { return f_on_bind_error ? f_on_bind_error( this, msg ) : UdpSocket::on_bind_error( msg ); } } // namespace Evel
24.653846
95
0.687988
hleclerc
c428833922bad37bca68690b5d71003424c6b628
1,249
cpp
C++
01-Question_after_WangDao/Chapter_02/2.2/T01.cpp
ysl970629/kaoyan_data_structure
d0a469bf0e9e7040de21eca38dc19961aa7e9a53
[ "MIT" ]
2
2021-03-24T03:29:16.000Z
2022-03-29T16:34:30.000Z
01-Question_after_WangDao/Chapter_02/2.2/T01.cpp
ysl2/kaoyan-data-structure
d0a469bf0e9e7040de21eca38dc19961aa7e9a53
[ "MIT" ]
null
null
null
01-Question_after_WangDao/Chapter_02/2.2/T01.cpp
ysl2/kaoyan-data-structure
d0a469bf0e9e7040de21eca38dc19961aa7e9a53
[ "MIT" ]
null
null
null
#include <iostream> #include <string.h> using namespace std; #define INFINITY 9999 typedef int ElemType; typedef struct { ElemType *data; int length; } SqList; SqList initList(int arr[], int length) { SqList L; L.length = length; L.data = (ElemType *)malloc(sizeof(ElemType) * L.length); for (int i = 0; i < length; i++) L.data[i] = arr[i]; return L; } void outPutList(SqList L) { for (int i = 0; i < L.length; i++) cout << L.data[i] << " "; cout << endl; } bool deleteList(SqList &L, ElemType &e) { if (L.length == 0) return false; ElemType minValue = INFINITY; int minIndex = -1; for (int i = 0; i < L.length; i++) { if (L.data[i] < minValue) { minValue = L.data[i]; minIndex = i; } } e = minValue; L.data[minIndex] = L.data[L.length - 1]; L.length--; return true; } void test(int arr1[], int length1) { SqList L = initList(arr1, length1); ElemType e; deleteList(L, e); cout << e << endl; outPutList(L); } int main() { ElemType A[] = {3, 4, 5, 0, 1, 2, 6, 7, 8}; int length1 = sizeof(A) / sizeof(int); test(A, length1); return 0; } // 输出结果: // 0 // 3 4 5 8 1 2 6 7
19.215385
61
0.536429
ysl970629
c430c3f7a41a594286a0aced1e17298807805390
418
cpp
C++
contest/AtCoder/abc173/B.cpp
not522/Competitive-Programming
be4a7d25caf5acbb70783b12899474a56c34dedb
[ "Unlicense" ]
7
2018-04-14T14:55:51.000Z
2022-01-31T10:49:49.000Z
contest/AtCoder/abc173/B.cpp
not522/Competitive-Programming
be4a7d25caf5acbb70783b12899474a56c34dedb
[ "Unlicense" ]
5
2018-04-14T14:28:49.000Z
2019-05-11T02:22:10.000Z
contest/AtCoder/abc173/B.cpp
not522/Competitive-Programming
be4a7d25caf5acbb70783b12899474a56c34dedb
[ "Unlicense" ]
null
null
null
#include "string.hpp" int main() { int n(in), ac = 0, wa = 0, tle = 0, re = 0; for (int i = 0; i < n; ++i) { String s(in); if (s == "AC") { ++ac; } else if (s == "WA") { ++wa; } else if (s == "TLE") { ++tle; } else { ++re; } } cout << "AC x " << ac << endl; cout << "WA x " << wa << endl; cout << "TLE x " << tle << endl; cout << "RE x " << re << endl; }
19
45
0.366029
not522
c431093118059ac620713bcb36cf416c81693b5e
254
hpp
C++
src/Modules/Interface/IModuleBuilder.hpp
pawel-jarosz/nastya-lisp
813a58523b741e00c8c27980fe658b546e9ff38c
[ "MIT" ]
1
2021-03-12T13:39:17.000Z
2021-03-12T13:39:17.000Z
src/Modules/Interface/IModuleBuilder.hpp
pawel-jarosz/nastya-lisp
813a58523b741e00c8c27980fe658b546e9ff38c
[ "MIT" ]
null
null
null
src/Modules/Interface/IModuleBuilder.hpp
pawel-jarosz/nastya-lisp
813a58523b741e00c8c27980fe658b546e9ff38c
[ "MIT" ]
null
null
null
// // Created by caedus on 04.02.2021. // #pragma once #include "Modules/Interface/IModule.hpp" namespace nastya::modules { class IModuleBuilder { public: virtual ~IModuleBuilder() = default; virtual std::unique_ptr<IModule> build() = 0; }; }
15.875
49
0.692913
pawel-jarosz
c4331b57d588538cff69656332c13bef13a5c624
3,031
hpp
C++
include/gp/genetic_operations/mutation.hpp
ho-ri1991/genetic-programming
06d0c1f0719f4d2ddcf9c066d9de1d0bb67772b0
[ "MIT" ]
null
null
null
include/gp/genetic_operations/mutation.hpp
ho-ri1991/genetic-programming
06d0c1f0719f4d2ddcf9c066d9de1d0bb67772b0
[ "MIT" ]
null
null
null
include/gp/genetic_operations/mutation.hpp
ho-ri1991/genetic-programming
06d0c1f0719f4d2ddcf9c066d9de1d0bb67772b0
[ "MIT" ]
null
null
null
#ifndef GP_GENETIC_OPERATIONS_MUTATION #define GP_GENETIC_OPERATIONS_MUTATION #include <gp/node/node_interface.hpp> #include <gp/tree/tree.hpp> #include <gp/tree_operations/tree_operations.hpp> #include <gp/utility/is_detected.hpp> #include <cassert> namespace gp::genetic_operations { namespace detail { template <typename RandomTreeGenerator> using is_match_random_tree_generator_concept = std::is_invocable_r< node::NodeInterface::node_instance_type, RandomTreeGenerator, const tree::TreeProperty&, std::size_t >; template <typename RandomTreeGenerator> static constexpr bool is_match_random_tree_generator_concept_v = is_match_random_tree_generator_concept<RandomTreeGenerator>::value; template <typename NodeSelector> using is_match_node_selector_concept = std::is_invocable_r< const node::NodeInterface&, NodeSelector, const node::NodeInterface& >; template <typename NodeSelector> static constexpr bool is_match_node_selector_concept_v = is_match_node_selector_concept<NodeSelector>::value; } template <typename RandomTreeGenerator, //concept: node::NodeInterface::node_instance_type operator()(const tree::TreeProperty&, std::size_t), the first argument is property of tree, second is max tree depth typename NodeSelector //concept: const node::NodeInterface& operator()(const node::NodeInterface&) , the argument is the root node of tree > auto mutation(tree::Tree tree, RandomTreeGenerator& randomTreeGenerator, NodeSelector& nodeSelector, std::size_t maxTreeDepth) -> std::enable_if_t< std::conjunction_v< detail::is_match_random_tree_generator_concept<RandomTreeGenerator>, detail::is_match_node_selector_concept<NodeSelector> >, tree::Tree > { const auto& selectedNode = nodeSelector(tree.getRootNode()); auto depth = tree_operations::getDepth(selectedNode); assert(depth <= maxTreeDepth); auto subtreeProperty = tree.getTreeProperty(); subtreeProperty.returnType = &selectedNode.getReturnType(); auto newSubtree = randomTreeGenerator(subtreeProperty, maxTreeDepth - depth); if(selectedNode.hasParent()) { auto& parent = const_cast<node::NodeInterface&>(selectedNode.getParent()); for(int i = 0; i < parent.getChildNum(); ++i) { if(parent.hasChild(i) && &parent.getChild(i) == &selectedNode) { parent.setChild(i, std::move(newSubtree)); return tree; } } return tree; } else { return tree::Tree(std::move(tree).getTreeProperty(), std::move(newSubtree)); } }; } #endif
41.520548
211
0.633124
ho-ri1991
c436876c46e9b0354a1ad972f0d59d2e4927cf83
1,646
hpp
C++
src/vkt/Resample_serial.hpp
szellmann/volk
f8e8755d0e016359e4977934412888830080dd42
[ "MIT" ]
1
2021-01-20T22:31:07.000Z
2021-01-20T22:31:07.000Z
src/vkt/Resample_serial.hpp
szellmann/volkit
f8e8755d0e016359e4977934412888830080dd42
[ "MIT" ]
null
null
null
src/vkt/Resample_serial.hpp
szellmann/volkit
f8e8755d0e016359e4977934412888830080dd42
[ "MIT" ]
null
null
null
// This file is distributed under the MIT license. // See the LICENSE file for details. #pragma once #include <vkt/Resample.hpp> #include <vkt/StructuredVolume.hpp> #include "linalg.hpp" namespace vkt { void Resample_serial( StructuredVolume& dst, StructuredVolume& src, Filter filter ) { if (dst.getDims() == src.getDims()) { // In that case don't resample spatially! Vec3i dims = dst.getDims(); for (int32_t z = 0; z != dims.z; ++z) { for (int32_t y = 0; y != dims.y; ++y) { for (int32_t x = 0; x != dims.x; ++x) { Vec3i index{x,y,z}; dst.setValue(index, src.getValue(index)); } } } } else { Vec3i dstDims = dst.getDims(); Vec3i srcDims = src.getDims(); for (int32_t z = 0; z != dstDims.z; ++z) { for (int32_t y = 0; y != dstDims.y; ++y) { for (int32_t x = 0; x != dstDims.x; ++x) { float srcX = x / float(dstDims.x) * srcDims.x; float srcY = y / float(dstDims.y) * srcDims.y; float srcZ = z / float(dstDims.z) * srcDims.z; float value = src.sampleLinear(srcX, srcY, srcZ); dst.setValue({x,y,z}, value); } } } } } } // vkt
26.983607
73
0.402795
szellmann
c439ec2d3cac849808d08ae87376fbed3236e7c5
1,337
cpp
C++
luogu/p6198.cpp
freedomDR/coding
310a68077de93ef445ccd2929e90ba9c22a9b8eb
[ "MIT" ]
null
null
null
luogu/p6198.cpp
freedomDR/coding
310a68077de93ef445ccd2929e90ba9c22a9b8eb
[ "MIT" ]
null
null
null
luogu/p6198.cpp
freedomDR/coding
310a68077de93ef445ccd2929e90ba9c22a9b8eb
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; int n; int val = 1; vector<int> arr(1e6+5), ans(1e6+5); vector<vector<int>> pos(1e6+5, vector<int>()); void slove(int l, int r, int splitNum) { /* cout << l << " " << r << endl; */ if(l>r) return; vector<int> splitPos; //记录分割点 // 二分查端点 int st = lower_bound(pos[splitNum].begin(), pos[splitNum].end(), r) - pos[splitNum].begin(); // splitNum 从r到l 按照val递增赋值 for(int i = min(st, int(pos[splitNum].size()-1)); i >= 0 && pos[splitNum][i] >= l; i--) { if(pos[splitNum][i] <= r && arr[pos[splitNum][i]] == splitNum) { ans[pos[splitNum][i]] = val++; splitPos.push_back(pos[splitNum][i]); } } // l r 也可以作为分割点 if(!splitPos.empty() && splitPos.back()!=l) splitPos.push_back(l-1); if(splitPos.front()!=r) splitPos.insert(splitPos.begin(),r+1); for(int i = splitPos.size()-2; i >= 0; i--) { slove(splitPos[i+1]+1, splitPos[i]-1, splitNum+1); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++) { cin >> arr[i]; if(arr[i] == -1) arr[i] = arr[i-1]+1; pos[arr[i]].push_back(i); } slove(1, n, 1); for(int i = 1; i <= n; i++) cout << ans[i] << " "; cout << endl; return 0; }
26.215686
96
0.511593
freedomDR
c43c81cf2f099d29d0bec5181481cc6203ce1388
800
cpp
C++
source/game/Main.cpp
AlexKoukoulas2074245K/Genesis
23c114cfe06b65b0b7b5f7807a9ceb4faf8cdf88
[ "MIT" ]
null
null
null
source/game/Main.cpp
AlexKoukoulas2074245K/Genesis
23c114cfe06b65b0b7b5f7807a9ceb4faf8cdf88
[ "MIT" ]
null
null
null
source/game/Main.cpp
AlexKoukoulas2074245K/Genesis
23c114cfe06b65b0b7b5f7807a9ceb4faf8cdf88
[ "MIT" ]
null
null
null
///------------------------------------------------------------------------------------------------ /// Main.cpp /// Genesis /// /// Created by Alex Koukoulas on 19/11/2019. ///------------------------------------------------------------------------------------------------ #include "Game.h" #include "../engine/GenesisEngine.h" #if defined(_WIN32) && !defined(NDEBUG) #include <vld.h> #endif ///------------------------------------------------------------------------------------------------ int main(int, char**) { genesis::GenesisEngine engine; genesis::GameStartupParameters startupParameters("Genesis", 0.7f); Game game; engine.RunGame(startupParameters, game); } ///------------------------------------------------------------------------------------------------
27.586207
99
0.3325
AlexKoukoulas2074245K
c43ebc79b8b575b62f652c1abbdb65988fd33316
984
cpp
C++
Plugins/Optimizations/Optimizations/AsyncLogFlush.cpp
Jorteck/unified
834e39fabfe8fdb0b636cf6b4d48b3a78af64c59
[ "MIT" ]
null
null
null
Plugins/Optimizations/Optimizations/AsyncLogFlush.cpp
Jorteck/unified
834e39fabfe8fdb0b636cf6b4d48b3a78af64c59
[ "MIT" ]
null
null
null
Plugins/Optimizations/Optimizations/AsyncLogFlush.cpp
Jorteck/unified
834e39fabfe8fdb0b636cf6b4d48b3a78af64c59
[ "MIT" ]
null
null
null
#include "Optimizations/AsyncLogFlush.hpp" #include "Services/Hooks/Hooks.hpp" #include "Services/Tasks/Tasks.hpp" #include "API/Functions.hpp" #include "API/CExoDebugInternal.hpp" #include "API/CExoFile.hpp" namespace Optimizations { using namespace NWNXLib; using namespace NWNXLib::API; NWNXLib::Services::TasksProxy* AsyncLogFlush::s_tasker; AsyncLogFlush::AsyncLogFlush(Services::HooksProxy* hooker, Services::TasksProxy* tasker) { s_tasker = tasker; hooker->Hook(API::Functions::_ZN17CExoDebugInternal12FlushLogFileEv, (void*)&FlushLogFile_Hook, Hooking::Order::Final); } void AsyncLogFlush::FlushLogFile_Hook(CExoDebugInternal* pThis) { // Rotating log file, do synchronously if (pThis->m_bRotateLogFile && ((pThis->m_nCurrentLogSize << 2) > pThis->m_nMaxLogSize)) { pThis->m_pLogFile->Flush(); return; } if (pThis->m_bFilesOpen) { s_tasker->QueueOnAsyncThread([pThis](){ pThis->m_pLogFile->Flush(); }); } } }
26.594595
123
0.721545
Jorteck
c4460696fcf299459176912295c98084eea6094e
6,149
cpp
C++
examples_tests/07.HardwareSkinning/main.cpp
Crisspl/Nabla
8e2ff2551113b2837513b188a8f16ef70adc9f81
[ "Apache-2.0" ]
null
null
null
examples_tests/07.HardwareSkinning/main.cpp
Crisspl/Nabla
8e2ff2551113b2837513b188a8f16ef70adc9f81
[ "Apache-2.0" ]
2
2021-04-28T21:42:36.000Z
2021-06-02T22:52:33.000Z
examples_tests/07.HardwareSkinning/main.cpp
Crisspl/Nabla
8e2ff2551113b2837513b188a8f16ef70adc9f81
[ "Apache-2.0" ]
1
2021-05-31T20:33:28.000Z
2021-05-31T20:33:28.000Z
#define _IRR_STATIC_LIB_ #include <irrlicht.h> #include "../../ext/ScreenShot/ScreenShot.h" #include "../common/QToQuitEventReceiver.h" using namespace irr; using namespace core; class SimpleCallBack : public video::IShaderConstantSetCallBack { int32_t mvpUniformLocation; int32_t cameraDirUniformLocation; video::E_SHADER_CONSTANT_TYPE mvpUniformType; video::E_SHADER_CONSTANT_TYPE cameraDirUniformType; public: SimpleCallBack() : cameraDirUniformLocation(-1), cameraDirUniformType(video::ESCT_FLOAT_VEC3) {} virtual void PostLink(video::IMaterialRendererServices* services, const video::E_MATERIAL_TYPE& materialType, const core::vector<video::SConstantLocationNamePair>& constants) { for (size_t i = 0; i<constants.size(); i++) { if (constants[i].name == "MVP") { mvpUniformLocation = constants[i].location; mvpUniformType = constants[i].type; } else if (constants[i].name == "cameraPos") { cameraDirUniformLocation = constants[i].location; cameraDirUniformType = constants[i].type; } } } virtual void OnSetConstants(video::IMaterialRendererServices* services, int32_t userData) { core::vectorSIMDf modelSpaceCamPos; modelSpaceCamPos.set(services->getVideoDriver()->getTransform(video::E4X3TS_WORLD_VIEW_INVERSE).getTranslation()); if (cameraDirUniformLocation != -1) services->setShaderConstant(&modelSpaceCamPos, cameraDirUniformLocation, cameraDirUniformType, 1); if (mvpUniformLocation != -1) services->setShaderConstant(services->getVideoDriver()->getTransform(video::EPTS_PROJ_VIEW_WORLD).pointer(), mvpUniformLocation, mvpUniformType, 1); } virtual void OnUnsetMaterial() {} }; int main() { // create device with full flexibility over creation parameters // you can add more parameters if desired, check irr::SIrrlichtCreationParameters irr::SIrrlichtCreationParameters params; params.Bits = 24; //may have to set to 32bit for some platforms params.ZBufferBits = 24; //we'd like 32bit here params.DriverType = video::EDT_OPENGL; //! Only Well functioning driver, software renderer left for sake of 2D image drawing params.WindowSize = dimension2d<uint32_t>(1280, 720); params.Fullscreen = false; params.Vsync = false; params.Doublebuffer = true; params.Stencilbuffer = false; //! This will not even be a choice soon IrrlichtDevice* device = createDeviceEx(params); if (device == 0) return 1; // could not create selected driver. video::IVideoDriver* driver = device->getVideoDriver(); SimpleCallBack* cb = new SimpleCallBack(); video::E_MATERIAL_TYPE newMaterialType = (video::E_MATERIAL_TYPE)driver->getGPUProgrammingServices()->addHighLevelShaderMaterialFromFiles("../mesh.vert", "", "", "", //! No Geometry or Tessellation Shaders "../mesh.frag", 3, video::EMT_SOLID, //! 3 vertices per primitive (this is tessellation shader relevant only cb, //! Our Shader Callback 0); //! No custom user data cb->drop(); scene::ISceneManager* smgr = device->getSceneManager(); driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 0.01f); camera->setPosition(core::vector3df(-4, 0, 0)); camera->setTarget(core::vector3df(0, 0, 0)); camera->setNearValue(0.01f); camera->setFarValue(250.0f); smgr->setActiveCamera(camera); device->getCursorControl()->setVisible(false); QToQuitEventReceiver receiver; device->setEventReceiver(&receiver); io::IFileSystem* fs = device->getFileSystem(); #define kInstanceSquareSize 10 scene::ISceneNode* instancesToRemove[kInstanceSquareSize*kInstanceSquareSize] = { 0 }; asset::IAssetLoader::SAssetLoadParams lparams; auto cpumesh = core::smart_refctd_ptr_static_cast<asset::ICPUMesh>(*device->getAssetManager()->getAsset("../../media/dwarf.baw", lparams).getContents().begin()); if (cpumesh&&cpumesh->getMeshType() == asset::EMT_ANIMATED_SKINNED) { scene::ISkinnedMeshSceneNode* anode = 0; auto manipulator = device->getAssetManager()->getMeshManipulator(); for (size_t x = 0; x<kInstanceSquareSize; x++) for (size_t z = 0; z<kInstanceSquareSize; z++) { auto duplicate = manipulator->createMeshDuplicate(cpumesh.get()); auto gpumesh = std::move(driver->getGPUObjectsFromAssets(&duplicate.get(), &duplicate.get()+1)->operator[](0u)); instancesToRemove[x + kInstanceSquareSize*z] = anode = smgr->addSkinnedMeshSceneNode(core::smart_refctd_ptr_static_cast<video::IGPUSkinnedMesh>(gpumesh)); anode->setScale(core::vector3df(0.05f)); anode->setPosition(core::vector3df(x, 0.f, z)*4.f); anode->setAnimationSpeed(18.f*float(x + 1 + (z + 1)*kInstanceSquareSize) / float(kInstanceSquareSize*kInstanceSquareSize)); for (auto i = 0u; i < gpumesh->getMeshBufferCount(); i++) { auto& material = gpumesh->getMeshBuffer(i)->getMaterial(); material.MaterialType = newMaterialType; material.setTexture(3u, core::smart_refctd_ptr<video::ITextureBufferObject>(anode->getBonePoseTBO())); } } } uint64_t lastFPSTime = 0; while (device->run() && receiver.keepOpen()) //if (device->isWindowActive()) { driver->beginScene(true, true, video::SColor(255, 0, 0, 255)); //! This animates (moves) the camera and sets the transforms //! Also draws the meshbuffer smgr->drawAll(); driver->endScene(); // display frames per second in window title uint64_t time = device->getTimer()->getRealTime(); if (time - lastFPSTime > 1000) { std::wostringstream str; str << L"Builtin Nodes Demo - Irrlicht Engine [" << driver->getName() << "] FPS:" << driver->getFPS() << " PrimitvesDrawn:" << driver->getPrimitiveCountDrawn(); device->setWindowCaption(str.str()); lastFPSTime = time; } } for (size_t x = 0; x<kInstanceSquareSize; x++) for (size_t z = 0; z<kInstanceSquareSize; z++) instancesToRemove[x + kInstanceSquareSize*z]->remove(); //create a screenshot { core::rect<uint32_t> sourceRect(0, 0, params.WindowSize.Width, params.WindowSize.Height); ext::ScreenShot::dirtyCPUStallingScreenshot(driver, device->getAssetManager(), "screenshot.png", sourceRect, asset::EF_R8G8B8_SRGB); } device->drop(); return 0; }
35.959064
175
0.733615
Crisspl
c448de0cde57393a668990a66beed745ce0007ac
3,075
cpp
C++
ad_map_access/src/point/BoundingSphereOperation.cpp
woojinjjang/map-1
d12bb410f03d078a995130b4e671746ace8b6287
[ "MIT" ]
61
2019-12-19T20:57:24.000Z
2022-03-29T15:20:51.000Z
ad_map_access/src/point/BoundingSphereOperation.cpp
woojinjjang/map-1
d12bb410f03d078a995130b4e671746ace8b6287
[ "MIT" ]
54
2020-04-05T05:32:47.000Z
2022-03-15T18:42:33.000Z
ad_map_access/src/point/BoundingSphereOperation.cpp
woojinjjang/map-1
d12bb410f03d078a995130b4e671746ace8b6287
[ "MIT" ]
31
2019-12-20T07:37:39.000Z
2022-03-16T13:06:16.000Z
// ----------------- BEGIN LICENSE BLOCK --------------------------------- // // Copyright (C) 2018-2021 Intel Corporation // // SPDX-License-Identifier: MIT // // ----------------- END LICENSE BLOCK ----------------------------------- #include "ad/map/point/BoundingSphereOperation.hpp" namespace ad { namespace map { namespace point { void expandBounds(point::ECEFPoint &upperBound, point::ECEFPoint &lowerBound, point::ECEFPoint const &point) { upperBound.x = std::max(upperBound.x, point.x); upperBound.y = std::max(upperBound.y, point.y); upperBound.z = std::max(upperBound.z, point.z); lowerBound.x = std::min(lowerBound.x, point.x); lowerBound.y = std::min(lowerBound.y, point.y); lowerBound.z = std::min(lowerBound.z, point.z); } point::BoundingSphere calcBoundingSphere(Geometry const &geometryLeft, Geometry const &geometryRight) { point::BoundingSphere boundingSphere; if (geometryLeft.ecefEdge.empty() && geometryRight.ecefEdge.empty()) { return boundingSphere; } point::ECEFPoint upperBound; point::ECEFPoint lowerBound; if (geometryLeft.ecefEdge.empty()) { upperBound = geometryRight.ecefEdge.front(); } else { upperBound = geometryLeft.ecefEdge.front(); } lowerBound = upperBound; for (auto const &point : geometryLeft.ecefEdge) { expandBounds(upperBound, lowerBound, point); } for (auto const &point : geometryRight.ecefEdge) { expandBounds(upperBound, lowerBound, point); } point::ECEFPoint const diagonalVector = upperBound - lowerBound; auto diagonalVectorLength = point::vectorLength(diagonalVector); boundingSphere.radius = 0.5 * diagonalVectorLength; boundingSphere.center = lowerBound + 0.5 * diagonalVector; return boundingSphere; } } // namespace point } // namespace map } // namespace ad ::ad::map::point::BoundingSphere operator+(::ad::map::point::BoundingSphere const &a, ::ad::map::point::BoundingSphere const &b) { ::ad::map::point::BoundingSphere result; ::ad::map::point::BoundingSphere const *small; ::ad::map::point::BoundingSphere const *large; if (a.radius < b.radius) { small = &a; large = &b; } else { small = &b; large = &a; } auto const fromLargeToSmallCenter = small->center - large->center; auto const sphereCenterDistance = ::ad::map::point::vectorLength(fromLargeToSmallCenter); // move the center of the larger sphere in direction of the smaller one // and increase the larger radius by the moving distance auto const displacement = 0.5 * (sphereCenterDistance - large->radius + small->radius); if (displacement <= ::ad::physics::Distance(0.)) { // small is already within large result = *large; } else if (sphereCenterDistance == ::ad::physics::Distance(0.)) { // tiny center distance result = *large; } else { result.center = large->center + ::ad::physics::Distance(displacement / sphereCenterDistance) * (fromLargeToSmallCenter); result.radius = large->radius + displacement; } return result; }
28.211009
112
0.663415
woojinjjang
c449c846ca94f3a68d09ce129de727b925a62c83
221
cpp
C++
Os/MemCommon.cpp
AlperenCetin0/fprime
7e20febd34019c730da1358567e7a512592de4d8
[ "Apache-2.0" ]
9,182
2017-07-06T15:51:35.000Z
2022-03-30T11:20:33.000Z
Os/MemCommon.cpp
AlperenCetin0/fprime
7e20febd34019c730da1358567e7a512592de4d8
[ "Apache-2.0" ]
719
2017-07-14T17:56:01.000Z
2022-03-31T02:41:35.000Z
Os/MemCommon.cpp
AlperenCetin0/fprime
7e20febd34019c730da1358567e7a512592de4d8
[ "Apache-2.0" ]
1,216
2017-07-12T15:41:08.000Z
2022-03-31T21:44:37.000Z
#include <Os/Mem.hpp> #include <cstring> namespace Os { U32 Mem::virtToPhys(U32 virtAddr) { return virtAddr; } U32 Mem::physToVirt(U32 physAddr) { return physAddr; } }
13.8125
39
0.552036
AlperenCetin0
c44a87df8b1fe729708ce05a2d1d2a0766fff0d8
1,587
cpp
C++
Source/Controllers/Corsair/CorsairController.cpp
pramberg/DeviceRGB
a2020b2b5accb1fc864c16905c35c352d3e4f39b
[ "MIT" ]
3
2021-08-12T16:13:22.000Z
2022-02-26T05:54:06.000Z
Source/Controllers/Corsair/CorsairController.cpp
pramberg/DeviceRGB
a2020b2b5accb1fc864c16905c35c352d3e4f39b
[ "MIT" ]
12
2021-08-11T09:00:36.000Z
2021-11-06T16:04:55.000Z
Source/Controllers/Corsair/CorsairController.cpp
pramberg/DeviceRGB
a2020b2b5accb1fc864c16905c35c352d3e4f39b
[ "MIT" ]
null
null
null
// Copyright(c) 2021 Viktor Pramberg #include "CorsairController.h" #include <Interfaces/IPluginManager.h> #include "CorsairDevice.h" #include "DeviceRGB.h" #include <CUESDK.h> FCorsairController::FCorsairController() { const FString BaseDir = IPluginManager::Get().FindPlugin("DeviceRGB")->GetBaseDir(); const FString LibraryPath = FPaths::Combine(*BaseDir, TEXT("Source/ThirdParty/CUESDK/redist/x64/CUESDK.x64_2017.dll")); SDKHandle = FPlatformProcess::GetDllHandle(*LibraryPath); } FCorsairController::~FCorsairController() { FPlatformProcess::FreeDllHandle(SDKHandle); SDKHandle = nullptr; } TUniquePtr<FCorsairController> FCorsairController::Construct() { auto Controller = TUniquePtr<FCorsairController>(new FCorsairController()); if (!Controller->SDKHandle) { return nullptr; } CorsairPerformProtocolHandshake(); if (CorsairGetLastError()) { UE_LOG(LogDeviceRGB, Display, TEXT("Failed to connect to Corsair CUE service.")); return nullptr; } for (int32 DeviceIndex = 0; DeviceIndex < CorsairGetDeviceCount(); DeviceIndex++) { Controller->AddDevice<FCorsairDevice>(DeviceIndex); } return MoveTemp(Controller); } void FCorsairController::FlushBuffers() { FlushBuffersImpl(); } void FCorsairController::FlushBuffersImpl() { CorsairSetLedsColorsFlushBufferAsync([](void* Context, bool Result, CorsairError Error) { if (Error != CE_Success) { UE_LOG(LogDeviceRGB, Error, TEXT("Failed to flush Corsair color buffer")); } }, nullptr); } void FCorsairController::SetEnabled(bool bEnabled) { CorsairSetLayerPriority(bEnabled ? 255 : 0); }
24.045455
120
0.759294
pramberg
c44be4f8fba288be41dc23c9d349f72f73b0c8cc
1,158
hpp
C++
include/nornir/external/fastflow/ff/make_unique.hpp
DanieleDeSensi/Nornir
60587824d6b0a6e61b8fc75bdea37c9fc69199c7
[ "MIT" ]
11
2020-12-16T22:44:08.000Z
2022-03-30T00:52:58.000Z
include/nornir/external/fastflow/ff/make_unique.hpp
DanieleDeSensi/Nornir
60587824d6b0a6e61b8fc75bdea37c9fc69199c7
[ "MIT" ]
1
2021-04-01T09:07:52.000Z
2021-07-21T22:10:07.000Z
include/nornir/external/fastflow/ff/make_unique.hpp
DanieleDeSensi/Nornir
60587824d6b0a6e61b8fc75bdea37c9fc69199c7
[ "MIT" ]
3
2020-12-21T18:47:43.000Z
2021-11-20T19:48:45.000Z
#ifndef FF_MAKEUNIQUE_HPP #define FF_MAKEUNIQUE_HPP #include <memory> #include <type_traits> #include <utility> #if __cplusplus < 201400L // to check // C++11 implementation of make_unique #if (__cplusplus >= 201103L) || (defined __GXX_EXPERIMENTAL_CXX0X__) || (defined(HAS_CXX11_VARIADIC_TEMPLATES)) template <typename T, typename... Args> std::unique_ptr<T> make_unique_helper(std::false_type, Args&&... args) { return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } template <typename T, typename... Args> std::unique_ptr<T> make_unique_helper(std::true_type, Args&&... args) { static_assert(std::extent<T>::value == 0, "make_unique<T[N]>() is forbidden, please use make_unique<T[]>()."); typedef typename std::remove_extent<T>::type U; return std::unique_ptr<T>(new U[sizeof...(Args)]{std::forward<Args>(args)...}); } template <typename T, typename... Args> std::unique_ptr<T> make_unique(Args&&... args) { return make_unique_helper<T>(std::is_array<T>(), std::forward<Args>(args)...); } #endif #else using std::make_unique;// need to check if only the name is sufficient #endif #endif // FF_MAKEUNIQUE_HPP
28.243902
111
0.701209
DanieleDeSensi
c44c7f7ed528e1e6acde199cb5f205e7fb51537d
14,535
cpp
C++
Source/Canvas/selectiontransformitem.cpp
erayzesen/turquoise2D
33bd2e85169bba4c82c388c1619b2de55065eb7b
[ "Zlib" ]
13
2020-05-24T23:52:48.000Z
2020-12-01T02:43:03.000Z
Source/Canvas/selectiontransformitem.cpp
erayzesen/turquoise2D
33bd2e85169bba4c82c388c1619b2de55065eb7b
[ "Zlib" ]
3
2020-05-26T22:19:49.000Z
2020-12-01T09:31:25.000Z
Source/Canvas/selectiontransformitem.cpp
erayzesen/turquoise2D
33bd2e85169bba4c82c388c1619b2de55065eb7b
[ "Zlib" ]
3
2020-05-26T01:35:20.000Z
2020-05-26T13:51:07.000Z
#include "selectiontransformitem.h" SelectionTransformItem::SelectionTransformItem(QList<QGraphicsItem*> _items,GraphicsScene * _scene,PropertiesItem *_propItem) { scene=_scene; items=_items; //(i) Defining anchor items for scale rightBottomAnchor=new TransformAnchor(this,TransformTypes::Scale); leftBottomAnchor=new TransformAnchor(this,TransformTypes::Scale); rightTopAnchor=new TransformAnchor(this,TransformTypes::Scale); leftTopAnchor=new TransformAnchor(this,TransformTypes::Scale); //Defining items container, all items will add to the container. itemsContainer=new QGraphicsItemGroup; scene->addItem(itemsContainer); scene->addItem(this); rectItem=setRectItem(); this->setZValue(9999999999); //rectItem->setFlag(QGraphicsItem::ItemStacksBehindParent); /* (i) Order of creating transform Item; 1-add items 2-add transform tools 3-add rectangle item */ this->addItems(); UpdateContainerZOrder(); this->addTransformTools(); this->addToGroup(rectItem); this->setFlag(QGraphicsItem::ItemIsMovable,true); this->setFlag(QGraphicsItem::ItemIsFocusable,false); this->setFlag(QGraphicsItem::ItemIsSelectable,false); propItem=_propItem; //Creating new properties item and add properties panel GraphicsScene* gs=dynamic_cast<GraphicsScene*>(scene); if(gs!=NULL){ if(propItem==NULL){ propItem=new PropertiesItem(this,gs->propPanel); gs->propPanel->AddGameProperties(propItem); }else{ propItem->transformItem=this; propItem->UpdateTransformProp(); } } } SelectionTransformItem::~SelectionTransformItem() { } void SelectionTransformItem::UpdateContainer() { itemsContainer->setTransform(this->transform()); itemsContainer->setPos(this->scenePos()); itemsContainer->setRotation(this->rotation()); } void SelectionTransformItem::UpdateContainerZOrder() { qreal minZOrder=999999999999; for(int i=0;i<items.count();i++){ GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(i)); if(selectedGameItem){ minZOrder=selectedGameItem->zValue()<minZOrder ? selectedGameItem->zValue():minZOrder; } } itemsContainer->setZValue(minZOrder); } void SelectionTransformItem::updateOrigin() { *originPoint=this->scenePos(); } SelectionTransformRect* SelectionTransformItem::setRectItem() { //(i) Defining min max variables with big numbers as default. float minX=items.count()==0 ? 0:10000000000; float minY=items.count()==0 ? 0:10000000000; float maxX=items.count()==0 ? 0:-10000000000; float maxY=items.count()==0 ? 0:-10000000000; float aloneItemRot; if(items.count()==1){ //(i) if the user selected one item,we're getting actual size and defining new rect. GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(0)); QSizeF cgsize=selectedGameItem->actualSize(); minX=selectedGameItem->pos().x()-cgsize.width()/2; minY=selectedGameItem->pos().y()-cgsize.height()/2; maxX=selectedGameItem->pos().x()+cgsize.width()/2; maxY=selectedGameItem->pos().y()+cgsize.height()/2; aloneItemRot=0; }else{ //(i) if the user selected multiple item, we're getting actual bounds from the item and checking min-max values for(int i=0;i<items.count();i++){ GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(i)); if(selectedGameItem){ QPolygonF itemBounds=selectedGameItem->actualBounds(true); for(int n=0;n<itemBounds.count();n++){ QPointF p=itemBounds.at(n); minX=p.x()<minX ? p.x():minX; minY=p.y()<minY ? p.y():minY; maxX=p.x()>maxX ? p.x():maxX; maxY=p.y()>maxY ? p.y():maxY; } } } } selectorSize=new QSizeF(maxX-minX,maxY-minY); //(i) We're creating transformRect according to min-max values in this period. transformRect=new QRectF(-selectorSize->width()/2,-selectorSize->height()/2,selectorSize->width(),selectorSize->height()); currentRect=transformRect; SelectionTransformRect *nRectItem=new SelectionTransformRect(this); // Setting position of transformRect to origin. nRectItem->setPos(minX+selectorSize->width()/2,minY+selectorSize->height()/2); originPoint=new QPointF(minX+selectorSize->width()/2,minY+selectorSize->height()/2); this->setPos(originPoint->x(),originPoint->y()); UpdateContainer(); if(items.count()==1) this->setRotation(aloneItemRot); return nRectItem; } void SelectionTransformItem::addItems() { //(i) Adding all items into group. for(int i=0;i<items.count();i++){ GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(i)); if(selectedGameItem){ QPointF delta=selectedGameItem->scenePos()-this->scenePos(); itemsContainer->addToGroup(selectedGameItem); selectedGameItem->setPos(delta.x(),delta.y()); //selectedGameItem->setFlag(QGraphicsItem::ItemStacksBehindParent); } } } void SelectionTransformItem::dropItems() { //(i) Removing all items from group and clearing items array. Calculating the final item size for all items. for(int i=0;i<items.count();i++){ GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(i)); if(selectedGameItem){ itemsContainer->removeFromGroup(selectedGameItem); selectedGameItem->setSelected(false); QPointF currentScale(selectedGameItem->transform().m11(),selectedGameItem->transform().m22()); QSize originalSize=selectedGameItem->pixmap().size(); QSizeF finalSize=QSizeF(currentScale.x()*originalSize.width(),currentScale.y()*originalSize.height()); QTransform tempTransform=QTransform(); } } items.clear(); } void SelectionTransformItem::addTransformTools() { /*(i) Settings anchors for scale and rotate operations. * If the user selects an item, we're setting the anchor positions to the item's actualBounds * If the user selects multiple items, we're setting the anchor positions according to the transformItem's boundingRect values. */ if(!rectItem) return; int rectSize=8; QPolygonF points(4); if(items.count()==1){ GameItem *gitem=dynamic_cast<GameItem*>(items.at(0)); if(gitem){ points=gitem->actualBounds(true); } }else{ points[0]=QPointF(originPoint->x()-rectItem->boundingRect().width()/2,originPoint->y()-rectItem->boundingRect().height()/2); points[1]=QPointF(originPoint->x()+rectItem->boundingRect().width()/2,originPoint->y()-rectItem->boundingRect().height()/2); points[2]=QPointF(originPoint->x()+rectItem->boundingRect().width()/2,originPoint->y()+rectItem->boundingRect().height()/2); points[3]=QPointF(originPoint->x()-rectItem->boundingRect().width()/2,originPoint->y()+rectItem->boundingRect().height()/2); } leftTopAnchor->setPos(points.at(0)); leftTopAnchor->setZValue(100000000); leftTopAnchor->UpdateDeltaFromOrigin(); this->addToGroup(leftTopAnchor); rightTopAnchor->setPos(points.at(1)); rightTopAnchor->setZValue(100000000); rightTopAnchor->UpdateDeltaFromOrigin(); this->addToGroup(rightTopAnchor); rightBottomAnchor->setPos(points.at(2)); rightBottomAnchor->setZValue(100000000); rightBottomAnchor->UpdateDeltaFromOrigin(); this->addToGroup(rightBottomAnchor); leftBottomAnchor->setPos(points.at(3)); leftBottomAnchor->setZValue(100000000); leftBottomAnchor->UpdateDeltaFromOrigin(); this->addToGroup(leftBottomAnchor); TransformAnchor *originAnchor=new TransformAnchor(this,TransformTypes::Origin); originAnchor->setPos(this->originPoint->x(),this->originPoint->y()); this->addToGroup(originAnchor); } bool SelectionTransformItem::checkScaleCursor(QGraphicsSceneMouseEvent *mouseEvent) { /* (i) Checking if mouse position is in the scale anchor and setting application cursor.*/ bool tmp=false; QGraphicsItem *mouseOverItem=scene->itemAt(mouseEvent->scenePos(),QTransform()); if(mouseOverItem){ TransformAnchor *overedAnchor=dynamic_cast<TransformAnchor*>(mouseOverItem); if(overedAnchor){ QPointF go=overedAnchor->transformGroup->scenePos(); // Group Origin QPointF tp=overedAnchor->scenePos(); if((tp.x()>go.x() && tp.y()>go.y()) || (tp.x()<go.x() && tp.y()<go.y())){ scene->view->setMouseCursor(QCursor(Qt::SizeFDiagCursor)); tmp=true; }else if((tp.x()<go.x() && tp.y()>go.y()) || (tp.x()>go.x() && tp.y()<go.y())){ scene->view->setMouseCursor(QCursor(Qt::SizeBDiagCursor)); tmp=true; } } } return tmp; } bool SelectionTransformItem::checkRotateCursor(QGraphicsSceneMouseEvent *mouseEvent) { /*(i) Checking if mouse position distance between enough for rotate transform. * And setting cursor, calculating cursor angle according to the between the origin and mousePosition. */ bool tmp=false; bool cond1=this->rightBottomAnchor->checkRotationDistance(mouseEvent->scenePos()); bool cond2=this->leftBottomAnchor->checkRotationDistance(mouseEvent->scenePos()); bool cond3=this->leftTopAnchor->checkRotationDistance(mouseEvent->scenePos()); bool cond4=this->rightTopAnchor->checkRotationDistance(mouseEvent->scenePos()); if(cond1 || cond2 || cond3 || cond4){ QPixmap cursor(":/mouseIcons/rotate_mouse_cursor.png"); float angle=MathOperations::vectorToAngle(mouseEvent->scenePos(),*this->originPoint); angle=qRadiansToDegrees(angle); QTransform trans; trans.rotate(angle-90); cursor=cursor.transformed(trans,Qt::SmoothTransformation); //qDebug()<<angle; QCursor nCursor(cursor); scene->view->setMouseCursor(nCursor); tmp=true; } return tmp; } void SelectionTransformItem::updateLastRotation() { //(i) We need lastRotation variable because calculating delta rotation except old rotation. Delta rotation=lastRotation+resultAngle lastRotation=this->rotation(); } bool SelectionTransformItem::checkTransformCursor(QGraphicsSceneMouseEvent *mouseEvent) { //(i) Checking if the mouse position is over the transformitem. If it's true, we're setting mouse cursor as arrow. bool tmp=false; QGraphicsItem *mouseOverItem=scene->itemAt(mouseEvent->scenePos(),QTransform()); if(mouseOverItem){ SelectionTransformRect *overedTransformItem=dynamic_cast<SelectionTransformRect*>(mouseOverItem); if(overedTransformItem){ scene->view->setMouseCursor(QCursor(Qt::ArrowCursor)); tmp=true; } } return tmp; } void SelectionTransformItem::rotateTransform(QPointF p1, QPointF p2) { /* Calculating the angle between p1 and p2. * p1 for begin angle (clicked mouse position) * p2 for current angle (moving mouse position) * Result angle is the endAngle-beginAngle. Because we need rotate according to the clicked point angle. * Delta rotation is how many degree rotated item except the default rotation angle. */ float beginAngle=MathOperations::vectorToAngle(*this->originPoint,p1); float endAngle=MathOperations::vectorToAngle(*this->originPoint,p2); //qDebug()<<"begin: "<<beginAngle<<" end: "<<endAngle; float resultAngle=endAngle-beginAngle; resultAngle=qRadiansToDegrees(resultAngle); //qDebug()<<"result: "<<resultAngle; rotateTransform(resultAngle); } void SelectionTransformItem::rotateTransform(float angle) { deltaRotation=lastRotation+angle; //reducing digits deltaRotation=qRound(deltaRotation*100); deltaRotation/=100; this->setRotation(deltaRotation); applyRotations(); this->UpdateContainer(); } void SelectionTransformItem::UpdateBounds() { //(i) We need update the selectable area according to the current scale. float w=transformRect->width()*this->transform().m11(); float h=transformRect->height()*this->transform().m22(); currentRect=new QRectF(-w/2,-h/2,w,h); } void SelectionTransformItem::applyRotations() { /* (i) Setting new rotation values of game items. * We're using tempRotate for that. tempRotate is the angle before transform operation. * We're adding delta rotation to the tempRotate value of item for set current item's rotation value. */ for(int i=0;i<items.count();i++){ GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(i)); if(selectedGameItem){ selectedGameItem->rotate=selectedGameItem->tempRotate+deltaRotation; } } } void SelectionTransformItem::applyScales() { /* (i) Setting new scale values of game items. * We're using tempScale for that. tempScale is the scale value of item before transform operation. * We're crossing tempScale values and transformItem current scale values for calculating new item's scale. */ for(int i=0;i<items.count();i++){ GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(i)); if(selectedGameItem){ selectedGameItem->scale.setWidth(selectedGameItem->tempScale.width()*(this->transform().m11())); selectedGameItem->scale.setHeight(selectedGameItem->tempScale.height()*(this->transform().m22())); } } } void SelectionTransformItem::rePrepareItems() { /*(i) We didn't use that function. We didn't need that for current version. * This function re-prepare game items for transformations. */ for(int i=0;i<items.count();i++){ GameItem *selectedGameItem=dynamic_cast<GameItem*>(items.at(i)); if(selectedGameItem){ selectedGameItem->prepareTransform(); } } } void SelectionTransformItem::updateAnchorTransforms(QPolygonF points) { } void SelectionTransformItem::setNewScale(QPointF newScale,bool digitFilter) { //Setting scale with new value (we convert two-digit number) QPointF filtScale=digitFilter==true ? MathOperations::setDigitFloat(newScale):newScale; QTransform trans; trans.scale(filtScale.x(),filtScale.y()); this->setTransform(trans); this->applyScales(); this->UpdateBounds(); this->propItem->UpdateTransformProp(); this->UpdateContainer(); }
38.76
135
0.684692
erayzesen
c44f77c396cd96c4c1070d239e652530745ad88b
470
hpp
C++
src/systems/EntityTestSystem.hpp
gabriellanzer/Ravine-ECS
f96467508cd22d4f4b9230b6c5502da201869449
[ "MIT" ]
7
2019-09-10T10:22:52.000Z
2021-11-23T02:54:10.000Z
src/systems/EntityTestSystem.hpp
gabriellanzer/Ravine-ECS
f96467508cd22d4f4b9230b6c5502da201869449
[ "MIT" ]
null
null
null
src/systems/EntityTestSystem.hpp
gabriellanzer/Ravine-ECS
f96467508cd22d4f4b9230b6c5502da201869449
[ "MIT" ]
null
null
null
#ifndef ENTITYTESTSYSTEM_HPP #define ENTITYTESTSYSTEM_HPP #include "components/Position.h" #include "ravine/ecs.h" #include "ravine/ecs/Entity.hpp" using namespace rv; class EntityTestSystem : public BaseSystem<EntityProxy, Position> { void update(double deltaTime, int32_t size, EntityProxy* const e, Position* const p) final { for (int32_t i = 0; i < size; i++) { fprintf(stdout, "|Ent(%u)|Pos(%.3f,%.3f)", e[i].entityId, p[i].x, p[i].y); } } }; #endif
22.380952
91
0.695745
gabriellanzer