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
108
| 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
67k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
188c682e13e2b48640c0e8ed6c3b41088570741e
| 985
|
cpp
|
C++
|
src/crypto/RsaKey.cpp
|
toolbrew/libtoolchain
|
fd98be60d1c5ca62871c16c88b8e59be05d7f0ac
|
[
"MIT"
] | 4
|
2019-01-30T21:04:33.000Z
|
2022-03-20T04:24:34.000Z
|
src/crypto/RsaKey.cpp
|
toolbrew/libtoolchain
|
fd98be60d1c5ca62871c16c88b8e59be05d7f0ac
|
[
"MIT"
] | 2
|
2021-11-18T09:07:53.000Z
|
2021-11-19T13:25:20.000Z
|
src/crypto/RsaKey.cpp
|
toolbrew/libtoolchain
|
fd98be60d1c5ca62871c16c88b8e59be05d7f0ac
|
[
"MIT"
] | 1
|
2021-11-18T09:11:04.000Z
|
2021-11-18T09:11:04.000Z
|
#include <tc/crypto/RsaKey.h>
tc::crypto::RsaPublicKey::RsaPublicKey(const byte_t* modulus, size_t modulus_size)
{
static const byte_t kPublicExponent[3] = { 0x01, 0x00, 0x01 };
if (modulus != nullptr && modulus_size != 0)
{
this->n = tc::ByteData(modulus, modulus_size);
this->e = tc::ByteData(kPublicExponent, sizeof(kPublicExponent));
}
}
tc::crypto::RsaPrivateKey::RsaPrivateKey(const byte_t* modulus, size_t modulus_size, const byte_t* private_exponent, size_t private_exponent_size)
{
static const byte_t kPublicExponent[3] = { 0x01, 0x00, 0x01 };
if (modulus != nullptr && modulus_size != 0 && private_exponent != nullptr && private_exponent_size != 0)
{
this->n = tc::ByteData(modulus, modulus_size);
this->d = tc::ByteData(private_exponent, private_exponent_size);
this->e = tc::ByteData(kPublicExponent, sizeof(kPublicExponent));
}
}
tc::crypto::RsaKey tc::crypto::RsaPrivateKey::getPublicKey()
{
return RsaPublicKey(this->n.data(), this->n.size());
}
| 33.965517
| 146
| 0.722843
|
toolbrew
|
188f7f8ac0582f03242f27ce5a33f429eb32532a
| 9,520
|
hpp
|
C++
|
src/core/math_func.hpp
|
trademarks/OpenTTD
|
fd7fca73cf61a2960e8df8fa221b179d23ae3ef0
|
[
"Unlicense"
] | 8
|
2016-10-21T09:01:43.000Z
|
2021-05-31T06:32:14.000Z
|
src/core/math_func.hpp
|
blackberry/OpenTTD
|
fd7fca73cf61a2960e8df8fa221b179d23ae3ef0
|
[
"Unlicense"
] | null | null | null |
src/core/math_func.hpp
|
blackberry/OpenTTD
|
fd7fca73cf61a2960e8df8fa221b179d23ae3ef0
|
[
"Unlicense"
] | 4
|
2017-05-16T00:15:58.000Z
|
2020-08-06T01:46:31.000Z
|
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file math_func.hpp Integer math functions */
#ifndef MATH_FUNC_HPP
#define MATH_FUNC_HPP
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#ifdef abs
#undef abs
#endif
/**
* Returns the maximum of two values.
*
* This function returns the greater value of two given values.
* If they are equal the value of a is returned.
*
* @param a The first value
* @param b The second value
* @return The greater value or a if equals
*/
template <typename T>
static FORCEINLINE T max(const T a, const T b)
{
return (a >= b) ? a : b;
}
/**
* Returns the minimum of two values.
*
* This function returns the smaller value of two given values.
* If they are equal the value of b is returned.
*
* @param a The first value
* @param b The second value
* @return The smaller value or b if equals
*/
template <typename T>
static FORCEINLINE T min(const T a, const T b)
{
return (a < b) ? a : b;
}
/**
* Returns the minimum of two integer.
*
* This function returns the smaller value of two given integers.
*
* @param a The first integer
* @param b The second integer
* @return The smaller value
*/
static FORCEINLINE int min(const int a, const int b)
{
return ::min<int>(a, b);
}
/**
* Returns the minimum of two unsigned integers.
*
* This function returns the smaller value of two given unsigned integers.
*
* @param a The first unsigned integer
* @param b The second unsigned integer
* @return The smaller value
*/
static FORCEINLINE uint minu(const uint a, const uint b)
{
return ::min<uint>(a, b);
}
/**
* Returns the absolute value of (scalar) variable.
*
* @note assumes variable to be signed
* @param a The value we want to unsign
* @return The unsigned value
*/
template <typename T>
static FORCEINLINE T abs(const T a)
{
return (a < (T)0) ? -a : a;
}
/**
* Return the smallest multiple of n equal or greater than x
*
* @note n must be a power of 2
* @param x The min value
* @param n The base of the number we are searching
* @return The smallest multiple of n equal or greater than x
*/
template <typename T>
static FORCEINLINE T Align(const T x, uint n)
{
assert((n & (n - 1)) == 0 && n != 0);
n--;
return (T)((x + n) & ~((T)n));
}
/**
* Return the smallest multiple of n equal or greater than x
* Applies to pointers only
*
* @note n must be a power of 2
* @param x The min value
* @param n The base of the number we are searching
* @return The smallest multiple of n equal or greater than x
* @see Align()
*/
template <typename T>
static FORCEINLINE T *AlignPtr(T *x, uint n)
{
assert_compile(sizeof(size_t) == sizeof(void *));
return (T *)Align((size_t)x, n);
}
/**
* Clamp a value between an interval.
*
* This function returns a value which is between the given interval of
* min and max. If the given value is in this interval the value itself
* is returned otherwise the border of the interval is returned, according
* which side of the interval was 'left'.
*
* @note The min value must be less or equal of max or you get some
* unexpected results.
* @param a The value to clamp/truncate.
* @param min The minimum of the interval.
* @param max the maximum of the interval.
* @returns A value between min and max which is closest to a.
* @see ClampU(uint, uint, uint)
* @see Clamp(int, int, int)
*/
template <typename T>
static FORCEINLINE T Clamp(const T a, const T min, const T max)
{
assert(min <= max);
if (a <= min) return min;
if (a >= max) return max;
return a;
}
/**
* Clamp an integer between an interval.
*
* This function returns a value which is between the given interval of
* min and max. If the given value is in this interval the value itself
* is returned otherwise the border of the interval is returned, according
* which side of the interval was 'left'.
*
* @note The min value must be less or equal of max or you get some
* unexpected results.
* @param a The value to clamp/truncate.
* @param min The minimum of the interval.
* @param max the maximum of the interval.
* @returns A value between min and max which is closest to a.
* @see ClampU(uint, uint, uint)
*/
static FORCEINLINE int Clamp(const int a, const int min, const int max)
{
return Clamp<int>(a, min, max);
}
/**
* Clamp an unsigned integer between an interval.
*
* This function returns a value which is between the given interval of
* min and max. If the given value is in this interval the value itself
* is returned otherwise the border of the interval is returned, according
* which side of the interval was 'left'.
*
* @note The min value must be less or equal of max or you get some
* unexpected results.
* @param a The value to clamp/truncate.
* @param min The minimum of the interval.
* @param max the maximum of the interval.
* @returns A value between min and max which is closest to a.
* @see Clamp(int, int, int)
*/
static FORCEINLINE uint ClampU(const uint a, const uint min, const uint max)
{
return Clamp<uint>(a, min, max);
}
/**
* Reduce a signed 64-bit int to a signed 32-bit one
*
* This function clamps a 64-bit integer to a 32-bit integer.
* If the 64-bit value is smaller than the smallest 32-bit integer
* value 0x80000000 this value is returned (the left one bit is the sign bit).
* If the 64-bit value is greater than the greatest 32-bit integer value 0x7FFFFFFF
* this value is returned. In all other cases the 64-bit value 'fits' in a
* 32-bits integer field and so the value is casted to int32 and returned.
*
* @param a The 64-bit value to clamps
* @return The 64-bit value reduced to a 32-bit value
* @see Clamp(int, int, int)
*/
static FORCEINLINE int32 ClampToI32(const int64 a)
{
return (int32)Clamp<int64>(a, INT32_MIN, INT32_MAX);
}
/**
* Reduce an unsigned 64-bit int to an unsigned 16-bit one
*
* @param a The 64-bit value to clamp
* @return The 64-bit value reduced to a 16-bit value
* @see ClampU(uint, uint, uint)
*/
static FORCEINLINE uint16 ClampToU16(const uint64 a)
{
/* MSVC thinks, in its infinite wisdom, that int min(int, int) is a better
* match for min(uint64, uint) than uint64 min(uint64, uint64). As such we
* need to cast the UINT16_MAX to prevent MSVC from displaying its
* infinite loads of warnings. */
return (uint16)::min<uint64>(a, (uint64)UINT16_MAX);
}
/**
* Returns the (absolute) difference between two (scalar) variables
*
* @param a The first scalar
* @param b The second scalar
* @return The absolute difference between the given scalars
*/
template <typename T>
static FORCEINLINE T Delta(const T a, const T b)
{
return (a < b) ? b - a : a - b;
}
/**
* Checks if a value is between a window started at some base point.
*
* This function checks if the value x is between the value of base
* and base+size. If x equals base this returns true. If x equals
* base+size this returns false.
*
* @param x The value to check
* @param base The base value of the interval
* @param size The size of the interval
* @return True if the value is in the interval, false else.
*/
template <typename T>
static FORCEINLINE bool IsInsideBS(const T x, const uint base, const uint size)
{
return (uint)(x - base) < size;
}
/**
* Checks if a value is in an interval.
*
* Returns true if a value is in the interval of [min, max).
*
* @param x The value to check
* @param min The minimum of the interval
* @param max The maximum of the interval
* @see IsInsideBS()
*/
template <typename T>
static FORCEINLINE bool IsInsideMM(const T x, const uint min, const uint max)
{
return (uint)(x - min) < (max - min);
}
/**
* Type safe swap operation
* @param a variable to swap with b
* @param b variable to swap with a
*/
template <typename T>
static FORCEINLINE void Swap(T &a, T &b)
{
T t = a;
a = b;
b = t;
}
/**
* Converts a "fract" value 0..255 to "percent" value 0..100
* @param i value to convert, range 0..255
* @return value in range 0..100
*/
static FORCEINLINE uint ToPercent8(uint i)
{
assert(i < 256);
return i * 101 >> 8;
}
/**
* Converts a "fract" value 0..65535 to "percent" value 0..100
* @param i value to convert, range 0..65535
* @return value in range 0..100
*/
static FORCEINLINE uint ToPercent16(uint i)
{
assert(i < 65536);
return i * 101 >> 16;
}
int LeastCommonMultiple(int a, int b);
int GreatestCommonDivisor(int a, int b);
/**
* Computes ceil(a / b) for non-negative a and b.
* @param a Numerator
* @param b Denominator
* @return Quotient, rounded up
*/
static FORCEINLINE uint CeilDiv(uint a, uint b)
{
return (a + b - 1) / b;
}
/**
* Computes round(a / b) for signed a and unsigned b.
* @param a Numerator
* @param b Denominator
* @return Quotient, rounded to nearest
*/
static FORCEINLINE int RoundDivSU(int a, uint b)
{
if (a > 0) {
/* 0.5 is rounded to 1 */
return (a + (int)b / 2) / (int)b;
} else {
/* -0.5 is rounded to 0 */
return (a - ((int)b - 1) / 2) / (int)b;
}
}
#endif /* MATH_FUNC_HPP */
| 27.2
| 185
| 0.689496
|
trademarks
|
188fd34689a01e00169a8c77c4b3d3f2ddb114d1
| 8,771
|
cpp
|
C++
|
EScript/Utils/StringUtils.cpp
|
antifermion/EScript
|
eca6765c28e319eb77b4da81125bdbb2510c9add
|
[
"MIT"
] | 3
|
2017-06-01T15:58:43.000Z
|
2019-08-07T05:36:44.000Z
|
EScript/Utils/StringUtils.cpp
|
antifermion/EScript
|
eca6765c28e319eb77b4da81125bdbb2510c9add
|
[
"MIT"
] | 4
|
2015-01-23T18:17:50.000Z
|
2019-02-10T11:48:55.000Z
|
EScript/Utils/StringUtils.cpp
|
antifermion/EScript
|
eca6765c28e319eb77b4da81125bdbb2510c9add
|
[
"MIT"
] | 12
|
2015-01-04T16:07:45.000Z
|
2020-10-06T15:42:46.000Z
|
// StringUtils.cpp
// This file is part of the EScript programming language (https://github.com/EScript)
//
// Copyright (C) 2011-2013 Claudius Jähn <ClaudiusJ@live.de>
// Copyright (C) 2011-2012 Benjamin Eikel <benjamin@eikel.org>
//
// Licensed under the MIT License. See LICENSE file for details.
// ---------------------------------------------------------------------------------
#include "StringUtils.h"
#include <cstdlib>
#include <cstdio>
#include <iomanip>
#include <sstream>
namespace EScript{
double StringUtils::readNumber(const char * s, std::size_t & cursor, bool checkSign) {
char c = s[cursor];
std::string accum="";
bool sign = true;
if( checkSign && c=='-' && s[cursor+1]>='0' && s[cursor+1]<='9' ) {
++cursor;
sign = false;
c = s[cursor];
}
if(c=='0' && (s[cursor+1]=='x'|| s[cursor+1]=='X')) {
++cursor;
accum="0x";
while(true) {
++cursor;
c = s[cursor];
if( (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F')) {
accum+=c;
continue;
}
break;
}
unsigned int number = 0;
sscanf(accum.c_str(),"%x",&number);
return sign?static_cast<double>(number) : -static_cast<double>(number);
} else if(c=='0' && (s[cursor+1]=='b'|| s[cursor+1]=='B')) { // binaryNumber
++cursor;
double number = 0;
while(true) {
++cursor;
c = s[cursor];
if( c=='0' ){
number *= 2;
} else if( c=='1' ){
number *= 2;
++number;
}else{
break;
}
}
return sign?number : -number;
} else if(c>='0' && c<='9') {
//const char * begin = s+cursor;
int dot = 0;
char numAccum[100];
int i = 0;
while(i<98) {
numAccum[i++]=c;
++cursor;
c = s[cursor];
if( isdigit(c) || (c=='.' && isdigit(s[cursor+1]) && dot++ < 1))
continue;
else if( (c=='E' ||c=='e')&& (s[cursor+1]=='+' || s[cursor+1]=='-')) {
numAccum[i++]=c;
++cursor;
c = s[cursor];
continue;
}
break;
}
numAccum[i]=0;
double number = std::strtod(numAccum,nullptr);
return sign?number:-number;
}
return 0;
}
std::string StringUtils::trim(const std::string & s) {
if(s.empty())
return std::string();
unsigned int start,end;
for(start = 0;start<s.length();++start) {
const char c = s[start];
if(c!=' '&&c!='\t'&&c!='\n'&&c!='\r'&&c!='\0'&&c!=11)
break;
}
for(end = s.length()-1;end>=start;--end) {
const char c = s[end];
if(c!=' '&&c!='\t'&&c!='\n'&&c!='\r'&&c!='\0'&&c!=11)
break;
}
const int count = end-start+1;
return count>0 ? s.substr(start,count) : std::string();
}
std::string StringUtils::rTrim(const std::string & s){
for(int right = s.length()-1 ; right >= 0 ; --right){
const char c = s[right];
if( !(c==' '||c=='\t'||c=='\n'||c=='\r'||c=='\0'||c==11))
return s.substr(0,right+1);
}
return std::string();
}
std::string StringUtils::lTrim(const std::string & s){
for(size_t left = 0 ; left<s.length() ; ++left){
const char c = s[left];
if( !(c==' '||c=='\t'||c=='\n'||c=='\r'||c=='\0'||c==11))
return s.substr(left,s.length()-left);
}
return std::string();
}
std::string StringUtils::replaceAll(const std::string &subject,const std::string &find,const std::string &replace,int count) {
std::ostringstream s;
unsigned int cursor = 0;
unsigned int len = subject.length();
unsigned int fLen = find.length();
//unsigned int pos = string::npos;
int nr = 0;
while(cursor<len&& nr!=count) {
size_t pos = subject.find(find,cursor);
//std::cout << " found "<<search<<" at "<< pos<<"\n";
if(pos==std::string::npos) {
break;
}
if(pos>cursor) {
s<<subject.substr(cursor,pos-cursor);
cursor = pos;
}
s<<replace;
cursor+=fLen;
++nr;
}
if(cursor<len) {
s<<subject.substr(cursor,len-cursor);
}
return s.str();
}
std::string StringUtils::replaceMultiple(const std::string &subject,const std::vector<std::pair<std::string,std::string> > & rules,int max){
typedef std::pair<std::string,std::string> keyValuePair_t;
const size_t ruleCount = rules.size();
std::vector<size_t> findLen(ruleCount);
std::vector<size_t> pos(ruleCount);
size_t i = 0;
for(const auto & keyValuePair : rules) {
// length of the search pattern
findLen[i] = keyValuePair.first.length();
// first position
pos[i] = subject.find(keyValuePair.first, 0);
++i;
}
int nr = 0;
std::ostringstream s;
size_t cursor = 0;
const size_t len = subject.length();
while(cursor<len&& nr!=max) {
// select next match
size_t nextPos = std::string::npos;
size_t nextFindLength = 0;
std::vector<keyValuePair_t>::const_iterator nextReplace = rules.begin();
std::vector<keyValuePair_t>::const_iterator ruleIt = rules.begin();
for(i = 0;i<ruleCount;++i,++ruleIt) {
// search not found -> continue
if(pos[i]==std::string::npos) {
continue;
}
// stepped over position (overlapping foundings) -> search again
if(cursor>pos[i]) {
pos[i]=subject.find((*ruleIt).first,cursor);
}
// nearest founding?
if(pos[i]<nextPos) {
nextReplace = ruleIt;
nextPos = pos[i];
nextFindLength = findLen[i];
}
}
// found nothing? -> finished
if(nextPos==std::string::npos)
break;
// append string
s<<subject.substr(cursor,nextPos-cursor);
s<<(*nextReplace).second;
cursor = nextPos+nextFindLength;
++nr;
}
// add ending
if(cursor<len)
s<<subject.substr(cursor,len-cursor);
return s.str();
}
/**
* TODO: 4byte encoding!
*/
std::string StringUtils::UCS2LE_to_ANSII(const std::string & source) {
std::ostringstream s;
size_t length = source.length();
if(length%2==1)
length--;
const uint8_t * c = reinterpret_cast<const uint8_t*>(source.data());
for(size_t i = 0;i<length;i+=2) {
// ascii char
if(c[i+1]==0x00) {
s<<static_cast<char>(c[i]);
}
// wrong encoding (illegal character)
else if(c[i]==0xfe && c[i+1]==0xff)
throw "UCS2LE_to_ANSII wrong encoding! Try big ending instead.";
else if(c[i]==0xff && c[i+1]==0xfe) // ignore
continue;
// // 4 byte TODO: http://en.wikipedia.org/wiki/UTF-16/UCS-2
// else if(){
// }
// 2 byte //⊕
else {
s<<"&#x"<<std::hex<<std::setfill ('0') <<
static_cast<int>(0x0100*c[i+1]+c[i]) <<std::dec<<";";
}
}
return s.str();
}
std::vector<std::string> StringUtils::split(const std::string & subject,const std::string & delimiter, int max){
std::vector<std::string> result;
const size_t len = subject.length();
if(len>0){
const size_t delimiterLen = delimiter.length();
if(delimiterLen>len || delimiterLen==0){
result.emplace_back(subject);
}else{
size_t cursor = 0;
for( int i = 1 ; i!=max&&cursor<=len-delimiterLen ; ++i){
size_t pos = subject.find(delimiter,cursor);
if( pos==std::string::npos ) // no delimiter found? -> to the end
pos = len;
result.push_back( subject.substr(cursor,pos-cursor) );
cursor = pos+delimiterLen;
if(cursor==len){ // ending on delimiter? -> add empty part
result.push_back("");
}
}
if(cursor<len)
result.push_back( subject.substr(cursor,len-cursor) );
}
}
return result;
}
static std::vector<std::pair<std::string,std::string>> getEscapeRules(){
typedef std::pair<std::string,std::string> keyValuePair_t;
std::vector<keyValuePair_t> replace;
replace.emplace_back("\"","\\\"");
replace.emplace_back("\b","\\b");
replace.emplace_back("\f","\\f");
replace.emplace_back("\n","\\n");
replace.emplace_back("\r","\\r");
replace.emplace_back("\t","\\t");
replace.emplace_back(std::string("\0",1),"\\0");
replace.emplace_back("\\","\\\\");
return replace;
}
std::string StringUtils::escape(const std::string & s){
static const auto escapeRules = getEscapeRules();
return replaceMultiple(s,escapeRules);
}
std::string StringUtils::getLine(const std::string &s,const int lineIndex){
size_t cursor = 0;
for(int i = 0;i<lineIndex;++i){
cursor = s.find('\n',cursor);
if(cursor == std::string::npos){
return "";
}
++cursor;
}
return s.substr(cursor, s.find('\n',cursor)-cursor );
}
std::string StringUtils::utf32_to_utf8(const uint32_t u32){
if(u32<=0x7F){
return { static_cast<char>(u32) }; // 0XXXXXXX
}else if(u32<=0x7FF){
return { static_cast<char>(0xC0 | ( (u32>>6) & 0x1F)), // 110XXXXX
static_cast<char>(0x80 | (u32&0x3F)) }; // 10XXXXXX
}else if(u32<=0xFFFF){
return { static_cast<char>(0xE0 | ( (u32>>12) & 0x0F)), // 1110XXXX
static_cast<char>(0x80 | ( (u32>>6) & 0x3F)), // 10XXXXXX
static_cast<char>(0x80 | (u32&0x3F)) }; // 10XXXXXX
}else if(u32<=0x13FFFF){
return { static_cast<char>(0xF0 | ( (u32>>18) & 0x07)), // 11110XXX
static_cast<char>(0x80 | ( (u32>>12) & 0x3F)), // 10XXXXXX
static_cast<char>(0x80 | ( (u32>>6) & 0x3F)), // 10XXXXXX
static_cast<char>(0x80 | (u32&0x3F)) }; // 10XXXXXX
}else {
return std::string();
}
}
}
| 27.070988
| 140
| 0.598221
|
antifermion
|
189309b189ef2a7c81a032054990158edefebe36
| 2,150
|
cpp
|
C++
|
src/camera-window-manager/src/wayland_exporter.cpp
|
webosose/g-camera-pipeline
|
8556015279e60ce4531f8566d1d62522faf6d63d
|
[
"Apache-2.0"
] | 2
|
2019-05-06T05:28:05.000Z
|
2020-05-11T16:24:29.000Z
|
src/camera-window-manager/src/wayland_exporter.cpp
|
webosose/g-camera-pipeline
|
8556015279e60ce4531f8566d1d62522faf6d63d
|
[
"Apache-2.0"
] | 1
|
2019-10-19T12:22:36.000Z
|
2019-10-19T12:22:36.000Z
|
src/camera-window-manager/src/wayland_exporter.cpp
|
webosose/g-camera-pipeline
|
8556015279e60ce4531f8566d1d62522faf6d63d
|
[
"Apache-2.0"
] | null | null | null |
// Copyright (c) 2020 LG Electronics, 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.
// SPDX-License-Identifier: Apache-2.0
#include "wayland_exporter.h"
void handlerWindowIDAssigned(void *data, struct wl_webos_exported *wlWebosExported, const char *windowID,
uint32_t exportedType)
{
auto exporter = (Wayland::Exporter *)data;
exporter->setWindowID(windowID);
}
static const struct wl_webos_exported_listener exportedListener = {handlerWindowIDAssigned};
namespace Wayland
{
Exporter::Exporter() : webosExported(nullptr) {}
Exporter::~Exporter() {}
bool Exporter::initialize(struct wl_display *display, struct wl_webos_foreign *foreign, struct wl_surface *surface,
uint32_t exportedType)
{
webosExported = wl_webos_foreign_export_element(foreign, surface, exportedType);
if (webosExported == nullptr)
return false;
wl_webos_exported_add_listener(webosExported, &exportedListener, this);
wl_display_dispatch(display);
return true;
}
void Exporter::finalize(void)
{
if (webosExported) {
wl_webos_exported_destroy(webosExported);
webosExported = nullptr;
}
}
void Exporter::setWindowID(const char *windowID) { this->windowID = windowID; }
const char *Exporter::getWindowID(void) { return windowID.c_str(); }
struct wl_webos_exported *Exporter::getWebosExported(void) { return webosExported; }
void Exporter::setRegion(struct wl_region *sourceRegion, struct wl_region *destinationRegion)
{
wl_webos_exported_set_exported_window(webosExported, sourceRegion, destinationRegion);
}
} // namespace Wayland
| 30.714286
| 115
| 0.73907
|
webosose
|
1894824c572149dce7dd6048bb1b0dd424057556
| 1,167
|
cpp
|
C++
|
src/PixelSampler.cpp
|
fuchsteufelswild/Ray-Tracer
|
d83553db691543b7925a31ca57139490547279c0
|
[
"MIT"
] | null | null | null |
src/PixelSampler.cpp
|
fuchsteufelswild/Ray-Tracer
|
d83553db691543b7925a31ca57139490547279c0
|
[
"MIT"
] | null | null | null |
src/PixelSampler.cpp
|
fuchsteufelswild/Ray-Tracer
|
d83553db691543b7925a31ca57139490547279c0
|
[
"MIT"
] | null | null | null |
#include "PixelSampler.h"
#include "Camera.h"
namespace actracer
{
PixelSampler *PixelSampler::CreatePixelSampler(PixelSampleMethod method)
{
switch(method)
{
case PixelSampleMethod::JITTERED:
return new JitteredPixelSampler();
}
return nullptr;
}
void JitteredPixelSampler::Init(const Camera &camera)
{
mRandomizerX = Random<double>{};
mRandomizerY = Random<double>{};
mSampleCount = camera.GetSampleCount();
mSampleCountSquared = std::sqrt(mSampleCount);
mSampleWidthHeight = 1.0f / mSampleCountSquared;
}
std::pair<float, float> JitteredPixelSampler::operator()(const Pixel& px, int sampleId) const
{
std::pair<float, float> samplePos = px.pixelBox.FindIthPartition(sampleId, mSampleCountSquared, mSampleWidthHeight); // Find the position of the ith partition sample (e.g 6x6 pixel's 20th)
float randX = mRandomizerX(0.0f, mSampleWidthHeight);
float randY = mRandomizerY(0.0f, mSampleWidthHeight);
samplePos.first += randX;
samplePos.second += randY;
return samplePos;
}
}
| 29.923077
| 196
| 0.655527
|
fuchsteufelswild
|
1895814a43f7931419ca6f3e711413691498f88c
| 5,883
|
cpp
|
C++
|
IntegrationPlatform/Adapters/Subversion/Interop.Subversion/SubversionClient.cpp
|
adamdriscoll/TfsIntegrationPlatform
|
28e0f51e804423bbde61083422711113662f2710
|
[
"MIT"
] | 6
|
2016-09-06T19:41:51.000Z
|
2021-06-08T19:50:15.000Z
|
IntegrationPlatform/Adapters/Subversion/Interop.Subversion/SubversionClient.cpp
|
adamdriscoll/TfsIntegrationPlatform
|
28e0f51e804423bbde61083422711113662f2710
|
[
"MIT"
] | null | null | null |
IntegrationPlatform/Adapters/Subversion/Interop.Subversion/SubversionClient.cpp
|
adamdriscoll/TfsIntegrationPlatform
|
28e0f51e804423bbde61083422711113662f2710
|
[
"MIT"
] | 6
|
2016-05-24T13:57:54.000Z
|
2020-01-27T12:11:57.000Z
|
#include "stdafx.h"
#include "AprPool.h"
#include "LibraryLoader.h"
#include "SvnError.h"
#include "SubversionClient.h"
#include "SubversionContext.h"
#include "Utils.h"
#include "ChangeSet.h"
#include "Item.h"
#include "DiffSummaryCommand.h"
#include "DownloadCommand.h"
#include "ItemInfoCommand.h"
#include "LatestRevisionCommand.h"
#include "ListCommand.h"
#include "LogCommand.h"
#include "SubversionInfoCommand.h"
using namespace System;
using namespace System::Collections::Generic;
using namespace Microsoft::TeamFoundation::Migration::Toolkit;
using namespace Microsoft::TeamFoundation::Migration::SubversionAdapter::Interop::Subversion;
using namespace Microsoft::TeamFoundation::Migration::SubversionAdapter::Interop::Subversion::Commands;
using namespace Microsoft::TeamFoundation::Migration::SubversionAdapter::Interop::Subversion::Helpers;
using namespace Microsoft::TeamFoundation::Migration::SubversionAdapter::Interop::Subversion::ObjectModel;
SubversionClient::SubversionClient()
{
Interlocked::Increment(s_references);
}
SubversionClient::~SubversionClient()
{
int count = Interlocked::Decrement(s_references);
if(0 == count)
{
//This is the last instance. Release all unmanaged ressources that are shared between the instances
DynamicInvocation::LibraryLoader::Instance()->ReleaseLibraries();
}
Disconnect();
}
void
SubversionClient::Connect(Uri^ repository, NetworkCredential^ credential)
{
if(nullptr == repository)
{
throw gcnew ArgumentNullException("repository");
}
try
{
m_context = gcnew SubversionContext(credential);
m_virtualRepositoryRoot = repository;
SubversionInfoCommand^ command = gcnew SubversionInfoCommand(m_context, repository);
command->Execute(m_repositoryRoot, m_repositoryID);
}
catch(Exception^)
{
Disconnect();
throw;
}
}
void
SubversionClient::Disconnect()
{
m_virtualRepositoryRoot = nullptr;
m_repositoryRoot = nullptr;
m_repositoryID = Guid::Empty;
if(nullptr != m_context)
{
delete m_context;
m_context = nullptr;
}
}
bool
SubversionClient::IsConnected::get()
{
return nullptr != m_context;
}
Guid
SubversionClient::RepositoryId::get()
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
return m_repositoryID;
}
Uri^
SubversionClient::RepositoryRoot::get()
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
return m_repositoryRoot;
}
Uri^
SubversionClient::VirtualRepositoryRoot::get()
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
return m_virtualRepositoryRoot;
}
long
SubversionClient::GetLatestRevisionNumber(Uri^ path)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
long result;
LatestRevisionCommand^ command = gcnew LatestRevisionCommand(m_context, path);
command->Execute(result);
return result;
}
SubversionContext^
SubversionClient::Context::get()
{
return m_context;
}
Dictionary<long, ChangeSet^>^
SubversionClient::QueryHistoryRange(Uri^ path, long startRevisionNumber, long endRevisionNumber, bool includeChanges)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
Dictionary<long, ChangeSet^>^ changesets;
LogCommand^ command = gcnew LogCommand(this, path, startRevisionNumber, endRevisionNumber, includeChanges);
command->Execute(changesets);
return changesets;
}
Dictionary<long, ChangeSet^>^
SubversionClient::QueryHistory(Uri^ path, long startRevisionNumber, int limit, bool includeChanges)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
Dictionary<long, ChangeSet^>^ changesets;
LogCommand^ command = gcnew LogCommand(this, path, startRevisionNumber, limit, includeChanges);
command->Execute(changesets);
return changesets;
}
Dictionary<long, ChangeSet^>^
SubversionClient::QueryHistory(Uri^ path, int limit, bool includeChanges)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
Dictionary<long, ChangeSet^>^ changesets;
LogCommand^ command = gcnew LogCommand(this, path, limit, includeChanges);
command->Execute(changesets);
return changesets;
}
List<ItemInfo^>^
SubversionClient::QueryItemInfo(Uri^ path, long revision, Depth depth)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
List<ItemInfo^>^ items;
ItemInfoCommand^ command = gcnew ItemInfoCommand(this, path, revision, depth);
command->Execute(items);
return items;
}
void
SubversionClient::DownloadItem(Uri^ fromPath, long revision, String^ toPath)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
DownloadCommand^ command = gcnew DownloadCommand(m_context, fromPath, revision, toPath);
command->Execute();
}
bool
SubversionClient::HasContentChange(Uri^ path1, long revision1, System::Uri^ path2, long revision2)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
bool result;
DiffSummaryCommand^ command = gcnew DiffSummaryCommand(m_context, path1, revision1, path2, revision2);
command->AreEqual(result);
return !result;
}
List<ObjectModel::Item^>^
SubversionClient::GetItems(Uri^ path, long revision, Depth depth)
{
if(!IsConnected)
{
throw gcnew MigrationException("Subversion Client: There is currently no active connection");
}
List<Item^>^ items;
ListCommand^ command = gcnew ListCommand(this, path, revision, depth);
command->Execute(items);
return items;
}
| 23.438247
| 117
| 0.767126
|
adamdriscoll
|
189ab1746731ed04a998dfa4cd3d82c3d019fbc2
| 3,420
|
cpp
|
C++
|
tests/math/TestDegMinSec.cpp
|
marek-cel/libmcutils
|
671a20f37378d32ade4decefdbfba70448d12504
|
[
"MIT"
] | null | null | null |
tests/math/TestDegMinSec.cpp
|
marek-cel/libmcutils
|
671a20f37378d32ade4decefdbfba70448d12504
|
[
"MIT"
] | null | null | null |
tests/math/TestDegMinSec.cpp
|
marek-cel/libmcutils
|
671a20f37378d32ade4decefdbfba70448d12504
|
[
"MIT"
] | null | null | null |
#include <gtest/gtest.h>
#include <mcutils/math/DegMinSec.h>
#include <mcutils/misc/Units.h>
////////////////////////////////////////////////////////////////////////////////
class TestDegMinSec : public ::testing::Test
{
protected:
TestDegMinSec() {}
virtual ~TestDegMinSec() {}
void SetUp() override {}
void TearDown() override {}
};
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanConstruct)
{
mc::DegMinSec *dms = nullptr;
EXPECT_NO_THROW( dms = new mc::DegMinSec() );
delete dms;
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanDestruct)
{
mc::DegMinSec *dms = new mc::DegMinSec();
EXPECT_NO_THROW( delete dms );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanInstantiate)
{
mc::DegMinSec dms;
EXPECT_EQ( dms.deg(), 0 );
EXPECT_EQ( dms.min(), 0 );
EXPECT_DOUBLE_EQ( dms.sec(), 0.0 );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanInstantiateAndCopy)
{
mc::DegMinSec dms( mc::Units::deg2rad( 1.0 + 2.0 / 60.0 + 3.0 / 3600.0 ) );
mc::DegMinSec dms1( dms );
EXPECT_EQ( dms1.deg(), 1 );
EXPECT_EQ( dms1.min(), 2 );
EXPECT_NEAR( dms1.sec(), 3.0, 1e-9 );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanInstantiateAndSetData)
{
mc::DegMinSec dms( mc::Units::deg2rad( 1.0 + 2.0 / 60.0 + 3.0 / 3600.0 ) );
EXPECT_EQ( dms.deg(), 1 );
EXPECT_EQ( dms.min(), 2 );
EXPECT_NEAR( dms.sec(), 3.0, 1e-9 );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanValidate)
{
mc::DegMinSec dms1( M_PI_4 );
EXPECT_TRUE( dms1.isValid() );
mc::DegMinSec dms2( std::numeric_limits<double>::quiet_NaN() );
EXPECT_FALSE( dms2.isValid() );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanGetAngle)
{
mc::DegMinSec dms( M_PI_4 );
EXPECT_DOUBLE_EQ( dms.getAngle(), M_PI_4 );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanSetAngle)
{
mc::DegMinSec dms;
dms.setAngle( M_PI_4 );
EXPECT_DOUBLE_EQ( dms.getAngle(), M_PI_4 );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanConvertToString)
{
mc::DegMinSec dms( mc::Units::deg2rad( 1.0 + 2.0 / 60.0 + 3.0 / 3600.0 ) );
EXPECT_STREQ( dms.toString().c_str(), "1 deg 2 min 3.00 sec" );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanAssign)
{
mc::DegMinSec dms;
mc::DegMinSec dms1( mc::Units::deg2rad( 1.0 + 2.0 / 60.0 + 3.0 / 3600.0 ) );
dms = dms1;
EXPECT_EQ( dms.deg(), 1 );
EXPECT_EQ( dms.min(), 2 );
EXPECT_NEAR( dms.sec(), 3.0, 1e-9 );
}
////////////////////////////////////////////////////////////////////////////////
TEST_F(TestDegMinSec, CanCompare)
{
mc::DegMinSec dms;
mc::DegMinSec dms1( mc::Units::deg2rad( 1.0 + 2.0 / 60.0 + 3.0 / 3600.0 ) );
EXPECT_FALSE( dms == dms1 );
EXPECT_TRUE( dms != dms1 );
dms = dms1;
EXPECT_TRUE( dms == dms1 );
EXPECT_FALSE( dms != dms1 );
}
| 25.333333
| 80
| 0.442105
|
marek-cel
|
189d437d84aa7e638e11153d010e2eae2ef5abaf
| 175
|
cpp
|
C++
|
hermes/src/edu/cmu/hermes/runtime/ThreadDelayFault.cpp
|
rolandomar/hermesCPP
|
32ba11155a88ba0292c4467c08cf6efbc90e37b2
|
[
"Apache-2.0"
] | 1
|
2017-10-09T03:50:37.000Z
|
2017-10-09T03:50:37.000Z
|
hermes/src/edu/cmu/hermes/runtime/ThreadDelayFault.cpp
|
rolandomar/hermesCPP
|
32ba11155a88ba0292c4467c08cf6efbc90e37b2
|
[
"Apache-2.0"
] | null | null | null |
hermes/src/edu/cmu/hermes/runtime/ThreadDelayFault.cpp
|
rolandomar/hermesCPP
|
32ba11155a88ba0292c4467c08cf6efbc90e37b2
|
[
"Apache-2.0"
] | null | null | null |
/*
* File: ThreadDelayFault.cpp
* Author: rmartins
*
* Created on May 3, 2013, 2:06 PM
*/
#include "ThreadDelayFault.h"
ThreadDelayFault::~ThreadDelayFault() {
}
| 12.5
| 39
| 0.657143
|
rolandomar
|
189dd762c3f93eed453312720521f283395b5022
| 3,367
|
cpp
|
C++
|
base64.cpp
|
MichaelWallace30/fileTransfer
|
d2950a7f24d82ee03ce42fa77fe173614bd21239
|
[
"MIT"
] | null | null | null |
base64.cpp
|
MichaelWallace30/fileTransfer
|
d2950a7f24d82ee03ce42fa77fe173614bd21239
|
[
"MIT"
] | null | null | null |
base64.cpp
|
MichaelWallace30/fileTransfer
|
d2950a7f24d82ee03ce42fa77fe173614bd21239
|
[
"MIT"
] | null | null | null |
#include<iostream>
using namespace std;
/*
encode: 6bit to 8bit
decode: 8bit to 6bit
needs padding if:
convert 3 bytes of 8 bit data into 4 chunks of 6 bits each
don't add new value of 0 to buffer use = sign
value char
0 A 16 Q 32 g 48 w
1 B 17 R 33 h 49 x
2 C 18 S 34 i 50 y
3 D 19 T 35 j 51 z
4 E 20 U 36 k 52 0
5 F 21 V 37 l 53 1
6 G 22 W 38 m 54 2
7 H 23 X 39 n 55 3
8 I 24 Y 40 o 56 4
9 J 25 Z 41 p 57 5
10 K 26 a 42 q 58 6
11 L 27 b 43 r 59 7
12 M 28 c 44 s 60 8
13 N 29 d 45 t 61 9
14 O 30 e 46 u 62 +
15 P 31 f 47 v 63 /
*/
//A = 255
//a = 97
//example: Hello World!!! == SGVsbG8gV29ybGQhISE=
#include "base64.h"
const std::string assciiBase64LookUp ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
#include <vector>
std::vector<char>* encode64(std::vector<char>* buffer)
{
int padding = 0;
//check for padding and pad extra zeros so we don't go out of scope of vector
while ((*buffer).size() % BLOCK_SIZE != 0)
{
buffer->push_back(0);
padding++;
}
char array[BLOCK_SIZE_64] = { 0 };
//CALUCALTE NEW SIZE of new vector
int newSize = buffer->size();
if (newSize % BLOCK_SIZE != 0)
{
newSize += newSize % BLOCK_SIZE;
}
newSize = (newSize / BLOCK_SIZE) * BLOCK_SIZE_64;
//COPY to new vector
std::vector<char>* buffer2 = new std::vector<char>;
buffer2->resize(newSize);
//encode and copy to new vector
for (int i = 0; i < buffer->size() /3; i++)
{
//convert to base64 by base64 lookuptable index
array[0] = ((*buffer)[0 + (i * 3)] & 0xfc) >> 2;
array[1] = (((*buffer)[0 + (i * 3)] & 0x03) << 4) + (((*buffer)[1 + (i * 3)] & 0xf0) >> 4);
array[2] = (((*buffer)[1 + (i * 3)] & 0x0f) << 2) + (((*buffer)[2 + (i * 3)] & 0xc0) >> 6);
array[3] = (*buffer)[2 + (i * 3)] & 0x3f;
//use look up table index to set value of base64
(*buffer2)[0 + (i * 4)] = assciiBase64LookUp[array[0]];
(*buffer2)[1 + (i * 4)] = assciiBase64LookUp[array[1]];
(*buffer2)[2 + (i * 4)] = assciiBase64LookUp[array[2]];
(*buffer2)[3 + (i * 4)] = assciiBase64LookUp[array[3]];
}
//add padding symbol '=' for lengths not module 0 of block size
for (int x = 1; x <= padding; x++)
{
(*buffer2)[newSize - x] = '=';
}
//delete old vector
delete buffer;
return buffer2;
}
std::vector<char>* decode64(std::vector<char>* buffer)
{
std::vector<char>* buffer2 = new std::vector<char>;
int newSize = (buffer->size() / BLOCK_SIZE_64) * BLOCK_SIZE;
//check for '=' padding
int sizeReduction = 0;
for (int i = buffer->size() - 1; i > buffer->size() - BLOCK_SIZE - 1; i --)
{
if ((*buffer)[i] == '=')
{
sizeReduction++;
}
}
//reszie for non needed '='
buffer2->resize(newSize - sizeReduction);
//decode and copy to new vector
for (int i = 0; i < newSize / 3; i++)
{
int index = i * 3;
(*buffer2)[index++] = (((assciiBase64LookUp.find((*buffer)[0 + i * 4]) & 0x3f) << 2) + ((assciiBase64LookUp.find((*buffer)[1 + i * 4]) & 0x30) >> 4));
if(index < (newSize - sizeReduction))(*buffer2)[index++] = (((assciiBase64LookUp.find((*buffer)[1 + i * 4]) & 0x0F) << 4) + ((assciiBase64LookUp.find((*buffer)[2 + i * 4]) & 0x3C) >> 2));
if(index < (newSize - sizeReduction))(*buffer2)[index] = (((assciiBase64LookUp.find((*buffer)[2 + i * 4]) & 0x03) << 6) + (assciiBase64LookUp.find((*buffer)[3 + i * 4]) & 0x3f));
}
//delete old vector buffer return new
delete buffer;
return buffer2;
}
| 27.373984
| 189
| 0.608851
|
MichaelWallace30
|
18a0c0bf52b589eba12fa14176cd6b60ca0b54a9
| 165
|
cpp
|
C++
|
test/llvm_test_code/inst_interaction/call_03.cpp
|
janniclas/phasar
|
324302ae96795e6f0a065c14d4f7756b1addc2a4
|
[
"MIT"
] | 1
|
2022-02-15T07:56:29.000Z
|
2022-02-15T07:56:29.000Z
|
test/llvm_test_code/inst_interaction/call_03.cpp
|
fabianbs96/phasar
|
5b8acd046d8676f72ce0eb85ca20fdb0724de444
|
[
"MIT"
] | null | null | null |
test/llvm_test_code/inst_interaction/call_03.cpp
|
fabianbs96/phasar
|
5b8acd046d8676f72ce0eb85ca20fdb0724de444
|
[
"MIT"
] | null | null | null |
unsigned factorial(unsigned n) {
if (n <= 1) {
return 1;
}
return n * factorial(n - 1);
}
int main() {
int i = 7;
int j = factorial(i);
return j;
}
| 12.692308
| 32
| 0.533333
|
janniclas
|
18a3f669a79f7fb1497e93cd6e1c65e4aabc2da0
| 3,600
|
cpp
|
C++
|
include/ibeosdk/database/datamodel/BsonT_Processing.cpp
|
chouer19/enjoyDriving
|
e4a29e6cad7d3b0061d59f584cce7cdea2a55351
|
[
"MIT"
] | 1
|
2020-07-04T15:23:05.000Z
|
2020-07-04T15:23:05.000Z
|
include/ibeosdk/database/datamodel/BsonT_Processing.cpp
|
chouer19/enjoyDriving
|
e4a29e6cad7d3b0061d59f584cce7cdea2a55351
|
[
"MIT"
] | null | null | null |
include/ibeosdk/database/datamodel/BsonT_Processing.cpp
|
chouer19/enjoyDriving
|
e4a29e6cad7d3b0061d59f584cce7cdea2a55351
|
[
"MIT"
] | null | null | null |
//======================================================================
/*! \file BsonT_Processing.cpp
*
* \copydoc Copyright
* \author Kristian Bischoff (kb)
* \date Feb 8, 2016
*///-------------------------------------------------------------------
//======================================================================
#include <ibeosdk/database/datamodel/BsonT.hpp>
#include <ibeosdk/database/basedatamodel/Processing.hpp>
//======================================================================
namespace ibeosdk {
namespace dbaccess {
//======================================================================
const std::string BsonT<ProcessingJob>::bsonTypeName = "EVSType";
const std::string BsonT<ProcessingJob>::bsonFtProcJobName = "displayName";
const std::string BsonT<ProcessingJob>::bsonFtProcJobTripName = "tripName";
const std::string BsonT<ProcessingJob>::bsonFtProcJobResultConfig = "resultConfig";
const std::string BsonT<ProcessingJob>::bsonFtProcJobStartTime = "startProcessingTime";
const std::string BsonT<ProcessingJob>::bsonFtProcJobFinishTime = "finishProcessingTime";
const std::string BsonT<Processing>::bsonFtProcessingName = "processingJobListName";
const std::string BsonT<Processing>::bsonFtProcessingJobs = "jobs";
//======================================================================
void BsonT<ProcessingJob>::createDataType(ProcessingJob& data,
const mongo::BSONObj& bsonObj)
{
mongo::BSONElement elem;
bsonObj.getObjectID(elem);
const std::string type = bsonObj.getField(bsonTypeName).String();
mongo::Date_t start = bsonObj.getField(bsonFtProcJobStartTime).Date();
mongo::Date_t end = bsonObj.getField(bsonFtProcJobFinishTime).Date();
std::vector<std::string> resultConf;
if(bsonObj.hasField(bsonFtProcJobResultConfig)){
mongo::BSONObjIterator fields (bsonObj.getField(bsonFtProcJobResultConfig).Obj());
while(fields.more()) {
resultConf.push_back(fields.next().String());
}
};
data.setDbId(elem.OID().toString());
data.setJobType(ProcessingUtil::getInstance()->getTypeFromStr(type));
data.setStartTime(NTPTime(MongoDbUtils::convertToBoostTimestamp(start)));
data.setFinishTime(NTPTime(MongoDbUtils::convertToBoostTimestamp(end)));
data.setTripName(bsonObj.getField(bsonFtProcJobTripName).String());
data.setResultConfig(resultConf);
}
//======================================================================
//======================================================================
//======================================================================
//======================================================================
//======================================================================
//======================================================================
void BsonT<Processing>::createDataType(Processing& data,
const mongo::BSONObj& bsonObj)
{
data.setName(bsonObj.getField(bsonFtProcessingName).String());
std::vector<mongo::BSONElement> jobList=bsonObj.getField(bsonFtProcessingJobs).Array();
std::vector<mongo::BSONElement>::const_iterator pIter=jobList.begin();
for (; pIter != jobList.end(); ++pIter) {
CollectionName cName(( *pIter).dbrefNS());
ProcessingJob newProcJob(cName, ( *pIter).dbrefOID().toString());
data.addProcessingJob(newProcJob);
}
}
//======================================================================
} // namespace dbaccess
} // namespace ibeosdk
//======================================================================
| 39.130435
| 92
| 0.525
|
chouer19
|
18a508afc7992496e3e529e792d1d966a2e88bf8
| 443
|
cpp
|
C++
|
UVa/10394 - Twin Primes.cpp
|
geniustanley/problem-solving
|
2b83c5c8197fa8fe2277367027b392a2911d4a28
|
[
"Apache-2.0"
] | 1
|
2018-11-21T07:36:16.000Z
|
2018-11-21T07:36:16.000Z
|
UVa/10394 - Twin Primes.cpp
|
geniustanley/problem-solving
|
2b83c5c8197fa8fe2277367027b392a2911d4a28
|
[
"Apache-2.0"
] | null | null | null |
UVa/10394 - Twin Primes.cpp
|
geniustanley/problem-solving
|
2b83c5c8197fa8fe2277367027b392a2911d4a28
|
[
"Apache-2.0"
] | null | null | null |
#include <stdio.h>
int prime[20000005] = {1, 1, 0};
int answer[100005] = {0};
int main(void)
{
int cnt = 1;
long long i, j;
for(i = 3; i < 20000000 && cnt <= 100000; i += 2) {
if(!prime[i]) {
for(j = i * i; j < 20000000; j+=i)
prime[j] = 1;
if(!prime[i] && !prime[i-2])
answer[cnt++] = i-2;
}
}
int n;
while(scanf("%d", &n) != EOF) {
printf("(%d, %d)\n", answer[n], answer[n]+2);
}
return 0;
}
| 20.136364
| 53
| 0.471783
|
geniustanley
|
18a7a3e7ab2055ea602c5b62e535d56ce665e2bd
| 2,004
|
hpp
|
C++
|
irohad/ametsuchi/index/index.hpp
|
tkyonezu/iroha-hakodate
|
4545c22bfb0db10d441182540d3caa7fd8375c48
|
[
"Apache-2.0"
] | null | null | null |
irohad/ametsuchi/index/index.hpp
|
tkyonezu/iroha-hakodate
|
4545c22bfb0db10d441182540d3caa7fd8375c48
|
[
"Apache-2.0"
] | null | null | null |
irohad/ametsuchi/index/index.hpp
|
tkyonezu/iroha-hakodate
|
4545c22bfb0db10d441182540d3caa7fd8375c48
|
[
"Apache-2.0"
] | null | null | null |
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AMETSUCHI_INDEX_INDEX_HPP
#define AMETSUCHI_INDEX_INDEX_HPP
#include <cstdint>
#include <nonstd/optional.hpp>
#include <string>
#include <vector>
namespace iroha {
namespace ametsuchi {
namespace index {
class Index {
public:
virtual bool add_blockhash_blockid(std::string block_hash,
uint32_t height) = 0;
virtual nonstd::optional<uint64_t> get_blockid_by_blockhash(
std::string hash) = 0;
virtual bool add_txhash_blockid_txid(std::string txhash,
uint32_t height, int txid) = 0;
virtual bool add_pubkey_txhash(std::string pubkey,
std::string txhash) = 0;
virtual nonstd::optional<uint64_t> get_txid_by_txhash(
std::string txhash) = 0;
virtual nonstd::optional<uint64_t> get_blockid_by_txhash(
std::string txhash) = 0;
virtual nonstd::optional<std::vector<std::string>>
get_txhashes_by_pubkey(std::string pubkey) = 0;
virtual nonstd::optional<uint64_t> get_last_blockid() = 0;
virtual bool exec_multi() = 0;
virtual bool discard_multi() = 0;
};
} // namespace index
} // namespace ametsuchi
} // namespace iroha
#endif // AMETSUCHI_INDEX_INDEX_HPP
| 34.551724
| 76
| 0.6502
|
tkyonezu
|
18abbff99ad0364b6fc3227ddbbbb323f47a9965
| 637
|
cpp
|
C++
|
LongestSubstring/LongestSubstring_2.cpp
|
yergen/leetcode
|
7b6dac49ac44e0bf43a4ecb4795ea8cfe6afa4ab
|
[
"MIT"
] | null | null | null |
LongestSubstring/LongestSubstring_2.cpp
|
yergen/leetcode
|
7b6dac49ac44e0bf43a4ecb4795ea8cfe6afa4ab
|
[
"MIT"
] | null | null | null |
LongestSubstring/LongestSubstring_2.cpp
|
yergen/leetcode
|
7b6dac49ac44e0bf43a4ecb4795ea8cfe6afa4ab
|
[
"MIT"
] | null | null | null |
#include<string>
#include<unordered_set>
#include<algorithm>
#include<iostream>
using namespace std;
class Solution {
public:
int lengthOfLongestSubstring(string s) {
int n = s.size();
unordered_set<char> set;
int length = 0,temp = 0;
for (int i = 0; i < n; ++i)
for (int j = temp; j < n; ++j)
{
if (set.find(s[j]) == set.end())
{
set.insert(s[j]);
length = max(length, j+1 - i);
}
else
{
temp = j;
set.erase(s[i]);
break;
}
}
return length;
}
};
int main()
{
string s = "1312454123423";
Solution solution;
cout << solution.lengthOfLongestSubstring(s) << endl;
return 0;
}
| 15.536585
| 54
| 0.590267
|
yergen
|
18ac184b8cb8bf0a521f736b9de9e4be069708c5
| 563
|
cpp
|
C++
|
src/coherence/lang/ClassNotFoundException.cpp
|
chpatel3/coherence-cpp-extend-client
|
4ea5267eae32064dff1e73339aa3fbc9347ef0f6
|
[
"UPL-1.0",
"Apache-2.0"
] | 6
|
2020-07-01T21:38:30.000Z
|
2021-11-03T01:35:11.000Z
|
src/coherence/lang/ClassNotFoundException.cpp
|
chpatel3/coherence-cpp-extend-client
|
4ea5267eae32064dff1e73339aa3fbc9347ef0f6
|
[
"UPL-1.0",
"Apache-2.0"
] | 1
|
2020-07-24T17:29:22.000Z
|
2020-07-24T18:29:04.000Z
|
src/coherence/lang/ClassNotFoundException.cpp
|
chpatel3/coherence-cpp-extend-client
|
4ea5267eae32064dff1e73339aa3fbc9347ef0f6
|
[
"UPL-1.0",
"Apache-2.0"
] | 6
|
2020-07-10T18:40:58.000Z
|
2022-02-18T01:23:40.000Z
|
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
#include "coherence/lang/ClassNotFoundException.hpp"
#include <sstream>
COH_OPEN_NAMESPACE2(coherence,lang)
// ----- constructors -------------------------------------------------------
ClassNotFoundException::ClassNotFoundException(String::View vsName, Exception::View vCause)
: super(COH_TO_STRING(vsName << ": class not found"), vCause)
{
}
COH_CLOSE_NAMESPACE2
| 26.809524
| 91
| 0.653641
|
chpatel3
|
18b41a401f9746f8705d127528ceec05563fa286
| 1,337
|
hpp
|
C++
|
include/ear/warnings.hpp
|
rsjtaylor/libear
|
40a4000296190c3f91eba79e5b92141e368bd72a
|
[
"Apache-2.0"
] | 14
|
2019-07-30T17:58:00.000Z
|
2022-02-15T15:33:36.000Z
|
include/ear/warnings.hpp
|
rsjtaylor/libear
|
40a4000296190c3f91eba79e5b92141e368bd72a
|
[
"Apache-2.0"
] | 27
|
2019-07-30T18:01:58.000Z
|
2021-12-14T10:24:52.000Z
|
include/ear/warnings.hpp
|
rsjtaylor/libear
|
40a4000296190c3f91eba79e5b92141e368bd72a
|
[
"Apache-2.0"
] | 5
|
2019-07-30T15:12:02.000Z
|
2020-09-14T16:22:43.000Z
|
#pragma once
#include <functional>
#include <string>
#include "export.hpp"
namespace ear {
/// A warning message, containing a code and a corresponding message. The code
/// does not need to be shown when displaying warnings; the message should
/// contain all the information required, the code is just to allow
/// implementations to take action on warnings without matching against the
/// messages.
struct Warning {
enum class Code {
/// LFE indication from frequency element does not match speakerLabel
FREQ_SPEAKERLABEL_LFE_MISMATCH = 1,
/// frequency indication present but does not indicate an LFE channel
FREQ_NOT_LFE,
/// frequency information is not implemented; ignoring
FREQ_IGNORED,
/// screenRef for HOA is not implemented; ignoring
HOA_SCREENREF_NOT_IMPLEMENTED,
/// nfcRefDist is not implemented; ignoring
HOA_NFCREFDIST_NOT_IMPLEMENTED,
};
Code code;
std::string message;
};
/// warning callback type; this is passed into `calculate` calls, and will be
/// called with any warnings.
using WarningCB = std::function<void(const Warning &warning)>;
/// default warning callback which prints to stderr with the prefix `libear:
/// warning: `
extern EAR_EXPORT const WarningCB default_warning_cb;
} // namespace ear
| 34.282051
| 80
| 0.715782
|
rsjtaylor
|
18b5fe778684da01ff1fbc9f616ea01d7b890b2d
| 15,233
|
hpp
|
C++
|
include/vif/core/bits/vectorize.hpp
|
lmorabit/vif
|
459715c60e0ef6c83c7ebfb8741355d597dbc7aa
|
[
"Apache-2.0"
] | 6
|
2018-09-04T10:57:00.000Z
|
2021-10-05T07:41:50.000Z
|
include/vif/core/bits/vectorize.hpp
|
lmorabit/vif
|
459715c60e0ef6c83c7ebfb8741355d597dbc7aa
|
[
"Apache-2.0"
] | 2
|
2019-05-22T02:59:46.000Z
|
2019-12-02T19:15:43.000Z
|
include/vif/core/bits/vectorize.hpp
|
lmorabit/vif
|
459715c60e0ef6c83c7ebfb8741355d597dbc7aa
|
[
"Apache-2.0"
] | 3
|
2019-05-01T10:20:47.000Z
|
2021-09-20T16:35:34.000Z
|
#ifndef VIF_INCLUDING_CORE_VEC_BITS
#error this file is not meant to be included separately, include "vif/core/vec.hpp" instead
#endif
namespace vif {
////////////////////////////////////////////
// Vectorization helpers //
////////////////////////////////////////////
#define VIF_VECTORIZE(name) \
template<std::size_t Dim, typename Type, typename ... Args> \
auto name(const vec<Dim,Type>& v, const Args& ... args) -> \
vec<Dim,decltype(name(v[0], args...))> { \
using ntype = decltype(name(v[0], args...)); \
vec<Dim,ntype> r; r.dims = v.dims; r.data.reserve(v.size()); \
for (auto& t : v.data) { \
r.data.push_back(name(impl::dref<Type>(t), args...)); \
} \
return r; \
} \
template<std::size_t Dim, typename Type, typename ... Args> \
auto name(vec<Dim,Type>&& v, const Args& ... args) -> typename std::enable_if< \
!std::is_pointer<Type>::value && std::is_same<decltype(name(v[0], args...)), Type>::value, \
vec<Dim,Type>>::type { \
for (auto& t : v) { \
t = name(t, args...); \
} \
return std::move(v); \
}
#define VIF_VECTORIZE2(name) \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(const vec<D,T1>& v1, const vec<D,T2>& v2, const Args& ... args) -> \
vec<D,decltype(name(v1[0], v2[0], args...))> { \
vif_check(v1.dims == v2.dims, "incompatible dimensions between V1 and V2 (", \
v1.dims, " vs. ", v2.dims, ")"); \
using ntype = decltype(name(v1[0], v2[0], args...)); \
vec<D,ntype> r; r.dims = v1.dims; r.data.reserve(v1.size()); \
for (uint_t i : range(v1)) { \
r.data.push_back(name(v1.safe[i], v2.safe[i], args...)); \
} \
return r; \
} \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(vec<D,T1>&& v1, const vec<D,T2>& v2, const Args& ... args) -> typename std::enable_if< \
!std::is_pointer<T1>::value && std::is_same<decltype(name(v1[0], v2[0], args...)), T1>::value, \
vec<D,T1>>::type { \
vif_check(v1.dims == v2.dims, "incompatible dimensions between V1 and V2 (", \
v1.dims, " vs. ", v2.dims, ")"); \
for (uint_t i : range(v1)) { \
v1.safe[i] = name(v1.safe[i], v2.safe[i], args...); \
} \
return v1; \
} \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(const vec<D,T1>& v1, vec<D,T2>&& v2, const Args& ... args) -> typename std::enable_if< \
!std::is_pointer<T2>::value && std::is_same<decltype(name(v1[0], v2[0], args...)), T2>::value, \
vec<D,T2>>::type { \
vif_check(v1.dims == v2.dims, "incompatible dimensions between V1 and V2 (", \
v1.dims, " vs. ", v2.dims, ")"); \
for (uint_t i : range(v1)) { \
v2.safe[i] = name(v1.safe[i], v2.safe[i], args...); \
} \
return v2; \
} \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(vec<D,T1>&& v1, vec<D,T2>&& v2, const Args& ... args) -> typename std::enable_if< \
!std::is_pointer<T1>::value && std::is_same<decltype(name(v1[0], v2[0], args...)), T1>::value, \
vec<D,T1>>::type { \
vif_check(v1.dims == v2.dims, "incompatible dimensions between V1 and V2 (", \
v1.dims, " vs. ", v2.dims, ")"); \
for (uint_t i : range(v1)) { \
v1.safe[i] = name(v1.safe[i], v2.safe[i], args...); \
} \
return v1; \
} \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(T1 v1, const vec<D,T2>& v2, const Args& ... args) -> typename std::enable_if<!meta::is_vec<T1>::value, \
vec<D,decltype(name(v1, v2[0], args...))>>::type { \
using ntype = decltype(name(v1, v2[0], args...)); \
vec<D,ntype> r; r.dims = v2.dims; r.data.reserve(v2.size()); \
for (uint_t i : range(v2)) { \
r.data.push_back(name(v1, v2.safe[i], args...)); \
} \
return r; \
} \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(const vec<D,T1>& v1, T2 v2, const Args& ... args) -> typename std::enable_if<!meta::is_vec<T2>::value, \
vec<D,decltype(name(v1[0], v2, args...))>>::type { \
using ntype = decltype(name(v1[0], v2, args...)); \
vec<D,ntype> r; r.dims = v1.dims; r.data.reserve(v1.size()); \
for (uint_t i : range(v1)) { \
r.data.push_back(name(v1.safe[i], v2, args...)); \
} \
return r; \
} \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(T1 v1, vec<D,T2>&& v2, const Args& ... args) -> typename std::enable_if<!meta::is_vec<T1>::value && \
!std::is_pointer<T2>::value && std::is_same<decltype(name(v1, v2[0], args...)), T2>::value, \
vec<D,decltype(name(v1, v2[0], args...))>>::type { \
for (uint_t i : range(v2)) { \
v2.safe[i] = name(v1, v2.safe[i], args...); \
} \
return v2; \
} \
template<std::size_t D, typename T1, typename T2, typename ... Args> \
auto name(vec<D,T1>&& v1, T2 v2, const Args& ... args) -> typename std::enable_if<!meta::is_vec<T2>::value && \
!std::is_pointer<T1>::value && std::is_same<decltype(name(v1[0], v2, args...)), T1>::value, \
vec<D,decltype(name(v1[0], v2, args...))>>::type { \
for (uint_t i : range(v1)) { \
v1.safe[i] = name(v1.safe[i], v2, args...); \
} \
return v1; \
} \
#define VIF_VECTORIZE_REN(name, orig) \
template<std::size_t Dim, typename Type, typename ... Args> \
auto name(const vec<Dim,Type>& v, const Args& ... args) -> \
vec<Dim,decltype(orig(v[0], args...))> { \
using ntype = decltype(orig(v[0], args...)); \
vec<Dim,ntype> r; r.dims = v.dims; r.data.reserve(v.size()); \
for (auto& t : v.data) { \
r.data.push_back(orig(impl::dref<Type>(t), args...)); \
} \
return r; \
} \
template<std::size_t Dim, typename Type, typename ... Args> \
auto name(vec<Dim,Type>&& v, const Args& ... args) -> typename std::enable_if< \
!std::is_pointer<Type>::value && std::is_same<decltype(orig(v[0], args...)), Type>::value, \
vec<Dim,Type>>::type { \
for (auto& t : v) { \
t = orig(t, args...); \
} \
return std::move(v); \
} \
template<typename ... Args> \
auto name(Args&& ... args) -> decltype(orig(std::forward<Args>(args)...)) { \
return orig(std::forward<Args>(args)...); \
}
// Create an overloaded lambda that supports both scalars and vectors for the first argument.
namespace impl {
template<typename L>
struct vectorized_lambda_first_t {
L lambda;
vectorized_lambda_first_t(L tlam) : lambda(tlam) {}
template<typename T, typename ... Args, typename enable =
typename std::enable_if<!meta::is_vec<typename std::decay<T>::type>::value>::type>
auto operator()(T&& t, Args&& ... args) ->
decltype(lambda(std::forward<T>(t), std::forward<Args>(args)...)) {
return lambda(std::forward<T>(t), std::forward<Args>(args)...);
}
template<typename T, std::size_t D, typename ... Args>
auto operator()(const vec<D,T>& t, Args&& ... args) ->
vec<D,typename std::decay<decltype(lambda(std::declval<const meta::rtype_t<T>&>(),
std::forward<Args>(args)...))>::type> {
vec<D,typename std::decay<decltype(lambda(std::declval<const meta::rtype_t<T>&>(),
std::forward<Args>(args)...))>::type> ret(t.dims);
for (uint_t i : range(t)) {
ret.safe[i] = lambda(t.safe[i], std::forward<Args>(args)...);
}
return ret;
}
template<typename T, std::size_t D, typename ... Args>
auto operator()(vec<D,T>&& t, Args&& ... args) ->
vec<D,typename std::decay<decltype(lambda(std::declval<meta::rtype_t<T>>(),
std::forward<Args>(args)...))>::type> {
vec<D,typename std::decay<decltype(lambda(std::declval<meta::rtype_t<T>>(),
std::forward<Args>(args)...))>::type> ret(t.dims);
for (uint_t i : range(t)) {
ret.safe[i] = lambda(std::move(t.safe[i]), std::forward<Args>(args)...);
}
return ret;
}
};
}
template<typename T>
impl::vectorized_lambda_first_t<typename std::decay<T>::type> vectorize_lambda_first(T&& t) {
return impl::vectorized_lambda_first_t<typename std::decay<T>::type>(std::move(t));
}
// Create an overloaded lambda that supports either scalars or vectors for all arguments.
// If multiple vectors are found in the argument list, they are iterated jointly and
// therefore must have the same dimensions.
namespace impl {
template<typename T>
struct elem_dim : std::integral_constant<std::size_t, 0> {};
template<std::size_t D, typename T>
struct elem_dim<vec<D,T>> : std::integral_constant<std::size_t, D> {};
template<typename ... Args>
using common_dim = meta::max<std::size_t, elem_dim<typename std::decay<Args>::type>::value...>;
template <std::size_t D>
struct has_right_dim {
template <typename T>
struct type : meta::bool_constant<elem_dim<T>::value == D || elem_dim<T>::value == 0> {};
};
template <typename T, typename U>
void lambda_check_dims(T& dims, bool& set, const U& u) {}
template <typename T, std::size_t D, typename U>
void lambda_check_dims(T& dims, bool& set, const vec<D,U>& u) {
if (!set) {
dims = u.dims;
set = true;
} else {
vif_check(dims == u.dims, "incompatible dimensions in lambda call (",
dims, " vs ", u.dims, ")");
}
}
template<typename L>
struct vectorize_lambda_t {
L lambda;
vectorize_lambda_t(L tlam) : lambda(tlam) {}
// Get 'i'th element from argument
template <typename T, typename ... Args>
static T& get(uint_t i, T& t) {
return t;
}
template <typename T, typename ... Args>
static const T& get(uint_t i, const T& t) {
return t;
}
template <std::size_t D, typename T, typename ... Args>
static auto get(uint_t i, vec<D,T>& t) -> decltype(t.safe[i]) {
return t.safe[i];
}
template <std::size_t D, typename T, typename ... Args>
static auto get(uint_t i, const vec<D,T>& t) -> decltype(t.safe[i]) {
return t.safe[i];
}
template <typename ... Args>
static void swallow(Args&&...) {}
// Bake return type
template <typename ... Args>
using scalar_return_type = decltype(std::declval<L>()(get(0, std::declval<Args>())...));
template <typename ... Args>
using vector_return_type = vec<common_dim<Args...>::value, scalar_return_type<Args...>>;
// Full scalar call
// ----------------
template <typename ... Args>
void run(std::true_type, std::true_type, Args&& ... args) {
lambda(std::forward<Args>(args)...);
}
template <typename ... Args>
scalar_return_type<Args...> run(std::true_type, std::false_type, Args&& ... args) {
return lambda(std::forward<Args>(args)...);
}
// Vectorized call
// ----------------
template <typename ... Args>
void run(std::false_type, std::true_type, Args&& ... args) {
constexpr const std::size_t D = common_dim<Args...>::value;
static_assert(meta::are_all_true<meta::bool_list<has_right_dim<D>::template type<Args>::value...>>::value,
"incompatible number of dimensions in lambda call");
bool set = false;
std::array<std::size_t,D> dims; // only used to get the dimensions
swallow((lambda_check_dims(dims, set, args), 0)...);
std::size_t size = 1;
for (uint_t i : range(D)) {
size *= dims[i];
}
for (uint_t i : range(size)) {
lambda(get(i, args)...);
}
}
template <typename ... Args>
vector_return_type<Args...> run(std::false_type, std::false_type, Args&& ... args) {
vector_return_type<Args...> ret;
constexpr const std::size_t D = common_dim<Args...>::value;
static_assert(meta::are_all_true<meta::bool_list<has_right_dim<D>::template type<Args>::value...>>::value,
"incompatible number of dimensions in lambda call");
bool set = false;
swallow((lambda_check_dims(ret.dims, set, args), 0)...);
ret.resize();
for (uint_t i : range(ret)) {
ret.safe[i] = lambda(get(i, args)...);
}
return ret;
}
// Generic call dispatcher
// -----------------------
// Needs to check if:
// 1) all the parameters are scalars, to return a scalar or a vector
// 2) the return value is void, to avoid creating a return value
template<typename ... Args>
auto operator()(Args&& ... args) ->
decltype(this->run(meta::bool_constant<common_dim<Args...>::value == 0>{},
std::is_same<scalar_return_type<Args...>, void>{},
std::forward<Args>(args)...)) {
return this->run(meta::bool_constant<common_dim<Args...>::value == 0>{},
std::is_same<scalar_return_type<Args...>, void>{},
std::forward<Args>(args)...);
}
};
}
template<typename T>
impl::vectorize_lambda_t<typename std::decay<T>::type> vectorize_lambda(T&& t) {
return impl::vectorize_lambda_t<typename std::decay<T>::type>(std::move(t));
}
}
| 45.607784
| 122
| 0.495044
|
lmorabit
|
18b77802b8e2fa60527b93d605a3f1d859e7abbb
| 254
|
cpp
|
C++
|
aula_25/TrajetoManhattan.cpp
|
matheusalanojoenck/aula_cpp
|
039bd4f4b11a736f1d800cad97a530e212b30375
|
[
"MIT"
] | null | null | null |
aula_25/TrajetoManhattan.cpp
|
matheusalanojoenck/aula_cpp
|
039bd4f4b11a736f1d800cad97a530e212b30375
|
[
"MIT"
] | null | null | null |
aula_25/TrajetoManhattan.cpp
|
matheusalanojoenck/aula_cpp
|
039bd4f4b11a736f1d800cad97a530e212b30375
|
[
"MIT"
] | null | null | null |
#include "TrajetoManhattan.hpp"
#include <cmath>
double TrajetoManhattan::calcularDistanciaPontos(const Ponto* const p1, const Ponto* const p2) const{
return std::abs(p1->getCoordX() - p2->getCoordX()) + std::abs(p1->getCoordY() - p2->getCoordY());
}
| 31.75
| 101
| 0.724409
|
matheusalanojoenck
|
18bc0819b939ceaab3a7cf55215971d56aee9f96
| 1,299
|
cpp
|
C++
|
154.cpp
|
felikjunvianto/kfile-uvaoj-submissions
|
5bd8b3b413ca8523abe412b0a0545f766f70ce63
|
[
"MIT"
] | null | null | null |
154.cpp
|
felikjunvianto/kfile-uvaoj-submissions
|
5bd8b3b413ca8523abe412b0a0545f766f70ce63
|
[
"MIT"
] | null | null | null |
154.cpp
|
felikjunvianto/kfile-uvaoj-submissions
|
5bd8b3b413ca8523abe412b0a0545f766f70ce63
|
[
"MIT"
] | null | null | null |
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pi 2*acos(0.0)
#define eps 1e-9
#define PII pair<int,int>
#define PDD pair<double,double>
using namespace std;
char masuk[100];
char alokasi[110][5];
int x,y,z,beda,terkecil,terbaik,kota;
int main()
{
kota=-1;
do
{
gets(masuk);
if(masuk[0]=='#') break;
if(masuk[0]=='e')
{
terbaik=terkecil=-1;
for(x=0;x<=kota;x++)
{
beda=0;
for(y=0;y<=kota;y++) if(y!=x)
for(z=0;z<5;z++) if(alokasi[x][z]!=alokasi[y][z]) beda++;
if((terbaik==-1)||(terkecil>beda))
{
terkecil=beda;
terbaik=x;
}
}
printf("%d\n",terbaik+1);
kota=-1;
} else
{
kota++;
for(x=0;x<18;x+=4) switch(masuk[x])
{
case('r') : alokasi[kota][0]=masuk[x+2];break;
case('o') : alokasi[kota][1]=masuk[x+2];break;
case('y') : alokasi[kota][2]=masuk[x+2];break;
case('g') : alokasi[kota][3]=masuk[x+2];break;
case('b') : alokasi[kota][4]=masuk[x+2];break;
}
}
}while(masuk[0]!='#');
return 0;
}
| 19.102941
| 63
| 0.553503
|
felikjunvianto
|
18c4db409264a14492bfc376fa2a9143451cea09
| 1,789
|
cpp
|
C++
|
data/transcoder_evaluation_gfg/cpp/SUBSEQUENCES_SIZE_THREE_ARRAY_WHOSE_SUM_DIVISIBLE_M.cpp
|
mxl1n/CodeGen
|
e5101dd5c5e9c3720c70c80f78b18f13e118335a
|
[
"MIT"
] | 241
|
2021-07-20T08:35:20.000Z
|
2022-03-31T02:39:08.000Z
|
data/transcoder_evaluation_gfg/cpp/SUBSEQUENCES_SIZE_THREE_ARRAY_WHOSE_SUM_DIVISIBLE_M.cpp
|
mxl1n/CodeGen
|
e5101dd5c5e9c3720c70c80f78b18f13e118335a
|
[
"MIT"
] | 49
|
2021-07-22T23:18:42.000Z
|
2022-03-24T09:15:26.000Z
|
data/transcoder_evaluation_gfg/cpp/SUBSEQUENCES_SIZE_THREE_ARRAY_WHOSE_SUM_DIVISIBLE_M.cpp
|
mxl1n/CodeGen
|
e5101dd5c5e9c3720c70c80f78b18f13e118335a
|
[
"MIT"
] | 71
|
2021-07-21T05:17:52.000Z
|
2022-03-29T23:49:28.000Z
|
// Copyright (c) 2019-present, Facebook, Inc.
// All rights reserved.
//
// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.
//
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <fstream>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
int f_gold ( int A [ ], int N, int M ) {
int sum = 0;
int ans = 0;
for ( int i = 0;
i < N;
i ++ ) {
for ( int j = i + 1;
j < N;
j ++ ) {
for ( int k = j + 1;
k < N;
k ++ ) {
sum = A [ i ] + A [ j ] + A [ k ];
if ( sum % M == 0 ) ans ++;
}
}
}
return ans;
}
//TOFILL
int main() {
int n_success = 0;
vector<vector<int>> param0 {{14,35,56,70,88},{-50,-92,16,-68,-36},{0,0,0,1,1,1},{76,43,22,41,49,99,25,40,3,45,60,16,83,62,26,93,64,73,72,53,6,32,35,67,17},{-90,-86,-86,-66,-50,-48,-44,-42,-42,-38,-24,-22,-20,-18,-8,8,24,28,34,48,60,62,66,68,74,76,80,82,88},{1,1,1,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,0,1,1,0},{4,5,8,9,10,12,13,16,17,18,21,21,25,27,28,30,36,36,54,55,56,57,60,62,67,67,68,71,72,72,73,73,77,77,83,86,86,86,87,89,92,92,96,97,97,98},{-64,52,-32,38,8,-62,-56,20,72,-12,32,44},{0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1},{77,68,45,6,27,19,29,95,21,2,39,48,72,67,49,45,1,16,56,78,25,22,27,40,31,34,26,35,12}};
vector<int> param1 {3,3,4,14,24,24,24,6,12,25};
vector<int> param2 {4,4,5,21,20,30,23,6,15,25};
for(int i = 0; i < param0.size(); ++i)
{
if(f_filled(¶m0[i].front(),param1[i],param2[i]) == f_gold(¶m0[i].front(),param1[i],param2[i]))
{
n_success+=1;
}
}
cout << "#Results:" << " " << n_success << ", " << param0.size();
return 0;
}
| 33.754717
| 654
| 0.536054
|
mxl1n
|
18c52ebff1afd6ce6e3c5d65fe9e42a50051e9fe
| 738
|
cxx
|
C++
|
POSN Camp2/ban_word-113028.cxx
|
ParamaaS/ParamaaS-Cpp-code-
|
a6c78151defe38d1460cde2b005a67be5a1d092d
|
[
"MIT"
] | null | null | null |
POSN Camp2/ban_word-113028.cxx
|
ParamaaS/ParamaaS-Cpp-code-
|
a6c78151defe38d1460cde2b005a67be5a1d092d
|
[
"MIT"
] | null | null | null |
POSN Camp2/ban_word-113028.cxx
|
ParamaaS/ParamaaS-Cpp-code-
|
a6c78151defe38d1460cde2b005a67be5a1d092d
|
[
"MIT"
] | null | null | null |
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
long long n;
long long ar[60][10];
long long dp(long long idx,long long ch)
{
if(ar[idx][ch]!=-1)
return ar[idx][ch];
if(idx==1)
return ar[idx][ch]=1;
if(ch!=1)/// not a
{
return ar[idx][ch]=dp(idx-1,1)+dp(idx-1,2)+dp(idx-1,3);
}
else if(ch==1)///is a
{
return ar[idx][ch]=dp(idx-1,1)+dp(idx-1,3);
}
}
main()
{
memset(ar,-1,sizeof ar);
while(scanf("%lld",&n)!=EOF)
{
if(n==0)
{
printf("1\n");
continue;
}
printf("%lld\n",dp(n,1)+dp(n,2)+dp(n,3));
}
}
| 19.945946
| 64
| 0.47561
|
ParamaaS
|
18c6f5b0ca802e3a3cff23d58e9e22b53e304993
| 1,609
|
cpp
|
C++
|
cpp/851. Loud and Rich.cpp
|
longwangjhu/LeetCode
|
a5c33e8d67e67aedcd439953d96ac7f443e2817b
|
[
"MIT"
] | 3
|
2021-08-07T07:01:34.000Z
|
2021-08-07T07:03:02.000Z
|
cpp/851. Loud and Rich.cpp
|
longwangjhu/LeetCode
|
a5c33e8d67e67aedcd439953d96ac7f443e2817b
|
[
"MIT"
] | null | null | null |
cpp/851. Loud and Rich.cpp
|
longwangjhu/LeetCode
|
a5c33e8d67e67aedcd439953d96ac7f443e2817b
|
[
"MIT"
] | null | null | null |
// https://leetcode.com/problems/loud-and-rich/
// In a group of N people (labelled 0, 1, 2, ..., N-1), each person has different
// amounts of money, and different levels of quietness.
// For convenience, we'll call the person with label x, simply "person x".
// We'll say that richer[i] = [x, y] if person x definitely has more money than
// person y. Note that richer may only be a subset of valid observations.
// Also, we'll say quiet[x] = q if person x has quietness q.
// Now, return answer, where answer[x] = y if y is the least quiet person (that is,
// the person y with the smallest value of quiet[y]), among all people who
// definitely have equal to or more money than person x.
////////////////////////////////////////////////////////////////////////////////
// edge x -> y if y is richer, for each x look for the quietest person start from x
class Solution {
public:
// graph[x] = set of richer people
unordered_map<int, unordered_set<int>> graph;
vector<int> ans;
vector<int> loudAndRich(vector<vector<int>>& richer, vector<int>& quiet) {
for (auto& edge : richer) graph[edge[1]].insert(edge[0]);
ans = vector<int>(quiet.size(), -1);
for (int i = 0; i < quiet.size(); ++i) dfs(quiet, i);
return ans;
}
int dfs(const vector<int>& quiet, int i) {
if (ans[i] != -1) return ans[i];
ans[i] = i; // initial val
for (auto child : graph[i]) {
int childAns = dfs(quiet, child);
if (quiet[childAns] < quiet[ans[i]]) ans[i] = childAns;
}
return ans[i];
}
};
| 37.418605
| 83
| 0.585457
|
longwangjhu
|
18c7f597236d07a90fb6e7e71d1fe22ccd75fb25
| 1,916
|
hpp
|
C++
|
src/types.hpp
|
PranayAnchuri/approx-graph-mining-with-label-costs
|
4bb1d78b52175add3955de47281c3ee0073c7943
|
[
"MIT"
] | null | null | null |
src/types.hpp
|
PranayAnchuri/approx-graph-mining-with-label-costs
|
4bb1d78b52175add3955de47281c3ee0073c7943
|
[
"MIT"
] | null | null | null |
src/types.hpp
|
PranayAnchuri/approx-graph-mining-with-label-costs
|
4bb1d78b52175add3955de47281c3ee0073c7943
|
[
"MIT"
] | 1
|
2020-05-08T11:17:33.000Z
|
2020-05-08T11:17:33.000Z
|
#pragma once
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
namespace types {
typedef int integer_t;
typedef integer_t int_t;
typedef unsigned int unsigned_integer_t;
typedef unsigned_integer_t uint_t;
typedef uint_t symbol_t;
typedef double double_t;
typedef char char_t;
typedef char * charp_t;
typedef float float_t;
typedef long long_t;
typedef unsigned long unsigned_long_t;
typedef unsigned long ulong_t;
typedef bool bool_t;
typedef std::string string_t;
typedef void * void_ptr_t;
typedef int label_t;
typedef int pat_vertex_t;
typedef int db_vertex_t;
typedef std::vector<types::db_vertex_t> vlist_t;
typedef std::set<types::db_vertex_t> set_vlist_t;
typedef std::map<int, label_t> vmap_t;
typedef std::map<int, set_vlist_t > graph_t;
typedef std::map<label_t, vlist_t> lmap_t;
typedef double cost_t;
typedef std::vector<pat_vertex_t> pat_vlist_t;
typedef std::set<pat_vertex_t> pat_set_vlist_t;
typedef std::vector<std::pair<pat_vertex_t, pat_vertex_t> > pat_elist_t;
typedef std::pair<pat_vertex_t, pat_vertex_t> pat_edge_t;
// Pattern in the form of a graph
typedef std::map<pat_vertex_t, pat_vlist_t> pat_graph_t;
// store just the representative vertices without the Repr object
typedef std::map<types::pat_vertex_t, types::set_vlist_t> bare_embeds_t;
// GAPPROX
// one embedding
typedef std::pair<types::cost_t, pat_vlist_t> gapprox_em_t;
// list of all embeddings for a given pattern
typedef std::vector<gapprox_em_t> gapprox_embed_t;
// offsets for the vertices in the database
typedef std::vector<int> offsets_t;
//typedef std::unordered_map<types::pat_vertex_t, std::unordered_map<int, KhopLabel> > pat_hops_t;
//typedef std::unordered_map<types::db_vertex_t , std::unordered_map<int, KhopLabel> > db_hops_t;
} // namespace types
| 31.409836
| 102
| 0.756785
|
PranayAnchuri
|
18c8fbbbe1a7e91792553cfe93e4e2e19133ad6c
| 746
|
hpp
|
C++
|
DlgApp/AppDlg.hpp
|
chrisoldwood/Template
|
9c09d28d97d821753a1607b92cd03cfa70d48353
|
[
"MIT"
] | 3
|
2015-10-13T00:51:58.000Z
|
2020-09-11T13:13:28.000Z
|
DlgApp/AppDlg.hpp
|
chrisoldwood/Template
|
9c09d28d97d821753a1607b92cd03cfa70d48353
|
[
"MIT"
] | null | null | null |
DlgApp/AppDlg.hpp
|
chrisoldwood/Template
|
9c09d28d97d821753a1607b92cd03cfa70d48353
|
[
"MIT"
] | null | null | null |
////////////////////////////////////////////////////////////////////////////////
//! \file AppDlg.hpp
//! \brief The AppDlg class declaration.
//! \author Chris Oldwood
// Check for previous inclusion
#ifndef APP_APPDLG_HPP
#define APP_APPDLG_HPP
#if _MSC_VER > 1000
#pragma once
#endif
#include <WCL/MainDlg.hpp>
////////////////////////////////////////////////////////////////////////////////
//! The application main dialog. This is the dialog that sits in the centre of
//! application window.
class AppDlg : public CMainDlg
{
public:
//! Constructor.
AppDlg();
//! Destructor.
virtual ~AppDlg();
private:
//
// Message processors.
//
//! Handle dialog creation.
virtual void OnInitDialog();
};
#endif // APP_APPDLG_HPP
| 19.128205
| 80
| 0.548257
|
chrisoldwood
|
18c9fcc6bbda982e62fa88f76c53db5246d67764
| 3,925
|
cc
|
C++
|
cc/trees/layer_tree_host_unittest_remote_server.cc
|
maidiHaitai/haitaibrowser
|
a232a56bcfb177913a14210e7733e0ea83a6b18d
|
[
"BSD-3-Clause"
] | 1
|
2020-09-15T08:43:34.000Z
|
2020-09-15T08:43:34.000Z
|
cc/trees/layer_tree_host_unittest_remote_server.cc
|
maidiHaitai/haitaibrowser
|
a232a56bcfb177913a14210e7733e0ea83a6b18d
|
[
"BSD-3-Clause"
] | null | null | null |
cc/trees/layer_tree_host_unittest_remote_server.cc
|
maidiHaitai/haitaibrowser
|
a232a56bcfb177913a14210e7733e0ea83a6b18d
|
[
"BSD-3-Clause"
] | null | null | null |
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "cc/test/fake_image_serialization_processor.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/proxy_common.h"
#include "cc/trees/proxy_main.h"
#include "cc/trees/remote_proto_channel.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
namespace {
class LayerTreeHostTestRemoteServer : public testing::Test,
public RemoteProtoChannel,
public LayerTreeHostClient {
public:
LayerTreeHostTestRemoteServer()
: calls_received_(0),
image_serialization_processor_(
base::WrapUnique(new FakeImageSerializationProcessor)) {
LayerTreeHost::InitParams params;
params.client = this;
params.task_graph_runner = &task_graph_runner_;
params.settings = &settings_;
params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
params.image_serialization_processor = image_serialization_processor_.get();
layer_tree_host_ = LayerTreeHost::CreateRemoteServer(this, ¶ms);
}
~LayerTreeHostTestRemoteServer() override {}
// LayerTreeHostClient implementation
void WillBeginMainFrame() override {}
void BeginMainFrame(const BeginFrameArgs& args) override {}
void BeginMainFrameNotExpectedSoon() override {}
void DidBeginMainFrame() override {}
void UpdateLayerTreeHost() override {}
void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
const gfx::Vector2dF& elastic_overscroll_delta,
float page_scale,
float top_controls_delta) override {}
void RequestNewOutputSurface() override { NOTREACHED(); }
void DidInitializeOutputSurface() override { NOTREACHED(); }
void DidFailToInitializeOutputSurface() override { NOTREACHED(); }
void WillCommit() override {}
void DidCommit() override {}
void DidCommitAndDrawFrame() override {}
void DidCompleteSwapBuffers() override {}
void DidCompletePageScaleAnimation() override {}
void ReportFixedRasterScaleUseCounters(
bool has_blurry_content,
bool has_potential_performance_regression) override {}
// RemoteProtoChannel implementation
void SetProtoReceiver(RemoteProtoChannel::ProtoReceiver* receiver) override {
receiver_ = receiver;
}
void SendCompositorProto(const proto::CompositorMessage& proto) override {}
int calls_received_;
TestTaskGraphRunner task_graph_runner_;
LayerTreeSettings settings_;
std::unique_ptr<LayerTreeHost> layer_tree_host_;
RemoteProtoChannel::ProtoReceiver* receiver_;
std::unique_ptr<FakeImageSerializationProcessor>
image_serialization_processor_;
private:
DISALLOW_COPY_AND_ASSIGN(LayerTreeHostTestRemoteServer);
};
class LayerTreeHostTestRemoteServerBeginMainFrame
: public LayerTreeHostTestRemoteServer {
protected:
void BeginMainFrame(const BeginFrameArgs& args) override {
calls_received_++;
}
};
// Makes sure that the BeginMainFrame call is not aborted on the server.
// See crbug.com/577301.
TEST_F(LayerTreeHostTestRemoteServerBeginMainFrame, BeginMainFrameNotAborted) {
layer_tree_host_->SetVisible(true);
std::unique_ptr<BeginMainFrameAndCommitState> begin_frame_state;
begin_frame_state.reset(new BeginMainFrameAndCommitState());
begin_frame_state->scroll_info.reset(new ScrollAndScaleSet());
static_cast<ProxyMain*>(layer_tree_host_->proxy())
->BeginMainFrame(std::move(begin_frame_state));
EXPECT_EQ(calls_received_, 1);
}
} // namespace
} // namespace cc
| 37.380952
| 80
| 0.74828
|
maidiHaitai
|
18cc94708e24ffa0a3ae9e1c38744ed4c06cea31
| 4,198
|
hpp
|
C++
|
include/atma/shared_memory.hpp
|
omnigoat/atma
|
73833f41373fac2af695587786c00a307046de64
|
[
"MIT"
] | 7
|
2016-04-08T03:53:42.000Z
|
2020-07-06T05:52:35.000Z
|
include/atma/shared_memory.hpp
|
omnigoat/atma
|
73833f41373fac2af695587786c00a307046de64
|
[
"MIT"
] | 1
|
2018-04-14T13:56:06.000Z
|
2018-04-14T13:56:06.000Z
|
include/atma/shared_memory.hpp
|
omnigoat/atma
|
73833f41373fac2af695587786c00a307046de64
|
[
"MIT"
] | null | null | null |
#pragma once
#include <atma/platform/allocation.hpp>
import atma.types;
namespace atma
{
namespace detail
{
constexpr size_t header_size = sizeof(size_t) + sizeof(std::atomic_uint32_t) + 4u;
constexpr inline size_t allocation_size(size_t alignment, size_t size)
{
return header_size + (header_size < alignment ? alignment - header_size : 0) + size;
}
}
struct shared_memory_t
{
shared_memory_t() = default;
explicit shared_memory_t(size_t size);
explicit shared_memory_t(size_t size, void* data);
explicit shared_memory_t(size_t alignment, size_t size);
explicit shared_memory_t(size_t alignment, size_t size, void* data);
shared_memory_t(shared_memory_t const&);
shared_memory_t(shared_memory_t&&);
~shared_memory_t();
auto operator = (shared_memory_t const&) -> shared_memory_t&;
auto operator = (shared_memory_t&&) -> shared_memory_t&;
auto size() const -> size_t;
auto begin() -> byte*;
auto end() -> byte*;
auto begin() const -> byte const*;
auto end() const -> byte const*;
private:
auto decrement() -> void;
auto increment() -> void;
auto ref() -> std::atomic_uint32_t&;
auto ref() const -> std::atomic_uint32_t const&;
private:
byte* data_ = nullptr;
};
// our actual data will start 16 bytes after the allocation, allowing space for
// an 8-byte size information, a 4-byte atomic uint32_t for ref-counting, and 4 bytes of padding,
// (to allow for 16-byte alignment naturally).
static_assert(sizeof(std::atomic_uint32_t) == sizeof(uint32_t), "unexpected size of std::atomic");
inline shared_memory_t::shared_memory_t(size_t size)
: shared_memory_t(alignof(int), size)
{}
inline shared_memory_t::shared_memory_t(size_t size, void* data)
: shared_memory_t(alignof(int), size, data)
{}
inline shared_memory_t::shared_memory_t(size_t alignment, size_t size)
: data_((byte*)platform::allocate_aligned_memory(alignment, detail::allocation_size(alignment, size)))
{
new (data_) size_t{size};
new (&ref()) std::atomic_uint32_t{1};
}
inline shared_memory_t::shared_memory_t(size_t alignment, size_t size, void* data)
: data_((byte*)platform::allocate_aligned_memory(alignment, detail::allocation_size(alignment, size)))
{
new (data_) size_t{size};
new (&ref()) std::atomic_uint32_t{1};
memcpy(begin(), data, size);
}
inline shared_memory_t::shared_memory_t(shared_memory_t const& rhs)
: data_(rhs.data_)
{
increment();
}
inline shared_memory_t::shared_memory_t(shared_memory_t&& rhs)
{
std::swap(data_, rhs.data_);
}
inline shared_memory_t::~shared_memory_t()
{
decrement();
}
inline auto shared_memory_t::operator = (shared_memory_t const& rhs) -> shared_memory_t&
{
if (this != &rhs)
{
data_ = rhs.data_;
}
return *this;
}
inline auto shared_memory_t::operator = (shared_memory_t&& rhs) -> shared_memory_t&
{
if (this != &rhs)
{
std::swap(data_, rhs.data_);
}
return *this;
}
inline auto shared_memory_t::size() const -> size_t
{
return *reinterpret_cast<size_t*>(data_);
}
inline auto shared_memory_t::begin() -> byte*
{
return data_ + sizeof(size_t) + sizeof(std::atomic_uint32_t) + 4u;
}
inline auto shared_memory_t::end() -> byte*
{
return begin() + size();
}
inline auto shared_memory_t::begin() const -> byte const*
{
return data_ + sizeof(size_t) + sizeof(std::atomic_uint32_t) + 4u;
}
inline auto shared_memory_t::end() const -> byte const*
{
return begin() + size();
}
inline auto shared_memory_t::decrement() -> void
{
if (data_ && --ref() == 0)
{
atma::platform::deallocate_aligned_memory(data_);
data_ = nullptr;
}
}
inline auto shared_memory_t::increment() -> void
{
if (data_)
++ref();
}
inline auto shared_memory_t::ref() -> std::atomic_uint32_t&
{
return *reinterpret_cast<std::atomic_uint32_t*>(data_ + sizeof(size_t));
}
inline auto shared_memory_t::ref() const -> std::atomic_uint32_t const&
{
return *reinterpret_cast<std::atomic_uint32_t const*>(data_ + sizeof(size_t));
}
}
| 24.694118
| 105
| 0.670796
|
omnigoat
|
18ce0bb394738ee31bcb67b641dd069384026962
| 1,662
|
cpp
|
C++
|
Source/OverlordProject/Components/Other/ColorFlickerComponent.cpp
|
TomvanWaas/OvercookedImitation
|
895b98ff23b026bafc24267c8707d68870a2ac58
|
[
"MIT"
] | null | null | null |
Source/OverlordProject/Components/Other/ColorFlickerComponent.cpp
|
TomvanWaas/OvercookedImitation
|
895b98ff23b026bafc24267c8707d68870a2ac58
|
[
"MIT"
] | null | null | null |
Source/OverlordProject/Components/Other/ColorFlickerComponent.cpp
|
TomvanWaas/OvercookedImitation
|
895b98ff23b026bafc24267c8707d68870a2ac58
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "ColorFlickerComponent.h"
#include "GameObject.h"
#include "SpriteComponent.h"
#include "GameScene.h"
#include "Destroyer.h"
ColorFlickerComponent::ColorFlickerComponent(const DirectX::XMFLOAT4& colorA, const DirectX::XMFLOAT4& colorB, float speed,
std::vector<SpriteComponent*> pSprites)
: m_Accu(0)
, m_Time(-1)
, m_Speed(speed)
, m_pSprites(pSprites)
, m_ColorA(colorA)
, m_ColorB(colorB)
{
}
void ColorFlickerComponent::Enable(bool enable, float time)
{
m_Time = time;
m_IsEnabled = enable;
m_Accu = 0;
if (enable == false)
{
for (auto* pSprite : m_pSprites)
{
if (pSprite) pSprite->SetColor({ 1,1,1,1 });
}
}
}
void ColorFlickerComponent::Initialize(const GameContext&)
{
//Empty => Init by Get All
if (m_pSprites.size() == 0)
{
m_pSprites = GetGameObject()->GetComponents<SpriteComponent>(true);
}
}
void ColorFlickerComponent::Update(const GameContext& gameContext)
{
if (m_IsEnabled)
{
m_Accu += gameContext.pGameTime->GetElapsed();
float sin = sinf(m_Accu * m_Speed); //[-1, 1]
sin = (sin + 1) * 0.5f; //[ 0, 1]
for (SpriteComponent* pSprite : m_pSprites)
{
if (pSprite) pSprite->SetColor(Lerp(m_ColorA, m_ColorB, sin));
}
if (m_Accu >= m_Time && m_Time > 0)
{
if (m_OnEnd) m_OnEnd();
Enable(false);
}
}
}
void ColorFlickerComponent::Draw(const GameContext&)
{
}
DirectX::XMFLOAT4 ColorFlickerComponent::Lerp(DirectX::XMFLOAT4 a, DirectX::XMFLOAT4 b, float t) const
{
return { a.x * (1 - t) + b.x*t,
a.y * (1 - t) + b.y*t,
a.z * (1 - t) + b.z*t,
a.w * (1 - t) + b.w*t };
}
| 22.767123
| 124
| 0.633574
|
TomvanWaas
|
18cffc0b71b7cebce9c043dc76d90fa6f86755c4
| 1,669
|
hpp
|
C++
|
rm_task/include/rm_task/task_image_proc.hpp
|
Hqz971016/rmoss_core
|
e9e37096ceb883945a838774e20ef58f2de0b10b
|
[
"MIT"
] | 1
|
2020-12-06T13:12:31.000Z
|
2020-12-06T13:12:31.000Z
|
rm_task/include/rm_task/task_image_proc.hpp
|
Hqz971016/rmoss_core
|
e9e37096ceb883945a838774e20ef58f2de0b10b
|
[
"MIT"
] | null | null | null |
rm_task/include/rm_task/task_image_proc.hpp
|
Hqz971016/rmoss_core
|
e9e37096ceb883945a838774e20ef58f2de0b10b
|
[
"MIT"
] | null | null | null |
/*******************************************************************************
* Copyright (c) 2020 robomaster-oss, All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the MIT License, See the MIT License for more details.
*
* You should have received a copy of the MIT License along with this program.
* If not, see <https://opensource.org/licenses/MIT/>.
*
******************************************************************************/
#ifndef RM_TASK_TASK_IMAGE_PROC_HPP
#define RM_TASK_TASK_IMAGE_PROC_HPP
#include <rclcpp/rclcpp.hpp>
#include <image_transport/image_transport.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <opencv2/opencv.hpp>
#include <thread>
#include <string>
namespace rm_task {
//图像处理相关任务基类.如自动瞄准任务,能量机关任务
class TaskImageProc
{
public:
TaskImageProc(rclcpp::Node::SharedPtr &nh);
~TaskImageProc(){};
public:
virtual void taskImageProcess(cv::Mat& img,double img_stamp)=0;
virtual void taskImageWait(){};
virtual void taskSleep(){};
void startTask();
void stopTask();
private:
void mainTask();
void imgSubCb(const sensor_msgs::msg::Image::ConstSharedPtr & msg);
private:
rclcpp::Node::SharedPtr nh_;
//tool
image_transport::Subscriber img_sub_;//订阅图片数据
std::thread task_thread_;
//data
cv::Mat imgbuf_, img_; //获取的图片,以及缓存图片
bool initflag_;
bool get_img_flag_;//使用flag实现多线程同步机制
bool run_flag_; //运行标志位
double img_stamp_;
};
}
#endif //RM_TASK_TASK_IMAGE_PROC_HPP
| 29.280702
| 80
| 0.603355
|
Hqz971016
|
18d15bd603150dbbdcb88f9aecbbb72bdd3c14a0
| 1,193
|
hpp
|
C++
|
src/Test.PlcNext/Deployment/ProgramWithNestedAndStructInStruct/src/MyProgramImpl.hpp
|
PLCnext/PLCnext_CLI
|
cf8ad590f05196747b403da891bdd5da86f82469
|
[
"Apache-2.0"
] | 7
|
2020-10-08T12:37:49.000Z
|
2021-03-29T07:49:52.000Z
|
src/Test.PlcNext/Deployment/ProgramWithNestedAndStructInStruct/src/MyProgramImpl.hpp
|
PLCnext/PLCnext_CLI
|
cf8ad590f05196747b403da891bdd5da86f82469
|
[
"Apache-2.0"
] | 10
|
2020-10-09T14:04:01.000Z
|
2022-03-09T09:38:58.000Z
|
src/Test.PlcNext/Deployment/ProgramWithNestedAndStructInStruct/src/MyProgramImpl.hpp
|
PLCnext/PLCnext_CLI
|
cf8ad590f05196747b403da891bdd5da86f82469
|
[
"Apache-2.0"
] | 2
|
2020-09-04T06:45:39.000Z
|
2020-10-30T10:07:33.000Z
|
#pragma once
#include "Arp/System/Core/Arp.h"
#include "Arp/Plc/Esm/ProgramBase.hpp"
#include "Arp/System/Commons/Logging.h"
namespace ProgramWithNestedAndStructInStruct { namespace MyComponent {
using namespace Arp;
using namespace Arp::Plc::Esm;
//#program
//#component(MyComponent)
class MyProgramImpl : public ProgramBase, private Loggable<MyProgramImpl>
{
public: // typedefs
struct nested{
struct supernested{
bit schnacken;
};
supernested fiooba;
};
struct instruct{
nested blubber;
nested::supernested test;
};
public: // construction/destruction
MyProgramImpl(const String& name);
MyProgramImpl(const MyProgramImpl& arg) = delete;
virtual ~MyProgramImpl(void) = default;
public: // operators
MyProgramImpl& operator=(const MyProgramImpl& arg) = delete;
public: // properties
public: // operations
void Execute(void)override;
private: // fields
//#port
//#attributes(Input)
instruct exampleInput;
};
///////////////////////////////////////////////////////////////////////////////
// inline methods of class ProgramBase
}} // end of namespace ProgramWithOneStructPort::MyComponent
| 23.392157
| 80
| 0.658843
|
PLCnext
|
18d281d705ffbb21956cda53215bce631ca92ec8
| 690
|
cpp
|
C++
|
examples/graphics/gnomon.cpp
|
AlloSphere-Research-Group/al_lib
|
94d23fe71b79d3464a658f16ca34c2040e6d7334
|
[
"BSD-3-Clause"
] | 26
|
2018-11-05T23:29:43.000Z
|
2022-03-17T18:16:49.000Z
|
examples/graphics/gnomon.cpp
|
yangevelyn/allolib
|
1654be795b6515c058eb8243751b903a2aa6efdc
|
[
"BSD-3-Clause"
] | 41
|
2018-01-19T18:34:41.000Z
|
2022-01-27T23:52:01.000Z
|
examples/graphics/gnomon.cpp
|
yangevelyn/allolib
|
1654be795b6515c058eb8243751b903a2aa6efdc
|
[
"BSD-3-Clause"
] | 11
|
2018-01-05T16:42:19.000Z
|
2022-01-27T22:08:01.000Z
|
#include "al/app/al_App.hpp"
#include "al/graphics/al_Font.hpp"
#include "al/ui/al_Gnomon.hpp"
using namespace al;
struct MyApp : public App {
Gnomon gnomon;
FontRenderer fontRender;
void onCreate() { fontRender.load(Font::defaultFont().c_str(), 24, 1024); }
void onDraw(Graphics& g) {
g.clear(0.2f);
// Draw at origin with labels
gnomon.drawOrigin(g);
gnomon.drawLabels(g, fontRender, pose());
// draw at specific positions
gnomon.drawAtPos(g, {-1.0, 0, -4});
gnomon.drawAtPos(g, {0.5, 0.5, -4}, Pose(), 0.5);
// draw in front of camera;
gnomon.drawFloating(g, pose(), 0.1);
}
};
int main() {
MyApp app;
app.start();
return 0;
}
| 20.294118
| 77
| 0.630435
|
AlloSphere-Research-Group
|
18d9603349604dad388e3eb31dde6bb4f83c195a
| 2,285
|
cpp
|
C++
|
project-euler/src/pe34.cpp
|
ammarhusain/challenges
|
efdb907833d04e9e37fc800d1b2b32507cfcd2e4
|
[
"MIT"
] | null | null | null |
project-euler/src/pe34.cpp
|
ammarhusain/challenges
|
efdb907833d04e9e37fc800d1b2b32507cfcd2e4
|
[
"MIT"
] | null | null | null |
project-euler/src/pe34.cpp
|
ammarhusain/challenges
|
efdb907833d04e9e37fc800d1b2b32507cfcd2e4
|
[
"MIT"
] | null | null | null |
/** ----------------------------------------------------------------------
* Copyright 2014 < Ammar Husain (Carnegie Mellon University) >
*
* @file pe1.cpp
* @author Ammar Husain <ahusain@nrec.ri.cmu.edu>
* @date Thu Jul 31 17:18:28 2014
*
* @brief Boiler Plate
*
*
---------------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <stdint.h>
#include <iostream>
#include <ctime>
void fillFactorial(std::vector<uint64_t>* factorials,
int n) {
factorials->at(n) = n*factorials->at(n-1);
}
uint64_t sumDigitFactorials(uint64_t num,
const std::vector<uint64_t>& factorials) {
uint64_t sum = 0;
while (num > 0) {
int digit = num%10;
sum += factorials[digit];
num = num/10;
}
return sum;
}
uint64_t DigitFactorials()
{
/// precompute factorials
std::vector<uint64_t> factorials(10);
factorials[0] = 1;
for (uint n = 1; n < 10; n++)
fillFactorial(&factorials, n);
/// lowerbound: 2 digits for adding numbers
/// upper bound: 7*9! = 2540160
/// since 8*9! is also a 7 digit number
uint64_t sum = 0;
for (uint64_t i = 10; i <= 2540160; i++) {
if (i == sumDigitFactorials(i, factorials)) {
std::cout << i << std::endl;
sum += i;
}
}
return sum;
}
/** ----------------------------------------------------------------
* Main Routine
*
* @param argc
* @param argv
*
* @return
---------------------------------------------------------------- */
int main(int argc, char *argv[]) {
std::cout << "Boiler-Plate code!" << std::endl;
uint numTests;
std::cin >> numTests;
uint64_t input;
/// keep a timer
std::clock_t start;
double duration;
for (uint i = 0; i < numTests; i++) {
std::cin >> input;
start = std::clock_t();
/// do work here
uint64_t answer = DigitFactorials();
std::cout << answer << std::endl;
duration = (std::clock() - start)/static_cast<double>(CLOCKS_PER_SEC);
std::cout<< "it took: "<< duration << "s" << std::endl;
}
return 0;
}
| 21.971154
| 78
| 0.476586
|
ammarhusain
|
18ddb8a5ebb3a4f000f095759205d7866f95384b
| 8,193
|
cc
|
C++
|
xt_base/www/www/keyform.cc
|
wrcad/xictools
|
f46ba6d42801426739cc8b2940a809b74f1641e2
|
[
"Apache-2.0"
] | 73
|
2017-10-26T12:40:24.000Z
|
2022-03-02T16:59:43.000Z
|
xt_base/www/www/keyform.cc
|
chris-ayala/xictools
|
4ea72c118679caed700dab3d49a8d36445acaec3
|
[
"Apache-2.0"
] | 12
|
2017-11-01T10:18:22.000Z
|
2022-03-20T19:35:36.000Z
|
xt_base/www/www/keyform.cc
|
chris-ayala/xictools
|
4ea72c118679caed700dab3d49a8d36445acaec3
|
[
"Apache-2.0"
] | 34
|
2017-10-06T17:04:21.000Z
|
2022-02-18T16:22:03.000Z
|
/*========================================================================*
* *
* Copyright (c) 2016 Whiteley Research Inc, all rights reserved. *
* *
* WHITELEY RESEARCH INCORPORATED PROPRIETARY SOFTWARE *
* Author: Stephen R. Whiteley (stevew@wrcad.com)
* *
*========================================================================*
* *
* Key registration form handling
* *
*========================================================================*
$Id: keyform.cc,v 1.1 2016/01/15 19:45:21 stevew Exp $
*========================================================================*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include "backend.h"
//
// This handles the "Get A Key" form.
//
namespace {
const char *sedcmdfmt = "sed \'s/@KEY@/%s/;s/@HOSTNAME@/%s/;"
"s/@MSW@/%s/;s/@LINUX@/%s/;s/@OSX@/%s/;"
"s/@KEYTEXT@/%s/;s/@EMAIL@/%s/;s%c@INFO@%c%s%c\' < "
WWWROOT"/www/prices.in";
}
int main(int argc, char **argv)
{
if (argc < 2)
return (1);
sBackEnd::keyval *kval;
int nkv;
if (!sBackEnd::get_keyvals(&kval, &nkv, argv[1])) {
sBackEnd::errordump("Parse failed!");
return (1);
}
// The keys:
// From "Submit"
// hostname
// keytext
// mtype
// email
// text
// From "Find Existing"
// key
OS_type ostype = OS_NONE;
for (int i = 0; i < nkv; i++) {
if (!strcmp(kval[i].key, "mtype")) {
const char *mtype = kval[i].val;
if (!strcmp(mtype, "msw"))
ostype = OS_MSW;
else if (!strcmp(mtype, "linux"))
ostype = OS_LINUX;
else if (!strcmp(mtype, "osx"))
ostype = OS_OSX;
break;
}
if (!strcmp(kval[i].key, "key")) {
sBackEnd be(ostype);
if (!be.set_key(kval[i].val)) {
sBackEnd::errordump(be.error_msg());
return (1);
}
if (!be.recall_hostname()) {
sBackEnd::errordump(be.error_msg());
return (1);
}
if (!be.recall_mtype()) {
sBackEnd::errordump(be.error_msg());
return (1);
}
if (!be.recall_keytext()) {
sBackEnd::errordump(be.error_msg());
return (1);
}
if (!be.recall_email()) {
sBackEnd::errordump(be.error_msg());
return (1);
}
if (!be.recall_info()) {
sBackEnd::errordump(be.error_msg());
return (1);
}
// We need an info string where the newlines are backslash
// quoted.
int len = 0;
const char *p = be.info();
while (*p) {
if (*p == '\n')
len++;
len++;
p++;
}
char *info = new char[len+1];
char *t = info;
p = be.info();
while (*p) {
if (*p == '\n')
*t++ = '\\';
*t++ = *p++;
}
*t = 0;
// Find a delimiter for sed that is not used in the info.
char sp = 0;
if (strchr(info, '/') == 0)
sp = '/';
else if (strchr(info, '%') == 0)
sp = '%';
else if (strchr(info, '&') == 0)
sp = '&';
else if (strchr(info, '~') == 0)
sp = '~';
else if (strchr(info, '+') == 0)
sp = '+';
else {
for (t = info; *t; t++) {
if (*t == '+')
*t = ' ';
}
sp = '+';
}
char *sedcmd = new char[strlen(sedcmdfmt) + strlen(info) +
strlen(be.get_key()) + strlen(be.hostname()) +
strlen(be.keytext()) + strlen(be.email()) + 20];
const char *msw = "";
const char *lnx = "";
const char *osx = "";
if (*be.osname() == 'm')
msw = "selected";
else if (*be.osname() == 'l')
lnx = "selected";
else if (*be.osname() == 'o')
osx = "selected";
sprintf(sedcmd, sedcmdfmt, be.get_key(), be.hostname(),
msw, lnx, osx, be.keytext(), be.email(), sp, sp, info, sp);
delete [] info;
system(sedcmd);
delete [] sedcmd;
return (0);
}
}
if (ostype == OS_NONE) {
sBackEnd::errordump("No Operating System selected!");
return (1);
}
sBackEnd be(ostype);
for (int i = 0; i < nkv; i++) {
if (!strcmp(kval[i].key, "hostname")) {
if (!be.set_hostname(kval[i].val)) {
sBackEnd::errordump(be.error_msg());
return (1);
}
}
else if (!strcmp(kval[i].key, "keytext")) {
if (!be.set_keytext(kval[i].val)) {
sBackEnd::errordump(be.error_msg());
return (1);
}
}
else if (!strcmp(kval[i].key, "email")) {
if (!be.set_email(kval[i].val)) {
sBackEnd::errordump(be.error_msg());
return (1);
}
}
else if (!strcmp(kval[i].key, "text")) {
if (!be.set_info(kval[i].val)) {
sBackEnd::errordump(be.error_msg());
return (1);
}
}
}
// Create the user's key.
const char *key = be.get_key();
if (!key) {
sBackEnd::errordump(be.error_msg());
return (1);
}
// Save the key data in a file.
if (!be.save_key_data()) {
sBackEnd::errordump(be.error_msg());
return (1);
}
// Email the key data to the user.
char *df = be.key_datafile();
FILE *kp = fopen(df, "r");
if (!kp) {
sBackEnd::errordump("failed to open data file");
return (1);
}
delete [] df;
const char *mcmd = "mail -s \"Whiteley Research license key\"";
char *cmd = new char[strlen(mcmd) + strlen(be.email()) + 2];
sprintf(cmd, "%s %s", mcmd, be.email());
FILE *fp = popen(cmd, "w");
if (!fp) {
sBackEnd::errordump("failed to start email thread");
return (1);
}
fprintf(fp, "Hello from wrcad.com, your license key is\n%s\n\n",
be.get_key());
fprintf(fp, "Keep this in a safe place, you will need this to renew\n"
"your license. Contact Whiteley Research if any questions.\n\n");
fprintf(fp, "Automated message, don't reply!\n\n");
fprintf(fp, "The data for this key follows, please verify correctness\n"
"You can re-create the key if necessary to update info.\n\n");
int c;
while ((c = fgetc(kp)) != EOF)
fputc(c, fp);
fclose(kp);
fputc('\n', fp);
pclose(fp);
// Compose the response page.
printf("<body background=/images/tmbg.gif text=#000000 link=#9c009e"
" vlink=#551a8b alink=#ff0000>\n");
printf("<br><br><br><br><br><br><br><br><br><br>\n");
printf("<center><table border=1 cellpadding=12><tr><td bgcolor=white>\n");
printf("<center>Your license key<br><br> <font size=5><tt>%s</tt></font><br></center>\n",
be.get_key());
printf("<br><br>Key data has been emailed to: <tt>%s</tt><br>\n",
be.email());
printf("<p><a href=/cgi-bin/prices.cgi?key=%s#getakey><b>Click here</b></a>"
" to continue.\n", be.get_key());
printf("</td></tr></table></center>\n");
return (0);
}
| 31.511538
| 93
| 0.415965
|
wrcad
|
18dea84a1a363f1f784a879e81c7f1a589eae3b3
| 409
|
cpp
|
C++
|
codechef/bolt.cpp
|
zshashz/CS50-
|
79067df0df1da02d716591a29f3b8670618c962d
|
[
"MIT"
] | 4
|
2021-01-11T13:05:33.000Z
|
2022-02-02T18:17:53.000Z
|
codechef/bolt.cpp
|
zshashz/CS50-
|
79067df0df1da02d716591a29f3b8670618c962d
|
[
"MIT"
] | null | null | null |
codechef/bolt.cpp
|
zshashz/CS50-
|
79067df0df1da02d716591a29f3b8670618c962d
|
[
"MIT"
] | 1
|
2021-10-03T12:46:20.000Z
|
2021-10-03T12:46:20.000Z
|
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin>>T;
for(int i=0; i<T; i++)
{
double k1,k2,k3,v;
cin>>k1>>k2>>k3>>v;
double tans = 100/(k1*k2*k3*v);
double t = (round(tans*100))/100;
if (t<9.58)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
| 16.36
| 41
| 0.432763
|
zshashz
|
18e03d1d708bdb656177db3811bb6d1089d1e45b
| 10,018
|
cpp
|
C++
|
ZooidEngine/SceneRenderer/RenderPass/DepthRenderPass.cpp
|
azon04/Z0-Engine
|
1a44781fb5308c11c3b63b954ad683a51e9ba271
|
[
"MIT"
] | 4
|
2019-05-31T22:55:49.000Z
|
2020-11-26T11:55:34.000Z
|
ZooidEngine/SceneRenderer/RenderPass/DepthRenderPass.cpp
|
azon04/Z0-Engine
|
1a44781fb5308c11c3b63b954ad683a51e9ba271
|
[
"MIT"
] | null | null | null |
ZooidEngine/SceneRenderer/RenderPass/DepthRenderPass.cpp
|
azon04/Z0-Engine
|
1a44781fb5308c11c3b63b954ad683a51e9ba271
|
[
"MIT"
] | 1
|
2018-04-11T02:50:47.000Z
|
2018-04-11T02:50:47.000Z
|
#include "DepthRenderPass.h"
#include "ResourceManagers/ShaderManager.h"
#include "ResourceManagers/BufferManager.h"
#include "Resources/Texture.h"
#include "Renderer/IRenderer.h"
#include "Renderer/RenderZooid.h"
#include "Renderer/IGPURenderBuffer.h"
#include "Renderer/IGPUFrameBuffer.h"
#include "Renderer/IGPUTexture.h"
#include "Renderer/IGPUStates.h"
#include "Renderer/RenderQuery.h"
#include "SceneRenderer/SceneRenderer.h"
#include "Math/Vector4.h"
#include "Renderer/DrawList.h"
namespace ZE
{
bool g_bDoSceneOcclusion = false;
bool g_bDoShadowOcclusion = false;
DepthRenderPass::DepthRenderPass()
{
m_shaderChain = nullptr;
m_skinnedShaderChain = nullptr;
m_depthTexture = nullptr;
m_frameBuffer = nullptr;
}
void DepthRenderPass::prepare(GameContext* _gameContext)
{
ScopedRenderThreadOwnership renderLock(_gameContext->getRenderer());
m_shaderChain = ShaderManager::GetInstance()->getShaderChain(Z_SHADER_CHAIN_DEPTH_ONLY);
m_skinnedShaderChain = ShaderManager::GetInstance()->getShaderChain(Z_SHADER_CHAIN_DEPTH_ONLY_SKINNED);
if (!m_depthTexture)
{
TextureCreateDesc textureDesc;
textureDesc.Width = (UInt32)_gameContext->getRenderer()->GetWidth();
textureDesc.Height = (UInt32)_gameContext->getRenderer()->GetHeight();
textureDesc.Channel = 1;
textureDesc.TextureFormat = TEX_DEPTH24_STENCIL8;
textureDesc.WrapU = CLAMP_TO_BORDER;
textureDesc.WrapV = CLAMP_TO_BORDER;
textureDesc.MinFilter = LINEAR;
textureDesc.MagFilter = LINEAR;
textureDesc.DataType = UNSIGNED_INT_24_8;
textureDesc.bGenerateMipMap = false;
Handle depthTextureHandle = _gameContext->getRenderZooid()->CreateRenderTexture();
if (depthTextureHandle.isValid())
{
m_depthTexture = depthTextureHandle.getObject<IGPUTexture>();
m_depthTexture->create(textureDesc);
m_depthTexture->setDebugName("DepthStencilBuffer");
}
}
if (!m_frameBuffer)
{
// Create Frame buffer
Handle fbHandle = _gameContext->getRenderZooid()->CreateFrameBuffer();
if (fbHandle.isValid())
{
m_frameBuffer = fbHandle.getObject<IGPUFrameBuffer>();
m_frameBuffer->bind();
m_frameBuffer->addTextureAttachment(DEPTH_STENCIL_ATTACHMENT, m_depthTexture);
m_frameBuffer->setupAttachments();
m_frameBuffer->unbind();
}
}
}
void DepthRenderPass::release(GameContext* _gameContext)
{
if (m_frameBuffer) { m_frameBuffer->release(); m_frameBuffer = nullptr; }
if (m_depthTexture) { m_depthTexture->release(); m_depthTexture = nullptr; }
}
void DepthRenderPass::begin(GameContext* _gameContext)
{
RenderPass::begin(_gameContext);
ZCHECK(m_frameBuffer);
m_frameBuffer->bind();
}
void DepthRenderPass::end(GameContext* _gameContext)
{
RenderPass::end(_gameContext);
m_frameBuffer->unbind();
// Add output
addOutputTextureBuffer(m_depthTexture);
}
bool DepthRenderPass::execute_CPU(GameContext* _gameContext)
{
return true;
}
bool DepthRenderPass::execute_GPU(GameContext* _gameContext)
{
DrawList* drawList = _gameContext->getRenderDrawList();
_gameContext->getRenderer()->ResetViewport();
_gameContext->getRenderer()->Clear(ERenderBufferBit::DEPTH_BUFFER_BIT | ERenderBufferBit::STENCIL_BUFFER_BIT);
MeshSceneRenderer::Render(drawList->m_meshRenderGatherer.getRenderInfos(), drawList->m_meshRenderGatherer.getRenderCount(), m_shaderChain, true);
SkinMeshSceneRenderer::Render(drawList->m_skinMeshRenderGatherer.getRenderInfos(), drawList->m_skinMeshRenderGatherer.getRenderCount(), m_skinnedShaderChain);
if (g_bDoSceneOcclusion)
{
doOcclusionSceneQueries(drawList->m_meshRenderGatherer.getRenderInfos(), drawList->m_meshRenderGatherer.getRenderCount());
doOcclusionSceneQueries(drawList->m_skinMeshRenderGatherer.getRenderInfos(), drawList->m_skinMeshRenderGatherer.getRenderCount(), true);
if (g_bDoShadowOcclusion)
{
doShadowOcclusionQueries();
}
}
return true;
}
void DepthRenderPass::doOcclusionSceneQueries(RenderInfo* renderInfos, UInt32 renderInfoCount, bool bUsingSkeleton)
{
if (renderInfoCount == 0) { return; }
gGameContext->getRenderer()->PushDebugGroup("SceneOcclusionQueries");
MeshRenderInfo* meshRenderInfos = static_cast<MeshRenderInfo*>(renderInfos);
SkinMeshRenderInfo* skinMeshRenderInfos = static_cast<SkinMeshRenderInfo*>(renderInfos);
// Make Render Queries
Array<RenderQuery> renderQueries(renderInfoCount);
// Get the cube buffer
IGPUBufferArray* cubeArray = BufferManager::getInstance()->getBufferArray(BUFFER_ARRAY_CUBE);
m_shaderChain->bind();
cubeArray->bind();
// Set Depth State
gGameContext->getRenderer()->SetRenderDepthStencilState(TRenderDepthStencilState<true, false, false, ERendererCompareFunc::LEQUAL, ERendererCompareFunc::ALWAYS, 0, 0, 0>::GetGPUState());
gGameContext->getRenderer()->SetRenderRasterizerState(TRenderRasterizerState<EFaceFrontOrder::CCW, ECullFace::CULL_NONE, ERenderFillMode::MODE_FILL>::GetGPUState());
Matrix4x4 transform;
Matrix4x4 worldTransform;
Vector3 extent;
Vector3 pos;
bool bUseStencil = false;
for (UInt32 index = 0; index < renderInfoCount; index++)
{
if (bUsingSkeleton)
{
SkinMeshRenderInfo& skinMesh = skinMeshRenderInfos[index];
extent = skinMesh.m_boxExtent;
pos = skinMesh.m_boxLocalPos;
worldTransform = skinMesh.m_worldTransform;
bUseStencil = false;
}
else
{
MeshRenderInfo& currentMesh = meshRenderInfos[index];
extent = currentMesh.m_boxExtent;
pos = currentMesh.m_boxLocalPos;
worldTransform = currentMesh.m_worldTransform;
bUseStencil = currentMesh.m_outlined;
}
// check if scale has any zero
if (extent.m_x == 0.0f) { extent.m_x = 0.001f; }
if (extent.m_y == 0.0f) { extent.m_y = 0.001f; }
if (extent.m_z == 0.0f) { extent.m_z = 0.001f; }
transform.setScale(extent * 2.0f);
transform.setPos(pos);
transform = transform * worldTransform;
// Bind frame_data
gGameContext->getRenderDrawList()->m_mainConstantBuffer->bind();
m_shaderChain->bindConstantBuffer("frame_data", gGameContext->getRenderDrawList()->m_mainConstantBuffer);
// Create and bind draw data
IGPUBufferData* drawBufferData = BufferManager::getInstance()->getOrCreateDrawBuffer(transform.m_data, sizeof(Matrix4x4));
drawBufferData->bind();
m_shaderChain->bindConstantBuffer("draw_data", drawBufferData);
renderQueries[index].BeginQuery(gGameContext->getRenderer(), RQ_ANY_SAMPLES_PASSED);
gGameContext->getRenderer()->DrawArray(ERenderTopologyEnum::TOPOLOGY_TRIANGLE, 0, 36);
renderQueries[index].EndQuery();
}
gGameContext->getRenderer()->SetRenderRasterizerState(DefaultRasterizerState::GetGPUState());
gGameContext->getRenderer()->SetRenderDepthStencilState(DefaultDepthStencilState::GetGPUState());
cubeArray->unbind();
m_shaderChain->unbind();
// Flush Command to get the query results
gGameContext->getRenderer()->FlushCommands();
gGameContext->getRenderer()->FinishCommands();
for (UInt32 index = 0; index < renderInfoCount; index++)
{
MeshRenderInfo& currentMesh = meshRenderInfos[index];
if (renderQueries[index].IsResultAvailable())
{
currentMesh.m_bCulled = !renderQueries[index].GetBoolResult();
}
}
gGameContext->getRenderer()->PopDebugGroup();
}
void DepthRenderPass::doShadowOcclusionQueries()
{
gGameContext->getRenderer()->PushDebugGroup("ShadowOcclusionQueries");
DrawList* drawList = gGameContext->getRenderDrawList();
const int shadowMapCount = drawList->m_lightShadowSize;
// Make Render Queries
Array<RenderQuery> renderQueries(shadowMapCount);
// Get the cube buffer
IGPUBufferArray* cubeArray = BufferManager::getInstance()->getBufferArray(BUFFER_ARRAY_CUBE);
m_shaderChain->bind();
cubeArray->bind();
// Set Depth State
gGameContext->getRenderer()->SetRenderDepthStencilState(TRenderDepthStencilState<true, false, false, ERendererCompareFunc::LEQUAL, ERendererCompareFunc::ALWAYS, 0, 0, 0>::GetGPUState());
gGameContext->getRenderer()->SetRenderRasterizerState(TRenderRasterizerState<EFaceFrontOrder::CCW, ECullFace::CULL_NONE, ERenderFillMode::MODE_FILL>::GetGPUState());
Matrix4x4 transform;
Matrix4x4 worldTransform;
Vector3 extent;
Vector3 pos;
for (UInt32 index = 0; index < shadowMapCount; index++)
{
if (drawList->m_lightShadowMapData[index].cascadeIndex == 0) { continue; } // first cascade index always visible, no need to do this
transform = drawList->m_lightShadowMapData[index].cullingBoxTransform;
// Bind frame_data
gGameContext->getRenderDrawList()->m_mainConstantBuffer->bind();
m_shaderChain->bindConstantBuffer("frame_data", gGameContext->getRenderDrawList()->m_mainConstantBuffer);
// Create and bind draw data
IGPUBufferData* drawBufferData = BufferManager::getInstance()->getOrCreateDrawBuffer(transform.m_data, sizeof(Matrix4x4));
drawBufferData->bind();
m_shaderChain->bindConstantBuffer("draw_data", drawBufferData);
renderQueries[index].BeginQuery(gGameContext->getRenderer(), RQ_ANY_SAMPLES_PASSED);
gGameContext->getRenderer()->DrawArray(ERenderTopologyEnum::TOPOLOGY_TRIANGLE, 0, 36);
renderQueries[index].EndQuery();
}
gGameContext->getRenderer()->SetRenderRasterizerState(DefaultRasterizerState::GetGPUState());
gGameContext->getRenderer()->SetRenderDepthStencilState(DefaultDepthStencilState::GetGPUState());
cubeArray->unbind();
m_shaderChain->unbind();
// Flush Command to get the query results
gGameContext->getRenderer()->FlushCommands();
gGameContext->getRenderer()->FinishCommands();
for (UInt32 index = 0; index < shadowMapCount; index++)
{
LightShadowMapData& lightMapData = drawList->m_lightShadowMapData[index];
if (lightMapData.cascadeIndex == 0) { continue; } // first cascade index always visible, no need to do this
if (renderQueries[index].IsResultAvailable())
{
lightMapData.bCull = !renderQueries[index].GetBoolResult();
}
}
gGameContext->getRenderer()->PopDebugGroup();
}
}
| 34.191126
| 188
| 0.759034
|
azon04
|
18e8bbbdc11f52188820140a0ae88bd9fa3fe142
| 6,901
|
cpp
|
C++
|
loop-perf/LoopPerforation.cpp
|
avanhatt/llvm-loop-perforation
|
5182f366ea4df2fa5dbf5f0863809f2d17f495a4
|
[
"MIT"
] | 3
|
2020-01-17T22:05:11.000Z
|
2020-12-15T18:48:25.000Z
|
loop-perf/LoopPerforation.cpp
|
avanhatt/llvm-loop-perforation
|
5182f366ea4df2fa5dbf5f0863809f2d17f495a4
|
[
"MIT"
] | null | null | null |
loop-perf/LoopPerforation.cpp
|
avanhatt/llvm-loop-perforation
|
5182f366ea4df2fa5dbf5f0863809f2d17f495a4
|
[
"MIT"
] | 1
|
2020-01-17T22:06:41.000Z
|
2020-01-17T22:06:41.000Z
|
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/IVUsers.h"
#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/Mem2Reg.h"
#include "llvm/Support/CommandLine.h"
#include "json.hpp"
#include <fstream>
#include <sstream>
using namespace llvm;
using namespace nlohmann;
using namespace std;
namespace {
int fileexists(string filename){
/* try to open file to read */
FILE *file;
if ((file = fopen(filename.c_str(), "r"))) {
fclose(file);
return 1;
}
return 0;
}
// -info is a command line argument to opt
static cl::opt<string> InfoFilename(
"info", // Name of command line arg
cl::desc("Specify the filename to write the loop info to"), // -help text
cl::init("loop-info.json") // Default value
);
// -rates is a command line argument to opt
static cl::opt<string> RatesFilename(
"rates", // Name of command line arg
cl::desc("Specify the filename to read the loop rates from"), // -help text
cl::init("loop-rates.json") // Default value
);
// Taken from llvm's Loop::Print()
// But doesn't print loop depth
std::string StringifyLoop(Loop *L) {
std::string LoopString;
raw_string_ostream LoopStream(LoopString);
BasicBlock *H = L->getHeader();
for (unsigned i = 0; i < L->getBlocks().size(); ++i) {
BasicBlock *BB = L->getBlocks()[i];
if (i)
LoopStream << ",";
BB->printAsOperand(LoopStream, false);
if (BB == H)
LoopStream << "<header>";
if (L->isLoopLatch(BB))
LoopStream << "<latch>";
if (L->isLoopExiting(BB))
LoopStream << "<exiting>";
}
return LoopStream.str();
}
bool isLoopPerforable(Loop *L) {
// skip loops in functions containing "NO_PERF"
const Function *F = L->getHeader()->getParent();
if (F->getName().find("NO_PERF") != std::string::npos) {
errs() << "Skipping loop in function: " << F->getName() << "\n";
return false;
}
// We don't modify unsimplified loops
bool IsSimple = L->isLoopSimplifyForm();
if (!IsSimple) {
return false;
}
// Find the canonical induction variable for this loop
PHINode *PHI = L->getCanonicalInductionVariable();
if (PHI == nullptr) {
return false;
}
// Find where the induction variable is modified by finding a user that
// is also an incoming value to the phi
Value *ValueToChange = nullptr;
for (auto User : PHI->users()) {
for (auto &Incoming : PHI->incoming_values()) {
if (Incoming == User) {
ValueToChange = Incoming;
break; // TODO: what if there are multiple?
}
}
}
if (ValueToChange == nullptr) {
return false;
}
if (!isa<BinaryOperator>(ValueToChange)) {
return false;
}
return true;
}
struct LoopCountPass : public FunctionPass {
static char ID;
json j;
LoopCountPass() : FunctionPass(ID) { }
// Write one JSON file in the destructor so it is only written once
// Expectation: one module per .ll file (but we don't rely on this)
~LoopCountPass() {
std::ofstream JsonFile;
JsonFile.open(InfoFilename);
JsonFile << j.dump(4) << "\n";
JsonFile.close();
}
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<LoopInfoWrapperPass>();
AU.addRequiredID(LoopSimplifyID);
}
// Record the loop's basic blocks in the JSON and handle subloops
void handleLoop(Function &F, Loop *L, int &NumLoops) {
if (isLoopPerforable(L)) {
NumLoops++;
j[F.getParent()->getName()][F.getName()][StringifyLoop(L)] = {};
}
// still handle subloops of non-perforable loops
for (Loop *SubLoop : L->getSubLoops()) {
handleLoop(F, SubLoop, NumLoops);
}
}
// Get the canonical form of all the function's loops
virtual bool runOnFunction(Function &F) {
LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
int NumLoops = 0;
for (auto &L : LI) {
handleLoop(F, L, NumLoops);
}
return false;
}
};
struct LoopPerforationPass : public LoopPass {
static char ID;
json j;
// Read the JSON with each loop's perforation rate
LoopPerforationPass() : LoopPass(ID) {
std::ifstream JsonFile;
std::stringstream buffer;
if (fileexists(RatesFilename)) {
JsonFile.open(RatesFilename);
buffer << JsonFile.rdbuf();
JsonFile.close();
j = json::parse(buffer.str());
}
}
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<LoopInfoWrapperPass>();
AU.addRequired<IVUsersWrapperPass>();
AU.addRequiredID(LoopSimplifyID);
}
virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
const Function *F = L->getHeader()->getParent();
// only run this perforation pass on loops that were
// determined to be perforable and were inserted into
// loop-info.json by the info pass
if (!j.contains(F->getParent()->getName()) ||
!j[F->getParent()->getName()].contains(F->getName()) ||
!j[F->getParent()->getName()][F->getName()].contains(StringifyLoop(L)))
return false;
// Find the canonical induction variable for this loop
PHINode *PHI = L->getCanonicalInductionVariable();
// Find where the induction variable is modified by finding a user that
// is also an incoming value to the phi
Value *ValueToChange = nullptr;
for (auto User : PHI->users()) {
for (auto &Incoming : PHI->incoming_values()) {
if (Incoming == User) {
ValueToChange = Incoming;
break; // TODO: what if there are multiple?
}
}
}
BinaryOperator *Increment = dyn_cast<BinaryOperator>(ValueToChange);
for (auto &Op : Increment->operands()) {
if (Op == PHI) continue;
int LoopRate = 1;
if (!j.empty()) {
LoopRate = j[F->getParent()->getName()][F->getName()][StringifyLoop(L)];
}
Type *ConstType = Op->getType();
Constant *NewInc = ConstantInt::get(ConstType, LoopRate /*value*/, true /*issigned*/);
errs() << "Changing [" << *Op << "] to [" << *NewInc << "]!\n";
Op = NewInc;
return true;
}
// should never reach here
return false;
}
};
}
char LoopPerforationPass::ID = 0;
char LoopCountPass::ID = 1;
// Register the pass so `opt -loop-perf` runs it.
static RegisterPass<LoopPerforationPass> X("loop-perf", "loop perforation pass");
static RegisterPass<LoopCountPass> Y("loop-count", "loop counting pass");
| 29.618026
| 94
| 0.61252
|
avanhatt
|
18ea96d0c0d3ae734df3fd3379dddaf3ffe75306
| 2,699
|
cpp
|
C++
|
src/GPE_Engine/GPE_Audio.cpp
|
creikey/Game-Pencil-Engine
|
961a33f090b6b8d94a660db9e4b67644d829c96f
|
[
"MIT"
] | null | null | null |
src/GPE_Engine/GPE_Audio.cpp
|
creikey/Game-Pencil-Engine
|
961a33f090b6b8d94a660db9e4b67644d829c96f
|
[
"MIT"
] | null | null | null |
src/GPE_Engine/GPE_Audio.cpp
|
creikey/Game-Pencil-Engine
|
961a33f090b6b8d94a660db9e4b67644d829c96f
|
[
"MIT"
] | null | null | null |
/*
GPE_Audio.cpp
This file is part of:
GAME PENCIL ENGINE
https://create.pawbyte.com
Copyright (c) 2014-2019 Nathan Hurde, Chase Lee.
Copyright (c) 2014-2019 PawByte LLC.
Copyright (c) 2014-2019 Game Pencil Engine contributors ( Contributors Page )
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.
-Game Pencil Engine <https://create.pawbyte.com>
*/
#include "GPE_Audio.h"
GPE_Audio::GPE_Audio(int aId , std::string aName , std::string aFileName )
{
audioChunk = NULL;
audioMusic = NULL;
audioId = aId;
audioName = aName;
audioFileName = aFileName;
audioLoops = 0;
isPlaying = false;
currentHour = 0;
currentMin = 0;
currentSec = 0;
currentPosition = 0;
audioLength = 0;
load_audio( audioFileName);
}
GPE_Audio::~GPE_Audio()
{
if( audioChunk!=NULL)
{
Mix_FreeChunk( audioChunk );
audioChunk = NULL;
}
if( audioMusic!=NULL)
{
Mix_FreeMusic(audioMusic);
audioMusic = NULL;
}
}
void GPE_Audio::audio_play( int repeatTimes )
{
}
void GPE_Audio::audio_pause()
{
}
void GPE_Audio::audio_stop()
{
}
int GPE_Audio::get_length()
{
return audioLength;
}
int GPE_Audio::get_position()
{
return currentPosition;
}
int GPE_Audio::get_position_secs()
{
return currentSec;
}
int GPE_Audio::get_position_min()
{
return currentMin;
}
int GPE_Audio::get_position_hour()
{
return currentMin;
}
int GPE_Audio::get_remaining_loops()
{
return audioLoops;
}
void GPE_Audio::load_audio( std::string aFileName)
{
}
bool GPE_Audio::is_playing()
{
return isPlaying;
}
| 21.943089
| 79
| 0.690626
|
creikey
|
18eb34869fd03cfd84df3483c3524043d4cec38e
| 4,659
|
hxx
|
C++
|
main/filter/source/pdf/pdfexport.hxx
|
Grosskopf/openoffice
|
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
|
[
"Apache-2.0"
] | 679
|
2015-01-06T06:34:58.000Z
|
2022-03-30T01:06:03.000Z
|
main/filter/source/pdf/pdfexport.hxx
|
Grosskopf/openoffice
|
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
|
[
"Apache-2.0"
] | 102
|
2017-11-07T08:51:31.000Z
|
2022-03-17T12:13:49.000Z
|
main/filter/source/pdf/pdfexport.hxx
|
Grosskopf/openoffice
|
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
|
[
"Apache-2.0"
] | 331
|
2015-01-06T11:40:55.000Z
|
2022-03-14T04:07:51.000Z
|
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef PDFEXPORT_HXX
#define PDFEXPORT_HXX
#include "pdffilter.hxx"
#include <tools/multisel.hxx>
#include <vcl/pdfwriter.hxx>
#include <vcl/pdfextoutdevdata.hxx>
#include <com/sun/star/view/XRenderable.hpp>
class SvEmbeddedObject;
class GDIMetaFile;
class VirtualDevice;
class PolyPolygon;
class Gradient;
class BitmapEx;
class Point;
class Size;
namespace vcl { class PDFWriter; }
// -------------
// - PDFExport -
// -------------
class PDFExport
{
private:
Reference< XComponent > mxSrcDoc;
Reference< lang::XMultiServiceFactory > mxMSF;
Reference< task::XStatusIndicator > mxStatusIndicator;
Reference< task::XInteractionHandler > mxIH;
sal_Bool mbUseTaggedPDF;
sal_Int32 mnPDFTypeSelection;
sal_Bool mbExportNotes;
sal_Bool mbExportNotesPages;
sal_Bool mbEmbedStandardFonts;
sal_Bool mbUseTransitionEffects;
sal_Bool mbExportBookmarks;
sal_Int32 mnOpenBookmarkLevels;
sal_Bool mbUseLosslessCompression;
sal_Bool mbReduceImageResolution;
sal_Bool mbSkipEmptyPages;
sal_Bool mbAddStream;
sal_Int32 mnMaxImageResolution;
sal_Int32 mnQuality;
sal_Int32 mnFormsFormat;
sal_Bool mbExportFormFields;
sal_Bool mbAllowDuplicateFieldNames;
sal_Int32 mnProgressValue;
sal_Bool mbRemoveTransparencies;
sal_Bool mbWatermark;
uno::Any maWatermark;
//these variable are here only to have a location in filter/pdf to set the default
//to be used by the macro (when the FilterData are set by the macro itself)
sal_Bool mbHideViewerToolbar;
sal_Bool mbHideViewerMenubar;
sal_Bool mbHideViewerWindowControls;
sal_Bool mbFitWindow;
sal_Bool mbCenterWindow;
sal_Bool mbOpenInFullScreenMode;
sal_Bool mbDisplayPDFDocumentTitle;
sal_Int32 mnPDFDocumentMode;
sal_Int32 mnPDFDocumentAction;
sal_Int32 mnZoom;
sal_Int32 mnInitialPage;
sal_Int32 mnPDFPageLayout;
sal_Bool mbFirstPageLeft;
sal_Bool mbEncrypt;
sal_Bool mbRestrictPermissions;
sal_Int32 mnPrintAllowed;
sal_Int32 mnChangesAllowed;
sal_Bool mbCanCopyOrExtract;
sal_Bool mbCanExtractForAccessibility;
SvtGraphicFill maCacheFill;
sal_Int32 mnCachePatternId;
//--->i56629
sal_Bool mbExportRelativeFsysLinks;
sal_Int32 mnDefaultLinkAction;
sal_Bool mbConvertOOoTargetToPDFTarget;
sal_Bool mbExportBmkToDest;
//<---
sal_Bool ImplExportPage( ::vcl::PDFWriter& rWriter, ::vcl::PDFExtOutDevData& rPDFExtOutDevData,
const GDIMetaFile& rMtf );
void ImplWriteWatermark( ::vcl::PDFWriter& rWriter, const Size& rPageSize );
public:
PDFExport( const Reference< XComponent >& rxSrcDoc,
const Reference< task::XStatusIndicator >& xStatusIndicator,
const Reference< task::XInteractionHandler >& xIH,
const Reference< lang::XMultiServiceFactory >& xFact );
~PDFExport();
sal_Bool ExportSelection( vcl::PDFWriter& rPDFWriter, Reference< com::sun::star::view::XRenderable >& rRenderable, Any& rSelection,
MultiSelection aMultiSelection, Sequence< PropertyValue >& rRenderOptions, sal_Int32 nPageCount );
sal_Bool Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData );
void showErrors( const std::set<vcl::PDFWriter::ErrorCode>& );
};
#endif
| 35.030075
| 147
| 0.657437
|
Grosskopf
|
18f0ea5527cb789b6c4aa7af6bffee73d562164a
| 16,636
|
cpp
|
C++
|
linear_solvers/Solver.cpp
|
acse-qq219/Linear_Solvers_app
|
faf5c2272a542a21a3da0c4689adc7eaad30b8e5
|
[
"MIT"
] | null | null | null |
linear_solvers/Solver.cpp
|
acse-qq219/Linear_Solvers_app
|
faf5c2272a542a21a3da0c4689adc7eaad30b8e5
|
[
"MIT"
] | null | null | null |
linear_solvers/Solver.cpp
|
acse-qq219/Linear_Solvers_app
|
faf5c2272a542a21a3da0c4689adc7eaad30b8e5
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <string>
#include <vector>
#include "Solver.h"
#define COUNT_TIME_MAX 10001
using namespace std;
template <class T>
Solver<T>::Solver() {}
template <class T>
Solver<T>::~Solver() {}
template <class T>
bool Solver<T>::solverJacobi(int iterations, double allowed_convergence, T init_guess, Matrix<T>& a_left, T* b_right_value, T* x_ans, int& counter) {
// Assign all solutions for the initial guess
for (int i = 0; i < a_left.rows; i++) {
x_ans[i] = init_guess;
}
auto* diag_mat = new Matrix<T>(a_left.rows, a_left.cols, true);
auto* remain_mat = new Matrix<T>(a_left.rows, a_left.cols, true);
a_left.getMatDiag(*diag_mat);
a_left.getMatRemn(*remain_mat);
// Get the inverse of diagonal matrix
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value"
<< "\n No solution";
return false;
}
else {
diag_mat->setValue(i, i, 1. / diag_mat->getValue(i, i));
}
}
// Result of inverse of diagonal matrix dot multiply (vector) b
// output_db = inv(D) .* b
T* output_db = new T[diag_mat->rows];
diag_mat->matVecMult(diag_mat->rows, b_right_value, output_db);
// Get negative of inverse of diagonal matrix for later use
for (int i = 0; i < diag_mat->rows; i++) {
if (diag_mat->getValue(i, i) != 0) {
diag_mat->setValue(i, i, (-diag_mat->getValue(i, i)));
}
}
counter = 0;
do {
// Result of negative inverse of diagonal matrix dot multiple remainder matrix
// output_dr = -inv(D) .* R
auto* output_dr = new Matrix<T>(diag_mat->rows, remain_mat->cols, true);
diag_mat->matMatMult(*remain_mat, *output_dr);
// Result of output_dr matrix dot multiply (vector) x
// output_drx = output_dr .* x
T* output_drx = new T[output_dr->rows];
output_dr->matVecMult(a_left.rows, x_ans, output_drx);
// Result of output_drx add output_db
// output_add = output_drx + output_db
T* output_add = new T[output_dr->rows];
for (int i = 0; i < output_dr->rows; i++) {
output_add[i] = output_drx[i] + output_db[i];
}
T err = 0;
int err_counter = 0;
for (int i = 0; i < a_left.rows; i++) {
err = abs(output_add[i] - x_ans[i]);
x_ans[i] = output_add[i];
if (err <= allowed_convergence) {
err_counter++;
}
}
counter++;
if (err_counter == a_left.rows) {
delete diag_mat;
delete remain_mat;
delete output_dr;
delete[] output_drx;
delete[] output_db;
delete[] output_add;
return true;
}
delete output_dr;
delete[] output_drx;
delete[] output_add;
} while (counter < iterations);
delete[] output_db;
delete diag_mat;
delete remain_mat;
return false;
}
template <class T>
bool Solver<T>::solverGausSeid(int iterations, double allowed_convergence, T init_guess, Matrix<T>& a_left, T* b_right_value, T* x_ans, int& counter) {
// Assign all solutions for the initial guess
T* temp_x = new T[a_left.rows];
for (int i = 0; i < a_left.rows; i++) {
x_ans[i] = init_guess;
temp_x[i] = 0;
}
auto* diag_mat = new Matrix<T>(a_left.rows, a_left.cols, true);
a_left.getMatDiag(*diag_mat);
// Get the negative inverse of diagonal matrix
for (int i = 0; i < diag_mat->rows; i++) {
if (diag_mat->getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value"
<< "\n No solution";
return false;
}
else {
diag_mat->setValue(i, i, 1. / diag_mat->getValue(i, i));
}
}
T temp_L, temp_U, temp_sum, err;
counter = 0;
int err_counter = 0; // if err is less than allowed convergence, err_counter + 1
do {
for (int i = 0; i < a_left.rows; i++) {
temp_L = temp_U = temp_sum = err = 0;
for (int j = 0; j < i; j++) {
temp_L += a_left.getValue(i, j) * x_ans[j];
}
for (int k = a_left.cols - 1; k >= i + 1; k--) {
temp_U += a_left.getValue(i, k) * x_ans[k];
}
temp_sum = b_right_value[i] - temp_L - temp_U;
temp_x[i] = diag_mat->getValue(i, i) * temp_sum;
err = abs(temp_x[i] - x_ans[i]);
x_ans[i] = temp_x[i];
if (err <= allowed_convergence) {
err_counter++;
}
}
counter++;
if (err_counter == a_left.rows) {
delete diag_mat;
return true;
}
} while (counter < iterations);
delete diag_mat;
return false;
}
template <class T>
bool Solver<T>::solverGausElim(Matrix<T>& a_left, T* b_right_value, T* x_ans) {
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value" << endl
<< "No solution" << endl << endl;
system("pause");
return false;
}
}
// Elimination
T temp = 0.0;
for (int k = 0; k < a_left.rows - 1; k++) {
for (int i = k + 1; i < a_left.rows; i++) {
temp = a_left.getValue(i, k) / a_left.getValue(k, k);
for (int j = k; j < a_left.rows; j++) {
a_left.setValue(i, j, a_left.getValue(i, j) - temp * a_left.getValue(k, j));
}
b_right_value[i] -= temp * b_right_value[k];
}
}
//Back substitution
for (int k = a_left.rows - 1; k >= 0; k--) {
temp = 0.0;
for (int j = k + 1; j < a_left.rows; j++) {
temp += a_left.getValue(k, j) * x_ans[j];
}
x_ans[k] = (b_right_value[k] - temp) / a_left.getValue(k, k);
}
return true;
}
template <class T>
bool Solver<T>::solverLuDecom(Matrix<T>& a_left, T* b_right_value, T* x_ans) {
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value" << endl
<< "No solution" << endl << endl;
system("pause");
return false;
}
}
T* mat_U = new T[a_left.rows * a_left.cols];
T* mat_L = new T[a_left.rows * a_left.cols];
T* mat_y = new T[a_left.rows];
for (int i = 0; i < a_left.rows * a_left.cols; i++) {
mat_L[i] = 0;
mat_U[i] = 0;
}
for (int i = 0; i < a_left.rows; i++) {
mat_y[i] = 0;
}
for (int i = 0; i < a_left.rows; i++) {
mat_U[i] = a_left.getValue(0, i);
}
for (int i = 1; i < a_left.rows; i++) {
mat_L[i * a_left.rows] = a_left.getValue(i * a_left.rows) / mat_U[0];
}
for (int i = 1; i < a_left.rows; i++) {
for (int k = i; k < a_left.rows; k++) {
T sum1 = 0;
for (int j = 0; j < i; j++) {
sum1 += mat_L[i * a_left.rows + j] * mat_U[j * a_left.rows + k];
}
mat_U[i * a_left.rows + k] = a_left.getValue(i, k) - sum1;
}
if (i != a_left.rows - 1) {
for (int k = i; k < a_left.rows; k++) {
T sum2 = 0;
for (int j = 0; j < i; j++) {
sum2 += mat_L[k * a_left.rows + j] * mat_U[j * a_left.rows + i];
}
mat_L[k * a_left.rows + i] = (a_left.getValue(k, i) - sum2) / mat_U[i * a_left.rows + i];
}
}
}
for (int i = 0; i < a_left.rows; i++) {
mat_L[i * a_left.rows + i] = 1;
}
mat_y[0] = b_right_value[0];
for (int i = 1; i < a_left.rows; i++) {
T sum3 = 0;
for (int k = 0; k < i; k++) {
sum3 += mat_L[i * a_left.rows + k] * mat_y[k];
}
mat_y[i] = b_right_value[i] - sum3;
}
x_ans[a_left.rows - 1] = mat_y[a_left.rows - 1] / mat_U[a_left.rows * a_left.rows - 1];
for (int i = a_left.rows - 2; i >= 0; i--) {
T sum4 = 0;
for (int k = i + 1; k < a_left.rows; k++) {
sum4 += mat_U[i * a_left.rows + k] * x_ans[k];
}
x_ans[i] = (mat_y[i] - sum4) / mat_U[i * a_left.rows + i];
}
delete[] mat_U;
delete[] mat_L;
delete[] mat_y;
return true;
}
template <class T>
bool Solver<T>::solverSor(int iterations, double allowed_convergence, T init_guess, Matrix<T>& a_left, T* b_right_value, T* x_ans, int& counter) {
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value" << endl
<< "No solution" << endl << endl;
system("pause");
return false;
}
}
T w = 1.46;
T* vec_y = new T[a_left.rows];
for (int i = 0; i < a_left.rows; i++) {
vec_y[i] = 0;
}
for (int i = 0; i < a_left.rows; i++) {
x_ans[i] = init_guess;
}
counter = 0;
do {
T err = 0;
for (int i = 0; i < a_left.rows; i++) {
T s = 0;
for (int j = 0; j < a_left.rows; j++)
if (j != i)
s += a_left.getValue(i, j) * x_ans[j];
vec_y[i] = (b_right_value[i] - s) / a_left.getValue(i, i);
vec_y[i] = (1 - w) * x_ans[i] + w * vec_y[i];
err = abs(x_ans[i] - vec_y[i]);
x_ans[i] = vec_y[i];
if (err <= allowed_convergence) break;
}
counter++;
} while (counter < iterations);
if (counter == iterations) {
delete[] vec_y;
return false;
}
delete[] vec_y;
return true;
}
template <class T>
bool Solver<T>::solverJacobi(int iterations, double allowed_convergence, T init_guess, CSRMatrix<T>& a_left, T* b_right_value, T* x_ans, int& counter) {
// Assign all solutions for the initial guess
for (int i = 0; i < a_left.rows; i++) {
x_ans[i] = init_guess;
}
auto* diag_mat = new CSRMatrix<T>(a_left.rows, a_left.cols, a_left.rows, true);
auto* remain_mat = new CSRMatrix<T>(a_left.rows, a_left.cols, a_left.nnzs, true);
a_left.getMatDiag(*diag_mat);
a_left.getMatRemn(*remain_mat);
// Get the inverse of diagonal matrix
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value"
<< "\n No solution";
return false;
}
else {
diag_mat->setValue(i, i, 1. / diag_mat->getValue(i, i));
}
}
// Result of inverse of diagonal matrix dot multiply (vector) b
// output_db = inv(D) .* b
T* output_db = new T[diag_mat->rows];
diag_mat->matVecMult(diag_mat->rows, b_right_value, output_db);
// Get negative of inverse of diagonal matrix for later use
for (int i = 0; i < diag_mat->rows; i++) {
if (diag_mat->getValue(i, i) != 0) {
diag_mat->setValue(i, i, (-diag_mat->getValue(i, i)));
}
}
counter = 0;
do {
// Result of negative inverse of diagonal matrix dot multiple remainder matrix
// output_dr = -inv(D) .* R
auto* output_dr = new CSRMatrix<T>(diag_mat->rows, remain_mat->cols, a_left.nnzs, true);
diag_mat->matMatMult(*remain_mat, *output_dr);
// Result of output_dr matrix dot multiply (vector) x
// output_drx = output_dr .* x
T* output_drx = new T[output_dr->rows];
output_dr->matVecMult(a_left.rows, x_ans, output_drx);
// Result of output_drx add output_db
// output_add = output_drx + output_db
T* output_add = new T[output_dr->rows];
for (int i = 0; i < output_dr->rows; i++) {
output_add[i] = output_drx[i] + output_db[i];
}
T err = 0;
int err_counter = 0;
for (int i = 0; i < a_left.rows; i++) {
err = abs(output_add[i] - x_ans[i]);
x_ans[i] = output_add[i];
if (err <= allowed_convergence) {
err_counter++;
}
}
counter++;
if (err_counter == a_left.rows) {
delete diag_mat;
delete remain_mat;
delete output_dr;
delete[] output_drx;
delete[] output_db;
delete[] output_add;
return true;
}
delete output_dr;
delete[] output_drx;
delete[] output_add;
} while (counter < iterations);
delete[] output_db;
delete diag_mat;
delete remain_mat;
return false;
}
template <class T>
bool Solver<T>::solverGausSeid(int iterations, double allowed_convergence, T init_guess, CSRMatrix<T>& a_left, T* b_right_value, T* x_ans, int& counter) {
// Assign all solutions for the initial guess
T* temp_x = new T[a_left.rows];
for (int i = 0; i < a_left.rows; i++) {
x_ans[i] = init_guess;
temp_x[i] = 0;
}
auto* diag_mat = new CSRMatrix<T>(a_left.rows, a_left.cols, a_left.cols, true);
a_left.getMatDiag(*diag_mat);
// Get the negative inverse of diagonal matrix
for (int i = 0; i < diag_mat->rows; i++) {
if (diag_mat->getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value"
<< "\n No solution";
return false;
}
else {
diag_mat->setValue(i, i, 1. / diag_mat->getValue(i, i));
}
}
T temp_L, temp_U, temp_sum, err;
counter = 0;
int err_counter = 0; // if err is less than allowed convergence, err_counter + 1
do {
for (int i = 0; i < a_left.rows; i++) {
temp_L = temp_U = temp_sum = err = 0;
for (int j = 0; j < i; j++) {
temp_L += a_left.getValue(i, j) * x_ans[j];
}
for (int k = a_left.cols - 1; k >= i + 1; k--) {
temp_U += a_left.getValue(i, k) * x_ans[k];
}
temp_sum = b_right_value[i] - temp_L - temp_U;
temp_x[i] = diag_mat->getValue(i, i) * temp_sum;
err = abs(temp_x[i] - x_ans[i]);
x_ans[i] = temp_x[i];
if (err <= allowed_convergence) {
err_counter++;
}
}
counter++;
if (err_counter == a_left.rows) {
delete diag_mat;
return true;
}
} while (counter < iterations);
delete diag_mat;
return false;
}
template <class T>
bool Solver<T>::solverGausElim(CSRMatrix<T>& a_left, T* b_right_value, T* x_ans) {
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value" << endl
<< "No solution" << endl << endl;
system("pause");
return false;
}
}
// Elimination
T temp = 0.0;
for (int k = 0; k < a_left.rows - 1; k++) {
for (int i = k + 1; i < a_left.rows; i++) {
temp = a_left.getValue(i, k) / a_left.getValue(k, k);
for (int j = k; j < a_left.rows; j++) {
a_left.setValue(i, j, a_left.getValue(i, j) - temp * a_left.getValue(k, j));
}
b_right_value[i] -= temp * b_right_value[k];
}
}
//Back substitution
for (int k = a_left.rows - 1; k >= 0; k--) {
temp = 0.0;
for (int j = k + 1; j < a_left.rows; j++) {
temp += a_left.getValue(k, j) * x_ans[j];
}
x_ans[k] = (b_right_value[k] - temp) / a_left.getValue(k, k);
}
return true;
}
template <class T>
bool Solver<T>::solverLuDecom(CSRMatrix<T>& a_left, T* b_right_value, T* x_ans) {
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value" << endl
<< "No solution" << endl << endl;
system("pause");
return false;
}
}
T* mat_U = new T[a_left.rows * a_left.cols];
T* mat_L = new T[a_left.rows * a_left.cols];
T* mat_y = new T[a_left.rows];
for (int i = 0; i < a_left.rows * a_left.cols; i++) {
mat_L[i] = 0;
mat_U[i] = 0;
}
for (int i = 0; i < a_left.rows; i++) {
mat_y[i] = 0;
}
for (int i = 0; i < a_left.rows; i++) {
mat_U[i] = a_left.getValue(0, i);
}
for (int i = 1; i < a_left.rows; i++) {
mat_L[i * a_left.rows] = a_left.getValue(i * a_left.rows) / mat_U[0];
}
for (int i = 1; i < a_left.rows; i++) {
for (int k = i; k < a_left.rows; k++) {
T sum1 = 0;
for (int j = 0; j < i; j++) {
sum1 += mat_L[i * a_left.rows + j] * mat_U[j * a_left.rows + k];
}
mat_U[i * a_left.rows + k] = a_left.getValue(i, k) - sum1;
}
if (i != a_left.rows - 1) {
for (int k = i; k < a_left.rows; k++) {
T sum2 = 0;
for (int j = 0; j < i; j++) {
sum2 += mat_L[k * a_left.rows + j] * mat_U[j * a_left.rows + i];
}
mat_L[k * a_left.rows + i] = (a_left.getValue(k, i) - sum2) / mat_U[i * a_left.rows + i];
}
}
}
for (int i = 0; i < a_left.rows; i++) {
mat_L[i * a_left.rows + i] = 1;
}
mat_y[0] = b_right_value[0];
for (int i = 1; i < a_left.rows; i++) {
T sum3 = 0;
for (int k = 0; k < i; k++) {
sum3 += mat_L[i * a_left.rows + k] * mat_y[k];
}
mat_y[i] = b_right_value[i] - sum3;
}
x_ans[a_left.rows - 1] = mat_y[a_left.rows - 1] / mat_U[a_left.rows * a_left.rows - 1];
for (int i = a_left.rows - 2; i >= 0; i--) {
T sum4 = 0;
for (int k = i + 1; k < a_left.rows; k++) {
sum4 += mat_U[i * a_left.rows + k] * x_ans[k];
}
x_ans[i] = (mat_y[i] - sum4) / mat_U[i * a_left.rows + i];
}
delete[] mat_U;
delete[] mat_L;
delete[] mat_y;
return true;
}
template <class T>
bool Solver<T>::solverSor(int iterations, double allowed_convergence, T init_guess, CSRMatrix<T>& a_left, T* b_right_value, T* x_ans, int& counter) {
for (int i = 0; i < a_left.rows; i++) {
if (a_left.getValue(i, i) == 0) {
cerr << "Main diagonal elements of LHS A matrix exist 0 value" << endl
<< "No solution" << endl << endl;
system("pause");
return false;
}
}
T w = 1.46;
T* vec_y = new T[a_left.rows];
for (int i = 0; i < a_left.rows; i++) {
vec_y[i] = 0;
}
for (int i = 0; i < a_left.rows; i++) {
x_ans[i] = init_guess;
}
counter = 0;
do {
T err = 0;
for (int i = 0; i < a_left.rows; i++) {
T s = 0;
for (int j = 0; j < a_left.rows; j++)
if (j != i)
s += a_left.getValue(i, j) * x_ans[j];
vec_y[i] = (b_right_value[i] - s) / a_left.getValue(i, i);
vec_y[i] = (1 - w) * x_ans[i] + w * vec_y[i];
err = abs(x_ans[i] - vec_y[i]);
x_ans[i] = vec_y[i];
if (err <= allowed_convergence) break;
}
counter++;
} while (counter < iterations);
if (counter == iterations) {
delete[] vec_y;
return false;
}
delete[] vec_y;
return true;
}
| 25.476263
| 154
| 0.594975
|
acse-qq219
|
18f7d8b99ab0329b98f5b67678bf3508ce0fae11
| 2,153
|
cpp
|
C++
|
DawnBreakers/Source/Basic/Private/TestAttrModifyActor.cpp
|
954818696/FPSGame
|
bc82ceb1b56460a8e0e0c0e9a0da20fb5898e158
|
[
"MIT"
] | 1
|
2017-01-21T14:08:06.000Z
|
2017-01-21T14:08:06.000Z
|
DawnBreakers/Source/Basic/Private/TestAttrModifyActor.cpp
|
954818696/FPSGame
|
bc82ceb1b56460a8e0e0c0e9a0da20fb5898e158
|
[
"MIT"
] | null | null | null |
DawnBreakers/Source/Basic/Private/TestAttrModifyActor.cpp
|
954818696/FPSGame
|
bc82ceb1b56460a8e0e0c0e9a0da20fb5898e158
|
[
"MIT"
] | 2
|
2017-11-14T10:36:01.000Z
|
2020-07-13T08:52:08.000Z
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "TestAttrModifyActor.h"
//#if WITH_DEV_AUTOMATION_TESTS
// Sets default values
ATestAttrModifyActor::ATestAttrModifyActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
AttrModifyComp = CreateDefaultSubobject<UAttrModifyComponent>(TEXT("AttrModifyComponent"));
IntegerAttr = 1024;
FloatAttr = 128.128;
// Register.
TArray<FAttrRegisterItem> RegAttr;
FAttrRegisterItem IntegerReg, FloatReg;
IntegerReg.AttrName = TEXT("IntegerAttr");
IntegerReg.AttrVariableType = EAttrVariableType::Int;
IntegerReg.AttrDataPtr = &IntegerAttr;
IntegerReg.OriginalValue = IntegerAttr;
IntegerReg.HasReplicatedTag = false;
RegAttr.Add(IntegerReg);
FloatReg.AttrName = TEXT("FloatAttr");
FloatReg.AttrVariableType = EAttrVariableType::Float;
FloatReg.AttrDataPtr = &FloatAttr;
FloatReg.OriginalValue = FloatAttr;
IntegerReg.HasReplicatedTag = false;
RegAttr.Add(FloatReg);
AttrModifyComp->RegisterModifyAbleAttr(RegAttr);
}
UAttrModifyComponent* ATestAttrModifyActor::GetAttrModifyComponent_Implementation()
{
//UE_LOG(LogTemp, Error, TEXT("ATestAttrModifyActor GetAttrModifyComponent_Implementation"));
return AttrModifyComp;
}
TArray<AActor*> ATestAttrModifyActor::GetRelevantActors_Implementation()
{
TArray<AActor*> OutTargets;
OutTargets.Add(this);
//UE_LOG(LogTemp, Error, TEXT("ATestAttrModifyActor GetRelevantActors_Implementation"));
return OutTargets;
}
// Called when the game starts or when spawned
void ATestAttrModifyActor::BeginPlay()
{
Super::BeginPlay();
}
bool ATestAttrModifyActor::TestGetVariable()
{
UIntProperty* IntProp = FindField<UIntProperty>(GetClass(), TEXT("xubowen"));
if (IntProp)
{
int32* FoundInt = nullptr;
FoundInt = IntProp->GetPropertyValuePtr_InContainer(this);
if (FoundInt)
{
*FoundInt = 100;
return true;
}
}
return false;
}
// Called every frame
void ATestAttrModifyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
//#endif //WITH_DEV_AUTOMATION_TESTS
| 24.465909
| 115
| 0.775662
|
954818696
|
18fd5e51b9ace076e762342b477cefb7d7ac7c90
| 773
|
hpp
|
C++
|
src/data/Contour.hpp
|
haruneko/uzume_vocoder
|
63343118fd8d0dd8b7ebb92d98f023bfa6b9855e
|
[
"MIT"
] | 1
|
2020-04-28T06:29:25.000Z
|
2020-04-28T06:29:25.000Z
|
src/data/Contour.hpp
|
haruneko/uzume
|
63343118fd8d0dd8b7ebb92d98f023bfa6b9855e
|
[
"MIT"
] | null | null | null |
src/data/Contour.hpp
|
haruneko/uzume
|
63343118fd8d0dd8b7ebb92d98f023bfa6b9855e
|
[
"MIT"
] | null | null | null |
// Copyright 2020 Hal@shurabaP. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
#ifndef UZUME_VOCODER_CONTOUR_HPP
#define UZUME_VOCODER_CONTOUR_HPP
namespace uzume { namespace vocoder {
/**
* Contour represents array values in time axis.
*/
class Contour final {
public:
Contour() = delete;
Contour(double msLength, double msFramePeriod);
~Contour();
/**
* @param ms points the time.
* @return the value at ms.
*/
double at(double ms) const;
/**
* @return an entire length in milli seconds.
*/
double msLength() const;
const int length;
double *data;
const double msFramePeriod;
};
} }
#endif //UZUME_VOCODER_CONTOUR_HPP
| 20.891892
| 53
| 0.673997
|
haruneko
|
7a02887e5bd1b83b8cfe300891ddcd59959f23c1
| 8,735
|
cpp
|
C++
|
shell/explorer/trayitem.cpp
|
npocmaka/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 17
|
2020-11-13T13:42:52.000Z
|
2021-09-16T09:13:13.000Z
|
shell/explorer/trayitem.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 2
|
2020-10-19T08:02:06.000Z
|
2020-10-19T08:23:18.000Z
|
shell/explorer/trayitem.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 14
|
2020-11-14T09:43:20.000Z
|
2021-08-28T08:59:57.000Z
|
#include "cabinet.h"
#include "trayitem.h"
#include "shellapi.h"
#include "strsafe.h"
//
// CTrayItem members...
//
DWORD CTrayItem::_GetStateFlag(ICONSTATEFLAG sf)
{
DWORD dwFlag = 0;
switch (sf)
{
case TIF_HIDDEN:
dwFlag = NIS_HIDDEN;
break;
case TIF_DEMOTED:
dwFlag = NISP_DEMOTED;
break;
case TIF_STARTUPICON:
dwFlag = NISP_STARTUPICON;
break;
case TIF_SHARED:
dwFlag = NIS_SHAREDICON;
break;
case TIF_SHAREDICONSOURCE:
dwFlag = NISP_SHAREDICONSOURCE;
break;
case TIF_ONCEVISIBLE:
dwFlag = NISP_ONCEVISIBLE;
break;
case TIF_ITEMCLICKED:
dwFlag = NISP_ITEMCLICKED;
break;
case TIF_ITEMSAMEICONMODIFY:
dwFlag = NISP_ITEMSAMEICONMODIFY;
break;
}
ASSERT(dwFlag);
return dwFlag;
}
void CTrayItem::_SetIconState(ICONSTATEFLAG sf, BOOL bSet)
{
DWORD dwFlag = _GetStateFlag(sf);
ASSERT(dwFlag);
if (bSet)
dwState |= (dwFlag & 0xFFFFFFFF);
else
dwState &= ~dwFlag;
}
BOOL CTrayItem::_CheckIconState(ICONSTATEFLAG sf)
{
DWORD dwFlag = _GetStateFlag(sf);
ASSERT(dwFlag);
return ((dwState & dwFlag) != 0);
}
//
// CTrayItemManager members
//
CTrayItem * CTrayItemManager::GetItemData(INT_PTR i, BOOL byIndex, HWND hwndToolbar)
{
TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.lParam = 0;
tbbi.dwMask = TBIF_LPARAM;
if (byIndex)
tbbi.dwMask |= TBIF_BYINDEX;
SendMessage(hwndToolbar, TB_GETBUTTONINFO, i, (LPARAM)&tbbi);
return (CTrayItem *)(void *)tbbi.lParam;
}
INT_PTR CTrayItemManager::FindItemAssociatedWithGuid(GUID guidItemToCheck)
{
if (guidItemToCheck == GUID_NULL)
return -1;
for (INT_PTR i = GetItemCount()-1; i >= 0; i--)
{
CTrayItem * pti = GetItemDataByIndex(i);
if (pti && pti->IsGuidItemValid() && IsEqualGUID(pti->guidItem, guidItemToCheck))
return i;
}
return -1;
}
INT_PTR CTrayItemManager::FindItemAssociatedWithTimer(UINT_PTR uIconDemoteTimerID)
{
for (INT_PTR i = GetItemCount()-1; i >= 0; i--)
{
CTrayItem * pti = GetItemDataByIndex(i);
if (pti && pti->uIconDemoteTimerID == uIconDemoteTimerID)
return i;
}
return -1;
}
INT_PTR CTrayItemManager::FindItemAssociatedWithHwndUid(HWND hwnd, UINT uID)
{
for (INT_PTR i = GetItemCount() - 1; i >= 0; --i)
{
CTrayItem * pti = GetItemDataByIndex(i);
if (pti && (pti->hWnd == hwnd) && (pti->uID == uID))
{
return i;
}
}
return -1;
}
// Decides if there are as many "TNUP_AUTOMATIC" demoted items in the tray, above the
// threshold that the user has specified...
// Returns TRUE if there is any TNUP_DEMOTED item in the list...
BOOL CTrayItemManager::DemotedItemsPresent(int nMinDemotedItemsThreshold)
{
ASSERT(nMinDemotedItemsThreshold >= 0);
INT_PTR cIcons = 0;
INT_PTR nItems = SendMessage(m_hwndToolbar, TB_BUTTONCOUNT, 0, 0L);
for (INT_PTR i = 0; i < nItems; i++)
{
CTrayItem * pti = GetItemDataByIndex(i);
ASSERT(pti);
// If the item is set to ALWAYS HIDE, then it must be shown in demoted state...
if (pti->dwUserPref == TNUP_DEMOTED)
{
return TRUE;
}
// If the item is demoted, then only if there are enough demoted items must
// they all be shown in demoted state...
else if (pti->IsDemoted())
{
cIcons++;
if (cIcons >= nMinDemotedItemsThreshold)
return TRUE;
}
}
return FALSE;
}
// Works irrespective of whether AutoTray is enabled or not...
INT_PTR CTrayItemManager::_GetItemCountHelper(int nItemFlag, int nItemCountThreshold)
{
INT_PTR cIcons = 0;
INT_PTR nItems = SendMessage(m_hwndToolbar, TB_BUTTONCOUNT, 0, 0L);
switch(nItemFlag)
{
case GIC_ALL:
cIcons = nItems;
break;
case GIC_PROMOTED:
case GIC_DEMOTED:
for (INT_PTR i = nItems-1; i>= 0; i--)
{
CTrayItem * pti = GetItemDataByIndex(i);
if (nItemFlag == GIC_PROMOTED)
{
if (pti && !pti->IsDemoted() && !pti->IsHidden())
cIcons ++;
}
else
{
if (pti && pti->IsDemoted())
cIcons++;
}
if (nItemCountThreshold != -1 && cIcons >= nItemCountThreshold)
break;
}
break;
}
return cIcons;
}
void CTrayItemManager::SetTBBtnImage(INT_PTR iIndex, int iImage)
{
TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_IMAGE | TBIF_BYINDEX;
tbbi.iImage = iImage;
SendMessage(m_hwndToolbar, TB_SETBUTTONINFO, iIndex, (LPARAM)&tbbi);
}
int CTrayItemManager::GetTBBtnImage(INT_PTR iIndex, BOOL fByIndex /* = TRUE */)
{
TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_IMAGE;
if (fByIndex)
tbbi.dwMask |= TBIF_BYINDEX;
SendMessage(m_hwndToolbar, TB_GETBUTTONINFO, iIndex, (LPARAM)&tbbi);
return tbbi.iImage;
}
BOOL CTrayItemManager::SetTBBtnStateHelper(INT_PTR iIndex, BYTE fsState, BOOL_PTR bSet)
{
TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_STATE | TBIF_BYINDEX;
// Get the original state of the button
SendMessage(m_hwndToolbar, TB_GETBUTTONINFO, iIndex, (LPARAM)&tbbi);
// Or the new state to the original state
BYTE fsStateOld = tbbi.fsState;
if (bSet)
tbbi.fsState |= fsState;
else
tbbi.fsState &= ~fsState;
if (tbbi.fsState ^ fsStateOld)
{
SendMessage(m_hwndToolbar, TB_SETBUTTONINFO, iIndex, (LPARAM)&tbbi);
return TRUE;
}
return FALSE;
}
void CTrayItemManager::SetTBBtnText(INT_PTR iIndex, LPTSTR pszText)
{
TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_TEXT | TBIF_BYINDEX;
tbbi.pszText = pszText;
tbbi.cchText = -1;
SendMessage(m_hwndToolbar, TB_SETBUTTONINFO, iIndex, (LPARAM)&tbbi);
}
int CTrayItemManager::FindImageIndex(HICON hIcon, BOOL fSetAsSharedSource)
{
INT_PTR i;
INT_PTR iCount = GetItemCount();
for (i = 0; i < iCount; i++)
{
CTrayItem * pti = GetItemDataByIndex(i);
if (pti && pti->hIcon == hIcon)
{
// if we're supposed to mark this as a shared icon source and its not itself a shared icon
// target, mark it now. this is to allow us to recognize when the source icon changes and
// that we can know that we need to find other indicies and update them too.
if (fSetAsSharedSource && !pti->IsIconShared())
pti->SetSharedIconSource(TRUE);
return GetTBBtnImage(i);
}
}
return -1;
}
// TO DO szText can be replaced by pti->szIconText
BOOL CTrayItemManager::GetTrayItem(INT_PTR nIndex, CNotificationItem * pni, BOOL * pbStat)
{
if (nIndex < 0 || nIndex >= GetItemCount())
{
*pbStat = FALSE;
return FALSE;
}
ASSERT(pni->hIcon == NULL); // else we're going to leak it
TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_BYINDEX | TBIF_IMAGE | TBIF_LPARAM | TBIF_TEXT;
TCHAR szText[80] = {0};
tbbi.pszText = szText;
tbbi.cchText = ARRAYSIZE(szText);
if (SendMessage(m_hwndToolbar, TB_GETBUTTONINFO, nIndex, (LPARAM)&tbbi) != -1)
{
CTrayItem * pti = (CTrayItem *)tbbi.lParam;
// don't expose the NIS_HIDDEN icons
if (pti && !pti->IsHidden())
{
pni->hWnd = pti->hWnd;
pni->uID = pti->uID;
pni->hIcon = ImageList_GetIcon(m_himlIcons, tbbi.iImage, ILD_NORMAL);
pni->dwUserPref = pti->dwUserPref;
pni->SetExeName(pti->szExeName);
pni->SetIconText(szText);
memcpy(&(pni->guidItem), &(pti->guidItem), sizeof(pti->guidItem));
*pbStat = TRUE;
return TRUE;
}
}
*pbStat = FALSE;
return TRUE;
}
| 26.959877
| 103
| 0.565999
|
npocmaka
|
bb394459d8e4a09198056a1c696801744b958669
| 52
|
cpp
|
C++
|
inetsrv/msmq/src/migtool/mqdbodbc/stdh.cpp
|
npocmaka/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 17
|
2020-11-13T13:42:52.000Z
|
2021-09-16T09:13:13.000Z
|
inetsrv/msmq/src/migtool/mqdbodbc/stdh.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 2
|
2020-10-19T08:02:06.000Z
|
2020-10-19T08:23:18.000Z
|
inetsrv/msmq/src/migtool/mqdbodbc/stdh.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 14
|
2020-11-14T09:43:20.000Z
|
2021-08-28T08:59:57.000Z
|
//
// file: stdh.cpp
//
#include "dbsys.h"
| 7.428571
| 19
| 0.461538
|
npocmaka
|
bb4402880342b48323057c0d00c0b5329f3a1af3
| 605
|
cpp
|
C++
|
tests/BinaryTreeRightSideViewTest.cpp
|
yanzhe-chen/LeetCode
|
d82f0b9721ea613ab216c78e7286671d0e9e4187
|
[
"MIT"
] | 43
|
2015-10-10T12:59:52.000Z
|
2018-07-11T18:07:00.000Z
|
tests/BinaryTreeRightSideViewTest.cpp
|
yanzhe-chen/LeetCode
|
d82f0b9721ea613ab216c78e7286671d0e9e4187
|
[
"MIT"
] | null | null | null |
tests/BinaryTreeRightSideViewTest.cpp
|
yanzhe-chen/LeetCode
|
d82f0b9721ea613ab216c78e7286671d0e9e4187
|
[
"MIT"
] | 11
|
2015-10-10T14:41:11.000Z
|
2018-07-28T06:03:16.000Z
|
#include "catch.hpp"
#include "BinaryTreeRightSideView.hpp"
TEST_CASE("Binary Tree Right Side View") {
BinaryTreeRightSideView s;
TreeNode *root = nullptr;
SECTION("Sample test") {
TreeNode *_5 = new TreeNode(5);
TreeNode *_4 = new TreeNode(4);
TreeNode *_2 = new TreeNode(2, nullptr, _5);
TreeNode *_3 = new TreeNode(3, nullptr, _4);
TreeNode *_1 = new TreeNode(1, _2, _3);
root = _1;
vector<int> expected{1, 3, 4};
vector<int> result = s.rightSideView(root);
REQUIRE(result == expected);
}
tree_free(root);
}
| 28.809524
| 52
| 0.603306
|
yanzhe-chen
|
bb4455886d8dbff0625ae111afb488763a801462
| 2,012
|
cpp
|
C++
|
TouchGFX/generated/fonts/src/Table_trebucbd_80_4bpp.cpp
|
timagr615/ILI9488_touchGFX
|
5d3695f09a440edefe3d0ddf727e08c7fd5e5bd2
|
[
"MIT"
] | null | null | null |
TouchGFX/generated/fonts/src/Table_trebucbd_80_4bpp.cpp
|
timagr615/ILI9488_touchGFX
|
5d3695f09a440edefe3d0ddf727e08c7fd5e5bd2
|
[
"MIT"
] | null | null | null |
TouchGFX/generated/fonts/src/Table_trebucbd_80_4bpp.cpp
|
timagr615/ILI9488_touchGFX
|
5d3695f09a440edefe3d0ddf727e08c7fd5e5bd2
|
[
"MIT"
] | null | null | null |
// Autogenerated, do not edit
#include <fonts/GeneratedFont.hpp>
FONT_TABLE_LOCATION_FLASH_PRAGMA
KEEP extern const touchgfx::GlyphNode glyphs_trebucbd_80_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE = {
{ 0, 0x0020, 0, 0, 0, 0, 24, 0, 1, 0x00 },
{ 0, 0x003F, 29, 60, 59, 4, 35, 0, 0, 0x00 },
{ 900, 0x0041, 51, 59, 59, 0, 51, 1, 1, 0x00 },
{ 2434, 0x0052, 45, 58, 58, 5, 49, 0, 0, 0x00 },
{ 3768, 0x0053, 35, 60, 59, 3, 41, 0, 0, 0x00 },
{ 4848, 0x0061, 39, 44, 43, 2, 43, 2, 1, 0x00 },
{ 5728, 0x0063, 37, 44, 43, 2, 41, 0, 0, 0x00 },
{ 6564, 0x0065, 42, 44, 43, 2, 46, 0, 0, 0x00 },
{ 7488, 0x0069, 17, 59, 59, 2, 24, 0, 0, 0x00 },
{ 8019, 0x006C, 16, 61, 60, 6, 24, 0, 0, 0x00 },
{ 8507, 0x006E, 37, 43, 43, 5, 47, 0, 0, 0x00 },
{ 9324, 0x0072, 29, 43, 43, 5, 34, 0, 0, 0x00 },
{ 9969, 0x0079, 42, 59, 42, 0, 43, 3, 1, 0x00 },
{ 11208, 0x007A, 38, 42, 42, 2, 42, 0, 0, 0x00 }
};
// trebucbd_80_4bpp
FONT_TABLE_LOCATION_FLASH_PRAGMA
KEEP extern const touchgfx::GlyphNode glyphs_trebucbd_80_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE;
FONT_GLYPH_LOCATION_FLASH_PRAGMA
KEEP extern const uint8_t unicodes_trebucbd_80_4bpp_0[] FONT_GLYPH_LOCATION_FLASH_ATTRIBUTE;
FONT_SEARCHTABLE_LOCATION_FLASH_PRAGMA
KEEP extern const uint8_t* const unicodes_trebucbd_80_4bpp[] FONT_SEARCHTABLE_LOCATION_FLASH_ATTRIBUTE = {
unicodes_trebucbd_80_4bpp_0
};
FONT_KERNING_LOCATION_FLASH_PRAGMA
KEEP extern const touchgfx::KerningNode kerning_trebucbd_80_4bpp[] FONT_KERNING_LOCATION_FLASH_ATTRIBUTE;
touchgfx::GeneratedFont& getFont_trebucbd_80_4bpp();
touchgfx::GeneratedFont& getFont_trebucbd_80_4bpp()
{
static touchgfx::GeneratedFont trebucbd_80_4bpp(glyphs_trebucbd_80_4bpp, 14, 80, 17, 4, 1, 0, 1, unicodes_trebucbd_80_4bpp, kerning_trebucbd_80_4bpp, 63, 0, 0, 0);
return trebucbd_80_4bpp;
}
| 49.073171
| 167
| 0.644135
|
timagr615
|
bb454db385d80d86cacdcbb9cae15acb8695970e
| 5,907
|
hpp
|
C++
|
src/module/sps_module.hpp
|
byrcoder/sps
|
20c910f6f3a2784f7bbab316d8a4049076650286
|
[
"MIT"
] | 8
|
2021-06-13T18:15:27.000Z
|
2022-02-05T07:39:58.000Z
|
src/module/sps_module.hpp
|
byrcoder/sps
|
20c910f6f3a2784f7bbab316d8a4049076650286
|
[
"MIT"
] | 4
|
2021-06-12T20:06:44.000Z
|
2022-02-05T08:22:08.000Z
|
src/module/sps_module.hpp
|
byrcoder/sps
|
20c910f6f3a2784f7bbab316d8a4049076650286
|
[
"MIT"
] | 1
|
2022-02-21T00:58:31.000Z
|
2022-02-21T00:58:31.000Z
|
/*****************************************************************************
MIT License
Copyright (c) 2021 byrcoder
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.
*****************************************************************************/
/**
* module X consists of followings:
* 1. Conf${X}Ctx reload context
* 2. ${X}Module
* a. create_conf required, impl Conf${X} context
* b. pre_conf optional, do something after create_conf and before init_conf default nothing
* c. post_sub_module optional, do something after a submodule post_conf.
* d. post_conf optional, do something after the init_conf success
* e. install optional, do something startup such as starting a server
* 3. ${X}ModuleFactory how ${X}Module create work as reflection
*
* module layer show such as
* ++++++++++++++++
* + root options +
* ++++++++++++++++ \
* / | \
* / | \
* ++++++++++++ ++++++++++++++ \ +++++++++++++++++++
* + upstream + + http/rtmp + + host (global) +
* ++++++++++++ ++++++++++++++ ++++++++++++++++++
* | | /
* | | /
* ++++++++++ ++++++++ /
* + server + + host +
* ++++++++++ ++++++++
* |
* |
* ++++++++++
* + stream +
* ++++++++++
*
*/
#ifndef SPS_CONFIG_MODULE_HPP
#define SPS_CONFIG_MODULE_HPP
#include <cstdio>
#include <cctype>
#include <cstddef>
#include <algorithm>
#include <list>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <sps_module_opt.hpp>
#include <sps_log.hpp>
namespace sps {
struct ConfCtx {
};
typedef std::shared_ptr<ConfCtx> PConfCtx;
class IModule;
typedef std::shared_ptr<IModule> PIModule;
typedef std::string ModuleType;
class IModule : public std::enable_shared_from_this<IModule> {
public:
IModule(ModuleType module_type, std::string module_name,
const ConfigOption* opts, PIModule parent);
virtual ~IModule() = default;
public:
virtual PConfCtx create_conf() = 0;
public:
// every thing work in
virtual error_t install();
public:
virtual error_t pre_conf();
virtual error_t post_conf();
virtual error_t post_sub_module(PIModule sub);
virtual error_t merge(PIModule& module);
error_t init_conf(PIReader rd);
error_t parse(const std::string &line, std::string &cmd, std::string &arg,
LineType <);
public:
bool is_module(const std::string& name);
private:
error_t set_default();
public:
ModuleType module_type;
std::string module_name;
PConfCtx conf;
const ConfigOption* opts;
PIModule parent;
public:
std::map<ModuleType, std::list<PIModule> > subs;
};
class IModuleFactory {
public:
virtual ~IModuleFactory() = default;
virtual PIModule create(const std::string& module, const std::string& arg,
PIModule parent) = 0;
public:
std::string module;
};
typedef std::shared_ptr<IModuleFactory> PIModuleFactory;
class ModuleFactoryRegister :
public KeyRegisters<std::string, PIModuleFactory> {
public:
PIModule create(const std::string& name, const std::string& arg,
PIModule parent);
private:
std::map<std::string, PIModuleFactory> factories;
};
#define MODULE_CONSTRUCT(N, opt) \
N##Module(std::string module_type, std::string module_name, \
PIModule parent): \
IModule(std::move(module_type), std::move(module_name), \
opt, std::move(parent)) { \
}
#define MODULE_CREATE_CTX(N) \
PConfCtx create_conf() override { \
return std::make_shared<N##ConfCtx>(); \
}
#define MODULE_FACTORY(N) \
class N##ModuleFactory : public IModuleFactory { \
public: \
N##ModuleFactory() { \
module = #N; \
std::transform(module.begin(), module.end(), module.begin(), ::tolower); \
} \
public: \
PIModule create(const std::string& module, \
const std::string& arg, PIModule parent) { \
sp_debug("===================== %s create %s module:%s, " \
"arg:%s=================================", \
parent ? parent->module_type.c_str() : "root", \
#N, module.c_str(), arg.c_str()); \
return std::make_shared<N##Module> (module, arg, parent); \
} \
};
} // namespace sps
#endif // SPS_CONFIG_MODULE_HPP
| 32.103261
| 96
| 0.555104
|
byrcoder
|
bb46c9e2d9bb0d25f35777c8508455ea9cc91693
| 495
|
hxx
|
C++
|
include/ui.hxx
|
gviegas/mad-meat-rampage
|
2edd70ab4a54fda344f410c498896077f0e994e2
|
[
"MIT"
] | null | null | null |
include/ui.hxx
|
gviegas/mad-meat-rampage
|
2edd70ab4a54fda344f410c498896077f0e994e2
|
[
"MIT"
] | null | null | null |
include/ui.hxx
|
gviegas/mad-meat-rampage
|
2edd70ab4a54fda344f410c498896077f0e994e2
|
[
"MIT"
] | null | null | null |
/*
* Created by Gustavo Viegas (2016/11)
*/
#ifndef UI_HXX
#define UI_HXX
#include <SFML/Graphics.hpp>
#include <vector>
class UI {
public:
UI(int digits = 3);
~UI();
void loadConf(const std::string& fileName);
void update(int score, double updateInterval);
void draw(sf::RenderWindow* screen);
private:
sf::Texture m_labelTex;
sf::Texture m_numbersTex;
sf::Sprite m_label;
std::vector<sf::Sprite> m_numbers;
int m_digits;
int m_score;
};
#endif
| 17.068966
| 50
| 0.662626
|
gviegas
|
bb4925305a58ee6e569b836d42b887e5429ec2f2
| 16,621
|
cpp
|
C++
|
ExeExplorer/CodeCommon.cpp
|
Fiskmans/FiskDisassembler
|
0ede8f0ebf307bf45730e36258f6718312d40490
|
[
"MIT"
] | null | null | null |
ExeExplorer/CodeCommon.cpp
|
Fiskmans/FiskDisassembler
|
0ede8f0ebf307bf45730e36258f6718312d40490
|
[
"MIT"
] | null | null | null |
ExeExplorer/CodeCommon.cpp
|
Fiskmans/FiskDisassembler
|
0ede8f0ebf307bf45730e36258f6718312d40490
|
[
"MIT"
] | null | null | null |
#include "CodeCommon.h"
#include "ConsoleHelp.h"
#include <algorithm>
#include <map>
namespace globals {
std::vector<BranchType> globalFunctions;
std::vector<BranchType> globalBranches;
const size_t globalLocationColumn = 50;
size_t globalImageBase = 0;
} // globals
std::string
GenerateName(
std::string aName,
std::string aSuffix)
{
static size_t counter = 0;
return aName + std::to_string(++counter) + aSuffix;
}
std::string
GetOrGenerateFunctionName(
size_t aAddress,
std::string aSuffix)
{
static std::map<size_t, std::string> names;
if (names.count(aAddress) == 0)
{
names[aAddress] = GenerateName("function_", aSuffix);
for (BranchType& b : globals::globalFunctions)
{
if (b.myAddress == aAddress)
{
names[aAddress] = b.myName;
}
}
}
return names[aAddress];
}
std::string
GetOrGenerateLocationName(
size_t aAddress,
std::string aSuffix)
{
static std::map<size_t, std::string> names;
if (names.count(aAddress) == 0)
{
names[aAddress] = GenerateName("location_", aSuffix);
}
return names[aAddress];
}
void
AddFunction(
BranchType aFunction)
{
globals::globalFunctions.insert(
std::upper_bound(
globals::globalFunctions.begin(),
globals::globalFunctions.end(),
aFunction,
[](const BranchType& aA, const BranchType& aB) { return aA.myAddress < aB.myAddress; }),
aFunction);
}
void
AddFunction(
size_t aAddress,
std::string aSuffix)
{
for (BranchType& b : globals::globalFunctions)
if (b.myAddress == aAddress)
return;
AddFunction({GetOrGenerateFunctionName(aAddress, aSuffix), aAddress, false});
}
void
AddBranch(
size_t aAddress,
std::string aSuffix)
{
for (BranchType& b : globals::globalBranches)
if (b.myAddress == aAddress)
return;
BranchType b{GetOrGenerateLocationName(aAddress, aSuffix), aAddress, false};
globals::globalBranches.insert(
std::upper_bound(
globals::globalBranches.begin(),
globals::globalBranches.end(),
b,
[](const BranchType& aA, const BranchType& aB) { return aA.myAddress < aB.myAddress; }),
b);
}
void
PrintFunction(
const std::string& aName)
{
PRINTF_LIGHTBLUE("%s", aName.c_str());
}
void
PrintFunction(
size_t aAddress)
{
PrintFunction(GetOrGenerateFunctionName(aAddress));
}
void
PrintLocation(
const std::string& aName)
{
PRINTF_BLUE("%s", aName.c_str());
}
void
PrintLocation(
size_t aAddress)
{
PrintLocation(GetOrGenerateLocationName(aAddress));
}
ModRMByte
ParseModRM(
unsigned char aByte,
REXState aREX)
{
ModRMByte ret;
ret.mod = (aByte & 0b11000000) >> 6;
ret.reg = (aByte & 0b00111000) >> 3;
ret.rm = (aByte & 0b00000111);
if (aREX.r)
ret.reg |= 0b1000;
if (aREX.b)
ret.rm |= 0b1000;
return ret;
}
SIBByte
ParseSIB(
unsigned char aByte,
REXState aREX)
{
SIBByte ret;
ret.scale = (aByte & 0b11000000) >> 6;
ret.index = (aByte & 0b00111000) >> 3;
ret.base = (aByte & 0b00000111);
if (aREX.x)
ret.index |= 0b1000;
if (aREX.b)
ret.base |= 0b1000;
return ret;
}
std::string
RegMemSIB(
ModRMByte aModRM,
SIBByte aSIB)
{
std::string out = "[";
switch (aSIB.index)
{
case 0b000:
out += (std::to_string(1 << aSIB.scale)) + " * rAX + ";
break;
case 0b001:
out += (std::to_string(1 << aSIB.scale)) + " * rCX + ";
break;
case 0b010:
out += (std::to_string(1 << aSIB.scale)) + " * rDX + ";
break;
case 0b011:
out += (std::to_string(1 << aSIB.scale)) + " * rBX + ";
break;
case 0b100:
break;
case 0b101:
out += (std::to_string(1 << aSIB.scale)) + " * rBP + ";
break;
case 0b110:
out += (std::to_string(1 << aSIB.scale)) + " * rSI + ";
break;
case 0b111:
out += (std::to_string(1 << aSIB.scale)) + " * rDI + ";
break;
}
switch (aSIB.base)
{
case 0b000:
out += "rAX + ";
break;
case 0b001:
out += "rCX + ";
break;
case 0b010:
out += "rDX + ";
break;
case 0b011:
out += "rBX + ";
break;
case 0b100:
out += "rSP + ";
break;
case 0b101:
if (aModRM.mod != 0b00)
{
out += "rBP + ";
}
break;
case 0b110:
out += "rSI + ";
break;
case 0b111:
out += "rDI + ";
break;
}
out += "offset]";
return out;
}
std::string
RegMem(
ModRMByte aModRM,
REXState aREX,
RegisterSize aRegisterSize,
bool aSelector,
const std::vector<unsigned char>& aImage,
size_t aNextByte,
uint32_t& aOutExtraConsumed,
int32_t* aOutMarkerAt)
{
aOutExtraConsumed = 0;
if (aSelector)
{
switch (aModRM.reg)
{
case 0b0000:
return "[rAX]";
case 0b0001:
return "[rCX]";
case 0b0010:
return "[rDX]";
case 0b0011:
return "[rBX]";
case 0b0100:
return "[rSP]";
case 0b0101:
return "[rBP]";
case 0b0110:
return "[rSI]";
case 0b0111:
return "[rDI]";
case 0b1000:
return "[r8]";
case 0b1001:
return "[r9]";
case 0b1010:
return "[r10]";
case 0b1011:
return "[r11]";
case 0b1100:
return "[r12]";
case 0b1101:
return "[r13]";
case 0b1110:
return "[r14]";
case 0b1111:
return "[r15]";
}
return "[unkwon reg field]";
}
switch (aModRM.mod)
{
case 0b11:
switch (aModRM.rm)
{
case 0b0000:
return "[rAX]";
case 0b0001:
return "[rCX]";
case 0b0010:
return "[rDX]";
case 0b0011:
return "[rBX]";
case 0b0100:
return "[rSP]";
case 0b0101:
return "[rBP]";
case 0b0110:
return "[rSI]";
case 0b0111:
return "[rDI]";
case 0b1000:
return "[r8]";
case 0b1001:
return "[r9]";
case 0b1010:
return "[r10]";
case 0b1011:
return "[r11]";
case 0b1100:
return "[r12]";
case 0b1101:
return "[r13]";
case 0b1110:
return "[r14]";
case 0b1111:
return "[r15]";
}
break;
case 0b01: {
int8_t offset;
memcpy(&offset, aImage.data() + aNextByte, sizeof(offset));
aOutExtraConsumed = 1;
switch (aModRM.rm)
{
case 0b000:
return "[rAX" + StringSignedHex(offset) + "]";
case 0b001:
return "[rCX" + StringSignedHex(offset) + "]";
case 0b010:
return "[rDX" + StringSignedHex(offset) + "]";
case 0b011:
return "[rBX" + StringSignedHex(offset) + "]";
case 0b100: {
SIBByte sib = ParseSIB(aImage[aNextByte], aREX);
std::string out = "[";
switch (sib.base)
{
case 0b000:
out += "rAX";
break;
case 0b001:
out += "rCX";
break;
case 0b010:
out += "rDX";
break;
case 0b011:
out += "rBX";
break;
case 0b100:
out += "rSP";
break;
case 0b101:
out += "rBP";
break;
case 0b110:
out += "rSI";
break;
case 0b111:
out += "rDI";
break;
}
int8_t offsetWithSib;
memcpy(&offsetWithSib, aImage.data() + aNextByte + 1, sizeof(offsetWithSib));
out += StringSignedHex(offset) + "]";
aOutExtraConsumed = 2;
return out;
}
case 0b101:
return "[rBP" + StringSignedHex(offset) + "]";
case 0b110: {
return "[rSI" + StringSignedHex(offset) + "]";
}
case 0b111:
return "[rDI" + StringSignedHex(offset) + "]";
case 0b1000:
return "[r8" + StringSignedHex(offset) + "]";
case 0b1001:
return "[r9" + StringSignedHex(offset) + "]";
case 0b1010:
return "[r10" + StringSignedHex(offset) + "]";
case 0b1011:
return "[r11" + StringSignedHex(offset) + "]";
case 0b1100:
return "[r12" + StringSignedHex(offset) + "]";
case 0b1101:
return "[r13" + StringSignedHex(offset) + "]";
case 0b1110:
return "[r14" + StringSignedHex(offset) + "]";
case 0b1111:
return "[r15" + StringSignedHex(offset) + "]";
}
break;
}
case 0b10: {
int32_t offset;
memcpy(&offset, aImage.data() + aNextByte, sizeof(offset));
aOutExtraConsumed = 4;
switch (aModRM.rm)
{
case 0b000:
return "[rAX" + StringSignedHex(offset) + "]";
case 0b001:
return "[rCX" + StringSignedHex(offset) + "]";
case 0b010:
return "[rDX" + StringSignedHex(offset) + "]";
case 0b011:
return "[rBX" + StringSignedHex(offset) + "]";
case 0b100: {
SIBByte sib = ParseSIB(aImage[aNextByte], aREX);
std::string out = "[";
switch (sib.base)
{
case 0b000:
out += "rAX";
break;
case 0b001:
out += "rCX";
break;
case 0b010:
out += "rDX";
break;
case 0b011:
out += "rBX";
break;
case 0b100:
out += "rSP";
break;
case 0b101:
out += "rBP";
break;
case 0b110:
out += "rSI";
break;
case 0b111:
out += "rDI";
break;
}
int32_t offsetWithSib;
memcpy(&offsetWithSib, aImage.data() + aNextByte + 1, sizeof(offsetWithSib));
out += StringSignedHex(offset) + "]";
aOutExtraConsumed = 5;
return out;
}
case 0b101:
return "[rBP" + StringSignedHex(offset) + "]";
case 0b110:
return "[rSI" + StringSignedHex(offset) + "]";
case 0b111:
return "[rDI" + StringSignedHex(offset) + "]";
case 0b1000:
return "[r8" + StringSignedHex(offset) + "]";
case 0b1001:
return "[r9" + StringSignedHex(offset) + "]";
case 0b1010:
return "[r10" + StringSignedHex(offset) + "]";
case 0b1011:
return "[r11" + StringSignedHex(offset) + "]";
case 0b1100:
return "[r12" + StringSignedHex(offset) + "]";
case 0b1101:
return "[r13" + StringSignedHex(offset) + "]";
case 0b1110:
return "[r14" + StringSignedHex(offset) + "]";
case 0b1111:
return "[r15" + StringSignedHex(offset) + "]";
}
break;
}
case 0b00:
switch (aModRM.rm)
{
case 0b000:
return "[rAX]";
case 0b001:
return "[rCX]";
case 0b010:
return "[rDX]";
case 0b011:
return "[rBX]";
case 0b100: {
aOutExtraConsumed = 1;
SIBByte sib = ParseSIB(aImage[aNextByte], aREX);
return RegMemSIB(aModRM, sib);
}
case 0b101: {
std::string out = "[rIP ";
int32_t offset;
memcpy(&offset, aImage.data() + aNextByte, sizeof(offset));
aOutExtraConsumed = sizeof(offset);
out += StringSignedHex(offset);
if (aOutMarkerAt)
{
*aOutMarkerAt = offset;
}
return out + "]";
}
case 0b110:
return "[rSI]";
case 0b111:
return "[rDI]";
case 0b1000:
return "[r8]";
case 0b1001:
return "[r9]";
case 0b1010:
return "[r10]";
case 0b1011:
return "[r11]";
case 0b1100:
return "[r12]";
case 0b1101:
return "[r13]";
case 0b1110:
return "[r14]";
case 0b1111:
return "[r15]";
default:
break;
}
break;
}
return "[Unparsed]";
}
size_t
Operands(
OperandType aFirst,
OperandType aSecond,
REXState aREX,
ModRMByte aModRMByte,
const std::vector<unsigned char>& aImage,
size_t aNextByte,
bool aIsLEA,
uint64_t* aOutPointOfInterestData)
{
size_t end = aNextByte;
int32_t pointOfInterest = 0;
ReadWrite pointOfInterestType = ReadWrite::READ;
uint32_t pointOfInterestSize = 1;
uint32_t extra;
switch (aFirst)
{
case OperandType::IMM8:
case OperandType::IMM16:
case OperandType::IMM32:
case OperandType::IMM64:
printf("imm as first operand, code corrupted");
return -1;
case OperandType::REG8:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_8BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REG16:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_16BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REG32:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_32BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REG64:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_64BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REGMEM8:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_8BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 1;
pointOfInterestType = ReadWrite::WRITE;
break;
case OperandType::REGMEM16:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_16BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 2;
pointOfInterestType = ReadWrite::WRITE;
break;
case OperandType::REGMEM32:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_32BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 4;
pointOfInterestType = ReadWrite::WRITE;
break;
case OperandType::REGMEM64:
printf("%s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_64BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 8;
pointOfInterestType = ReadWrite::WRITE;
break;
}
switch (aSecond)
{
case OperandType::IMM8: {
uint8_t imm;
memcpy(&imm, aImage.data() + end, sizeof(imm));
printf(", ");
PRINTF_GREEN("$0x%02x", imm);
end += sizeof(imm);
}
break;
case OperandType::IMM16: {
uint16_t imm;
memcpy(&imm, aImage.data() + end, sizeof(imm));
printf(", ");
PRINTF_GREEN("$0x%04x", imm);
end += sizeof(imm);
}
break;
case OperandType::IMM32: {
uint32_t imm;
memcpy(&imm, aImage.data() + end, sizeof(imm));
printf(", ");
PRINTF_GREEN("$0x%08x", imm);
end += sizeof(imm);
}
break;
case OperandType::IMM64: {
uint64_t imm;
memcpy(&imm, aImage.data() + end, sizeof(imm));
printf(", ");
PRINTF_GREEN("$0x%016I64x", imm);
end += sizeof(imm);
}
break;
case OperandType::REG8:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_8BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REG16:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_16BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REG32:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_32BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REG64:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_64BIT, true, aImage, end, extra).c_str());
break;
case OperandType::REGMEM8:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_8BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 1;
pointOfInterestType = ReadWrite::READ;
break;
case OperandType::REGMEM16:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_16BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 2;
pointOfInterestType = ReadWrite::READ;
break;
case OperandType::REGMEM32:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_32BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 4;
pointOfInterestType = ReadWrite::READ;
break;
case OperandType::REGMEM64:
printf(", %s", RegMem(aModRMByte, aREX, RegisterSize::REGISTER_64BIT, false, aImage, end, extra, &pointOfInterest).c_str());
end += extra;
pointOfInterestSize = 8;
pointOfInterestType = ReadWrite::READ;
break;
case OperandType::NONE:
pointOfInterestType = ReadWrite::READ;
break;
default:
break;
}
if (pointOfInterest != 0)
{
size_t location = pointOfInterest + end;
SetColumn(globals::globalLocationColumn);
if (aIsLEA)
{
PRINTF_GREEN("0x%08zx", location);
}
else
{
printf("0x%08zx", location);
}
switch (pointOfInterestType)
{
case ReadWrite::READ:
if (aIsLEA)
printf(" LOAD ADDR");
else
printf(" LOAD");
{
switch (pointOfInterestSize)
{
case 1: {
uint8_t data;
memcpy(&data, aImage.data() + location, sizeof(data));
if (aIsLEA)
{
printf(" 0x%02x", data);
}
else
{
PRINTF_GREEN(" 0x%02x", data);
}
if (aOutPointOfInterestData)
*aOutPointOfInterestData = data;
}
break;
case 2: {
uint16_t data;
memcpy(&data, aImage.data() + location, sizeof(data));
if (aIsLEA)
{
printf(" 0x%04x", data);
}
else
{
PRINTF_GREEN(" 0x%04x", data);
}
if (aOutPointOfInterestData)
*aOutPointOfInterestData = data;
}
break;
case 4: {
uint32_t data;
memcpy(&data, aImage.data() + location, sizeof(data));
if (aIsLEA)
{
printf(" 0x%08x", data);
}
else
{
PRINTF_GREEN(" 0x%08x", data);
}
if (aOutPointOfInterestData)
*aOutPointOfInterestData = data;
}
break;
case 8: {
uint64_t data;
memcpy(&data, aImage.data() + location, sizeof(data));
if (aIsLEA)
{
printf(" 0x%016I64x", data);
}
else
{
PRINTF_GREEN(" 0x%016I64x", data);
}
if (aOutPointOfInterestData)
*aOutPointOfInterestData = data;
}
break;
}
}
break;
case ReadWrite::WRITE:
printf(" STORE");
break;
}
}
return end;
}
| 21.336329
| 126
| 0.621082
|
Fiskmans
|
bb4da8a8a526dee82519216963ea175634ed8763
| 5,800
|
cpp
|
C++
|
high_level_controller/examples/cpp/eight_zero/src/main.cpp
|
Durrrr95/cpm_lab
|
e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67
|
[
"MIT"
] | 9
|
2020-06-24T11:22:15.000Z
|
2022-01-13T14:14:13.000Z
|
high_level_controller/examples/cpp/eight_zero/src/main.cpp
|
Durrrr95/cpm_lab
|
e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67
|
[
"MIT"
] | 1
|
2021-05-10T13:48:04.000Z
|
2021-05-10T13:48:04.000Z
|
high_level_controller/examples/cpp/eight_zero/src/main.cpp
|
Durrrr95/cpm_lab
|
e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67
|
[
"MIT"
] | 2
|
2021-11-08T11:59:29.000Z
|
2022-03-15T13:50:54.000Z
|
#include "cpm/Logging.hpp"
#include "cpm/CommandLineReader.hpp"
#include "cpm/init.hpp"
#include "cpm/HLCCommunicator.hpp"
#include "cpm/Writer.hpp"
#include "VehicleCommandTrajectory.hpp"
#include "Eight.hpp"
#include <iostream>
#include <memory>
#include <stdlib.h>
using std::vector;
//Description for bash files
/**
* \defgroup eight_zero_files Additional Files
* \ingroup eight_zero
*/
/**
* \page eight_zero_files_page Additional Files for Eight Zero
* \subpage e_z_build <br>
* \subpage e_z_run <br>
* \ingroup eight_zero_files
*/
/**
* \page e_z_build build.bash
* \brief Build script for eight_zero
*/
/**
* \page e_z_run run.bash
* \brief Run script for eight_zero
*/
/**
* \brief Main function of the eight_zero scenario
* \param argc Command line param
* \param argv Command line param
* \ingroup eight_zero
*/
int main(int argc, char *argv[])
{
const std::string node_id = "eight_zero";
cpm::init(argc, argv);
cpm::Logging::Instance().set_id(node_id);
const std::vector<int> vehicle_ids_int = cpm::cmd_parameter_ints("vehicle_ids", {4}, argc, argv);
std::vector<uint8_t> vehicle_ids;
for(auto i:vehicle_ids_int)
{
assert(i>0);
assert(i<255);
vehicle_ids.push_back(i);
}
assert(vehicle_ids.size() > 0);
uint8_t vehicle_id = vehicle_ids.at(0);
// Ease-of-life class to communicate with the middleware.
// This participant should only communicate on this system, so its messages are not directly sent to the vehicles.
// Instead we communicate with the middleware, and the middleware relays these messages to the vehicle.
// These settings are saved in the Quality of Service (QoS) xml-file and are identical to the ones the middleware uses.
// One QoS file can define multiple profiles, which is why we need to specify that we want to use the
// LocalCommunicationProfile, from the MatlabLibrary.
HLCCommunicator hlc_communicator(
vehicle_id
);
// Writer for sending trajectory commands
cpm::Writer<VehicleCommandTrajectory> writer_vehicleCommandTrajectory(
hlc_communicator.getLocalParticipant()->get_participant(),
"vehicleCommandTrajectory");
// Initialize 8-Trajectory
Eight eight;
// This variabel tracks the reference state of the time,
// it is incremented as time passes. It refers to the first trajectory point the vehicle will drive to.
uint64_t reference_trajectory_time = 0;
// This variable refers to the last currently planned trajectory point the vehicle will drive to. --TODO
uint64_t trajectory_duration = 0;
uint64_t t_now = 0;
// Saves the current trajectory which is to be sent
vector<TrajectoryPoint> trajectory_points;
// The code inside the onEachTimestep method is executed each timestep.
// Here we assume that we send trajectories every 200ms
// This means we need to manually set the middleware_period_ms parameter in the LCC to 200ms.
// Commands must be sent to the vehicle regularly, more than 2x per second.
// Otherwise it is assumed that the connection is lost and the vehicle stops.
const uint64_t dt_nanos = 200000000ull; // 400 milliseconds == 400000000 nanoseconds
hlc_communicator.onFirstTimestep([&](VehicleStateList vehicle_state_list)
{
// Initial time used for trajectory generation
reference_trajectory_time = vehicle_state_list.t_now() + 2000000000ull;
});
// The code inside the cpm::Timer is executed every 400 milliseconds.
// Commands must be sent to the vehicle regularly, more than 2x per second.
// Otherwise it is assumed that the connection is lost and the vehicle stops.
hlc_communicator.onEachTimestep([&](VehicleStateList vehicle_state_list)
{
// Check if middleware_period_ms was set correctly, as described above
// If not, write a message to log
if( vehicle_state_list.period_ms()*1000000ull != dt_nanos ){
cpm::Logging::Instance().write(1,
"Please set middleware_period_ms to 200ms");
return;
}
t_now = vehicle_state_list.t_now();
// Append new points to the trajectory
while (reference_trajectory_time + trajectory_duration < t_now + 4000000000ull){
TrajectoryPoint trajectory_point = eight.get_trajectoryPoint();
trajectory_point.t().nanoseconds(reference_trajectory_time + trajectory_duration);
trajectory_points.push_back(trajectory_point);
trajectory_duration += eight.get_segment_duration();
eight.move_forward(); //TODO Fitting with initial point?
}
// Delete outdated points, i.e., remove first point if second one lies in past, too,
while (!trajectory_points.empty() && trajectory_points.at(1).t().nanoseconds() < t_now){
uint64_t delta_t = trajectory_points.at(1).t().nanoseconds() - trajectory_points.at(0).t().nanoseconds();
trajectory_duration -= delta_t;
reference_trajectory_time += delta_t;
trajectory_points.erase(trajectory_points.begin());
}
// Send the current trajectory
rti::core::vector<TrajectoryPoint> rti_trajectory_points(trajectory_points);
VehicleCommandTrajectory vehicle_command_trajectory;
vehicle_command_trajectory.vehicle_id(vehicle_id);
vehicle_command_trajectory.trajectory_points(rti_trajectory_points);
vehicle_command_trajectory.header().create_stamp().nanoseconds(t_now);
vehicle_command_trajectory.header().valid_after_stamp().nanoseconds(t_now + 1000000000ull);
writer_vehicleCommandTrajectory.write(vehicle_command_trajectory);
});
hlc_communicator.start();
}
| 37.908497
| 123
| 0.704483
|
Durrrr95
|
bb4f71d24ca575595cdbc23da001e9b2c458d520
| 428
|
hpp
|
C++
|
src/libs/cosinesimilarity.hpp
|
ronaldpereira/collaborative-filtering-movie-recommendation
|
0ecdd5f531a677540c0047c09d300d81c85dc821
|
[
"MIT"
] | null | null | null |
src/libs/cosinesimilarity.hpp
|
ronaldpereira/collaborative-filtering-movie-recommendation
|
0ecdd5f531a677540c0047c09d300d81c85dc821
|
[
"MIT"
] | null | null | null |
src/libs/cosinesimilarity.hpp
|
ronaldpereira/collaborative-filtering-movie-recommendation
|
0ecdd5f531a677540c0047c09d300d81c85dc821
|
[
"MIT"
] | null | null | null |
#ifndef COSINESIM
#define COSINESIM
#include <unordered_map>
#include "itemuser.hpp"
class CosineSimilarity
{
private:
// Data
std::unordered_map<int, std::unordered_map<int, double>> computedSimilarities;
// Methods
std::unordered_map<int, double> getKNearestNeighbors(std::unordered_map<int, double> *, int);
public:
std::unordered_map<int, double> calculateSimilarity(ItemUser *, int, int);
};
#endif
| 21.4
| 97
| 0.731308
|
ronaldpereira
|
bb52f4073517a6c40660dfeda4f047b6f34ea571
| 2,581
|
cpp
|
C++
|
Codeforces/Lyft/Elimination2018/D.cpp
|
Mindjolt2406/Competitive-Programming
|
d000d98bf7005ee4fb809bcea2f110e4c4793b80
|
[
"MIT"
] | 2
|
2018-12-11T14:37:24.000Z
|
2022-01-23T18:11:54.000Z
|
Codeforces/Lyft/Elimination2018/D.cpp
|
Mindjolt2406/Competitive-Programming
|
d000d98bf7005ee4fb809bcea2f110e4c4793b80
|
[
"MIT"
] | null | null | null |
Codeforces/Lyft/Elimination2018/D.cpp
|
Mindjolt2406/Competitive-Programming
|
d000d98bf7005ee4fb809bcea2f110e4c4793b80
|
[
"MIT"
] | null | null | null |
// Implement this. DON'T CLOSE IT
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 998244353
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<long long int>
#define sc(n) scanf("%d",&n);
#define scll(n) scanf("%lld",&n);
#define scld(n) scanf("%Lf",&n);
#define scr(s) {char temp[1000000];scanf("%s",temp);s = temp;}
using namespace std;
long long int size;
bitset<10000010> bs;
vi prime;
void sieve(ll upperbound)
{
size = upperbound + 1;
bs.set();
bs[0] = bs[1] = false;
for(ll i = 2;i< size;i++)
{
if(bs[i])
{
for(ll j = i*i;j<size;j+=i) bs[j] = false;
}
prime.pu((int)i);
}
}
ll gcd(ll a, ll b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
int main()
{
sieve(3000000);
cout<<"here"<<endl;
int n;
sc(n);
ll *l = new ll[n];
map<ll,int> d,dprime;
map<ll,int> :: iterator it;
vector<ll> v;
for(int i=0;i<n;i++) scll(l[i]);
cout<<"here1"<<endl;
ll prod = 1;
for(int i=0;i<n;i++)
{
ll k = l[i];
int boo = 1;
for(int j=0;j<prime.size();j++)
{
// cout<<"j: "<<j<<"prime: "<<prime[j]<<endl;
if(prime[j]<=1500000000 && prime[j]*prime[j]==k)
{
if(d.find(prime[j])==d.end()) d[prime[j]] = 3;
else d[prime[j]]+=3;
boo = 1;break;
}
else if(prime[j]<=2000000 && prime[j]*prime[j]*prime[j]==k)
{
if(d.find(prime[j])==d.end()) d[prime[j]] = 4;
else d[prime[j]]+=4;
boo = 1;break;
}
else if(prime[j]<=38000 && prime[j]*prime[j]*prime[j]*prime[j]==k)
{
if(d.find(prime[j])==d.end()) d[prime[j]] = 5;
else d[prime[j]]+=5;
boo = 1;break;
}
else boo = 0;
// cout<<"here2"<<endl;
}
cout<<"prod: "<<prod<<endl;
cout<<"here"<<endl;
if(!boo)
{
if(d.find(k)!=d.end()) d[k]++;
else d[k] = 1;
for(it=d.begin();it!=d.end();it++) v.pu(it->first);
for(int i=0;i<v.size();i++)
{
int boo = 1;
for(int j=i+1;j<v.size();j++)
{
ll g = gcd(v[i],v[j]);
if(g!=1)
{
boo = 0;
if(dprime.find(g)!=d.end()) dprime[g]+=2;
else dprime[g] = 2;
}
}
if(boo) {prod*=4*d[v[i]];prod%=MOD;}
}
}
}
for(it = dprime.begin();it!=dprime.end();it++)
{
cout<<it->first<<" ";
int c = it->second/2+1;
cout<<c<<endl;
prod*=(c+1);prod%=MOD;
}
cout<<prod<<endl;
return 0;
}
| 21.330579
| 73
| 0.483146
|
Mindjolt2406
|
bb54bd95cfa5a715d0c1492c203c807a40b15239
| 12,642
|
cpp
|
C++
|
libs/object/tests/TCntPtrTest.cpp
|
ZachHenkel/Mso
|
ee250782dfc67e309a1c66c67e97f774727b56af
|
[
"MIT"
] | null | null | null |
libs/object/tests/TCntPtrTest.cpp
|
ZachHenkel/Mso
|
ee250782dfc67e309a1c66c67e97f774727b56af
|
[
"MIT"
] | null | null | null |
libs/object/tests/TCntPtrTest.cpp
|
ZachHenkel/Mso
|
ee250782dfc67e309a1c66c67e97f774727b56af
|
[
"MIT"
] | null | null | null |
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/****************************************************************************
Unit tests for the TCntPtr smart pointer
****************************************************************************/
#include "precomp.h"
#include <atomic>
#include <functional>
#include <object/refCounted.h>
#include <object/unknownObject.h>
#include <test/testCheck.h>
MSO_STRUCT_GUID(IUnkSimple, "9FEAB33F-E5D0-4A52-9216-6BA8BA9990A4")
struct IUnkSimple : public IUnknown
{
virtual void DoSomething() = 0;
};
MSO_STRUCT_GUID(IUnkSample, "8A2560F5-E28D-4342-8716-1BBD3A4603B3")
struct IUnkSample : public IUnknown
{
virtual void DoAnything() = 0;
};
struct ISimple : public Mso::IRefCounted
{
virtual void DoSomething() = 0;
};
typedef std::function<void(bool inc)> RefCountChangedCallback;
class SimpleClass : public ISimple
{
public:
SimpleClass(RefCountChangedCallback&& onRefCountChanged)
: m_refCount(0)
, m_onRefCountChanged(std::move(onRefCountChanged))
{
}
virtual void AddRef() const noexcept override
{
OACR_ASSUME_NOTHROW_BEGIN
m_onRefCountChanged(/*incremented*/true);
OACR_ASSUME_NOTHROW_END
++m_refCount;
}
virtual void Release() const noexcept override
{
OACR_ASSUME_NOTHROW_BEGIN
m_onRefCountChanged(/*incremented*/false);
OACR_ASSUME_NOTHROW_END
if (--m_refCount == 0)
{
delete this;
}
}
virtual void DoSomething() noexcept override
{
}
void ClassDoSomething() noexcept
{
OACR_USE_PTR(this); // simulates access to 'this' for OACR build
}
private:
mutable std::atomic<uint32_t> m_refCount;
RefCountChangedCallback m_onRefCountChanged;
};
class UnkSimpleClass : public IUnkSimple
{
public:
UnkSimpleClass(RefCountChangedCallback&& onRefCountChanged)
: m_refCount(0)
, m_onRefCountChanged(std::move(onRefCountChanged))
{
}
_Success_(return == S_OK)
STDMETHOD(QueryInterface)(const GUID& /*riid*/, _Outptr_ void** /*ppvObject*/) noexcept override
{
return E_NOINTERFACE;
}
STDMETHOD_(ULONG, AddRef)() noexcept override
{
OACR_ASSUME_NOTHROW_BEGIN
m_onRefCountChanged(/*incremented*/true);
OACR_ASSUME_NOTHROW_END
++m_refCount;
return 1;
}
STDMETHOD_(ULONG, Release)() noexcept override
{
OACR_ASSUME_NOTHROW_BEGIN
m_onRefCountChanged(/*incremented*/false);
OACR_ASSUME_NOTHROW_END
if (--m_refCount == 0)
{
delete this;
}
return 1;
}
virtual void DoSomething() noexcept override
{
}
void ClassDoSomething() noexcept
{
OACR_USE_PTR(this); // simulates access to 'this' for OACR build
}
private:
mutable std::atomic<uint32_t> m_refCount;
RefCountChangedCallback m_onRefCountChanged;
};
inline static std::wstring ToString(UnkSimpleClass* q) { return L""; }
inline static std::wstring ToString(SimpleClass* q) { return L""; }
inline static std::wstring ToString(const UnkSimpleClass* q) { return L""; }
inline static std::wstring ToString(const SimpleClass* q) { return L""; }
class AggregatedObject : public Mso::UnknownObject<IUnkSimple, IUnkSample>
{
public:
virtual void DoSomething() noexcept override
{
}
virtual void DoAnything() noexcept override
{
}
};
template <typename TAction>
static void ValidateRefCount(uint32_t expectedIncRefCountCallCount, TAction action)
{
uint32_t actualIncRefCountCallCount = 0;
uint32_t actualDecRefCountCallCount = 0;
auto callback = [&actualIncRefCountCallCount, &actualDecRefCountCallCount](bool incremented) noexcept
{
if (incremented)
{
++actualIncRefCountCallCount;
}
else
{
++actualDecRefCountCallCount;
}
};
action(RefCountChangedCallback(callback));
TestAssert::AreEqual(actualIncRefCountCallCount, actualDecRefCountCallCount, L"IncCount != DecCount.");
TestAssert::AreEqual(expectedIncRefCountCallCount, actualIncRefCountCallCount, L"Unexpected IncCount.");
}
TestClassComponent(TCntPtrTest, Mso.TCntPtr)
TEST_CLASS(TCntPtrTest)
{
TEST_METHOD(TCntPtr_EmptyCtor)
{
Mso::TCntPtr<SimpleClass> spObj;
TestAssert::IsNull(spObj.Get(), L"Expected null");
}
TEST_METHOD(TCntPtr_NullCtor)
{
Mso::TCntPtr<SimpleClass> spObj = nullptr;
TestAssert::IsNull(spObj.Get(), L"Expected null");
}
TEST_METHOD(TCntPtr_DeprecatedNullCtor)
{
//TODO: Remove when we stop using NULL
Mso::TCntPtr<SimpleClass> spObj;
TestAssert::IsNull(spObj.Get(), L"Expected null");
}
TEST_METHOD(TCntPtr_Create)
{
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
TestAssert::AreEqual((void*)ptr, (void*)spObj.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_CreateInterface)
{
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<ISimple> spIntf(ptr);
TestAssert::AreEqual((void*)ptr, (void*)spIntf.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_CopyConstructor)
{
ValidateRefCount(2, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
Mso::TCntPtr<SimpleClass> spSameObj(spObj);
TestAssert::AreEqual((void*)ptr, (void*)spObj.Get(), L"Expected ptr");
TestAssert::AreEqual((void*)ptr, (void*)spSameObj.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_CopyConstructorInterface)
{
ValidateRefCount(2, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
Mso::TCntPtr<ISimple> spIntf(spObj);
TestAssert::AreEqual((void*) ptr, (void*) spObj.Get(), L"Expected ptr");
TestAssert::AreEqual((void*)ptr, (void*)spIntf.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_MoveConstructor)
{
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
Mso::TCntPtr<SimpleClass> spSameObj(std::move(spObj));
TestAssert::IsNull(spObj.Get(), L"Expected null");
TestAssert::AreEqual((void*)ptr, (void*)spSameObj.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_MoveConstructorInterface)
{
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
Mso::TCntPtr<ISimple> spIntf(std::move(spObj));
TestAssert::IsNull(spObj.Get(), L"Expected null");
TestAssert::AreEqual((void*)ptr, (void*)spIntf.Get(), L"Expected ptr");
});
}
// Factory method to get benefits from using the move constructor
static Mso::TCntPtr<SimpleClass> CreateSimpleClass(RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<SimpleClass> spObj = new SimpleClass(std::move(onRefCountChanged));
spObj->ClassDoSomething();
return spObj; // std::move() not needed because the same type allows the named return value optimization.
}
TEST_METHOD(TCntPtr_CallCreateSimpleClass)
{
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<ISimple> spObj = CreateSimpleClass(std::move(onRefCountChanged));
TestAssert::IsNotNull(spObj.Get(), L"Expected not a null value");
});
}
// Factory method to get benefits from using the move constructor
static Mso::TCntPtr<ISimple> CreateISimple(RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<SimpleClass> spObj = new SimpleClass(std::move(onRefCountChanged));
spObj->ClassDoSomething();
return std::move(spObj); // We should use std::move() here to avoid use of copy constructor.
// Named value return optimization will not work because we have different types.
}
TEST_METHOD(TCntPtr_CallCreateISimple)
{
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<ISimple> spIntf = CreateISimple(std::move(onRefCountChanged));
TestAssert::IsNotNull(spIntf.Get(), L"Expected not a null value");
});
}
TEST_METHOD(TCntPtr_CopyAssignment)
{
ValidateRefCount(3, [](RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<SimpleClass> spObj1(new SimpleClass(RefCountChangedCallback(onRefCountChanged)));
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj2(ptr);
spObj1 = spObj2;
TestAssert::AreEqual((void*)ptr, (void*)spObj1.Get(), L"Expected ptr");
TestAssert::AreEqual((void*)ptr, (void*)spObj2.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_CopyAssignmentInterface)
{
ValidateRefCount(3, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(RefCountChangedCallback(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
Mso::TCntPtr<ISimple> spIntf = new SimpleClass(std::move(onRefCountChanged));
spIntf = spObj;
TestAssert::AreEqual((void*)ptr, (void*)spObj.Get(), L"Expected ptr");
TestAssert::AreEqual((void*)ptr, (void*)spIntf.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_CopyAssignmentSameObject)
{
// See what happens when we assign TCntPtr to itself.
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
OACR_WARNING_SUPPRESS(IDENTITY_ASSIGNMENT, "We want to test our code that nothing bad happens in this case");
spObj = spObj;
TestAssert::AreEqual((void*)ptr, (void*)spObj.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_CopyAssignmentConst)
{
// Test that TCntPtr can accept a const variable and AddRef/Release methods are not const.
ValidateRefCount(3, [](RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<const UnkSimpleClass> spObj1(new UnkSimpleClass(RefCountChangedCallback(onRefCountChanged)));
const UnkSimpleClass* ptr = new UnkSimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<const UnkSimpleClass> spObj2(ptr);
spObj1 = spObj2;
TestAssert::AreEqual((void*)ptr, (void*)spObj1.Get(), L"Expected ptr");
TestAssert::AreEqual((void*)ptr, (void*)spObj2.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_MoveAssignment)
{
ValidateRefCount(2, [](RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<SimpleClass> spObj1 = new SimpleClass(RefCountChangedCallback(onRefCountChanged));
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj2(ptr);
spObj1 = std::move(spObj2);
TestAssert::AreEqual((void*)ptr, (void*)spObj1.Get(), L"Expected ptr");
TestAssert::IsNull(spObj2.Get(), L"Expected null");
});
}
TEST_METHOD(TCntPtr_MoveAssignmentInterface)
{
ValidateRefCount(2, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(RefCountChangedCallback(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
Mso::TCntPtr<ISimple> spIntf = new SimpleClass(std::move(onRefCountChanged));
spIntf = std::move(spObj);
TestAssert::IsNull(spObj.Get(), L"Expected null");
TestAssert::AreEqual((void*)ptr, (void*)spIntf.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_MoveAssignmentSameObject)
{
// Our copy assignment does not check if we use the same object. This test is to see that nothing bad happens.
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
SimpleClass* ptr = new SimpleClass(std::move(onRefCountChanged));
Mso::TCntPtr<SimpleClass> spObj(ptr);
spObj = std::move(spObj);
TestAssert::AreEqual((void*)ptr, (void*)spObj.Get(), L"Expected ptr");
});
}
TEST_METHOD(TCntPtr_NullAssignment)
{
ValidateRefCount(1, [](RefCountChangedCallback&& onRefCountChanged)
{
Mso::TCntPtr<SimpleClass> spObj = new SimpleClass(RefCountChangedCallback(onRefCountChanged));
spObj = nullptr;
TestAssert::IsNull(spObj.Get(), L"Expected null");
});
}
TEST_METHOD(TCntPtr_IsEqualObject_BothISimpleClass_AreEqual)
{
Mso::TCntPtr<IUnkSimple> spObj = Mso::Make<AggregatedObject>();
Mso::TCntPtr<IUnkSimple> spObjTwo = spObj;
TestAssert::IsTrue(Mso::ComUtil::AreEqualObjects(spObj, spObjTwo));
}
TEST_METHOD(TCntPtr_IsEqualObject_DifferentInterfaceTypes_AreEqual)
{
Mso::TCntPtr<IUnkSimple> spObj = Mso::Make<AggregatedObject>();
Mso::TCntPtr<IUnkSample> spSample;
TestAssert::HrSucceeded(Mso::ComUtil::HrQueryFrom(spSample, spObj));
TestAssert::IsTrue(Mso::ComUtil::AreEqualObjects(spObj, spSample));
}
TEST_METHOD(TCntPtr_IsEqualObject_DifferentObject_AreNotEqual)
{
Mso::TCntPtr<IUnkSimple> spObj = Mso::Make<AggregatedObject>();
Mso::TCntPtr<IUnkSimple> spObjTwo = Mso::Make<AggregatedObject>();
TestAssert::IsFalse(Mso::ComUtil::AreEqualObjects(spObj, spObjTwo));
}
};
| 28.408989
| 111
| 0.742525
|
ZachHenkel
|
bb565e823c97421d0945ac22f09f969a61112027
| 1,226
|
hpp
|
C++
|
test-suite/generated-src/cwrapper/cw__Foo_Callback2.hpp
|
ubook-editora/finn
|
9a2b0e442c94e7311f85d2892dd33b1e3579bb1f
|
[
"Apache-2.0"
] | 3
|
2019-11-07T03:38:03.000Z
|
2020-03-28T10:24:40.000Z
|
test-suite/generated-src/cwrapper/cw__Foo_Callback2.hpp
|
ubook-editora/finn
|
9a2b0e442c94e7311f85d2892dd33b1e3579bb1f
|
[
"Apache-2.0"
] | null | null | null |
test-suite/generated-src/cwrapper/cw__Foo_Callback2.hpp
|
ubook-editora/finn
|
9a2b0e442c94e7311f85d2892dd33b1e3579bb1f
|
[
"Apache-2.0"
] | 2
|
2020-12-01T18:39:26.000Z
|
2021-02-04T03:55:31.000Z
|
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from foo_duplicate_file_creation.djinni
#pragma once
#include <atomic>
#include <experimental/optional>
#include "Foo_Callback2.hpp"
#ifdef __cplusplus
extern "C" {
#endif
#include "cw__Foo_Callback2.h"
#ifdef __cplusplus
}
#endif
struct DjinniWrapperFooCallback2 final {
DjinniWrapperFooCallback2(std::shared_ptr<::testsuite::FooCallback2>wo): wrapped_obj(wo) {};
static std::shared_ptr<::testsuite::FooCallback2> get(djinni::Handle<DjinniWrapperFooCallback2> dw);
static djinni::Handle<DjinniWrapperFooCallback2> wrap(std::shared_ptr<::testsuite::FooCallback2> obj);
const std::shared_ptr<::testsuite::FooCallback2> wrapped_obj;
std::atomic<size_t> ref_count {1};
};
class FooCallback2PythonProxy final : public ::testsuite::FooCallback2 {
public:
explicit FooCallback2PythonProxy(DjinniObjectHandle * c_ptr);
~FooCallback2PythonProxy();
DjinniObjectHandle * get_m_py_obj_handle();
void methodA(const std::vector<::testsuite::FooRecord> & records);
void methodB(const std::vector<::testsuite::FooRecord> & records);
private:
DjinniObjectHandle * m_py_obj_handle;
};
| 29.902439
| 106
| 0.74062
|
ubook-editora
|
bb5a0334002f1517f6a080b793f0ced044a4c5c1
| 230,241
|
cc
|
C++
|
tensorflow/core/profiler/tfprof_log.pb.cc
|
1250281649/tensorflow
|
fc6f4ec813c3514fc4a4c6a078f3f492b3ff325c
|
[
"Apache-2.0"
] | null | null | null |
tensorflow/core/profiler/tfprof_log.pb.cc
|
1250281649/tensorflow
|
fc6f4ec813c3514fc4a4c6a078f3f492b3ff325c
|
[
"Apache-2.0"
] | 2
|
2021-08-25T15:57:35.000Z
|
2022-02-10T01:09:32.000Z
|
tensorflow/core/profiler/tfprof_log.pb.cc
|
1250281649/tensorflow
|
fc6f4ec813c3514fc4a4c6a078f3f492b3ff325c
|
[
"Apache-2.0"
] | null | null | null |
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: tensorflow/core/profiler/tfprof_log.proto
#include "tensorflow/core/profiler/tfprof_log.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>
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fframework_2fstep_5fstats_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_AllocationRecord_tensorflow_2fcore_2fframework_2fstep_5fstats_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fframework_2fattr_5fvalue_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_AttrValue_tensorflow_2fcore_2fframework_2fattr_5fvalue_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecMemory_OutputMemoryEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<4> scc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecProfile_AcceleratorExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecProfile_CpuExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Memory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpLogProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<8> scc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_AttrsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_ExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_InputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileNode_InputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_OutputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileNode_OutputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileNode_SrcOutputIndexEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileProto_NodesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto;
namespace tensorflow {
namespace tfprof {
class CodeDef_TraceDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<CodeDef_Trace> _instance;
} _CodeDef_Trace_default_instance_;
class CodeDefDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<CodeDef> _instance;
} _CodeDef_default_instance_;
class OpLogEntryDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<OpLogEntry> _instance;
} _OpLogEntry_default_instance_;
class OpLogProto_IdToStringEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<OpLogProto_IdToStringEntry_DoNotUse> _instance;
} _OpLogProto_IdToStringEntry_DoNotUse_default_instance_;
class OpLogProtoDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<OpLogProto> _instance;
} _OpLogProto_default_instance_;
class ProfileProto_NodesEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileProto_NodesEntry_DoNotUse> _instance;
} _ProfileProto_NodesEntry_DoNotUse_default_instance_;
class ProfileProto_IdToStringEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileProto_IdToStringEntry_DoNotUse> _instance;
} _ProfileProto_IdToStringEntry_DoNotUse_default_instance_;
class ProfileProtoDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileProto> _instance;
} _ProfileProto_default_instance_;
class ProfileNode_InputsEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode_InputsEntry_DoNotUse> _instance;
} _ProfileNode_InputsEntry_DoNotUse_default_instance_;
class ProfileNode_InputShapesEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode_InputShapesEntry_DoNotUse> _instance;
} _ProfileNode_InputShapesEntry_DoNotUse_default_instance_;
class ProfileNode_OutputsEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode_OutputsEntry_DoNotUse> _instance;
} _ProfileNode_OutputsEntry_DoNotUse_default_instance_;
class ProfileNode_OutputShapesEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode_OutputShapesEntry_DoNotUse> _instance;
} _ProfileNode_OutputShapesEntry_DoNotUse_default_instance_;
class ProfileNode_SrcOutputIndexEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode_SrcOutputIndexEntry_DoNotUse> _instance;
} _ProfileNode_SrcOutputIndexEntry_DoNotUse_default_instance_;
class ProfileNode_AttrsEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode_AttrsEntry_DoNotUse> _instance;
} _ProfileNode_AttrsEntry_DoNotUse_default_instance_;
class ProfileNode_ExecsEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode_ExecsEntry_DoNotUse> _instance;
} _ProfileNode_ExecsEntry_DoNotUse_default_instance_;
class ProfileNodeDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ProfileNode> _instance;
} _ProfileNode_default_instance_;
class ExecProfile_AcceleratorExecsEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ExecProfile_AcceleratorExecsEntry_DoNotUse> _instance;
} _ExecProfile_AcceleratorExecsEntry_DoNotUse_default_instance_;
class ExecProfile_CpuExecsEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ExecProfile_CpuExecsEntry_DoNotUse> _instance;
} _ExecProfile_CpuExecsEntry_DoNotUse_default_instance_;
class ExecProfileDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ExecProfile> _instance;
} _ExecProfile_default_instance_;
class ExecTimeDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ExecTime> _instance;
} _ExecTime_default_instance_;
class ExecMemory_OutputMemoryEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ExecMemory_OutputMemoryEntry_DoNotUse> _instance;
} _ExecMemory_OutputMemoryEntry_DoNotUse_default_instance_;
class ExecMemoryDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ExecMemory> _instance;
} _ExecMemory_default_instance_;
class TupleDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Tuple> _instance;
} _Tuple_default_instance_;
class MemoryDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Memory> _instance;
} _Memory_default_instance_;
} // namespace tfprof
} // namespace tensorflow
static void InitDefaultsscc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_CodeDef_default_instance_;
new (ptr) ::tensorflow::tfprof::CodeDef();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::CodeDef::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_CodeDef_Trace_default_instance_;
new (ptr) ::tensorflow::tfprof::CodeDef_Trace();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::CodeDef_Trace::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static void InitDefaultsscc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ExecMemory_default_instance_;
new (ptr) ::tensorflow::tfprof::ExecMemory();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::ExecMemory::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ExecMemory_OutputMemoryEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ExecMemory_OutputMemoryEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ExecMemory_OutputMemoryEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse();
}
::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecMemory_OutputMemoryEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ExecMemory_OutputMemoryEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_Memory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ExecProfile_default_instance_;
new (ptr) ::tensorflow::tfprof::ExecProfile();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::ExecProfile::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<4> scc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 4, 0, InitDefaultsscc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ExecProfile_AcceleratorExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecProfile_CpuExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_AllocationRecord_tensorflow_2fcore_2fframework_2fstep_5fstats_2eproto.base,}};
static void InitDefaultsscc_info_ExecProfile_AcceleratorExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ExecProfile_AcceleratorExecsEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse();
}
::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecProfile_AcceleratorExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ExecProfile_AcceleratorExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ExecProfile_CpuExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ExecProfile_CpuExecsEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse();
}
::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecProfile_CpuExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ExecProfile_CpuExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ExecTime_default_instance_;
new (ptr) ::tensorflow::tfprof::ExecTime();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::ExecTime::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_Memory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_Memory_default_instance_;
new (ptr) ::tensorflow::tfprof::Memory();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::Memory::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Memory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Memory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static void InitDefaultsscc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_OpLogEntry_default_instance_;
new (ptr) ::tensorflow::tfprof::OpLogEntry();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::OpLogEntry::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_OpLogProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_OpLogProto_default_instance_;
new (ptr) ::tensorflow::tfprof::OpLogProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::OpLogProto::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_OpLogProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_OpLogProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_OpLogProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_OpLogProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_OpLogProto_IdToStringEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse();
}
::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpLogProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpLogProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static void InitDefaultsscc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::ProfileNode::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<8> scc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 8, 0, InitDefaultsscc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ProfileNode_InputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_InputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_OutputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_OutputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_SrcOutputIndexEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_AttrsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_ExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ProfileNode_AttrsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_AttrsEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_AttrsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ProfileNode_AttrsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_AttrValue_tensorflow_2fcore_2fframework_2fattr_5fvalue_2eproto.base,}};
static void InitDefaultsscc_info_ProfileNode_ExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_ExecsEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_ExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ProfileNode_ExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ProfileNode_InputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_InputShapesEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_InputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ProfileNode_InputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ProfileNode_InputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_InputsEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileNode_InputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ProfileNode_InputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static void InitDefaultsscc_info_ProfileNode_OutputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_OutputShapesEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileNode_OutputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ProfileNode_OutputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ProfileNode_OutputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_OutputsEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileNode_OutputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ProfileNode_OutputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static void InitDefaultsscc_info_ProfileNode_SrcOutputIndexEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileNode_SrcOutputIndexEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileNode_SrcOutputIndexEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ProfileNode_SrcOutputIndexEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static void InitDefaultsscc_info_ProfileProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileProto_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileProto();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::ProfileProto::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ProfileProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_ProfileProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ProfileProto_NodesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_ProfileProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileProto_IdToStringEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ProfileProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ProfileProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static void InitDefaultsscc_info_ProfileProto_NodesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_ProfileProto_NodesEntry_DoNotUse_default_instance_;
new (ptr) ::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse();
}
::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ProfileProto_NodesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ProfileProto_NodesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {
&scc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,}};
static void InitDefaultsscc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::tensorflow::tfprof::_Tuple_default_instance_;
new (ptr) ::tensorflow::tfprof::Tuple();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::tensorflow::tfprof::Tuple::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto}, {}};
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto[24];
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, file_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, file_id_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, lineno_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, function_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, function_id_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, line_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, line_id_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef_Trace, func_start_line_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::CodeDef, traces_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogEntry, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogEntry, name_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogEntry, float_ops_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogEntry, types_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogEntry, code_def_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogProto, log_entries_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::OpLogProto, id_to_string_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto, nodes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto, has_trace_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto, miss_accelerator_stream_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto, steps_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileProto, id_to_string_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, name_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, op_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, id_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, inputs_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, input_shapes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, outputs_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, output_shapes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, src_output_index_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, shape_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, op_types_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, canonical_device_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, host_device_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, float_ops_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, trace_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, attrs_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ProfileNode, execs_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse, value_),
0,
1,
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, run_count_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, all_start_micros_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, latest_end_micros_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, accelerator_execs_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, cpu_execs_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, memory_execs_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, allocations_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecProfile, devices_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecTime, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecTime, times_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, memory_micros_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, host_temp_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, host_persistent_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, accelerator_temp_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, accelerator_persistent_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, requested_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, peak_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, residual_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, output_bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, allocator_bytes_in_use_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::ExecMemory, output_memory_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::Tuple, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::Tuple, int64_values_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::Memory, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::Memory, bytes_),
PROTOBUF_FIELD_OFFSET(::tensorflow::tfprof::Memory, ptr_),
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::tensorflow::tfprof::CodeDef_Trace)},
{ 13, -1, sizeof(::tensorflow::tfprof::CodeDef)},
{ 19, -1, sizeof(::tensorflow::tfprof::OpLogEntry)},
{ 28, 35, sizeof(::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse)},
{ 37, -1, sizeof(::tensorflow::tfprof::OpLogProto)},
{ 44, 51, sizeof(::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse)},
{ 53, 60, sizeof(::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse)},
{ 62, -1, sizeof(::tensorflow::tfprof::ProfileProto)},
{ 72, 79, sizeof(::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse)},
{ 81, 88, sizeof(::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse)},
{ 90, 97, sizeof(::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse)},
{ 99, 106, sizeof(::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse)},
{ 108, 115, sizeof(::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse)},
{ 117, 124, sizeof(::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse)},
{ 126, 133, sizeof(::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse)},
{ 135, -1, sizeof(::tensorflow::tfprof::ProfileNode)},
{ 156, 163, sizeof(::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse)},
{ 165, 172, sizeof(::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse)},
{ 174, -1, sizeof(::tensorflow::tfprof::ExecProfile)},
{ 187, -1, sizeof(::tensorflow::tfprof::ExecTime)},
{ 193, 200, sizeof(::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse)},
{ 202, -1, sizeof(::tensorflow::tfprof::ExecMemory)},
{ 218, -1, sizeof(::tensorflow::tfprof::Tuple)},
{ 224, -1, sizeof(::tensorflow::tfprof::Memory)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_CodeDef_Trace_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_CodeDef_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_OpLogEntry_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_OpLogProto_IdToStringEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_OpLogProto_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileProto_NodesEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileProto_IdToStringEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileProto_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_InputsEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_InputShapesEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_OutputsEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_OutputShapesEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_SrcOutputIndexEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_AttrsEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_ExecsEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ProfileNode_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ExecProfile_AcceleratorExecsEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ExecProfile_CpuExecsEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ExecProfile_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ExecTime_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ExecMemory_OutputMemoryEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_ExecMemory_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_Tuple_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::tfprof::_Memory_default_instance_),
};
const char descriptor_table_protodef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n)tensorflow/core/profiler/tfprof_log.pr"
"oto\022\021tensorflow.tfprof\032*tensorflow/core/"
"framework/attr_value.proto\032*tensorflow/c"
"ore/framework/step_stats.proto\"\337\001\n\007CodeD"
"ef\0220\n\006traces\030\001 \003(\0132 .tensorflow.tfprof.C"
"odeDef.Trace\032\241\001\n\005Trace\022\020\n\004file\030\001 \001(\tB\002\030\001"
"\022\017\n\007file_id\030\006 \001(\003\022\016\n\006lineno\030\002 \001(\005\022\024\n\010fun"
"ction\030\003 \001(\tB\002\030\001\022\023\n\013function_id\030\007 \001(\003\022\020\n\004"
"line\030\004 \001(\tB\002\030\001\022\017\n\007line_id\030\010 \001(\003\022\027\n\017func_"
"start_line\030\005 \001(\005\"j\n\nOpLogEntry\022\014\n\004name\030\001"
" \001(\t\022\021\n\tfloat_ops\030\002 \001(\003\022\r\n\005types\030\003 \003(\t\022,"
"\n\010code_def\030\004 \001(\0132\032.tensorflow.tfprof.Cod"
"eDef\"\270\001\n\nOpLogProto\0222\n\013log_entries\030\001 \003(\013"
"2\035.tensorflow.tfprof.OpLogEntry\022C\n\014id_to"
"_string\030\002 \003(\0132-.tensorflow.tfprof.OpLogP"
"roto.IdToStringEntry\0321\n\017IdToStringEntry\022"
"\013\n\003key\030\001 \001(\003\022\r\n\005value\030\002 \001(\t:\0028\001\"\324\002\n\014Prof"
"ileProto\0229\n\005nodes\030\001 \003(\0132*.tensorflow.tfp"
"rof.ProfileProto.NodesEntry\022\021\n\thas_trace"
"\030\002 \001(\010\022\037\n\027miss_accelerator_stream\030\005 \001(\010\022"
"\r\n\005steps\030\003 \003(\003\022E\n\014id_to_string\030\004 \003(\0132/.t"
"ensorflow.tfprof.ProfileProto.IdToString"
"Entry\032L\n\nNodesEntry\022\013\n\003key\030\001 \001(\003\022-\n\005valu"
"e\030\002 \001(\0132\036.tensorflow.tfprof.ProfileNode:"
"\0028\001\0321\n\017IdToStringEntry\022\013\n\003key\030\001 \001(\003\022\r\n\005v"
"alue\030\002 \001(\t:\0028\001\"\323\010\n\013ProfileNode\022\014\n\004name\030\001"
" \001(\t\022\n\n\002op\030\t \001(\t\022\n\n\002id\030\r \001(\003\022:\n\006inputs\030\002"
" \003(\0132*.tensorflow.tfprof.ProfileNode.Inp"
"utsEntry\022E\n\014input_shapes\030\020 \003(\0132/.tensorf"
"low.tfprof.ProfileNode.InputShapesEntry\022"
"<\n\007outputs\030\003 \003(\0132+.tensorflow.tfprof.Pro"
"fileNode.OutputsEntry\022G\n\routput_shapes\030\017"
" \003(\01320.tensorflow.tfprof.ProfileNode.Out"
"putShapesEntry\022L\n\020src_output_index\030\016 \003(\013"
"22.tensorflow.tfprof.ProfileNode.SrcOutp"
"utIndexEntry\022\r\n\005shape\030\004 \003(\003\022\020\n\010op_types\030"
"\005 \003(\t\022\030\n\020canonical_device\030\006 \001(\t\022\023\n\013host_"
"device\030\007 \001(\t\022\021\n\tfloat_ops\030\010 \001(\003\022)\n\005trace"
"\030\n \001(\0132\032.tensorflow.tfprof.CodeDef\0228\n\005at"
"trs\030\013 \003(\0132).tensorflow.tfprof.ProfileNod"
"e.AttrsEntry\0228\n\005execs\030\014 \003(\0132).tensorflow"
".tfprof.ProfileNode.ExecsEntry\032-\n\013Inputs"
"Entry\022\013\n\003key\030\001 \001(\005\022\r\n\005value\030\002 \001(\003:\0028\001\032L\n"
"\020InputShapesEntry\022\013\n\003key\030\001 \001(\005\022\'\n\005value\030"
"\002 \001(\0132\030.tensorflow.tfprof.Tuple:\0028\001\032.\n\014O"
"utputsEntry\022\013\n\003key\030\001 \001(\005\022\r\n\005value\030\002 \001(\003:"
"\0028\001\032M\n\021OutputShapesEntry\022\013\n\003key\030\001 \001(\005\022\'\n"
"\005value\030\002 \001(\0132\030.tensorflow.tfprof.Tuple:\002"
"8\001\0325\n\023SrcOutputIndexEntry\022\013\n\003key\030\001 \001(\003\022\r"
"\n\005value\030\002 \001(\005:\0028\001\032C\n\nAttrsEntry\022\013\n\003key\030\001"
" \001(\t\022$\n\005value\030\002 \001(\0132\025.tensorflow.AttrVal"
"ue:\0028\001\032L\n\nExecsEntry\022\013\n\003key\030\001 \001(\003\022-\n\005val"
"ue\030\002 \001(\0132\036.tensorflow.tfprof.ExecProfile"
":\0028\001\"\204\004\n\013ExecProfile\022\021\n\trun_count\030\001 \001(\003\022"
"\030\n\020all_start_micros\030\002 \001(\003\022\031\n\021latest_end_"
"micros\030\003 \001(\003\022O\n\021accelerator_execs\030\004 \003(\0132"
"4.tensorflow.tfprof.ExecProfile.Accelera"
"torExecsEntry\022\?\n\tcpu_execs\030\005 \003(\0132,.tenso"
"rflow.tfprof.ExecProfile.CpuExecsEntry\0223"
"\n\014memory_execs\030\007 \003(\0132\035.tensorflow.tfprof"
".ExecMemory\0221\n\013allocations\030\013 \003(\0132\034.tenso"
"rflow.AllocationRecord\022\017\n\007devices\030\006 \003(\t\032"
"T\n\025AcceleratorExecsEntry\022\013\n\003key\030\001 \001(\t\022*\n"
"\005value\030\002 \001(\0132\033.tensorflow.tfprof.ExecTim"
"e:\0028\001\032L\n\rCpuExecsEntry\022\013\n\003key\030\001 \001(\t\022*\n\005v"
"alue\030\002 \001(\0132\033.tensorflow.tfprof.ExecTime:"
"\0028\001\"3\n\010ExecTime\022\'\n\005times\030\001 \003(\0132\030.tensorf"
"low.tfprof.Tuple\"\264\003\n\nExecMemory\022\025\n\rmemor"
"y_micros\030\001 \001(\003\022\027\n\017host_temp_bytes\030\002 \001(\003\022"
"\035\n\025host_persistent_bytes\030\003 \001(\003\022\036\n\026accele"
"rator_temp_bytes\030\004 \001(\003\022$\n\034accelerator_pe"
"rsistent_bytes\030\005 \001(\003\022\027\n\017requested_bytes\030"
"\006 \001(\003\022\022\n\npeak_bytes\030\007 \001(\003\022\026\n\016residual_by"
"tes\030\010 \001(\003\022\024\n\014output_bytes\030\t \001(\003\022\036\n\026alloc"
"ator_bytes_in_use\030\n \001(\003\022F\n\routput_memory"
"\030\013 \003(\0132/.tensorflow.tfprof.ExecMemory.Ou"
"tputMemoryEntry\032N\n\021OutputMemoryEntry\022\013\n\003"
"key\030\001 \001(\005\022(\n\005value\030\002 \001(\0132\031.tensorflow.tf"
"prof.Memory:\0028\001\"\035\n\005Tuple\022\024\n\014int64_values"
"\030\001 \003(\003\"$\n\006Memory\022\r\n\005bytes\030\001 \001(\003\022\013\n\003ptr\030\002"
" \001(\004b\006proto3"
;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_deps[2] = {
&::descriptor_table_tensorflow_2fcore_2fframework_2fattr_5fvalue_2eproto,
&::descriptor_table_tensorflow_2fcore_2fframework_2fstep_5fstats_2eproto,
};
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_sccs[24] = {
&scc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecMemory_OutputMemoryEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecProfile_AcceleratorExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecProfile_CpuExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_Memory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_OpLogProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_OpLogProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_AttrsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_ExecsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_InputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_InputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_OutputShapesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_OutputsEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileNode_SrcOutputIndexEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileProto_IdToStringEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_ProfileProto_NodesEntry_DoNotUse_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
&scc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_once;
static bool descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_initialized = false;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto = {
&descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_initialized, descriptor_table_protodef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto, "tensorflow/core/profiler/tfprof_log.proto", 3212,
&descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_once, descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_sccs, descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto_deps, 24, 2,
schemas, file_default_instances, TableStruct_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto::offsets,
file_level_metadata_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto, 24, file_level_enum_descriptors_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto, file_level_service_descriptors_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto,
};
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto = ( ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto), true);
namespace tensorflow {
namespace tfprof {
// ===================================================================
void CodeDef_Trace::InitAsDefaultInstance() {
}
class CodeDef_Trace::_Internal {
public:
};
CodeDef_Trace::CodeDef_Trace()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.CodeDef.Trace)
}
CodeDef_Trace::CodeDef_Trace(const CodeDef_Trace& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_file().empty()) {
file_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.file_);
}
function_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_function().empty()) {
function_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.function_);
}
line_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_line().empty()) {
line_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.line_);
}
::memcpy(&lineno_, &from.lineno_,
static_cast<size_t>(reinterpret_cast<char*>(&line_id_) -
reinterpret_cast<char*>(&lineno_)) + sizeof(line_id_));
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.CodeDef.Trace)
}
void CodeDef_Trace::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
function_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
line_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
::memset(&lineno_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&line_id_) -
reinterpret_cast<char*>(&lineno_)) + sizeof(line_id_));
}
CodeDef_Trace::~CodeDef_Trace() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.CodeDef.Trace)
SharedDtor();
}
void CodeDef_Trace::SharedDtor() {
file_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
function_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
line_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void CodeDef_Trace::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const CodeDef_Trace& CodeDef_Trace::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_CodeDef_Trace_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void CodeDef_Trace::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.CodeDef.Trace)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
file_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
function_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
line_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
::memset(&lineno_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&line_id_) -
reinterpret_cast<char*>(&lineno_)) + sizeof(line_id_));
_internal_metadata_.Clear();
}
const char* CodeDef_Trace::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string file = 1 [deprecated = true];
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_file(), ptr, ctx, "tensorflow.tfprof.CodeDef.Trace.file");
CHK_(ptr);
} else goto handle_unusual;
continue;
// int32 lineno = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
lineno_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// string function = 3 [deprecated = true];
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_function(), ptr, ctx, "tensorflow.tfprof.CodeDef.Trace.function");
CHK_(ptr);
} else goto handle_unusual;
continue;
// string line = 4 [deprecated = true];
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_line(), ptr, ctx, "tensorflow.tfprof.CodeDef.Trace.line");
CHK_(ptr);
} else goto handle_unusual;
continue;
// int32 func_start_line = 5;
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
func_start_line_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 file_id = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
file_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 function_id = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
function_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 line_id = 8;
case 8:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
line_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* CodeDef_Trace::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.CodeDef.Trace)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string file = 1 [deprecated = true];
if (this->file().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_file().data(), static_cast<int>(this->_internal_file().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.CodeDef.Trace.file");
target = stream->WriteStringMaybeAliased(
1, this->_internal_file(), target);
}
// int32 lineno = 2;
if (this->lineno() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_lineno(), target);
}
// string function = 3 [deprecated = true];
if (this->function().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_function().data(), static_cast<int>(this->_internal_function().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.CodeDef.Trace.function");
target = stream->WriteStringMaybeAliased(
3, this->_internal_function(), target);
}
// string line = 4 [deprecated = true];
if (this->line().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_line().data(), static_cast<int>(this->_internal_line().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.CodeDef.Trace.line");
target = stream->WriteStringMaybeAliased(
4, this->_internal_line(), target);
}
// int32 func_start_line = 5;
if (this->func_start_line() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_func_start_line(), target);
}
// int64 file_id = 6;
if (this->file_id() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(6, this->_internal_file_id(), target);
}
// int64 function_id = 7;
if (this->function_id() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(7, this->_internal_function_id(), target);
}
// int64 line_id = 8;
if (this->line_id() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(8, this->_internal_line_id(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.CodeDef.Trace)
return target;
}
size_t CodeDef_Trace::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.CodeDef.Trace)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string file = 1 [deprecated = true];
if (this->file().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_file());
}
// string function = 3 [deprecated = true];
if (this->function().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_function());
}
// string line = 4 [deprecated = true];
if (this->line().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_line());
}
// int32 lineno = 2;
if (this->lineno() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_lineno());
}
// int32 func_start_line = 5;
if (this->func_start_line() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_func_start_line());
}
// int64 file_id = 6;
if (this->file_id() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_file_id());
}
// int64 function_id = 7;
if (this->function_id() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_function_id());
}
// int64 line_id = 8;
if (this->line_id() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_line_id());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void CodeDef_Trace::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.CodeDef.Trace)
GOOGLE_DCHECK_NE(&from, this);
const CodeDef_Trace* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<CodeDef_Trace>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.CodeDef.Trace)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.CodeDef.Trace)
MergeFrom(*source);
}
}
void CodeDef_Trace::MergeFrom(const CodeDef_Trace& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.CodeDef.Trace)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.file().size() > 0) {
file_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.file_);
}
if (from.function().size() > 0) {
function_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.function_);
}
if (from.line().size() > 0) {
line_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.line_);
}
if (from.lineno() != 0) {
_internal_set_lineno(from._internal_lineno());
}
if (from.func_start_line() != 0) {
_internal_set_func_start_line(from._internal_func_start_line());
}
if (from.file_id() != 0) {
_internal_set_file_id(from._internal_file_id());
}
if (from.function_id() != 0) {
_internal_set_function_id(from._internal_function_id());
}
if (from.line_id() != 0) {
_internal_set_line_id(from._internal_line_id());
}
}
void CodeDef_Trace::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.CodeDef.Trace)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CodeDef_Trace::CopyFrom(const CodeDef_Trace& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.CodeDef.Trace)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CodeDef_Trace::IsInitialized() const {
return true;
}
void CodeDef_Trace::InternalSwap(CodeDef_Trace* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
file_.Swap(&other->file_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
function_.Swap(&other->function_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
line_.Swap(&other->line_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
swap(lineno_, other->lineno_);
swap(func_start_line_, other->func_start_line_);
swap(file_id_, other->file_id_);
swap(function_id_, other->function_id_);
swap(line_id_, other->line_id_);
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeDef_Trace::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void CodeDef::InitAsDefaultInstance() {
}
class CodeDef::_Internal {
public:
};
CodeDef::CodeDef()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.CodeDef)
}
CodeDef::CodeDef(const CodeDef& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
traces_(from.traces_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.CodeDef)
}
void CodeDef::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
}
CodeDef::~CodeDef() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.CodeDef)
SharedDtor();
}
void CodeDef::SharedDtor() {
}
void CodeDef::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const CodeDef& CodeDef::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_CodeDef_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void CodeDef::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.CodeDef)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
traces_.Clear();
_internal_metadata_.Clear();
}
const char* CodeDef::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// repeated .tensorflow.tfprof.CodeDef.Trace traces = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_traces(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* CodeDef::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.CodeDef)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .tensorflow.tfprof.CodeDef.Trace traces = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_traces_size()); i < n; i++) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessageToArray(1, this->_internal_traces(i), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.CodeDef)
return target;
}
size_t CodeDef::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.CodeDef)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .tensorflow.tfprof.CodeDef.Trace traces = 1;
total_size += 1UL * this->_internal_traces_size();
for (const auto& msg : this->traces_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void CodeDef::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.CodeDef)
GOOGLE_DCHECK_NE(&from, this);
const CodeDef* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<CodeDef>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.CodeDef)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.CodeDef)
MergeFrom(*source);
}
}
void CodeDef::MergeFrom(const CodeDef& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.CodeDef)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
traces_.MergeFrom(from.traces_);
}
void CodeDef::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.CodeDef)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CodeDef::CopyFrom(const CodeDef& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.CodeDef)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CodeDef::IsInitialized() const {
return true;
}
void CodeDef::InternalSwap(CodeDef* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
traces_.InternalSwap(&other->traces_);
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeDef::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void OpLogEntry::InitAsDefaultInstance() {
::tensorflow::tfprof::_OpLogEntry_default_instance_._instance.get_mutable()->code_def_ = const_cast< ::tensorflow::tfprof::CodeDef*>(
::tensorflow::tfprof::CodeDef::internal_default_instance());
}
class OpLogEntry::_Internal {
public:
static const ::tensorflow::tfprof::CodeDef& code_def(const OpLogEntry* msg);
};
const ::tensorflow::tfprof::CodeDef&
OpLogEntry::_Internal::code_def(const OpLogEntry* msg) {
return *msg->code_def_;
}
OpLogEntry::OpLogEntry()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.OpLogEntry)
}
OpLogEntry::OpLogEntry(const OpLogEntry& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
types_(from.types_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) {
name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from._internal_has_code_def()) {
code_def_ = new ::tensorflow::tfprof::CodeDef(*from.code_def_);
} else {
code_def_ = nullptr;
}
float_ops_ = from.float_ops_;
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.OpLogEntry)
}
void OpLogEntry::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
::memset(&code_def_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&float_ops_) -
reinterpret_cast<char*>(&code_def_)) + sizeof(float_ops_));
}
OpLogEntry::~OpLogEntry() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.OpLogEntry)
SharedDtor();
}
void OpLogEntry::SharedDtor() {
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete code_def_;
}
void OpLogEntry::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const OpLogEntry& OpLogEntry::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpLogEntry_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void OpLogEntry::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.OpLogEntry)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
types_.Clear();
name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (GetArenaNoVirtual() == nullptr && code_def_ != nullptr) {
delete code_def_;
}
code_def_ = nullptr;
float_ops_ = PROTOBUF_LONGLONG(0);
_internal_metadata_.Clear();
}
const char* OpLogEntry::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "tensorflow.tfprof.OpLogEntry.name");
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 float_ops = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
float_ops_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// repeated string types = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_add_types(), ptr, ctx, "tensorflow.tfprof.OpLogEntry.types");
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
} else goto handle_unusual;
continue;
// .tensorflow.tfprof.CodeDef code_def = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) {
ptr = ctx->ParseMessage(_internal_mutable_code_def(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* OpLogEntry::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.OpLogEntry)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.OpLogEntry.name");
target = stream->WriteStringMaybeAliased(
1, this->_internal_name(), target);
}
// int64 float_ops = 2;
if (this->float_ops() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(2, this->_internal_float_ops(), target);
}
// repeated string types = 3;
for (int i = 0, n = this->_internal_types_size(); i < n; i++) {
const auto& s = this->_internal_types(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
s.data(), static_cast<int>(s.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.OpLogEntry.types");
target = stream->WriteString(3, s, target);
}
// .tensorflow.tfprof.CodeDef code_def = 4;
if (this->has_code_def()) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessageToArray(
4, _Internal::code_def(this), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.OpLogEntry)
return target;
}
size_t OpLogEntry::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.OpLogEntry)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated string types = 3;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(types_.size());
for (int i = 0, n = types_.size(); i < n; i++) {
total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
types_.Get(i));
}
// string name = 1;
if (this->name().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name());
}
// .tensorflow.tfprof.CodeDef code_def = 4;
if (this->has_code_def()) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*code_def_);
}
// int64 float_ops = 2;
if (this->float_ops() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_float_ops());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void OpLogEntry::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.OpLogEntry)
GOOGLE_DCHECK_NE(&from, this);
const OpLogEntry* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<OpLogEntry>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.OpLogEntry)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.OpLogEntry)
MergeFrom(*source);
}
}
void OpLogEntry::MergeFrom(const OpLogEntry& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.OpLogEntry)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
types_.MergeFrom(from.types_);
if (from.name().size() > 0) {
name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from.has_code_def()) {
_internal_mutable_code_def()->::tensorflow::tfprof::CodeDef::MergeFrom(from._internal_code_def());
}
if (from.float_ops() != 0) {
_internal_set_float_ops(from._internal_float_ops());
}
}
void OpLogEntry::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.OpLogEntry)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void OpLogEntry::CopyFrom(const OpLogEntry& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.OpLogEntry)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool OpLogEntry::IsInitialized() const {
return true;
}
void OpLogEntry::InternalSwap(OpLogEntry* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
types_.InternalSwap(&other->types_);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
swap(code_def_, other->code_def_);
swap(float_ops_, other->float_ops_);
}
::PROTOBUF_NAMESPACE_ID::Metadata OpLogEntry::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
OpLogProto_IdToStringEntry_DoNotUse::OpLogProto_IdToStringEntry_DoNotUse() {}
OpLogProto_IdToStringEntry_DoNotUse::OpLogProto_IdToStringEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void OpLogProto_IdToStringEntry_DoNotUse::MergeFrom(const OpLogProto_IdToStringEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata OpLogProto_IdToStringEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void OpLogProto_IdToStringEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
void OpLogProto::InitAsDefaultInstance() {
}
class OpLogProto::_Internal {
public:
};
OpLogProto::OpLogProto()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.OpLogProto)
}
OpLogProto::OpLogProto(const OpLogProto& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
log_entries_(from.log_entries_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
id_to_string_.MergeFrom(from.id_to_string_);
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.OpLogProto)
}
void OpLogProto::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpLogProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
}
OpLogProto::~OpLogProto() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.OpLogProto)
SharedDtor();
}
void OpLogProto::SharedDtor() {
}
void OpLogProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const OpLogProto& OpLogProto::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpLogProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void OpLogProto::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.OpLogProto)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
log_entries_.Clear();
id_to_string_.Clear();
_internal_metadata_.Clear();
}
const char* OpLogProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// repeated .tensorflow.tfprof.OpLogEntry log_entries = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_log_entries(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
// map<int64, string> id_to_string = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&id_to_string_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* OpLogProto::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.OpLogProto)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .tensorflow.tfprof.OpLogEntry log_entries = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_log_entries_size()); i < n; i++) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessageToArray(1, this->_internal_log_entries(i), target, stream);
}
// map<int64, string> id_to_string = 2;
if (!this->_internal_id_to_string().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int64, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->second.data(), static_cast<int>(p->second.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.OpLogProto.IdToStringEntry.value");
}
};
if (stream->IsSerializationDeterministic() &&
this->_internal_id_to_string().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_id_to_string().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_iterator
it = this->_internal_id_to_string().begin();
it != this->_internal_id_to_string().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = OpLogProto_IdToStringEntry_DoNotUse::Funcs::InternalSerialize(2, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)].second));
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_iterator
it = this->_internal_id_to_string().begin();
it != this->_internal_id_to_string().end(); ++it) {
target = OpLogProto_IdToStringEntry_DoNotUse::Funcs::InternalSerialize(2, it->first, it->second, target, stream);
Utf8Check::Check(&(*it));
}
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.OpLogProto)
return target;
}
size_t OpLogProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.OpLogProto)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .tensorflow.tfprof.OpLogEntry log_entries = 1;
total_size += 1UL * this->_internal_log_entries_size();
for (const auto& msg : this->log_entries_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
// map<int64, string> id_to_string = 2;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_id_to_string_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_iterator
it = this->_internal_id_to_string().begin();
it != this->_internal_id_to_string().end(); ++it) {
total_size += OpLogProto_IdToStringEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void OpLogProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.OpLogProto)
GOOGLE_DCHECK_NE(&from, this);
const OpLogProto* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<OpLogProto>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.OpLogProto)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.OpLogProto)
MergeFrom(*source);
}
}
void OpLogProto::MergeFrom(const OpLogProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.OpLogProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
log_entries_.MergeFrom(from.log_entries_);
id_to_string_.MergeFrom(from.id_to_string_);
}
void OpLogProto::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.OpLogProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void OpLogProto::CopyFrom(const OpLogProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.OpLogProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool OpLogProto::IsInitialized() const {
return true;
}
void OpLogProto::InternalSwap(OpLogProto* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
log_entries_.InternalSwap(&other->log_entries_);
id_to_string_.Swap(&other->id_to_string_);
}
::PROTOBUF_NAMESPACE_ID::Metadata OpLogProto::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
ProfileProto_NodesEntry_DoNotUse::ProfileProto_NodesEntry_DoNotUse() {}
ProfileProto_NodesEntry_DoNotUse::ProfileProto_NodesEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileProto_NodesEntry_DoNotUse::MergeFrom(const ProfileProto_NodesEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileProto_NodesEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileProto_NodesEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ProfileProto_IdToStringEntry_DoNotUse::ProfileProto_IdToStringEntry_DoNotUse() {}
ProfileProto_IdToStringEntry_DoNotUse::ProfileProto_IdToStringEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileProto_IdToStringEntry_DoNotUse::MergeFrom(const ProfileProto_IdToStringEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileProto_IdToStringEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileProto_IdToStringEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
void ProfileProto::InitAsDefaultInstance() {
}
class ProfileProto::_Internal {
public:
};
ProfileProto::ProfileProto()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.ProfileProto)
}
ProfileProto::ProfileProto(const ProfileProto& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
steps_(from.steps_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
nodes_.MergeFrom(from.nodes_);
id_to_string_.MergeFrom(from.id_to_string_);
::memcpy(&has_trace_, &from.has_trace_,
static_cast<size_t>(reinterpret_cast<char*>(&miss_accelerator_stream_) -
reinterpret_cast<char*>(&has_trace_)) + sizeof(miss_accelerator_stream_));
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.ProfileProto)
}
void ProfileProto::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ProfileProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
::memset(&has_trace_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&miss_accelerator_stream_) -
reinterpret_cast<char*>(&has_trace_)) + sizeof(miss_accelerator_stream_));
}
ProfileProto::~ProfileProto() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.ProfileProto)
SharedDtor();
}
void ProfileProto::SharedDtor() {
}
void ProfileProto::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ProfileProto& ProfileProto::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ProfileProto_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void ProfileProto::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.ProfileProto)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
nodes_.Clear();
steps_.Clear();
id_to_string_.Clear();
::memset(&has_trace_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&miss_accelerator_stream_) -
reinterpret_cast<char*>(&has_trace_)) + sizeof(miss_accelerator_stream_));
_internal_metadata_.Clear();
}
const char* ProfileProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// map<int64, .tensorflow.tfprof.ProfileNode> nodes = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&nodes_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
// bool has_trace = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
has_trace_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// repeated int64 steps = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt64Parser(_internal_mutable_steps(), ptr, ctx);
CHK_(ptr);
} else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24) {
_internal_add_steps(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr));
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<int64, string> id_to_string = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&id_to_string_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr));
} else goto handle_unusual;
continue;
// bool miss_accelerator_stream = 5;
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
miss_accelerator_stream_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ProfileProto::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.ProfileProto)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// map<int64, .tensorflow.tfprof.ProfileNode> nodes = 1;
if (!this->_internal_nodes().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ProfileNode >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int64, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_nodes().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_nodes().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ProfileNode >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ProfileNode >::const_iterator
it = this->_internal_nodes().begin();
it != this->_internal_nodes().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileProto_NodesEntry_DoNotUse::Funcs::InternalSerialize(1, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ProfileNode >::const_iterator
it = this->_internal_nodes().begin();
it != this->_internal_nodes().end(); ++it) {
target = ProfileProto_NodesEntry_DoNotUse::Funcs::InternalSerialize(1, it->first, it->second, target, stream);
}
}
}
// bool has_trace = 2;
if (this->has_trace() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_has_trace(), target);
}
// repeated int64 steps = 3;
{
int byte_size = _steps_cached_byte_size_.load(std::memory_order_relaxed);
if (byte_size > 0) {
target = stream->WriteInt64Packed(
3, _internal_steps(), byte_size, target);
}
}
// map<int64, string> id_to_string = 4;
if (!this->_internal_id_to_string().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int64, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->second.data(), static_cast<int>(p->second.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ProfileProto.IdToStringEntry.value");
}
};
if (stream->IsSerializationDeterministic() &&
this->_internal_id_to_string().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_id_to_string().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_iterator
it = this->_internal_id_to_string().begin();
it != this->_internal_id_to_string().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileProto_IdToStringEntry_DoNotUse::Funcs::InternalSerialize(4, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)].second));
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_iterator
it = this->_internal_id_to_string().begin();
it != this->_internal_id_to_string().end(); ++it) {
target = ProfileProto_IdToStringEntry_DoNotUse::Funcs::InternalSerialize(4, it->first, it->second, target, stream);
Utf8Check::Check(&(*it));
}
}
}
// bool miss_accelerator_stream = 5;
if (this->miss_accelerator_stream() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_miss_accelerator_stream(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.ProfileProto)
return target;
}
size_t ProfileProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.ProfileProto)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// map<int64, .tensorflow.tfprof.ProfileNode> nodes = 1;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_nodes_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ProfileNode >::const_iterator
it = this->_internal_nodes().begin();
it != this->_internal_nodes().end(); ++it) {
total_size += ProfileProto_NodesEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// repeated int64 steps = 3;
{
size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
Int64Size(this->steps_);
if (data_size > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
static_cast<::PROTOBUF_NAMESPACE_ID::int32>(data_size));
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size);
_steps_cached_byte_size_.store(cached_size,
std::memory_order_relaxed);
total_size += data_size;
}
// map<int64, string> id_to_string = 4;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_id_to_string_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, std::string >::const_iterator
it = this->_internal_id_to_string().begin();
it != this->_internal_id_to_string().end(); ++it) {
total_size += ProfileProto_IdToStringEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// bool has_trace = 2;
if (this->has_trace() != 0) {
total_size += 1 + 1;
}
// bool miss_accelerator_stream = 5;
if (this->miss_accelerator_stream() != 0) {
total_size += 1 + 1;
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void ProfileProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.ProfileProto)
GOOGLE_DCHECK_NE(&from, this);
const ProfileProto* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<ProfileProto>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.ProfileProto)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.ProfileProto)
MergeFrom(*source);
}
}
void ProfileProto::MergeFrom(const ProfileProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.ProfileProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
nodes_.MergeFrom(from.nodes_);
steps_.MergeFrom(from.steps_);
id_to_string_.MergeFrom(from.id_to_string_);
if (from.has_trace() != 0) {
_internal_set_has_trace(from._internal_has_trace());
}
if (from.miss_accelerator_stream() != 0) {
_internal_set_miss_accelerator_stream(from._internal_miss_accelerator_stream());
}
}
void ProfileProto::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.ProfileProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ProfileProto::CopyFrom(const ProfileProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.ProfileProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ProfileProto::IsInitialized() const {
return true;
}
void ProfileProto::InternalSwap(ProfileProto* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
nodes_.Swap(&other->nodes_);
steps_.InternalSwap(&other->steps_);
id_to_string_.Swap(&other->id_to_string_);
swap(has_trace_, other->has_trace_);
swap(miss_accelerator_stream_, other->miss_accelerator_stream_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileProto::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
ProfileNode_InputsEntry_DoNotUse::ProfileNode_InputsEntry_DoNotUse() {}
ProfileNode_InputsEntry_DoNotUse::ProfileNode_InputsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileNode_InputsEntry_DoNotUse::MergeFrom(const ProfileNode_InputsEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode_InputsEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileNode_InputsEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ProfileNode_InputShapesEntry_DoNotUse::ProfileNode_InputShapesEntry_DoNotUse() {}
ProfileNode_InputShapesEntry_DoNotUse::ProfileNode_InputShapesEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileNode_InputShapesEntry_DoNotUse::MergeFrom(const ProfileNode_InputShapesEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode_InputShapesEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileNode_InputShapesEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ProfileNode_OutputsEntry_DoNotUse::ProfileNode_OutputsEntry_DoNotUse() {}
ProfileNode_OutputsEntry_DoNotUse::ProfileNode_OutputsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileNode_OutputsEntry_DoNotUse::MergeFrom(const ProfileNode_OutputsEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode_OutputsEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileNode_OutputsEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ProfileNode_OutputShapesEntry_DoNotUse::ProfileNode_OutputShapesEntry_DoNotUse() {}
ProfileNode_OutputShapesEntry_DoNotUse::ProfileNode_OutputShapesEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileNode_OutputShapesEntry_DoNotUse::MergeFrom(const ProfileNode_OutputShapesEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode_OutputShapesEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileNode_OutputShapesEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ProfileNode_SrcOutputIndexEntry_DoNotUse::ProfileNode_SrcOutputIndexEntry_DoNotUse() {}
ProfileNode_SrcOutputIndexEntry_DoNotUse::ProfileNode_SrcOutputIndexEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileNode_SrcOutputIndexEntry_DoNotUse::MergeFrom(const ProfileNode_SrcOutputIndexEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode_SrcOutputIndexEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileNode_SrcOutputIndexEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ProfileNode_AttrsEntry_DoNotUse::ProfileNode_AttrsEntry_DoNotUse() {}
ProfileNode_AttrsEntry_DoNotUse::ProfileNode_AttrsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileNode_AttrsEntry_DoNotUse::MergeFrom(const ProfileNode_AttrsEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode_AttrsEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileNode_AttrsEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ProfileNode_ExecsEntry_DoNotUse::ProfileNode_ExecsEntry_DoNotUse() {}
ProfileNode_ExecsEntry_DoNotUse::ProfileNode_ExecsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ProfileNode_ExecsEntry_DoNotUse::MergeFrom(const ProfileNode_ExecsEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode_ExecsEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ProfileNode_ExecsEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
void ProfileNode::InitAsDefaultInstance() {
::tensorflow::tfprof::_ProfileNode_default_instance_._instance.get_mutable()->trace_ = const_cast< ::tensorflow::tfprof::CodeDef*>(
::tensorflow::tfprof::CodeDef::internal_default_instance());
}
class ProfileNode::_Internal {
public:
static const ::tensorflow::tfprof::CodeDef& trace(const ProfileNode* msg);
};
const ::tensorflow::tfprof::CodeDef&
ProfileNode::_Internal::trace(const ProfileNode* msg) {
return *msg->trace_;
}
void ProfileNode::clear_attrs() {
attrs_.Clear();
}
ProfileNode::ProfileNode()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.ProfileNode)
}
ProfileNode::ProfileNode(const ProfileNode& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
shape_(from.shape_),
op_types_(from.op_types_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
inputs_.MergeFrom(from.inputs_);
outputs_.MergeFrom(from.outputs_);
attrs_.MergeFrom(from.attrs_);
execs_.MergeFrom(from.execs_);
src_output_index_.MergeFrom(from.src_output_index_);
output_shapes_.MergeFrom(from.output_shapes_);
input_shapes_.MergeFrom(from.input_shapes_);
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_name().empty()) {
name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_);
}
canonical_device_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_canonical_device().empty()) {
canonical_device_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.canonical_device_);
}
host_device_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_host_device().empty()) {
host_device_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.host_device_);
}
op_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_op().empty()) {
op_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.op_);
}
if (from._internal_has_trace()) {
trace_ = new ::tensorflow::tfprof::CodeDef(*from.trace_);
} else {
trace_ = nullptr;
}
::memcpy(&float_ops_, &from.float_ops_,
static_cast<size_t>(reinterpret_cast<char*>(&id_) -
reinterpret_cast<char*>(&float_ops_)) + sizeof(id_));
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.ProfileNode)
}
void ProfileNode::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
canonical_device_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
host_device_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
op_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
::memset(&trace_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&id_) -
reinterpret_cast<char*>(&trace_)) + sizeof(id_));
}
ProfileNode::~ProfileNode() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.ProfileNode)
SharedDtor();
}
void ProfileNode::SharedDtor() {
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
canonical_device_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
host_device_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
op_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete trace_;
}
void ProfileNode::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ProfileNode& ProfileNode::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ProfileNode_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void ProfileNode::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.ProfileNode)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
inputs_.Clear();
outputs_.Clear();
shape_.Clear();
op_types_.Clear();
attrs_.Clear();
execs_.Clear();
src_output_index_.Clear();
output_shapes_.Clear();
input_shapes_.Clear();
name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
canonical_device_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
host_device_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
op_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (GetArenaNoVirtual() == nullptr && trace_ != nullptr) {
delete trace_;
}
trace_ = nullptr;
::memset(&float_ops_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&id_) -
reinterpret_cast<char*>(&float_ops_)) + sizeof(id_));
_internal_metadata_.Clear();
}
const char* ProfileNode::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "tensorflow.tfprof.ProfileNode.name");
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<int32, int64> inputs = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&inputs_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
} else goto handle_unusual;
continue;
// map<int32, int64> outputs = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&outputs_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
} else goto handle_unusual;
continue;
// repeated int64 shape = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt64Parser(_internal_mutable_shape(), ptr, ctx);
CHK_(ptr);
} else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32) {
_internal_add_shape(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr));
CHK_(ptr);
} else goto handle_unusual;
continue;
// repeated string op_types = 5;
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) {
ptr -= 1;
do {
ptr += 1;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_add_op_types(), ptr, ctx, "tensorflow.tfprof.ProfileNode.op_types");
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr));
} else goto handle_unusual;
continue;
// string canonical_device = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_canonical_device(), ptr, ctx, "tensorflow.tfprof.ProfileNode.canonical_device");
CHK_(ptr);
} else goto handle_unusual;
continue;
// string host_device = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_host_device(), ptr, ctx, "tensorflow.tfprof.ProfileNode.host_device");
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 float_ops = 8;
case 8:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
float_ops_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// string op = 9;
case 9:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 74)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_op(), ptr, ctx, "tensorflow.tfprof.ProfileNode.op");
CHK_(ptr);
} else goto handle_unusual;
continue;
// .tensorflow.tfprof.CodeDef trace = 10;
case 10:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 82)) {
ptr = ctx->ParseMessage(_internal_mutable_trace(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<string, .tensorflow.AttrValue> attrs = 11;
case 11:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&attrs_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<90>(ptr));
} else goto handle_unusual;
continue;
// map<int64, .tensorflow.tfprof.ExecProfile> execs = 12;
case 12:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 98)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&execs_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<98>(ptr));
} else goto handle_unusual;
continue;
// int64 id = 13;
case 13:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 104)) {
id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<int64, int32> src_output_index = 14;
case 14:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 114)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&src_output_index_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<114>(ptr));
} else goto handle_unusual;
continue;
// map<int32, .tensorflow.tfprof.Tuple> output_shapes = 15;
case 15:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&output_shapes_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<122>(ptr));
} else goto handle_unusual;
continue;
// map<int32, .tensorflow.tfprof.Tuple> input_shapes = 16;
case 16:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 130)) {
ptr -= 2;
do {
ptr += 2;
ptr = ctx->ParseMessage(&input_shapes_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<130>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ProfileNode::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.ProfileNode)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ProfileNode.name");
target = stream->WriteStringMaybeAliased(
1, this->_internal_name(), target);
}
// map<int32, int64> inputs = 2;
if (!this->_internal_inputs().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int32, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_inputs().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_inputs().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_iterator
it = this->_internal_inputs().begin();
it != this->_internal_inputs().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileNode_InputsEntry_DoNotUse::Funcs::InternalSerialize(2, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_iterator
it = this->_internal_inputs().begin();
it != this->_internal_inputs().end(); ++it) {
target = ProfileNode_InputsEntry_DoNotUse::Funcs::InternalSerialize(2, it->first, it->second, target, stream);
}
}
}
// map<int32, int64> outputs = 3;
if (!this->_internal_outputs().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int32, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_outputs().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_outputs().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_iterator
it = this->_internal_outputs().begin();
it != this->_internal_outputs().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileNode_OutputsEntry_DoNotUse::Funcs::InternalSerialize(3, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_iterator
it = this->_internal_outputs().begin();
it != this->_internal_outputs().end(); ++it) {
target = ProfileNode_OutputsEntry_DoNotUse::Funcs::InternalSerialize(3, it->first, it->second, target, stream);
}
}
}
// repeated int64 shape = 4;
{
int byte_size = _shape_cached_byte_size_.load(std::memory_order_relaxed);
if (byte_size > 0) {
target = stream->WriteInt64Packed(
4, _internal_shape(), byte_size, target);
}
}
// repeated string op_types = 5;
for (int i = 0, n = this->_internal_op_types_size(); i < n; i++) {
const auto& s = this->_internal_op_types(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
s.data(), static_cast<int>(s.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ProfileNode.op_types");
target = stream->WriteString(5, s, target);
}
// string canonical_device = 6;
if (this->canonical_device().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_canonical_device().data(), static_cast<int>(this->_internal_canonical_device().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ProfileNode.canonical_device");
target = stream->WriteStringMaybeAliased(
6, this->_internal_canonical_device(), target);
}
// string host_device = 7;
if (this->host_device().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_host_device().data(), static_cast<int>(this->_internal_host_device().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ProfileNode.host_device");
target = stream->WriteStringMaybeAliased(
7, this->_internal_host_device(), target);
}
// int64 float_ops = 8;
if (this->float_ops() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(8, this->_internal_float_ops(), target);
}
// string op = 9;
if (this->op().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_op().data(), static_cast<int>(this->_internal_op().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ProfileNode.op");
target = stream->WriteStringMaybeAliased(
9, this->_internal_op(), target);
}
// .tensorflow.tfprof.CodeDef trace = 10;
if (this->has_trace()) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessageToArray(
10, _Internal::trace(this), target, stream);
}
// map<string, .tensorflow.AttrValue> attrs = 11;
if (!this->_internal_attrs().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::AttrValue >::const_pointer
ConstPtr;
typedef ConstPtr SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less;
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->first.data(), static_cast<int>(p->first.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ProfileNode.AttrsEntry.key");
}
};
if (stream->IsSerializationDeterministic() &&
this->_internal_attrs().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_attrs().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::AttrValue >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::AttrValue >::const_iterator
it = this->_internal_attrs().begin();
it != this->_internal_attrs().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileNode_AttrsEntry_DoNotUse::Funcs::InternalSerialize(11, items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second, target, stream);
Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)]));
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::AttrValue >::const_iterator
it = this->_internal_attrs().begin();
it != this->_internal_attrs().end(); ++it) {
target = ProfileNode_AttrsEntry_DoNotUse::Funcs::InternalSerialize(11, it->first, it->second, target, stream);
Utf8Check::Check(&(*it));
}
}
}
// map<int64, .tensorflow.tfprof.ExecProfile> execs = 12;
if (!this->_internal_execs().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ExecProfile >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int64, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_execs().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_execs().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ExecProfile >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ExecProfile >::const_iterator
it = this->_internal_execs().begin();
it != this->_internal_execs().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileNode_ExecsEntry_DoNotUse::Funcs::InternalSerialize(12, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ExecProfile >::const_iterator
it = this->_internal_execs().begin();
it != this->_internal_execs().end(); ++it) {
target = ProfileNode_ExecsEntry_DoNotUse::Funcs::InternalSerialize(12, it->first, it->second, target, stream);
}
}
}
// int64 id = 13;
if (this->id() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(13, this->_internal_id(), target);
}
// map<int64, int32> src_output_index = 14;
if (!this->_internal_src_output_index().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::PROTOBUF_NAMESPACE_ID::int32 >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int64, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_src_output_index().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_src_output_index().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::PROTOBUF_NAMESPACE_ID::int32 >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::PROTOBUF_NAMESPACE_ID::int32 >::const_iterator
it = this->_internal_src_output_index().begin();
it != this->_internal_src_output_index().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileNode_SrcOutputIndexEntry_DoNotUse::Funcs::InternalSerialize(14, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::PROTOBUF_NAMESPACE_ID::int32 >::const_iterator
it = this->_internal_src_output_index().begin();
it != this->_internal_src_output_index().end(); ++it) {
target = ProfileNode_SrcOutputIndexEntry_DoNotUse::Funcs::InternalSerialize(14, it->first, it->second, target, stream);
}
}
}
// map<int32, .tensorflow.tfprof.Tuple> output_shapes = 15;
if (!this->_internal_output_shapes().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int32, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_output_shapes().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_output_shapes().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_iterator
it = this->_internal_output_shapes().begin();
it != this->_internal_output_shapes().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileNode_OutputShapesEntry_DoNotUse::Funcs::InternalSerialize(15, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_iterator
it = this->_internal_output_shapes().begin();
it != this->_internal_output_shapes().end(); ++it) {
target = ProfileNode_OutputShapesEntry_DoNotUse::Funcs::InternalSerialize(15, it->first, it->second, target, stream);
}
}
}
// map<int32, .tensorflow.tfprof.Tuple> input_shapes = 16;
if (!this->_internal_input_shapes().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int32, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_input_shapes().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_input_shapes().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_iterator
it = this->_internal_input_shapes().begin();
it != this->_internal_input_shapes().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ProfileNode_InputShapesEntry_DoNotUse::Funcs::InternalSerialize(16, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_iterator
it = this->_internal_input_shapes().begin();
it != this->_internal_input_shapes().end(); ++it) {
target = ProfileNode_InputShapesEntry_DoNotUse::Funcs::InternalSerialize(16, it->first, it->second, target, stream);
}
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.ProfileNode)
return target;
}
size_t ProfileNode::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.ProfileNode)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// map<int32, int64> inputs = 2;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_inputs_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_iterator
it = this->_internal_inputs().begin();
it != this->_internal_inputs().end(); ++it) {
total_size += ProfileNode_InputsEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// map<int32, int64> outputs = 3;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_outputs_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::PROTOBUF_NAMESPACE_ID::int64 >::const_iterator
it = this->_internal_outputs().begin();
it != this->_internal_outputs().end(); ++it) {
total_size += ProfileNode_OutputsEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// repeated int64 shape = 4;
{
size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
Int64Size(this->shape_);
if (data_size > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
static_cast<::PROTOBUF_NAMESPACE_ID::int32>(data_size));
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size);
_shape_cached_byte_size_.store(cached_size,
std::memory_order_relaxed);
total_size += data_size;
}
// repeated string op_types = 5;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(op_types_.size());
for (int i = 0, n = op_types_.size(); i < n; i++) {
total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
op_types_.Get(i));
}
// map<string, .tensorflow.AttrValue> attrs = 11;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_attrs_size());
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::AttrValue >::const_iterator
it = this->_internal_attrs().begin();
it != this->_internal_attrs().end(); ++it) {
total_size += ProfileNode_AttrsEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// map<int64, .tensorflow.tfprof.ExecProfile> execs = 12;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_execs_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::tensorflow::tfprof::ExecProfile >::const_iterator
it = this->_internal_execs().begin();
it != this->_internal_execs().end(); ++it) {
total_size += ProfileNode_ExecsEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// map<int64, int32> src_output_index = 14;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_src_output_index_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int64, ::PROTOBUF_NAMESPACE_ID::int32 >::const_iterator
it = this->_internal_src_output_index().begin();
it != this->_internal_src_output_index().end(); ++it) {
total_size += ProfileNode_SrcOutputIndexEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// map<int32, .tensorflow.tfprof.Tuple> output_shapes = 15;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_output_shapes_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_iterator
it = this->_internal_output_shapes().begin();
it != this->_internal_output_shapes().end(); ++it) {
total_size += ProfileNode_OutputShapesEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// map<int32, .tensorflow.tfprof.Tuple> input_shapes = 16;
total_size += 2 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_input_shapes_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Tuple >::const_iterator
it = this->_internal_input_shapes().begin();
it != this->_internal_input_shapes().end(); ++it) {
total_size += ProfileNode_InputShapesEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// string name = 1;
if (this->name().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name());
}
// string canonical_device = 6;
if (this->canonical_device().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_canonical_device());
}
// string host_device = 7;
if (this->host_device().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_host_device());
}
// string op = 9;
if (this->op().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_op());
}
// .tensorflow.tfprof.CodeDef trace = 10;
if (this->has_trace()) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*trace_);
}
// int64 float_ops = 8;
if (this->float_ops() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_float_ops());
}
// int64 id = 13;
if (this->id() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_id());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void ProfileNode::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.ProfileNode)
GOOGLE_DCHECK_NE(&from, this);
const ProfileNode* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<ProfileNode>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.ProfileNode)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.ProfileNode)
MergeFrom(*source);
}
}
void ProfileNode::MergeFrom(const ProfileNode& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.ProfileNode)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
inputs_.MergeFrom(from.inputs_);
outputs_.MergeFrom(from.outputs_);
shape_.MergeFrom(from.shape_);
op_types_.MergeFrom(from.op_types_);
attrs_.MergeFrom(from.attrs_);
execs_.MergeFrom(from.execs_);
src_output_index_.MergeFrom(from.src_output_index_);
output_shapes_.MergeFrom(from.output_shapes_);
input_shapes_.MergeFrom(from.input_shapes_);
if (from.name().size() > 0) {
name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from.canonical_device().size() > 0) {
canonical_device_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.canonical_device_);
}
if (from.host_device().size() > 0) {
host_device_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.host_device_);
}
if (from.op().size() > 0) {
op_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.op_);
}
if (from.has_trace()) {
_internal_mutable_trace()->::tensorflow::tfprof::CodeDef::MergeFrom(from._internal_trace());
}
if (from.float_ops() != 0) {
_internal_set_float_ops(from._internal_float_ops());
}
if (from.id() != 0) {
_internal_set_id(from._internal_id());
}
}
void ProfileNode::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.ProfileNode)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ProfileNode::CopyFrom(const ProfileNode& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.ProfileNode)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ProfileNode::IsInitialized() const {
return true;
}
void ProfileNode::InternalSwap(ProfileNode* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
inputs_.Swap(&other->inputs_);
outputs_.Swap(&other->outputs_);
shape_.InternalSwap(&other->shape_);
op_types_.InternalSwap(&other->op_types_);
attrs_.Swap(&other->attrs_);
execs_.Swap(&other->execs_);
src_output_index_.Swap(&other->src_output_index_);
output_shapes_.Swap(&other->output_shapes_);
input_shapes_.Swap(&other->input_shapes_);
name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
canonical_device_.Swap(&other->canonical_device_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
host_device_.Swap(&other->host_device_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
op_.Swap(&other->op_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
swap(trace_, other->trace_);
swap(float_ops_, other->float_ops_);
swap(id_, other->id_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ProfileNode::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
ExecProfile_AcceleratorExecsEntry_DoNotUse::ExecProfile_AcceleratorExecsEntry_DoNotUse() {}
ExecProfile_AcceleratorExecsEntry_DoNotUse::ExecProfile_AcceleratorExecsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ExecProfile_AcceleratorExecsEntry_DoNotUse::MergeFrom(const ExecProfile_AcceleratorExecsEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ExecProfile_AcceleratorExecsEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ExecProfile_AcceleratorExecsEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
ExecProfile_CpuExecsEntry_DoNotUse::ExecProfile_CpuExecsEntry_DoNotUse() {}
ExecProfile_CpuExecsEntry_DoNotUse::ExecProfile_CpuExecsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ExecProfile_CpuExecsEntry_DoNotUse::MergeFrom(const ExecProfile_CpuExecsEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ExecProfile_CpuExecsEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ExecProfile_CpuExecsEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
void ExecProfile::InitAsDefaultInstance() {
}
class ExecProfile::_Internal {
public:
};
void ExecProfile::clear_allocations() {
allocations_.Clear();
}
ExecProfile::ExecProfile()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.ExecProfile)
}
ExecProfile::ExecProfile(const ExecProfile& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
devices_(from.devices_),
memory_execs_(from.memory_execs_),
allocations_(from.allocations_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
accelerator_execs_.MergeFrom(from.accelerator_execs_);
cpu_execs_.MergeFrom(from.cpu_execs_);
::memcpy(&run_count_, &from.run_count_,
static_cast<size_t>(reinterpret_cast<char*>(&latest_end_micros_) -
reinterpret_cast<char*>(&run_count_)) + sizeof(latest_end_micros_));
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.ExecProfile)
}
void ExecProfile::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
::memset(&run_count_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&latest_end_micros_) -
reinterpret_cast<char*>(&run_count_)) + sizeof(latest_end_micros_));
}
ExecProfile::~ExecProfile() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.ExecProfile)
SharedDtor();
}
void ExecProfile::SharedDtor() {
}
void ExecProfile::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ExecProfile& ExecProfile::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ExecProfile_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void ExecProfile::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.ExecProfile)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
accelerator_execs_.Clear();
cpu_execs_.Clear();
devices_.Clear();
memory_execs_.Clear();
allocations_.Clear();
::memset(&run_count_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&latest_end_micros_) -
reinterpret_cast<char*>(&run_count_)) + sizeof(latest_end_micros_));
_internal_metadata_.Clear();
}
const char* ExecProfile::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// int64 run_count = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
run_count_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 all_start_micros = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
all_start_micros_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 latest_end_micros = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
latest_end_micros_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<string, .tensorflow.tfprof.ExecTime> accelerator_execs = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&accelerator_execs_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr));
} else goto handle_unusual;
continue;
// map<string, .tensorflow.tfprof.ExecTime> cpu_execs = 5;
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&cpu_execs_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr));
} else goto handle_unusual;
continue;
// repeated string devices = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_add_devices(), ptr, ctx, "tensorflow.tfprof.ExecProfile.devices");
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
} else goto handle_unusual;
continue;
// repeated .tensorflow.tfprof.ExecMemory memory_execs = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_memory_execs(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr));
} else goto handle_unusual;
continue;
// repeated .tensorflow.AllocationRecord allocations = 11;
case 11:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_allocations(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<90>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ExecProfile::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.ExecProfile)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 run_count = 1;
if (this->run_count() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_run_count(), target);
}
// int64 all_start_micros = 2;
if (this->all_start_micros() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(2, this->_internal_all_start_micros(), target);
}
// int64 latest_end_micros = 3;
if (this->latest_end_micros() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(3, this->_internal_latest_end_micros(), target);
}
// map<string, .tensorflow.tfprof.ExecTime> accelerator_execs = 4;
if (!this->_internal_accelerator_execs().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_pointer
ConstPtr;
typedef ConstPtr SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less;
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->first.data(), static_cast<int>(p->first.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ExecProfile.AcceleratorExecsEntry.key");
}
};
if (stream->IsSerializationDeterministic() &&
this->_internal_accelerator_execs().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_accelerator_execs().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_iterator
it = this->_internal_accelerator_execs().begin();
it != this->_internal_accelerator_execs().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ExecProfile_AcceleratorExecsEntry_DoNotUse::Funcs::InternalSerialize(4, items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second, target, stream);
Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)]));
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_iterator
it = this->_internal_accelerator_execs().begin();
it != this->_internal_accelerator_execs().end(); ++it) {
target = ExecProfile_AcceleratorExecsEntry_DoNotUse::Funcs::InternalSerialize(4, it->first, it->second, target, stream);
Utf8Check::Check(&(*it));
}
}
}
// map<string, .tensorflow.tfprof.ExecTime> cpu_execs = 5;
if (!this->_internal_cpu_execs().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_pointer
ConstPtr;
typedef ConstPtr SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less;
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->first.data(), static_cast<int>(p->first.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ExecProfile.CpuExecsEntry.key");
}
};
if (stream->IsSerializationDeterministic() &&
this->_internal_cpu_execs().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_cpu_execs().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_iterator
it = this->_internal_cpu_execs().begin();
it != this->_internal_cpu_execs().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ExecProfile_CpuExecsEntry_DoNotUse::Funcs::InternalSerialize(5, items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second, target, stream);
Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)]));
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_iterator
it = this->_internal_cpu_execs().begin();
it != this->_internal_cpu_execs().end(); ++it) {
target = ExecProfile_CpuExecsEntry_DoNotUse::Funcs::InternalSerialize(5, it->first, it->second, target, stream);
Utf8Check::Check(&(*it));
}
}
}
// repeated string devices = 6;
for (int i = 0, n = this->_internal_devices_size(); i < n; i++) {
const auto& s = this->_internal_devices(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
s.data(), static_cast<int>(s.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"tensorflow.tfprof.ExecProfile.devices");
target = stream->WriteString(6, s, target);
}
// repeated .tensorflow.tfprof.ExecMemory memory_execs = 7;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_memory_execs_size()); i < n; i++) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessageToArray(7, this->_internal_memory_execs(i), target, stream);
}
// repeated .tensorflow.AllocationRecord allocations = 11;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_allocations_size()); i < n; i++) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessageToArray(11, this->_internal_allocations(i), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.ExecProfile)
return target;
}
size_t ExecProfile::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.ExecProfile)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// map<string, .tensorflow.tfprof.ExecTime> accelerator_execs = 4;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_accelerator_execs_size());
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_iterator
it = this->_internal_accelerator_execs().begin();
it != this->_internal_accelerator_execs().end(); ++it) {
total_size += ExecProfile_AcceleratorExecsEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// map<string, .tensorflow.tfprof.ExecTime> cpu_execs = 5;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_cpu_execs_size());
for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::tensorflow::tfprof::ExecTime >::const_iterator
it = this->_internal_cpu_execs().begin();
it != this->_internal_cpu_execs().end(); ++it) {
total_size += ExecProfile_CpuExecsEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// repeated string devices = 6;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(devices_.size());
for (int i = 0, n = devices_.size(); i < n; i++) {
total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
devices_.Get(i));
}
// repeated .tensorflow.tfprof.ExecMemory memory_execs = 7;
total_size += 1UL * this->_internal_memory_execs_size();
for (const auto& msg : this->memory_execs_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
// repeated .tensorflow.AllocationRecord allocations = 11;
total_size += 1UL * this->_internal_allocations_size();
for (const auto& msg : this->allocations_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
// int64 run_count = 1;
if (this->run_count() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_run_count());
}
// int64 all_start_micros = 2;
if (this->all_start_micros() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_all_start_micros());
}
// int64 latest_end_micros = 3;
if (this->latest_end_micros() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_latest_end_micros());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void ExecProfile::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.ExecProfile)
GOOGLE_DCHECK_NE(&from, this);
const ExecProfile* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<ExecProfile>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.ExecProfile)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.ExecProfile)
MergeFrom(*source);
}
}
void ExecProfile::MergeFrom(const ExecProfile& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.ExecProfile)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
accelerator_execs_.MergeFrom(from.accelerator_execs_);
cpu_execs_.MergeFrom(from.cpu_execs_);
devices_.MergeFrom(from.devices_);
memory_execs_.MergeFrom(from.memory_execs_);
allocations_.MergeFrom(from.allocations_);
if (from.run_count() != 0) {
_internal_set_run_count(from._internal_run_count());
}
if (from.all_start_micros() != 0) {
_internal_set_all_start_micros(from._internal_all_start_micros());
}
if (from.latest_end_micros() != 0) {
_internal_set_latest_end_micros(from._internal_latest_end_micros());
}
}
void ExecProfile::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.ExecProfile)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ExecProfile::CopyFrom(const ExecProfile& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.ExecProfile)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ExecProfile::IsInitialized() const {
return true;
}
void ExecProfile::InternalSwap(ExecProfile* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
accelerator_execs_.Swap(&other->accelerator_execs_);
cpu_execs_.Swap(&other->cpu_execs_);
devices_.InternalSwap(&other->devices_);
memory_execs_.InternalSwap(&other->memory_execs_);
allocations_.InternalSwap(&other->allocations_);
swap(run_count_, other->run_count_);
swap(all_start_micros_, other->all_start_micros_);
swap(latest_end_micros_, other->latest_end_micros_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ExecProfile::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void ExecTime::InitAsDefaultInstance() {
}
class ExecTime::_Internal {
public:
};
ExecTime::ExecTime()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.ExecTime)
}
ExecTime::ExecTime(const ExecTime& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
times_(from.times_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.ExecTime)
}
void ExecTime::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
}
ExecTime::~ExecTime() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.ExecTime)
SharedDtor();
}
void ExecTime::SharedDtor() {
}
void ExecTime::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ExecTime& ExecTime::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ExecTime_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void ExecTime::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.ExecTime)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
times_.Clear();
_internal_metadata_.Clear();
}
const char* ExecTime::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// repeated .tensorflow.tfprof.Tuple times = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_times(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ExecTime::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.ExecTime)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .tensorflow.tfprof.Tuple times = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_times_size()); i < n; i++) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessageToArray(1, this->_internal_times(i), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.ExecTime)
return target;
}
size_t ExecTime::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.ExecTime)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .tensorflow.tfprof.Tuple times = 1;
total_size += 1UL * this->_internal_times_size();
for (const auto& msg : this->times_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void ExecTime::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.ExecTime)
GOOGLE_DCHECK_NE(&from, this);
const ExecTime* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<ExecTime>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.ExecTime)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.ExecTime)
MergeFrom(*source);
}
}
void ExecTime::MergeFrom(const ExecTime& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.ExecTime)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
times_.MergeFrom(from.times_);
}
void ExecTime::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.ExecTime)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ExecTime::CopyFrom(const ExecTime& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.ExecTime)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ExecTime::IsInitialized() const {
return true;
}
void ExecTime::InternalSwap(ExecTime* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
times_.InternalSwap(&other->times_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ExecTime::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
ExecMemory_OutputMemoryEntry_DoNotUse::ExecMemory_OutputMemoryEntry_DoNotUse() {}
ExecMemory_OutputMemoryEntry_DoNotUse::ExecMemory_OutputMemoryEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void ExecMemory_OutputMemoryEntry_DoNotUse::MergeFrom(const ExecMemory_OutputMemoryEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata ExecMemory_OutputMemoryEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void ExecMemory_OutputMemoryEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
void ExecMemory::InitAsDefaultInstance() {
}
class ExecMemory::_Internal {
public:
};
ExecMemory::ExecMemory()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.ExecMemory)
}
ExecMemory::ExecMemory(const ExecMemory& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
output_memory_.MergeFrom(from.output_memory_);
::memcpy(&memory_micros_, &from.memory_micros_,
static_cast<size_t>(reinterpret_cast<char*>(&allocator_bytes_in_use_) -
reinterpret_cast<char*>(&memory_micros_)) + sizeof(allocator_bytes_in_use_));
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.ExecMemory)
}
void ExecMemory::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
::memset(&memory_micros_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&allocator_bytes_in_use_) -
reinterpret_cast<char*>(&memory_micros_)) + sizeof(allocator_bytes_in_use_));
}
ExecMemory::~ExecMemory() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.ExecMemory)
SharedDtor();
}
void ExecMemory::SharedDtor() {
}
void ExecMemory::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ExecMemory& ExecMemory::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ExecMemory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void ExecMemory::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.ExecMemory)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
output_memory_.Clear();
::memset(&memory_micros_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&allocator_bytes_in_use_) -
reinterpret_cast<char*>(&memory_micros_)) + sizeof(allocator_bytes_in_use_));
_internal_metadata_.Clear();
}
const char* ExecMemory::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// int64 memory_micros = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
memory_micros_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 host_temp_bytes = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
host_temp_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 host_persistent_bytes = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
host_persistent_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 accelerator_temp_bytes = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
accelerator_temp_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 accelerator_persistent_bytes = 5;
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
accelerator_persistent_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 requested_bytes = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
requested_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 peak_bytes = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
peak_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 residual_bytes = 8;
case 8:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
residual_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 output_bytes = 9;
case 9:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 72)) {
output_bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// int64 allocator_bytes_in_use = 10;
case 10:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) {
allocator_bytes_in_use_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<int32, .tensorflow.tfprof.Memory> output_memory = 11;
case 11:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&output_memory_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<90>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ExecMemory::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.ExecMemory)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 memory_micros = 1;
if (this->memory_micros() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_memory_micros(), target);
}
// int64 host_temp_bytes = 2;
if (this->host_temp_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(2, this->_internal_host_temp_bytes(), target);
}
// int64 host_persistent_bytes = 3;
if (this->host_persistent_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(3, this->_internal_host_persistent_bytes(), target);
}
// int64 accelerator_temp_bytes = 4;
if (this->accelerator_temp_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(4, this->_internal_accelerator_temp_bytes(), target);
}
// int64 accelerator_persistent_bytes = 5;
if (this->accelerator_persistent_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(5, this->_internal_accelerator_persistent_bytes(), target);
}
// int64 requested_bytes = 6;
if (this->requested_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(6, this->_internal_requested_bytes(), target);
}
// int64 peak_bytes = 7;
if (this->peak_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(7, this->_internal_peak_bytes(), target);
}
// int64 residual_bytes = 8;
if (this->residual_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(8, this->_internal_residual_bytes(), target);
}
// int64 output_bytes = 9;
if (this->output_bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(9, this->_internal_output_bytes(), target);
}
// int64 allocator_bytes_in_use = 10;
if (this->allocator_bytes_in_use() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(10, this->_internal_allocator_bytes_in_use(), target);
}
// map<int32, .tensorflow.tfprof.Memory> output_memory = 11;
if (!this->_internal_output_memory().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Memory >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int32, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
if (stream->IsSerializationDeterministic() &&
this->_internal_output_memory().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_output_memory().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Memory >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Memory >::const_iterator
it = this->_internal_output_memory().begin();
it != this->_internal_output_memory().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = ExecMemory_OutputMemoryEntry_DoNotUse::Funcs::InternalSerialize(11, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Memory >::const_iterator
it = this->_internal_output_memory().begin();
it != this->_internal_output_memory().end(); ++it) {
target = ExecMemory_OutputMemoryEntry_DoNotUse::Funcs::InternalSerialize(11, it->first, it->second, target, stream);
}
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.ExecMemory)
return target;
}
size_t ExecMemory::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.ExecMemory)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// map<int32, .tensorflow.tfprof.Memory> output_memory = 11;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_output_memory_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, ::tensorflow::tfprof::Memory >::const_iterator
it = this->_internal_output_memory().begin();
it != this->_internal_output_memory().end(); ++it) {
total_size += ExecMemory_OutputMemoryEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// int64 memory_micros = 1;
if (this->memory_micros() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_memory_micros());
}
// int64 host_temp_bytes = 2;
if (this->host_temp_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_host_temp_bytes());
}
// int64 host_persistent_bytes = 3;
if (this->host_persistent_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_host_persistent_bytes());
}
// int64 accelerator_temp_bytes = 4;
if (this->accelerator_temp_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_accelerator_temp_bytes());
}
// int64 accelerator_persistent_bytes = 5;
if (this->accelerator_persistent_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_accelerator_persistent_bytes());
}
// int64 requested_bytes = 6;
if (this->requested_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_requested_bytes());
}
// int64 peak_bytes = 7;
if (this->peak_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_peak_bytes());
}
// int64 residual_bytes = 8;
if (this->residual_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_residual_bytes());
}
// int64 output_bytes = 9;
if (this->output_bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_output_bytes());
}
// int64 allocator_bytes_in_use = 10;
if (this->allocator_bytes_in_use() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_allocator_bytes_in_use());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void ExecMemory::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.ExecMemory)
GOOGLE_DCHECK_NE(&from, this);
const ExecMemory* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<ExecMemory>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.ExecMemory)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.ExecMemory)
MergeFrom(*source);
}
}
void ExecMemory::MergeFrom(const ExecMemory& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.ExecMemory)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
output_memory_.MergeFrom(from.output_memory_);
if (from.memory_micros() != 0) {
_internal_set_memory_micros(from._internal_memory_micros());
}
if (from.host_temp_bytes() != 0) {
_internal_set_host_temp_bytes(from._internal_host_temp_bytes());
}
if (from.host_persistent_bytes() != 0) {
_internal_set_host_persistent_bytes(from._internal_host_persistent_bytes());
}
if (from.accelerator_temp_bytes() != 0) {
_internal_set_accelerator_temp_bytes(from._internal_accelerator_temp_bytes());
}
if (from.accelerator_persistent_bytes() != 0) {
_internal_set_accelerator_persistent_bytes(from._internal_accelerator_persistent_bytes());
}
if (from.requested_bytes() != 0) {
_internal_set_requested_bytes(from._internal_requested_bytes());
}
if (from.peak_bytes() != 0) {
_internal_set_peak_bytes(from._internal_peak_bytes());
}
if (from.residual_bytes() != 0) {
_internal_set_residual_bytes(from._internal_residual_bytes());
}
if (from.output_bytes() != 0) {
_internal_set_output_bytes(from._internal_output_bytes());
}
if (from.allocator_bytes_in_use() != 0) {
_internal_set_allocator_bytes_in_use(from._internal_allocator_bytes_in_use());
}
}
void ExecMemory::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.ExecMemory)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ExecMemory::CopyFrom(const ExecMemory& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.ExecMemory)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ExecMemory::IsInitialized() const {
return true;
}
void ExecMemory::InternalSwap(ExecMemory* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
output_memory_.Swap(&other->output_memory_);
swap(memory_micros_, other->memory_micros_);
swap(host_temp_bytes_, other->host_temp_bytes_);
swap(host_persistent_bytes_, other->host_persistent_bytes_);
swap(accelerator_temp_bytes_, other->accelerator_temp_bytes_);
swap(accelerator_persistent_bytes_, other->accelerator_persistent_bytes_);
swap(requested_bytes_, other->requested_bytes_);
swap(peak_bytes_, other->peak_bytes_);
swap(residual_bytes_, other->residual_bytes_);
swap(output_bytes_, other->output_bytes_);
swap(allocator_bytes_in_use_, other->allocator_bytes_in_use_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ExecMemory::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void Tuple::InitAsDefaultInstance() {
}
class Tuple::_Internal {
public:
};
Tuple::Tuple()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.Tuple)
}
Tuple::Tuple(const Tuple& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
int64_values_(from.int64_values_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.Tuple)
}
void Tuple::SharedCtor() {
}
Tuple::~Tuple() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.Tuple)
SharedDtor();
}
void Tuple::SharedDtor() {
}
void Tuple::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const Tuple& Tuple::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Tuple_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void Tuple::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.Tuple)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
int64_values_.Clear();
_internal_metadata_.Clear();
}
const char* Tuple::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// repeated int64 int64_values = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt64Parser(_internal_mutable_int64_values(), ptr, ctx);
CHK_(ptr);
} else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8) {
_internal_add_int64_values(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr));
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* Tuple::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.Tuple)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated int64 int64_values = 1;
{
int byte_size = _int64_values_cached_byte_size_.load(std::memory_order_relaxed);
if (byte_size > 0) {
target = stream->WriteInt64Packed(
1, _internal_int64_values(), byte_size, target);
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.Tuple)
return target;
}
size_t Tuple::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.Tuple)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated int64 int64_values = 1;
{
size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
Int64Size(this->int64_values_);
if (data_size > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
static_cast<::PROTOBUF_NAMESPACE_ID::int32>(data_size));
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size);
_int64_values_cached_byte_size_.store(cached_size,
std::memory_order_relaxed);
total_size += data_size;
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void Tuple::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.Tuple)
GOOGLE_DCHECK_NE(&from, this);
const Tuple* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Tuple>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.Tuple)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.Tuple)
MergeFrom(*source);
}
}
void Tuple::MergeFrom(const Tuple& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.Tuple)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
int64_values_.MergeFrom(from.int64_values_);
}
void Tuple::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.Tuple)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Tuple::CopyFrom(const Tuple& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.Tuple)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Tuple::IsInitialized() const {
return true;
}
void Tuple::InternalSwap(Tuple* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
int64_values_.InternalSwap(&other->int64_values_);
}
::PROTOBUF_NAMESPACE_ID::Metadata Tuple::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void Memory::InitAsDefaultInstance() {
}
class Memory::_Internal {
public:
};
Memory::Memory()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:tensorflow.tfprof.Memory)
}
Memory::Memory(const Memory& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
::memcpy(&bytes_, &from.bytes_,
static_cast<size_t>(reinterpret_cast<char*>(&ptr_) -
reinterpret_cast<char*>(&bytes_)) + sizeof(ptr_));
// @@protoc_insertion_point(copy_constructor:tensorflow.tfprof.Memory)
}
void Memory::SharedCtor() {
::memset(&bytes_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&ptr_) -
reinterpret_cast<char*>(&bytes_)) + sizeof(ptr_));
}
Memory::~Memory() {
// @@protoc_insertion_point(destructor:tensorflow.tfprof.Memory)
SharedDtor();
}
void Memory::SharedDtor() {
}
void Memory::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const Memory& Memory::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Memory_tensorflow_2fcore_2fprofiler_2ftfprof_5flog_2eproto.base);
return *internal_default_instance();
}
void Memory::Clear() {
// @@protoc_insertion_point(message_clear_start:tensorflow.tfprof.Memory)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
::memset(&bytes_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&ptr_) -
reinterpret_cast<char*>(&bytes_)) + sizeof(ptr_));
_internal_metadata_.Clear();
}
const char* Memory::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// int64 bytes = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
bytes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// uint64 ptr = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
ptr_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* Memory::InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tensorflow.tfprof.Memory)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 bytes = 1;
if (this->bytes() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_bytes(), target);
}
// uint64 ptr = 2;
if (this->ptr() != 0) {
stream->EnsureSpace(&target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(2, this->_internal_ptr(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tensorflow.tfprof.Memory)
return target;
}
size_t Memory::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tensorflow.tfprof.Memory)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// int64 bytes = 1;
if (this->bytes() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size(
this->_internal_bytes());
}
// uint64 ptr = 2;
if (this->ptr() != 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
this->_internal_ptr());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void Memory::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:tensorflow.tfprof.Memory)
GOOGLE_DCHECK_NE(&from, this);
const Memory* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Memory>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.tfprof.Memory)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.tfprof.Memory)
MergeFrom(*source);
}
}
void Memory::MergeFrom(const Memory& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.tfprof.Memory)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.bytes() != 0) {
_internal_set_bytes(from._internal_bytes());
}
if (from.ptr() != 0) {
_internal_set_ptr(from._internal_ptr());
}
}
void Memory::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:tensorflow.tfprof.Memory)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Memory::CopyFrom(const Memory& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.tfprof.Memory)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Memory::IsInitialized() const {
return true;
}
void Memory::InternalSwap(Memory* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(bytes_, other->bytes_);
swap(ptr_, other->ptr_);
}
::PROTOBUF_NAMESPACE_ID::Metadata Memory::GetMetadata() const {
return GetMetadataStatic();
}
// @@protoc_insertion_point(namespace_scope)
} // namespace tfprof
} // namespace tensorflow
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::CodeDef_Trace* Arena::CreateMaybeMessage< ::tensorflow::tfprof::CodeDef_Trace >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::CodeDef_Trace >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::CodeDef* Arena::CreateMaybeMessage< ::tensorflow::tfprof::CodeDef >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::CodeDef >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::OpLogEntry* Arena::CreateMaybeMessage< ::tensorflow::tfprof::OpLogEntry >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::OpLogEntry >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::OpLogProto_IdToStringEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::OpLogProto* Arena::CreateMaybeMessage< ::tensorflow::tfprof::OpLogProto >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::OpLogProto >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileProto_NodesEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileProto_IdToStringEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileProto* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileProto >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileProto >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode_InputsEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode_InputShapesEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode_OutputsEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode_OutputShapesEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode_SrcOutputIndexEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode_AttrsEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode_ExecsEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ProfileNode* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ProfileNode >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ProfileNode >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ExecProfile_AcceleratorExecsEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ExecProfile_CpuExecsEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ExecProfile* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ExecProfile >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ExecProfile >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ExecTime* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ExecTime >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ExecTime >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ExecMemory_OutputMemoryEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::ExecMemory* Arena::CreateMaybeMessage< ::tensorflow::tfprof::ExecMemory >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::ExecMemory >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::Tuple* Arena::CreateMaybeMessage< ::tensorflow::tfprof::Tuple >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::Tuple >(arena);
}
template<> PROTOBUF_NOINLINE ::tensorflow::tfprof::Memory* Arena::CreateMaybeMessage< ::tensorflow::tfprof::Memory >(Arena* arena) {
return Arena::CreateInternal< ::tensorflow::tfprof::Memory >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 44.611703
| 243
| 0.736398
|
1250281649
|
bb5cabb75565a5bfda40797aa68518c687b0edc7
| 33,944
|
cpp
|
C++
|
frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params.cpp
|
chaoyangcui/aafwk_standard
|
6a1ba0b0aa175c709e7a0d684f89ebd41a006061
|
[
"Apache-2.0"
] | null | null | null |
frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params.cpp
|
chaoyangcui/aafwk_standard
|
6a1ba0b0aa175c709e7a0d684f89ebd41a006061
|
[
"Apache-2.0"
] | null | null | null |
frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params.cpp
|
chaoyangcui/aafwk_standard
|
6a1ba0b0aa175c709e7a0d684f89ebd41a006061
|
[
"Apache-2.0"
] | 1
|
2021-09-13T12:07:39.000Z
|
2021-09-13T12:07:39.000Z
|
/*
* Copyright (c) 2021 Huawei Device 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.
*/
#include "want_params.h"
#include "parcel.h"
#include "string_ex.h"
#include "ohos/aafwk/base/base_interfaces.h"
#include "ohos/aafwk/base/array_wrapper.h"
#include "ohos/aafwk/base/base_object.h"
#include "ohos/aafwk/base/bool_wrapper.h"
#include "ohos/aafwk/base/byte_wrapper.h"
#include "ohos/aafwk/base/short_wrapper.h"
#include "ohos/aafwk/base/int_wrapper.h"
#include "ohos/aafwk/base/long_wrapper.h"
#include "ohos/aafwk/base/float_wrapper.h"
#include "ohos/aafwk/base/double_wrapper.h"
#include "ohos/aafwk/base/string_wrapper.h"
#include "want_params_wrapper.h"
#include "ohos/aafwk/base/zchar_wrapper.h"
#include "app_log_wrapper.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace AAFwk {
std::string WantParams::GetStringByType(const sptr<IInterface> iIt, int typeId)
{
if (typeId == VALUE_TYPE_BOOLEAN) {
return static_cast<Boolean *>(IBoolean::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_BYTE) {
return static_cast<Byte *>(IByte::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_CHAR) {
return static_cast<Char *>(IChar::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_SHORT) {
return static_cast<Short *>(IShort::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_INT) {
return static_cast<Integer *>(IInteger::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_LONG) {
return static_cast<Long *>(ILong::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_FLOAT) {
return static_cast<Float *>(IFloat::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_DOUBLE) {
return static_cast<Double *>(IDouble::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_STRING) {
return static_cast<String *>(IString::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_ARRAY) {
return static_cast<Array *>(IArray::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_WANTPARAMS) {
return static_cast<WantParamWrapper *>(IWantParams::Query(iIt))->ToString();
} else {
return "";
}
return "";
}
template <typename T1, typename T2, typename T3>
static void SetNewArray(const AAFwk::InterfaceID &id, AAFwk::IArray *orgIArray, sptr<AAFwk::IArray> &ao);
/**
* @description: A constructor used to create an IntentParams instance by using the parameters of an existing
* IntentParams object.
* @param intentParams Indicates the existing IntentParams object.
*/
WantParams::WantParams(const WantParams &wantParams)
{
params_.clear();
NewParams(wantParams, *this);
}
// inner use function
bool WantParams::NewParams(const WantParams &source, WantParams &dest)
{
// Deep copy
for (auto it = source.params_.begin(); it != source.params_.end(); it++) {
sptr<IInterface> o = it->second;
if (IString::Query(o) != nullptr) {
dest.params_[it->first] = String::Box(String::Unbox(IString::Query(o)));
} else if (IBoolean::Query(o) != nullptr) {
dest.params_[it->first] = Boolean::Box(Boolean::Unbox(IBoolean::Query(o)));
} else if (IByte::Query(o) != nullptr) {
dest.params_[it->first] = Byte::Box(Byte::Unbox(IByte::Query(o)));
} else if (IChar::Query(o) != nullptr) {
dest.params_[it->first] = Char::Box(Char::Unbox(IChar::Query(o)));
} else if (IShort::Query(o) != nullptr) {
dest.params_[it->first] = Short::Box(Short::Unbox(IShort::Query(o)));
} else if (IInteger::Query(o) != nullptr) {
dest.params_[it->first] = Integer::Box(Integer::Unbox(IInteger::Query(o)));
} else if (ILong::Query(o) != nullptr) {
dest.params_[it->first] = Long::Box(Long::Unbox(ILong::Query(o)));
} else if (IFloat::Query(o) != nullptr) {
dest.params_[it->first] = Float::Box(Float::Unbox(IFloat::Query(o)));
} else if (IDouble::Query(o) != nullptr) {
dest.params_[it->first] = Double::Box(Double::Unbox(IDouble::Query(o)));
} else if (IWantParams::Query(o) != nullptr) {
WantParams newDest(WantParamWrapper::Unbox(IWantParams::Query(o)));
dest.params_[it->first] = WantParamWrapper::Box(newDest);
} else if (IArray::Query(o) != nullptr) {
sptr<IArray> destAO = nullptr;
if (!NewArrayData(IArray::Query(o), destAO)) {
continue;
}
dest.params_[it->first] = destAO;
}
}
return true;
} // namespace AAFwk
// inner use
bool WantParams::NewArrayData(IArray *source, sptr<IArray> &dest)
{
if (Array::IsBooleanArray(source)) {
SetNewArray<bool, AAFwk::Boolean, AAFwk::IBoolean>(AAFwk::g_IID_IBoolean, source, dest);
} else if (Array::IsCharArray(source)) {
SetNewArray<char, AAFwk::Char, AAFwk::IChar>(AAFwk::g_IID_IChar, source, dest);
} else if (Array::IsByteArray(source)) {
SetNewArray<byte, AAFwk::Byte, AAFwk::IByte>(AAFwk::g_IID_IByte, source, dest);
} else if (Array::IsShortArray(source)) {
SetNewArray<short, AAFwk::Short, AAFwk::IShort>(AAFwk::g_IID_IShort, source, dest);
} else if (Array::IsIntegerArray(source)) {
SetNewArray<int, AAFwk::Integer, AAFwk::IInteger>(AAFwk::g_IID_IInteger, source, dest);
} else if (Array::IsLongArray(source)) {
SetNewArray<long, AAFwk::Long, AAFwk::ILong>(AAFwk::g_IID_ILong, source, dest);
} else if (Array::IsFloatArray(source)) {
SetNewArray<float, AAFwk::Float, AAFwk::IFloat>(AAFwk::g_IID_IFloat, source, dest);
} else if (Array::IsDoubleArray(source)) {
SetNewArray<double, AAFwk::Double, AAFwk::IDouble>(AAFwk::g_IID_IDouble, source, dest);
} else if (Array::IsStringArray(source)) {
SetNewArray<std::string, AAFwk::String, AAFwk::IString>(AAFwk::g_IID_IString, source, dest);
} else {
return false;
}
if (dest == nullptr) {
return false;
}
return true;
}
/**
* @description: A WantParams used to
*
* @param intentParams Indicates the existing IntentParams object.
*/
WantParams &WantParams::operator=(const WantParams &other)
{
if (this != &other) {
params_.clear();
NewParams(other, *this);
}
return *this;
}
bool WantParams::operator==(const WantParams &other)
{
if (this->params_.size() != other.params_.size()) {
return false;
}
for (auto itthis : this->params_) {
auto itother = other.params_.find(itthis.first);
if (itother == other.params_.end()) {
return false;
}
if (!CompareInterface(itother->second, itthis.second, WantParams::GetDataType(itother->second))) {
return false;
}
}
return true;
}
#define GETWRAPDATATYPE(id, value, ret) \
do { \
if (value != nullptr && id::Query(value) != nullptr) { \
return ret; \
} else { \
break; \
} \
} while (0)
#define GETSPTRBYTYPE(type, typeid, typeClass, str) \
do { \
if (type == typeid) { \
return typeClass::Parse(str); \
} \
} while (0)
int WantParams::GetDataType(const sptr<IInterface> iIt)
{
GETWRAPDATATYPE(IBoolean, iIt, VALUE_TYPE_BOOLEAN);
GETWRAPDATATYPE(IByte, iIt, VALUE_TYPE_BYTE);
GETWRAPDATATYPE(IChar, iIt, VALUE_TYPE_CHAR);
GETWRAPDATATYPE(IShort, iIt, VALUE_TYPE_SHORT);
GETWRAPDATATYPE(IInteger, iIt, VALUE_TYPE_INT);
GETWRAPDATATYPE(ILong, iIt, VALUE_TYPE_LONG);
GETWRAPDATATYPE(IFloat, iIt, VALUE_TYPE_FLOAT);
GETWRAPDATATYPE(IDouble, iIt, VALUE_TYPE_DOUBLE);
GETWRAPDATATYPE(IString, iIt, VALUE_TYPE_STRING);
GETWRAPDATATYPE(IArray, iIt, VALUE_TYPE_ARRAY);
GETWRAPDATATYPE(IWantParams, iIt, VALUE_TYPE_WANTPARAMS);
return VALUE_TYPE_NULL;
}
sptr<IInterface> WantParams::GetInterfaceByType(int typeId, const std::string &value)
{
GETSPTRBYTYPE(VALUE_TYPE_BOOLEAN, typeId, Boolean, value);
GETSPTRBYTYPE(VALUE_TYPE_BYTE, typeId, Byte, value);
GETSPTRBYTYPE(VALUE_TYPE_CHAR, typeId, Char, value);
GETSPTRBYTYPE(VALUE_TYPE_SHORT, typeId, Short, value);
GETSPTRBYTYPE(VALUE_TYPE_INT, typeId, Integer, value);
GETSPTRBYTYPE(VALUE_TYPE_LONG, typeId, Long, value);
GETSPTRBYTYPE(VALUE_TYPE_FLOAT, typeId, Float, value);
GETSPTRBYTYPE(VALUE_TYPE_DOUBLE, typeId, Double, value);
GETSPTRBYTYPE(VALUE_TYPE_STRING, typeId, String, value);
GETSPTRBYTYPE(VALUE_TYPE_ARRAY, typeId, Array, value);
return nullptr;
}
bool WantParams::CompareInterface(const sptr<IInterface> iIt1, const sptr<IInterface> iIt2, int typeId)
{
bool flag = false;
switch (typeId) {
case VALUE_TYPE_BOOLEAN:
flag =
static_cast<Boolean *>(IBoolean::Query(iIt1))->Equals(*(static_cast<Boolean *>(IBoolean::Query(iIt1))));
break;
case VALUE_TYPE_BYTE:
flag = static_cast<Byte *>(IByte::Query(iIt1))->Equals(*(static_cast<Byte *>(IByte::Query(iIt1))));
break;
case VALUE_TYPE_CHAR:
flag = static_cast<Char *>(IChar::Query(iIt1))->Equals(*(static_cast<Char *>(IChar::Query(iIt1))));
break;
case VALUE_TYPE_SHORT:
flag = static_cast<Short *>(IShort::Query(iIt1))->Equals(*(static_cast<Short *>(IShort::Query(iIt1))));
break;
case VALUE_TYPE_INT:
flag =
static_cast<Integer *>(IInteger::Query(iIt1))->Equals(*(static_cast<Integer *>(IInteger::Query(iIt1))));
break;
case VALUE_TYPE_LONG:
flag = static_cast<Long *>(ILong::Query(iIt1))->Equals(*(static_cast<Long *>(ILong::Query(iIt1))));
break;
case VALUE_TYPE_FLOAT:
flag = static_cast<Float *>(IFloat::Query(iIt1))->Equals(*(static_cast<Float *>(IFloat::Query(iIt1))));
break;
case VALUE_TYPE_DOUBLE:
flag = static_cast<Double *>(IDouble::Query(iIt1))->Equals(*(static_cast<Double *>(IDouble::Query(iIt1))));
break;
case VALUE_TYPE_STRING:
flag = static_cast<String *>(IString::Query(iIt1))->Equals(*(static_cast<String *>(IString::Query(iIt1))));
break;
case VALUE_TYPE_ARRAY:
flag = static_cast<Array *>(IArray::Query(iIt1))->Equals(*(static_cast<Array *>(IArray::Query(iIt1))));
break;
case VALUE_TYPE_WANTPARAMS:
flag = static_cast<WantParamWrapper *>(IWantParams::Query(iIt1))
->Equals(*(static_cast<WantParamWrapper *>(IWantParams::Query(iIt1))));
break;
default:
break;
}
return flag;
}
/**
* @description: Sets a parameter in key-value pair format.
* @param key Indicates the key matching the parameter.
*/
void WantParams::SetParam(const std::string &key, IInterface *value)
{
params_[key] = value;
}
/**
* @description: Obtains the parameter value based on a given key.
* @param key Indicates the key matching the parameter.
* @return Returns the value matching the given key.
*/
sptr<IInterface> WantParams::GetParam(const std::string &key) const
{
auto it = params_.find(key);
if (it == params_.cend()) {
return nullptr;
}
return it->second;
}
/**
* @description: Obtains the parameter value based on a given key.
* @param key Indicates the key matching the parameter.
* @return Returns the value matching the given key.
*/
const std::map<std::string, sptr<IInterface>> &WantParams::GetParams() const
{
return params_;
}
/**
* @description: Obtains a set of the keys of all parameters.
* @param
* @return Returns a set of keys.
*/
const std::set<std::string> WantParams::KeySet() const
{
std::set<std::string> keySet;
keySet.clear();
for (auto it : params_) {
keySet.emplace(it.first);
}
return keySet;
}
/**
* @description: Removes the parameter matching the given key.
* @param key Indicates the key matching the parameter to be removed.
*/
void WantParams::Remove(const std::string &key)
{
params_.erase(key);
}
/**
* @description: Checks whether the Intent contains the given key.
* @param key Indicates the key to check.
* @return Returns true if the Intent contains the key; returns false otherwise.
*/
bool WantParams::HasParam(const std::string &key) const
{
return (params_.count(key) > 0);
}
/**
* @description: Obtains the number of parameters contained in this IntentParams object.
* @return Returns the number of parameters.
*/
int WantParams::Size() const
{
return params_.size();
}
/**
* @description: Checks whether this IntentParams object contains no parameters.
* @return Returns true if this object does not contain any parameters; returns false otherwise.
*/
bool WantParams::IsEmpty() const
{
return (params_.size() == 0);
}
bool WantParams::WriteToParcelString(Parcel &parcel, sptr<IInterface> &o) const
{
std::string value = String::Unbox(IString::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_STRING)) {
return false;
}
return parcel.WriteString16(Str8ToStr16(value));
}
bool WantParams::WriteToParcelBool(Parcel &parcel, sptr<IInterface> &o) const
{
bool value = Boolean::Unbox(IBoolean::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_BOOLEAN)) {
return false;
}
return parcel.WriteInt8(value);
}
bool WantParams::WriteToParcelWantParams(Parcel &parcel, sptr<IInterface> &o) const
{
WantParams value = WantParamWrapper::Unbox(IWantParams::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_WANTPARAMS)) {
return false;
}
return parcel.WriteString16(Str8ToStr16(static_cast<WantParamWrapper *>(IWantParams::Query(o))->ToString()));
}
bool WantParams::WriteToParcelByte(Parcel &parcel, sptr<IInterface> &o) const
{
byte value = Byte::Unbox(IByte::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_BYTE)) {
return false;
}
return parcel.WriteInt8(value);
}
bool WantParams::WriteToParcelChar(Parcel &parcel, sptr<IInterface> &o) const
{
zchar value = Char::Unbox(IChar::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_CHAR)) {
return false;
}
return parcel.WriteInt32(value);
}
bool WantParams::WriteToParcelShort(Parcel &parcel, sptr<IInterface> &o) const
{
short value = Short::Unbox(IShort::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_SHORT)) {
return false;
}
return parcel.WriteInt16(value);
}
bool WantParams::WriteToParcelInt(Parcel &parcel, sptr<IInterface> &o) const
{
int value = Integer::Unbox(IInteger::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_INT)) {
return false;
}
return parcel.WriteInt32(value);
}
bool WantParams::WriteToParcelLong(Parcel &parcel, sptr<IInterface> &o) const
{
long value = Long::Unbox(ILong::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_LONG)) {
return false;
}
return parcel.WriteInt64(value);
}
bool WantParams::WriteToParcelFloat(Parcel &parcel, sptr<IInterface> &o) const
{
float value = Float::Unbox(IFloat::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_FLOAT)) {
return false;
}
return parcel.WriteFloat(value);
}
bool WantParams::WriteToParcelDouble(Parcel &parcel, sptr<IInterface> &o) const
{
double value = Double::Unbox(IDouble::Query(o));
if (!parcel.WriteInt32(VALUE_TYPE_DOUBLE)) {
return false;
}
return parcel.WriteDouble(value);
}
bool WantParams::WriteMarshalling(Parcel &parcel, sptr<IInterface> &o) const
{
if (IString::Query(o) != nullptr) {
return WriteToParcelString(parcel, o);
} else if (IBoolean::Query(o) != nullptr) {
return WriteToParcelBool(parcel, o);
} else if (IByte::Query(o) != nullptr) {
return WriteToParcelByte(parcel, o);
} else if (IChar::Query(o) != nullptr) {
return WriteToParcelChar(parcel, o);
} else if (IShort::Query(o) != nullptr) {
return WriteToParcelShort(parcel, o);
} else if (IInteger::Query(o) != nullptr) {
return WriteToParcelInt(parcel, o);
} else if (ILong::Query(o) != nullptr) {
return WriteToParcelLong(parcel, o);
} else if (IFloat::Query(o) != nullptr) {
return WriteToParcelFloat(parcel, o);
} else if (IWantParams::Query(o) != nullptr) {
return WriteToParcelWantParams(parcel, o);
} else if (IDouble::Query(o) != nullptr) {
return WriteToParcelDouble(parcel, o);
} else {
IArray *ao = IArray::Query(o);
if (ao != nullptr) {
sptr<IArray> array(ao);
return WriteArrayToParcel(parcel, array);
} else {
return true;
}
}
}
/**
* @description: Marshals an IntentParams object into a Parcel.
* @param Key-value pairs in the IntentParams are marshalled separately.
* @return If any key-value pair fails to be marshalled, false is returned.
*/
bool WantParams::Marshalling(Parcel &parcel) const
{
size_t size = params_.size();
if (!parcel.WriteInt32(size)) {
return false;
}
auto iter = params_.cbegin();
while (iter != params_.cend()) {
std::string key = iter->first;
sptr<IInterface> o = iter->second;
if (!parcel.WriteString16(Str8ToStr16(key))) {
return false;
}
if (!WriteMarshalling(parcel, o)) {
return false;
}
iter++;
}
return true;
}
template <typename T1, typename T2>
static bool SetArray(const InterfaceID &id, const std::vector<T1> &value, sptr<IArray> &ao)
{
typename std::vector<T1>::size_type size = value.size();
ao = new (std::nothrow) Array(size, id);
if (ao != nullptr) {
for (typename std::vector<T1>::size_type i = 0; i < size; i++) {
ao->Set(i, T2::Box(value[i]));
}
return true;
}
return false;
}
template <typename T1, typename T2, typename T3>
static void FillArray(IArray *ao, std::vector<T1> &array)
{
auto func = [&](IInterface *object) {
if (object != nullptr) {
T3 *value = T3::Query(object);
if (value != nullptr) {
array.push_back(T2::Unbox(value));
}
}
};
Array::ForEach(ao, func);
}
// inner use template function
template <typename T1, typename T2, typename T3>
static void SetNewArray(const AAFwk::InterfaceID &id, AAFwk::IArray *orgIArray, sptr<AAFwk::IArray> &ao)
{
if (orgIArray == nullptr) {
return;
}
std::vector<T1> array;
auto func = [&](IInterface *object) {
if (object != nullptr) {
T3 *value = T3::Query(object);
if (value != nullptr) {
array.push_back(T2::Unbox(value));
}
}
};
Array::ForEach(orgIArray, func);
typename std::vector<T1>::size_type size = array.size();
if (size > 0) {
ao = new (std::nothrow) AAFwk::Array(size, id);
if (ao != nullptr) {
for (typename std::vector<T1>::size_type i = 0; i < size; i++) {
ao->Set(i, T2::Box(array[i]));
}
}
}
}
bool WantParams::WriteArrayToParcelString(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<std::u16string> array;
auto func = [&](IInterface *object) {
std::string s = String::Unbox(IString::Query(object));
array.push_back(Str8ToStr16(s));
};
Array::ForEach(ao, func);
if (!parcel.WriteInt32(VALUE_TYPE_STRINGARRAY)) {
return false;
}
return parcel.WriteString16Vector(array);
}
bool WantParams::WriteArrayToParcelBool(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<int8_t> array;
FillArray<int8_t, Boolean, IBoolean>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_BOOLEANARRAY)) {
return false;
}
return parcel.WriteInt8Vector(array);
}
bool WantParams::WriteArrayToParcelByte(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<int8_t> array;
FillArray<int8_t, Byte, IByte>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_BYTEARRAY)) {
return false;
}
return parcel.WriteInt8Vector(array);
}
bool WantParams::WriteArrayToParcelChar(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<int32_t> array;
FillArray<int32_t, Char, IChar>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_CHARARRAY)) {
return false;
}
return parcel.WriteInt32Vector(array);
}
bool WantParams::WriteArrayToParcelShort(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<short> array;
FillArray<short, Short, IShort>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_SHORTARRAY)) {
return false;
}
return parcel.WriteInt16Vector(array);
}
bool WantParams::WriteArrayToParcelInt(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<int> array;
FillArray<int, Integer, IInteger>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_INTARRAY)) {
return false;
}
return parcel.WriteInt32Vector(array);
}
bool WantParams::WriteArrayToParcelLong(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<int64_t> array;
FillArray<int64_t, Long, ILong>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_LONGARRAY)) {
return false;
}
return parcel.WriteInt64Vector(array);
}
bool WantParams::WriteArrayToParcelFloat(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<float> array;
FillArray<float, Float, IFloat>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_FLOATARRAY)) {
return false;
}
return parcel.WriteFloatVector(array);
}
bool WantParams::WriteArrayToParcelDouble(Parcel &parcel, IArray *ao) const
{
if (ao == nullptr) {
return false;
}
std::vector<double> array;
FillArray<double, Double, IDouble>(ao, array);
if (!parcel.WriteInt32(VALUE_TYPE_DOUBLEARRAY)) {
return false;
}
return parcel.WriteDoubleVector(array);
}
bool WantParams::WriteArrayToParcel(Parcel &parcel, IArray *ao) const
{
if (Array::IsStringArray(ao)) {
return WriteArrayToParcelString(parcel, ao);
} else if (Array::IsBooleanArray(ao)) {
return WriteArrayToParcelBool(parcel, ao);
} else if (Array::IsByteArray(ao)) {
return WriteArrayToParcelByte(parcel, ao);
} else if (Array::IsCharArray(ao)) {
return WriteArrayToParcelChar(parcel, ao);
} else if (Array::IsShortArray(ao)) {
return WriteArrayToParcelShort(parcel, ao);
} else if (Array::IsIntegerArray(ao)) {
return WriteArrayToParcelInt(parcel, ao);
} else if (Array::IsLongArray(ao)) {
return WriteArrayToParcelLong(parcel, ao);
} else if (Array::IsFloatArray(ao)) {
return WriteArrayToParcelFloat(parcel, ao);
} else if (Array::IsDoubleArray(ao)) {
return WriteArrayToParcelDouble(parcel, ao);
} else {
return true;
}
}
bool WantParams::ReadFromParcelArrayString(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<std::u16string> value;
if (!parcel.ReadString16Vector(&value)) {
return false;
}
std::vector<std::u16string>::size_type size = value.size();
ao = new (std::nothrow) Array(size, g_IID_IString);
if (ao != nullptr) {
for (std::vector<std::u16string>::size_type i = 0; i < size; i++) {
ao->Set(i, String::Box(Str16ToStr8(value[i])));
}
return true;
}
return false;
}
bool WantParams::ReadFromParcelArrayBool(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<int8_t> value;
if (!parcel.ReadInt8Vector(&value)) {
return false;
}
return SetArray<int8_t, Boolean>(g_IID_IBoolean, value, ao);
}
bool WantParams::ReadFromParcelArrayByte(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<int8_t> value;
if (!parcel.ReadInt8Vector(&value)) {
return false;
}
return SetArray<int8_t, Byte>(g_IID_IByte, value, ao);
}
bool WantParams::ReadFromParcelArrayChar(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<int32_t> value;
if (!parcel.ReadInt32Vector(&value)) {
return false;
}
return SetArray<int32_t, Char>(g_IID_IChar, value, ao);
}
bool WantParams::ReadFromParcelArrayShort(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<short> value;
if (!parcel.ReadInt16Vector(&value)) {
return false;
}
return SetArray<short, Short>(g_IID_IShort, value, ao);
}
bool WantParams::ReadFromParcelArrayInt(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<int> value;
if (!parcel.ReadInt32Vector(&value)) {
return false;
}
return SetArray<int, Integer>(g_IID_IInteger, value, ao);
}
bool WantParams::ReadFromParcelArrayLong(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<int64_t> value;
if (!parcel.ReadInt64Vector(&value)) {
return false;
}
return SetArray<int64_t, Long>(g_IID_ILong, value, ao);
}
bool WantParams::ReadFromParcelArrayFloat(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<float> value;
if (!parcel.ReadFloatVector(&value)) {
return false;
}
return SetArray<float, Float>(g_IID_IFloat, value, ao);
}
bool WantParams::ReadFromParcelArrayDouble(Parcel &parcel, sptr<IArray> &ao)
{
std::vector<double> value;
if (!parcel.ReadDoubleVector(&value)) {
return false;
}
return SetArray<double, Double>(g_IID_IDouble, value, ao);
}
bool WantParams::ReadArrayToParcel(Parcel &parcel, int type, sptr<IArray> &ao)
{
switch (type) {
case VALUE_TYPE_STRINGARRAY:
return ReadFromParcelArrayString(parcel, ao);
case VALUE_TYPE_BOOLEANARRAY:
return ReadFromParcelArrayBool(parcel, ao);
case VALUE_TYPE_BYTEARRAY:
return ReadFromParcelArrayByte(parcel, ao);
case VALUE_TYPE_CHARARRAY:
return ReadFromParcelArrayChar(parcel, ao);
case VALUE_TYPE_SHORTARRAY:
return ReadFromParcelArrayShort(parcel, ao);
case VALUE_TYPE_INTARRAY:
return ReadFromParcelArrayInt(parcel, ao);
case VALUE_TYPE_LONGARRAY:
return ReadFromParcelArrayLong(parcel, ao);
case VALUE_TYPE_FLOATARRAY:
return ReadFromParcelArrayFloat(parcel, ao);
case VALUE_TYPE_DOUBLEARRAY:
return ReadFromParcelArrayDouble(parcel, ao);
default:
// ignore
;
}
return true;
}
bool WantParams::ReadFromParcelString(Parcel &parcel, const std::string &key)
{
std::u16string value = parcel.ReadString16();
sptr<IInterface> intf = String::Box(Str16ToStr8(value));
if (intf) {
SetParam(key, intf);
}
return true;
}
bool WantParams::ReadFromParcelBool(Parcel &parcel, const std::string &key)
{
int8_t value;
if (parcel.ReadInt8(value)) {
sptr<IInterface> intf = Boolean::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelInt8(Parcel &parcel, const std::string &key)
{
int8_t value;
if (parcel.ReadInt8(value)) {
sptr<IInterface> intf = Byte::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelChar(Parcel &parcel, const std::string &key)
{
int32_t value;
if (parcel.ReadInt32(value)) {
sptr<IInterface> intf = Char::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelShort(Parcel &parcel, const std::string &key)
{
short value;
if (parcel.ReadInt16(value)) {
sptr<IInterface> intf = Short::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelInt(Parcel &parcel, const std::string &key)
{
int value;
if (parcel.ReadInt32(value)) {
sptr<IInterface> intf = Integer::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelWantParamWrapper(Parcel &parcel, const std::string &key)
{
std::u16string value = parcel.ReadString16();
sptr<IInterface> intf = WantParamWrapper::Parse(Str16ToStr8(value));
if (intf) {
SetParam(key, intf);
}
return true;
}
bool WantParams::ReadFromParcelLong(Parcel &parcel, const std::string &key)
{
int64_t value;
if (parcel.ReadInt64(value)) {
sptr<IInterface> intf = Long::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelFloat(Parcel &parcel, const std::string &key)
{
float value;
if (parcel.ReadFloat(value)) {
sptr<IInterface> intf = Float::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelDouble(Parcel &parcel, const std::string &key)
{
double value;
if (parcel.ReadDouble(value)) {
sptr<IInterface> intf = Double::Box(value);
if (intf) {
SetParam(key, intf);
}
return true;
} else {
return false;
}
}
bool WantParams::ReadFromParcelParam(Parcel &parcel, const std::string &key, int type)
{
switch (type) {
case VALUE_TYPE_STRING:
return ReadFromParcelString(parcel, key);
case VALUE_TYPE_BOOLEAN:
return ReadFromParcelBool(parcel, key);
case VALUE_TYPE_BYTE:
return ReadFromParcelInt8(parcel, key);
case VALUE_TYPE_CHAR:
return ReadFromParcelChar(parcel, key);
case VALUE_TYPE_SHORT:
return ReadFromParcelShort(parcel, key);
case VALUE_TYPE_INT:
return ReadFromParcelInt(parcel, key);
case VALUE_TYPE_LONG:
return ReadFromParcelLong(parcel, key);
case VALUE_TYPE_FLOAT:
return ReadFromParcelFloat(parcel, key);
case VALUE_TYPE_DOUBLE:
return ReadFromParcelDouble(parcel, key);
case VALUE_TYPE_WANTPARAMS:
return ReadFromParcelWantParamWrapper(parcel, key);
case VALUE_TYPE_NULL:
break;
default: {
// handle array
sptr<IArray> ao = nullptr;
if (!ReadArrayToParcel(parcel, type, ao)) {
return false;
}
sptr<IInterface> intf = ao;
if (intf) {
SetParam(key, intf);
}
break;
}
}
return true;
}
bool WantParams::ReadFromParcel(Parcel &parcel)
{
int32_t size;
if (!parcel.ReadInt32(size)) {
return false;
}
for (int32_t i = 0; i < size; i++) {
std::u16string key = parcel.ReadString16();
int type;
if (!parcel.ReadInt32(type)) {
return false;
}
if (!ReadFromParcelParam(parcel, Str16ToStr8(key), type)) {
return false;
}
}
return true;
}
/**
* @description: Unmarshals an IntentParams object from a Parcel.
* @param Key-value pairs in the IntentParams are unmarshalled separately.
* @return If any key-value pair fails to be unmarshalled, false is returned.
*/
WantParams *WantParams::Unmarshalling(Parcel &parcel)
{
WantParams *wantParams = new (std::nothrow) WantParams();
if (wantParams != nullptr && !wantParams->ReadFromParcel(parcel)) {
delete wantParams;
wantParams = nullptr;
}
return wantParams;
}
void WantParams::DumpInfo(int level) const
{
APP_LOGI("=======WantParams::DumpInfo level: %{public}d start=============", level);
int params_size = params_.size();
APP_LOGI("===WantParams::params_: count %{public}d =============", params_size);
int typeId = VALUE_TYPE_NULL;
for (auto it : params_) {
typeId = VALUE_TYPE_NULL;
typeId = WantParams::GetDataType(it.second);
if (typeId != VALUE_TYPE_NULL) {
std::string value = WantParams::GetStringByType(it.second, typeId);
APP_LOGI("=WantParams::params_[%{public}s] : %{public}s =============", it.first.c_str(), value.c_str());
} else {
APP_LOGI("=WantParams::params_[%{public}s] : type error =============", it.first.c_str());
}
}
APP_LOGI("=======WantParams::DumpInfo level: %{public}d end=============", level);
}
} // namespace AAFwk
} // namespace OHOS
| 31.693744
| 120
| 0.624705
|
chaoyangcui
|
bb5cbcdd274ece693781081ec0d792c503723887
| 1,194
|
hpp
|
C++
|
module-08/ex02/mutantstack.hpp
|
kotabrog/CPP-module
|
db858e57ac194d4ca9b38667ff3820418b42e9c8
|
[
"MIT"
] | 1
|
2021-09-05T14:59:20.000Z
|
2021-09-05T14:59:20.000Z
|
module-08/ex02/mutantstack.hpp
|
kotabrog/CPP-module
|
db858e57ac194d4ca9b38667ff3820418b42e9c8
|
[
"MIT"
] | null | null | null |
module-08/ex02/mutantstack.hpp
|
kotabrog/CPP-module
|
db858e57ac194d4ca9b38667ff3820418b42e9c8
|
[
"MIT"
] | null | null | null |
#ifndef MUTANTSTACK_H
#define MUTANTSTACK_H
#include <stack>
template <typename T>
class MutantStack : public std::stack<T>
{
public:
typedef typename std::stack<T>::container_type::iterator iterator;
typedef typename std::stack<T>::container_type::const_iterator const_iterator;
typedef typename std::stack<T>::container_type::reverse_iterator reverse_iterator;
typedef typename std::stack<T>::container_type::const_reverse_iterator const_reverse_iterator;
MutantStack() : std::stack<T>() {}
MutantStack(const MutantStack<T>& mutant) : std::stack<T>(mutant) {}
~MutantStack() {}
MutantStack<T>& operator=(const MutantStack<T>& mutant)
{
this->c = mutant.c;
return *this;
}
iterator begin() {return this->c.begin();}
const_iterator begin() const {return this->c.begin();}
reverse_iterator rbegin() {return this->c.rbegin();}
const_reverse_iterator rbegin() const {return this->c.rbegin();}
iterator end() {return this->c.end();}
const_iterator end() const {return this->c.end();}
reverse_iterator rend() {return this->c.rend();}
const_reverse_iterator rend() const {return this->c.rend();}
};
#endif
| 33.166667
| 98
| 0.691792
|
kotabrog
|
bb5d6b464d756f20311a5895324bb33bb629734d
| 789
|
hpp
|
C++
|
include/depthai-shared/datatype/RawImgDetections.hpp
|
kamleshbhalui/depthai-shared
|
28da84fc8a81b8d692d801924598ce9cb34ac761
|
[
"MIT"
] | null | null | null |
include/depthai-shared/datatype/RawImgDetections.hpp
|
kamleshbhalui/depthai-shared
|
28da84fc8a81b8d692d801924598ce9cb34ac761
|
[
"MIT"
] | null | null | null |
include/depthai-shared/datatype/RawImgDetections.hpp
|
kamleshbhalui/depthai-shared
|
28da84fc8a81b8d692d801924598ce9cb34ac761
|
[
"MIT"
] | null | null | null |
#pragma once
#include "RawBuffer.hpp"
#include "depthai-shared/common/Point3f.hpp"
#include "depthai-shared/utility/Serialization.hpp"
namespace dai {
/// ImgDetection structure
struct ImgDetection {
uint32_t label;
float confidence;
float xmin;
float ymin;
float xmax;
float ymax;
};
DEPTHAI_SERIALIZE_EXT(ImgDetection, label, confidence, xmin, ymin, xmax, ymax);
/// RawImgDetections structure
struct RawImgDetections : public RawBuffer {
std::vector<ImgDetection> detections;
void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override {
metadata = utility::serialize(*this);
datatype = DatatypeEnum::ImgDetections;
};
DEPTHAI_SERIALIZE(RawImgDetections, detections);
};
} // namespace dai
| 23.205882
| 96
| 0.721166
|
kamleshbhalui
|
bb5e18cb03423ed0c63210d105648ad672af010c
| 1,933
|
cpp
|
C++
|
luogu/codes/P3367_test.cpp
|
Tony031218/OI
|
562f5f45d0448f4eab77643b99b825405a123d92
|
[
"MIT"
] | 1
|
2021-02-22T03:39:24.000Z
|
2021-02-22T03:39:24.000Z
|
luogu/codes/P3367_test.cpp
|
Tony031218/OI
|
562f5f45d0448f4eab77643b99b825405a123d92
|
[
"MIT"
] | null | null | null |
luogu/codes/P3367_test.cpp
|
Tony031218/OI
|
562f5f45d0448f4eab77643b99b825405a123d92
|
[
"MIT"
] | null | null | null |
/*************************************************************
* > File Name : P3367_test.cpp
* > Author : Tony
* > Created Time : 2019/09/21 17:57:40
* > Algorithm : ufs
**************************************************************/
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0; int f = 1; char ch = getchar();
while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
while (isdigit(ch)) {x = x * 10 + ch - 48; ch = getchar();}
return x * f;
}
const int maxn = 10010;
int ufs[maxn];
int n, m;
namespace Test1 {
int find(int x) {
return ufs[x] == x ? x : find(ufs[x]);
}
void merge(int x, int y) {
int fx = find(x);
int fy = find(y);
if (fx != fy) {
ufs[fx] = fy;
}
}
}
namespace Test2 {
int find(int x) {
return ufs[x] == x ? x : ufs[x] = find(ufs[x]);
}
void merge(int x, int y) {
int fx = find(x);
int fy = find(y);
if (fx != fy) {
ufs[fx] = fy;
}
}
}
namespace Test3 {
int dep[maxn];
int find(int x) {
return ufs[x] == x ? x : ufs[x] = find(ufs[x]);
}
void merge(int x, int y) {
int fx = find(x);
int fy = find(y);
if (dep[fx] <= dep[fy]) {
ufs[fx] = fy;
if (dep[fx] == dep[fy]) {
dep[fy]++;
}
} else {
ufs[fy] = fx;
}
}
}
int main() {
n = read(), m = read();
for (int i = 1; i <= n; ++i) {
ufs[i] = i;
}
for (int i = 1; i <= m; ++i) {
int opt = read(), x = read(), y = read();
if (opt == 1) {
Test1::merge(x, y);
} else {
if (Test1::find(x) == Test1::find(y)) {
printf("Y\n");
} else {
printf("N\n");
}
}
}
return 0;
}
| 22.476744
| 65
| 0.366787
|
Tony031218
|
bb62529e61fbb71d6159ef513dec02bdd9fb7f1d
| 1,155
|
hpp
|
C++
|
src/core/simulate/src/duneini.hpp
|
henryiii/spatial-model-editor
|
2138d03ae4c7cc353b40324dfd1a3e763d7085d9
|
[
"MIT"
] | 4
|
2019-07-18T15:05:09.000Z
|
2020-03-14T09:50:07.000Z
|
src/core/simulate/src/duneini.hpp
|
henryiii/spatial-model-editor
|
2138d03ae4c7cc353b40324dfd1a3e763d7085d9
|
[
"MIT"
] | 418
|
2020-10-08T07:42:27.000Z
|
2022-03-08T12:10:52.000Z
|
src/core/simulate/src/duneini.hpp
|
henryiii/spatial-model-editor
|
2138d03ae4c7cc353b40324dfd1a3e763d7085d9
|
[
"MIT"
] | 2
|
2021-09-02T11:20:38.000Z
|
2021-10-13T14:05:32.000Z
|
// DUNE-copasi ini file generation
// - iniFile class: simple ini file generation one line at a time
#pragma once
#include <QString>
namespace sme {
namespace simulate {
class IniFile {
private:
QString text;
public:
[[nodiscard]] const QString &getText() const;
void addSection(const QString &str);
void addSection(const QString &str1, const QString &str2);
void addSection(const QString &str1, const QString &str2,
const QString &str3);
void addSection(const QString &str1, const QString &str2, const QString &str3,
const QString &str4);
void addSection(const QString &str1, const QString &str2, const QString &str3,
const QString &str4, const QString &str5);
void addSection(const QString &str1, const QString &str2, const QString &str3,
const QString &str4, const QString &str5,
const QString &str6);
void addValue(const QString &var, const QString &value);
void addValue(const QString &var, int value);
void addValue(const QString &var, double value, int precision);
void clear();
};
} // namespace simulate
} // namespace sme
| 30.394737
| 80
| 0.678788
|
henryiii
|
bb6390187f9d91bd014cba5bad92977c4504e2fa
| 370
|
cpp
|
C++
|
console/src/boost_1_78_0/libs/config/test/boost_override_test.cpp
|
vany152/FilesHash
|
39f282807b7f1abc56dac389e8259ee3bb557a8d
|
[
"MIT"
] | 106
|
2015-08-07T04:23:50.000Z
|
2020-12-27T18:25:15.000Z
|
console/src/boost_1_78_0/libs/config/test/boost_override_test.cpp
|
vany152/FilesHash
|
39f282807b7f1abc56dac389e8259ee3bb557a8d
|
[
"MIT"
] | 130
|
2016-06-22T22:11:25.000Z
|
2020-11-29T20:24:09.000Z
|
Libs/boost_1_76_0/libs/config/test/boost_override_test.cpp
|
Antd23rus/S2DE
|
47cc7151c2934cd8f0399a9856c1e54894571553
|
[
"MIT"
] | 41
|
2015-07-08T19:18:35.000Z
|
2021-01-14T16:39:56.000Z
|
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
struct base {
virtual void first() = 0;
virtual void second() { }
};
struct derived
: base {
void first() BOOST_OVERRIDE { }
void second() BOOST_OVERRIDE { }
};
| 18.5
| 54
| 0.678378
|
vany152
|
bb68cf75ac974a6789efbd2bba88b89579f7e0c2
| 3,673
|
cpp
|
C++
|
qt-creator-opensource-src-4.6.1/src/plugins/valgrind/callgrind/callgrindfunctioncycle.cpp
|
kevinlq/Qt-Creator-Opensource-Study
|
b8cadff1f33f25a5d4ef33ed93f661b788b1ba0f
|
[
"MIT"
] | 5
|
2018-12-22T14:49:13.000Z
|
2022-01-13T07:21:46.000Z
|
qt-creator-opensource-src-4.6.1/src/plugins/valgrind/callgrind/callgrindfunctioncycle.cpp
|
kevinlq/Qt-Creator-Opensource-Study
|
b8cadff1f33f25a5d4ef33ed93f661b788b1ba0f
|
[
"MIT"
] | null | null | null |
qt-creator-opensource-src-4.6.1/src/plugins/valgrind/callgrind/callgrindfunctioncycle.cpp
|
kevinlq/Qt-Creator-Opensource-Study
|
b8cadff1f33f25a5d4ef33ed93f661b788b1ba0f
|
[
"MIT"
] | 8
|
2018-07-17T03:55:48.000Z
|
2021-12-22T06:37:53.000Z
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "callgrindfunctioncycle.h"
#include "callgrindfunction_p.h"
#include "callgrindfunctioncall.h"
#include "callgrindparsedata.h"
#include <QStringList>
#include <QDebug>
namespace Valgrind {
namespace Callgrind {
//BEGIN FunctionCycle::Private
class FunctionCycle::Private : public Function::Private
{
public:
Private(const ParseData *data);
QVector<const Function *> m_functions;
};
FunctionCycle::Private::Private(const ParseData *data)
: Function::Private(data)
{
}
#define CYCLE_D static_cast<FunctionCycle::Private *>(this->d)
//BEGIN FunctionCycle
FunctionCycle::FunctionCycle(const ParseData *data)
: Function(new Private(data))
{
}
FunctionCycle::~FunctionCycle()
{
// d should be deleted by Function::~Function()
}
void FunctionCycle::setFunctions(const QVector<const Function *> &functions)
{
Private *d = CYCLE_D;
d->m_functions = functions;
d->m_incomingCallMap.clear();
d->m_outgoingCallMap.clear();
d->m_called = 0;
d->m_selfCost.fill(0, d->m_data->events().size());
d->m_inclusiveCost.fill(0, d->m_data->events().size());
foreach (const Function *func, functions) {
// just add up self cost
d->accumulateCost(d->m_selfCost, func->selfCosts());
// add outgoing calls to functions that are not part of the cycle
foreach (const FunctionCall *call, func->outgoingCalls()) {
if (!functions.contains(call->callee()))
d->accumulateCall(call, Function::Private::Outgoing);
}
// add incoming calls from functions that are not part of the cycle
foreach (const FunctionCall *call, func->incomingCalls()) {
if (!functions.contains(call->caller())) {
d->accumulateCall(call, Function::Private::Incoming);
d->m_called += call->calls();
d->accumulateCost(d->m_inclusiveCost, call->costs());
}
}
}
// now subtract self from incl. cost (see implementation of inclusiveCost())
// now subtract self cost (see @c inclusiveCost() implementation)
for (int i = 0, c = d->m_inclusiveCost.size(); i < c; ++i) {
if (d->m_inclusiveCost.at(i) < d->m_selfCost.at(i))
d->m_inclusiveCost[i] = 0;
else
d->m_inclusiveCost[i] -= d->m_selfCost.at(i);
}
}
QVector<const Function *> FunctionCycle::functions() const
{
return CYCLE_D->m_functions;
}
} // namespace Callgrind
} // namespace Valgrind
| 32.794643
| 80
| 0.653689
|
kevinlq
|
bb69645df5e1abe2569d8ad5f7f17cdf983facac
| 8,404
|
cc
|
C++
|
src/net/cert/ev_root_ca_metadata_unittest.cc
|
godfo/naiveproxy
|
369269a12832bf34bf01c7b0e7ca121555abd3eb
|
[
"BSD-3-Clause"
] | 2,151
|
2020-04-18T07:31:17.000Z
|
2022-03-31T08:39:18.000Z
|
src/net/cert/ev_root_ca_metadata_unittest.cc
|
wclmgcd/naiveproxy
|
e32a3afb76fd21207c322f2d5e794c4f5505fb59
|
[
"BSD-3-Clause"
] | 395
|
2020-04-18T08:22:18.000Z
|
2021-12-08T13:04:49.000Z
|
src/net/cert/ev_root_ca_metadata_unittest.cc
|
wclmgcd/naiveproxy
|
e32a3afb76fd21207c322f2d5e794c4f5505fb59
|
[
"BSD-3-Clause"
] | 338
|
2020-04-18T08:03:10.000Z
|
2022-03-29T12:33:22.000Z
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/cert/ev_root_ca_metadata.h"
#include "build/build_config.h"
#include "net/cert/x509_cert_types.h"
#include "net/der/input.h"
#include "net/test/cert_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(USE_NSS_CERTS)
#include "crypto/nss_util.h"
#include "crypto/scoped_nss_types.h"
#endif
namespace net {
namespace {
#if defined(USE_NSS_CERTS) || defined(OS_WIN)
const char kVerisignPolicyStr[] = "2.16.840.1.113733.1.7.23.6";
const char kThawtePolicyStr[] = "2.16.840.1.113733.1.7.48.1";
const char kFakePolicyStr[] = "2.16.840.1.42";
const char kCabEvPolicyStr[] = "2.23.140.1.1";
#elif defined(OS_MACOSX)
const char kFakePolicyStr[] = "2.16.840.1.42";
#endif
#if defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX)
// DER OID values (no tag or length).
const uint8_t kVerisignPolicyBytes[] = {0x60, 0x86, 0x48, 0x01, 0x86, 0xf8,
0x45, 0x01, 0x07, 0x17, 0x06};
const uint8_t kThawtePolicyBytes[] = {0x60, 0x86, 0x48, 0x01, 0x86, 0xf8,
0x45, 0x01, 0x07, 0x30, 0x01};
const uint8_t kFakePolicyBytes[] = {0x60, 0x86, 0x48, 0x01, 0x2a};
const uint8_t kCabEvPolicyBytes[] = {0x67, 0x81, 0x0c, 0x01, 0x01};
const SHA256HashValue kVerisignFingerprint = {
{0xe7, 0x68, 0x56, 0x34, 0xef, 0xac, 0xf6, 0x9a, 0xce, 0x93, 0x9a,
0x6b, 0x25, 0x5b, 0x7b, 0x4f, 0xab, 0xef, 0x42, 0x93, 0x5b, 0x50,
0xa2, 0x65, 0xac, 0xb5, 0xcb, 0x60, 0x27, 0xe4, 0x4e, 0x70}};
const SHA256HashValue kFakeFingerprint = {
{0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa,
0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}};
class EVOidData {
public:
EVOidData();
bool Init();
EVRootCAMetadata::PolicyOID verisign_policy;
der::Input verisign_policy_bytes;
EVRootCAMetadata::PolicyOID thawte_policy;
der::Input thawte_policy_bytes;
EVRootCAMetadata::PolicyOID fake_policy;
der::Input fake_policy_bytes;
EVRootCAMetadata::PolicyOID cab_ev_policy;
der::Input cab_ev_policy_bytes;
};
#endif // defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX)
#if defined(USE_NSS_CERTS)
SECOidTag RegisterOID(PLArenaPool* arena, const char* oid_string) {
SECOidData oid_data;
memset(&oid_data, 0, sizeof(oid_data));
oid_data.offset = SEC_OID_UNKNOWN;
oid_data.desc = oid_string;
oid_data.mechanism = CKM_INVALID_MECHANISM;
oid_data.supportedExtension = INVALID_CERT_EXTENSION;
SECStatus rv = SEC_StringToOID(arena, &oid_data.oid, oid_string, 0);
if (rv != SECSuccess)
return SEC_OID_UNKNOWN;
return SECOID_AddEntry(&oid_data);
}
EVOidData::EVOidData()
: verisign_policy(SEC_OID_UNKNOWN),
verisign_policy_bytes(kVerisignPolicyBytes),
thawte_policy(SEC_OID_UNKNOWN),
thawte_policy_bytes(kThawtePolicyBytes),
fake_policy(SEC_OID_UNKNOWN),
fake_policy_bytes(kFakePolicyBytes),
cab_ev_policy(SEC_OID_UNKNOWN),
cab_ev_policy_bytes(kCabEvPolicyBytes) {}
bool EVOidData::Init() {
crypto::EnsureNSSInit();
crypto::ScopedPLArenaPool pool(PORT_NewArena(DER_DEFAULT_CHUNKSIZE));
if (!pool.get())
return false;
verisign_policy = RegisterOID(pool.get(), kVerisignPolicyStr);
thawte_policy = RegisterOID(pool.get(), kThawtePolicyStr);
fake_policy = RegisterOID(pool.get(), kFakePolicyStr);
cab_ev_policy = RegisterOID(pool.get(), kCabEvPolicyStr);
return verisign_policy != SEC_OID_UNKNOWN &&
thawte_policy != SEC_OID_UNKNOWN && fake_policy != SEC_OID_UNKNOWN &&
cab_ev_policy != SEC_OID_UNKNOWN;
}
#elif defined(OS_WIN)
EVOidData::EVOidData()
: verisign_policy(kVerisignPolicyStr),
verisign_policy_bytes(kVerisignPolicyBytes),
thawte_policy(kThawtePolicyStr),
thawte_policy_bytes(kThawtePolicyBytes),
fake_policy(kFakePolicyStr),
fake_policy_bytes(kFakePolicyBytes),
cab_ev_policy(kCabEvPolicyStr),
cab_ev_policy_bytes(kCabEvPolicyBytes) {}
bool EVOidData::Init() {
return true;
}
#elif defined(OS_MACOSX)
EVOidData::EVOidData()
: verisign_policy(kVerisignPolicyBytes),
verisign_policy_bytes(kVerisignPolicyBytes),
thawte_policy(kThawtePolicyBytes),
thawte_policy_bytes(kThawtePolicyBytes),
fake_policy(kFakePolicyBytes),
fake_policy_bytes(kFakePolicyBytes),
cab_ev_policy(kCabEvPolicyBytes),
cab_ev_policy_bytes(kCabEvPolicyBytes) {}
bool EVOidData::Init() {
return true;
}
#endif
#if defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX)
class EVRootCAMetadataTest : public testing::Test {
protected:
void SetUp() override { ASSERT_TRUE(ev_oid_data.Init()); }
EVOidData ev_oid_data;
};
TEST_F(EVRootCAMetadataTest, Basic) {
EVRootCAMetadata* ev_metadata(EVRootCAMetadata::GetInstance());
EXPECT_TRUE(ev_metadata->IsEVPolicyOID(ev_oid_data.verisign_policy));
EXPECT_TRUE(
ev_metadata->IsEVPolicyOIDGivenBytes(ev_oid_data.verisign_policy_bytes));
EXPECT_FALSE(ev_metadata->IsEVPolicyOID(ev_oid_data.fake_policy));
EXPECT_FALSE(
ev_metadata->IsEVPolicyOIDGivenBytes(ev_oid_data.fake_policy_bytes));
EXPECT_TRUE(ev_metadata->HasEVPolicyOID(kVerisignFingerprint,
ev_oid_data.verisign_policy));
EXPECT_TRUE(ev_metadata->HasEVPolicyOIDGivenBytes(
kVerisignFingerprint, ev_oid_data.verisign_policy_bytes));
EXPECT_FALSE(ev_metadata->HasEVPolicyOID(kFakeFingerprint,
ev_oid_data.verisign_policy));
EXPECT_FALSE(ev_metadata->HasEVPolicyOIDGivenBytes(
kFakeFingerprint, ev_oid_data.verisign_policy_bytes));
EXPECT_FALSE(ev_metadata->HasEVPolicyOID(kVerisignFingerprint,
ev_oid_data.fake_policy));
EXPECT_FALSE(ev_metadata->HasEVPolicyOIDGivenBytes(
kVerisignFingerprint, ev_oid_data.fake_policy_bytes));
EXPECT_FALSE(ev_metadata->HasEVPolicyOID(kVerisignFingerprint,
ev_oid_data.thawte_policy));
EXPECT_FALSE(ev_metadata->HasEVPolicyOIDGivenBytes(
kVerisignFingerprint, ev_oid_data.thawte_policy_bytes));
// Test a completely bogus OID given bytes.
const uint8_t bad_oid[] = {0};
EXPECT_FALSE(ev_metadata->HasEVPolicyOIDGivenBytes(kVerisignFingerprint,
der::Input(bad_oid)));
}
TEST_F(EVRootCAMetadataTest, AddRemove) {
EVRootCAMetadata* ev_metadata(EVRootCAMetadata::GetInstance());
EXPECT_FALSE(ev_metadata->IsEVPolicyOID(ev_oid_data.fake_policy));
EXPECT_FALSE(
ev_metadata->IsEVPolicyOIDGivenBytes(ev_oid_data.fake_policy_bytes));
EXPECT_FALSE(
ev_metadata->HasEVPolicyOID(kFakeFingerprint, ev_oid_data.fake_policy));
EXPECT_FALSE(ev_metadata->HasEVPolicyOIDGivenBytes(
kFakeFingerprint, ev_oid_data.fake_policy_bytes));
{
ScopedTestEVPolicy test_ev_policy(ev_metadata, kFakeFingerprint,
kFakePolicyStr);
EXPECT_TRUE(ev_metadata->IsEVPolicyOID(ev_oid_data.fake_policy));
EXPECT_TRUE(
ev_metadata->IsEVPolicyOIDGivenBytes(ev_oid_data.fake_policy_bytes));
EXPECT_TRUE(
ev_metadata->HasEVPolicyOID(kFakeFingerprint, ev_oid_data.fake_policy));
EXPECT_TRUE(ev_metadata->HasEVPolicyOIDGivenBytes(
kFakeFingerprint, ev_oid_data.fake_policy_bytes));
}
EXPECT_FALSE(ev_metadata->IsEVPolicyOID(ev_oid_data.fake_policy));
EXPECT_FALSE(
ev_metadata->IsEVPolicyOIDGivenBytes(ev_oid_data.fake_policy_bytes));
EXPECT_FALSE(
ev_metadata->HasEVPolicyOID(kFakeFingerprint, ev_oid_data.fake_policy));
EXPECT_FALSE(ev_metadata->HasEVPolicyOIDGivenBytes(
kFakeFingerprint, ev_oid_data.fake_policy_bytes));
}
TEST_F(EVRootCAMetadataTest, IsCaBrowserForumEvOid) {
EXPECT_TRUE(
EVRootCAMetadata::IsCaBrowserForumEvOid(ev_oid_data.cab_ev_policy));
EXPECT_FALSE(
EVRootCAMetadata::IsCaBrowserForumEvOid(ev_oid_data.fake_policy));
EXPECT_FALSE(
EVRootCAMetadata::IsCaBrowserForumEvOid(ev_oid_data.verisign_policy));
}
#endif // defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX)
} // namespace
} // namespace net
| 34.584362
| 80
| 0.73108
|
godfo
|
bb69dbd249724d064cb803ab3e6389c54b515455
| 1,692
|
hpp
|
C++
|
src/SingleLayerOptics/src/BaseCell.hpp
|
bakonyidani/Windows-CalcEngine
|
afa4c4a9f88199c6206af8bc994a073931fc8b91
|
[
"BSD-3-Clause-LBNL"
] | null | null | null |
src/SingleLayerOptics/src/BaseCell.hpp
|
bakonyidani/Windows-CalcEngine
|
afa4c4a9f88199c6206af8bc994a073931fc8b91
|
[
"BSD-3-Clause-LBNL"
] | null | null | null |
src/SingleLayerOptics/src/BaseCell.hpp
|
bakonyidani/Windows-CalcEngine
|
afa4c4a9f88199c6206af8bc994a073931fc8b91
|
[
"BSD-3-Clause-LBNL"
] | null | null | null |
#ifndef BASECELL_H
#define BASECELL_H
#include <memory>
#include <vector>
namespace FenestrationCommon {
enum class Side;
class CSeries;
}
namespace SingleLayerOptics {
class CMaterial;
class ICellDescription;
class CBeamDirection;
// Handles optical layer "cell". Base behavior is to calculate specular (direct-direct) component of a light
// beam. Inherit from this class when want to create new shading type.
class CBaseCell {
public:
CBaseCell();
CBaseCell( const std::shared_ptr< CMaterial >& t_Material,
const std::shared_ptr< ICellDescription >& t_CellDescription );
virtual void setSourceData( std::shared_ptr< FenestrationCommon::CSeries > t_SourceData );
// Direct to direct component of transmitted ray
virtual double T_dir_dir( const FenestrationCommon::Side t_Side, const CBeamDirection& t_Direction );
virtual double R_dir_dir( const FenestrationCommon::Side t_Side, const CBeamDirection& t_Direction );
virtual std::vector< double > T_dir_dir_band( const FenestrationCommon::Side t_Side,
const CBeamDirection& t_Direction );
virtual std::vector< double > R_dir_dir_band( const FenestrationCommon::Side t_Side,
const CBeamDirection& t_Direction );
std::vector< double > getBandWavelengths() const;
void setBandWavelengths(const std::vector<double> & wavelengths);
int getBandIndex( double t_Wavelength );
size_t getBandSize() const;
double getMinLambda() const;
double getMaxLambda() const;
protected:
std::shared_ptr< CMaterial > m_Material;
std::shared_ptr< ICellDescription > m_CellDescription;
};
}
#endif
| 30.214286
| 109
| 0.72104
|
bakonyidani
|
bb6e6836a82cfab2293892d87697c52e711d0956
| 561
|
hpp
|
C++
|
src/xmesh.d/cramer3.hpp
|
naruto2/CodeFEM
|
eb689aa7573d4ac9fc83d057f99c79a5d8f3bd90
|
[
"MIT"
] | 1
|
2020-09-27T07:28:04.000Z
|
2020-09-27T07:28:04.000Z
|
src/xmesh.d/cramer3.hpp
|
naruto2/CodeFEM
|
eb689aa7573d4ac9fc83d057f99c79a5d8f3bd90
|
[
"MIT"
] | null | null | null |
src/xmesh.d/cramer3.hpp
|
naruto2/CodeFEM
|
eb689aa7573d4ac9fc83d057f99c79a5d8f3bd90
|
[
"MIT"
] | null | null | null |
#ifndef CRAMER3_HPP_
#define CRAMER3_HPP_
#include "sarrus.hpp"
template<class Real>
void cramer3(Real *px,Real *py,Real *pz,
Real a11,Real a12,Real a13,
Real a21,Real a22,Real a23,
Real a31,Real a32,Real a33,
Real b1,Real b2, Real b3 )
{ Real det;
*px = sarrus(b1 ,a12,a13, b2 ,a22,a23, b3 ,a32,a33);
*py = sarrus(a11,b1 ,a13, a21,b2 ,a23, a31,b3 ,a33);
*pz = sarrus(a11,a12,b1 , a21,a22,b2 , a31,a32,b3 );
det = sarrus(a11,a12,a13, a21,a22,a23, a31,a32,a33);
if(det != 0.0){ *px/=det;*py/=det;*pz/=det;}
}
#endif
| 28.05
| 54
| 0.614973
|
naruto2
|
bb6f6a9899e7430bb2baa063d47f87f6d5d5fd8c
| 2,446
|
cc
|
C++
|
smartag/src/model/ListDpiGroupsResult.cc
|
aliyun/aliyun-openapi-cpp-sdk
|
0cf5861ece17dfb0bb251f13bf3fbdb39c0c6e36
|
[
"Apache-2.0"
] | 89
|
2018-02-02T03:54:39.000Z
|
2021-12-13T01:32:55.000Z
|
smartag/src/model/ListDpiGroupsResult.cc
|
aliyun/aliyun-openapi-cpp-sdk
|
0cf5861ece17dfb0bb251f13bf3fbdb39c0c6e36
|
[
"Apache-2.0"
] | 89
|
2018-03-14T07:44:54.000Z
|
2021-11-26T07:43:25.000Z
|
smartag/src/model/ListDpiGroupsResult.cc
|
aliyun/aliyun-openapi-cpp-sdk
|
0cf5861ece17dfb0bb251f13bf3fbdb39c0c6e36
|
[
"Apache-2.0"
] | 69
|
2018-01-22T09:45:52.000Z
|
2022-03-28T07:58:38.000Z
|
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/smartag/model/ListDpiGroupsResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Smartag;
using namespace AlibabaCloud::Smartag::Model;
ListDpiGroupsResult::ListDpiGroupsResult() :
ServiceResult()
{}
ListDpiGroupsResult::ListDpiGroupsResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
ListDpiGroupsResult::~ListDpiGroupsResult()
{}
void ListDpiGroupsResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto allDpiGroupNode = value["DpiGroup"]["DpiGroupItem"];
for (auto valueDpiGroupDpiGroupItem : allDpiGroupNode)
{
DpiGroupItem dpiGroupObject;
if(!valueDpiGroupDpiGroupItem["MinSignatureDbVersion"].isNull())
dpiGroupObject.minSignatureDbVersion = valueDpiGroupDpiGroupItem["MinSignatureDbVersion"].asString();
if(!valueDpiGroupDpiGroupItem["DpiGroupName"].isNull())
dpiGroupObject.dpiGroupName = valueDpiGroupDpiGroupItem["DpiGroupName"].asString();
if(!valueDpiGroupDpiGroupItem["DpiGroupId"].isNull())
dpiGroupObject.dpiGroupId = valueDpiGroupDpiGroupItem["DpiGroupId"].asString();
if(!valueDpiGroupDpiGroupItem["MinEngineVersion"].isNull())
dpiGroupObject.minEngineVersion = valueDpiGroupDpiGroupItem["MinEngineVersion"].asString();
dpiGroup_.push_back(dpiGroupObject);
}
if(!value["TotalCount"].isNull())
totalCount_ = std::stoi(value["TotalCount"].asString());
if(!value["NextToken"].isNull())
nextToken_ = value["NextToken"].asString();
}
int ListDpiGroupsResult::getTotalCount()const
{
return totalCount_;
}
std::string ListDpiGroupsResult::getNextToken()const
{
return nextToken_;
}
std::vector<ListDpiGroupsResult::DpiGroupItem> ListDpiGroupsResult::getDpiGroup()const
{
return dpiGroup_;
}
| 31.358974
| 104
| 0.769011
|
aliyun
|
bb80df157fd5d29ec9fecf367f679530b3722441
| 3,649
|
cpp
|
C++
|
02-functions-and-libs/readerEx.02.09/main.cpp
|
heavy3/programming-abstractions
|
e10eab5fe7d9ca7d7d4cc96551524707214e43a8
|
[
"MIT"
] | 81
|
2018-11-15T21:23:19.000Z
|
2022-03-06T09:46:36.000Z
|
02-functions-and-libs/readerEx.02.09/main.cpp
|
heavy3/programming-abstractions
|
e10eab5fe7d9ca7d7d4cc96551524707214e43a8
|
[
"MIT"
] | null | null | null |
02-functions-and-libs/readerEx.02.09/main.cpp
|
heavy3/programming-abstractions
|
e10eab5fe7d9ca7d7d4cc96551524707214e43a8
|
[
"MIT"
] | 41
|
2018-11-15T21:23:24.000Z
|
2022-02-24T03:02:26.000Z
|
//
// main.cpp
//
// This program implements the classic permutation function from
// statistics:
//
// P(n, k) = n! / (n - k)!
//
// in such a way as to avoid overflow for potentially large factorials.
//
// --------------------------------------------------------------------------
// Attribution: "Programming Abstractions in C++" by Eric Roberts
// Chapter 2, Exercise 9
// Stanford University, Autumn Quarter 2012
// http://web.stanford.edu/class/archive/cs/cs106b/cs106b.1136/materials/CS106BX-Reader.pdf
// --------------------------------------------------------------------------
//
// Created by Glenn Streiff on 9/19/15.
// Copyright © 2015 Glenn Streiff. All rights reserved.
//
#include <iostream>
#include <string>
#include <cstdlib>
// Function prototypes
void error(std::string msg);
long permutations(unsigned n, unsigned k);
bool testPermutations(unsigned n, unsigned k, long expectedAnswer);
// Main program
int main(int argc, char * argv[]) {
unsigned nItems = 6;
unsigned chooseK = 2;
long expectedAnswer = 30;
testPermutations(nItems, chooseK, expectedAnswer);
nItems = 6;
chooseK = 0;
expectedAnswer = 1;
testPermutations(nItems, chooseK, expectedAnswer);
nItems = 0;
chooseK = 2;
expectedAnswer = 1;
testPermutations(nItems, chooseK, expectedAnswer);
return 0;
}
// Function definitions
//
// Function: error
// Usage: error("Goodbye, bitter sweet existence.");
// ----------------------
// Returns control to the operating system with EXIT_FAILURE,
// defined in <cstdlib>
//
void error(std::string msg) {
std::cerr << msg << std::endl;
exit(EXIT_FAILURE);
}
//
// Function: permutations
// Usage: int answer = permutations(nItems, chooseK);
// --------------------------------------------------
// This functions returns the number of permutations for
// for choosing n items k at a time with choice order
// considered significant as given in this formula:
//
// P(n, k) = n! / (n - k)!
//
// Implementation is optimized (and overflow avoided)
// by using the denominator as a guide to factoring out
// a clever form of one.
//
long permutations(unsigned nItems, unsigned chooseK) {
long numeratorProduct = 1;
//
// Given that P(6, 2) = 6 * 5 * 4 * 3 * 2 * 1 / 4 * 3 * 2 * 1
//
// we can avoid evaluation of the denominator and corresponding
// portions of the numerator by factoring out a clever form of
// one, leaving just a partial factorial in the numerator to evaluate:
//
// P(6, 2) = (4 * 3 * 2 * 1) * (6 * 5) = 6 * 5 = 30
// ------------------------- -----
// (4 * 3 * 2 * 1) * 1 1
//
for (int i = nItems; i > (nItems - chooseK); i--) {
numeratorProduct *= i;
}
return numeratorProduct;
}
//
// Function: testPermutations
// Usage: (testPermutations(6, 2, 30)) ? std::cout << "pass" : std::cout "fail";
// -----------------------------------------------------------------------------
// Tests the permutation primitive by comparing the actual answer against
// an expected answer passed in as the final argument.
//
bool testPermutations(unsigned n, unsigned k, long expectedAnswer) {
long actualAnswer = permutations(n, k);
if (actualAnswer == expectedAnswer ) {
std::cout << "[PASS] P(" << n << ", " << k << ") = " << expectedAnswer
<< std::endl;
return true;
} else {
std::cout << "[FAIL] P(" << n << ", " << k << ") = " << actualAnswer
<< " (expecting " << expectedAnswer << ")" << std::endl;
return false;
}
}
| 29.192
| 91
| 0.560702
|
heavy3
|
bb82786b464cb26a5ff7bbbce7c227c9daf1cccc
| 444
|
hpp
|
C++
|
xctest/xctest_process.hpp
|
daher-alfawares/xctest
|
70a38a54e8d8229bd51182cf518a4a5ea3d4257f
|
[
"Apache-2.0"
] | 1
|
2017-12-08T22:35:28.000Z
|
2017-12-08T22:35:28.000Z
|
xctest/xctest_process.hpp
|
daher-alfawares/xctest
|
70a38a54e8d8229bd51182cf518a4a5ea3d4257f
|
[
"Apache-2.0"
] | null | null | null |
xctest/xctest_process.hpp
|
daher-alfawares/xctest
|
70a38a54e8d8229bd51182cf518a4a5ea3d4257f
|
[
"Apache-2.0"
] | null | null | null |
//
// xctest_process.hpp
// xctest
//
// Created by Daher Alfawares on 8/29/17.
// Copyright © 2017 Daher Alfawares. All rights reserved.
//
#ifndef xctest_process_hpp
#define xctest_process_hpp
#include <string>
#include <sstream>
namespace xctest {
class process {
public:
process(std::string process);
std::string output();
private:
std::stringstream out;
};
}
#endif /* xctest_process_hpp */
| 17.076923
| 58
| 0.655405
|
daher-alfawares
|
bb844b3252df0c53e5516622c90cd5c446e4edd0
| 5,759
|
cpp
|
C++
|
jni/src/java-m3g-common.cpp
|
bryan10328/java-m3g
|
571baeae7be590b78a0f73a5d5e58506b5525446
|
[
"MIT"
] | 2
|
2017-03-19T09:00:45.000Z
|
2021-01-17T13:25:56.000Z
|
jni/src/java-m3g-common.cpp
|
bryan10328/java-m3g
|
571baeae7be590b78a0f73a5d5e58506b5525446
|
[
"MIT"
] | null | null | null |
jni/src/java-m3g-common.cpp
|
bryan10328/java-m3g
|
571baeae7be590b78a0f73a5d5e58506b5525446
|
[
"MIT"
] | 3
|
2017-01-31T17:25:06.000Z
|
2017-07-12T10:11:03.000Z
|
#include <jni.h>
#include <iostream>
#include <typeinfo>
#include "m3g/m3g.hpp"
#include "java-Loader.hpp"
#include "java-m3g-common.hpp"
using namespace m3g;
using namespace std;
void* getNativePointer (JNIEnv* env, jobject obj)
{
if (obj == 0) {
return NULL;
}
jclass clazz = env->GetObjectClass (obj);
jfieldID fid = env->GetFieldID (clazz, "nativePointer", "J");
void* pointer = (void*)env->GetLongField (obj, fid);
env->DeleteLocalRef (clazz);
return pointer;
}
void setNativePointer (JNIEnv* env, jobject obj, void* pointer)
{
jclass clazz = env->GetObjectClass (obj);
jfieldID fid = env->GetFieldID (clazz, "nativePointer", "J");
env->SetLongField (obj, fid, (long)pointer);
env->DeleteLocalRef (clazz);
}
jobject getJavaReference (JNIEnv* env, m3g::Object* obj)
{
if (obj == NULL) {
return 0;
}
jobject entity = (jobject)obj->getExportedEntity();
return env->NewLocalRef(entity);
}
void bindJavaReference (JNIEnv* env, jobject thiz, m3g::Object* obj)
{
jobject entity = env->NewWeakGlobalRef (thiz);
obj->setExportedEntity (entity);
}
void releaseJavaReference (JNIEnv* env, m3g::Object* obj)
{
jobject entity = (jobject)obj->getExportedEntity();
env->DeleteWeakGlobalRef (entity);
}
jobject allocJavaObject (JNIEnv* env, const char* class_name)
{
jclass clazz = env->FindClass (class_name);
jobject thiz = env->AllocObject (clazz);
env->DeleteLocalRef (clazz);
return thiz;
}
int getByteArrayLength (JNIEnv* env, jbyteArray array)
{
return env->GetArrayLength (array);
}
int getShortArrayLength (JNIEnv* env, jshortArray array)
{
return env->GetArrayLength (array);
}
int getintArrayLength (JNIEnv* env, jintArray array)
{
return env->GetArrayLength (array);
}
int getFloatArrayLength (JNIEnv* env, jfloatArray array)
{
return env->GetArrayLength (array);
}
char* getByteArrayPointer (JNIEnv* env, jbyteArray array)
{
char* pointer = NULL;
if (array) {
pointer = (char*)env->GetByteArrayElements (array, 0);
}
return pointer;
}
short* getShortArrayPointer (JNIEnv* env, jshortArray array)
{
short* pointer = NULL;
if (array) {
pointer = env->GetShortArrayElements (array, 0);
}
return pointer;
}
int* getIntArrayPointer (JNIEnv* env, jintArray array)
{
int* pointer = NULL;
if (array) {
pointer = env->GetIntArrayElements (array, 0);
}
return pointer;
}
float* getFloatArrayPointer (JNIEnv* env, jfloatArray array)
{
float* pointer = NULL;
if (array) {
pointer = env->GetFloatArrayElements (array, 0);
}
return pointer;
}
void releaseByteArrayPointer (JNIEnv* env, jbyteArray array, char* pointer)
{
if (array && pointer) {
env->ReleaseByteArrayElements (array, (jbyte*)pointer, 0);
}
}
void releaseShortArrayPointer (JNIEnv* env, jshortArray array, short* pointer)
{
if (array && pointer) {
env->ReleaseShortArrayElements (array, pointer, 0);
}
}
void releaseIntArrayPointer (JNIEnv* env, jintArray array, int* pointer)
{
if (array && pointer) {
env->ReleaseIntArrayElements (array, pointer, 0);
}
}
void releaseFloatArrayPointer (JNIEnv* env, jfloatArray array, float* pointer)
{
if (array && pointer) {
env->ReleaseFloatArrayElements (array, pointer, 0);
}
}
/**
* m3g::Objectに相当するJavaオブジェクトを作成する.
*/
void Java_new_JavaM3GObject (JNIEnv* env, m3g::Object3D* obj)
{
if (typeid(*obj) == typeid(AnimationController))
Java_new_AnimationController (env, obj);
else if (typeid(*obj) == typeid(AnimationTrack))
Java_new_AnimationTrack (env, obj);
else if (typeid(*obj) == typeid(Appearance))
Java_new_Appearance (env, obj);
else if (typeid(*obj) == typeid(Background))
Java_new_Background (env, obj);
else if (typeid(*obj) == typeid(Camera))
Java_new_Camera (env, obj);
else if (typeid(*obj) == typeid(CompositingMode))
Java_new_CompositingMode (env, obj);
else if (typeid(*obj) == typeid(Fog))
Java_new_Fog (env, obj);
else if (typeid(*obj) == typeid(Group))
Java_new_Group (env, obj);
else if (typeid(*obj) == typeid(Image2D))
Java_new_Image2D (env, obj);
else if (typeid(*obj) == typeid(KeyframeSequence))
Java_new_KeyframeSequence (env, obj);
else if (typeid(*obj) == typeid(Light))
Java_new_Light (env, obj);
else if (typeid(*obj) == typeid(Material))
Java_new_Material (env, obj);
else if (typeid(*obj) == typeid(Mesh))
Java_new_Mesh (env, obj);
else if (typeid(*obj) == typeid(MorphingMesh))
Java_new_MorphingMesh (env, obj);
else if (typeid(*obj) == typeid(PolygonMode))
Java_new_PolygonMode (env, obj);
else if (typeid(*obj) == typeid(SkinnedMesh))
Java_new_SkinnedMesh (env, obj);
else if (typeid(*obj) == typeid(Sprite3D))
Java_new_Sprite3D (env, obj);
else if (typeid(*obj) == typeid(Texture2D))
Java_new_Texture2D (env, obj);
else if (typeid(*obj) == typeid(TriangleStripArray))
Java_new_TriangleStripArray (env, obj);
else if (typeid(*obj) == typeid(VertexArray))
Java_new_VertexArray (env, obj);
else if (typeid(*obj) == typeid(VertexBuffer))
Java_new_VertexBuffer (env, obj);
else if (typeid(*obj) == typeid(World))
Java_new_World (env, obj);
else {
cout << "java-m3g-common: Unknwon object.\n";
}
}
| 28.369458
| 78
| 0.624761
|
bryan10328
|
bb9445bddc9e50bb7b8b0b482dd231dd0ce8bed0
| 611
|
cpp
|
C++
|
engine/calculators/source/unit_tests/SpellboundCalculator_test.cpp
|
sidav/shadow-of-the-wyrm
|
747afdeebed885b1a4f7ab42f04f9f756afd3e52
|
[
"MIT"
] | 60
|
2019-08-21T04:08:41.000Z
|
2022-03-10T13:48:04.000Z
|
engine/calculators/source/unit_tests/SpellboundCalculator_test.cpp
|
cleancoindev/shadow-of-the-wyrm
|
51b23e98285ecb8336324bfd41ebf00f67b30389
|
[
"MIT"
] | 3
|
2021-03-18T15:11:14.000Z
|
2021-10-20T12:13:07.000Z
|
engine/calculators/source/unit_tests/SpellboundCalculator_test.cpp
|
cleancoindev/shadow-of-the-wyrm
|
51b23e98285ecb8336324bfd41ebf00f67b30389
|
[
"MIT"
] | 8
|
2019-11-16T06:29:05.000Z
|
2022-01-23T17:33:43.000Z
|
#include "gtest/gtest.h"
TEST(SW_World_Calculator_SpellboundCalculator, calc_pct_chance_spellbound)
{
CreaturePtr creature = std::make_shared<Creature>();
creature->set_willpower(3);
creature->get_resistances().set_resistance_value(DamageType::DAMAGE_TYPE_ARCANE, 1.0);
SpellboundCalculator sc;
EXPECT_EQ(10, sc.calculate_pct_chance_effect(creature));
creature->set_willpower(51);
EXPECT_EQ(5, sc.calculate_pct_chance_effect(creature));
creature->get_resistances().set_resistance_value(DamageType::DAMAGE_TYPE_ARCANE, 0.8);
EXPECT_EQ(4, sc.calculate_pct_chance_effect(creature));
}
| 26.565217
| 88
| 0.792144
|
sidav
|
bb95d7ec8196807f1ca1519a45c555327be12565
| 1,605
|
hpp
|
C++
|
include/ecs/RigidBodyObjectComponent.hpp
|
icebreakersentertainment/ice_engine
|
52a8313bc266c053366bdf554b5dc27a54ddcb25
|
[
"MIT"
] | null | null | null |
include/ecs/RigidBodyObjectComponent.hpp
|
icebreakersentertainment/ice_engine
|
52a8313bc266c053366bdf554b5dc27a54ddcb25
|
[
"MIT"
] | null | null | null |
include/ecs/RigidBodyObjectComponent.hpp
|
icebreakersentertainment/ice_engine
|
52a8313bc266c053366bdf554b5dc27a54ddcb25
|
[
"MIT"
] | 1
|
2019-06-11T03:41:48.000Z
|
2019-06-11T03:41:48.000Z
|
#ifndef RIGIDBODYOBJECTCOMPONENT_H_
#define RIGIDBODYOBJECTCOMPONENT_H_
#include "physics/CollisionShapeHandle.hpp"
#include "physics/RigidBodyObjectHandle.hpp"
#include "serialization/Serialization.hpp"
namespace ice_engine
{
namespace ecs
{
struct RigidBodyObjectComponent
{
RigidBodyObjectComponent() = default;
RigidBodyObjectComponent(physics::CollisionShapeHandle collisionShapeHandle) : collisionShapeHandle(collisionShapeHandle)
{
};
RigidBodyObjectComponent(physics::CollisionShapeHandle collisionShapeHandle, float32 mass, float32 friction, float32 restitution)
:
collisionShapeHandle(collisionShapeHandle),
mass(mass),
friction(friction),
restitution(restitution)
{
};
RigidBodyObjectComponent(physics::CollisionShapeHandle collisionShapeHandle, float32 mass, float32 friction, float32 restitution, physics::RigidBodyObjectHandle rigidBodyObjectHandle)
:
collisionShapeHandle(collisionShapeHandle),
mass(mass),
friction(friction),
restitution(restitution),
rigidBodyObjectHandle(rigidBodyObjectHandle)
{
};
static uint8 id() { return 4; }
physics::CollisionShapeHandle collisionShapeHandle;
float32 mass = 1.0f;
float32 friction = 1.0f;
float32 restitution = 1.0f;
physics::RigidBodyObjectHandle rigidBodyObjectHandle;
};
}
}
namespace boost
{
namespace serialization
{
template<class Archive>
void serialize(Archive& ar, ice_engine::ecs::RigidBodyObjectComponent& c, const unsigned int version)
{
ar & c.collisionShapeHandle & c.mass & c.friction & c.restitution & c.rigidBodyObjectHandle;
}
}
}
#endif /* RIGIDBODYOBJECTCOMPONENT_H_ */
| 23.602941
| 184
| 0.8
|
icebreakersentertainment
|
bba3e41b6d4ffffcaeaea2cb27e00546c6b987c7
| 8,843
|
cpp
|
C++
|
allofw.node/src/node_sharedmemory.cpp
|
donghaoren/AllofwModule
|
4367327cda0605aad53469294ed8751f8befbdc3
|
[
"Unlicense"
] | 3
|
2016-05-04T23:23:48.000Z
|
2021-08-03T21:48:07.000Z
|
allofw.node/src/node_sharedmemory.cpp
|
donghaoren/AllofwModule
|
4367327cda0605aad53469294ed8751f8befbdc3
|
[
"Unlicense"
] | null | null | null |
allofw.node/src/node_sharedmemory.cpp
|
donghaoren/AllofwModule
|
4367327cda0605aad53469294ed8751f8befbdc3
|
[
"Unlicense"
] | 2
|
2016-01-31T04:06:51.000Z
|
2016-09-30T16:38:36.000Z
|
#include <node.h>
#include <node_buffer.h>
#include <v8.h>
#include "node_sharedmemory.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <stdexcept>
using namespace v8;
void NODE_SharedMemory::Init(Handle<Object> exports) {
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
tpl->SetClassName(Nan::New<String>("SharedMemory").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
Nan::SetPrototypeMethod(tpl, "size", NODE_size);
Nan::SetPrototypeMethod(tpl, "shmid", NODE_shmid);
Nan::SetPrototypeMethod(tpl, "semid", NODE_semid);
Nan::SetPrototypeMethod(tpl, "buffer", NODE_buffer);
Nan::SetPrototypeMethod(tpl, "delete", NODE_delete);
Nan::SetPrototypeMethod(tpl, "close", NODE_close);
Nan::SetPrototypeMethod(tpl, "writeLock", NODE_writeLock);
Nan::SetPrototypeMethod(tpl, "writeUnlock", NODE_writeUnlock);
Nan::SetPrototypeMethod(tpl, "readLock", NODE_readLock);
Nan::SetPrototypeMethod(tpl, "readUnlock", NODE_readUnlock);
constructor.Reset(tpl->GetFunction());
// Export constructor.
Nan::Set(exports, Nan::New<String>("SharedMemory").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
}
int shmrm(key_t key) {
if(key) {
int id = shmget(key, 0, 0);
if(id == -1)
return -1;
return shmctl(id, IPC_RMID, NULL);
}
return -1;
}
int semrm(key_t key) {
if(key) {
int id = semget(key, 0, 0);
if(id == -1)
return -1;
return semctl(id, 0, IPC_RMID, NULL);
}
return -1;
}
// open(key: int, size: int) -> [ shm_id, sem_id ]
NODE_SharedMemory::NODE_SharedMemory(int key, int size_, bool is_create_) {
is_create = is_create_;
shm_data = NULL;
size = size_;
if(is_create) {
// Try to remove first.
shmrm(key);
semrm(key);
shm_id = shmget(key, size, IPC_CREAT | IPC_EXCL | 0666);
if(shm_id < 0) { perror("shmget"); return; }
sem_id = semget(key, 2, IPC_CREAT | IPC_EXCL | 0666);
if(sem_id < 0) { perror("semget"); return; }
short sarray[2] = { 0, 0 };
semctl(sem_id, 0, SETALL, sarray);
shm_data = (unsigned char*)shmat(shm_id, NULL, 0);
} else {
shm_id = shmget(key, size, 0666);
if(shm_id < 0) { perror("shmget"); return; }
sem_id = semget(key, 2, 0666);
if(sem_id < 0) { perror("semget"); return; }
shm_data = (unsigned char*)shmat(shm_id, NULL, 0);
}
}
NODE_SharedMemory::NODE_SharedMemory(int shmid, int semid, int size_, bool is_create_) {
is_create = is_create_;
shm_data = NULL;
size = size_;
if(is_create) {
shm_id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0666);
if(shm_id < 0) { perror("shmget2"); return; }
sem_id = semget(IPC_PRIVATE, 2, IPC_CREAT | 0666);
if(sem_id < 0) { perror("semget2"); return; }
short sarray[2] = { 0, 0 };
semctl(sem_id, 0, SETALL, sarray);
shm_data = (unsigned char*)shmat(shm_id, NULL, 0);
} else {
shm_id = shmid;
sem_id = semid;
shm_data = (unsigned char*)shmat(shm_id, NULL, 0);
}
}
NODE_SharedMemory::~NODE_SharedMemory() {
if(is_create) {
if(sem_id >= 0) semctl(sem_id, 0, IPC_RMID, 0);
if(shm_id >= 0) shmctl(shm_id, IPC_RMID, 0);
}
}
NAN_METHOD(NODE_SharedMemory::New) {
Nan::HandleScope scope;
if(info.IsConstructCall()) {
if(info.Length() == 3) {
int key = info[0]->IntegerValue();
int size = info[1]->IntegerValue();
bool is_create = info[2]->BooleanValue();
NODE_SharedMemory* obj = new NODE_SharedMemory(key, size, is_create);
if(obj->shm_id < 0 || obj->sem_id < 0) {
Nan::ThrowError("SharedMemory: shmget()/semget() failed.");
}
obj->Wrap(info.This());
info.GetReturnValue().Set(info.This());
} else if(info.Length() == 4) {
int shmid = info[0]->IntegerValue();
int semid = info[1]->IntegerValue();
int size = info[2]->IntegerValue();
bool is_create = info[3]->BooleanValue();
NODE_SharedMemory* obj = new NODE_SharedMemory(shmid, semid, size, is_create);
if(obj->shm_id < 0 || obj->sem_id < 0) {
Nan::ThrowError("SharedMemory: shmget()/semget() failed.");
}
obj->Wrap(info.This());
info.GetReturnValue().Set(info.This());
} else {
Nan::ThrowError("SharedMemory: invalid arguments.");
}
} else {
// Invoked as plain function `MyObject(...)`, turn into construct call.
const int argc = 3;
Local<Value> argv[argc] = { info[0], info[1], info[2] };
info.GetReturnValue().Set(Nan::New(constructor)->NewInstance(argc, argv));
}
}
NAN_METHOD(NODE_SharedMemory::NODE_size) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
info.GetReturnValue().Set(Nan::New<Integer>(obj->size));
}
NAN_METHOD(NODE_SharedMemory::NODE_shmid) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
info.GetReturnValue().Set(Nan::New<Integer>(obj->shm_id));
}
NAN_METHOD(NODE_SharedMemory::NODE_semid) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
info.GetReturnValue().Set(Nan::New<Integer>(obj->sem_id));
}
void do_nothing_free_callback(char* data, void* hint) { }
NAN_METHOD(NODE_SharedMemory::NODE_buffer) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
if(obj->shm_data) {
int start = info[0]->IsUndefined() ? 0 : info[0]->IntegerValue();
int length = info[1]->IsUndefined() ? obj->size : info[1]->IntegerValue();
info.GetReturnValue().Set(Nan::NewBuffer((char*)obj->shm_data + start, length, do_nothing_free_callback, NULL).ToLocalChecked());
} else {
Nan::ThrowError("buffer: shared memory deleted or not opened.");
}
}
NAN_METHOD(NODE_SharedMemory::NODE_delete) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
if(obj->sem_id >= 0) semctl(obj->sem_id, 0, IPC_RMID, 0);
if(obj->shm_id >= 0) shmctl(obj->shm_id, IPC_RMID, 0);
obj->shm_id = -1;
obj->sem_id = -1;
obj->shm_data = NULL;
info.GetReturnValue().Set(info.This());
}
NAN_METHOD(NODE_SharedMemory::NODE_close) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
shmdt(obj->shm_data);
info.GetReturnValue().Set(info.This());
}
NAN_METHOD(NODE_SharedMemory::NODE_writeLock) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
sembuf operations[2];
operations[0].sem_num = 1; // wait for reads to be zero.
operations[0].sem_op = 0;
operations[0].sem_flg = 0;
operations[1].sem_num = 0; // increment writes.
operations[1].sem_op = 1;
operations[1].sem_flg = 0;
if(semop(obj->sem_id, operations, 2) == 0) {
info.GetReturnValue().Set(info.This());
} else {
Nan::ThrowError("writeLock: semop() failed.");
}
}
NAN_METHOD(NODE_SharedMemory::NODE_writeUnlock) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
sembuf operations[1];
operations[0].sem_num = 0; // decrement writes.
operations[0].sem_op = -1;
operations[0].sem_flg = 0;
if(semop(obj->sem_id, operations, 1) == 0) {
info.GetReturnValue().Set(info.This());
} else {
Nan::ThrowError("writeUnlock: semop() failed.");
}
}
NAN_METHOD(NODE_SharedMemory::NODE_readLock) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
sembuf operations[2];
operations[0].sem_num = 0; // wait for writes to be zero.
operations[0].sem_op = 0;
operations[0].sem_flg = 0;
operations[1].sem_num = 1; // increment reads.
operations[1].sem_op = 1;
operations[1].sem_flg = 0;
if(semop(obj->sem_id, operations, 2) == 0) {
info.GetReturnValue().Set(info.This());
} else {
Nan::ThrowError("readUnlock: semop() failed.");
}
}
NAN_METHOD(NODE_SharedMemory::NODE_readUnlock) {
NODE_SharedMemory* obj = node::ObjectWrap::Unwrap<NODE_SharedMemory>(info.This());
sembuf operations[1];
operations[0].sem_num = 1; // decrement reads.
operations[0].sem_op = -1;
operations[0].sem_flg = 0;
if(semop(obj->sem_id, operations, 1) == 0) {
info.GetReturnValue().Set(info.This());
} else {
Nan::ThrowError("readUnlock: semop() failed.");
}
}
Nan::Persistent<v8::Function> NODE_SharedMemory::constructor;
| 34.952569
| 137
| 0.622979
|
donghaoren
|
bbaec392dfb693c4adc22fe7d91aac984a4cefd7
| 6,591
|
cpp
|
C++
|
source/octoon-hal/OpenGL 30/gl30_texture.cpp
|
naeioi/octoon
|
e32152fe4730fa609def41114613dbe067d31276
|
[
"MIT"
] | null | null | null |
source/octoon-hal/OpenGL 30/gl30_texture.cpp
|
naeioi/octoon
|
e32152fe4730fa609def41114613dbe067d31276
|
[
"MIT"
] | null | null | null |
source/octoon-hal/OpenGL 30/gl30_texture.cpp
|
naeioi/octoon
|
e32152fe4730fa609def41114613dbe067d31276
|
[
"MIT"
] | null | null | null |
#include "gl30_texture.h"
namespace octoon
{
namespace hal
{
OctoonImplementSubClass(GL30Texture, GraphicsTexture, "GL30Texture")
GL30Texture::GL30Texture() noexcept
: _texture(GL_NONE)
, _target(GL_INVALID_ENUM)
, _pbo(GL_NONE)
, _pboSize(0)
{
}
GL30Texture::~GL30Texture() noexcept
{
this->close();
}
bool
GL30Texture::setup(const GraphicsTextureDesc& textureDesc) noexcept
{
assert(_texture == GL_NONE);
GLenum target = GL30Types::asTextureTarget(textureDesc.getTexDim());
if (target == GL_INVALID_ENUM)
return false;
GLenum internalFormat = GL30Types::asTextureInternalFormat(textureDesc.getTexFormat());
if (internalFormat == GL_INVALID_ENUM)
return false;
glGenTextures(1, &_texture);
if (_texture == GL_NONE)
{
GL_PLATFORM_LOG("glGenTextures() fail");
return false;
}
glBindTexture(target, _texture);
GLsizei width = (GLsizei)textureDesc.getWidth();
GLsizei height = (GLsizei)textureDesc.getHeight();
GLsizei depth = (GLsizei)textureDesc.getDepth();
GLsizei mipBase = textureDesc.getMipBase();
GLsizei mipLevel = std::max((GLsizei)textureDesc.getMipNums(), 1);
if (target == GL_TEXTURE_2D)
glTexStorage2D(target, mipLevel, internalFormat, width, height);
else if (target == GL_TEXTURE_2D_ARRAY)
glTexStorage3D(target, mipLevel, internalFormat, width, height, depth);
else if (target == GL_TEXTURE_3D)
glTexStorage3D(target, mipLevel, internalFormat, width, height, depth);
else if (target == GL_TEXTURE_CUBE_MAP)
glTexStorage2D(target, mipLevel, internalFormat, width, height);
auto stream = textureDesc.getStream();
if (stream)
{
if (GL30Types::isCompressedTexture(textureDesc.getTexFormat()))
{
GLsizei offset = 0;
GLint oldPackStore = 1;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &oldPackStore);
glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
for (GLint mip = mipBase; mip < mipBase + mipLevel; mip++)
{
GLsizei w = std::max(width / (1 << mip), 1);
GLsizei h = std::max(height / (1 << mip), 1);
GLsizei mipSize = GL30Types::getCompressedTextureSize(w, h, 1, internalFormat);
glCompressedTexSubImage2D(target, mip, 0, 0, w, h, internalFormat, mipSize, (char*)stream + offset);
offset += mipSize;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, oldPackStore);
}
else
{
GLenum format = GL30Types::asTextureFormat(textureDesc.getTexFormat());
GLenum type = GL30Types::asTextureType(textureDesc.getTexFormat());
GLsizei offset = 0;
GLsizei pixelSize = GL30Types::getFormatNum(format, type);
GLenum cubeFace[] =
{
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};
GLint oldPackStore = 1;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &oldPackStore);
if (pixelSize == 1)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
else if (pixelSize == 2)
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
else if (pixelSize == 4 || pixelSize == 12)
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
else if (pixelSize == 8 || pixelSize == 16)
glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
else
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
for (GLsizei mip = mipBase; mip < mipBase + mipLevel; mip++)
{
GLsizei w = std::max(width / (1 << mip), 1);
GLsizei h = std::max(height / (1 << mip), 1);
GLsizei mipSize = w * h * pixelSize;
GLsizei layerBase = textureDesc.getLayerBase() + 1;
GLsizei layerLevel = textureDesc.getLayerNums();
for (GLsizei layer = layerBase; layer < layerBase + layerLevel; layer++)
{
if (target == GL_TEXTURE_2D)
{
glTexSubImage2D(target, mip, 0, 0, w, h, format, type, (char*)stream + offset);
offset += mipSize;
}
else
{
if (target == GL_TEXTURE_CUBE_MAP)
{
for (std::size_t i = 0; i < 6; i++)
{
if (target == GL_TEXTURE_CUBE_MAP)
glTexSubImage2D(cubeFace[i], mip, 0, 0, w, h, format, type, (char*)stream + offset);
else
glTexSubImage3D(cubeFace[i], mip, 0, 0, 0, w, h, layer, format, type, (char*)stream + offset);
offset += mipSize;
}
}
else
{
glTexSubImage3D(target, mip, 0, 0, 0, w, h, depth * layer, format, type, (char*)stream + offset);
offset += mipSize * depth;
}
}
}
}
glPixelStorei(GL_UNPACK_ALIGNMENT, oldPackStore);
}
}
glBindTexture(target, GL_NONE);
_target = target;
_textureDesc = textureDesc;
return GL30Check::checkError();
}
void
GL30Texture::close() noexcept
{
if (_texture != GL_NONE)
{
glDeleteTextures(1, &_texture);
_texture = GL_NONE;
}
}
GLenum
GL30Texture::getTarget() const noexcept
{
return _target;
}
GLuint
GL30Texture::getInstanceID() const noexcept
{
return _texture;
}
bool
GL30Texture::map(std::uint32_t x, std::uint32_t y, std::uint32_t w, std::uint32_t h, std::uint32_t mipLevel, void** data) noexcept
{
assert(data);
GLenum format = GL30Types::asTextureFormat(_textureDesc.getTexFormat());
if (format == GL_INVALID_ENUM)
return false;
GLenum type = GL30Types::asTextureType(_textureDesc.getTexFormat());
if (type == GL_INVALID_ENUM)
return false;
GLsizei num = GL30Types::getFormatNum(format, type);
if (num == 0)
return false;
if (_pbo == GL_NONE)
glGenBuffers(1, &_pbo);
glBindBuffer(GL_PIXEL_PACK_BUFFER, _pbo);
GLsizei mapSize = w * h * num;
if (_pboSize < mapSize)
{
glBufferData(GL_PIXEL_PACK_BUFFER, mapSize, nullptr, GL_STREAM_READ);
_pboSize = mapSize;
}
glBindTexture(_target, _texture);
glReadPixels(x, y, w, h, format, type, 0);
*data = glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, mapSize, GL_MAP_READ_BIT);
return *data != nullptr;
}
void
GL30Texture::unmap() noexcept
{
glBindBuffer(GL_PIXEL_PACK_BUFFER, _pbo);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
}
const std::uint64_t
GL30Texture::handle() const noexcept
{
return _texture;
}
const GraphicsTextureDesc&
GL30Texture::getTextureDesc() const noexcept
{
return _textureDesc;
}
void
GL30Texture::setDevice(GraphicsDevicePtr device) noexcept
{
_device = device;
}
GraphicsDevicePtr
GL30Texture::getDevice() noexcept
{
return _device.lock();
}
}
}
| 26.258964
| 132
| 0.656046
|
naeioi
|
bbb469bcc1e2ca6aa4d70e262070ee4eb862c92d
| 23,128
|
cpp
|
C++
|
library/Java/Util/Vector/VectorTest.cpp
|
foodtiny/native
|
9025d337c50951b2d31eb243d0b5414496171ea5
|
[
"Zlib"
] | 19
|
2017-06-10T11:32:06.000Z
|
2018-07-07T13:38:50.000Z
|
library/Java/Util/Vector/VectorTest.cpp
|
tinylife-io/native
|
9025d337c50951b2d31eb243d0b5414496171ea5
|
[
"Zlib"
] | 188
|
2017-06-10T19:45:18.000Z
|
2018-07-27T16:52:21.000Z
|
library/Java/Util/Vector/VectorTest.cpp
|
foodtiny/native
|
9025d337c50951b2d31eb243d0b5414496171ea5
|
[
"Zlib"
] | 8
|
2017-06-23T06:59:16.000Z
|
2018-07-19T11:38:24.000Z
|
/**
* Copyright (c) 2016 Tiny Express Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "../../../Test.hpp"
#include "Vector.hpp"
using namespace Java::Util;
TEST (JavaUtilVector, Constructor) {
Vector<int> vector;
assertEquals(10, vector.capacity());
// Checks initial capacity.
Vector<int> vector1(30);
assertEquals(30, vector1.capacity());
// Checks initial capacity and capacity increment.
Vector<int> vector2(3, 2);
assertEquals(0, vector2.size());
assertEquals(3, vector2.capacity());
vector2.add(1);
assertEquals(1, vector2.size());
assertEquals(3, vector2.capacity());
vector2.add(2);
assertEquals(2, vector2.size());
assertEquals(3, vector2.capacity());
vector2.add(3);
assertEquals(3, vector2.size());
assertEquals(3, vector2.capacity());
// new capacity = old capacity + capacity increment.
vector2.add(4);
assertEquals(4, vector2.size());
assertEquals(5, vector2.capacity());
}
TEST (JavaUtilVector, InitializerListConstructor) {
// Given a vector construct from a std::initializer_list.
Vector<int> vector{1, 2, 3, 4, 5};
// Checks size.
assertEquals(5, vector.size());
// Check the first-last elements.
assertEquals(1, vector.firstElement());
assertEquals(5, vector.lastElement());
}
TEST (JavaUtilVector, CopyConstructor) {
// Given a valid vector.
Vector<int> target;
target.add(1);
target.add(2);
target.add(3);
target.add(4);
target.add(5);
// Use copy-constructor.
Vector<int> vector(target);
assertEquals(target.size(), vector.size());
assertEquals(target.firstElement(), vector.firstElement());
assertEquals(target.lastElement(), vector.lastElement());
}
TEST (JavaUtilVector, Add) {
// Given a valid vector - check size and check the first - last element.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
assertEquals(5, vector.size());
assertEquals(1, vector.firstElement());
assertEquals(5, vector.lastElement());
// Add an element at specified index in vector
// return that element at that index.
vector.add(3, 100);
assertEquals(100, vector.get(3));
assertEquals(4, vector.get(4));
// Test exception
try {
vector.add(-1, 100);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.add(100, 100);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, AddAll) {
// Given an empty vector.
Vector<int> vector1;
// Add all elements from initializer list.
assertTrue(vector1.addAll({1, 2, 3, 4, 5}));
// Checks size.
assertEquals(5, vector1.size());
// Check the first-last elements.
assertEquals(1, vector1.firstElement());
assertEquals(5, vector1.lastElement());
// Given a valid vector.
Vector<int> vector2;
vector2.add(1);
vector2.add(2);
vector2.add(3);
vector2.add(4);
vector2.add(5);
// Add initializer list at index 2.
assertTrue(vector2.addAll(2, {7, 8, 9}));
// Check the first-last element.
assertEquals(8, vector2.size());
assertEquals(1, vector2.firstElement());
assertEquals(5, vector2.lastElement());
// Check element at index 2.
assertEquals(7, vector2.get(2));
}
TEST (JavaUtilVector, AddElement) {
Vector<int> vector;
vector.addElement(1);
vector.addElement(2);
vector.addElement(3);
vector.addElement(4);
vector.addElement(5);
assertEquals(1, vector.firstElement());
assertEquals(5, vector.lastElement());
}
TEST (JavaUtilVector, Clear) {
// Given empty vector - return size of vector is 0.
Vector<String> vector;
assertEquals(0, vector.size());
// Add three elements into vector - return size of vector is 3.
vector.add("Hello");
vector.add("World");
vector.add("Vector");
assertEquals(3, vector.size());
// Clear all elements of vector - return size of vector is 0.
vector.clear();
assertEquals(0, vector.size());
}
TEST (JavaUtilVector, Clone) {
// Given an empty vector, check size of cloned vector.
Vector<int> vector;
Vector<int> clonedVector1 = vector.clone();
assertEquals(0, clonedVector1.size());
// Given a valid vector, check size of cloned vector;
// check first-last element.7
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
Vector<int> clonedVector2 = vector.clone();
assertEquals(5, clonedVector2.size());
assertEquals(1, clonedVector2.firstElement());
assertEquals(5, clonedVector2.lastElement());
}
TEST (JavaUtilVector, Contains) {
// Given a valid vector - checks element exists or not.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
assertFalse(vector.contains(0));
assertTrue(vector.contains(5));
}
TEST (JavaUtilVector, ContainsAll) {
// Given a valid vector.
Vector<int> vector{1, 2, 3, 4, 5};
// Checks vector for having all elements in a list.
assertFalse(vector.containsAll({1, 2, 3, 4, 6}));
assertTrue(vector.containsAll({1, 2, 3, 4, 5}));
}
TEST (JavaUtilVector, CopyInto) {
Vector<int> vector{1, 2, 3, 4, 5};
Array<int> anArray;
vector.copyInto(anArray);
assertEquals(vector.size(), anArray.length);
int index;
for (index = 0; index < vector.size(); index++) {
assertEquals(vector.get(index), anArray.get(index));
}
}
TEST (JavaUtilVector, ElementAt) {
// Given a valid vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
// Get element at the first and the last position.
assertEquals(vector.firstElement(), vector.elementAt(0));
assertEquals(vector.lastElement(), vector.elementAt(4));
}
TEST (JavaUtilVector, EnsureCapacity) {
// Given an empty vector with initial capacity is 10 and capacity increment is 5.
Vector<int> vector1(10, 5);
assertEquals(10, vector1.capacity());
// New capacity = old capacity + capacity increment.
vector1.ensureCapacity(12);
assertEquals(15, vector1.capacity());
// New capacity = min capacity (because old capacity + capacity increment < min capacity).
vector1.ensureCapacity(25);
assertEquals(25, vector1.capacity());
// Given an empty vector with initial capacity is 10 and capacity increment is 0.
Vector<int> vector2(10, 0);
// New capacity = old capacity * 2 (because capacity increment is zero).
vector2.ensureCapacity(15);
assertEquals(20, vector2.capacity());
// New capacity = min capacity (because old capacity * 2 < min capacity).
vector2.ensureCapacity(100);
assertEquals(100, vector2.capacity());
}
TEST (JavaUtilVector, Equals) {
// Given two valid vectors, check they are equals or not.
Vector<int> vector1{1, 2, 3, 4, 5};
Vector<int> target1{1, 2, 3, 5, 4};
assertFalse(vector1.equals(target1));
// Given two valid vector, check they are equals or not.
Vector<int> vector2{1, 2, 3, 4, 5, 6, 7};
Vector<int> target2{1, 2, 3, 4, 5, 6, 7};
assertTrue(vector2.equals(target2));
// Test different size
Vector<int> vector3;
Vector<int> target3;
vector3.setSize(5);
target3.setSize(10);
assertFalse(vector3.equals(target3));
}
TEST (JavaUtilVector, FirstElement) {
// Given a valid vector, contains three elements are string - return the first element.
Vector<String> vector;
vector.add("Hello");
vector.add("World");
vector.add("Vector");
assertEquals("Hello", vector.firstElement().toString());
// Test exception
Vector<String> emptyVector;
try {
emptyVector.firstElement();
} catch (Exception exception) {
assertEquals("vector is empty", exception.getMessage());
}
}
TEST (JavaUtilVector, Get) {
// Given an valid vector with elements are string.
Vector<String> vector;
vector.add("Hello");
vector.add("World");
vector.add("I'm");
vector.add("a");
vector.add("Vector");
// Get element at index 0, then index 4.
assertEquals("Hello", vector.get(0).toString());
assertEquals("Vector", vector.get(4).toString());
// Test exception
try {
vector.get(-1);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.remove(100);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, IsEmpty) {
// Given an empty vector, vector is empty.
Vector<int> vector;
assertTrue(vector.isEmpty());
// Add an element into vector, vector is not empty.
vector.add(0);
assertFalse(vector.isEmpty());
}
TEST (JavaUtilVector, IndexOf) {
// Given a valid vector - return index of an element in vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
assertEquals(0, vector.indexOf(1));
assertEquals(2, vector.indexOf(3));
vector.clear();
vector.add(1);
vector.add(2);
vector.add(4);
vector.add(4);
vector.add(5);
assertEquals(-1, vector.indexOf(4, 4));
assertEquals(2, vector.indexOf(4, 0));
// Test exception
try {
vector.indexOf(4, -1);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.indexOf(4, 100);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, InsertElementAt) {
// Given a valid vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
assertEquals(1, vector.firstElement());
assertEquals(5, vector.lastElement());
// Inserts an element.
vector.insertElementAt(0, 0);
// Checks that element after added.
assertEquals(0, vector.get(0));
}
TEST (JavaUtilVector, LastElement) {
// Given a valid vector, contains three elements are string - return the last element.
Vector<String> vector;
vector.add("Hello");
vector.add("World");
vector.add("Vector");
assertEquals("Vector", vector.lastElement().toString());
// Test exception
Vector<String> emptyVector;
try {
emptyVector.lastElement();
} catch (Exception exception) {
assertEquals("vector is empty", exception.getMessage());
}
}
TEST (JavaUtilVector, LastIndexOf) {
// Given an valid vector - check last index of some elements.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(2);
vector.add(2);
vector.add(5);
assertEquals(0, vector.lastIndexOf(1));
assertEquals(3, vector.lastIndexOf(2));
assertEquals(3, vector.lastIndexOf(2, 4));
assertEquals(1, vector.lastIndexOf(2, 1));
// Test exception
try {
vector.lastIndexOf(2, -1);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.lastIndexOf(2, 100);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, Remove) {
// Given empty vector, add three elements, remove at index 1 twice times, then remove at index 0.
// Result is element that removed from vector.
Vector<int> vector1;
vector1.add(1);
vector1.add(2);
vector1.add(3);
assertEquals(2, vector1.remove(1));
assertEquals(3, vector1.remove(1));
assertEquals(1, vector1.remove(0));
// Check size of vector.
assertEquals(0, vector1.size());
// Given a valid vector, removes specified elements.
Vector<String> vector2;
vector2.add(String("1"));
vector2.add(String("2"));
vector2.add(String("3"));
vector2.add(String("4"));
vector2.add(String("5"));
// assertFalse(vector2.remove(String("10"))); // This element doesn't exists.
// assertTrue(vector2.remove(String("5")));
Vector<Integer> vector3;
vector3.add(Integer(1));
vector3.add(Integer(2));
vector3.add(Integer(3));
vector3.add(Integer(4));
vector3.add(Integer(5));
vector3.remove(Integer(3));
assertFalse(vector3.contains(Integer(3)));
assertFalse(vector3.remove(Integer(10)));
// Test execption
try {
vector1.remove(-1);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector1.remove(100);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, RemoveAll) {
// Given a valid vector.
Vector<int> vector({1, 2, 3, 4, 5});
// Removes element appearing in the specified list.
assertTrue(vector.removeAll({1, 2, 3}));
// Checks size and the first-last element.
assertEquals(2, vector.size());
assertEquals(4, vector.firstElement());
assertEquals(5, vector.lastElement());
}
TEST (JavaUtilVector, RemoveAllElements) {
// Given empty vector - return size of vector is 0.
Vector<String> vector;
assertEquals(0, vector.size());
// Add three elements into vector - return size of vector is 3.
vector.add("Hello");
vector.add("World");
vector.add("Vector");
assertEquals(3, vector.size());
// Remove all elements of vector - return size of vector is 0.
vector.clear();
assertEquals(0, vector.size());
}
TEST (JavaUtilVector, RemoveElement) {
Vector<Integer> vector;
vector.add(Integer(1));
vector.add(Integer(2));
vector.add(Integer(3));
vector.add(Integer(4));
vector.add(Integer(5));
vector.removeElement(Integer(3));
assertEquals(4, vector.size());
assertFalse(vector.contains(Integer(3)));
}
TEST (JavaUtilVector, RemoveElementAt) {
// Given a valid vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
// Removes element at index = 2.
vector.removeElementAt(2);
// Checks element value at index = 2.
assertEquals(4, vector.get(2));
}
// This class use to call some protected methods in Vector class to run in test cases.
template<typename E>
class VectorFriend : public Vector<E> {
public:
void removeRange(int fromIndex, int toIndex) {
Vector<E>::removeRange(fromIndex, toIndex);
}
};
TEST (JavaUtilVector, RemoveRange) {
// Given a valid vector.
VectorFriend<int> vector;
vector.add(1); // 0
vector.add(2); // 1
vector.add(3); // 2
vector.add(4); // 3
vector.add(5);
vector.add(6);
vector.add(7);
vector.add(8);
// index: 0 1 2 3 4 5 6 7
// value: 1 2 3 4 5 6 7 8
// Removes elements at index: {1, 2}
vector.removeRange(1, 3);
// index: 0 1 2 3 4 5
// value: 1 4 5 6 7 8
assertEquals(1, vector.get(0));
assertEquals(4, vector.get(1));
// index: 0 1 2 3 4 5
// value: 1 4 5 6 7 8
// Remove element at index : {1, 1}
vector.removeRange(1, 1);
// index: 0 1 2 3 4
// value: 1 5 6 7 8
assertEquals(1, vector.get(0));
assertEquals(5, vector.get(1));
// Test Exception
try {
vector.removeRange(3, 1);
} catch (IllegalArgumentException exception) {
assertEquals("start index greater than end index", exception.getMessage());
}
try {
vector.removeRange(-1, 5);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.removeRange(100, 3);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.removeRange(1, -1);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.removeRange(1, 100);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, RetainAll) {
Vector<int> vector{1, 2, 3, 4, 5};
assertTrue(vector.retainAll({4, 5, 6}));
assertEquals(2, vector.size());
assertEquals(4, vector.firstElement());
assertEquals(5, vector.lastElement());
}
TEST (JavaUtilVector, Set) {
// Given a valid vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
// Change element at index 0.
assertEquals(1, vector.set(0, 10));
// Check element at index 0.
assertEquals(10, vector.get(0));
// Change element at index 4.
assertEquals(5, vector.set(4, 0));
// Check element at index 4.
assertEquals(0, vector.get(4));
// Test index out of range
try {
vector.set(-1, 1302);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
try {
vector.set(100, 1302);
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, SetElementAt) {
// Given a valid vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
// Change element at index 0.
vector.setElementAt(10, 0);
// Check element at index 0.
assertEquals(10, vector.get(0));
// Change element at index 4.
vector.setElementAt(0, 4);
// Check element at index 4.
assertEquals(0, vector.get(4));
}
TEST (JavaUtilVector, SetSize) {
// Given a valid vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
vector.add(6);
vector.add(7);
vector.add(8);
vector.add(9);
// Set new size > original size
vector.setSize(20);
assertEquals(20, vector.size());
// Sets size and checks size.
vector.setSize(5);
assertEquals(5, vector.size());
// Set negative size
try {
vector.setSize(-1);
} catch (IllegalArgumentException exception) {
assertEquals("new size is negative", exception.getMessage());
}
}
TEST (JavaUtilVector, Size) {
// Given a empty vector, then add an element - return size.
Vector<int> vector;
vector.add(0);
assertEquals(1, vector.size());
// Remove the element at index 0 - return size.
vector.remove(0);
assertEquals(0, vector.size());
// Add five elements into vector - return size.
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
assertEquals(5, vector.size());
}
TEST (JavaUtilVector, ToArray) {
// Given a valid vector.
Vector<int> vector{1, 2, 3, 4, 5};
// Copies vector to an array.
Array<int> anArray = vector.toArray();
// Check elements of vector and array at same order.
int index;
for (index = 0; index < vector.size(); index++) {
assertEquals(vector[index], anArray[index]);
}
}
TEST (JavaUtilVector, TrimToSize) {
// Given a valid vector.
Vector<int> vector;
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
vector.add(5);
vector.add(6);
// Trims the capacity to be the current size.
vector.trimToSize();
assertEquals(vector.size(), vector.capacity());
// After removing an element, capacity is not equal with size.
vector.remove(0);
assertNotEquals(vector.size(), vector.capacity());
vector.trimToSize();
assertEquals(vector.size(), vector.capacity());
}
TEST (JavaUtilVector, RangeBasedForLoop) {
// Given a valid vector.
Vector<int> vector;
vector.add(0);
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
// Using range-base-for-loop and checks element value.
int index = 0;
for (int element : vector) {
assertEquals(index, element);
index++;
}
}
TEST (JavaUtilVector, ArrayOperator) {
// Given a valid vector.
Vector<int> vector;
vector.add(0);
vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);
// Accesses element value using array operator.
int index;
for (index = 0; index < vector.size(); index++) {
assertEquals(index, vector[index]);
}
vector[0] = -1;
assertEquals(-1, vector.get(0));
// Test IllegalArgumentException
try {
vector[-1] = 1302;
} catch (IllegalArgumentException exception) {
assertEquals("index is out of range", exception.getMessage());
}
}
TEST (JavaUtilVector, AssignmentOperator) {
// Given an empty vector and add an element to it.
Vector<int> vector;
vector.add(-1);
// Assigns with an initializer list.
vector = {1, 2, 3, 4, 5};
// Checks size and the first-last element.
assertEquals(5, vector.size());
assertEquals(1, vector.firstElement());
assertEquals(5, vector.lastElement());
// Given an target vector with some elements inside.
Vector<int> target{10, 11, 12};
// Assigns target to vector.
vector = target;
// Checks size and the first-last element.
assertEquals(3, vector.size());
assertEquals(10, vector.firstElement());
assertEquals(12, vector.lastElement());
}
| 27.698204
| 101
| 0.642987
|
foodtiny
|
bbb58ffceb8ecdb195da3b9189229bcc639e5b98
| 865
|
hpp
|
C++
|
src/lib/storage/proxy_chunk.hpp
|
nilsthamm/hyrise
|
75a701f281bb7dc1636832012c43005ec3c66384
|
[
"MIT"
] | 2
|
2019-01-22T19:44:32.000Z
|
2019-01-22T19:52:33.000Z
|
src/lib/storage/proxy_chunk.hpp
|
nilsthamm/hyrise
|
75a701f281bb7dc1636832012c43005ec3c66384
|
[
"MIT"
] | 33
|
2019-02-02T09:52:50.000Z
|
2019-03-07T13:14:40.000Z
|
src/lib/storage/proxy_chunk.hpp
|
nilsthamm/hyrise
|
75a701f281bb7dc1636832012c43005ec3c66384
|
[
"MIT"
] | 1
|
2020-11-30T13:11:04.000Z
|
2020-11-30T13:11:04.000Z
|
#pragma once
#include <algorithm>
#include <atomic>
#include <memory>
#include "chunk.hpp"
namespace opossum {
// The ProxyChunk class wraps chunk objects and implements the RAII pattern
// to track the time a particular chunk has been in scope. These times are
// measured using the RDTSC instructions and are stored in the Chunk's
// ChunkAccessCounter.
class ProxyChunk {
public:
explicit ProxyChunk(const std::shared_ptr<Chunk>& chunk);
~ProxyChunk();
const std::shared_ptr<Chunk> operator*() const { return _chunk; }
const std::shared_ptr<Chunk> operator->() const { return _chunk; }
operator const std::shared_ptr<Chunk>&() const { return _chunk; }
bool operator==(const ProxyChunk& rhs) const { return _chunk == rhs._chunk; }
protected:
const std::shared_ptr<Chunk> _chunk;
const uint64_t _begin_rdtsc;
};
} // namespace opossum
| 25.441176
| 79
| 0.730636
|
nilsthamm
|
bbb7a7fdb37b7082341295665bff96c2d5a148cb
| 376
|
cpp
|
C++
|
2021/05/02/jh20s/Biweekly Contest 49/1815.cpp
|
jh20s/stupid-week-2021
|
790d9a361ce708ea3e3dad33a5dc2d5549482a9b
|
[
"MIT"
] | 28
|
2020-12-21T16:16:55.000Z
|
2022-02-08T08:20:55.000Z
|
2021/05/02/jh20s/Biweekly Contest 49/1815.cpp
|
jh20s/stupid-week-2021
|
790d9a361ce708ea3e3dad33a5dc2d5549482a9b
|
[
"MIT"
] | 98
|
2021-01-01T11:07:02.000Z
|
2021-08-28T06:49:43.000Z
|
2021/05/02/jh20s/Biweekly Contest 49/1815.cpp
|
jh20s/stupid-week-2021
|
790d9a361ce708ea3e3dad33a5dc2d5549482a9b
|
[
"MIT"
] | 37
|
2021-01-02T07:44:28.000Z
|
2021-11-01T03:51:16.000Z
|
class Solution {
public:
int rev(int num) {
int ret = 0;
while (num) {
ret = ret * 10 + num % 10;
num /= 10;
}
return ret;
}
int countNicePairs(vector<int>& nums) {
int ret = 0;
vector<int> v;
map<int, int> m;
for (int i = 0; i < nums.size(); i++) {
int f = nums[i] - rev(nums[i]);
if(m.count(f))
ret = (ret+m[f])%1000000007;
m[f]++;
}
return ret;
}
};
| 15.666667
| 40
| 0.539894
|
jh20s
|
bbb80428e65e149720126a5b2579d9d28ac55014
| 2,088
|
cpp
|
C++
|
svntrunk/src/BlueMatter/bringup/tenrootl/call_tenrootl.cpp
|
Bhaskers-Blu-Org1/BlueMatter
|
1ab2c41af870c19e2e1b1095edd1d5c85eeb9b5e
|
[
"BSD-2-Clause"
] | 7
|
2020-02-25T15:46:18.000Z
|
2022-02-25T07:04:47.000Z
|
svntrunk/src/BlueMatter/bringup/tenrootl/call_tenrootl.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | null | null | null |
svntrunk/src/BlueMatter/bringup/tenrootl/call_tenrootl.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | 5
|
2019-06-06T16:30:21.000Z
|
2020-11-16T19:43:01.000Z
|
/* Copyright 2001, 2019 IBM Corporation
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
void tenrootl(double* f, const double* x, int groupcount) ;
extern "C" {
int _CP_main(void) ;
int _IOP_main(void) ;
void s0printf(const char *, ...) ;
unsigned long long GetTimeBase(void) ;
} ;
void call_tenrootl(void)
{
double src[210] ;
double tgt[200] ;
double d = 1.0 ;
for (int a=0; a<400; a+=1)
{
src[a] = d ;
d += 1.0 ;
} /* endfor */
long long tbstart = GetTimeBase() ;
for (int b=0; b<400000; b+=1)
{
tenrootl(tgt,src,20) ;
} /* endfor */
long long tbend = GetTimeBase() ;
int taken = tbend-tbstart ;
s0printf("Ending after %i cycles\n",taken) ;
} ;
int _CP_main(void)
{
call_tenrootl() ;
return 0 ;
}
int _IOP_main(void)
{
call_tenrootl() ;
return 0 ;
}
| 34.8
| 118
| 0.704502
|
Bhaskers-Blu-Org1
|
c7d96742855a437a4b4b4de2b8eca08defde13c4
| 4,014
|
cc
|
C++
|
multibody/fem/dev/linear_constitutive_model.cc
|
RobotLocomotion/drake-python3.7
|
ae397a4c6985262d23e9675b9bf3927c08d027f5
|
[
"BSD-3-Clause"
] | 2
|
2021-02-25T02:01:02.000Z
|
2021-03-17T04:52:04.000Z
|
multibody/fem/dev/linear_constitutive_model.cc
|
RobotLocomotion/drake-python3.7
|
ae397a4c6985262d23e9675b9bf3927c08d027f5
|
[
"BSD-3-Clause"
] | null | null | null |
multibody/fem/dev/linear_constitutive_model.cc
|
RobotLocomotion/drake-python3.7
|
ae397a4c6985262d23e9675b9bf3927c08d027f5
|
[
"BSD-3-Clause"
] | 1
|
2021-06-13T12:05:39.000Z
|
2021-06-13T12:05:39.000Z
|
#include "drake/multibody/fem/dev/linear_constitutive_model.h"
#include "drake/common/unused.h"
namespace drake {
namespace multibody {
namespace fem {
template <typename T>
LinearConstitutiveModel<T>::LinearConstitutiveModel(const T& youngs_modulus,
const T& poisson_ratio)
: E_(youngs_modulus), nu_(poisson_ratio) {
VerifyParameterValidity(E_, nu_);
SetLameParameters(E_, nu_);
/* Recall that
Pᵢⱼ = 2μ * εᵢⱼ + λ * εₐₐ * δᵢⱼ,
So,
∂Pᵢⱼ/∂Fₖₗ = 2μ * ∂εᵢⱼ/∂Fₖₗ + λ * ∂εₐₐ/∂Fₖₗ * δᵢⱼ,
Since
∂εᵢⱼ/∂Fₖₗ = 0.5 * δᵢₖ δⱼₗ + 0.5 * δᵢₗ δₖⱼ.
Plugging in, we get:
∂Pᵢⱼ/∂Fₖₗ = μ * (δᵢₖδⱼₗ + δᵢₗ δⱼₖ) + λ * δₖₗ * δᵢⱼ.
Keep in mind that the indices are laid out such that the ik-th entry in the
jl-th block corresponds to the value dPᵢⱼ/dFₖₗ. */
// First term.
dPdF_ = mu_ * Eigen::Matrix<T, 9, 9>::Identity();
for (int k = 0; k < 3; ++k) {
// Second term.
for (int l = 0; l < 3; ++l) {
const int i = l;
const int j = k;
dPdF_(3 * j + i, 3 * l + k) += mu_;
}
// Third term.
for (int i = 0; i < 3; ++i) {
const int l = k;
const int j = i;
dPdF_(3 * j + i, 3 * l + k) += lambda_;
}
}
}
template <typename T>
void LinearConstitutiveModel<T>::DoCalcElasticEnergyDensity(
const DeformationGradientCacheEntry<T>& cache_entry,
std::vector<T>* Psi) const {
const LinearConstitutiveModelCacheEntry<T>& linear_cache_entry =
static_cast<const LinearConstitutiveModelCacheEntry<T>&>(cache_entry);
for (int i = 0; i < linear_cache_entry.num_quadrature_points(); ++i) {
const auto& strain = linear_cache_entry.strain()[i];
const auto& trace_strain = linear_cache_entry.trace_strain()[i];
(*Psi)[i] = mu_ * strain.squaredNorm() +
0.5 * lambda_ * trace_strain * trace_strain;
}
}
template <typename T>
void LinearConstitutiveModel<T>::DoCalcFirstPiolaStress(
const DeformationGradientCacheEntry<T>& cache_entry,
std::vector<Matrix3<T>>* P) const {
const LinearConstitutiveModelCacheEntry<T>& linear_cache_entry =
static_cast<const LinearConstitutiveModelCacheEntry<T>&>(cache_entry);
for (int i = 0; i < linear_cache_entry.num_quadrature_points(); ++i) {
const auto& strain = linear_cache_entry.strain()[i];
const auto& trace_strain = linear_cache_entry.trace_strain()[i];
(*P)[i] =
2.0 * mu_ * strain + lambda_ * trace_strain * Matrix3<T>::Identity();
}
}
template <typename T>
void LinearConstitutiveModel<T>::DoCalcFirstPiolaStressDerivative(
const DeformationGradientCacheEntry<T>& cache_entry,
std::vector<Eigen::Matrix<T, 9, 9>>* dPdF) const {
unused(cache_entry);
std::fill(dPdF->begin(), dPdF->end(), dPdF_);
}
template <typename T>
std::unique_ptr<DeformationGradientCacheEntry<T>>
LinearConstitutiveModel<T>::DoMakeDeformationGradientCacheEntry(
ElementIndex element_index, int num_quadrature_points) const {
return std::make_unique<LinearConstitutiveModelCacheEntry<T>>(
element_index, num_quadrature_points);
}
template <typename T>
void LinearConstitutiveModel<T>::VerifyParameterValidity(
const T& youngs_modulus, const T& poisson_ratio) const {
if (youngs_modulus < 0.0) {
throw std::logic_error("Young's modulus must be nonnegative.");
}
if (poisson_ratio >= 0.5 || poisson_ratio <= -1) {
throw std::logic_error("Poisson ratio must be in (-1, 0.5).");
}
}
template <typename T>
void LinearConstitutiveModel<T>::SetLameParameters(const T& youngs_modulus,
const T& poisson_ratio) {
mu_ = youngs_modulus / (2.0 * (1.0 + poisson_ratio));
lambda_ = youngs_modulus * poisson_ratio /
((1.0 + poisson_ratio) * (1.0 - 2.0 * poisson_ratio));
}
} // namespace fem
} // namespace multibody
} // namespace drake
DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_NONSYMBOLIC_SCALARS(
class ::drake::multibody::fem::LinearConstitutiveModel);
| 36.825688
| 79
| 0.661684
|
RobotLocomotion
|
c7dd3e1073c647dae2f1ffc4c27ae24be1714020
| 4,029
|
hxx
|
C++
|
include/itkSinusoidImageSource.hxx
|
dzenanz/ITKPhaseSymmetry
|
0b6993c4f7d1d48db110d145f6f2b22c84e5f2dd
|
[
"Apache-2.0"
] | null | null | null |
include/itkSinusoidImageSource.hxx
|
dzenanz/ITKPhaseSymmetry
|
0b6993c4f7d1d48db110d145f6f2b22c84e5f2dd
|
[
"Apache-2.0"
] | null | null | null |
include/itkSinusoidImageSource.hxx
|
dzenanz/ITKPhaseSymmetry
|
0b6993c4f7d1d48db110d145f6f2b22c84e5f2dd
|
[
"Apache-2.0"
] | null | null | null |
/*=========================================================================
*
* Copyright NumFOCUS
*
* 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.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkSinusoidImageSource_hxx
#define itkSinusoidImageSource_hxx
#include "itkSinusoidSpatialFunction.h"
#include "itkImageRegionIterator.h"
#include "itkProgressReporter.h"
namespace itk
{
template <typename TOutputImage>
SinusoidImageSource<TOutputImage>::SinusoidImageSource()
{
m_Frequency.Fill(1.0);
}
template <typename TOutputImage>
void
SinusoidImageSource<TOutputImage>::PrintSelf(std::ostream & os, Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Sinusoid frequency: [";
for (unsigned int ii = 0; ii < ImageDimension; ++ii)
{
os << this->m_Frequency[ii];
if (ii != ImageDimension - 1)
{
os << ", ";
}
}
os << "]" << std::endl;
os << indent << "Sinusoid phase shift: " << m_PhaseOffset << std::endl;
}
template <typename TOutputImage>
void
SinusoidImageSource<TOutputImage>::SetParameters(const ParametersType & parameters)
{
ArrayType frequency;
for (unsigned int ii = 0; ii < ArrayType::Length; ++ii)
{
frequency[ii] = parameters[ii];
}
this->SetFrequency(frequency);
const double phaseOffset = parameters[ArrayType::Length];
this->SetPhaseOffset(phaseOffset);
}
template <typename TOutputImage>
typename SinusoidImageSource<TOutputImage>::ParametersType
SinusoidImageSource<TOutputImage>::GetParameters() const
{
ParametersType parameters(ArrayType::Length + 1);
for (unsigned int ii = 0; ii < ArrayType::Length; ++ii)
{
parameters[ii] = m_Frequency[ii];
}
parameters[ArrayType::Length] = m_PhaseOffset;
return parameters;
}
template <typename TOutputImage>
unsigned int
SinusoidImageSource<TOutputImage>::GetNumberOfParameters() const
{
return ArrayType::Length + 1;
}
template <typename TOutputImage>
void
SinusoidImageSource<TOutputImage>::GenerateData()
{
TOutputImage * outputPtr = this->GetOutput();
// allocate the output buffer
outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion());
outputPtr->Allocate();
// Create and initialize a new gaussian function
using FunctionType = SinusoidSpatialFunction<double, ImageDimension>;
typename FunctionType::Pointer sinusoid = FunctionType::New();
sinusoid->SetFrequency(m_Frequency);
sinusoid->SetPhaseOffset(m_PhaseOffset);
// Create an iterator that will walk the output region
using OutputIterator = ImageRegionIterator<TOutputImage>;
const typename OutputImageType::RegionType requestedRegion = outputPtr->GetRequestedRegion();
OutputIterator outIt = OutputIterator(outputPtr, outputPtr->GetRequestedRegion());
ProgressReporter progress(this, 0, outputPtr->GetRequestedRegion().GetNumberOfPixels());
// Walk the output image, evaluating the spatial function at each pixel
outIt.GoToBegin();
while (!outIt.IsAtEnd())
{
typename TOutputImage::IndexType index = outIt.GetIndex();
// The position at which the function is evaluated
typename FunctionType::InputType evalPoint;
outputPtr->TransformIndexToPhysicalPoint(index, evalPoint);
const double value = sinusoid->Evaluate(evalPoint);
// Set the pixel value to the function value
outIt.Set(static_cast<typename TOutputImage::PixelType>(value));
progress.CompletedPixel();
++outIt;
}
}
} // end namespace itk
#endif
| 28.778571
| 112
| 0.704641
|
dzenanz
|
c7de81427d353d552d641dd888d213754632c4ce
| 2,083
|
cpp
|
C++
|
oactobjs32/piadata/pib54ame.cpp
|
codeforboston/anypia-emscripten
|
d4d1d154bae6b97acc619d5588d9a7515d220338
|
[
"CC0-1.0"
] | 1
|
2020-09-23T21:46:55.000Z
|
2020-09-23T21:46:55.000Z
|
oactobjs32/piadata/pib54ame.cpp
|
codeforboston/anypia-emscripten
|
d4d1d154bae6b97acc619d5588d9a7515d220338
|
[
"CC0-1.0"
] | 16
|
2020-05-07T18:53:55.000Z
|
2021-03-24T03:16:29.000Z
|
oactobjs32/piadata/pib54ame.cpp
|
codeforboston/anypia-emscripten
|
d4d1d154bae6b97acc619d5588d9a7515d220338
|
[
"CC0-1.0"
] | 6
|
2020-04-19T23:04:22.000Z
|
2021-03-17T01:40:10.000Z
|
// Functions for the <see cref=Pib54Ame"/> class to handle 1954 pib-ame
// conversion table.
//
// $Id: pib54ame.cpp 1.2 2011/08/08 08:45:12EDT 044579 Development $
#include "pibtable.h"
#include "Resource.h"
#include "PiaException.h"
// <summary>The 1954 ame's.</summary>
const double Pib54Ame::ame54[] = {
30.5, 31.0, 31.6, 32.1, 32.7, 33.2, 33.8, 34.3, 34.9, 35.4,
36.0, 36.5, 37.1, 37.6, 38.2, 38.7, 39.3, 39.8, 40.4, 40.9,
41.5, 42.0, 42.6, 43.1, 43.7, 44.2, 44.8, 45.3, 45.9, 46.4,
47.0, 47.5, 48.1, 48.6, 49.2, 49.7, 50.3, 50.8, 51.4, 51.9,
52.5, 53.0, 53.6, 54.1, 54.7, 55.2, 55.8, 56.3, 56.9, 57.4,
58.0, 58.5, 59.1, 59.6, 60.2, 60.5, 60.7, 60.9, 61.1, 61.3,
61.5, 61.7, 61.9, 62.1, 62.3, 62.5, 62.7, 62.9, 63.1, 63.3,
63.5, 63.7, 63.9, 64.1, 64.3, 64.5, 64.7, 64.9, 65.1, 65.3,
65.5, 65.7, 65.9, 66.1, 66.3, 66.5, 66.7, 66.9, 67.1, 67.3,
67.5, 67.7, 67.9, 68.1, 68.3, 68.5, 68.7, 68.9, 69.1, 69.3,
69.5, 69.7, 69.9, 70.1, 70.3, 70.5, 70.7, 70.9, 71.1, 71.3,
71.5, 71.7, 71.9, 72.1, 72.3, 72.5, 72.7, 72.9, 73.1, 73.3,
73.5, 73.7, 73.9, 74.1, 74.4, 74.6, 74.8, 75.0, 75.2, 75.4,
75.6, 75.8, 76.0, 76.2, 76.4, 76.6, 76.8, 77.0, 77.2, 77.4,
77.6, 77.8, 78.0, 78.2, 78.4, 78.6, 78.8, 79.0, 79.2, 79.4,
79.6, 79.8, 80.0, 80.2, 80.4, 80.6, 80.8, 81.0, 81.2, 81.4,
81.6, 81.8, 82.0, 82.2, 82.4, 82.6, 82.8, 83.0, 83.2, 83.4,
83.6, 83.8, 84.0, 84.2, 84.4, 84.6, 84.8, 85.0, 85.2, 85.4,
85.6, 85.8, 86.0, 86.2, 86.4, 86.6, 86.8, 87.0, 87.2, 87.4,
87.6, 87.8, 88.0, 88.2, 88.4, 88.5
};
/// <summary>Returns 1954 conversion table ame.</summary>
///
/// <returns>1954 conversion table ame.</returns>
///
/// <exception cref="PiaException"><see cref="PiaException"/> of type
/// <see cref="PIA_IDS_PIB54PIA"/> if index is out of range (only in debug
/// mode).</exception>
///
/// <param name="index">Number of pia desired.</param>
double Pib54Ame::getAt( int index )
{
#ifndef NDEBUG
if (index < 0 || index > 195)
throw PiaException(PIA_IDS_PIB54PIA);
#endif
return(ame54[index]);
}
| 40.843137
| 75
| 0.550648
|
codeforboston
|
c7e2b142c61337ac424a2697289efb0f88c05745
| 700
|
cpp
|
C++
|
Patterns/In-placeTraversalOfLinkedList/61_rotate_list.cpp
|
xtstc131/mall0x_Leetcode
|
db528f2a78808d4123785c35218cce00906166dd
|
[
"MIT"
] | 1
|
2019-12-25T16:19:21.000Z
|
2019-12-25T16:19:21.000Z
|
Patterns/In-placeTraversalOfLinkedList/61_rotate_list.cpp
|
xtstc131/mall0x_Leetcode
|
db528f2a78808d4123785c35218cce00906166dd
|
[
"MIT"
] | null | null | null |
Patterns/In-placeTraversalOfLinkedList/61_rotate_list.cpp
|
xtstc131/mall0x_Leetcode
|
db528f2a78808d4123785c35218cce00906166dd
|
[
"MIT"
] | null | null | null |
#include "header.hpp"
// Definition for singly-linked list.
struct ListNode
{
int val;
ListNode *next;
ListNode(int x) : val(x), next(nullptr) {}
};
class Solution {
public:
ListNode* rotateRight(ListNode* head, int k) {
if (!head || !head->next || k == 0) return head;
int len = 1;
auto node = head;
while(node->next)
{
node = node->next;
len++;
}
k = k % len;
int move = len - k;
node->next = head;
for(int i = 0; i < move; i++)
{
node = node->next;
}
head = node->next;
node->next = nullptr;
return head;
}
};
| 21.875
| 58
| 0.46
|
xtstc131
|
c7e6e0996cfa865dad7cda2a18032633634b558d
| 229
|
hpp
|
C++
|
shift/scene/public/shift/scene/renderer.hpp
|
cspanier/shift
|
5b3b9be310155fbc57d165d06259b723a5728828
|
[
"Apache-2.0"
] | 2
|
2018-11-28T18:14:08.000Z
|
2020-08-06T07:44:36.000Z
|
shift/scene/public/shift/scene/renderer.hpp
|
cspanier/shift
|
5b3b9be310155fbc57d165d06259b723a5728828
|
[
"Apache-2.0"
] | 4
|
2018-11-06T21:01:05.000Z
|
2019-02-19T07:52:52.000Z
|
shift/scene/public/shift/scene/renderer.hpp
|
cspanier/shift
|
5b3b9be310155fbc57d165d06259b723a5728828
|
[
"Apache-2.0"
] | null | null | null |
#ifndef SHIFT_SCENE_RENDERER_HPP
#define SHIFT_SCENE_RENDERER_HPP
#include <shift/core/abstract_factory.hpp>
#include "shift/scene/entity.hpp"
namespace shift
{
namespace scene
{
class renderer
{
public:
};
}
}
#endif
| 12.052632
| 42
| 0.755459
|
cspanier
|
c7e89a5a4fc5e5b72177e859d8b346950962a287
| 699
|
cpp
|
C++
|
Leetcode/0295. Find Median from Data Stream/0295.cpp
|
Next-Gen-UI/Code-Dynamics
|
a9b9d5e3f27e870b3e030c75a1060d88292de01c
|
[
"MIT"
] | null | null | null |
Leetcode/0295. Find Median from Data Stream/0295.cpp
|
Next-Gen-UI/Code-Dynamics
|
a9b9d5e3f27e870b3e030c75a1060d88292de01c
|
[
"MIT"
] | null | null | null |
Leetcode/0295. Find Median from Data Stream/0295.cpp
|
Next-Gen-UI/Code-Dynamics
|
a9b9d5e3f27e870b3e030c75a1060d88292de01c
|
[
"MIT"
] | null | null | null |
class MedianFinder {
public:
void addNum(int num) {
if (maxHeap.empty() || num <= maxHeap.top())
maxHeap.push(num);
else
minHeap.push(num);
// balance two heaps s.t.
// |maxHeap| >= |minHeap| and |maxHeap| - |minHeap| <= 1
if (maxHeap.size() < minHeap.size())
maxHeap.push(minHeap.top()), minHeap.pop();
else if (maxHeap.size() - minHeap.size() > 1)
minHeap.push(maxHeap.top()), maxHeap.pop();
}
double findMedian() {
if (maxHeap.size() == minHeap.size())
return (maxHeap.top() + minHeap.top()) / 2.0;
return maxHeap.top();
}
private:
priority_queue<int> maxHeap;
priority_queue<int, vector<int>, greater<>> minHeap;
};
| 25.888889
| 60
| 0.596567
|
Next-Gen-UI
|
c7e997c0a28d55fdded483a918e29e51687e3406
| 4,202
|
cc
|
C++
|
permut/permut.cc
|
alex4747-pub/scratchpad
|
507c16adf50e0abe7abbbbc6cc093736b939b8d5
|
[
"MIT"
] | null | null | null |
permut/permut.cc
|
alex4747-pub/scratchpad
|
507c16adf50e0abe7abbbbc6cc093736b939b8d5
|
[
"MIT"
] | null | null | null |
permut/permut.cc
|
alex4747-pub/scratchpad
|
507c16adf50e0abe7abbbbc6cc093736b939b8d5
|
[
"MIT"
] | null | null | null |
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <vector>
static void PrintVec(std::vector<int> const& vec) {
if (vec.empty()) {
return;
}
auto cit = vec.cbegin();
std::cout << (*cit++);
while(cit != vec.cend()) {
std::cout << " " << (*cit++);
}
}
// Dramatically simplified version of next_permutation
// just as a reference
template <class BidirectionalIterator>
bool my_next_permutation (BidirectionalIterator first,
BidirectionalIterator last) {
if (first == last) {
// Empty
return false;
}
BidirectionalIterator i = first;
++i;
if (i == last) {
// Single element
return false;
}
i = last;
--i;
// 1. Starting from the last element find the first element
// not in descending order (i) and its previous one (j).
// if all elements are in descending order reverse them
// and return false
//
// 2. Starting from the last element find the first element
// greater than the one just found (k). It should be always
// be one, in the worst case it is j.
//
// 3. Swap i and k. Note that it does change the main property:
// elements from [j,end) are in descending order
//
// 4. Reverse starting from j to the end, they will be in assendng
// order to get next lexicographical permutation
for(;;) {
BidirectionalIterator j = i;
--i;
if (*i < *j) {
BidirectionalIterator k = last;
while (!(*i < *(--k)));
iter_swap(i, k);
reverse(j, last);
return true;
}
if (i == first) {
reverse(first, last);
return false;
}
}
}
// Same with compare function
template <class BidirectionalIterator, typename Compare>
bool my_next_permutation (BidirectionalIterator first,
BidirectionalIterator last,
Compare comp) {
if (first == last) {
// Empty
return false;
}
BidirectionalIterator i = first;
++i;
if (i == last) {
// Single element
return false;
}
i = last;
--i;
// 1. Starting from the last element find the first element
// not in descending order (i) and its previous one (j).
// if all elements are in descending order reverse them
// and return false
//
// 2. Starting from the last element find the first element
// greater than the one just found (k). It should be always
// be one, in the worst case it is j.
//
// 3. Swap i and k. Note that it does change the main property:
// elements from [j,end) are in descending order
//
// 4. Reverse starting from j to the end, they will be in ascending
// order to get next lexicographical permutation
for(;;) {
BidirectionalIterator j = i;
--i;
if (comp(*i, *j)) {
BidirectionalIterator k = last;
while (!comp(*i,*(--k)));
iter_swap(i, k);
reverse(j, last);
return true;
}
if (i == first) {
reverse(first, last);
return false;
}
}
}
int
main(int, char**) {
std::vector<int> va{1,2,3,4,5};
std::vector<int> vb{1,2,3,4,5};
std::vector<int> vc{1,2,3,4,5};
int count = 0;
std::cout << count << ": ";
PrintVec(va);
std::cout << "\n";
for(;;) {
bool res = std::next_permutation(va.begin(), va.end());
bool my_res1 = my_next_permutation(vb.begin(), vb.end());
bool my_res2 = my_next_permutation(vc.begin(), vc.end(), std::less<int>());
assert(res == my_res1);
assert(va == vb);
assert(res == my_res2);
assert(va == vc);
if (!res) {
break;
}
count++;
std::cout << count << ": ";
PrintVec(va);
std::cout << "\n";
}
std::cout << "done: ";
PrintVec(va);
std::cout << "\n";
return 0;
}
| 24.289017
| 83
| 0.52237
|
alex4747-pub
|
c7e9d675a3c91d828b88549fb83a06912575a227
| 2,095
|
cpp
|
C++
|
example/rpc/rpc_client.cpp
|
gatsbyd/HPNL
|
8e95eef4cb076292b9cf4d88bbb59b37d7beb4eb
|
[
"MIT"
] | 38
|
2019-12-07T04:51:36.000Z
|
2022-03-04T03:17:46.000Z
|
example/rpc/rpc_client.cpp
|
gatsbyd/HPNL
|
8e95eef4cb076292b9cf4d88bbb59b37d7beb4eb
|
[
"MIT"
] | 1
|
2020-07-02T03:55:53.000Z
|
2020-07-02T03:55:53.000Z
|
example/rpc/rpc_client.cpp
|
gatsbyd/HPNL
|
8e95eef4cb076292b9cf4d88bbb59b37d7beb4eb
|
[
"MIT"
] | 10
|
2019-12-21T08:44:36.000Z
|
2022-02-14T14:09:14.000Z
|
#include "echo.pb.h"
#include "args.pb.h"
#include "Log.h"
#include "rpc/RpcClient.h"
#include <assert.h>
#include <stdio.h>
#include <memory>
using namespace melon;
using namespace melon::rpc;
using namespace cherry;
std::shared_ptr<RequestAppendArgs> constructAppendArgs() {
std::shared_ptr<RequestAppendArgs> append_args(new RequestAppendArgs);
append_args->set_term(3);
append_args->set_leader_id(100);
append_args->set_pre_log_index(1);
append_args->set_pre_log_term(1);
append_args->set_leader_commit(1);
//entries
LogEntry* entry = append_args->add_entries();
entry->set_term(1);
entry->set_index(1);
//cmd
std::string cmd_data;
KvCommnad cmd;
cmd.set_operation("GET");
cmd.set_key("key1");
cmd.set_value("value1");
cmd.set_cid(99);
cmd.set_seq(2);
cmd.SerializeToString(&cmd_data);
entry->set_command(cmd_data);
return append_args;
}
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("Usage: %s ip\n", argv[0]);
return 0;
}
Logger::setLogLevel(LogLevel::INFO);
Singleton<Logger>::getInstance()->addAppender("console", LogAppender::ptr(new ConsoleAppender()));
IpAddress server_addr(argv[1], 5000);
Scheduler scheduler;
scheduler.startAsync();
RpcClient client(server_addr, &scheduler);
client.Call<RequestAppendReply>(constructAppendArgs(), [](std::shared_ptr<RequestAppendReply> append_reply) {
LOG_INFO << "append replay. term=" << append_reply->term() << ", success=" << append_reply->success();
});
/**
std::shared_ptr<echo::EchoRequest> request(new echo::EchoRequest);
request->set_msg("hello");
client.Call<echo::EchoResponse>(request, [](std::shared_ptr<echo::EchoResponse> response) {
LOG_INFO << "client receive response, message:" << response->msg();
});
std::shared_ptr<echo::UnregisterRequest> unregister_request(new echo::UnregisterRequest);
unregister_request->set_id(1);
client.Call<echo::EchoResponse>(unregister_request, [](std::shared_ptr<echo::EchoResponse> response) {
LOG_INFO << "client receive response, message:" << response->msg();
});
**/
getchar();
return 0;
}
| 27.565789
| 110
| 0.715513
|
gatsbyd
|
c7ea61af89a54d524bec5cf158112fb0777bd136
| 3,674
|
cpp
|
C++
|
voronoiFinal - working/Box.cpp
|
mcastorena/voronoi
|
09c0d934c7da78d8e53688d81cddf9423a5e904c
|
[
"MIT"
] | null | null | null |
voronoiFinal - working/Box.cpp
|
mcastorena/voronoi
|
09c0d934c7da78d8e53688d81cddf9423a5e904c
|
[
"MIT"
] | null | null | null |
voronoiFinal - working/Box.cpp
|
mcastorena/voronoi
|
09c0d934c7da78d8e53688d81cddf9423a5e904c
|
[
"MIT"
] | null | null | null |
#include "Box.h"
#include "doubleArray.h"
#define INFINITY ((unsigned) ~0)
bool Box::contains(const Vector2& point) const
{
return point.x >= left - EPSILON && point.x <= right + EPSILON &&
point.y >= bottom - EPSILON && point.y <= top + EPSILON;
}
Box::Intersection Box::getFirstIntersection(const Vector2& origin, const Vector2& direction) const
{
// origin must be in the box
Intersection intersection;
double t = INFINITY;
if (direction.x > 0.0)
{
t = (right - origin.x) / direction.x;
intersection.side = Side::RIGHT;
intersection.point = origin + t * direction;
}
else if (direction.x < 0.0)
{
t = (left - origin.x) / direction.x;
intersection.side = Side::LEFT;
intersection.point = origin + t * direction;
}
if (direction.y > 0.0)
{
double newT = (top - origin.y) / direction.y;
if (newT < t)
{
intersection.side = Side::TOP;
intersection.point = origin + newT * direction;
}
}
else if (direction.y < 0.0)
{
double newT = (bottom - origin.y) / direction.y;
if (newT < t)
{
intersection.side = Side::BOTTOM;
intersection.point = origin + newT * direction;
}
}
return intersection;
}
int Box::getIntersections(const Vector2& origin, const Vector2& destination, intersectionArray intersections) const
{
// WARNING: If the intersection is a corner, both intersections are equals
Vector2 direction = destination - origin;
doubleArray t;
unsigned int i = 0; // index of the current intersection
// Left
if (origin.x < left - EPSILON || destination.x < left - EPSILON)
{
t[i] = (left - origin.x) / direction.x;
if (t[i] > EPSILON && t[i] < 1.0 - EPSILON)
{
intersections[i]->side = Side::LEFT;
intersections[i]->point = origin + t[i] * direction;
if (intersections[i]->point.y >= bottom - EPSILON && intersections[i]->point.y <= top + EPSILON)
++i;
}
}
// Right
if (origin.x > right + EPSILON || destination.x > right + EPSILON)
{
t[i] = (right - origin.x) / direction.x;
if (t[i] > EPSILON && t[i] < 1.0 - EPSILON)
{
intersections[i]->side = Side::RIGHT;
intersections[i]->point = origin + t[i] * direction;
if (intersections[i]->point.y >= bottom - EPSILON && intersections[i]->point.y <= top + EPSILON)
++i;
}
}
// Bottom
if (origin.y < bottom - EPSILON || destination.y < bottom - EPSILON)
{
t[i] = (bottom - origin.y) / direction.y;
if (i < 2 && t[i] > EPSILON && t[i] < 1.0 - EPSILON)
{
intersections[i]->side = Side::BOTTOM;
intersections[i]->point = origin + t[i] * direction;
if (intersections[i]->point.x >= left - EPSILON && intersections[i]->point.x <= right + EPSILON)
++i;
}
}
// Top
if (origin.y > top + EPSILON || destination.y > top + EPSILON)
{
t[i] = (top - origin.y) / direction.y;
if (i < 2 && t[i] > EPSILON && t[i] < 1.0 - EPSILON)
{
intersections[i]->side = Side::TOP;
intersections[i]->point = origin + t[i] * direction;
if (intersections[i]->point.x >= left - EPSILON && intersections[i]->point.x <= right + EPSILON)
++i;
}
}
// Sort the intersections from the nearest to the farthest
if (i == 2 && t[0] > t[1])
intersections.swap();
return i;
}
| 33.706422
| 115
| 0.534567
|
mcastorena
|
c7eaf987990ab215dffe455ff117a0ae72b4b4e4
| 583
|
cpp
|
C++
|
Online-Judge-Solution/Codeforces Solutions/91(A.Lucky Division).cpp
|
arifparvez14/Basic-and-competetive-programming
|
4cb9ee7fbed3c70307d0f63499fcede86ed3c732
|
[
"MIT"
] | null | null | null |
Online-Judge-Solution/Codeforces Solutions/91(A.Lucky Division).cpp
|
arifparvez14/Basic-and-competetive-programming
|
4cb9ee7fbed3c70307d0f63499fcede86ed3c732
|
[
"MIT"
] | null | null | null |
Online-Judge-Solution/Codeforces Solutions/91(A.Lucky Division).cpp
|
arifparvez14/Basic-and-competetive-programming
|
4cb9ee7fbed3c70307d0f63499fcede86ed3c732
|
[
"MIT"
] | null | null | null |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,r,k,i,count;
while(cin>>n)
{
k=count=0;
if(n%4==0 || n%7==0 || n%44==0 || n%47==0 || n%444==0 || n%447==0 || n%474==0)
cout<<"YES"<<endl;
else
{
while(n!=0)
{
r=n%10;
n=n/10;
if(r!=4 && r!=7)
count=1;
}
if(count==0)
cout<<"YES"<<endl;
else if(count==1)
cout<<"NO"<<endl;
}
}
return 0;
}
| 20.821429
| 86
| 0.324185
|
arifparvez14
|
c7ecaae102772a23104ab10cdbb4091186a1391e
| 4,212
|
cpp
|
C++
|
src/DefaultPropertyControl.cpp
|
TimoKunze/ExplorerListView
|
8bc0299b7d58def5393527f518fd857f5122b42d
|
[
"MIT"
] | 2
|
2019-12-12T08:12:28.000Z
|
2020-10-02T09:56:48.000Z
|
src/DefaultPropertyControl.cpp
|
TimoKunze/ExplorerListView
|
8bc0299b7d58def5393527f518fd857f5122b42d
|
[
"MIT"
] | null | null | null |
src/DefaultPropertyControl.cpp
|
TimoKunze/ExplorerListView
|
8bc0299b7d58def5393527f518fd857f5122b42d
|
[
"MIT"
] | 1
|
2021-12-09T18:20:14.000Z
|
2021-12-09T18:20:14.000Z
|
// DefaultPropertyControl.cpp: Default implementation of the IPropertyControl interface
#include "stdafx.h"
#include "DefaultPropertyControl.h"
#ifdef INCLUDESUBITEMCALLBACKCODE
DefaultPropertyControl::Properties::~Properties()
{
if(pOwnerExLvw) {
pOwnerExLvw->Release();
}
}
//////////////////////////////////////////////////////////////////////
// implementation of IPropertyControlBase
STDMETHODIMP DefaultPropertyControl::Initialize(LPUNKNOWN, PROPDESC_CONTROL_TYPE)
{
ATLASSERT(FALSE && "Initialize");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::GetSize(PROPCTL_RECT_TYPE /*unknown1*/, HDC /*hDC*/, SIZE const* /*pUnknown2*/, LPSIZE /*pUnknown3*/)
{
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::SetWindowTheme(LPCWSTR, LPCWSTR)
{
ATLASSERT(FALSE && "SetWindowTheme");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::SetFont(HFONT hFont)
{
if(properties.editControl.IsWindow()) {
properties.editControl.SetFont(hFont);
}
return S_OK;
}
STDMETHODIMP DefaultPropertyControl::SetTextColor(COLORREF /*color*/)
{
// must be implemented
return S_OK;
}
STDMETHODIMP DefaultPropertyControl::GetFlags(PINT)
{
ATLASSERT(FALSE && "GetFlags");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::SetFlags(int /*flags*/, int /*mask*/)
{
// must be implemented
return S_OK;
}
STDMETHODIMP DefaultPropertyControl::AdjustWindowRectPCB(HWND /*hWndListView*/, LPRECT /*pItemRectangle*/, RECT const* /*pUnknown1*/, int /*unknown2*/)
{
// must be implemented
return S_OK;
}
STDMETHODIMP DefaultPropertyControl::SetValue(LPUNKNOWN)
{
ATLASSERT(FALSE && "SetValue");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::InvokeDefaultAction(void)
{
ATLASSERT(FALSE && "InvokeDefaultAction");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::Destroy(void)
{
if(properties.editControl.IsWindow()) {
properties.editControl.DestroyWindow();
}
return S_OK;
}
STDMETHODIMP DefaultPropertyControl::SetFormatFlags(int)
{
ATLASSERT(FALSE && "SetFormatFlags");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::GetFormatFlags(PINT)
{
ATLASSERT(FALSE && "GetFormatFlags");
return E_NOTIMPL;
}
// implementation of IPropertyControlBase
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// implementation of IPropertyControl
STDMETHODIMP DefaultPropertyControl::GetValue(REFIID /*requiredInterface*/, LPVOID* /*ppObject*/)
{
ATLASSERT(FALSE && "GetValue");
return E_NOINTERFACE;
}
STDMETHODIMP DefaultPropertyControl::Create(HWND hWndParent, RECT const* pItemRectangle, RECT const* /*pUnknown1*/, int unknown2)
{
ATLASSERT(unknown2 == 0x02 || unknown2 == 0x0C);
if(IsWindow(hWndParent)) {
properties.editControl.Create(hWndParent, *const_cast<LPRECT>(pItemRectangle), NULL, WS_BORDER | WS_CHILDWINDOW | WS_VISIBLE | ES_AUTOHSCROLL | ES_WANTRETURN);
properties.editControl.SetFont(CWindow(hWndParent).GetFont());
properties.editControl.SetFocus();
return S_OK;
}
return E_INVALIDARG;
}
STDMETHODIMP DefaultPropertyControl::SetPosition(RECT const*, RECT const*)
{
ATLASSERT(FALSE && "SetPosition");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::IsModified(LPBOOL /*pModified*/)
{
ATLASSERT(FALSE && "IsModified");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::SetModified(BOOL /*modified*/)
{
ATLASSERT(FALSE && "SetModified");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::ValidationFailed(LPCWSTR)
{
ATLASSERT(FALSE && "ValidationFailed");
return E_NOTIMPL;
}
STDMETHODIMP DefaultPropertyControl::GetState(PINT /*pState*/)
{
ATLASSERT(FALSE && "GetState");
return E_NOTIMPL;
}
// implementation of IPropertyControl
//////////////////////////////////////////////////////////////////////
void DefaultPropertyControl::SetOwner(__in_opt ExplorerListView* pOwner)
{
if(properties.pOwnerExLvw) {
properties.pOwnerExLvw->Release();
}
properties.pOwnerExLvw = pOwner;
if(properties.pOwnerExLvw) {
properties.pOwnerExLvw->AddRef();
}
}
#endif
| 25.527273
| 162
| 0.695157
|
TimoKunze
|
c7ee8d62dd43437da0809c73ce16a9384628a35e
| 1,502
|
cpp
|
C++
|
1 sem/10 week/1 problem/1 problem/test.cpp
|
resueman/HW_Sem1
|
f096c7b026ce13ec4b7df5c9bea980a33697e60a
|
[
"Apache-2.0"
] | null | null | null |
1 sem/10 week/1 problem/1 problem/test.cpp
|
resueman/HW_Sem1
|
f096c7b026ce13ec4b7df5c9bea980a33697e60a
|
[
"Apache-2.0"
] | 1
|
2018-11-22T14:14:55.000Z
|
2018-11-22T14:14:55.000Z
|
1 sem/10 week/1 problem/1 problem/test.cpp
|
resueman/HW_Sem1
|
f096c7b026ce13ec4b7df5c9bea980a33697e60a
|
[
"Apache-2.0"
] | null | null | null |
#include "test.h"
#include "readFromFile.h"
#include <iostream>
using namespace std;
bool test()
{
set<int> noStateVertecies;
vector<int> states;
//Test1
Graph* graph1 = createGraph();
readFromFile("test1.txt", graph1, states, noStateVertecies);
distributeCities(graph1, states, noStateVertecies);
vector<int> result1 = getAnswer(graph1);
vector<int> desiredResult1 = {1, 1, 4, 6, 6, 4, 6, 4};
if (result1 != desiredResult1)
{
deleteGraph(graph1);
return false;
}
cout << "Test 1 passed!!!\n";
deleteGraph(graph1);
noStateVertecies.clear();
states.clear();
//Test2
Graph* graph2 = createGraph();
readFromFile("test2.txt", graph2, states, noStateVertecies);
distributeCities(graph2, states, noStateVertecies);
vector<int> result2 = getAnswer(graph2);
vector<int> desiredResult2 = {1, 2, 3};
if (result2 != desiredResult2)
{
deleteGraph(graph2);
return false;
}
cout << "Test 2 passed!!!\n";
deleteGraph(graph2);
noStateVertecies.clear();
states.clear();
//Test3
Graph* graph3 = createGraph();
readFromFile("test3.txt", graph3, states, noStateVertecies);
distributeCities(graph3, states, noStateVertecies);
vector<int> result3 = getAnswer(graph3);
vector<int> desiredResult3 = {9, 9, 9, 4, 4, 4, 4, 4, 9, 4, 9};
if (result3 != desiredResult3)
{
deleteGraph(graph3);
return false;
}
cout << "Test 3 passed!!!\n";
deleteGraph(graph3);
noStateVertecies.clear();
states.clear();
cout << "\nAll tests passed successfully ;)\n\n";
return true;
}
| 23.46875
| 64
| 0.693076
|
resueman
|
c7f1f5cfbfd989f07df8a6028962e794a27e539c
| 1,237
|
hpp
|
C++
|
src/include/framework/accessmode.hpp
|
achreto/fm-translation-framework
|
a46afcc43f94c8a224f32fcad988a830689a9256
|
[
"MIT"
] | null | null | null |
src/include/framework/accessmode.hpp
|
achreto/fm-translation-framework
|
a46afcc43f94c8a224f32fcad988a830689a9256
|
[
"MIT"
] | null | null | null |
src/include/framework/accessmode.hpp
|
achreto/fm-translation-framework
|
a46afcc43f94c8a224f32fcad988a830689a9256
|
[
"MIT"
] | null | null | null |
/**
* The Access Modes and Permissions
*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2022, Reto Achermann (The University of British Columbia)
*/
#ifndef _ACCESS_MODE_H_
#define _ACCESS_MODE_H_ 1
// access permissions
#define ACCESS_PERMISSION_USER_READ (1 << 0)
#define ACCESS_PERMISSION_USER_WRITE (1 << 1)
#define ACCESS_PERMISSION_NOSEC_READ (1 << 2)
#define ACCESS_PERMISSION_NOSEC_WRITE (1 << 3)
#define ACCESS_PERMISSION_SEC_READ (1 << 4)
#define ACCESS_PERMISSION_SEC_WRITE (1 << 5)
#define ACCESS_PERMISSION_ALL ((1 << 6) - 1)
#define ACCESS_PERMISSION_MASK ACCESS_PERMISSION_ALL
///< the type of register permissions
typedef unsigned int access_perms_t;
///< defines various register access modes
enum access_mode {
ACCESS_MODE_USER_READ = ACCESS_PERMISSION_USER_READ,
ACCESS_MODE_USER_WRITE = ACCESS_PERMISSION_USER_WRITE,
ACCESS_MODE_NOSEC_READ = ACCESS_PERMISSION_NOSEC_READ,
ACCESS_MODE_NOSEC_WRITE = ACCESS_PERMISSION_NOSEC_WRITE,
ACCESS_MODE_SEC_READ = ACCESS_PERMISSION_SEC_READ,
ACCESS_MODE_SEC_WRITE = ACCESS_PERMISSION_SEC_WRITE,
};
///< the type for register access modes
typedef enum access_mode access_mode_t;
#endif /* _ACCESS_MODE_H_ */
| 30.925
| 74
| 0.765562
|
achreto
|
c7f31c7004107a2509705e742e916f694f0ecde1
| 977
|
cpp
|
C++
|
suanfake/HanoiTower.cpp
|
Leon-Francis/AlgorithmPractice
|
bfff066da64ebbb00ecd33d94ebbe5bcc382867c
|
[
"MIT"
] | 1
|
2020-10-07T12:03:12.000Z
|
2020-10-07T12:03:12.000Z
|
suanfake/HanoiTower.cpp
|
Leon-Francis/AlgorithmPractice
|
bfff066da64ebbb00ecd33d94ebbe5bcc382867c
|
[
"MIT"
] | null | null | null |
suanfake/HanoiTower.cpp
|
Leon-Francis/AlgorithmPractice
|
bfff066da64ebbb00ecd33d94ebbe5bcc382867c
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
void MoveTowers(int n, int tower1[52], int tower2[52], int tower3[52])
{
if (n == 1)
{
int temp = tower1[--tower1[1]];
tower3[tower3[1]++] = temp;
cout << "move disk " << temp << " from tower " << tower1[0] << " to tower " << tower3[0] << endl;
;
return;
}
MoveTowers(n - 1, tower1, tower3, tower2);
int temp = tower1[--tower1[1]];
tower3[tower3[1]++] = temp;
cout << "move disk " << temp << " from tower " << tower1[0] << " to tower " << tower3[0] << endl;
MoveTowers(n - 1, tower2, tower1, tower3);
return;
}
int main(int argc, char const *argv[])
{
int n;
cout << "请输入塔的高度:";
cin >> n;
int tower1[52];
int tower2[52] = {2, 2};
int tower3[52] = {3, 2};
tower1[0] = 1;
tower1[1] = n + 2;
for (int i = n + 1; i > 1; i--)
{
tower1[i] = n - i + 2;
}
MoveTowers(n, tower1, tower2, tower3);
return 0;
}
| 25.710526
| 105
| 0.502559
|
Leon-Francis
|
c7f48b90476d9273a83a835e825a587bc26d085e
| 7,212
|
cpp
|
C++
|
CodeXL/Components/ShaderAnalyzer/AMDTBackEnd/Emulator/Parser/ParserSIVOP.cpp
|
jeongjoonyoo/CodeXL
|
ea6d623d0530aa3a862ef0bf60ad2923a2f8f8a5
|
[
"MIT"
] | 1,025
|
2016-04-19T21:36:08.000Z
|
2020-04-26T05:12:53.000Z
|
RadeonGPUAnalyzerBackend/Emulator/Parser/ParserSIVOP.cpp
|
Acidburn0zzz/RGA
|
35cd028602e21f6b8853fdc86b16153b693acb72
|
[
"MIT"
] | 244
|
2016-04-20T02:05:43.000Z
|
2020-04-29T17:40:49.000Z
|
RadeonGPUAnalyzerBackend/Emulator/Parser/ParserSIVOP.cpp
|
Acidburn0zzz/RGA
|
35cd028602e21f6b8853fdc86b16153b693acb72
|
[
"MIT"
] | 161
|
2016-04-20T03:23:53.000Z
|
2020-04-14T01:46:55.000Z
|
#include "ParserSIVOP.h"
ParserSI::kaStatus
ParserSIVOP::Parse(GDT_HW_GENERATION hwGen, Instruction::instruction32bit hexInstruction, Instruction*& instruction, bool, uint32_t, int iLabel /*=NO_LABEL*/ , int iGotoLabel /*=NO_LABEL*/)
{
kaStatus retStatus = ParserSI::Status_32BitInstructionNotSupported;
VOPInstruction::Encoding encoding = GetInstructionType(hexInstruction);
if ((hwGen == GDT_HW_GENERATION_SEAISLAND) || (hwGen == GDT_HW_GENERATION_SOUTHERNISLAND))
{
if (VOPInstruction::Encoding_VOP1 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
SIVOP1Instruction::VOP1_OP op1 = static_cast<SIVOP1Instruction::VOP1_OP>(hexInstTem);
instruction = new SIVOP1Instruction(32, encoding, op1, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
else if (VOPInstruction::Encoding_VOP2 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
SIVOP2Instruction::VOP2_OP op2 = static_cast<SIVOP2Instruction::VOP2_OP>(hexInstTem);
instruction = new SIVOP2Instruction(32, encoding, op2, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
else if (VOPInstruction::Encoding_VOPC == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
SIVOPCInstruction::VOPC_OP opc = static_cast<SIVOPCInstruction::VOPC_OP>(hexInstTem);
instruction = new SIVOPCInstruction(32, encoding, opc, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
}
else if (hwGen == GDT_HW_GENERATION_VOLCANICISLAND)
{
if (VOPInstruction::Encoding_VOP1 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
VIVOP1Instruction::VOP1_OP op1 = static_cast<VIVOP1Instruction::VOP1_OP>(hexInstTem);
instruction = new VIVOP1Instruction(32, encoding, op1, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
else if (VOPInstruction::Encoding_VOP2 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
VIVOP2Instruction::VOP2_OP op2 = static_cast<VIVOP2Instruction::VOP2_OP>(hexInstTem);
instruction = new VIVOP2Instruction(32, encoding, op2, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
else if (VOPInstruction::Encoding_VOPC == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
VIVOPCInstruction::VOPC_OP opc = static_cast<VIVOPCInstruction::VOPC_OP>(hexInstTem);
instruction = new VIVOPCInstruction(32, encoding, opc, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
}
else if (hwGen == GDT_HW_GENERATION_GFX9)
{
if (VOPInstruction::Encoding_VOP1 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
G9VOP1Instruction::VOP1_OP op1 = static_cast<G9VOP1Instruction::VOP1_OP>(hexInstTem);
instruction = new G9VOP1Instruction(32, encoding, op1, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
else if (VOPInstruction::Encoding_VOP2 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
G9VOP2Instruction::VOP2_OP op2 = static_cast<G9VOP2Instruction::VOP2_OP>(hexInstTem);
instruction = new G9VOP2Instruction(32, encoding, op2, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
else if (VOPInstruction::Encoding_VOPC == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
VIVOPCInstruction::VOPC_OP opc = static_cast<VIVOPCInstruction::VOPC_OP>(hexInstTem);
instruction = new VIVOPCInstruction(32, encoding, opc, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
}
else
{
retStatus = ParserSI::Status_UnexpectedHWGeneration;
}
return retStatus;
}
ParserSI::kaStatus
ParserSIVOP::Parse(GDT_HW_GENERATION hwGen, Instruction::instruction64bit hexInstruction, Instruction*& instruction, int iLabel /*=NO_LABEL*/ , int iGotoLabel /*=NO_LABEL*/)
{
kaStatus retStatus = ParserSI::Status_64BitInstructionNotSupported;
VOPInstruction::Encoding encoding = GetInstructionType(hexInstruction);
if (hwGen == GDT_HW_GENERATION_SEAISLAND || hwGen == GDT_HW_GENERATION_SOUTHERNISLAND || hwGen == GDT_HW_GENERATION_VOLCANICISLAND)
{
if (VOPInstruction::Encoding_VOP3 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
SIVOP3Instruction::VOP3_OP op3 = static_cast<SIVOP3Instruction::VOP3_OP>(hexInstTem);
instruction = new SIVOP3Instruction(64, encoding, op3, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
}
else if (hwGen == GDT_HW_GENERATION_GFX9)
{
if (VOPInstruction::Encoding_VOP3P == encoding)
{
uint64_t hexInstTem = (hexInstruction >> 16) & 0x7F;
G9VOP3Instruction::VOP3_OP op3 = static_cast<G9VOP3Instruction::VOP3_OP>(hexInstTem);
instruction = new G9VOP3Instruction(64, encoding, op3, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
else if (VOPInstruction::Encoding_VOP3 == encoding)
{
uint64_t hexInstTem = hexInstruction << 15;
hexInstTem = hexInstTem >> 24;
G9VOP3Instruction::VOP3_OP op3 = static_cast<G9VOP3Instruction::VOP3_OP>(hexInstTem);
instruction = new G9VOP3Instruction(64, encoding, op3, iLabel, iGotoLabel);
retStatus = ParserSI::Status_SUCCESS;
}
}
else
{
retStatus = ParserSI::Status_UnexpectedHWGeneration;
}
return retStatus;
}
VOPInstruction::Encoding
ParserSIVOP::GetInstructionType(Instruction::instruction32bit hexInstruction)
{
uint64_t hexInstTemp = hexInstruction >> 25;
if (hexInstTemp == VOPInstruction::Encoding_VOP1)
{
return VOPInstruction::Encoding_VOP1;
}
else if (hexInstTemp == VOPInstruction::VOPMask_VOPC)
{
return VOPInstruction::Encoding_VOPC;
}
hexInstTemp = hexInstruction >> 31;
if (hexInstTemp == VOPInstruction::VOPMask_VOP2)
{
return VOPInstruction::Encoding_VOP2;
}
return VOPInstruction::Encoding_Illegal;
}
VOPInstruction::Encoding
ParserSIVOP::GetInstructionType(Instruction::instruction64bit hexInstruction)
{
if ((hexInstruction && VOPInstruction::VOPMask_VOP3) >> 26 == VOPInstruction::Encoding_VOP3)
{
return VOPInstruction::Encoding_VOP3;
}
return VOPInstruction::Encoding_Illegal;
}
| 40.290503
| 189
| 0.655713
|
jeongjoonyoo
|
c7f5d37f2f9affbcdd465c9f91e8781534c13646
| 5,801
|
cpp
|
C++
|
pytorch/torch/csrc/jit/codegen/cuda/ir_base_nodes.cpp
|
zhou3968322/dl-code-read
|
aca204a986dabe2755becff0f42de1082299d791
|
[
"MIT"
] | null | null | null |
pytorch/torch/csrc/jit/codegen/cuda/ir_base_nodes.cpp
|
zhou3968322/dl-code-read
|
aca204a986dabe2755becff0f42de1082299d791
|
[
"MIT"
] | null | null | null |
pytorch/torch/csrc/jit/codegen/cuda/ir_base_nodes.cpp
|
zhou3968322/dl-code-read
|
aca204a986dabe2755becff0f42de1082299d791
|
[
"MIT"
] | null | null | null |
#include <torch/csrc/jit/codegen/cuda/dispatch.h>
#include <torch/csrc/jit/codegen/cuda/fusion.h>
#include <torch/csrc/jit/codegen/cuda/ir_all_nodes.h>
#include <torch/csrc/jit/codegen/cuda/ir_cloner.h>
#include <torch/csrc/jit/codegen/cuda/ir_printer.h>
#include <torch/csrc/jit/codegen/cuda/mutator.h>
#include <torch/csrc/jit/ir/ir.h>
#include <c10/util/Exception.h>
#include <iostream>
#include <stdexcept>
#include <string>
#include <unordered_map>
namespace torch {
namespace jit {
namespace fuser {
Statement::Statement(const Statement* src, IrCloner* ir_cloner) {
ir_cloner->registerClone(src, this);
name_ = src->name_;
fusion_ = ir_cloner->fusion();
}
Val* Statement::asVal() {
TORCH_INTERNAL_ASSERT(isVal(), "Cannot cast to Val as this is not a Val.");
return static_cast<Val*>(this);
}
Expr* Statement::asExpr() {
TORCH_INTERNAL_ASSERT(isExpr(), "Cannot cast to Expr as this is not a Expr.");
return static_cast<Expr*>(this);
}
void Statement::print() const {
IRPrinter ir_printer(std::cout);
ir_printer.handle(this);
std::cout << std::endl;
}
// When we create a Val we immediately register them with the active fusion.
Val::Val(ValType _vtype, DataType _dtype, bool register_val)
: vtype_{_vtype}, dtype_{_dtype} {
Fusion* fusion = FusionGuard::getCurFusion();
TORCH_CHECK(
fusion != nullptr, "No active fusion group found when creating a Val.");
this->fusion_ = fusion;
if (register_val)
this->name_ = this->fusion_->registerVal(this);
}
Val::Val(const Val* src, IrCloner* ir_cloner)
: Statement(src, ir_cloner), vtype_(src->vtype_), dtype_(src->dtype_) {}
// Traverse origin of all values involved in constructing the provided val.
// Check if all values involved are constant values, meaning the provided
// val is also a constant value.
namespace {
class ConstCheck : OptOutConstDispatch {
private:
bool is_const_ = true;
void handle(const Bool* b) override {
is_const_ = is_const_ && b->isConst();
}
void handle(const Float* f) override {
is_const_ = is_const_ && f->isConst();
}
void handle(const Half* h) override {
is_const_ = is_const_ && h->isConst();
}
void handle(const Int* i) override {
is_const_ = is_const_ && i->isConst();
}
void handle(const NamedScalar* ns) override {
is_const_ = is_const_ && false;
}
void handle(const Expr* expr) override {
for (auto inp : expr->inputs()) {
OptOutConstDispatch::handle(inp);
}
}
void handle(const Val* val) override {
const Expr* orig = FusionGuard::getCurFusion()->origin(val);
if (orig != nullptr)
handle(orig);
else
OptOutConstDispatch::handle(val);
}
public:
static bool isConst(const Val* val) {
ConstCheck cc;
cc.handle(val);
return cc.is_const_;
}
};
} // namespace
bool Val::isConstScalar() const {
if (!isScalar())
return false;
return ConstCheck::isConst(this);
}
bool Val::isZeroInt() const {
if (isConstScalar() && getValType().value() == ValType::Scalar &&
getDataType().value() == DataType::Int &&
static_cast<const Int*>(this)->value().value() == 0)
return true;
return false;
}
bool Val::isOneInt() const {
if (isConstScalar() && getValType().value() == ValType::Scalar &&
getDataType().value() == DataType::Int &&
static_cast<const Int*>(this)->value().value() == 1)
return true;
return false;
}
c10::optional<DataType> Val::getDataType() const {
TORCH_INTERNAL_ASSERT(
dtype_ != DataType::Null, "Value does not have a data type.");
return dtype_;
}
Expr* Val::getOrigin() {
return (fusion_->origin(this));
}
Scope::Scope(const Scope* src, IrCloner* ir_cloner)
: exprs_(ir_cloner->clone(src->exprs_)) {}
void Scope::insert_before(Expr* ref, Expr* expr) {
auto it = exprs_.begin();
while (it != exprs_.end()) {
if ((*it)->sameAs(ref))
break;
it++;
}
if (it != exprs_.end())
exprs_.insert(it, expr);
}
void Scope::insert_after(Expr* ref, Expr* expr) {
auto it = exprs_.begin();
while (it != exprs_.end()) {
if (*it == ref)
break;
it++;
}
if (it != exprs_.end())
exprs_.insert(++it, expr);
}
void Scope::erase(Expr* ref) {
auto it = exprs_.begin();
while (it != exprs_.end()) {
if (*it == ref)
break;
it++;
}
if (it != exprs_.end())
exprs_.erase(it);
}
bool Scope::contains(Expr* expr) const {
for (auto e : exprs_)
if (e == expr)
return true;
return false;
}
bool Scope::sameAs(const Scope& other) const {
if (other.exprs().size() != this->exprs().size())
return false;
for (decltype(exprs().size()) i{0}; i < exprs().size(); i++)
if (other.exprs()[i] != exprs()[i])
return false;
return true;
}
void Scope::clear() {
this->exprs_ = std::vector<Expr*>();
}
// We don't register with the active fusion in Expr as this needs to be done
// after inputs and outputs are registered with the Expr
Expr::Expr(ExprType _type) : type_{_type} {
Fusion* fusion = FusionGuard::getCurFusion();
if (fusion == nullptr)
TORCH_CHECK(false, "No active fusion group found when creating an Expr.");
this->fusion_ = fusion;
}
Expr::Expr(const Expr* src, IrCloner* ir_cloner)
: Statement(src, ir_cloner),
type_(src->type_),
inputs_(ir_cloner->clone(src->inputs_)),
outputs_(ir_cloner->clone(src->outputs_)) {}
bool Expr::sameAs(const Expr* const other) const {
if (getExprType() != other->getExprType())
return false;
if (inputs().size() != other->inputs().size() ||
outputs().size() != other->outputs().size())
return false;
for (size_t i = 0; i < inputs().size(); i++) {
if (!input(i)->sameAs(other->input(i)))
return false;
}
return true;
}
} // namespace fuser
} // namespace jit
} // namespace torch
| 25.331878
| 80
| 0.649198
|
zhou3968322
|
c7f67ff450e18a1e3a905a4e42055e19347c62d5
| 919
|
cc
|
C++
|
pw_rpc/client_call.cc
|
curtin-space/pigweed
|
fe2e1743e03fabd2676f01d9de0ac9d34a426076
|
[
"Apache-2.0"
] | 86
|
2021-03-09T23:49:40.000Z
|
2022-03-30T08:14:51.000Z
|
pw_rpc/client_call.cc
|
curtin-space/pigweed
|
fe2e1743e03fabd2676f01d9de0ac9d34a426076
|
[
"Apache-2.0"
] | 4
|
2021-07-27T20:32:03.000Z
|
2022-03-08T10:39:07.000Z
|
pw_rpc/client_call.cc
|
curtin-space/pigweed
|
fe2e1743e03fabd2676f01d9de0ac9d34a426076
|
[
"Apache-2.0"
] | 22
|
2021-03-11T15:15:47.000Z
|
2022-02-09T06:16:36.000Z
|
// Copyright 2021 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#include "pw_rpc/internal/client_call.h"
namespace pw::rpc::internal {
void ClientCall::SendInitialRequestLocked(ConstByteSpan payload) {
if (const Status status = SendPacket(PacketType::REQUEST, payload);
!status.ok()) {
rpc_lock().lock();
HandleError(status);
}
}
} // namespace pw::rpc::internal
| 32.821429
| 80
| 0.73123
|
curtin-space
|
c7f72e6d15db91277c9f4fb1210e6213dd14a20e
| 791
|
cpp
|
C++
|
Codeforces/1618A-polycarp-and-sums-of-subsequences.cpp
|
SusmoySenGupta/online-judge-solutions
|
8735a1bc71a05dc46255664c3ec6f47f042bfa6c
|
[
"MIT"
] | null | null | null |
Codeforces/1618A-polycarp-and-sums-of-subsequences.cpp
|
SusmoySenGupta/online-judge-solutions
|
8735a1bc71a05dc46255664c3ec6f47f042bfa6c
|
[
"MIT"
] | null | null | null |
Codeforces/1618A-polycarp-and-sums-of-subsequences.cpp
|
SusmoySenGupta/online-judge-solutions
|
8735a1bc71a05dc46255664c3ec6f47f042bfa6c
|
[
"MIT"
] | null | null | null |
/*
author: Susmoy Sen Gupta
email: susmoy.cse@gmail.com
github: github.com/SusmoySenGupta
Judge: Codeforces
problem no: 1618A
problem name: Polycarp and Sums of Subsequences
problem link: https://codeforces.com/problemset/problem/1618/A
Status: ____
Solved at: __
*/
#include <iostream>
#include <vector>
using namespace std;
#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007ll
#define PI 3.14159
#define MAX 1003
#define ll long long int
void solve()
{
vector<int> numbers(7);
for (int i = 0; i < 7; i++)
cin >> numbers[i];
cout << numbers[0] << " " << numbers[1] << " " << numbers[6] - numbers[1] - numbers[0] << "\n";
}
int main()
{
int t;
cin >> t;
while (t--)
solve();
return 0;
}
| 16.142857
| 100
| 0.60177
|
SusmoySenGupta
|
c7f84d6a17f9d22101dfbad974788699083da3f0
| 7,462
|
cc
|
C++
|
src/htsim/flow_driver.cc
|
ngvozdiev/ncode
|
269573ee651f3b5e13d323ee747fede244d47564
|
[
"Apache-2.0"
] | null | null | null |
src/htsim/flow_driver.cc
|
ngvozdiev/ncode
|
269573ee651f3b5e13d323ee747fede244d47564
|
[
"Apache-2.0"
] | null | null | null |
src/htsim/flow_driver.cc
|
ngvozdiev/ncode
|
269573ee651f3b5e13d323ee747fede244d47564
|
[
"Apache-2.0"
] | null | null | null |
#include "flow_driver.h"
#include <algorithm>
#include <limits>
#include "../common/logging.h"
#include "packet.h"
namespace ncode {
namespace htsim {
void ManualFlowDriver::AddData(const std::vector<AddDataEvent>& events) {
add_data_events_.insert(add_data_events_.end(), events.begin(), events.end());
std::stable_sort(add_data_events_.begin(), add_data_events_.end(),
[](const AddDataEvent& lhs, const AddDataEvent& rhs) {
return lhs.at > rhs.at;
});
}
AddDataEvent ManualFlowDriver::Next() {
AddDataEvent to_return = PeekNextAddData();
PopNextAddData();
return to_return;
}
const AddDataEvent& ManualFlowDriver::PeekNextAddData() {
if (add_data_events_.empty()) {
return kAddDataInfinity;
}
return add_data_events_.back();
}
void ManualFlowDriver::PopNextAddData() {
if (!add_data_events_.empty()) {
add_data_events_.pop_back();
}
}
RateKeyFrame ConstantRateFlowDriver::NextKeyFrame() {
if (next_key_frame_index_ == rate_change_key_frames_.size()) {
return RateKeyFrame(EventQueueTime::MaxTime(), curr_rate_);
}
return rate_change_key_frames_[next_key_frame_index_];
}
void ConstantRateFlowDriver::AdvanceToNextKeyFrame() {
RateKeyFrame next_key_frame = NextKeyFrame();
curr_time_ = next_key_frame.at;
curr_rate_ = next_key_frame.rate_bps;
inter_packet_gap_ =
EventQueueTime(second_.Raw() / ((curr_rate_ / 8.0) / packet_size_bytes_));
++next_key_frame_index_;
}
AddDataEvent ConstantRateFlowDriver::Next() {
if (curr_time_ == EventQueueTime::MaxTime()) {
return {EventQueueTime::MaxTime(), 0};
}
EventQueueTime next_packet_time = curr_time_ + inter_packet_gap_;
RateKeyFrame next_key_frame = NextKeyFrame();
if (inter_packet_gap_.isZero() || next_key_frame.at < next_packet_time) {
AdvanceToNextKeyFrame();
return Next();
}
curr_time_ = next_packet_time;
return {next_packet_time, packet_size_bytes_};
}
void ConstantRateFlowDriver::AddRateChangeKeyframes(
const std::vector<RateKeyFrame>& key_frames) {
rate_change_key_frames_.insert(rate_change_key_frames_.end(),
key_frames.begin(), key_frames.end());
std::stable_sort(rate_change_key_frames_.begin(),
rate_change_key_frames_.end(),
[](const RateKeyFrame& lhs, const RateKeyFrame& rhs) {
return lhs.at < rhs.at;
});
}
FeedbackLoopFlowDriver::FeedbackLoopFlowDriver(
const std::string& id,
std::unique_ptr<ObjectSizeAndWaitTimeGenerator> generator,
EventQueue* event_queue)
: EventConsumer(id, event_queue),
generator_(std::move(generator)),
data_to_add_(0),
connection_(nullptr) {
ScheduleNext();
}
void FeedbackLoopFlowDriver::HandleEvent() {
uint64_t prev_data_to_add_ = data_to_add_;
if (!data_to_add_) {
ScheduleNext();
}
if (prev_data_to_add_) {
connection_->OnSendBufferDrained([this] { ScheduleNext(); });
connection_->AddData(data_to_add_);
}
}
void FeedbackLoopFlowDriver::ConnectionAttached(Connection* connection) {
connection_ = connection;
}
void FeedbackLoopFlowDriver::ScheduleNext() {
ObjectSizeAndWaitTime next = generator_->Next();
data_to_add_ = next.object_size;
EnqueueIn(next.wait_time);
}
void FlowPack::Init() {
AddFirstEvents();
num_events_cached_ = CacheEvents();
if (num_events_cached_) {
EnqueueAt(pending_events_[0].add_data_event.at);
}
}
void FlowPack::AddDriver(std::unique_ptr<FlowDriver> driver,
Connection* connection) {
if (driver->type() == FlowDriver::INDEPENDENT) {
std::unique_ptr<IndependentFlowDriver> independent_flow_driver(
static_cast<IndependentFlowDriver*>(driver.release()));
ConnectionAndIndependentDriver connection_and_driver;
connection_and_driver.driver = std::move(independent_flow_driver);
connection_and_driver.connection = connection;
independent_drivers_.emplace_back(std::move(connection_and_driver));
} else if (driver->type() == FlowDriver::DEPENDENT) {
std::unique_ptr<ConnectionDependentFlowDriver> dependent_flow_driver(
static_cast<ConnectionDependentFlowDriver*>(driver.release()));
dependent_flow_driver->ConnectionAttached(connection);
dependent_drivers_.emplace_back(std::move(dependent_flow_driver));
}
}
void FlowPack::HandleEvent() {
const Event& ev = pending_events_[next_event_index_++];
Connection* connection = ev.connection_and_driver->connection;
if (ev.add_data_event.close) {
connection->Close();
} else {
uint64_t data_to_add = ev.add_data_event.bytes;
if (data_to_add) {
connection->AddData(data_to_add);
}
}
if (next_event_index_ == num_events_cached_) {
num_events_cached_ = CacheEvents();
next_event_index_ = 0;
if (num_events_cached_ == 0) {
return;
}
}
EnqueueAt(pending_events_[next_event_index_].add_data_event.at);
}
void FlowPack::AddFirstEvents() {
Event ev;
for (auto& connection_and_driver : independent_drivers_) {
ev.connection_and_driver = &connection_and_driver;
ev.add_data_event = connection_and_driver.driver->Next();
if (ev.add_data_event.at != EventQueueTime::MaxTime()) {
queue_.emplace(std::move(ev));
}
}
}
size_t FlowPack::CacheEvents() {
size_t i;
Event ev;
for (i = 0; i < kEventCacheSize; ++i) {
if (!queue_.size()) {
break;
}
pending_events_[i] = std::move(const_cast<Event&>(queue_.top()));
queue_.pop();
Event& curr_event = pending_events_[i];
ev.connection_and_driver = curr_event.connection_and_driver;
ev.add_data_event = curr_event.connection_and_driver->driver->Next();
if (ev.add_data_event.at != EventQueueTime::MaxTime()) {
queue_.emplace(std::move(ev));
}
}
LOG(INFO) << "Cached " << i << " events";
return i;
}
DefaultObjectSizeAndWaitTimeGenerator::DefaultObjectSizeAndWaitTimeGenerator(
size_t mean_object_size_bytes, bool size_fixed,
std::chrono::milliseconds mean_wait_time_ms, bool wait_time_fixed,
double seed, EventQueue* event_queue)
: mean_object_size_(mean_object_size_bytes),
mean_wait_time_(mean_wait_time_ms.count()),
object_size_fixed_(size_fixed),
wait_time_fixed_(wait_time_fixed),
generator_(seed),
object_size_distribution_(1.0 / mean_object_size_bytes),
wait_time_distribution_(1.0 / mean_wait_time_ms.count()),
constant_delay_ms_(0),
event_queue_(event_queue) {}
ObjectSizeAndWaitTime DefaultObjectSizeAndWaitTimeGenerator::Next() {
bool max_object_size =
mean_object_size_ == std::numeric_limits<uint64_t>::max();
bool min_wait_time = mean_wait_time_ == 0;
size_t object_size_bytes;
if (max_object_size) {
object_size_bytes = std::numeric_limits<uint64_t>::max();
} else if (object_size_fixed_) {
object_size_bytes = mean_object_size_;
} else {
object_size_bytes = object_size_distribution_(generator_);
object_size_bytes = std::max(1ul, object_size_bytes);
}
size_t wait_time_ms;
if (min_wait_time) {
wait_time_ms = 0;
} else if (wait_time_fixed_) {
wait_time_ms = mean_wait_time_;
} else {
wait_time_ms = constant_delay_ms_ + wait_time_distribution_(generator_);
wait_time_ms = std::max(1ul, wait_time_ms);
}
return {object_size_bytes, event_queue_->RawMillisToTime(wait_time_ms)};
}
} // namespace htsim
} // namespace ncode
| 30.581967
| 80
| 0.713214
|
ngvozdiev
|
c7fbd92e7d4db60613a9ef434077b074ab2335ca
| 37,463
|
hpp
|
C++
|
include/tao/algorithm/adjacent_swap.hpp
|
tao-cpp/algorithm
|
156655aed1c522a3386cb82fb4aa2b3a302ee7e8
|
[
"MIT"
] | 2
|
2017-01-13T09:20:58.000Z
|
2019-06-28T15:27:13.000Z
|
include/tao/algorithm/adjacent_swap.hpp
|
tao-cpp/algorithm
|
156655aed1c522a3386cb82fb4aa2b3a302ee7e8
|
[
"MIT"
] | null | null | null |
include/tao/algorithm/adjacent_swap.hpp
|
tao-cpp/algorithm
|
156655aed1c522a3386cb82fb4aa2b3a302ee7e8
|
[
"MIT"
] | 2
|
2017-05-31T12:05:26.000Z
|
2019-10-13T22:36:32.000Z
|
//! \file tao/algorithm/adjacent_swap.hpp
// Tao.Algorithm
//
// Copyright (c) 2016-2021 Fernando Pelliccioni.
//
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef TAO_ALGORITHM_ADJACENT_SWAP_HPP_
#define TAO_ALGORITHM_ADJACENT_SWAP_HPP_
//Position Based Rearrangements
#include <algorithm>
#include <iterator>
#include <utility>
// #include <iostream>
#include <tao/algorithm/concepts.hpp>
#include <tao/algorithm/copy.hpp>
#include <tao/algorithm/iterator.hpp>
#include <tao/algorithm/swap.hpp>
#include <tao/algorithm/type_attributes.hpp>
namespace tao { namespace algorithm {
template <ForwardIterator I>
I adjacent_swap(I f, I l, std::forward_iterator_tag) {
//precondition: mutable_bounded_range(f, l)
while (f != l) {
I n = f; ++n;
if (n == l) return f;
std::iter_swap(f, n);
++n;
f = n;
}
return f;
}
//Complexity:
// Runtime:
// Amortized: O(n)
// Exact:
// Space:
// O(1)
template <RandomAccessIterator I>
I adjacent_swap(I f, I l, std::random_access_iterator_tag) {
//precondition: mutable_bounded_range(f, l)
auto n = l - f;
while (n > 1) {
std::iter_swap(f, f + 1);
f += 2;
n -= 2;
}
return f;
}
template <ForwardIterator I>
inline
I adjacent_swap(I f, I l) {
//precondition: mutable_bounded_range(f, l)
return adjacent_swap(f, l, IteratorCategory<I>{});
}
// -----------------------------------------------------------------
// adjacent_swap_0
// -----------------------------------------------------------------
//Complexity:
// Runtime:
// Amortized: O(n)
// Exact:
// Space:
// O(1)
// template <ForwardIterator I>
// void adjacent_swap_0(I f, I l, std::forward_iterator_tag) {
// //precondition: mutable_bounded_range(f, l)
// using std::swap;
// while (f != l) {
// I n = f; ++n;
// if (n == l) return;
// swap(*f, *n);
// ++n;
// f = n;
// }
// }
}} /*tao::algorithm*/
#endif /* TAO_ALGORITHM_ADJACENT_SWAP_HPP_ */
#ifdef DOCTEST_LIBRARY_INCLUDED
#include <iterator>
#include <forward_list>
#include <list>
#include <vector>
#include <tao/benchmark/instrumented.hpp>
using namespace std;
using namespace tao::algorithm;
TEST_CASE("[adjacent_swap] testing adjacent_swap 0 elements random access") {
using T = int;
vector<T> a;
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == vector<T>());
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 1 elements random access") {
using T = int;
vector<T> a = {1};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == vector<T>{1});
CHECK(ret == begin(a));
CHECK(*ret == 1);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 2 elements random access") {
using T = int;
vector<T> a = {1, 2};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == vector<T>{2, 1});
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 3 elements random access") {
using T = int;
vector<T> a = {1, 2, 3};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == vector<T>{2, 1, 3});
CHECK(ret == prev(end(a)));
CHECK(*ret == 3);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 4 elements random access") {
using T = int;
vector<T> a = {1, 2, 3, 4};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == vector<T>{2, 1, 4, 3});
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 5 elements random access") {
using T = int;
vector<T> a = {1, 2, 3, 4, 5};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == vector<T>{2, 1, 4, 3, 5});
CHECK(ret == prev(end(a)));
CHECK(*ret == 5);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 0 elements bidirectional") {
using T = int;
list<T> a;
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == list<T>());
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 1 elements bidirectional") {
using T = int;
list<T> a = {1};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == list<T>{1});
CHECK(ret == begin(a));
CHECK(*ret == 1);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 2 elements bidirectional") {
using T = int;
list<T> a = {1, 2};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == list<T>{2, 1});
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 3 elements bidirectional") {
using T = int;
list<T> a = {1, 2, 3};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == list<T>{2, 1, 3});
CHECK(ret == prev(end(a)));
CHECK(*ret == 3);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 4 elements bidirectional") {
using T = int;
list<T> a = {1, 2, 3, 4};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == list<T>{2, 1, 4, 3});
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 5 elements bidirectional") {
using T = int;
list<T> a = {1, 2, 3, 4, 5};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == list<T>{2, 1, 4, 3, 5});
CHECK(ret == prev(end(a)));
CHECK(*ret == 5);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 0 elements forward") {
using T = int;
forward_list<T> a;
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == forward_list<T>());
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 1 elements forward") {
using T = int;
forward_list<T> a = {1};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == forward_list<T>{1});
CHECK(ret == begin(a));
CHECK(*ret == 1);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 2 elements forward") {
using T = int;
forward_list<T> a = {1, 2};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == forward_list<T>{2, 1});
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 3 elements forward") {
using T = int;
forward_list<T> a = {1, 2, 3};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == forward_list<T>{2, 1, 3});
CHECK(ret == next(begin(a), 3 - 1));
CHECK(*ret == 3);
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 4 elements forward") {
using T = int;
forward_list<T> a = {1, 2, 3, 4};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == forward_list<T>{2, 1, 4, 3});
CHECK(ret == end(a));
}
TEST_CASE("[adjacent_swap] testing adjacent_swap 5 elements forward") {
using T = int;
forward_list<T> a = {1, 2, 3, 4, 5};
auto ret = adjacent_swap(begin(a), end(a));
CHECK(a == forward_list<T>{2, 1, 4, 3, 5});
CHECK(ret == next(begin(a), 5 - 1));
CHECK(*ret == 5);
}
// // ---------------------------------------------------------------------------------------------------
// // TEST_CASE("[adjacent_swap] testing adjacent_swap 6 elements random access compare with std::adjacent_swap") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // std::auto ret = adjacent_swap(begin(a), end(a) - 1, end(a));
// // CHECK(a == vector<T>{6, 1, 2, 3, 4, 5});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap instrumented random access compare with std::adjacent_swap") {
// // using T = instrumented<int>;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // std::auto ret = adjacent_swap(begin(a), std::prev(end(a), 1), end(a));
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap instrumented bidirectional compare with std::adjacent_swap") {
// // using T = instrumented<int>;
// // list<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // std::auto ret = adjacent_swap(begin(a), std::prev(end(a), 1), end(a));
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap instrumented forward compare with std::adjacent_swap") {
// // using T = instrumented<int>;
// // forward_list<T> a = {1, 2, 3, 4, 5, 6};
// // auto n = distance(begin(a), end(a));
// // instrumented<int>::initialize(0);
// // std::auto ret = adjacent_swap(begin(a), std::next(begin(a), n - 1), end(a));
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == 2 * n - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // ---------------------------------------------------------------------------------------------------
// TEST_CASE("[adjacent_swap] testing adjacent_swap instrumented random access") {
// using T = instrumented<int>;
// vector<T> a = {1, 2, 3, 4, 5, 6};
// instrumented<int>::initialize(0);
// auto ret = adjacent_swap(begin(a), end(a));
// double* count_p = instrumented<int>::counts;
// CHECK(count_p[instrumented_base::copy_ctor] +
// count_p[instrumented_base::copy_assignment] +
// count_p[instrumented_base::move_ctor] +
// count_p[instrumented_base::move_assignment] == a.size() + 1);
// CHECK(count_p[instrumented_base::destructor] == 1);
// }
// TEST_CASE("[adjacent_swap] testing adjacent_swap instrumented bidirectional") {
// using T = instrumented<int>;
// list<T> a = {1, 2, 3, 4, 5, 6};
// instrumented<int>::initialize(0);
// auto ret = adjacent_swap(begin(a), end(a));
// double* count_p = instrumented<int>::counts;
// CHECK(count_p[instrumented_base::copy_ctor] +
// count_p[instrumented_base::copy_assignment] +
// count_p[instrumented_base::move_ctor] +
// count_p[instrumented_base::move_assignment] == a.size() + 1);
// CHECK(count_p[instrumented_base::destructor] == 1);
// }
// TEST_CASE("[adjacent_swap] testing adjacent_swap instrumented forward") {
// using T = instrumented<int>;
// forward_list<T> a = {1, 2, 3, 4, 5, 6};
// auto n = distance(begin(a), end(a));
// instrumented<int>::initialize(0);
// auto ret = adjacent_swap(begin(a), end(a));
// double* count_p = instrumented<int>::counts;
// CHECK(count_p[instrumented_base::copy_ctor] +
// count_p[instrumented_base::copy_assignment] +
// count_p[instrumented_base::move_ctor] +
// count_p[instrumented_base::move_assignment] == 2 * n);
// CHECK(count_p[instrumented_base::destructor] == 2);
// }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 0 elements random access") {
// // using T = int;
// // vector<T> a;
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == vector<T>());
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 1 elements random access") {
// // using T = int;
// // vector<T> a = {1};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == vector<T>{1});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 2 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == vector<T>{2, 1});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 3 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == vector<T>{3, 1, 2});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 4 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == vector<T>{4, 1, 2, 3});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 5 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4, 5};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == vector<T>{5, 1, 2, 3, 4});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 6 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == vector<T>{6, 1, 2, 3, 4, 5});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 0 elements bidirectional") {
// // using T = int;
// // list<T> a;
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == list<T>());
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 1 elements bidirectional") {
// // using T = int;
// // list<T> a = {1};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == list<T>{1});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 2 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == list<T>{2, 1});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 3 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == list<T>{3, 1, 2});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 4 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == list<T>{4, 1, 2, 3});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 5 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4, 5};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == list<T>{5, 1, 2, 3, 4});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 6 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4, 5, 6};
// // adjacent_swap_n(begin(a), a.size());
// // CHECK(a == list<T>{6, 1, 2, 3, 4, 5});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 0 elements forward") {
// // using T = int;
// // forward_list<T> a;
// // auto n = distance(begin(a), end(a));
// // adjacent_swap_n(begin(a), n);
// // CHECK(a == forward_list<T>());
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 1 elements forward") {
// // using T = int;
// // forward_list<T> a = {1};
// // auto n = distance(begin(a), end(a));
// // adjacent_swap_n(begin(a), n);
// // CHECK(a == forward_list<T>{1});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 2 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2};
// // auto n = distance(begin(a), end(a));
// // adjacent_swap_n(begin(a), n);
// // CHECK(a == forward_list<T>{2, 1});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 3 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3};
// // auto n = distance(begin(a), end(a));
// // adjacent_swap_n(begin(a), n);
// // CHECK(a == forward_list<T>{3, 1, 2});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 4 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4};
// // auto n = distance(begin(a), end(a));
// // adjacent_swap_n(begin(a), n);
// // CHECK(a == forward_list<T>{4, 1, 2, 3});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 5 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4, 5};
// // auto n = distance(begin(a), end(a));
// // adjacent_swap_n(begin(a), n);
// // CHECK(a == forward_list<T>{5, 1, 2, 3, 4});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n 6 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4, 5, 6};
// // auto n = distance(begin(a), end(a));
// // adjacent_swap_n(begin(a), n);
// // CHECK(a == forward_list<T>{6, 1, 2, 3, 4, 5});
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n instrumented random access") {
// // using T = instrumented<int>;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // adjacent_swap_n(begin(a), a.size());
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() + 1);
// // CHECK(count_p[instrumented_base::destructor] == 1);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n instrumented bidirectional") {
// // using T = instrumented<int>;
// // list<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // adjacent_swap_n(begin(a), a.size());
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() + 1);
// // CHECK(count_p[instrumented_base::destructor] == 1);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_n instrumented forward") {
// // using T = instrumented<int>;
// // forward_list<T> a = {1, 2, 3, 4, 5, 6};
// // auto n = distance(begin(a), end(a));
// // instrumented<int>::initialize(0);
// // adjacent_swap_n(begin(a), n);
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == 2 * n);
// // CHECK(count_p[instrumented_base::destructor] == 2);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 0 elements random access") {
// // using T = int;
// // vector<T> a;
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == vector<T>());
// // CHECK(ret == end(a));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 1 elements random access") {
// // using T = int;
// // vector<T> a = {1};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == vector<T>{1});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 2 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == vector<T>{2, 2});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 3 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == vector<T>{2, 3, 3});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 4 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == vector<T>{2, 3, 4, 4});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 5 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4, 5};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == vector<T>{2, 3, 4, 5, 5});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 6 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == vector<T>{2, 3, 4, 5, 6, 6});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 0 elements bidirectional") {
// // using T = int;
// // list<T> a;
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == list<T>());
// // CHECK(ret == end(a));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 1 elements bidirectional") {
// // using T = int;
// // list<T> a = {1};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == list<T>{1});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 2 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == list<T>{2, 2});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 3 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == list<T>{2, 3, 3});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 4 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == list<T>{2, 3, 4, 4});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 5 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4, 5};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == list<T>{2, 3, 4, 5, 5});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 6 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4, 5, 6};
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == list<T>{2, 3, 4, 5, 6, 6});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 0 elements forward") {
// // using T = int;
// // forward_list<T> a;
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == forward_list<T>());
// // CHECK(ret == end(a));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 1 elements forward") {
// // using T = int;
// // forward_list<T> a = {1};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == forward_list<T>{1});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 2 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == forward_list<T>{2, 2});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 3 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == forward_list<T>{2, 3, 3});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 4 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == forward_list<T>{2, 3, 4, 4});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 5 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4, 5};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == forward_list<T>{2, 3, 4, 5, 5});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one 6 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4, 5, 6};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // CHECK(a == forward_list<T>{2, 3, 4, 5, 6, 6});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one instrumented random access") {
// // using T = instrumented<int>;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one instrumented bidirectional") {
// // using T = instrumented<int>;
// // list<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one instrumented forward") {
// // using T = instrumented<int>;
// // forward_list<T> a = {1, 2, 3, 4, 5, 6};
// // auto n = distance(begin(a), end(a));
// // instrumented<int>::initialize(0);
// // auto ret = adjacent_swap_left_by_one(begin(a), end(a));
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == n - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 0 elements random access") {
// // using T = int;
// // vector<T> a;
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == vector<T>());
// // CHECK(ret == end(a));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 1 elements random access") {
// // using T = int;
// // vector<T> a = {1};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == vector<T>{1});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 2 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == vector<T>{2, 2});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 3 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == vector<T>{2, 3, 3});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 4 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == vector<T>{2, 3, 4, 4});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 5 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4, 5};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == vector<T>{2, 3, 4, 5, 5});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 6 elements random access") {
// // using T = int;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == vector<T>{2, 3, 4, 5, 6, 6});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 0 elements bidirectional") {
// // using T = int;
// // list<T> a;
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == list<T>());
// // CHECK(ret == end(a));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 1 elements bidirectional") {
// // using T = int;
// // list<T> a = {1};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == list<T>{1});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 2 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == list<T>{2, 2});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 3 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == list<T>{2, 3, 3});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 4 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == list<T>{2, 3, 4, 4});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 5 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4, 5};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == list<T>{2, 3, 4, 5, 5});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 6 elements bidirectional") {
// // using T = int;
// // list<T> a = {1, 2, 3, 4, 5, 6};
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // CHECK(a == list<T>{2, 3, 4, 5, 6, 6});
// // CHECK(ret == std::next(begin(a), a.size() - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 0 elements forward") {
// // using T = int;
// // forward_list<T> a;
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // CHECK(a == forward_list<T>());
// // CHECK(ret == end(a));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 1 elements forward") {
// // using T = int;
// // forward_list<T> a = {1};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // CHECK(a == forward_list<T>{1});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 2 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // CHECK(a == forward_list<T>{2, 2});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 3 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // CHECK(a == forward_list<T>{2, 3, 3});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 4 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // CHECK(a == forward_list<T>{2, 3, 4, 4});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 5 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4, 5};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // CHECK(a == forward_list<T>{2, 3, 4, 5, 5});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n 6 elements forward") {
// // using T = int;
// // forward_list<T> a = {1, 2, 3, 4, 5, 6};
// // auto n = distance(begin(a), end(a));
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // CHECK(a == forward_list<T>{2, 3, 4, 5, 6, 6});
// // CHECK(ret == std::next(begin(a), n - 1));
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n instrumented random access") {
// // using T = instrumented<int>;
// // vector<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n instrumented bidirectional") {
// // using T = instrumented<int>;
// // list<T> a = {1, 2, 3, 4, 5, 6};
// // instrumented<int>::initialize(0);
// // auto ret = adjacent_swap_left_by_one_n(begin(a), a.size());
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == a.size() - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
// // TEST_CASE("[adjacent_swap] testing adjacent_swap_left_by_one_n instrumented forward") {
// // using T = instrumented<int>;
// // forward_list<T> a = {1, 2, 3, 4, 5, 6};
// // auto n = distance(begin(a), end(a));
// // instrumented<int>::initialize(0);
// // auto ret = adjacent_swap_left_by_one_n(begin(a), n);
// // double* count_p = instrumented<int>::counts;
// // CHECK(count_p[instrumented_base::copy_ctor] +
// // count_p[instrumented_base::copy_assignment] +
// // count_p[instrumented_base::move_ctor] +
// // count_p[instrumented_base::move_assignment] == n - 1);
// // CHECK(count_p[instrumented_base::destructor] == 0);
// // }
#endif /*DOCTEST_LIBRARY_INCLUDED*/
| 36.90936
| 117
| 0.564077
|
tao-cpp
|
c7fd68c3bb0e7f828e32f707a2c1f0769da5e05e
| 26,218
|
cpp
|
C++
|
test/com/ComModTestAAF/ModuleTests/CAAFTypeDefWeakObjRefTest.cpp
|
Phygon/aaf
|
faef720e031f501190481e1d1fc1870a7dc8f98b
|
[
"Linux-OpenIB"
] | null | null | null |
test/com/ComModTestAAF/ModuleTests/CAAFTypeDefWeakObjRefTest.cpp
|
Phygon/aaf
|
faef720e031f501190481e1d1fc1870a7dc8f98b
|
[
"Linux-OpenIB"
] | null | null | null |
test/com/ComModTestAAF/ModuleTests/CAAFTypeDefWeakObjRefTest.cpp
|
Phygon/aaf
|
faef720e031f501190481e1d1fc1870a7dc8f98b
|
[
"Linux-OpenIB"
] | null | null | null |
//=---------------------------------------------------------------------=
//
// $Id$ $Name$
//
// The contents of this file are subject to the AAF SDK Public Source
// License Agreement Version 2.0 (the "License"); You may not use this
// file except in compliance with the License. The License is available
// in AAFSDKPSL.TXT, or you may obtain a copy of the License from the
// Advanced Media Workflow Association, Inc., or its successor.
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
// the License for the specific language governing rights and limitations
// under the License. Refer to Section 3.3 of the License for proper use
// of this Exhibit.
//
// WARNING: Please contact the Advanced Media Workflow Association,
// Inc., for more information about any additional licenses to
// intellectual property covering the AAF Standard that may be required
// to create and distribute AAF compliant products.
// (http://www.amwa.tv/policies).
//
// Copyright Notices:
// The Original Code of this file is Copyright 1998-2009, licensor of the
// Advanced Media Workflow Association. All rights reserved.
//
// The Initial Developer of the Original Code of this file and the
// licensor of the Advanced Media Workflow Association is
// Avid Technology.
// All rights reserved.
//
//=---------------------------------------------------------------------=
// Undefine NO_REFERENCE_TO_MOB_TEST to enable the test of
// sets of references to mob. The tests a complied out because
// files with property definitions which are references to mobs
// cannot be opened by the previous version of the toolkit.
#define NO_REFERENCE_TO_MOB_TEST
#include "AAF.h"
#include "AAFResult.h"
#include "ModuleTest.h"
#include "AAFStoredObjectIDs.h"
#include "AAFTypeDefUIDs.h"
#include "AAFPropertyDefs.h"
#include "AAFDefUIDs.h"
#include "CAAFBuiltinDefs.h"
#include "AAFSmartPointer.h"
typedef IAAFSmartPointer<IUnknown> IUnknownSP;
typedef IAAFSmartPointer<IAAFFile> IAAFFileSP;
typedef IAAFSmartPointer<IAAFHeader> IAAFHeaderSP;
typedef IAAFSmartPointer<IAAFIdentification> IAAFIdentificationSP;
typedef IAAFSmartPointer<IAAFDictionary> IAAFDictionarySP;
typedef IAAFSmartPointer<IAAFObject> IAAFObjectSP;
typedef IAAFSmartPointer<IAAFClassDef> IAAFClassDefSP;
typedef IAAFSmartPointer<IAAFPropertyDef> IAAFPropertyDefSP;
typedef IAAFSmartPointer<IAAFPropertyValue> IAAFPropertyValueSP;
typedef IAAFSmartPointer<IAAFTypeDef> IAAFTypeDefSP;
typedef IAAFSmartPointer<IAAFTypeDefWeakObjRef> IAAFTypeDefWeakObjRefSP;
typedef IAAFSmartPointer<IAAFMob> IAAFMobSP;
typedef IAAFSmartPointer<IAAFSequence> IAAFSequenceSP;
typedef IAAFSmartPointer<IAAFFiller> IAAFFillerSP;
typedef IAAFSmartPointer<IAAFComponent> IAAFComponentSP;
typedef IAAFSmartPointer<IAAFSegment> IAAFSegmentSP;
typedef IAAFSmartPointer<IAAFTimelineMobSlot> IAAFTimelineMobSlotSP;
typedef IAAFSmartPointer<IAAFMobSlot> IAAFMobSlotSP;
typedef IAAFSmartPointer<IAAFTypeDefObjectRef> IAAFTypeDefObjectRefSP;
#include <iostream>
using namespace std;
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
// Required function prototypes
// Create the test file.
void CAAFTypeDefWeakObjRef_create (
aafCharacter_constptr pFileName,
aafUID_constref fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_constref productID); // throw HRESULT
// Open the test file read only and validate the data.
void CAAFTypeDefWeakObjRef_read (aafCharacter_constptr pFileName); // throw HRESULT
void CAAFTypeDefWeakObjRef_verify (IAAFHeader * pHeader); // throw HRESULT
extern "C" HRESULT CAAFTypeDefWeakObjRef_test(
testMode_t mode,
aafUID_t fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_t productID);
extern "C" HRESULT CAAFTypeDefWeakObjRef_test(
testMode_t mode,
aafUID_t fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_t productID)
{
HRESULT result = AAFRESULT_SUCCESS;
const size_t fileNameBufLen = 128;
aafCharacter wFileName[ fileNameBufLen ] = L"";
GenerateTestFileName( productID.productName, fileKind, fileNameBufLen, wFileName );
try
{
// Run through a basic set of tests. Create the file,
// and then read and validate the new file.
if(mode == kAAFUnitTestReadWrite)
CAAFTypeDefWeakObjRef_create (wFileName, fileKind, rawStorageType, productID);
CAAFTypeDefWeakObjRef_read (wFileName);
}
catch (HRESULT &rhr)
{
result = rhr;
}
return result;
}
// Constant for "new" weak reference to a type definition.
extern "C" const aafUID_t kAAFTypeID_TestWeakReferenceToType =
{ 0x012345678, 0x0123, 0x0123, {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}};
// Constant for "new" weak reference to a type definition.
extern "C" const aafUID_t kAAFPropID_TestWeakReferenceToType =
{ 0x012345679, 0x0123, 0x0123, {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}};
const aafCharacter kMyWeakReferenceToTypeDefinitionName[] = L"My Weak Reference to Type Definitions";
const aafCharacter kMyWeakReferenceToTypeDefinitionPropertyName[] = L"My Weak Reference to Type Definition Property";
#ifndef NO_REFERENCE_TO_MOB_TEST
// Constant for "new" weak reference to a mob.
extern "C" const aafUID_t kAAFTypeID_TestWeakReferenceToMob =
{ 0xfda25dda, 0xbb25, 0x493a, {0x84, 0x28, 0xf2, 0x54, 0x77, 0x23, 0x67, 0x74}};
// Constant for "new" weak reference to a mob.
extern "C" const aafUID_t kAAFPropID_TestWeakReferenceToMob =
{ 0xacbc7853, 0xfbdc, 0x47b4, {0xab, 0x8b, 0xc6, 0xef, 0xcd, 0x99, 0x31, 0x1b}};
const aafCharacter kMyWeakReferenceToMobName[] = L"My Weak Reference to Mobs";
const aafCharacter kMyWeakReferenceToMobPropertyName[] = L"My Weak Reference to Mob Property";
#endif
static const aafMobID_t TEST_MobID =
{{0x06, 0x0c, 0x2b, 0x34, 0x02, 0x05, 0x11, 0x01, 0x01, 0x00, 0x10, 0x00},
0x13, 0x00, 0x00, 0x00,
{0xc68dee89, 0x0405, 0x11d4, {0x8e, 0x3d, 0x00, 0x90, 0x27, 0xdf, 0xca, 0x7c}}};
static const aafSlotID_t TEST_SlotID = 1;
#if 1 //#ifndef _DEBUG
// convenient error handlers.
inline void checkResult(HRESULT r)
{
if (FAILED(r))
throw r;
}
inline void checkExpression(bool expression, HRESULT r)
{
if (!expression)
throw r;
}
#else // #ifndef _DEBUG
// convenient error handlers.
#define checkResult(x)\
do {\
HRESULT r = (x);\
if (FAILED(r))\
{\
cerr << "FILE:" << __FILE__ << " LINE:" << __LINE__ << " Error code = " << hex << r << dec << endl;\
throw (HRESULT)r;\
}\
} while (false)
#define checkExpression(expression, r)\
do {\
if (!(expression))\
{\
cerr << "FILE:" << __FILE__ << " LINE:" << __LINE__ << " Expression failed = " << #expression << endl;\
throw (HRESULT)r;\
}\
} while (false)
#endif // #else // #ifndef _DEBUG
static bool EqualObjects(IUnknown *pObj1, IUnknown *pObj2) // throw HRESULT
{
checkExpression(NULL != pObj1 && NULL != pObj2, AAFRESULT_NULL_PARAM);
IUnknownSP pUnk1, pUnk2;
checkResult(pObj1->QueryInterface(IID_IUnknown, (void **)&pUnk1));
checkResult(pObj2->QueryInterface(IID_IUnknown, (void **)&pUnk2));
if ((IUnknown *)pUnk1 == (IUnknown *)pUnk2)
{
return true;
}
else
{
return false;
}
}
static void CreateWeakReference(
IAAFFiller * pFiller,
IAAFTypeDef * pTargetType)
{
IAAFObjectSP pObject;
checkResult(pFiller->QueryInterface(IID_IAAFObject, (void **)&pObject));
IAAFClassDefSP pClassDef;
checkResult(pObject->GetDefinition(&pClassDef));
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult(pClassDef->LookupPropertyDef(kAAFPropID_TestWeakReferenceToType, &pWeakRefPropertyDef));
// Make sure the property's type definition is in fact a weak reference.
IAAFTypeDefSP pPropertyType;
checkResult(pWeakRefPropertyDef->GetTypeDef(&pPropertyType));
IAAFTypeDefWeakObjRefSP pWeakReferenceType;
checkResult(pPropertyType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));
// Create the weak reference property value.
IAAFTypeDefObjectRefSP pObjectReferenceType;
checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
IAAFPropertyValueSP pWeakReferenceValue;
checkResult(pObjectReferenceType->CreateValue(pTargetType, &pWeakReferenceValue));
// Install the new weak reference value into the filler object.
checkResult(pObject->SetPropertyValue(pWeakRefPropertyDef, pWeakReferenceValue));
}
static void ChangeWeakReference(
IAAFFiller * pFiller,
IAAFTypeDef * pTargetType)
{
IAAFObjectSP pObject;
checkResult(pFiller->QueryInterface(IID_IAAFObject, (void **)&pObject));
IAAFClassDefSP pClassDef;
checkResult(pObject->GetDefinition(&pClassDef));
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult(pClassDef->LookupPropertyDef(kAAFPropID_TestWeakReferenceToType, &pWeakRefPropertyDef));
// Get weak reference value from the filler object.
IAAFPropertyValueSP pWeakReferenceValue;
checkResult(pObject->GetPropertyValue(pWeakRefPropertyDef, &pWeakReferenceValue));
// Make sure the value's type definition is in fact a weak reference.
IAAFTypeDefSP pPropertyType;
checkResult(pWeakReferenceValue->GetType(&pPropertyType));
IAAFTypeDefWeakObjRefSP pWeakReferenceType;
checkResult(pPropertyType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));
// Create the weak reference property value.
IAAFTypeDefObjectRefSP pObjectReferenceType;
checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
// Make sure the target of the weak reference is a type definition.
checkResult(pObjectReferenceType->SetObject(pWeakReferenceValue, pTargetType));
}
static void CheckWeakReference(
IAAFFiller * pFiller,
IAAFTypeDef * pTargetType)
{
IAAFObjectSP pObject;
checkResult(pFiller->QueryInterface(IID_IAAFObject, (void **)&pObject));
IAAFClassDefSP pClassDef;
checkResult(pObject->GetDefinition(&pClassDef));
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult(pClassDef->LookupPropertyDef(kAAFPropID_TestWeakReferenceToType, &pWeakRefPropertyDef));
// Get weak reference value from the filler object.
IAAFPropertyValueSP pWeakReferenceValue;
checkResult(pObject->GetPropertyValue(pWeakRefPropertyDef, &pWeakReferenceValue));
// Make sure the value's type definition is in fact a weak reference.
IAAFTypeDefSP pPropertyType;
checkResult(pWeakReferenceValue->GetType(&pPropertyType));
IAAFTypeDefWeakObjRefSP pWeakReferenceType;
checkResult(pPropertyType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));
// Create the weak reference property value.
IAAFTypeDefObjectRefSP pObjectReferenceType;
checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
// Make sure the target of the weak reference is a type definition.
IAAFTypeDefSP pFoundTargetType;
checkResult(pObjectReferenceType->GetObject(pWeakReferenceValue, IID_IAAFTypeDef, (IUnknown **)&pFoundTargetType));
// Verify that the object that was the target of the weak reference was the
// type that we were expecting.
checkExpression(EqualObjects(pFoundTargetType, pTargetType), AAFRESULT_TEST_FAILED);
}
#ifndef NO_REFERENCE_TO_MOB_TEST
static void CreateWeakReference(
IAAFFiller * pFiller,
IAAFMob * pTargetMob)
{
IAAFObjectSP pObject;
checkResult(pFiller->QueryInterface(IID_IAAFObject, (void **)&pObject));
IAAFClassDefSP pClassDef;
checkResult(pObject->GetDefinition(&pClassDef));
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult(pClassDef->LookupPropertyDef(kAAFPropID_TestWeakReferenceToMob, &pWeakRefPropertyDef));
// Make sure the property's type definition is in fact a weak reference.
IAAFTypeDefSP pPropertyType;
checkResult(pWeakRefPropertyDef->GetTypeDef(&pPropertyType));
IAAFTypeDefWeakObjRefSP pWeakReferenceType;
checkResult(pPropertyType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));
// Create the weak reference property value.
IAAFTypeDefObjectRefSP pObjectReferenceType;
checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
IAAFPropertyValueSP pWeakReferenceValue;
checkResult(pObjectReferenceType->CreateValue(pTargetMob, &pWeakReferenceValue));
// Install the new weak reference value into the filler object.
checkResult(pObject->SetPropertyValue(pWeakRefPropertyDef, pWeakReferenceValue));
}
static void CheckWeakReference(
IAAFFiller * pFiller,
IAAFMob * pTargetMob)
{
IAAFObjectSP pObject;
checkResult(pFiller->QueryInterface(IID_IAAFObject, (void **)&pObject));
IAAFClassDefSP pClassDef;
checkResult(pObject->GetDefinition(&pClassDef));
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult(pClassDef->LookupPropertyDef(kAAFPropID_TestWeakReferenceToMob, &pWeakRefPropertyDef));
// Get weak reference value from the filler object.
IAAFPropertyValueSP pWeakReferenceValue;
checkResult(pObject->GetPropertyValue(pWeakRefPropertyDef, &pWeakReferenceValue));
// Make sure the value's type definition is in fact a weak reference.
IAAFTypeDefSP pPropertyType;
checkResult(pWeakReferenceValue->GetType(&pPropertyType));
IAAFTypeDefWeakObjRefSP pWeakReferenceType;
checkResult(pPropertyType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));
// Create the weak reference property value.
IAAFTypeDefObjectRefSP pObjectReferenceType;
checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
// Make sure the target of the weak reference is a type definition.
IAAFMobSP pFoundTargetMob;
checkResult(pObjectReferenceType->GetObject(pWeakReferenceValue, IID_IAAFMob, (IUnknown **)&pFoundTargetMob));
// Verify that the object that was the target of the weak reference was the
// type that we were expecting.
checkExpression(EqualObjects(pFoundTargetMob, pTargetMob), AAFRESULT_TEST_FAILED);
}
#endif
// Create the test file.
void CAAFTypeDefWeakObjRef_create (
aafCharacter_constptr pFileName,
aafUID_constref fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_constref productID)
{
// Remove the previous test file is one exists
RemoveTestFile (pFileName);
// Create the file.
IAAFFileSP pFile;
checkResult (CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
try
{
IAAFHeaderSP pHeader;
checkResult (pFile->GetHeader (&pHeader));
aafProductVersion_t toolkitVersion;
checkResult(GetAAFVersions(pHeader, &toolkitVersion, NULL));
bool weakReferencesSupported = WeakReferencesSupported(toolkitVersion);
IAAFDictionarySP pDictionary;
checkResult (pHeader->GetDictionary (&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
if (weakReferencesSupported)
{
// Create a Weak reference to a type definition.
IAAFTypeDefWeakObjRefSP pWeakObjRef;
checkResult(pDictionary->CreateMetaInstance(AUID_AAFTypeDefWeakObjRef,
IID_IAAFTypeDefWeakObjRef,
(IUnknown **)&pWeakObjRef));
// Find the class definition for all type definitions.
IAAFClassDefSP pClassDef;
checkResult(pDictionary->LookupClassDef(AUID_AAFTypeDef, &pClassDef));
aafUID_t targetSet[2];
targetSet[0] = kAAFPropID_Root_MetaDictionary;
targetSet[1] = kAAFPropID_MetaDictionary_TypeDefinitions;
checkResult(pWeakObjRef->Initialize(kAAFTypeID_TestWeakReferenceToType,
pClassDef,
kMyWeakReferenceToTypeDefinitionName,
sizeof(targetSet)/sizeof(aafUID_t),
targetSet));
// Validate that we make the correct "type" by inspecting the type category.
IAAFTypeDefSP pTypeDef;
checkResult(pWeakObjRef->QueryInterface(IID_IAAFTypeDef, (void **)&pTypeDef));
eAAFTypeCategory_t category;
checkResult(pTypeDef->GetTypeCategory(&category));
checkExpression(kAAFTypeCatWeakObjRef == category, AAFRESULT_TEST_FAILED);
// Add the new type to the dictionary.
checkResult(pDictionary->RegisterTypeDef(pTypeDef));
// Now add a new optional weak reference property to an existing class.
IAAFClassDefSP pFillerClass;
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult(pDictionary->LookupClassDef(AUID_AAFComponent, &pFillerClass));
checkResult(pFillerClass->RegisterOptionalPropertyDef(
kAAFPropID_TestWeakReferenceToType,
kMyWeakReferenceToTypeDefinitionPropertyName,
pTypeDef,
&pWeakRefPropertyDef));
}
#ifndef NO_REFERENCE_TO_MOB_TEST
if (weakReferencesSupported)
{
// Create a Weak reference to a mob.
IAAFTypeDefWeakObjRefSP pWeakObjRef;
checkResult(pDictionary->CreateMetaInstance(AUID_AAFTypeDefWeakObjRef,
IID_IAAFTypeDefWeakObjRef,
(IUnknown **)&pWeakObjRef));
// Find the class definition for all mobs.
IAAFClassDefSP pClassDef;
checkResult(pDictionary->LookupClassDef(AUID_AAFMob, &pClassDef));
aafUID_t targetSet[3];
targetSet[0] = kAAFPropID_Root_Header;
targetSet[1] = kAAFPropID_Header_Content;
targetSet[2] = kAAFPropID_ContentStorage_Mobs;
checkResult(pWeakObjRef->Initialize(kAAFTypeID_TestWeakReferenceToMob,
pClassDef,
kMyWeakReferenceToMobName,
sizeof(targetSet)/sizeof(aafUID_t),
targetSet));
// Validate that we make the correct "type" by inspecting the type category.
IAAFTypeDefSP pTypeDef;
checkResult(pWeakObjRef->QueryInterface(IID_IAAFTypeDef, (void **)&pTypeDef));
eAAFTypeCategory_t category;
checkResult(pTypeDef->GetTypeCategory(&category));
checkExpression(kAAFTypeCatWeakObjRef == category, AAFRESULT_TEST_FAILED);
// Add the new type to the dictionary.
checkResult(pDictionary->RegisterTypeDef(pTypeDef));
// Now add a new optional weak reference property to an existing class.
IAAFClassDefSP pFillerClass;
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult(pDictionary->LookupClassDef(AUID_AAFComponent, &pFillerClass));
checkResult(pFillerClass->RegisterOptionalPropertyDef(
kAAFPropID_TestWeakReferenceToMob,
kMyWeakReferenceToMobPropertyName,
pTypeDef,
&pWeakRefPropertyDef));
}
#endif
//
// Create a Composition Mob
//
IAAFMobSP pMob;
checkResult(defs.cdCompositionMob()->CreateInstance(IID_IAAFMob, (IUnknown **)&pMob));
checkResult(pMob->SetMobID(TEST_MobID));
checkResult(pMob->SetName(L"TestCompMob"));
//
// Create a sequence to hold our test fillers components.
//
IAAFSequenceSP pSequence;
checkResult (defs.cdSequence()->CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence));
checkResult (pSequence->Initialize (defs.ddkAAFPicture()));
IAAFFillerSP pFiller1;
checkResult (defs.cdFiller()->CreateInstance(IID_IAAFFiller, (IUnknown **)&pFiller1));
checkResult (pFiller1->Initialize (defs.ddkAAFPicture(), 16));
IAAFFillerSP pFiller2;
checkResult (defs.cdFiller()->CreateInstance(IID_IAAFFiller, (IUnknown **)&pFiller2));
checkResult (pFiller2->Initialize (defs.ddkAAFPicture(), 32));
if (weakReferencesSupported)
{
// Try adding a weak reference before filler is attached to the file.
CreateWeakReference(pFiller1, defs.tdInt64());
CheckWeakReference(pFiller1, defs.tdInt64());
ChangeWeakReference(pFiller1, defs.tdString());
CreateWeakReference(pFiller2, defs.tdInt32());
}
//
// Add the initialized fillers to the sequence.
//
IAAFComponentSP pComp1;
checkResult(pFiller1->QueryInterface(IID_IAAFComponent, (void **)&pComp1));
checkResult(pSequence->AppendComponent(pComp1));
IAAFComponentSP pComp2;
checkResult(pFiller2->QueryInterface(IID_IAAFComponent, (void **)&pComp2));
checkResult(pSequence->AppendComponent(pComp2));
//
// Append the sequence as the segment in a new timeline mob slot.
//
IAAFSegmentSP pSegment;
checkResult(pSequence->QueryInterface(IID_IAAFSegment, (void **)&pSegment));
aafRational_t editRate = {30000, 1001};
aafCharacter_constptr pSlotName = L"Slot 1";
aafPosition_t origin = 0;
IAAFTimelineMobSlotSP pNewSlot;
checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, TEST_SlotID, pSlotName, origin, &pNewSlot));
//
// Add to the set of mobs in the file.
//
checkResult(pHeader->AddMob(pMob));
#ifndef NO_REFERENCE_TO_MOB_TEST
if (weakReferencesSupported)
{
// The referenced object needs to be attached to the file.
CreateWeakReference(pFiller1, pMob);
CheckWeakReference(pFiller1, pMob);
}
#endif
// if (weakReferencesSupported)
// {
// // Try adding a weak reference after filler is attached to the file.
// CreateWeakReference(pFiller2, defs.tdInt32());
// }
// Verify the data before the save.
CAAFTypeDefWeakObjRef_verify (pHeader);
checkResult(pFile->Save());
checkResult(pFile->Close());
}
catch (HRESULT& rhr)
{
if (pFile) // only save & close the file if it was actually opened
{
pFile->Save(); // This may not be safe???
pFile->Close();
}
throw rhr;
}
catch (...)
{
if (pFile) // only close the file if it was actually opened
pFile->Close();
throw;
}
}
// Create the test file.
void CAAFTypeDefWeakObjRef_read (aafCharacter_constptr pFileName) // throw HRESULT
{
IAAFFileSP pFile;
IAAFHeaderSP pHeader;
HRESULT result = S_OK;
try
{
checkResult (AAFFileOpenExistingRead(pFileName, 0, &pFile));
checkResult (pFile->GetHeader (&pHeader));
CAAFTypeDefWeakObjRef_verify (pHeader);
result = pFile->Close();
}
catch (...)
{
if (pFile) // only close the file if it was actually opened
pFile->Close();
throw;
}
checkResult(result);
}
void CAAFTypeDefWeakObjRef_verify (IAAFHeader * pHeader)
{
IAAFDictionarySP pDictionary;
IAAFPropertyDefSP pWeakRefPropertyDef;
checkResult (pHeader->GetDictionary (&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
// Determine if it is okay to ready/validate weak references from the
// test file with the current version of the AAF.
bool weakReferencesSupported = false;
aafProductVersion_t toolkitVersion, fileToolkitVersion;
checkResult(GetAAFVersions(pHeader, &toolkitVersion, &fileToolkitVersion));
if (WeakReferencesSupported(toolkitVersion) && WeakReferencesSupported(fileToolkitVersion))
{
weakReferencesSupported = true;
}
if (weakReferencesSupported)
{
//
// Find and validate the new weak reference.
IAAFTypeDefSP pType;
checkResult(pDictionary->LookupTypeDef (kAAFTypeID_TestWeakReferenceToType, &pType));
eAAFTypeCategory_t category;
checkResult(pType->GetTypeCategory(&category));
checkExpression(kAAFTypeCatWeakObjRef == category, AAFRESULT_TEST_FAILED);
IAAFTypeDefWeakObjRefSP pWeakReferenceType;
checkResult(pType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));
checkResult(defs.cdFiller()->LookupPropertyDef(kAAFPropID_TestWeakReferenceToType, &pWeakRefPropertyDef));
// Validate the property's type
checkResult(pWeakRefPropertyDef->GetTypeDef(&pType));
checkExpression(EqualObjects(pType, pWeakReferenceType), AAFRESULT_TEST_FAILED);
// Use GetObjectType to make sure that the target class definitions are
// the same.
IAAFTypeDefObjectRefSP pObjectReferenceType;
checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
IAAFClassDefSP pReferencedObjectClass;
checkResult(pObjectReferenceType->GetObjectType(&pReferencedObjectClass));
// Find the class definition for all type definitions.
IAAFClassDefSP pTypeDefClass;
checkResult(pDictionary->LookupClassDef(AUID_AAFTypeDef, &pTypeDefClass));
checkExpression(EqualObjects(pReferencedObjectClass, pTypeDefClass), AAFRESULT_TEST_FAILED);
//
// Find our composition mob.
IAAFMobSP pMob;
checkResult(pHeader->LookupMob(TEST_MobID, &pMob));
IAAFMobSlotSP pSlot;
checkResult(pMob->LookupSlot(TEST_SlotID, &pSlot));
IAAFSegmentSP pSegment;
checkResult(pSlot->GetSegment(&pSegment));
IAAFSequenceSP pSequence;
checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **)&pSequence));
aafUInt32 elementCount;
checkResult(pSequence->CountComponents(&elementCount));
checkExpression(2 == elementCount, AAFRESULT_TEST_FAILED);
IAAFComponentSP pComp1;
checkResult(pSequence->GetComponentAt(0, &pComp1));
IAAFFillerSP pFiller1;
checkResult(pComp1->QueryInterface(IID_IAAFFiller, (void **)&pFiller1));
IAAFComponentSP pComp2;
checkResult(pSequence->GetComponentAt(1, &pComp2));
IAAFFillerSP pFiller2;
checkResult(pComp2->QueryInterface(IID_IAAFFiller, (void **)&pFiller2));
CheckWeakReference(pFiller1, defs.tdString());
CheckWeakReference(pFiller2, defs.tdInt32());
#ifndef NO_REFERENCE_TO_MOB_TEST
CheckWeakReference(pFiller1, pMob);
#endif
}
else if (!WeakReferencesSupported(toolkitVersion))
{
// This version does not support reading weak references.
throw AAFRESULT_NOT_IN_CURRENT_VERSION;
}
}
| 36.013736
| 117
| 0.729079
|
Phygon
|
c7fd6bb7f2d8e5953656243d97b5db63a9aeada5
| 5,321
|
cpp
|
C++
|
hw1/p2.cpp
|
andy0130tw/NTU-DSnP2015
|
38c883db0c94509819f6bd72bbc581bec42e18d7
|
[
"MIT"
] | 6
|
2016-10-29T05:50:13.000Z
|
2020-02-16T22:20:25.000Z
|
hw1/p2.cpp
|
andy0130tw/NTU-DSnP2015
|
38c883db0c94509819f6bd72bbc581bec42e18d7
|
[
"MIT"
] | 1
|
2016-12-13T20:28:13.000Z
|
2016-12-14T12:01:02.000Z
|
hw1/p2.cpp
|
andy0130tw/NTU-DSnP2015
|
38c883db0c94509819f6bd72bbc581bec42e18d7
|
[
"MIT"
] | null | null | null |
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#define UNDEF 9999
using namespace std;
class Data {
public:
Data(size_t s) {
_cols = new int[s];
}
const int operator[] (size_t i) const { return _cols[i]; }
int& operator[] (size_t i) { return _cols[i]; }
private:
int *_cols;
};
struct SortData {
bool operator() (const Data& d1, const Data& d2) {
int a, b;
for (int i = 0; i < _sortOrder.size(); i++) {
a = d1[_sortOrder[i]];
b = d2[_sortOrder[i]];
if (a != b) return a < b;
}
return false;
}
void pushOrder(size_t i) {
_sortOrder.push_back(i);
};
vector<size_t> _sortOrder;
};
int calculateSum(vector<Data> table, int col) {
int sum = 0;
int num;
for (int i = 0; i < table.size(); i++) {
num = table[i][col];
sum += (num == UNDEF ? 0 : num);
}
return sum;
}
double calculateAvg(vector<Data> table, int col) {
int sum = 0, cnt = 0;
int num;
for (int i = 0; i < table.size(); i++) {
num = table[i][col];
if (num != UNDEF) {
sum += num;
cnt++;
}
}
return 1.0 * sum / cnt;
}
int calculateMinMax(vector<Data> table, int col, int isMax) {
int ans = isMax ? -UNDEF : UNDEF;
int num;
for (int i = 0; i < table.size(); i++) {
num = table[i][col];
if (num != UNDEF && ((isMax && ans < num) || (!isMax && ans > num)))
ans = num;
}
return ans;
}
int calculateCnt(vector<Data> table, int col) {
int sorted[table.size()], p = 0;
for (int i = 0; i < table.size(); i++) {
if (table[i][col] != UNDEF)
sorted[p++] = table[i][col];
}
sort(sorted, sorted + p);
int cnt = 1;
for (int i = 0; i < p - 1; i++) {
if (sorted[i] != sorted[i + 1])
cnt++;
}
return cnt;
}
int main() {
vector<Data> table;
int n, m;
string filename;
cout << "Please enter the file name: ";
cin >> filename;
cout << "Please enter the number of rows and columns: ";
cin >> n >> m;
int num = UNDEF;
int sign = 1;
int j;
char tmp;
int flg;
FILE* f = fopen(filename.c_str(), "r");
for (int i = 0; i < n; i++) {
Data row(m);
j = 0;
flg = 0;
table.push_back(row);
while (1) {
flg = fscanf(f, "%c", &tmp);
// a workaround to force a line break at EOF
if (flg == EOF)
tmp = '\n';
if (tmp >= '0' && tmp <= '9') {
if (num == UNDEF)
num = 0;
num = num * 10 + (tmp - '0');
} else if (tmp == '-') {
sign = -1;
} else if (j > 0 || tmp == ',') {
row[j++] = num * sign;
num = UNDEF;
sign = 1;
if (tmp == '\n' || tmp == '\r') {
break;
}
}
if (flg == EOF)
break;
}
}
fclose(f);
cout << "File \"" << filename << "\" was read in successfully.\n";
string cmd;
while (cin >> cmd) {
if (cmd == "PRINT") {
for (int i = 0; i < table.size(); i++) {
for (int j = 0; j < m; j++) {
num = table[i][j];
if (num == UNDEF)
cout << " ";
else
cout << setw(4) << right << num;
}
cout << endl;
}
} else if (cmd == "ADD") {
Data row(m);
table.push_back(row);
for (int i = 0; i < m; i++) {
string str;
num = 0;
sign = 1;
cin >> str;
if (str == "-")
num = UNDEF;
else {
for (int c = 0; c < str.size(); c++) {
if (str[c] == '-')
sign = -1;
else
num = num * 10 + (str[c] - '0');
}
}
row[i] = num * sign;
}
} else if (cmd == "SUM") {
cin >> num;
cout << "The summation of data in column #"
<< num << " is " << calculateSum(table, num) << "." << endl;
} else if (cmd == "AVE") {
cin >> num;
cout << "The average of data in column #"
<< num << " is " << calculateAvg(table, num) << "." << endl;
} else if (cmd == "MAX") {
cin >> num;
cout << "The maximum of data in column #"
<< num << " is " << calculateMinMax(table, num, 1) << "." << endl;
} else if (cmd == "MIN") {
cin >> num;
cout << "The minimum of data in column #"
<< num << " is " << calculateMinMax(table, num, 0) << "." << endl;
} else if (cmd == "COUNT") {
cin >> num;
cout << "The distinct count of data in column #"
<< num << " is " << calculateCnt(table, num) << "." << endl;
} else if (cmd == "SORT") {
string fields;
getline(cin, fields);
SortData cmpfn;
num = -1;
for(int i = 0; i < fields.size(); i++) {
if (fields[i] >= '0' && fields[i] <= '9') {
if (num < 0)
num = 0;
num = num * 10 + fields[i] - '0';
} else if (num >= 0) {
cmpfn.pushOrder(num);
num = -1;
}
}
if (num >= 0)
cmpfn.pushOrder(num);
sort(table.begin(), table.end(), cmpfn);
} else {
cout << "UNRECOGNIZED: " << cmd << endl;
}
}
}
| 24.748837
| 78
| 0.430934
|
andy0130tw
|
c7fde809d3cae6496f625738bb68bf5e73b9de03
| 4,318
|
hpp
|
C++
|
src/game_api/savedata.hpp
|
estebanfer/overlunky
|
ffc41e7cc9bb6345942ed346f1a65a966fd0f39d
|
[
"MIT"
] | null | null | null |
src/game_api/savedata.hpp
|
estebanfer/overlunky
|
ffc41e7cc9bb6345942ed346f1a65a966fd0f39d
|
[
"MIT"
] | null | null | null |
src/game_api/savedata.hpp
|
estebanfer/overlunky
|
ffc41e7cc9bb6345942ed346f1a65a966fd0f39d
|
[
"MIT"
] | 1
|
2020-11-15T05:43:12.000Z
|
2020-11-15T05:43:12.000Z
|
#pragma once
#include <array>
#include <cstdint>
#include "state_structs.hpp"
#pragma pack(push, 1)
struct SaveGameArenaRuleset
{
uint8_t unknown1;
uint8_t unknown12;
uint8_t timer;
uint8_t timer_ending;
uint8_t wins;
uint8_t lives;
uint8_t unknown7;
uint8_t unknown8;
std::array<uint16_t, 4> unused_player_idolheld_countdown; // struct is similar to state.arenas so they just copied it, but this is not useful to store in the savegame
uint8_t health;
uint8_t bombs;
uint8_t ropes;
uint8_t stun_time;
uint8_t mount;
uint8_t arena_select;
ArenaConfigArenas arenas;
uint8_t dark_level_chance;
uint8_t crate_frequency;
ArenaConfigItems items_enabled;
ArenaConfigItems items_in_crate;
int8_t held_item;
int8_t equipped_backitem;
ArenaConfigEquippedItems equipped_items;
uint8_t whip_damage;
bool final_ghost;
uint8_t breath_cooldown;
bool punish_ball;
uint8_t padding[2];
};
struct ConstellationStar
{
uint32_t type;
float x;
float y;
float size;
float red;
float green;
float blue;
float alpha;
float halo_red;
float halo_green;
float halo_blue;
float halo_alpha;
bool canis_ring;
bool fidelis_ring;
uint8_t padding[2];
uint32_t unknown14; // might have something to do with how they are laid out on the path, having/being offshoots etc
};
struct ConstellationLine
{
uint8_t from; // zero based star index into Constellation.stars
uint8_t to;
};
struct Constellation
{
uint32_t star_count;
std::array<ConstellationStar, 45> stars;
float scale;
uint8_t line_count;
std::array<ConstellationLine, 90> lines; // You'd only need 44 lines if you have 45 stars, but there is room for 91. Could be to draw two lines on top of each other to make it brighter.
uint8_t padding[3];
float line_red_intensity; // 0 = normal white, npc_kills 8 - 16 = 0.5 - 1.0 (pink to deep red for criminalis)
};
struct SaveData
{
std::array<bool, 16> places;
std::array<bool, 78> bestiary;
std::array<bool, 38> people;
std::array<bool, 54> items;
std::array<bool, 24> traps;
int8_t skip1[2];
int32_t time_tutorial;
char last_daily[8];
uint8_t show_longer_journal_popup_count; // the next n times the 'Journal entry added' popup is shown, it's shown for 300 frames instead of 180
int8_t skip2[3];
uint32_t characters;
int8_t tutorial_state;
uint8_t shortcuts;
int8_t skip3[2];
std::array<int32_t, 78> bestiary_killed;
std::array<int32_t, 78> bestiary_killed_by;
std::array<int32_t, 38> people_killed;
std::array<int32_t, 38> people_killed_by;
int32_t plays;
int32_t deaths;
int32_t wins_normal;
int32_t wins_hard;
int32_t wins_special;
int64_t score_total;
int32_t score_top;
uint8_t deepest_area;
uint8_t deepest_level;
int8_t skip4[1022]; // TODO
std::array<std::array<uint32_t, 255>, 8> deathcount_per_level; // 8 themes, 255 uint32_t's for each level
int64_t time_total;
int32_t time_best;
std::array<int32_t, 20> character_deaths;
std::array<uint8_t, 3> pets_rescued;
// 1-based theme id into this array (0 = invalid theme, 19 = unknown)
// bool is set during transition with a theme change, except for CO, basecamp, arena
// due to tiamat and hundun, bool for neobab/sunkencity is only set when finishing these as 7-98
std::array<bool, 20> completed_themes;
bool completed_normal;
bool completed_ironman;
bool completed_hard;
bool profile_seen;
bool seeded_unlocked;
uint8_t world_last;
uint8_t level_last;
uint8_t theme_last;
int8_t skip7;
uint32_t score_last;
uint32_t time_last;
std::array<int32_t, 20> stickers;
int8_t skip8[40]; // first dword is a mask(?) that determines horizontal spacing between stickers
std::array<float, 20> sticker_angles; // rotation angle for each sticker
int8_t skip9[40];
std::array<float, 20> sticker_vert_offsets; // vertical offset for each sticker
int8_t skip10[40];
std::array<uint8_t, 4> players;
SaveGameArenaRuleset arena_favorite_ruleset;
Constellation constellation;
};
#pragma pack(pop)
| 30.195804
| 189
| 0.695924
|
estebanfer
|
c7ff8d1ca5558b155a60f714ab2ab389ad30bd33
| 614
|
hpp
|
C++
|
include/boost/sml/policies.hpp
|
GuiCodron/sml
|
2dab1265f87f70a2941af9de8f3f157df9a6a53f
|
[
"BSL-1.0"
] | 320
|
2020-07-03T18:58:34.000Z
|
2022-03-31T05:31:44.000Z
|
include/boost/sml/policies.hpp
|
GuiCodron/sml
|
2dab1265f87f70a2941af9de8f3f157df9a6a53f
|
[
"BSL-1.0"
] | 106
|
2020-06-30T15:03:00.000Z
|
2022-03-31T10:42:38.000Z
|
include/boost/sml/policies.hpp
|
GuiCodron/sml
|
2dab1265f87f70a2941af9de8f3f157df9a6a53f
|
[
"BSL-1.0"
] | 55
|
2020-07-10T12:32:49.000Z
|
2022-03-14T07:12:28.000Z
|
#include "boost/sml/back/policies.hpp"
#include "boost/sml/front/actions/defer.hpp"
template <class T>
struct thread_safe : aux::pair<back::thread_safety_policy__, thread_safe<T>> {
using type = T;
};
template <template <class...> class T>
struct defer_queue : aux::pair<back::defer_queue_policy__, defer_queue<T>> {
template <class U>
using rebind = T<U>;
template <class... Ts>
using defer = front::actions::defer_event<Ts...>;
};
template <class T>
struct logger : aux::pair<back::logger_policy__, logger<T>> {
using type = T;
};
struct testing : aux::pair<back::testing_policy__, testing> {};
| 25.583333
| 78
| 0.701954
|
GuiCodron
|
2a011b6bef490a13a1d357054abc7e639f9bdbff
| 1,132
|
cpp
|
C++
|
UVA/vol-111/11110.cpp
|
arash16/prays
|
0fe6bb2fa008b8fc46c80b01729f68308114020d
|
[
"MIT"
] | 3
|
2017-05-12T14:45:37.000Z
|
2020-01-18T16:51:25.000Z
|
UVA/vol-111/11110.cpp
|
arash16/prays
|
0fe6bb2fa008b8fc46c80b01729f68308114020d
|
[
"MIT"
] | null | null | null |
UVA/vol-111/11110.cpp
|
arash16/prays
|
0fe6bb2fa008b8fc46c80b01729f68308114020d
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
int n; char A[120][120];
int dfs(int y, int x, char c) {
if (A[y][x] != c) return 0;
A[y][x] = -1;
int r = 1;
if (x > 0) r += dfs(y, x-1, c);
if (x<n-1) r += dfs(y, x+1, c);
if (y > 0) r += dfs(y-1, x, c);
if (y<n-1) r += dfs(y+1, x, c);
return r;
}
bool seen[101];
bool check() {
memset(seen, 0, n);
for (int i=0; i<n; ++i)
for (int j=0; j<n; ++j)
if (A[i][j]>=0) {
if (seen[A[i][j]])
return 0;
else {
seen[A[i][j]] = 1;
dfs(i, j, A[i][j]);
}
}
return 1;
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);
string line;
while (cin >> n && n) {
for (int i=0; i<n; ++i)
memset(A[i], 0, n);
cin.ignore(500, '\n');
for (int i=1, x, y; i<n; ++i) {
getline(cin, line);
stringstream sin(line);
while (sin>>y>>x)
A[y-1][x-1] = i;
}
cout << (check() ? "good\n" : "wrong\n");
}
}
| 21.769231
| 49
| 0.373675
|
arash16
|