blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
ed333e184fa31115a8e3235ba53d8fed98857c84
78cdbfbfa915497c5b0415d0a6e09dcc749fd6ba
/gotcloud/src/bamUtil/src/Diff.h
058184abafa1926ee5e4c2ffbcced378dcbae6a6
[ "Apache-2.0" ]
permissive
statgen/topmed_freeze3_calling
9b00ee64804165e320ae5690ebb42e01345c24e2
b01a53468e1e989988b09fd74f3e9ce9faa62a99
refs/heads/master
2018-12-12T20:02:46.909940
2018-12-05T01:35:08
2018-12-05T01:35:08
68,630,437
11
5
null
null
null
null
UTF-8
C++
false
false
5,732
h
/* * Copyright (C) 2011 Regents of the University of Michigan * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ ////////////////////////////////////////////////////////////////////////// // This file contains the processing for the executable option "diff" // which reads two SAM/BAM files and writes the differences. #ifndef __DIFF_H__ #define __DIFF_H__ #include <stack> #include <list> #include <map> #include "BamExecutable.h" #include "SamFile.h" class Diff : public BamExecutable { public: Diff(); ~Diff(); static void diffDescription(); void description(); void usage(); int execute(int argc, char **argv); virtual const char* getProgramName() {return("bam:diff");} private: struct diffStruct { bool posDiff; bool cigarDiff; bool flagDiff; bool mapqDiff; bool mateDiff; bool isizeDiff; bool seqDiff; bool qualDiff; bool tagsDiff; } myDiffStruct; class FileInfo { public: SamFile file; SamFileHeader header; }; class UnmatchedRecords { public: UnmatchedRecords() : myListUnmatched(), myFragmentMaps(4), myUnmatchedFileIter() { } // Return the number of elements in this unmatched record container. inline int size() { return(myListUnmatched.size()); } // Add the specified record to the list of unmatched records. void addUnmatchedRecord(SamRecord& record); // Get and remove the record that matches the specified record's // query(read) name and fragment (first/last/mid/unknown). // If no match is found, return NULL. SamRecord* removeFragmentMatch(SamRecord& record); // Remove the first entry from this unmatched file container, returning a pointer // to the record. SamRecord* removeFirst(); // Get the first entry from this unmatched file container, returning a pointer // to the record without removing it. SamRecord* getFirst(); private: typedef std::map<std::string, std::list<SamRecord*>::iterator> mapType; std::list<SamRecord*> myListUnmatched; std::vector<mapType> myFragmentMaps; std::map<std::string,std::list<SamRecord*>::iterator>::iterator myUnmatchedFileIter; }; // Check to see if the two records are a match - same read name & fragment. // Return true if they match, false if not. bool matchingRecs(SamRecord* rec1, SamRecord* rec2); // Compare two records. Returns true if the first record chrom/pos are less than or // equal to record2's chrom/pos, false if rec2 is less than rec1. // Threshold is a value to be added to rec1's position before comparing to rec2. It is // a way to determine if rec1 is more than a certain number of positions less than rec2. // Threshold is defaulted to 0, so the excact positions are compared. // If they are on different chromosomes, threshold is not used. bool lessThan(SamRecord* rec1, SamRecord* rec2, int threshold = 0); void writeBamDiffs(SamRecord* rec1, SamRecord* rec2); void writeDiffDiffs(SamRecord* rec1, SamRecord* rec2); void writeDiffs(SamRecord* rec1, SamRecord* rec2); bool getDiffs(SamRecord* rec1, SamRecord* rec2); bool writeReadName(SamRecord& record); SamRecord* getSamRecord(); // If record is not NULL, adds it back to the free list. If record is NULL, nothing is done. void releaseSamRecord(SamRecord* record); bool checkDiffFile(); static const char* FLAG_DIFF_TAG; static const char* POS_DIFF_TAG; static const char* CIGAR_DIFF_TAG; static const char* MAPQ_DIFF_TAG; static const char* MATE_DIFF_TAG; static const char* ISIZE_DIFF_TAG; static const char* SEQ_DIFF_TAG; static const char* QUAL_DIFF_TAG; static const char* TAGS_DIFF_TAG; static const char POS_DIFF_TYPE = 'Z'; static const char MATE_DIFF_TYPE = 'Z'; static const char CIGAR_DIFF_TYPE = 'Z'; static const char SEQ_DIFF_TYPE = 'Z'; static const char QUAL_DIFF_TYPE = 'Z'; static const char TAGS_DIFF_TYPE = 'Z'; std::stack<SamRecord*> myFreeSamRecords; UnmatchedRecords myFile1Unmatched; UnmatchedRecords myFile2Unmatched; bool myCompAll; bool myCompCigar; bool myCompPos; bool myCompBaseQual; bool myCompSeq; bool myCompFlag; bool myCompMapQ; bool myCompMate; bool myCompISize; String myTags; bool myEveryTag; bool myOnlyDiffs; bool myBamOut; int myMaxAllowedRecs; int myAllocatedRecs; int myThreshold; int myNumPoolOverflows; FileInfo myFile1; FileInfo myFile2; String myDiffFileName; String myBamOnly1Name; String myBamOnly2Name; String myBamDiffName; IFILE myDiffFile; SamFile myBamOnly1; SamFile myBamOnly2; SamFile myBamDiff; String myDiff1; String myDiff2; String myTags1; String myTags2; String myTempBuffer; }; #endif
[ "hmkang@umich.edu" ]
hmkang@umich.edu
6946e5cd68e3f0f04fa95717046b55af1e7d8bef
ae32568140c6020d700de6f22bfeff2c4332e66a
/C++/data-structures/AVLTree.h
b74c3ee2704933aa74914e84d16cba7370ad6d15
[]
no_license
darvelo/data-structures-and-algorithms
66555d961c98ac112cccf208efc9e8bfb25a5163
7e524aa31846219eee6c63a8c0bd62a401b4d979
refs/heads/master
2021-01-13T01:27:54.636554
2015-11-14T23:42:16
2015-11-14T23:42:16
25,101,051
0
0
null
null
null
null
UTF-8
C++
false
false
8,086
h
#ifndef AVL_TREE_H #define AVL_TREE_H #include <iostream> #include <functional> /* less, function */ #include <utility> /* move, forward */ #include <algorithm> /* max */ template <typename Object, typename Comparator=std::less<Object>> class AVLTree { private: struct Node { Object data; Node* left = nullptr; Node* right = nullptr; int height; Node (const Object& x, Node* _left = nullptr, Node* _right = nullptr, int _height = 0) : data(x), left(_left), right(_right), height(_height) { } Node (Object&& x, Node* _left = nullptr, Node* _right = nullptr, int _height = 0) : data(std::move(x)), left(_left), right(_right), height(_height) { } }; public: AVLTree() { } AVLTree(const AVLTree& rhs) : root{nullptr} { *this = rhs; } AVLTree(AVLTree&& rhs) : root{nullptr} { *this = std::forward<AVLTree>(rhs); } AVLTree& operator=(const AVLTree& rhs) { clear(); root = clone(rhs.root); } AVLTree& operator=(AVLTree&& rhs) { clear(); root = std::move(rhs.root); rhs.root = nullptr; } ~AVLTree() { clear(); } Node* min () const { min(root); } Node* min (Node* min) const { if (min == nullptr) { return nullptr; } while (min->left != nullptr) { min = min->left; } return min; } Node* max () const { max(root); } Node* max (Node* max) const { if (max == nullptr) { return nullptr; } while (max->right != nullptr) { max = max->right; } return max; } Node* search (const Object& data) const { return search(data, root); } bool contains(const Object& data) const { return search(data, root) != nullptr; } void insert (const Object& data) { insert(data, root); } void insert (Object&& data) { insert(std::forward<Object>(data), root); } void remove (const Object& data) { remove(data, root); } void clear () { clear(root); } void print (std::ostream& out = std::cout) { print(root, out); } private: Node* search (const Object& data, Node*const& t) const { if (t == nullptr || data == t->data) { return t; } if (isLessThan(t->data, data)) { return search(data, t->right); } else { return search(data, t->left); } } int height(Node* t) const { return t == nullptr ? -1 : t->height; } void rotateWithLeftChild(Node*& t) { Node* k = t->left; t->left = k->right; k->right = t; t->height = 1 + std::max(height(t->left), height(t->right)); k->height = 1 + std::max(height(k->left), t->height); t = k; } void rotateWithRightChild(Node*& t) { Node* k = t->right; t->right = k->left; k->left = t; t->height = 1 + std::max(height(t->left), height(t->right)); k->height = 1 + std::max(height(k->right), t->height); t = k; } void doubleRotateWithLeftChild(Node*& t) { rotateWithRightChild(t->left); rotateWithLeftChild(t); } void doubleRotateWithRightChild(Node*& t) { rotateWithLeftChild(t->right); rotateWithRightChild(t); } void balance(Node*& t) { if (t == nullptr) { return; } // if left is higher than right if (height(t->left) - height(t->right) > ALLOWED_IMBALANCE) { // if the height runs higher on the outer left margins of the subtree. // the `>=` allows deletions to rotate correctly when the subtree // on the opposite subtree of the deletion has subtrees of equal height if (height(t->left->left) >= height(t->left->right)) { rotateWithLeftChild(t); // if the height runs higher on the inner subtree of the left node } else { doubleRotateWithLeftChild(t); } // if right is higher than left } else if (height(t->right) - height(t->left) > ALLOWED_IMBALANCE) { // if the height runs higher on the outer right margins of the subtree. // the `>=` allows deletions to rotate correctly when the subtree // on the opposite subtree of the deletion has subtrees of equal height if (height(t->right->right) >= height(t->right->left)) { rotateWithRightChild(t); // if the height runs higher on the inner subtree of the right node } else { doubleRotateWithRightChild(t); } } t->height = 1 + std::max(height(t->left), height(t->right)); } void insert (const Object& data, Node*& t) { if (t == nullptr) { t = new Node(data); } else if (isLessThan(data, t->data)) { insert(data, t->left); } else if (isLessThan(t->data, data)) { insert(data, t->right); } else { ; // duplicate data - do nothing } balance(t); } void insert (Object&& data, Node*& t) { if (t == nullptr) { t = new Node(std::move(data)); } else if (isLessThan(data, t->data)) { insert(std::forward<Object>(data), t->left); } else if (isLessThan(t->data, data)) { insert(std::forward<Object>(data), t->right); } else { ; // duplicate data - do nothing } balance(t); } void remove (const Object& data, Node*& t) { if (t == nullptr) { return; } else if (isLessThan(data, t->data)) { remove(data, t->left); } else if (isLessThan(t->data, data)) { remove(data, t->right); } else if (t->left != nullptr && t->right != nullptr) { // two child nodes t->data = min(t->right)->data; remove(t->data, t->right); } else { // zero or one child node Node* oldNode = t; t = (t->right != nullptr) ? t->right : t->left; delete oldNode; } balance(t); } void clear (Node*& t) { if (t != nullptr) { clear(t->left); clear(t->right); delete t; t = nullptr; } } Node* clone (Node* t) const { if (t == nullptr) { return nullptr; } return new Node(t->data, clone(t->left), clone(t->right)); } void print (Node* t, std::ostream& out = std::cout) { preOrderTraversal(t, [&out] (Node* t) { out << "data: " << t->data << ", height = " << t->height; out << ", left: "; (t->left != nullptr) ? out << t->left->data : out << "null"; out << ", right: "; (t->right != nullptr) ? out << t->right->data : out << "null"; out << std::endl; }); out << std::endl; } void preOrderTraversal (Node*& t, std::function<void(Node*)> processNode) { if (t == nullptr) { return; } processNode(t); preOrderTraversal(t->left, processNode); preOrderTraversal(t->right, processNode); } void inOrderTraversal (Node*& t, std::function<void(Node*)> processNode) { if (t == nullptr) { return; } inOrderTraversal(t->left, processNode); processNode(t); inOrderTraversal(t->right, processNode); } void postOrderTraversal (Node*& t, std::function<void(Node*)> processNode) { if (t == nullptr) { return; } postOrderTraversal(t->left, processNode); postOrderTraversal(t->right, processNode); processNode(t); } static const int ALLOWED_IMBALANCE = 1; Comparator isLessThan; Node* root = nullptr; }; #endif
[ "david@davidarvelo.com" ]
david@davidarvelo.com
0a924e2755f189f9dbd5a7536d89641797ecbfd9
6b5d6690678f05a71837b85016db3da52359a2f6
/src/net/base/upload_file_element_reader.h
f246553d421028bdc8d9e4818a479c5bafe3e8fe
[ "BSD-3-Clause", "MIT" ]
permissive
bopopescu/MQUIC
eda5477bacc68f30656488e3cef243af6f7460e6
703e944ec981366cfd2528943b1def2c72b7e49d
refs/heads/master
2022-11-22T07:41:11.374401
2016-04-08T22:27:32
2016-04-08T22:27:32
282,352,335
0
0
MIT
2020-07-25T02:05:49
2020-07-25T02:05:49
null
UTF-8
C++
false
false
3,409
h
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ #define NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ #include <stdint.h> #include "base/compiler_specific.h" #include "base/files/file.h" #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/base/upload_element_reader.h" namespace base { class TaskRunner; } namespace net { class FileStream; // An UploadElementReader implementation for file. class NET_EXPORT UploadFileElementReader : public UploadElementReader { public: // |task_runner| is used to perform file operations. It must not be NULL. UploadFileElementReader(base::TaskRunner* task_runner, const base::FilePath& path, uint64_t range_offset, uint64_t range_length, const base::Time& expected_modification_time); ~UploadFileElementReader() override; const base::FilePath& path() const { return path_; } uint64_t range_offset() const { return range_offset_; } uint64_t range_length() const { return range_length_; } const base::Time& expected_modification_time() const { return expected_modification_time_; } // UploadElementReader overrides: const UploadFileElementReader* AsFileReader() const override; int Init(const CompletionCallback& callback) override; uint64_t GetContentLength() const override; uint64_t BytesRemaining() const override; int Read(IOBuffer* buf, int buf_length, const CompletionCallback& callback) override; private: FRIEND_TEST_ALL_PREFIXES(ElementsUploadDataStreamTest, FileSmallerThanLength); FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, UploadFileSmallerThanLength); // Resets this instance to the uninitialized state. void Reset(); // These methods are used to implement Init(). void OnOpenCompleted(const CompletionCallback& callback, int result); void OnSeekCompleted(const CompletionCallback& callback, int64_t result); void OnGetFileInfoCompleted(const CompletionCallback& callback, base::File::Info* file_info, bool result); // This method is used to implement Read(). int OnReadCompleted(const CompletionCallback& callback, int result); // Sets an value to override the result for GetContentLength(). // Used for tests. struct NET_EXPORT_PRIVATE ScopedOverridingContentLengthForTests { explicit ScopedOverridingContentLengthForTests(uint64_t value); ~ScopedOverridingContentLengthForTests(); }; scoped_refptr<base::TaskRunner> task_runner_; const base::FilePath path_; const uint64_t range_offset_; const uint64_t range_length_; const base::Time expected_modification_time_; scoped_ptr<FileStream> file_stream_; uint64_t content_length_; uint64_t bytes_remaining_; base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(UploadFileElementReader); }; } // namespace net #endif // NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_
[ "junhuac@hotmail.com" ]
junhuac@hotmail.com
e8f0a8715d3fe824c32386f7412841549c8cda1a
3180c55988e3e87dd1290d6f90c3b63a08f6042a
/IfcPlusPlus/src/ifcpp/IFC4/IfcCompoundPlaneAngleMeasure.cpp
b5f2daefefe0581526fcfaa2d320d4551e49e1d5
[]
no_license
bbrangeo/IFCPlusPlus
65d3bb3c0cdd4043f516a6a8321d522e0683a180
87e361487c86a15a4417b4ab8d744cd7b9a39876
refs/heads/master
2021-01-17T22:20:29.395459
2014-06-05T13:05:31
2014-06-05T13:05:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,755
cpp
/* -*-c++-*- IfcPlusPlus - www.ifcplusplus.com - Copyright (C) 2011 Fabian Gerold * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include <sstream> #include <limits> #include <map> #include "ifcpp/reader/ReaderUtil.h" #include "ifcpp/writer/WriterUtil.h" #include "ifcpp/model/shared_ptr.h" #include "ifcpp/model/IfcPPException.h" #include "include/IfcDerivedMeasureValue.h" #include "include/IfcCompoundPlaneAngleMeasure.h" // TYPE IfcCompoundPlaneAngleMeasure IfcCompoundPlaneAngleMeasure::IfcCompoundPlaneAngleMeasure() {} IfcCompoundPlaneAngleMeasure::~IfcCompoundPlaneAngleMeasure() {} void IfcCompoundPlaneAngleMeasure::getStepParameter( std::stringstream& stream, bool is_select_type ) const { if( is_select_type ) { stream << "IFCCOMPOUNDPLANEANGLEMEASURE("; } writeIntList( stream, m_vec ); if( is_select_type ) { stream << ")"; } } shared_ptr<IfcCompoundPlaneAngleMeasure> IfcCompoundPlaneAngleMeasure::createObjectFromStepData( const std::string& arg ) { // read TYPE if( arg.compare( "$" ) == 0 ) { return shared_ptr<IfcCompoundPlaneAngleMeasure>(); } auto type_object = std::make_shared<IfcCompoundPlaneAngleMeasure>(); readIntList( arg, type_object->m_vec ); return type_object; }
[ "fabian.gerold@gmail.com@06f6d6f3-f2e0-f239-6e86-ba6a5d17d3a5" ]
fabian.gerold@gmail.com@06f6d6f3-f2e0-f239-6e86-ba6a5d17d3a5
fb1086b7e34ad6f67307720576b6e12416d01b6f
9c433cba8a1d67410cc5354c789a7d17af6b8890
/MFC/wbxu_20140704/DDX/MyListBoxProxy.h
03aa38440ca6e34620d41724c8f2cb0679bf91a4
[]
no_license
958724723/KR_Ph2
011d5d4bcd6c3381ea16e051f5e50c828a63cdfc
07e3ed72265e8254b894f444cca3fd807d1fc6bb
refs/heads/master
2021-12-03T16:13:31.529881
2014-08-28T16:19:09
2014-08-28T16:19:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,148
h
#if !defined(AFX_MYLISTBOXPROXY_H__CF61CB90_89FF_4E1A_980B_EA61F41091FD__INCLUDED_) #define AFX_MYLISTBOXPROXY_H__CF61CB90_89FF_4E1A_980B_EA61F41091FD__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // MyListBoxProxy.h : header file // ///////////////////////////////////////////////////////////////////////////// // CMyListBoxProxy window class CMyListBoxProxy : public CListBox { // Construction public: CMyListBoxProxy(); // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMyListBoxProxy) //}}AFX_VIRTUAL // Implementation public: virtual ~CMyListBoxProxy(); // Generated message map functions protected: //{{AFX_MSG(CMyListBoxProxy) afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MYLISTBOXPROXY_H__CF61CB90_89FF_4E1A_980B_EA61F41091FD__INCLUDED_)
[ "xuwenbo_outlook@outlook.com" ]
xuwenbo_outlook@outlook.com
8ca2b16ba0a76c0a9a9e6d536cb9ec6c806c2d5d
aa2c4d1eda9e7c4bc609a2f03e3e037ef03c4ea0
/src/util.h
ecf4040430b26644ce980a6bacd8b0515a0ebee6
[]
no_license
andi-d/project-euler
83c137a308bd1814620d79fbdd4d7657b6c2057e
8177aa48e23d159042fd51beefcf217e99f10e05
refs/heads/master
2021-01-18T12:17:49.173476
2015-06-14T18:23:46
2015-06-14T18:23:46
38,903,949
0
0
null
null
null
null
UTF-8
C++
false
false
2,335
h
#pragma once #include <sstream> #include <string> #include <chrono> #include <map> template<class T, class D> std::string strjoin(T t, D d) { std::stringstream ss; for (auto ii = std::begin(t); ii != (std::end(t)-1);ii++) { ss << *ii << d; } ss << *(std::end(t)-1); return ss.str(); } namespace detail { template<typename T> std::string getSuffix();// { return ""; } template<> std::string getSuffix<std::nano>() { return "ns"; } template<> std::string getSuffix<std::micro>() { return "us"; } template<> std::string getSuffix<std::milli>() { return "ms"; } template<> std::string getSuffix<std::ratio<1>>() { return "s"; } } class Stopwatch { private: using time_point = std::chrono::time_point<std::chrono::high_resolution_clock>; struct Trial { time_point start_; time_point end_; bool ended_ = false; }; public: void start(std::string tag = std::string{""}) { Trial t; t.start_ = std::chrono::high_resolution_clock::now(); trials_.insert({ std::move(tag), std::move(t) }); }; void stop(std::string tag = std::string{ "" }) { auto t = trials_.find(tag); if (t != trials_.end()) { stop(t->second); } } template<typename TimeUnit = std::ratio<1>> std::string get(std::string tag = std::string{ "" }) { auto t = trials_.begin(); if (t != std::end(trials_)) { if (!tag.empty()) { t = trials_.find(tag); } if (!t->second.ended_) { stop(t->second); } std::ostringstream ss; if (!t->first.empty()) { ss << t->first << ": "; } ss << count<TimeUnit>(t->second) << detail::getSuffix<TimeUnit>(); trials_.erase(t->first); lastResult_ = ss.str(); } return lastResult_; } private: template<typename TimeUnit = std::ratio<1>> double count(Trial &t) { return std::chrono::duration<double, TimeUnit>(t.end_ - t.start_).count(); } void stop(Trial &t) { t.end_ = std::chrono::high_resolution_clock::now(); t.ended_ = true; } std::map<std::string, Trial> trials_; std::string lastResult_; };
[ "andreas.derksen2@gmail.com" ]
andreas.derksen2@gmail.com
39fd9ac4a7e6589598c203eff20670a632ee1f7f
dda672f0bd67fcafc14aae0e8abc3aa7c8d801ac
/core/geometry/rorgeometry_utilities.hh
2bb2fc17d09d640d44ba5424a59a864cb04fd446
[ "MIT" ]
permissive
abbaswasim/roar
0ee809b048d7597aca82f4e340f412387993e552
c845daf5fb1e76c628b4d3d7a346ca0bbfe0641e
refs/heads/master
2023-08-04T10:32:31.010407
2023-08-02T19:21:13
2023-08-02T19:21:13
182,329,573
2
0
null
null
null
null
UTF-8
C++
false
false
20,938
hh
// Roar Source Code // Wasim Abbas // http://www.waZim.com // Copyright (c) 2008-2020 // // 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. // // Version: 1.0.0 #pragma once #include "foundation/rortypes.hpp" #include "math/rormatrix4_functions.hpp" #include "math/rorvector3.hpp" #include "rorgeometry_utilities.hpp" #include <cstddef> #include <cstdint> #include <functional> #include <vector> #define PAR_OCTASPHERE_IMPLEMENTATION #include "par/par_octasphere.h" #define PAR_SHAPES_IMPLEMENTATION #include "par/par_shapes.h" namespace ror { /** * @brief Returns 8 corners for a cube or 4 corners of a box * @param a_minimum Starting point of the box * @param a_maximum Finishing point of the box * @param a_corners The amount of corners requested (8, 4) * @param a_output Corners are returned here */ template <class _type> FORCE_INLINE void _box_corners_internal(const _type &a_minimum, const _type &a_maximum, uint32_t a_corners, std::vector<_type> &a_output) { a_output.reserve(a_output.size() + a_corners); // https://github.com/sgorsten/linalg algoritm for creating cube for (uint32_t i = 0; i < a_corners; ++i) { // Two copies of Vector3i or Vector2i arn't good but this isn't suppose to be real time _type corner = vector_select(vector_type<_type, uint32_t>(Vector3ui(i & 1, i & 2, i & 4)), a_minimum, a_maximum); a_output.emplace_back(corner); } } /** * @brief Returns 8 corners for a cube or 4 corners of a box * @param a_minimum Starting point of the box * @param a_maximum Finishing point of the box * @param a_vertex_buffer Corners are returned here */ template <class _type> FORCE_INLINE void _box_points_internal(const _type &a_minimum, const _type &a_maximum, std::vector<_type> &a_vertex_buffer) { static_assert(!(std::is_same<_type, Vector4<typename _type::value_type>>::value), "Can't create a 4D Cube\n"); uint32_t corners = 8; if constexpr (std::is_same<_type, Vector2<typename _type::value_type>>::value) { corners = 4; } _box_corners_internal(a_minimum, a_maximum, corners, a_vertex_buffer); } /** * @brief Returns 12 or 2 triangles created from 8 corners of a cube or 4 corners of a box * @param a_minimum Starting point of the box * @param a_maximum Finishing point of the box * @param a_vertex_buffer Corners are returned here */ template <class _type> FORCE_INLINE void _box_triangles_internal(const _type &a_minimum, const _type &a_maximum, std::vector<_type> &a_vertex_buffer) { static_assert(!(std::is_same<_type, Vector4<typename _type::value_type>>::value), "Can't create a 4D Cube\n"); const size_t indices[] = {0, 1, 2, 1, 3, 2, 5, 4, 6, 5, 6, 7, 0, 2, 6, 4, 0, 6, 1, 5, 3, 5, 7, 3, 3, 7, 2, 7, 6, 2, 0, 4, 1, 4, 5, 1}; uint32_t corners = 8; uint32_t triangles = 12; if constexpr (std::is_same<_type, Vector2<typename _type::value_type>>::value) { corners = 4; triangles = 2; } std::vector<_type> vertex_buffer; _box_corners_internal(a_minimum, a_maximum, corners, vertex_buffer); // Lets calculate index buffer and triangles a_vertex_buffer.reserve(a_vertex_buffer.size() + triangles * 9); for (uint32_t i = 0; i < triangles; ++i) { a_vertex_buffer.emplace_back(vertex_buffer[indices[3 * i]]); a_vertex_buffer.emplace_back(vertex_buffer[indices[3 * i + 1]]); a_vertex_buffer.emplace_back(vertex_buffer[indices[3 * i + 2]]); } } /** * @brief Returns indices for a_triangles amount of triangles for a Cube or Box * @param a_index_buffer Triangle indices are returned here * @param a_triangles Amount of triangles requested (2 for a box, 12 for a Cube) */ template <class _index_type = uint32_t> FORCE_INLINE void _box_triangles_indices_internal(uint32_t a_triangles, std::vector<ror::Vector3<_index_type>> &a_index_buffer) { const std::vector<ror::Vector3<_index_type>> indices{{0, 1, 2}, {1, 3, 2}, {5, 4, 6}, {5, 6, 7}, {0, 2, 6}, {4, 0, 6}, {1, 5, 3}, {5, 7, 3}, {3, 7, 2}, {7, 6, 2}, {0, 4, 1}, {4, 5, 1}}; a_index_buffer.reserve(a_index_buffer.size() + a_triangles); std::copy(indices.begin(), indices.begin() + a_triangles, std::back_inserter(a_index_buffer)); } template <class _type> FORCE_INLINE void _box_lines_internal(const _type &a_minimum, const _type &a_maximum, std::vector<_type> &a_vertex_buffer) { static_assert(!(std::is_same<_type, Vector4<typename _type::value_type>>::value), "Can't create a 4D Box\n"); const size_t indices[] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 1, 5, 2, 6, 3, 7, 4, 5, 5, 7, 7, 6, 6, 4}; uint32_t corners = 8; uint32_t lines = 12; if constexpr (std::is_same<_type, Vector2<typename _type::value_type>>::value) { corners = 4; lines = 4; } std::vector<_type> vertex_buffer; _box_corners_internal(a_minimum, a_maximum, corners, vertex_buffer); // Lets calculate index buffer and lines a_vertex_buffer.reserve(a_vertex_buffer.size() + lines); for (uint32_t i = 0; i < lines; ++i) { a_vertex_buffer.emplace_back(vertex_buffer[indices[2 * i]]); a_vertex_buffer.emplace_back(vertex_buffer[indices[2 * i + 1]]); } } template <class _index_type = uint32_t> FORCE_INLINE void _box_lines_indices_internal(uint32_t a_lines, std::vector<ror::Vector2<_index_type>> &a_index_buffer) { const std::vector<ror::Vector2<_index_type>> indices{{0, 1}, {1, 3}, {3, 2}, {2, 0}, {0, 4}, {1, 5}, {2, 6}, {3, 7}, {4, 5}, {5, 7}, {7, 6}, {6, 4}}; a_index_buffer.reserve(a_index_buffer.size() + a_lines); std::copy(indices.begin(), indices.begin() + a_lines, std::back_inserter(a_index_buffer)); } template <class _type> FORCE_INLINE void make_box_triangles(std::vector<_type> &a_vertex_buffer, const _type &a_minimum, const _type &a_maximum) { _box_triangles_internal(a_minimum, a_maximum, a_vertex_buffer); } template <class _type> FORCE_INLINE void make_box_triangles(const _type &a_size, const _type &a_origin, std::vector<_type> &a_vertex_buffer) { _type half_size = (a_size / 2); _type minimum{a_origin - half_size}, maximum{half_size + a_origin}; _box_triangles_internal(minimum, maximum, a_vertex_buffer); } template <class _type> FORCE_INLINE void make_box_triangles(float32_t a_size, const _type &a_origin, std::vector<_type> &a_vertex_buffer) { make_box_triangles(_type(a_size), a_origin, a_vertex_buffer); } template <class _type> FORCE_INLINE void make_box_triangles(float32_t a_size, std::vector<_type> &a_vertex_buffer) { make_box_triangles(_type(a_size), _type(0), a_vertex_buffer); } template <class _type> FORCE_INLINE std::vector<_type> make_box_triangles(float32_t a_size) { std::vector<_type> a_vertex_buffer; make_box_triangles(_type(a_size), _type(0), a_vertex_buffer); return a_vertex_buffer; } template <class _type, class _index_type> FORCE_INLINE void make_box_triangles_indexed(const _type &a_size, const _type &a_origin, std::vector<_type> &a_vertex_buffer, std::vector<ror::Vector3<_index_type>> &a_index_buffer) { uint32_t triangles = 12; if constexpr (std::is_same<_type, Vector2<typename _type::value_type>>::value) { triangles = 2; } _type half_size = (a_size / 2); _type minimum{a_origin - half_size}, maximum{half_size + a_origin}; _box_points_internal(minimum, maximum, a_vertex_buffer); _box_triangles_indices_internal(triangles, a_index_buffer); } template <class _type, class _index_type> FORCE_INLINE void make_box_triangles_indexed(std::vector<_type> &a_vertex_buffer, std::vector<ror::Vector3<_index_type>> &a_index_buffer) { make_box_triangles_indexed(_type(1), _type(0), a_vertex_buffer, a_index_buffer); } // Same set of functions for box but this time for lines instead of triangles template <class _type> FORCE_INLINE void make_box_lines(std::vector<_type> &a_vertex_buffer, const _type &a_minimum, const _type &a_maximum) { _box_lines_internal(a_minimum, a_maximum, a_vertex_buffer); } template <class _type> FORCE_INLINE void make_box_lines(const _type &a_size, const _type &a_origin, std::vector<_type> &a_vertex_buffer) { _type half_size = (a_size / 2); _type minimum{a_origin - half_size}, maximum{half_size + a_origin}; _box_lines_internal(minimum, maximum, a_vertex_buffer); } template <class _type> FORCE_INLINE void make_box_lines(float32_t a_size, const _type &a_origin, std::vector<_type> &a_vertex_buffer) { make_box_lines(_type(a_size), a_origin, a_vertex_buffer); } template <class _type> FORCE_INLINE void make_box_lines(float32_t a_size, std::vector<_type> &a_vertex_buffer) { make_box_lines(_type(a_size), _type(0), a_vertex_buffer); } template <class _type> FORCE_INLINE std::vector<_type> make_box_lines(float32_t a_size) { std::vector<_type> a_vertex_buffer; make_box_lines(_type(a_size), _type(0), a_vertex_buffer); return a_vertex_buffer; } template <class _type, class _index_type> FORCE_INLINE void make_box_lines_indexed(const _type &a_size, const _type &a_origin, std::vector<_type> &a_vertex_buffer, std::vector<ror::Vector2<_index_type>> &a_index_buffer) { uint32_t lines = 12; if constexpr (std::is_same<_type, Vector2<typename _type::value_type>>::value) { lines = 4; } _type half_size = (a_size / 2); _type minimum{a_origin - half_size}, maximum{half_size + a_origin}; _box_points_internal(minimum, maximum, a_vertex_buffer); _box_lines_indices_internal(lines, a_index_buffer); } template <class _type, class _index_type> FORCE_INLINE void make_box_lines_indexed(std::vector<_type> &a_vertex_buffer, std::vector<ror::Vector2<_index_type>> &a_index_buffer) { make_box_lines_indexed(_type(1), _type(0), a_vertex_buffer, a_index_buffer); } void make_sphere_triangles(std::vector<ror::Vector3f> &a_vertex_buffer, int32_t a_subdivisions, float32_t a_cornder_radius) { par_octasphere_config cfg{};// = { cfg.corner_radius = a_cornder_radius; cfg.width = 0; cfg.height = 0; cfg.depth = 0; cfg.num_subdivisions = a_subdivisions; // cfg.uv_mode = PAR_OCTASPHERE_UV_LATLONG; // cfg.normals_mode = PAR_OCTASPHERE_NORMALS_SMOOT; //}; uint32_t num_indices; uint32_t num_vertices; par_octasphere_get_counts(&cfg, &num_indices, &num_vertices); std::vector<ror::Vector3f> vertex_buffer{}; std::vector<uint16_t> indicies{}; vertex_buffer.resize(num_vertices * sizeof(ror::Vector3f)); indicies.resize(num_indices); par_octasphere_mesh mesh{};// = { mesh.positions = reinterpret_cast<float32_t *>(vertex_buffer.data()); mesh.normals = nullptr; // Don't want normals mesh.texcoords = nullptr; // Don't want uvs mesh.indices = indicies.data(); // mesh.num_indices = num_indices; // mesh.num_vertices = num_vertices; //}; // Generate vertex coordinates, ignoring normals, uv, and triangle indices. par_octasphere_populate(&cfg, &mesh); a_vertex_buffer.reserve(num_indices); for (uint32_t i = 0; i < num_indices; ++i) a_vertex_buffer.emplace_back(vertex_buffer[indicies[i]]); } static void shape_to_buffer(std::vector<ror::Vector3f> &a_vertex_buffer, const ror::Matrix4f &a_transform, par_shapes_mesh *a_shape) { a_vertex_buffer.reserve(a_vertex_buffer.size() + (static_cast<size_t>(a_shape->ntriangles) * 3)); for (int32_t i = 0; i < a_shape->ntriangles; ++i) { auto *ptr = a_shape->points; auto *ts = a_shape->triangles; auto ti = 3 * i; for (int32_t j = 0; j < 3; ++j) { auto vid = ts[ti + j]; auto point = ror::Vector3f{ptr[vid * 3 + 0], ptr[vid * 3 + 1], ptr[vid * 3 + 2]}; point = a_transform * point; a_vertex_buffer.emplace_back(point); } } } void make_cylinder_triangles(std::vector<ror::Vector3f> &a_vertex_buffer, int32_t a_slices, int32_t a_stackes) { auto *shape = par_shapes_create_cylinder(a_slices, a_stackes); // Make the cylinder in roar y-axis and unit diameter auto xform = ror::matrix4_rotation_around_x(ror::to_radians(-90.0f)) * ror::matrix4_scaling(0.5f, 0.5f, 1.0f); shape_to_buffer(a_vertex_buffer, xform, shape); delete shape; } void make_cone_triangles(std::vector<ror::Vector3f> &a_vertex_buffer, int32_t a_slices, int32_t a_stackes) { auto *shape = par_shapes_create_cone(a_slices, a_stackes); // Make the cylinder in roar y-axis and unit diameter auto xform = ror::matrix4_rotation_around_x(ror::to_radians(-90.0f)) * ror::matrix4_scaling(0.5f, 0.5f, 1.0f); shape_to_buffer(a_vertex_buffer, xform, shape); delete shape; } void make_tetrahedron_triangles(std::vector<ror::Vector3f> &a_vertex_buffer) { auto *shape = par_shapes_create_tetrahedron(); shape_to_buffer(a_vertex_buffer, ror::Matrix4f{}, shape); delete shape; } void make_hemisphere_triangles(std::vector<ror::Vector3f> &a_vertex_buffer, int32_t a_slices, int32_t a_stackes) { auto *shape = par_shapes_create_hemisphere(a_slices, a_stackes); shape_to_buffer(a_vertex_buffer, ror::Matrix4f{}, shape); delete shape; } void make_disk_triangles(std::vector<ror::Vector3f> &a_vertex_buffer, ror::Vector3f a_center, ror::Vector3f a_normal, float32_t a_radius, int32_t a_slices) { // radius, slices, center, normal auto *shape = par_shapes_create_disk(a_radius, a_slices, reinterpret_cast<float32_t *>(&a_center.x), reinterpret_cast<float32_t *>(&a_normal.x)); shape_to_buffer(a_vertex_buffer, ror::Matrix4f{}, shape); delete shape; } template <class _type, class _index_type> void make_sphere_triangles(std::vector<ror::Vector3<_type>> &a_vertex_buffer, std::vector<ror::Vector3<_index_type>> &a_index_buffer, uint32_t a_samples) // 50 samples are enough for normal use { // Sphere motivations // https://stackoverflow.com/a/26127012 for Fibonacci sphere // And convex hull solution from convhull_3d https://github.com/leomccormack/convhull_3d _type offset = static_cast<_type>(2.0f) / static_cast<_type>(a_samples); _type increment = ror_pi * (static_cast<_type>(3.0f) - std::sqrt(static_cast<_type>(5.0f))); ch_vertex *vertices = new ch_vertex[a_samples]; for (uint32_t sample = 0; sample < a_samples; ++sample) { _type u = static_cast<_type>(sample); _type y = ((u * offset) - static_cast<_type>(1.0f)) + (offset / static_cast<_type>(2.0f)); _type r = std::sqrt(static_cast<_type>(1.0f) - std::pow(y, static_cast<_type>(2.0f))); _type phi = static_cast<_type>((sample) % a_samples) * increment; _type x = std::cos(phi) * r; _type z = std::sin(phi) * r; vertices[sample].x = x; vertices[sample].y = y; vertices[sample].z = z; // Save my vertices a_vertex_buffer.emplace_back(ror::Vector3<_type>(x, y, z)); } int32_t *face_indices = nullptr; int32_t face_count; convhull_3d_build(vertices, static_cast<int32_t>(a_samples), &face_indices, &face_count); for (int32_t i = 0; i < face_count * 3; i += 3) { // Save my indices a_index_buffer.emplace_back(ror::Vector3<_index_type>( static_cast<uint32_t>(face_indices[i]), static_cast<uint32_t>(face_indices[i + 1]), static_cast<uint32_t>(face_indices[i + 2]))); } delete[] vertices; delete[] face_indices; } void create_arrow(std::vector<ror::Vector3f> &arrow_triangles_data, ror::Vector3f a_scale) { std::vector<ror::Vector3f> cylinder_triangles_data{}; std::vector<ror::Vector3f> cone_triangles_data{}; std::vector<ror::Vector3f> disk_triangles_data{}; make_cylinder_triangles(cylinder_triangles_data); make_cone_triangles(cone_triangles_data); make_disk_triangles(disk_triangles_data, ror::Vector3f{}, ror::Vector3f{0.0, -1.0, 0.0}); auto smat = ror::matrix4_scaling(0.01f * a_scale.x, 0.5f * a_scale.y, 0.01f * a_scale.z); auto smat2 = ror::matrix4_scaling(0.03f * a_scale.x, 0.04f * a_scale.y, 0.03f * a_scale.z); auto smat3 = ror::matrix4_scaling(0.015f * a_scale.x, 0.04f * a_scale.y, 0.015f * a_scale.z); auto tmat = ror::matrix4_translation(0.0f * a_scale.x, 0.5f * a_scale.y, 0.0f * a_scale.z); auto rmat = ror::matrix4_rotation_around_y(ror::to_radians(18.0f)); arrow_triangles_data.reserve(cylinder_triangles_data.size() + cone_triangles_data.size() + disk_triangles_data.size()); // Lets make an arrow from the three objects, cylinder, cone and disk for (auto &p : cylinder_triangles_data) arrow_triangles_data.emplace_back(smat * p); for (auto &p : cone_triangles_data) arrow_triangles_data.emplace_back(tmat * smat2 * p); for (auto &p : disk_triangles_data) arrow_triangles_data.emplace_back(tmat * rmat * smat3 * p); } void create_axis(std::vector<std::vector<float32_t>> &debug_data, std::vector<rhi::PrimitiveTopology> &topology_data) { std::vector<float32_t> points_colors{}; auto add_point = [&points_colors](ror::Vector3f &point, ror::Vector4f &color, ror::Matrix4f xform) { auto xpoint = xform * point; points_colors.push_back(xpoint.x); points_colors.push_back(xpoint.y); points_colors.push_back(xpoint.z); points_colors.push_back(0.0f); points_colors.push_back(color.x); points_colors.push_back(color.y); points_colors.push_back(color.z); points_colors.push_back(color.w); }; std::vector<ror::Vector3f> arrow_triangles_data{}; create_arrow(arrow_triangles_data, ror::Vector3f{1.0f}); float32_t color_intensity = 1.0f; float32_t color_fade = 0.2f; auto redcolor_p = ror::Vector4f{color_intensity, color_fade, color_fade, 1.0f}; auto redcolor_n = redcolor_p * ror::Vector4f(color_fade, color_fade, color_fade, 1.0); auto greencolor_p = ror::Vector4f{color_fade, color_intensity, color_fade, 1.0f}; auto greencolor_n = greencolor_p * ror::Vector4f(color_fade, color_fade, color_fade, 1.0); auto bluecolor_p = ror::Vector4f{color_fade, color_fade, color_intensity, 1.0f}; auto bluecolor_n = bluecolor_p * ror::Vector4f(color_fade, color_fade, color_fade, 1.0); // +X for (auto &p : arrow_triangles_data) add_point(p, redcolor_p, ror::matrix4_rotation_around_z(ror::to_radians(-90.0f))); // -X for (auto &p : arrow_triangles_data) add_point(p, redcolor_n, ror::matrix4_rotation_around_z(ror::to_radians(90.0f))); // +Y for (auto &p : arrow_triangles_data) add_point(p, greencolor_p, {}); // -Y for (auto &p : arrow_triangles_data) add_point(p, greencolor_n, ror::matrix4_rotation_around_x(ror::to_radians(180.0f))); // +Z for (auto &p : arrow_triangles_data) add_point(p, bluecolor_p, ror::matrix4_rotation_around_x(ror::to_radians(90.0f))); // -Z for (auto &p : arrow_triangles_data) add_point(p, bluecolor_n, ror::matrix4_rotation_around_x(ror::to_radians(-90.0f))); debug_data.emplace_back(points_colors); topology_data.emplace_back(rhi::PrimitiveTopology::triangles); } template <class _type> FORCE_INLINE void make_sphere_triangles(uint32_t a_samples) { (void) a_samples; } template <class _type> FORCE_INLINE void add_normals(const std::vector<_type> &a_vertex_buffer, uint32_t a_size, std::vector<_type> &a_output, const std::vector<_type> *a_index_buffer) { (void) a_vertex_buffer; (void) a_size; (void) a_output; (void) a_index_buffer; } template <class _type> FORCE_INLINE void add_colors(const std::vector<_type> &a_vertex_buffer, uint32_t a_size, std::vector<_type> &a_output, const std::vector<_type> *a_index_buffer) { (void) a_vertex_buffer; (void) a_size; (void) a_output; (void) a_index_buffer; } } // namespace ror
[ "abbas.wasim@gmail.com" ]
abbas.wasim@gmail.com
c847dc569a23cc599b62ab729489aad3f23e7667
05baad95ec62a79a245c32b6a6b30fb3f93eb9cd
/search/search_quality/assessment_tool/result_view.hpp
fd57c9419d9fc7e81ff1fb497a9cb7b44faf4022
[ "Apache-2.0" ]
permissive
DenisJu/omim
1a9faad6b2b912b48a94fe9b9cafb56c669284bd
298e7a55d8545fb0b2020137e102f80cacbcb6fa
refs/heads/master
2021-01-22T22:44:22.582797
2017-03-22T15:18:31
2017-03-22T15:18:31
85,833,359
0
0
null
2017-03-22T13:51:11
2017-03-22T13:51:11
null
UTF-8
C++
false
false
623
hpp
#pragma once #include "search/search_quality/sample.hpp" #include <QtWidgets/QWidget> class QLabel; class QRadioButton; namespace search { class Result; } class ResultView : public QWidget { public: ResultView(search::Result const & result, QWidget & parent); void SetRelevance(search::Sample::Result::Relevance relevance); private: void Init(); void SetContents(search::Result const & result); QLabel * m_string = nullptr; QLabel * m_type = nullptr; QLabel * m_address = nullptr; QRadioButton * m_irrelevant = nullptr; QRadioButton * m_relevant = nullptr; QRadioButton * m_vital = nullptr; };
[ "y@maps.me" ]
y@maps.me
6802fdc601e916f709ad5c8130b2bbafe68a8d5f
5350528f269892758a014a3235d93532b9a2b801
/3rd/ios/include/luabind/out_value_policy.hpp
1fa224196853488006537c835415c711b072a2bd
[]
no_license
shwetak16/Pocker-1
ff3c035024ef19a74215af000169c8edbdf843bc
bc7fafaa1e1420f238f2ac67732dad55bbcee1e3
refs/heads/master
2020-07-01T20:53:13.440269
2019-08-08T18:39:46
2019-08-08T18:39:46
201,297,346
0
0
null
2019-08-08T16:32:02
2019-08-08T16:32:01
null
UTF-8
C++
false
false
10,986
hpp
// Copyright (c) 2003 Daniel Wallin and Arvid Norberg // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE // OR OTHER DEALINGS IN THE SOFTWARE. #ifndef LUABIND_OUT_VALUE_POLICY_HPP_INCLUDED #define LUABIND_OUT_VALUE_POLICY_HPP_INCLUDED #include <luabind/config.hpp> #include <luabind/detail/policy.hpp> // for find_conversion_policy, etc #include <luabind/detail/decorate_type.hpp> // for LUABIND_DECORATE_TYPE #include <luabind/detail/primitives.hpp> // for by_pointer, by_reference, etc #include <luabind/detail/typetraits.hpp> // for is_nonconst_pointer, is_nonconst_reference, etc #include <boost/mpl/apply_wrap.hpp> // for apply_wrap2 #include <boost/mpl/if.hpp> // for if_ #include <boost/mpl/or.hpp> // for or_ #include <boost/type_traits/is_same.hpp> // for is_same #include <new> // for operator new namespace luabind { namespace detail { template<int N> struct char_array { char storage[N]; }; #if defined(__GNUC__) && ( __GNUC__ == 3 && __GNUC_MINOR__ == 1 ) template<class U> char_array<sizeof(U)> indirect_sizeof_test(by_reference<U>); template<class U> char_array<sizeof(U)> indirect_sizeof_test(by_const_reference<U>); template<class U> char_array<sizeof(U)> indirect_sizeof_test(by_pointer<U>); template<class U> char_array<sizeof(U)> indirect_sizeof_test(by_const_pointer<U>); template<class U> char_array<sizeof(U)> indirect_sizeof_test(by_value<U>); #else template<class U> char_array<sizeof(typename identity<U>::type)> indirect_sizeof_test(by_reference<U>); template<class U> char_array<sizeof(typename identity<U>::type)> indirect_sizeof_test(by_const_reference<U>); template<class U> char_array<sizeof(typename identity<U>::type)> indirect_sizeof_test(by_pointer<U>); template<class U> char_array<sizeof(typename identity<U>::type)> indirect_sizeof_test(by_const_pointer<U>); template<class U> char_array<sizeof(typename identity<U>::type)> indirect_sizeof_test(by_value<U>); #endif template<class T> struct indirect_sizeof { BOOST_STATIC_CONSTANT(int, value = sizeof(indirect_sizeof_test(LUABIND_DECORATE_TYPE(T)))); }; namespace mpl = boost::mpl; template<int Size, class Policies = detail::null_type> struct out_value_converter { int consumed_args(...) const { return 1; } template<class T> T& apply(lua_State* L, by_reference<T>, int index) { typedef typename find_conversion_policy<1, Policies>::type converter_policy; typename mpl::apply_wrap2<converter_policy,T,lua_to_cpp>::type converter; #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); new (storage) T(converter.apply(L, LUABIND_DECORATE_TYPE(T), index)); return *storage; #else new (m_storage) T(converter.apply(L, LUABIND_DECORATE_TYPE(T), index)); return *reinterpret_cast<T*>(m_storage); #endif } template<class T> static int match(lua_State* L, by_reference<T>, int index) { typedef typename find_conversion_policy<1, Policies>::type converter_policy; typedef typename mpl::apply_wrap2<converter_policy,T,lua_to_cpp>::type converter; return converter::match(L, LUABIND_DECORATE_TYPE(T), index); } template<class T> void converter_postcall(lua_State* L, by_reference<T>, int) { typedef typename find_conversion_policy<2, Policies>::type converter_policy; typename mpl::apply_wrap2<converter_policy,T,cpp_to_lua>::type converter; #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); converter.apply(L, *storage); storage->~T(); #else converter.apply(L, *reinterpret_cast<T*>(m_storage)); reinterpret_cast<T*>(m_storage)->~T(); #endif } template<class T> T* apply(lua_State* L, by_pointer<T>, int index) { typedef typename find_conversion_policy<1, Policies>::type converter_policy; typename mpl::apply_wrap2<converter_policy,T,lua_to_cpp>::type converter; #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); new (storage) T(converter.apply(L, LUABIND_DECORATE_TYPE(T), index)); return storage; #else new (m_storage) T(converter.apply(L, LUABIND_DECORATE_TYPE(T), index)); return reinterpret_cast<T*>(m_storage); #endif } template<class T> static int match(lua_State* L, by_pointer<T>, int index) { typedef typename find_conversion_policy<1, Policies>::type converter_policy; typedef typename mpl::apply_wrap2<converter_policy,T,lua_to_cpp>::type converter; return converter::match(L, LUABIND_DECORATE_TYPE(T), index); } template<class T> void converter_postcall(lua_State* L, by_pointer<T>, int) { typedef typename find_conversion_policy<2, Policies>::type converter_policy; typename mpl::apply_wrap2<converter_policy,T,cpp_to_lua>::type converter; #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); converter.apply(L, *storage); storage->~T(); #else converter.apply(L, *reinterpret_cast<T*>(m_storage)); reinterpret_cast<T*>(m_storage)->~T(); #endif } char m_storage[Size]; }; template<int N, class Policies = detail::null_type> struct out_value_policy : conversion_policy<N> { static void precall(lua_State*, const index_map&) {} static void postcall(lua_State*, const index_map&) {} struct only_accepts_nonconst_references_or_pointers {}; struct can_only_convert_from_lua_to_cpp {}; template<class T, class Direction> struct apply { typedef typename boost::mpl::if_<boost::is_same<lua_to_cpp, Direction> , typename boost::mpl::if_<boost::mpl::or_<is_nonconst_reference<T>, is_nonconst_pointer<T> > , out_value_converter<indirect_sizeof<T>::value, Policies> , only_accepts_nonconst_references_or_pointers >::type , can_only_convert_from_lua_to_cpp >::type type; }; }; template<int Size, class Policies = detail::null_type> struct pure_out_value_converter { int consumed_args(...) const { return 0; } template<class T> T& apply(lua_State*, by_reference<T>, int) { #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); new (storage) T(); return *storage; #else new (m_storage) T(); return *reinterpret_cast<T*>(m_storage); #endif } template<class T> static int match(lua_State*, by_reference<T>, int) { return 0; } template<class T> void converter_postcall(lua_State* L, by_reference<T>, int) { typedef typename find_conversion_policy<1, Policies>::type converter_policy; typename mpl::apply_wrap2<converter_policy,T,cpp_to_lua>::type converter; #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); converter.apply(L, *storage); storage->~T(); #else converter.apply(L, *reinterpret_cast<T*>(m_storage)); reinterpret_cast<T*>(m_storage)->~T(); #endif } template<class T> T* apply(lua_State*, by_pointer<T>, int) { #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); new (storage) T(); return storage; #else new (m_storage) T(); return reinterpret_cast<T*>(m_storage); #endif } template<class T> static int match(lua_State*, by_pointer<T>, int) { return 0; } template<class T> void converter_postcall(lua_State* L, by_pointer<T>, int) { typedef typename find_conversion_policy<1, Policies>::type converter_policy; typename mpl::apply_wrap2<converter_policy,T,cpp_to_lua>::type converter; #if defined(__GNUC__) && __GNUC__ >= 4 T* storage = reinterpret_cast<T*>(m_storage); converter.apply(L, *storage); storage->~T(); #else converter.apply(L, *reinterpret_cast<T*>(m_storage)); reinterpret_cast<T*>(m_storage)->~T(); #endif } char m_storage[Size]; }; template<int N, class Policies = detail::null_type> struct pure_out_value_policy : conversion_policy<N, false> { static void precall(lua_State*, const index_map&) {} static void postcall(lua_State*, const index_map&) {} struct only_accepts_nonconst_references_or_pointers {}; struct can_only_convert_from_lua_to_cpp {}; template<class T, class Direction> struct apply { typedef typename boost::mpl::if_<boost::is_same<lua_to_cpp, Direction> , typename boost::mpl::if_<boost::mpl::or_<is_nonconst_reference<T>, is_nonconst_pointer<T> > , pure_out_value_converter<indirect_sizeof<T>::value, Policies> , only_accepts_nonconst_references_or_pointers >::type , can_only_convert_from_lua_to_cpp >::type type; }; }; }} namespace luabind { template<int N> detail::policy_cons<detail::out_value_policy<N>, detail::null_type> out_value(LUABIND_PLACEHOLDER_ARG(N)) { return detail::policy_cons<detail::out_value_policy<N>, detail::null_type>(); } template<int N, class Policies> detail::policy_cons<detail::out_value_policy<N, Policies>, detail::null_type> out_value(LUABIND_PLACEHOLDER_ARG(N), const Policies&) { return detail::policy_cons<detail::out_value_policy<N, Policies>, detail::null_type>(); } template<int N> detail::policy_cons<detail::pure_out_value_policy<N>, detail::null_type> pure_out_value(LUABIND_PLACEHOLDER_ARG(N)) { return detail::policy_cons<detail::pure_out_value_policy<N>, detail::null_type>(); } template<int N, class Policies> detail::policy_cons<detail::pure_out_value_policy<N, Policies>, detail::null_type> pure_out_value(LUABIND_PLACEHOLDER_ARG(N), const Policies&) { return detail::policy_cons<detail::pure_out_value_policy<N, Policies>, detail::null_type>(); } } #endif // LUABIND_OUT_VALUE_POLICY_HPP_INCLUDED
[ "panyumiao@panyumiaodeMacBook-Pro.local" ]
panyumiao@panyumiaodeMacBook-Pro.local
4ee50c87ee8ec7895e67d11ca911631e6f978e52
57bd1ec74aa1dad53d7431cd613ffcf7e6cfe2ab
/cpp/libs/include/openpal/executor/ITimer.h
af346d0466590029aba5658fd578d862cf0c326e
[ "BSD-3-Clause" ]
permissive
emgre/openpal
bb280673f3c36215599749bba61365790c2c33e3
4ec9c0926c7a80eb9868dcb9c6e8db002bf94255
refs/heads/master
2021-05-06T05:48:24.562838
2017-06-21T15:06:22
2017-06-21T15:06:22
115,162,022
0
0
null
2017-12-23T01:23:12
2017-12-23T01:23:12
null
UTF-8
C++
false
false
1,896
h
/* * Copyright (c) 2016, Automatak LLC * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following * disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote * products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef OPENPAL_ITIMER_H #define OPENPAL_ITIMER_H #include "Timestamp.h" namespace openpal { /** * Timer are used to defer events for a later time on an executor. */ class ITimer { public: virtual ~ITimer() {} virtual void cancel() = 0; virtual Timestamp expires_at() = 0; }; } #endif
[ "jadamcrain@gmail.com" ]
jadamcrain@gmail.com
2baf7d68c1a07de0442e96ea2a1af7fdf0991319
086343324bd50b2922daf9a4299b9b0de98e6a94
/Client Lourd/Commun/Utilitaire/Modele/OpenGL_Storage/ModeleStorage_CPU_Local.h
e54c4cd7268257a58874679444ddfa5eb8cc8dce
[]
no_license
Bodheem/ProjetIntegrateur3
c23e0ebf56b09733951f4195b99bd48673aa6f48
080179d68465d6be0002e201b114e27065129241
refs/heads/master
2021-01-20T14:04:53.018994
2017-02-22T04:04:00
2017-02-22T04:04:00
82,735,194
0
0
null
null
null
null
ISO-8859-1
C++
false
false
2,090
h
/////////////////////////////////////////////////////////////////////////////// /// @file ModeleStorage_CPU_Local.h /// @author Martin Paradis /// @date 2014-08-16 /// @version 1.0 /// /// @addtogroup modele Modele /// @{ /////////////////////////////////////////////////////////////////////////////// #ifndef __MODELESTORAGE_CPU_LOCAL_H__ #define __MODELESTORAGE_CPU_LOCAL_H__ #include "ModeleStorageRendu.h" namespace modele{ class Modele3D; class Noeud; struct Materiau; namespace opengl_storage{ /////////////////////////////////////////////////////////////////////////// /// @class CPU_Local /// @brief Classe permettant le dessin d'un modèle 3D sans aucun storage /// de données ou de commandes sur la carte graphique. /// /// @note Précondition : prends pour acquis que le pointeur vers le modèle /// 3D reste valide durant toute la durée de vie du storage. /// /// @author Martin Paradis /// @date 2014-08-16 /////////////////////////////////////////////////////////////////////////// class CPU_Local : public ModeleStorageRendu{ public: CPU_Local() = default; /// Constructeur avec un modèle 3D CPU_Local(Modele3D const* modele); /// Destructeur virtual ~CPU_Local() = default; /// Permet de charger les données/commandes sur la carte graphique virtual void storageCharger() override; /// Permet d'effectuer le dessin du modèle 3D virtual void dessiner() const override; /// Permet de relâcher les données/commandes sur la crate graphique virtual void storageRelacher() override; private: /// Modèle à dessiner modele::Modele3D const* modele_{ nullptr }; /// Dessin récursif du modèle 3D void dessiner(modele::Noeud const& noeud) const; /// Assigne le matériau pour une face quelconque void appliquerMateriau(modele::Materiau const& materiau) const; }; } } #endif /// __MODELESTORAGE_CPU_LOCAL_H__ /////////////////////////////////////////////////////////////////////////////// /// @} ///////////////////////////////////////////////////////////////////////////////
[ "nikolayradoev@gmail.com" ]
nikolayradoev@gmail.com
7fcf24ae19f34c005f14fefa0613d2fb6223fe70
3a822381dcd160cac16e9560748481e9d9234129
/sketch_nov22a/sketch_nov22a.ino
26d3d0ed20f9f8c6cb39c9403d88fe0c74377a33
[]
no_license
datphanhuu99/arduino1
5aa21afe2f2c537628fd79bca3eed2bc75f094ce
32a9aa6721a20f49608abf634f02b47cf8ee33e7
refs/heads/master
2020-07-29T20:26:19.275526
2019-09-21T08:28:23
2019-09-21T08:28:23
209,948,340
0
0
null
null
null
null
UTF-8
C++
false
false
1,580
ino
#include <Servo.h> Servo myservo; #define sbi(PORT,bit) {PORT |=(1<<bit);} #define cbi(PORT,bit) {PORT &=~(1<<bit);} #define tbi(PORT,bit) {PORT ^= (1<<bit);} int servoPin = B1 ; //Chan dieu khien servo void control(int a, int b, int c, int d); void setup() { pinMode(A0,INPUT); pinMode(A1,INPUT); pinMode(A2,INPUT); pinMode(A3,INPUT); myservo.attach(servoPin); DDRB=0xff; Serial.begin(115200); } void loop() { PORTB=0x00; int x = analogRead(A0); //doc gia tri a0 gan vao x int y= analogRead(A1); //doc gia tri a1 gan vao y int z=analogRead(A2); //doc gia tri a2 gan vao z int t=analogRead(A3); //doc gia tri a3 gan vao t control(x,y,z,t); } void control(int a, int b, int c, int d) { int n=0; //gan lai gia tri ban dau cho n if(a>40||b>40||c>40||d>40) //dieu kien vao vong lap { for(int i=0;i<500;i++) //kiem tra tin hieu nhieu { int a= analogRead(A0); //doc gia tri a0 gan vao a int b= analogRead(A1); //doc gia tri a1 gan vao b int c= analogRead(A2); //doc gia tri a2 gan vao c int d= analogRead(A3); //doc gia tri a3 gan vao d if(a>40) //dieu kien tang n n++; if(b>40) //dieu kien tang n n++; if(c>40) //dieu kien tang n n++; if(d>40) //dieu kien tang n n++; if (n>10) //dieu kien de thuc hien lenh { sbi(DDRB,2); sbi(DDRB,0); int servoPos = map(90, 0, 1023, 0, 180); myservo.attach(servoPin); } } sbi(DDRB,0); cbi(DDRB,2); } }
[ "datphanhuu99@gmail.com" ]
datphanhuu99@gmail.com
b1b6dd39d5d7a77bc45532758af5c9b0c46c6ba9
7c33dda3710041185e1427118fb4d052141112ed
/p11800.cpp
3106252bcc72fa95385e2c43146cdd7d908e5e94
[]
no_license
AlexandreBellas/UVa-Online-Judge
97c586bf64594a19e96cc8a16bf06ce81ff25d5f
1ffc07ad64f5d5e45a9855dadf1b3781a250619c
refs/heads/master
2021-08-07T19:16:12.853076
2017-11-08T20:33:16
2017-11-08T20:33:16
109,752,595
0
0
null
null
null
null
UTF-8
C++
false
false
2,313
cpp
#include <bits/stdc++.h> using namespace std; #define PI acos(-1.0) #define EPS 1e-6 struct Point{ int x, y; Point(){} Point(int a, int b) { x = a; y = b; } double norma() { return sqrt(x*x + y*y); } Point operator + (Point v) { return Point(v.x + x, v.y + y); } Point operator - (Point v) { return Point(x - v.x, y - v.y); } double operator * (Point v) { return x * v.x + y * v.y; } }; Point p[4]; double det(Point a, Point b) { return a.x * b.y - b.x * a.y; } double dpp(Point a, Point b){ //cout << "passoudpp" << endl; return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y)); } int cmp(Point a, Point b) { Point P = a - p[0]; Point Q = b - p[0]; return (Point(1, 0) * P)/P.norma() < (Point(1, 0) * Q)/Q.norma(); // quanto maior o produto escalar, menor será o ângulo, pois o produto escalar da a norma da projeção desse vetor na horizontal } string resposta(){ Point a = p[1] - p[0]; Point b = p[2] - p[1]; Point c = p[3] - p[2]; Point d = p[0] - p[3]; if(a.norma() == b.norma() && b.norma() == c.norma() && c.norma() == d.norma()){ if(a*b == 0 && b*c == 0 && c*d == 0 && d*a == 0) return "Square"; else return "Rhombus"; } else{ if(a*b == 0 && b*c == 0 && c*d == 0 && d*a == 0) return "Rectangle"; if(det(a,c) == 0 && det(b,d) == 0) return "Parallelogram"; else if(det(a,c) == 0 || det(b,d) == 0) return "Trapezium"; else return "Ordinary Quadrilateral"; } } int main(){ int T; int i; cin >> T; int cont = 1; while(T--){ int j = 0; for(int i = 0; i < 4; ++i) { int x, y; cin >> x >> y; if((y == p[j].y and x < p[j].x) or y < p[j].y) j = i; p[i] = Point(x, y); } swap(p[0], p[j]); sort(p + 1, p + 4, cmp); p[4] = p[0]; /*cout << "Pontos ordenados" << endl; for(int i = 0; i < 4; i++){ cout << p[i].x << " " << p[i].y << endl; } cout << endl; */ string resp; resp = resposta(); cout << "Case " << cont << ": " << resp << endl; cont++; // if(T != 0) // cout << endl; } return 0; }
[ "alexandre.bellas@usp.br" ]
alexandre.bellas@usp.br
f039da568e7b4ac01d8bc5dd3a374561e3f4e1d6
860b9349bdfa31224653d12bcb78656365bf4853
/core/src/tij/tijmonitor.cpp
d45fd972ef09d2a15168e9e8f465b9b66e8dc622
[]
no_license
iserramacsa/mcomms
27bcdf136f095a3ab92af6302be45ea673b615fa
d092110025d19464fc359318159678292b812a95
refs/heads/master
2022-11-16T01:33:37.937927
2020-04-20T17:24:25
2020-04-20T17:24:25
210,377,193
0
0
null
null
null
null
UTF-8
C++
false
false
3,378
cpp
#include "tij/tijmonitor.h" #include "mprotocol/mprotocol.h" #include "mprotocol/mfiles.h" using namespace Macsa; using namespace Macsa::MComms; using namespace Macsa::Network; TijMonitor::TijMonitor(const std::string &id, const std::string &address) : TijController(id, address) { _running.store(false); _maxReconnections = 30; _reconnections = 0; } TijMonitor::~TijMonitor() { stop(); } bool TijMonitor::connect() { bool connected = PrinterController::connect(); if (connected) { start(); } return connected; } bool TijMonitor::disconnect() { bool disconnected = PrinterController::disconnect(); if (NetworkNode::status() == DISCONNECTED) { stop(); } return disconnected; } #include <iostream> void TijMonitor::run() { _running.store(true); while (_running.load() && _reconnections < _maxReconnections) { { std::unique_lock<std::mutex> _lck(_mLoop); if (_cv.wait_for(_lck, std::chrono::seconds(1)) == std::cv_status::timeout) { const std::lock_guard<std::mutex>lock(_mCommands); _commands.push_back(_factory.getLiveCommand()); } else if (_running.load() == false){ break; } } while (_commands.size()) { MProtocol::MCommand* cmd = nullptr; { const std::lock_guard<std::mutex>lock(_mCommands); cmd = (*_commands.begin()); } if (cmd){ sendCmd(cmd); } { const std::lock_guard<std::mutex>lock(_mCommands); _commands.pop_front(); } } if (isStatusChanged()) { TijController::updateStatus(); } if (isConfigChanged()) { TijController::updateConfig(); } if (isFilesChanged()) { TijController::updateFilesList(); } if (isFontsChanged()) { TijController::updateFontsList(); } if (isUserValuesChanged()){ TijController::updateUserValues(); } if (isErrorsLogsChanged()) { TijController::updateErrorsList(); } } _reconnections = 0; } bool TijMonitor::send(XMLCommand *cmd) { ulong numCommands = _commands.size(); { const std::lock_guard<std::mutex>lock(_mCommands); _commands.push_back(dynamic_cast<MProtocol::MCommand*>(cmd)); } { std::unique_lock<std::mutex> _lck(_mLoop); _cv.notify_one(); } return ((_commands.size() - numCommands) > 0); } bool TijMonitor::sendCmd(MProtocol::MCommand *cmd) { bool success = false; success = TijController::send(cmd); if (!success) { std::cout << __FUNCTION__ << " Send command " << cmd->commandName() << " failed" << std::endl; std::cout << " reason: " << std::flush; switch (_lastSentStatus) { case nFrameStatus::FRAME_TIMEOUT: std::cout << "FRAME_TIMEOUT" << std::endl; _reconnections++; break; case nFrameStatus::FRAME_INCOMPLETED: std::cout << "FRAME_INCOMPLETED" << std::endl; break; case nFrameStatus::FRAME_ERROR: std::cout << "FRAME_ERROR" << std::endl; _reconnections++; break; default: break; } PrinterController::reconnect(); } else { _reconnections = 0; } return success; } int TijMonitor::maxReconnections() const { return _maxReconnections; } void TijMonitor::setMaxReconnections(int maxReconnections) { _maxReconnections = maxReconnections; } void TijMonitor::start() { if (_running.load()) { stop(); } _th = std::thread(&TijMonitor::run, this); } void TijMonitor::stop() { if (_running.load()){ _running.store(false); { std::unique_lock<std::mutex> _lck(_mLoop); _cv.notify_all(); } _th.join(); } }
[ "i.serra@macsa.es" ]
i.serra@macsa.es
e64435bd3f79c61e947eb9007366ef1fb498ed02
c95c67818f89ace2d75133fc4a87b877363dcff8
/include/wheels/meta.h++
85b9de72f92c40a432fefc4be70e458cdbf95faf
[ "CC0-1.0" ]
permissive
rmartinho/wheels
9ffde06eac69c7be0588a00c6a81fbbf4da220cf
a49e790dbc277335907b393ebaddea947ae14d0e
refs/heads/stable
2021-01-17T08:44:16.859499
2016-05-08T13:33:29
2016-05-08T13:33:29
10,555,595
24
10
null
2015-04-06T09:25:32
2013-06-07T17:48:55
C++
UTF-8
C++
false
false
2,433
// Wheels - various C++ utilities // // Written in 2013 by Martinho Fernandes <martinho.fernandes@gmail.com> // // To the extent possible under law, the author(s) have dedicated all copyright and related // and neighboring rights to this software to the public domain worldwide. This software is // distributed without any warranty. // // You should have received a copy of the CC0 Public Domain Dedication along with this software. // If not, see <http://creativecommons.org/publicdomain/zero/1.0/> // Meta-programming facilities #ifndef WHEELS_META_HPP #define WHEELS_META_HPP #include <wheels/meta/invoke.h++> #include <wheels/meta/id.h++> #include <wheels/meta/alias.h++> #include <wheels/meta/not_deducible.h++> #include <wheels/meta/constant.h++> #include <wheels/meta/int.h++> #include <wheels/meta/bool.h++> #include <wheels/meta/not.h++> #include <wheels/meta/any.h++> #include <wheels/meta/all.h++> #include <wheels/meta/void.h++> #include <wheels/meta/if.h++> #include <wheels/meta/invoke_if.h++> #include <wheels/meta/enable_if.h++> #include <wheels/meta/is_computable.h++> #include <wheels/meta/depend_on.h++> #include <wheels/meta/trait_of.h++> #include <wheels/meta/add_const.h++> #include <wheels/meta/remove_const.h++> #include <wheels/meta/add_volatile.h++> #include <wheels/meta/remove_volatile.h++> #include <wheels/meta/add_cv.h++> #include <wheels/meta/remove_cv.h++> #include <wheels/meta/add_lvalue_reference.h++> #include <wheels/meta/add_rvalue_reference.h++> #include <wheels/meta/remove_reference.h++> #include <wheels/meta/decay.h++> #include <wheels/meta/unqual.h++> #include <wheels/meta/is_unqual.h++> #include <wheels/meta/qualifying_value_category_of.h++> #include <wheels/meta/qualifying_const_of.h++> #include <wheels/meta/qualifying_volatile_of.h++> #include <wheels/meta/qualifying_cv_of.h++> #include <wheels/meta/qualifying.h++> #include <wheels/meta/add_pointer.h++> #include <wheels/meta/remove_pointer.h++> #include <wheels/meta/remove_extent.h++> #include <wheels/meta/remove_all_extents.h++> #include <wheels/meta/make_signed.h++> #include <wheels/meta/make_unsigned.h++> #include <wheels/meta/underlying_type.h++> #include <wheels/meta/common_type.h++> #include <wheels/meta/is_related.h++> #include <wheels/meta/is_deduced.h++> #include <wheels/meta/class_of.h++> #include <wheels/meta/member_of.h++> #include <wheels/meta/noexcept.h++> #endif // WHEELS_META_HPP
[ "martinho.fernandes@gmail.com" ]
martinho.fernandes@gmail.com
72cd5fb97153e5ed7ea3cb0748eea9a72ca76ee2
8955b19cf694818f57be0670762f8e5decbf4313
/include/twigs/serializable.h
20a59206400742134c346a5f5a684d63bad2b3c3
[]
no_license
wbrawner/libtwigs
09b77948ca2e748502eaae8851f7220162a43341
97e51e09249abb3028fdfab08eb41a08df27f77e
refs/heads/main
2023-05-10T20:24:08.581542
2021-01-29T14:14:34
2021-01-29T14:14:34
325,180,236
0
0
null
null
null
null
UTF-8
C++
false
false
145
h
#ifndef SERIALIZABLE_H #define SERIALIZABLE_H #include <string> class Serializable { public: virtual std::string serialize() = 0; }; #endif
[ "me@wbrawner.com" ]
me@wbrawner.com
c0d0a7a3ebe089b9285f7ff4d27d80145227fd88
4bea57e631734f8cb1c230f521fd523a63c1ff23
/projects/openfoam/rarefied-flows/impingment/sims/templates/wedge15Ma5/0.14/T
bffca57cf7a87fb601dbffd12c774433b2abf447
[]
no_license
andytorrestb/cfal
76217f77dd43474f6b0a7eb430887e8775b78d7f
730fb66a3070ccb3e0c52c03417e3b09140f3605
refs/heads/master
2023-07-04T01:22:01.990628
2021-08-01T15:36:17
2021-08-01T15:36:17
294,183,829
1
0
null
null
null
null
UTF-8
C++
false
false
36,457
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.14"; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 1 0 0 0]; internalField nonuniform List<scalar> 4800 ( 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.5847 13.6198 13.7075 13.6924 13.6799 13.6612 13.6463 13.647 13.6658 13.7081 13.7671 13.8324 13.8936 13.948 13.998 14.0453 14.09 14.134 14.1748 14.2065 14.2226 14.2376 14.2681 14.3362 14.425 14.4954 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.5771 13.6165 13.7069 13.6919 13.679 13.6598 13.6451 13.6461 13.666 13.7101 13.7701 13.834 13.8925 13.945 13.9946 14.0422 14.0869 14.1301 14.1697 14.2006 14.2182 14.2361 14.2704 14.3306 14.4148 14.4834 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.5607 13.6123 13.7053 13.6901 13.6764 13.6566 13.6426 13.645 13.6671 13.714 13.7746 13.8349 13.8892 13.9391 13.9887 14.0369 14.0814 14.1231 14.1608 14.1915 14.2134 14.2363 14.2738 14.3287 14.4075 14.472 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.5362 13.6068 13.7023 13.6868 13.6721 13.6518 13.6395 13.6437 13.6693 13.7197 13.7805 13.8362 13.8847 13.9312 13.9802 14.0286 14.0728 14.1128 14.149 14.1809 14.2108 14.2403 14.2829 14.3365 14.4063 14.4596 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.5034 13.5983 13.6985 13.6823 13.6662 13.6456 13.6359 13.6427 13.6726 13.7268 13.7874 13.8377 13.8795 13.9217 13.9691 14.017 14.0608 14.0996 14.136 14.1722 14.2112 14.2511 14.3006 14.3534 14.4129 14.4548 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.4623 13.5833 13.6945 13.6772 13.6596 13.6391 13.6325 13.6423 13.677 13.7346 13.7942 13.8391 13.8743 13.9112 13.9557 14.0023 14.0455 14.0846 14.1245 14.1682 14.2177 14.2704 14.3259 14.3753 14.4226 14.4514 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.4139 13.5586 13.6904 13.6725 13.6536 13.6333 13.6297 13.6426 13.6821 13.7425 13.8005 13.8402 13.869 13.9003 13.9407 13.9848 14.0277 14.0696 14.1176 14.1716 14.2335 14.2967 14.3533 14.3941 14.428 14.4452 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.3584 13.5245 13.6856 13.6679 13.6483 13.6284 13.6275 13.6438 13.6878 13.7498 13.8055 13.8408 13.8637 13.8894 13.9245 13.9653 14.0092 14.0579 14.1167 14.1842 14.2609 14.3268 14.3721 14.4054 14.4296 14.4399 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.2954 13.4852 13.6793 13.6624 13.6426 13.624 13.6254 13.6459 13.6936 13.7561 13.809 13.8404 13.8581 13.8786 13.908 13.9453 13.9925 14.0527 14.1248 14.2116 14.2935 14.3478 14.3817 14.4095 14.4284 14.4351 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.2252 13.4435 13.671 13.655 13.6356 13.6196 13.6239 13.6489 13.6995 13.7612 13.8105 13.8386 13.852 13.8676 13.8915 13.9273 13.9816 14.0542 14.1476 14.2465 14.3189 14.3586 14.3852 14.4084 14.424 14.4297 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.1481 13.3998 13.6607 13.6452 13.6266 13.6153 13.6233 13.6527 13.7054 13.7647 13.8107 13.835 13.8448 13.8562 13.8767 13.9153 13.9783 14.0689 14.181 14.2755 14.3346 14.3629 14.3844 14.4037 14.4173 14.4241 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11.0643 13.3536 13.6485 13.6333 13.6156 13.6113 13.6236 13.6576 13.711 13.7667 13.8089 13.8293 13.8361 13.8445 13.8666 13.9118 13.9875 14.1 14.2122 14.2932 14.3411 14.3637 14.3811 14.3972 14.4099 14.4181 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.9749 13.3048 13.6345 13.619 13.6038 13.6064 13.6248 13.6634 13.716 13.7671 13.8046 13.8215 13.8264 13.8347 13.8636 13.9194 14.0174 14.1345 14.2322 14.3005 14.342 14.3608 14.376 14.3908 14.4034 14.412 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.8801 13.2525 13.6177 13.6018 13.5928 13.6016 13.6277 13.6698 13.7197 13.7657 13.7978 13.8115 13.8162 13.8301 13.8701 13.9472 14.0581 14.1622 14.2422 14.3006 14.337 14.3538 14.3697 14.3857 14.3985 14.4065 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.7801 13.1955 13.5969 13.5816 13.5831 13.5994 13.6327 13.6762 13.722 13.7621 13.7884 13.8 13.8078 13.8314 13.8903 13.9894 14.0982 14.1816 14.2452 14.2946 14.3268 14.345 14.3634 14.3812 14.3945 14.4021 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.6762 13.1329 13.5715 13.563 13.5729 13.5991 13.6389 13.6825 13.7232 13.7565 13.7771 13.7881 13.8028 13.842 13.9269 14.0378 14.1315 14.1932 14.2434 14.2851 14.315 14.3349 14.3554 14.3751 14.3898 14.3982 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.5721 13.0636 13.5369 13.5461 13.5668 13.6014 13.6458 13.6882 13.7229 13.749 13.7649 13.7775 13.8037 13.8682 13.9761 14.0813 14.1545 14.2002 14.24 14.2754 14.3032 14.324 14.3458 14.3671 14.3838 14.3941 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.4714 12.9842 13.5 13.5312 13.5623 13.605 13.6527 13.6926 13.7207 13.7398 13.7528 13.7705 13.8144 13.9094 14.0268 14.115 14.1691 14.2045 14.2358 14.2666 14.2922 14.3127 14.3345 14.3571 14.3758 14.3888 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.3763 12.8917 13.4648 13.5172 13.5593 13.6095 13.6589 13.6944 13.7158 13.7294 13.7423 13.7703 13.8422 13.9605 14.0696 14.1394 14.1783 14.2075 14.2322 14.2591 14.2824 14.3014 14.3224 14.3456 14.3661 14.3819 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.278 12.8009 13.4302 13.5039 13.5584 13.6148 13.6638 13.6932 13.7083 13.719 13.7356 13.7824 13.8846 14.0101 14.1012 14.1557 14.1854 14.21 14.2302 14.2532 14.274 14.2906 14.31 14.3335 14.3557 14.3739 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.1724 12.7138 13.3989 13.4926 13.5596 13.6201 13.6663 13.6892 13.6989 13.7097 13.736 13.811 13.9363 14.0507 14.1217 14.1657 14.1913 14.2131 14.2302 14.2492 14.2667 14.2801 14.2978 14.3215 14.3449 14.3651 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0978 12.6171 13.3594 13.4803 13.5631 13.6251 13.6664 13.6825 13.6891 13.7031 13.7494 13.8546 13.9861 14.0796 14.1342 14.1725 14.1962 14.2162 14.2316 14.2476 14.2613 14.2709 14.2864 14.3095 14.3338 14.3559 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0705 12.5214 13.3118 13.463 13.5663 13.6288 13.6644 13.6741 13.6806 13.7024 13.7777 13.9079 14.0274 14.0985 14.1412 14.1763 14.1999 14.2191 14.2338 14.2474 14.2584 14.2642 14.2765 14.2979 14.3221 14.3457 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0593 12.4341 13.2609 13.4407 13.5668 13.6301 13.6596 13.6651 13.6741 13.7138 13.8211 13.9607 14.0571 14.109 14.1456 14.1783 14.2023 14.2217 14.2358 14.2477 14.2573 14.2607 14.2695 14.2874 14.3098 14.3341 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0543 12.3585 13.2076 13.4131 13.5642 13.6292 13.652 13.6569 13.6726 13.7409 13.8761 14.0067 14.0773 14.1133 14.1477 14.1793 14.2041 14.2239 14.2374 14.2483 14.2568 14.2598 14.2652 14.2787 14.2978 14.3212 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0521 12.2966 13.1534 13.3795 13.5575 13.626 13.6424 13.6491 13.6792 13.782 13.9322 14.0415 14.091 14.1164 14.1485 14.1792 14.2046 14.2254 14.239 14.2495 14.2578 14.2597 14.2628 14.272 14.2869 14.3079 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.051 12.2491 13.1012 13.3394 13.5453 13.6191 13.6321 13.6432 13.6997 13.835 13.9831 14.0654 14.1 14.1198 14.1489 14.1786 14.2041 14.2262 14.241 14.2517 14.2598 14.2603 14.2612 14.2674 14.2786 14.2958 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0503 12.2147 13.0547 13.2922 13.5258 13.6081 13.6223 13.6424 13.7332 13.892 14.0245 14.083 14.1061 14.1228 14.1493 14.1779 14.203 14.2261 14.2428 14.2541 14.2622 14.2612 14.2599 14.2645 14.2733 14.2864 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0495 12.191 13.0168 13.239 13.497 13.5937 13.6125 13.6517 13.7791 13.9453 14.0536 14.0954 14.1112 14.1264 14.1503 14.1773 14.2014 14.225 14.244 14.2561 14.2648 14.2629 14.2595 14.263 14.2707 14.2805 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0481 12.1747 12.9889 13.1829 13.4573 13.5769 13.6055 13.6744 13.8327 13.9916 14.0738 14.1033 14.1151 14.1297 14.1516 14.1773 14.2004 14.2236 14.2442 14.2574 14.2671 14.2661 14.2607 14.2626 14.2695 14.2772 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0461 12.1626 12.97 13.1284 13.4065 13.5565 13.6044 13.709 13.8854 14.0275 14.0891 14.1091 14.1184 14.1314 14.1524 14.1774 14.2003 14.2229 14.2439 14.2578 14.2682 14.2694 14.2633 14.2631 14.2689 14.2757 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0435 12.1527 12.9575 13.0797 13.3458 13.5306 13.6151 13.754 13.9309 14.0511 14.1007 14.1141 14.1216 14.1328 14.1529 14.1769 14.2 14.2229 14.2438 14.2579 14.2684 14.2714 14.2658 14.2637 14.2688 14.2751 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0406 12.1436 12.9495 13.0414 13.2793 13.4984 13.6339 13.8042 13.9686 14.0658 14.1091 14.1184 14.1247 14.1347 14.1535 14.1761 14.1991 14.2227 14.2439 14.258 14.2684 14.2722 14.2673 14.2641 14.269 14.2751 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0377 12.1338 12.9451 13.0156 13.2123 13.4586 13.6581 13.8554 13.9995 14.0764 14.1142 14.1222 14.1279 14.1375 14.1546 14.1755 14.1982 14.2224 14.244 14.2579 14.2682 14.2724 14.268 14.2647 14.2695 14.2757 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0349 12.1237 12.9431 13.0007 13.1523 13.4116 13.6846 13.9049 14.0253 14.0855 14.1164 14.1248 14.131 14.1409 14.1566 14.1761 14.1983 14.2222 14.2437 14.2575 14.2677 14.2724 14.2688 14.2656 14.2705 14.2769 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0325 12.1147 12.9417 12.993 13.1044 13.3605 13.7085 13.9496 14.0471 14.0937 14.1168 14.1261 14.134 14.1447 14.1595 14.178 14.199 14.2219 14.2431 14.257 14.2674 14.2728 14.2699 14.2668 14.2717 14.2783 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0305 12.108 12.9395 12.9895 13.0704 13.3103 13.7261 13.9882 14.0659 14.1014 14.1166 14.1273 14.1372 14.1482 14.1627 14.1804 14.2001 14.2217 14.2427 14.257 14.2674 14.2732 14.2708 14.2679 14.2728 14.2798 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0291 12.1041 12.9365 12.9872 13.0498 13.2676 13.7365 14.0178 14.08 14.1073 14.1187 14.1306 14.1408 14.1517 14.1657 14.1825 14.201 14.2217 14.2427 14.2575 14.2677 14.2733 14.271 14.2682 14.2734 14.2811 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0282 12.1015 12.9337 12.9875 13.039 13.2363 13.741 14.0388 14.0896 14.1098 14.1211 14.1331 14.1435 14.1543 14.1678 14.1834 14.2009 14.221 14.2424 14.2576 14.2676 14.2729 14.2703 14.2677 14.2733 14.2816 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10.0277 12.0996 12.9324 12.9889 13.035 13.2195 13.7387 14.048 14.0974 14.1129 14.1253 14.1371 14.1468 14.1571 14.1699 14.1847 14.2016 14.2217 14.2434 14.2587 14.2686 14.2735 14.2706 14.268 14.2737 14.2823 14.7202 14.6645 14.6709 14.691 14.7231 14.7586 14.7792 14.7761 14.7676 14.7586 14.7544 14.7541 14.7561 14.7606 14.7684 14.7825 14.8091 14.8471 14.8716 14.8749 14.873 14.8691 14.8631 14.8579 14.8558 14.8551 14.8548 14.8575 14.8679 14.8945 14.9335 14.9577 14.961 14.9565 14.9507 14.9431 14.9314 14.9163 14.899 14.8765 14.8576 14.8544 14.902 15.0613 15.2774 15.4888 15.6163 15.6812 15.6965 15.678 15.6426 15.6019 15.5543 15.5064 15.4688 15.452 15.4422 15.443 15.4473 15.4472 15.4424 15.4432 15.4478 15.4532 15.458 15.4598 15.4547 15.448 15.4424 15.4325 15.4397 15.4754 15.5082 15.5181 15.5537 15.6733 15.8254 15.9305 15.9638 15.9951 14.5616 14.5454 14.5895 14.6437 14.6968 14.7383 14.7605 14.7598 14.7548 14.7505 14.7493 14.7515 14.7557 14.7619 14.7716 14.788 14.8156 14.8514 14.8711 14.8724 14.8709 14.8666 14.8598 14.8551 14.8537 14.8532 14.854 14.8593 14.8744 14.9037 14.9389 14.9553 14.9551 14.9502 14.9447 14.9365 14.9242 14.9108 14.8931 14.8728 14.8603 14.8763 14.9553 15.1261 15.3179 15.5061 15.6173 15.6668 15.6807 15.6634 15.6314 15.5943 15.5499 15.5047 15.4687 15.4544 15.4473 15.4493 15.4516 15.4465 15.4378 15.4398 15.4452 15.4508 15.4545 15.4521 15.4434 15.4358 15.4319 15.4308 15.4454 15.4839 15.5211 15.5521 15.6261 15.7395 15.8478 15.9266 15.9504 15.9799 14.5339 14.558 14.6068 14.6478 14.6955 14.7325 14.7509 14.7522 14.7471 14.7445 14.7448 14.748 14.7531 14.76 14.7704 14.7873 14.8147 14.849 14.8668 14.868 14.8669 14.8628 14.856 14.8515 14.8495 14.8488 14.8504 14.8576 14.8753 14.9058 14.9383 14.9532 14.9531 14.9484 14.9413 14.9303 14.9169 14.9031 14.8869 14.8754 14.8744 14.9187 15.0237 15.1763 15.3168 15.4778 15.5886 15.6393 15.6626 15.6521 15.6258 15.5935 15.5505 15.5055 15.47 15.4565 15.451 15.4532 15.4546 15.4476 15.4375 15.4391 15.4448 15.4504 15.4498 15.4423 15.4317 15.4275 15.4223 15.4242 15.445 15.4955 15.5605 15.6365 15.7167 15.7812 15.8372 15.899 15.9341 15.9691 14.5065 14.534 14.5785 14.6207 14.6721 14.712 14.7323 14.7368 14.7332 14.7323 14.7344 14.7388 14.7454 14.7539 14.7654 14.7825 14.8096 14.8431 14.8598 14.8611 14.8605 14.8562 14.85 14.8466 14.8446 14.8438 14.8462 14.8554 14.8749 14.9063 14.9368 14.9492 14.9481 14.9431 14.9342 14.9198 14.9057 14.8918 14.8818 14.8832 14.9102 14.9876 15.1002 15.2114 15.3034 15.4273 15.5403 15.6004 15.6369 15.6354 15.6199 15.5927 15.5524 15.5079 15.4733 15.46 15.4555 15.457 15.459 15.4483 15.437 15.4379 15.4427 15.4461 15.4424 15.4328 15.4241 15.4173 15.413 15.4213 15.4543 15.5328 15.6402 15.7347 15.7829 15.8025 15.824 15.8678 15.9208 15.9665 14.4891 14.5117 14.548 14.5898 14.6432 14.6877 14.7133 14.7227 14.7227 14.724 14.7287 14.7348 14.7422 14.7512 14.7625 14.7793 14.8068 14.8396 14.854 14.8554 14.8549 14.8505 14.8452 14.8428 14.8418 14.8426 14.8461 14.855 14.874 14.9049 14.9348 14.9464 14.9446 14.9386 14.9264 14.9097 14.8941 14.8824 14.882 14.9032 14.9689 15.0674 15.1595 15.2275 15.2839 15.3718 15.4836 15.5555 15.604 15.6201 15.6097 15.5896 15.5541 15.5125 15.4784 15.4655 15.4622 15.4639 15.4663 15.4525 15.4404 15.4398 15.4412 15.4407 15.434 15.4248 15.4162 15.4097 15.4091 15.4258 15.4826 15.6084 15.7367 15.808 15.8181 15.8164 15.8195 15.8517 15.9167 15.9728 14.4733 14.4889 14.5163 14.5569 14.6107 14.6598 14.6929 14.7096 14.7148 14.7187 14.7253 14.7322 14.7395 14.748 14.7588 14.7753 14.8033 14.8356 14.8474 14.8484 14.8473 14.8431 14.8403 14.8395 14.8397 14.8414 14.8458 14.8548 14.8727 14.9027 14.9327 14.9428 14.9402 14.9322 14.9161 14.8974 14.8824 14.8776 14.8907 14.9483 15.0435 15.1358 15.1964 15.2304 15.2628 15.3146 15.4169 15.5054 15.5684 15.6007 15.5971 15.5844 15.5555 15.5181 15.4853 15.4745 15.4737 15.4761 15.4781 15.4614 15.4462 15.4406 15.438 15.4323 15.4232 15.4141 15.4069 15.4044 15.4107 15.449 15.5547 15.6983 15.8074 15.8468 15.8428 15.8346 15.8286 15.8567 15.9156 15.9702 14.4588 14.4703 14.4911 14.5267 14.5778 14.6292 14.6698 14.6952 14.7078 14.7161 14.7249 14.732 14.7383 14.746 14.7564 14.7726 14.7999 14.8318 14.8423 14.8429 14.841 14.8378 14.8375 14.8387 14.8404 14.8431 14.8476 14.8558 14.8718 14.9007 14.931 14.9399 14.9354 14.924 14.9051 14.8867 14.8768 14.8815 14.9239 15.0138 15.1105 15.1769 15.2119 15.2325 15.2469 15.2655 15.3455 15.4515 15.5306 15.5765 15.5868 15.5787 15.5569 15.5245 15.4943 15.4878 15.4896 15.4926 15.4925 15.4734 15.4541 15.4415 15.4314 15.419 15.4073 15.4015 15.3995 15.4031 15.4322 15.5202 15.6484 15.7661 15.8401 15.8641 15.8622 15.8572 15.8576 15.8775 15.9106 15.9477 14.4487 14.4571 14.4735 14.5024 14.547 14.5963 14.642 14.6762 14.6977 14.7112 14.723 14.7314 14.7377 14.7451 14.7554 14.771 14.7966 14.827 14.8377 14.8381 14.8362 14.8352 14.8368 14.8396 14.8427 14.846 14.8503 14.8574 14.8717 14.8988 14.9278 14.9352 14.928 14.9132 14.8951 14.8815 14.8796 14.9074 14.9838 15.0795 15.1537 15.194 15.2195 15.2311 15.2313 15.2302 15.2794 15.3913 15.4899 15.5501 15.5761 15.573 15.5593 15.5338 15.5082 15.5052 15.5077 15.5094 15.5067 15.4847 15.4588 15.4373 15.4196 15.4021 15.3922 15.391 15.3972 15.4229 15.5034 15.6179 15.7255 15.8027 15.8519 15.872 15.8811 15.889 15.897 15.9056 15.909 15.923 14.4413 14.4482 14.4621 14.485 14.521 14.5634 14.6093 14.651 14.6819 14.7025 14.7185 14.7292 14.7359 14.7436 14.7539 14.769 14.7921 14.8203 14.8331 14.8347 14.8343 14.835 14.838 14.8419 14.8456 14.8491 14.8533 14.86 14.8729 14.8968 14.9218 14.927 14.9173 14.9022 14.8896 14.8841 14.9014 14.9626 15.0518 15.1279 15.1742 15.1991 15.2173 15.2249 15.2168 15.2057 15.2294 15.3245 15.4414 15.5185 15.5608 15.5697 15.5634 15.546 15.5271 15.5234 15.5238 15.5235 15.5173 15.4917 15.4584 15.4277 15.4055 15.3885 15.3826 15.3875 15.4142 15.4912 15.6012 15.6978 15.7713 15.8209 15.8559 15.8774 15.898 15.9184 15.9287 15.926 15.9132 15.9117 14.4358 14.4426 14.4549 14.4736 14.502 14.5353 14.5752 14.6199 14.6589 14.6878 14.7092 14.7236 14.7319 14.7405 14.7513 14.7661 14.7873 14.8136 14.829 14.8323 14.8338 14.8362 14.84 14.8441 14.8478 14.8515 14.8561 14.863 14.8743 14.8937 14.9126 14.9149 14.9049 14.8949 14.8907 14.9024 14.9517 15.0328 15.1079 15.1564 15.1795 15.1957 15.209 15.215 15.2057 15.1898 15.1964 15.2587 15.382 15.481 15.5391 15.5662 15.5669 15.56 15.5474 15.5385 15.5368 15.5329 15.5217 15.4933 15.4546 15.4177 15.3933 15.3818 15.3823 15.4068 15.4815 15.588 15.6806 15.7445 15.7929 15.83 15.8602 15.8845 15.9106 15.9364 15.9448 15.9371 15.9191 15.9142 14.4317 14.4393 14.4506 14.4668 14.4893 14.5149 14.5445 14.5849 14.6288 14.666 14.6943 14.714 14.725 14.7346 14.7463 14.7616 14.7824 14.8082 14.8257 14.831 14.8337 14.837 14.8411 14.8452 14.8492 14.8534 14.8582 14.8644 14.8736 14.8875 14.9004 14.9007 14.8955 14.8937 14.903 14.9453 15.0213 15.0968 15.1436 15.167 15.1785 15.187 15.1966 15.2047 15.1971 15.1801 15.1748 15.2053 15.3161 15.4365 15.5136 15.5582 15.57 15.5717 15.5638 15.5516 15.5459 15.5359 15.5193 15.4896 15.4456 15.4089 15.3896 15.383 15.4075 15.4787 15.5787 15.667 15.7269 15.7667 15.8015 15.8372 15.8672 15.8931 15.92 15.943 15.9486 15.9402 15.9241 15.9202 14.4274 14.4362 14.4474 14.4624 14.482 14.5027 14.521 14.55 14.5925 14.6358 14.6727 14.6997 14.7153 14.7265 14.7394 14.7556 14.777 14.8034 14.8231 14.8302 14.8334 14.8367 14.8408 14.8453 14.8499 14.8543 14.8586 14.863 14.8688 14.8773 14.8865 14.8897 14.8913 14.9011 14.9382 15.0105 15.0889 15.1401 15.1624 15.1686 15.172 15.175 15.1837 15.1945 15.1902 15.1733 15.1606 15.1713 15.2524 15.3842 15.4857 15.5438 15.5732 15.5813 15.5758 15.5636 15.5499 15.5331 15.51 15.4798 15.4394 15.4078 15.3917 15.4133 15.4799 15.5741 15.656 15.7127 15.7475 15.7765 15.808 15.8428 15.878 15.9074 15.9304 15.9437 15.9438 15.9352 15.9235 15.9249 14.4225 14.4328 14.4446 14.4594 14.4781 14.4951 14.5051 14.5215 14.5539 14.5978 14.6424 14.6789 14.7021 14.7164 14.731 14.7489 14.7716 14.7992 14.8212 14.8297 14.8331 14.8358 14.8397 14.8444 14.8493 14.8536 14.8566 14.8581 14.8594 14.8644 14.8754 14.8845 14.8972 14.929 14.9964 15.0774 15.1363 15.1624 15.1684 15.1666 15.1624 15.1624 15.1708 15.1832 15.1842 15.1691 15.1523 15.1537 15.2 15.3266 15.4523 15.5272 15.5741 15.5868 15.5838 15.5704 15.549 15.5263 15.5022 15.4753 15.4412 15.4131 15.4248 15.4814 15.5672 15.6445 15.6978 15.7326 15.758 15.784 15.8125 15.8481 15.8929 15.9282 15.9469 15.9491 15.9411 15.9293 15.922 15.9256 14.4173 14.4288 14.4417 14.457 14.4758 14.4903 14.4964 14.5026 14.5197 14.5562 14.6039 14.6501 14.6841 14.7047 14.7222 14.742 14.7663 14.795 14.8189 14.8291 14.8328 14.8349 14.838 14.8425 14.8473 14.8508 14.8513 14.8492 14.847 14.8516 14.8672 14.8891 14.9198 14.9813 15.0606 15.126 15.1609 15.1707 15.168 15.1605 15.153 15.1515 15.1586 15.1717 15.1778 15.1662 15.1495 15.1435 15.1651 15.2688 15.4097 15.5083 15.5672 15.5882 15.5851 15.5694 15.5459 15.5226 15.5042 15.4806 15.4504 15.45 15.4943 15.5652 15.6314 15.6804 15.7159 15.7423 15.7651 15.789 15.8161 15.8575 15.9128 15.9537 15.9697 15.9674 15.9486 15.9334 15.9241 15.9246 14.4127 14.4251 14.439 14.4549 14.4741 14.4885 14.4924 14.4925 14.4972 14.5189 14.5609 14.6128 14.6591 14.6901 14.7127 14.7354 14.7611 14.7903 14.8156 14.8272 14.8318 14.8338 14.8363 14.8399 14.8437 14.8451 14.8427 14.8376 14.8348 14.8432 14.8671 14.9085 14.9668 15.0441 15.1101 15.1516 15.1693 15.1701 15.1652 15.1541 15.1452 15.1424 15.1472 15.1601 15.1706 15.1643 15.1491 15.1393 15.147 15.2173 15.3565 15.4797 15.5494 15.5814 15.5768 15.5632 15.5436 15.5252 15.5115 15.4952 15.4937 15.5295 15.5845 15.6325 15.6681 15.698 15.7243 15.7475 15.7693 15.7936 15.8238 15.8746 15.936 15.9808 15.9922 15.988 15.9685 15.9525 15.9431 15.9468 14.4091 14.422 14.437 14.4534 14.4728 14.4879 14.4911 14.489 14.4869 14.4933 14.522 14.5708 14.6255 14.6695 14.7007 14.7279 14.7556 14.7849 14.8109 14.8238 14.8294 14.832 14.8344 14.8369 14.8384 14.837 14.8317 14.8257 14.8267 14.8414 14.8822 14.9484 15.0279 15.0964 15.1379 15.1608 15.1691 15.1675 15.1596 15.1477 15.1387 15.1347 15.1368 15.148 15.1615 15.1621 15.1504 15.1388 15.1423 15.1808 15.2974 15.4359 15.5211 15.5629 15.5624 15.5532 15.5421 15.5325 15.5371 15.5508 15.5854 15.6287 15.6597 15.6777 15.6918 15.7096 15.7309 15.7521 15.7741 15.7995 15.8375 15.8967 15.9604 16.0018 16.0058 15.9952 15.9803 15.9752 15.9776 15.9933 14.4061 14.4196 14.4354 14.4526 14.4719 14.4874 14.4909 14.4885 14.4841 14.4811 14.494 14.5303 14.5845 14.6396 14.6825 14.7173 14.7487 14.7789 14.8051 14.8192 14.8257 14.8291 14.8316 14.8331 14.8317 14.827 14.8203 14.817 14.8243 14.8526 14.9176 15.0042 15.0822 15.1277 15.1498 15.1608 15.1637 15.1611 15.1527 15.1424 15.1334 15.1279 15.1274 15.1361 15.1515 15.1592 15.1518 15.1415 15.1428 15.1614 15.242 15.378 15.4814 15.5349 15.5476 15.547 15.546 15.563 15.6025 15.6505 15.6911 15.709 15.7105 15.7083 15.7117 15.7238 15.7406 15.7588 15.7797 15.8076 15.8549 15.9193 15.9793 16.0103 16.008 15.9933 15.9829 15.9843 15.9959 16.0198 14.4025 14.4171 14.434 14.452 14.4711 14.4873 14.4919 14.4892 14.4841 14.4779 14.4794 14.4991 14.5421 14.5996 14.6541 14.6999 14.7387 14.7718 14.7985 14.8139 14.821 14.8245 14.8268 14.8272 14.8234 14.816 14.8114 14.8145 14.8331 14.8833 14.9694 15.057 15.1161 15.1415 15.1522 15.1571 15.1558 15.1517 15.1453 15.1368 15.1279 15.1213 15.1194 15.1264 15.1422 15.1561 15.1549 15.1467 15.1439 15.1513 15.1975 15.3126 15.4315 15.5003 15.5337 15.5484 15.5723 15.6249 15.6935 15.7485 15.7685 15.7596 15.7423 15.7306 15.7323 15.7419 15.7541 15.7676 15.7868 15.8189 15.8736 15.9365 15.9855 16.0062 16.0022 15.9924 15.9906 15.9946 16.0062 16.03 14.3977 14.4136 14.4318 14.4508 14.4703 14.4875 14.4934 14.491 14.4853 14.4777 14.4743 14.4813 14.5069 14.5552 14.6147 14.6722 14.7222 14.762 14.7913 14.8082 14.8155 14.8181 14.8192 14.818 14.8129 14.8069 14.8073 14.8215 14.8595 14.9304 15.0196 15.092 15.1303 15.146 15.1502 15.1494 15.1465 15.1427 15.1378 15.1302 15.1214 15.1145 15.1124 15.119 15.1355 15.154 15.1591 15.1517 15.1427 15.1444 15.1641 15.2481 15.3738 15.4671 15.5288 15.5724 15.6293 15.7038 15.7744 15.8136 15.8108 15.7899 15.764 15.7505 15.7523 15.7598 15.769 15.7796 15.7988 15.8364 15.8924 15.9449 15.9794 15.9946 15.996 15.9972 16.0014 16.0079 16.0191 16.0413 14.3914 14.4087 14.4281 14.4482 14.469 14.4875 14.4946 14.4932 14.4871 14.4782 14.4735 14.474 14.4851 14.5164 14.5691 14.6327 14.6957 14.7468 14.7819 14.8013 14.8086 14.8095 14.8079 14.8054 14.8016 14.8014 14.8123 14.8437 14.902 14.9802 15.0552 15.1087 15.1349 15.1439 15.1446 15.1408 15.1373 15.1338 15.1291 15.1217 15.1135 15.1074 15.1068 15.1146 15.1325 15.1528 15.1613 15.1555 15.1418 15.1333 15.1422 15.1943 15.3149 15.4412 15.5406 15.623 15.7028 15.7744 15.8263 15.8471 15.8351 15.8091 15.7837 15.7696 15.7688 15.7726 15.7806 15.7943 15.8159 15.8609 15.9105 15.9462 15.968 15.9832 15.9913 15.9995 16.0077 16.0173 16.026 16.0489 14.384 14.4023 14.4227 14.4439 14.4665 14.4868 14.4951 14.4949 14.4888 14.479 14.4737 14.4723 14.4755 14.4909 14.5274 14.5857 14.657 14.7219 14.767 14.7911 14.7995 14.7982 14.7939 14.7911 14.7927 14.8028 14.8314 14.883 14.9502 15.0189 15.0737 15.113 15.1334 15.1392 15.1367 15.1324 15.1288 15.1253 15.1201 15.1126 15.1052 15.1003 15.1017 15.1113 15.1307 15.1508 15.1581 15.152 15.1352 15.1205 15.1268 15.1594 15.2671 15.4273 15.5716 15.6856 15.7672 15.8218 15.8542 15.8632 15.8501 15.8274 15.8035 15.7869 15.7803 15.7805 15.7885 15.8063 15.8389 15.8885 15.9274 15.9467 15.9599 15.9761 15.9875 15.9972 16.0072 16.0172 16.0249 16.0506 14.3762 14.3951 14.4163 14.4383 14.4625 14.4847 14.4945 14.4957 14.4903 14.4801 14.4747 14.4725 14.4729 14.4791 14.4988 14.541 14.6082 14.6837 14.7421 14.7745 14.7864 14.7849 14.7796 14.7797 14.7904 14.8174 14.8669 14.9297 14.9913 15.0415 15.08 15.1115 15.1283 15.1307 15.1287 15.1261 15.1222 15.1177 15.1113 15.1034 15.0965 15.0931 15.0961 15.1076 15.1277 15.1453 15.1492 15.1402 15.1245 15.1119 15.12 15.1478 15.2472 15.4302 15.6099 15.736 15.8089 15.8485 15.8716 15.878 15.8684 15.8491 15.824 15.8025 15.7896 15.786 15.7951 15.8188 15.8644 15.914 15.9436 15.953 15.961 15.9734 15.9832 15.9944 16.007 16.0193 16.028 16.0562 14.3677 14.3875 14.4094 14.4323 14.4576 14.481 14.4924 14.4954 14.4911 14.4815 14.476 14.4736 14.4733 14.4763 14.4855 14.5092 14.5589 14.633 14.7034 14.7479 14.7679 14.7706 14.7684 14.7757 14.8006 14.8478 14.9111 14.9708 15.0179 15.0507 15.079 15.104 15.1194 15.1221 15.1221 15.1214 15.1172 15.1111 15.1036 15.0953 15.0884 15.0859 15.0893 15.1013 15.1208 15.1349 15.135 15.1273 15.1169 15.1122 15.1229 15.1632 15.2673 15.449 15.6346 15.759 15.8276 15.8613 15.8846 15.8941 15.89 15.8727 15.8436 15.816 15.7978 15.7918 15.8024 15.8351 15.8882 15.9332 15.9578 15.9658 15.969 15.9748 15.9814 15.9927 16.008 16.0242 16.0398 16.0702 14.3578 14.3791 14.4023 14.4264 14.4525 14.4766 14.4891 14.4936 14.4913 14.4833 14.478 14.4757 14.475 14.4771 14.4821 14.4937 14.5223 14.5803 14.6512 14.7084 14.7417 14.7547 14.7629 14.7834 14.8264 14.8881 14.9502 14.9976 15.0292 15.0521 15.0726 15.0935 15.1091 15.1146 15.1173 15.117 15.113 15.1057 15.0972 15.0884 15.0812 15.0789 15.0817 15.0923 15.1088 15.12 15.1196 15.1174 15.1181 15.1224 15.1501 15.2141 15.3175 15.458 15.6278 15.7547 15.8337 15.8747 15.9054 15.9204 15.9168 15.8964 15.8619 15.8289 15.8059 15.7989 15.8129 15.8555 15.9075 15.945 15.9666 15.9788 15.9851 15.9886 15.9972 16.0147 16.0347 16.052 16.0684 16.0916 14.3461 14.3694 14.3947 14.4208 14.4479 14.4721 14.4853 14.4909 14.4906 14.485 14.4805 14.4791 14.4783 14.4793 14.4825 14.4886 14.5027 14.5391 14.5955 14.6564 14.705 14.7367 14.763 14.8058 14.8627 14.9253 14.9759 15.0109 15.0319 15.0477 15.0637 15.0833 15.1009 15.1094 15.1132 15.1127 15.1087 15.1008 15.0917 15.0823 15.075 15.0721 15.0733 15.0807 15.094 15.1051 15.1107 15.1156 15.1264 15.153 15.2075 15.2763 15.3527 15.4465 15.5952 15.73 15.8261 15.8855 15.9257 15.9446 15.9416 15.9185 15.8798 15.842 15.8149 15.81 15.8321 15.8783 15.9224 15.951 15.9717 15.9897 16.007 16.025 16.0422 16.0565 16.0676 16.0766 16.0906 16.115 14.3328 14.3579 14.3856 14.4143 14.4432 14.4678 14.4818 14.4882 14.4895 14.4862 14.4831 14.4832 14.4829 14.4831 14.4842 14.4871 14.4941 14.5137 14.5516 14.6009 14.6586 14.7156 14.7705 14.8345 14.8973 14.951 14.9882 15.0117 15.0274 15.0401 15.0559 15.0766 15.0951 15.1047 15.108 15.107 15.1032 15.0959 15.0868 15.0774 15.0696 15.0647 15.0631 15.0669 15.08 15.0971 15.109 15.1236 15.1556 15.2122 15.2735 15.3215 15.3677 15.4285 15.548 15.6903 15.8084 15.8929 15.9463 15.968 15.9627 15.9362 15.8944 15.8524 15.826 15.8294 15.8601 15.9032 15.9369 15.958 15.9777 16.001 16.0281 16.0566 16.0768 16.0835 16.0867 16.0909 16.1037 16.1262 14.319 14.3447 14.3744 14.406 14.4372 14.4631 14.4785 14.4859 14.4883 14.4867 14.4852 14.4866 14.4877 14.4879 14.4872 14.4872 14.4907 14.5022 14.5265 14.5575 14.6111 14.6912 14.7798 14.8584 14.9225 14.9653 14.9928 15.0084 15.0204 15.0332 15.0501 15.0713 15.0905 15.1005 15.1021 15.1006 15.0968 15.0906 15.0824 15.0733 15.0641 15.056 15.0515 15.0561 15.0738 15.0955 15.1205 15.1572 15.2169 15.2802 15.3225 15.347 15.3723 15.4119 15.5042 15.6432 15.7822 15.8909 15.9564 15.9826 15.9752 15.9459 15.9022 15.8605 15.8418 15.856 15.895 15.9314 15.9547 15.971 15.9886 16.0141 16.0453 16.0755 16.0943 16.0982 16.0975 16.0993 16.1069 16.1261 14.3061 14.3306 14.3606 14.3946 14.4289 14.4572 14.475 14.4841 14.4874 14.4863 14.4859 14.4886 14.4912 14.492 14.4908 14.489 14.4901 14.4981 14.5159 14.5395 14.5826 14.6701 14.7763 14.8648 14.9273 14.9654 14.9873 14.9999 15.0114 15.026 15.0444 15.0668 15.0869 15.0952 15.0949 15.093 15.0897 15.0844 15.0768 15.0669 15.0552 15.0453 15.0425 15.0527 15.0744 15.1103 15.1604 15.2234 15.2873 15.3319 15.3511 15.3623 15.3752 15.4039 15.4704 15.5953 15.7456 15.8765 15.9562 15.9871 15.9773 15.9461 15.9012 15.866 15.8629 15.8881 15.9324 15.9624 15.9793 15.9917 16.0078 16.0333 16.0622 16.0883 16.1033 16.1056 16.1036 16.1055 16.1081 16.1197 14.2955 14.3168 14.345 14.3798 14.4173 14.4493 14.4705 14.482 14.4865 14.4854 14.4851 14.4885 14.4921 14.4937 14.4929 14.4908 14.4912 14.4991 14.5182 14.5443 14.5875 14.6649 14.759 14.8473 14.9092 14.9491 14.9734 14.9892 15.0028 15.0188 15.0379 15.0607 15.081 15.088 15.0877 15.086 15.0831 15.0779 15.0693 15.0572 15.0439 15.0362 15.04 15.0562 15.0917 15.1554 15.2289 15.2939 15.3385 15.361 15.3695 15.3742 15.3825 15.4042 15.4491 15.5521 15.6998 15.8476 15.9487 15.9835 15.971 15.9394 15.8984 15.8757 15.8874 15.9258 15.9692 15.9931 16.0077 16.0179 16.0334 16.0576 16.0826 16.1036 16.1147 16.1152 16.1145 16.1175 16.1123 16.1174 14.2881 14.305 14.3293 14.3628 14.4025 14.4385 14.4639 14.4788 14.485 14.4841 14.4833 14.4865 14.4903 14.4925 14.4926 14.4918 14.4944 14.5059 14.5331 14.5681 14.6159 14.673 14.7363 14.8085 14.8721 14.9211 14.9556 14.9774 14.9936 15.0113 15.0315 15.0538 15.0736 15.0812 15.0813 15.0793 15.0755 15.0688 15.0581 15.0447 15.0346 15.0336 15.045 15.077 15.1398 15.223 15.2957 15.3413 15.3653 15.3753 15.3815 15.387 15.3938 15.4103 15.4433 15.5195 15.6522 15.8087 15.9297 15.9755 15.9624 15.9319 15.9002 15.8929 15.9166 15.9633 16.0011 16.0197 16.0317 16.0427 16.0575 16.0794 16.102 16.1227 16.1376 16.1426 16.1373 16.1349 16.1247 16.1296 14.284 14.2966 14.3161 14.3457 14.3853 14.4246 14.4545 14.4734 14.4822 14.482 14.4804 14.4831 14.4866 14.4892 14.491 14.4938 14.5012 14.5209 14.5595 14.6064 14.6514 14.6859 14.7152 14.7625 14.8198 14.878 14.9269 14.959 14.9811 15.0022 15.0243 15.0464 15.0658 15.0747 15.0747 15.0714 15.0652 15.0558 15.044 15.0341 15.0312 15.039 15.0681 15.1259 15.2057 15.2843 15.3381 15.3653 15.3758 15.3821 15.3899 15.3984 15.4058 15.4197 15.4471 15.5 15.6119 15.7655 15.9009 15.9645 15.9548 15.9286 15.9075 15.9149 15.9488 15.995 16.0239 16.0392 16.0487 16.0595 16.0726 16.0905 16.1111 16.1349 16.1605 16.1782 16.1802 16.1776 16.1634 16.1616 14.2824 14.2919 14.3067 14.3309 14.3675 14.408 14.4415 14.4649 14.477 14.4786 14.4768 14.4784 14.4814 14.4844 14.4889 14.4968 14.513 14.5463 14.596 14.6464 14.6811 14.6969 14.7038 14.726 14.7658 14.823 14.8835 14.9308 14.9636 14.9909 15.0161 15.039 15.0587 15.0679 15.0666 15.0611 15.0517 15.0408 15.0328 15.0303 15.0371 15.0634 15.118 15.19 15.2633 15.3227 15.3591 15.3734 15.3802 15.3869 15.3951 15.4056 15.4144 15.4279 15.4532 15.4934 15.5861 15.7258 15.8683 15.948 15.9483 15.9314 15.9208 15.9375 15.9781 16.017 16.0364 16.0484 16.0558 16.0659 16.0772 16.0913 16.1113 16.1401 16.1733 16.1973 16.2076 16.209 16.1996 16.1956 14.2821 14.2902 14.3015 14.32 14.351 14.3898 14.4252 14.4526 14.469 14.4737 14.4725 14.4732 14.4755 14.4799 14.488 14.5035 14.5324 14.5798 14.6346 14.6785 14.7007 14.7047 14.7023 14.7052 14.7245 14.7666 14.8276 14.8884 14.9364 14.9746 15.0059 15.0305 15.0504 15.0587 15.0553 15.0469 15.036 15.0298 15.0295 15.0373 15.0623 15.1141 15.1801 15.2435 15.2987 15.3412 15.3667 15.3774 15.3831 15.3891 15.397 15.408 15.4194 15.4334 15.4573 15.496 15.572 15.6937 15.8347 15.9279 15.9453 15.9367 15.9374 15.9609 16.0005 16.0276 16.0383 16.0455 16.0513 16.0614 16.0719 16.0866 16.1096 16.1439 16.1789 16.2008 16.2111 16.2162 16.2166 16.2176 14.2826 14.2902 14.2994 14.3133 14.3375 14.372 14.4063 14.4363 14.4571 14.4662 14.4672 14.4679 14.4704 14.4775 14.4915 14.5173 14.5592 14.6146 14.6661 14.6992 14.712 14.7113 14.7044 14.7001 14.7046 14.7251 14.7707 14.834 14.8966 14.9492 14.9906 15.0194 15.0391 15.046 15.0404 15.0302 15.0246 15.0266 15.0369 15.064 15.1137 15.1743 15.2291 15.2741 15.3141 15.3486 15.371 15.3796 15.3842 15.3894 15.3968 15.4081 15.4226 15.4381 15.4624 15.5 15.5646 15.6697 15.8014 15.9044 15.9407 15.946 15.9562 15.9847 16.0149 16.0287 16.0309 16.0334 16.0394 16.0508 16.0644 16.0841 16.111 16.1461 16.1775 16.1962 16.2046 16.2099 16.214 16.2203 14.2837 14.291 14.2991 14.3102 14.3285 14.357 14.3867 14.416 14.4405 14.4548 14.4598 14.4625 14.4679 14.4804 14.5026 14.5395 14.5895 14.6439 14.6868 14.711 14.7183 14.7167 14.7084 14.7019 14.7019 14.7082 14.7308 14.7788 14.8444 14.9095 14.9643 15.0021 15.0232 15.0296 15.0233 15.0172 15.0208 15.0344 15.0645 15.1149 15.1717 15.2198 15.2556 15.2857 15.3186 15.3517 15.3732 15.3809 15.3843 15.3886 15.3962 15.4078 15.4251 15.4434 15.469 15.504 15.5617 15.6506 15.7676 15.8761 15.933 15.9569 15.9797 16.0072 16.023 16.024 16.0208 16.0213 16.0297 16.0438 16.063 16.0845 16.1113 16.1414 16.1677 16.1845 16.1924 16.1987 16.2043 16.2077 14.2853 14.2923 14.2999 14.3095 14.3241 14.3464 14.3687 14.3933 14.4188 14.4382 14.4492 14.4573 14.4696 14.4903 14.5231 14.567 14.6174 14.6643 14.6977 14.717 14.7223 14.722 14.7159 14.7083 14.7047 14.7069 14.7165 14.7405 14.7889 14.8543 14.9209 14.9728 15.0008 15.0101 15.0087 15.0135 15.029 15.0632 15.1146 15.1701 15.2146 15.2444 15.2657 15.2893 15.3189 15.3505 15.3719 15.3809 15.3848 15.389 15.3969 15.4092 15.4282 15.4497 15.4764 15.5104 15.56 15.6361 15.7363 15.8458 15.9237 15.967 16.0042 16.0259 16.0291 16.0228 16.017 16.0188 16.0307 16.0477 16.0679 16.0904 16.1146 16.1373 16.1568 16.17 16.1748 16.1794 16.185 16.189 14.2871 14.2942 14.3014 14.3103 14.3228 14.34 14.3551 14.3718 14.3938 14.4165 14.4347 14.4525 14.4753 14.5082 14.5498 14.5953 14.6397 14.6761 14.7024 14.7189 14.7249 14.7261 14.723 14.7167 14.7122 14.7113 14.7152 14.7244 14.7472 14.7939 14.86 14.9256 14.9686 14.9889 15.0024 15.0242 15.0612 15.113 15.1677 15.2109 15.2372 15.253 15.2684 15.2895 15.3171 15.3461 15.3674 15.3785 15.3841 15.3892 15.3977 15.4115 15.4319 15.4569 15.485 15.5194 15.5623 15.626 15.7103 15.8162 15.9126 15.9788 16.0266 16.0416 16.036 16.0278 16.0241 16.0278 16.0408 16.06 16.0811 16.1022 16.1224 16.1411 16.1562 16.1668 16.1691 16.1694 16.1704 16.175 14.289 14.2963 14.3032 14.3114 14.3228 14.3367 14.3469 14.3552 14.3695 14.3916 14.417 14.4479 14.4853 14.5307 14.5771 14.6198 14.6557 14.6828 14.7042 14.7195 14.7268 14.7291 14.7289 14.7253 14.7219 14.7198 14.7187 14.7204 14.7263 14.7481 14.7954 14.8632 14.9243 14.9684 15.0086 15.0572 15.1119 15.1644 15.2074 15.2347 15.2484 15.2566 15.2687 15.2876 15.3131 15.3397 15.3611 15.3759 15.3855 15.3928 15.4018 15.4156 15.4361 15.4634 15.4944 15.5303 15.5684 15.6205 15.693 15.7902 15.9037 15.9942 16.0475 16.0566 16.045 16.0354 16.0354 16.0441 16.0601 16.0806 16.1019 16.1229 16.1412 16.1566 16.1682 16.1763 16.1773 16.1751 16.1724 16.1766 14.2902 14.2977 14.3042 14.3115 14.3224 14.335 14.3417 14.3438 14.3514 14.3685 14.3995 14.4438 14.4972 14.5518 14.5994 14.6358 14.6632 14.6844 14.7035 14.7186 14.7274 14.731 14.733 14.7319 14.7298 14.7273 14.7238 14.7202 14.7176 14.7228 14.7471 14.8006 14.8728 14.9504 15.0266 15.1006 15.1607 15.2004 15.2251 15.2408 15.2499 15.2584 15.268 15.2839 15.3062 15.3307 15.3529 15.3705 15.3834 15.3939 15.405 15.4197 15.4403 15.4685 15.5021 15.5395 15.5747 15.6183 15.6836 15.7707 15.8986 16.0102 16.0642 16.0681 16.0512 16.0363 16.0377 16.0512 16.0734 16.0973 16.1205 16.1433 16.1653 16.1846 16.1976 16.2036 16.201 16.1936 16.1863 16.1842 14.2914 14.2995 14.3066 14.3139 14.3242 14.3355 14.3403 14.3397 14.342 14.3531 14.3851 14.4384 14.5033 14.5647 14.6147 14.6494 14.6715 14.6882 14.705 14.7202 14.7286 14.7325 14.7355 14.7356 14.7351 14.7343 14.7298 14.7229 14.7176 14.7155 14.7241 14.7582 14.8288 14.9299 15.04 15.1331 15.1987 15.2329 15.2466 15.2506 15.2528 15.2585 15.2689 15.2845 15.307 15.3331 15.3568 15.3742 15.3869 15.3979 15.4091 15.4231 15.4434 15.4718 15.5075 15.5471 15.5821 15.6198 15.6807 15.758 15.8917 16.019 16.0734 16.0774 16.0603 16.0474 16.0503 16.0648 16.0866 16.1103 16.1343 16.1584 16.1834 16.2068 16.2219 16.2267 16.2195 16.2086 16.1994 16.1949 ) ; boundaryField { inlet { type fixedValue; value uniform 10; } outlet { type zeroGradient; } bottom { type symmetryPlane; } top { type symmetryPlane; } obstacle { type zeroGradient; } defaultFaces { type empty; } } // ************************************************************************* //
[ "andytorrestb@gmail.com" ]
andytorrestb@gmail.com
42ddfdc586201ec931ee813bcd17403ffb466901
6697cd726d4cd3744ae52a7d5618f4ad107befba
/CP/1500/638B.cpp
17e5e0e980527e4f1c04e0dd2988100b51fd0646
[]
no_license
Saifu0/Competitive-Programming
4385777115d5d83ba5140324c309db1e6c16f4af
ecc1c05f1a85636c57f7f6609dd6a002f220c0b0
refs/heads/master
2022-12-15T09:11:53.907652
2020-09-08T08:20:44
2020-09-08T08:20:44
293,743,953
0
0
null
null
null
null
UTF-8
C++
false
false
973
cpp
#include<bits/stdc++.h> using namespace std; #define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define fo(i,n) for(int i=0;i<n;i++) #define Fo(i,k,n) for(int i=k;i<n;i++) #define iii tuple<int,int,int> #define vi vector<int> #define ii pair<int,int> #define vii vector<ii> #define int long long #define pb push_back #define endl "\n" #define setbits __builtin_popcountll #define mp map<int,int> #define F first #define S second #define sz(v) (int)v.size() #define mod 1000000007 #define inf (int)1e18 int32_t main(){ NINJA; int t; cin >> t; while(t--){ int n,k; cin >> n >> k; set<int> s; int a[n]; fo(i,n){ cin >> a[i]; s.insert(a[i]); } if(s.size()>k){ cout << -1 << endl; continue; } for(int i=1;i<=k;i++){ if(s.size()<k) if(s.find(i)==s.end()){ s.insert(i); } } vi ans; cout << n*s.size() << endl; fo(j,n){ for(auto it : s) cout << it << " "; } cout << endl; } return 0; }
[ "43892879+Saifu0@users.noreply.github.com" ]
43892879+Saifu0@users.noreply.github.com
f13cdd3b629aeac7eba925df83ff4e4c934de1a5
d9b146be61dc5b164f00b3c818115dccee4703fd
/room.cpp
0a315c30406d9291d3d295435e4b96f71a05c836
[]
no_license
alyssajasminee/343-software-project
26665c05637d234ebf402dff670b664cb3b4e3a4
6681c4ec0866a7c0501e30a38f450888c18cc25e
refs/heads/master
2020-05-03T00:10:33.943895
2019-05-11T06:04:08
2019-05-11T06:04:08
178,302,413
0
0
null
2019-04-26T01:48:06
2019-03-29T00:23:39
C++
UTF-8
C++
false
false
557
cpp
#include "room.h" Room::Room(){} Room::Room(QString bldgName, int roomNum, int capacity) { this->bldgName = bldgName; this->roomNum = roomNum; this->capacity = capacity; } QString Room::getBldgName() { return bldgName; } int Room::getRoomNum() { return roomNum; } int Room::getCapacity() { return capacity; } void Room::setBldgName(QString bldgName) { this->bldgName = bldgName; } void Room::setRoomNum(int roomNum) { this->roomNum = roomNum; } void Room::setCapacity(int capacity) { this->capacity = capacity; }
[ "gfsbox@gmail.com" ]
gfsbox@gmail.com
7f84a2a5ef1323326cdcc60f202a57e63a70a439
319d0f5beaa7f9772b85ebca4d77ade340b53d31
/RsCppDemo/TODO.h
ba14640b9a3486cf9d6b2cfab9dcb9c368f0931a
[]
no_license
anastasiak2512/RsCppDemo
ad11105fdbaa4f79533768b509fc1f71f11f6cb0
55112691df726220f5252059e8ba5089c989477d
refs/heads/master
2020-04-03T15:37:50.181476
2019-03-17T15:46:06
2019-03-17T15:46:06
155,369,514
1
0
null
null
null
null
UTF-8
C++
false
false
104
h
#pragma once class TODO { public: TODO(); virtual ~TODO(); //TODO: implement some functionality };
[ "anastasia.kazakova2512@gmail.com" ]
anastasia.kazakova2512@gmail.com
e5c2b4b0487b7ff751539fb53acf441f95f751a0
3092dba22735b2a714be2f44a28716af71b863d8
/src/Game/GL.h
03638bccd6dc57759c1af73471b0acdf3b870600
[]
no_license
ha-drid/MineCraft2d
360643a6962b5e890880f03abe7d58cb99873f5b
e68e6ace849aaf9ffa5e50fd9b61e49d6478501d
refs/heads/master
2023-01-29T15:00:50.253533
2020-12-11T09:22:09
2020-12-11T09:22:09
320,524,868
0
0
null
null
null
null
UTF-8
C++
false
false
603
h
#pragma once #include <GLFW/glfw3.h> #include <gl/GL.h> #include "Block.h" #include "Player.h" class World; class GL { public: void texture_load(uint32_t* texture, std::string file); void block_draw(Block block); void player_draw(Player player); friend World; private: uint32_t grass_texture; uint32_t undefined_texture; uint32_t bedrok_texture; uint32_t stone_texture; uint32_t wood_texture; uint32_t foliage_texture; uint32_t iron_ore_texture; uint32_t dimond_ore_texture; uint32_t gold_ore_texture; uint32_t soil_texture; }; static float texture_coord[] = { 0,1, 1,1, 1,0, 0,0 };
[ "chekelekov1@outlook.com" ]
chekelekov1@outlook.com
e35218d7bdf9ebd2d2a85a04f896fca56ef0c776
382cfe7e26143fe17e266a2d510752b25150e4d0
/inc/npnet.h
5bf1e0308fdf0b50939eddd326ca1a112bd73e21
[]
no_license
strin/NPnet
486b109daa6cb7f7712149cd27c762ac2ab15564
8599e2f1becaf59894b0e66f15818f8e1ca36dfc
refs/heads/master
2020-12-24T14:10:38.634142
2015-04-25T17:05:41
2015-04-25T17:05:41
33,399,249
0
0
null
null
null
null
UTF-8
C++
false
false
5,619
h
#ifndef NPNET_MAIN #define NPNET_MAIN #include <boost/python.hpp> #include <boost/any.hpp> #include <boost/random.hpp> // #include <boost/random/mersenne_twister.hpp> // #include <boost/random/discrete_distribution.hpp> #include <functional> #include <string> #include <vector> #include <random> #include <unordered_map> #include <armadillo> #include "matio.h" namespace arma { /* extension on randomness */ template<> double randn<double>() { return as_scalar(randn<colvec>(1)); } double randg(distr_param dist) { return as_scalar(randg<colvec>(1, dist)); } /* boost randomness */ namespace brand = boost::random; using randgen = boost::mt19937; static randgen global_rng; /* std randomness */ std::default_random_engine global_std_rng; template<class V> V randber(const V& p) { V res = p; typename V::const_iterator it = p.begin(); typename V::iterator rt = res.begin(); for(;it != p.end() and rt != res.end(); it++, rt++) { std::bernoulli_distribution rg(*it); *rt = rg(global_std_rng); } return res; } /* io with mat files */ std::unordered_map<std::string, boost::any> loadmat(std::string path) { mat_t* matfp; matvar_t* matvar; matfp = Mat_Open(path.c_str(),MAT_ACC_RDONLY); std::unordered_map<std::string, boost::any> res; if(matfp == nullptr) return res; while((matvar = Mat_VarReadNextInfo(matfp)) != nullptr) { std::string name(matvar->name); if(matvar->data_type == MAT_T_CELL) { throw "cell type not supported"; } else { if(matvar->class_type == MAT_C_DOUBLE and (matvar->rank == 2)) { int start[2] = {0, 0}; int stride[2] = {1, 1}; const int& n0 = matvar->dims[0]; const int& n1 = matvar->dims[1]; int edge[2] = {n0, n1}; static std::vector<double> x(n0 * n1); Mat_VarReadData(matfp, matvar, &x[0], start, stride, edge); mat x2(x); x2.reshape(n0, n1); res[name] = x2; } else if(matvar->class_type == MAT_C_DOUBLE and matvar->rank == 3) { int start[3] = {0, 0, 0}; int stride[3] = {1, 1, 1}; const int& n0 = matvar->dims[0]; const int& n1 = matvar->dims[1]; const int& n2 = matvar->dims[2]; int edge[3] = {n0, n1, n2}; static std::vector<double> x(n0 * n1 * n2); Mat_VarReadData(matfp, matvar, &x[0], start, stride, edge); cube x3(n1, n2, n0); for(int i = 0; i < n0; i++) { for(int j = 0; j < n1; j++) { for(int k = 0; k < n2; k++) { x3(j, k, i) = x[k * n0 * n1 + j * n0 + i]; } } } res[name] = x3; } else { throw "unknow type in mat"; } } Mat_VarFree(matvar); } return res; } } namespace NPnet { /* namespace resolution */ using str = std::string; template<class T> using vec = std::vector<T>; template<class T> using vec2d = vec<vec<T>>; template<class T> using ptr = std::shared_ptr<T>; using any = boost::any; template<class T, class... Args> ptr<T> make_shared(Args&&... args) { return ptr<T>(new T(std::forward<Args>(args)...)); } template<class K, class T> class map : public std::unordered_map<K, T> { public: bool contains(K key) { return this->find(key) != this->end(); } }; using param = map<str, any>; template<class T, class... Args> T extract(Args&&... args) { return boost::python::extract<T>(args...); } using namespace arma; /* boost python */ namespace bpy = boost::python; namespace bnp = boost::python::numeric; template<> mat extract<mat>(const bnp::array& arr) { bpy::tuple shape = static_cast<bpy::tuple>(arr.getshape()); if(bpy::len(shape) != 2) { throw "unable to extract: array shape size is not 2."; } int nrows = bpy::extract<int>(shape[0]), ncols = bpy::extract<int>(shape[1]); mat res = zeros(nrows, ncols); for(int i = 0; i < nrows; i++) { for(int j = 0; j < ncols; j++) { res(i,j) = bpy::extract<double>(arr[bpy::make_tuple(i, j)]); } } return res; } /* activation function */ auto sigmoid = [] (const colvec& x) { colvec y = x; for(auto& elem : y) { elem = 1/(1+exp(-elem)); } return y; }; auto inv_sigmoid = [] (const colvec& y) { colvec x = y; for(auto& elem : x) { x = log(elem) - log(1-elem); } return x; }; /* arma randomness */ static inline double randint(int a, int b) { return as_scalar(randi(1, distr_param(a,b))); } } #endif
[ "stl501@gmail.com" ]
stl501@gmail.com
6a8ee804717ee5079bd225edf379e0c9f36b75bb
c3a424748ca2a3bc8604d76f1bf70ff3fee40497
/legacy_POL_source/oldPOL2_2007/src/pol/vital.h
d7b2401c784cedfa3b7c2cb84da27c26e3b98566
[]
no_license
polserver/legacy_scripts
f597338fbbb654bce8de9c2b379a9c9bd4698673
98ef8595e72f146dfa6f5b5f92a755883b41fd1a
refs/heads/master
2022-10-25T06:57:37.226088
2020-06-12T22:52:22
2020-06-12T22:52:22
23,924,142
4
0
null
null
null
null
UTF-8
C++
false
false
1,290
h
// History // 2005/09/14 Shinigami: regen_while_dead implemented #ifndef VITAL_H #define VITAL_H #include <string> #include <vector> class ConfigElem; class ExportedFunction; class Package; class Vital { public: Vital( const Package* pkg, ConfigElem& elem ); const Package* pkg; std::string name; std::vector< std::string > aliases; // aliases[0] is always name unsigned vitalid; Vital* next; ExportedFunction* get_regenrate_func; ExportedFunction* get_maximum_func; ExportedFunction* underflow_func; bool regen_while_dead; }; Vital* FindVital( const std::string& vitalname ); Vital* FindVital( unsigned vitalid ); extern std::vector< Vital* > vitals; extern unsigned numVitals; const int VITAL_LOWEST_REGENRATE = -30000; const int VITAL_HIGHEST_REGENRATE = 30000; const unsigned VITAL_MIN_VALUE = 0; const unsigned VITAL_MAX_VALUE = 100000L; const unsigned long VITAL_MAX_HUNDREDTHS = 10000000L; // 10,000,000 hundredths = 100,000.00 const unsigned long VITAL_LOWEST_MAX_HUNDREDTHS = 100L; // 100 hundredths = 1.00 const unsigned long VITAL_HIGHEST_MAX_HUNDREDTHS = 10000000L; // 10,000,000 hundredths = 100,000.00 // max vital: extern const Vital* pVitalLife; extern const Vital* pVitalStamina; extern const Vital* pVitalMana; #endif
[ "hopelivesproject@gmail.com" ]
hopelivesproject@gmail.com
8e195dc7773efb522926519bff5a3c5893e0a38c
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/3d/e0fc53f2046845/main.cpp
5d6b5a4df0d209d78b6bbc128c1b7821a8df2a82
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
538
cpp
#include <iostream> #include <string> bool is_double( const std::string& str ) { std::size_t pos ; try { std::stod( str, std::addressof(pos) ) ; return pos == str.size() ; // entire string has been consumed } catch( const std::exception& ) { return false ; } // error in conversion } int main() { for( std::string str : { "-123.456", "45fg", "1.0e-23", "inf", "nan", "", "0xab.cdP+55" } ) std::cout << '"' << str << "\" ? " << std::boolalpha << is_double(str) << '\n' ; }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
a159b3ac79fbbde62bb6be82f505f1fc0fa909d9
1546c3cfb0a767fa610746530e773f208954f831
/排七/Card.h
470c95db5adc498a072d31986f1a2395ed17889e
[]
no_license
Alisa1114/Object-oriented-Programming-Homework
aeb289a5062fe686c9d22b6426e0e2147367c03f
9ec2f354a13af0d87fd514df1ae8a5e960a963de
refs/heads/main
2023-04-27T07:18:07.969658
2021-04-28T16:22:56
2021-04-28T16:22:56
362,535,247
0
0
null
null
null
null
UTF-8
C++
false
false
382
h
#include <iostream> #include <string> #define L 10 #define W 11 #define MAX 52 #define N 12 using namespace std; class Card{ int _face, _suit; char picture[N][L][W]; public: Card(); void face(int); void suit(int); void drawHeart(int); void drawTile(int); void drawClover(int); void drawPike(int); void drawCard(int); void printCard(); };
[ "noreply@github.com" ]
Alisa1114.noreply@github.com
06082b7f7cbe81320c3e24b9ef37e63f0397c3b7
0c8327e3c194a5045462f38b28f4626ad009cba7
/qt_cpp_version/QtGeoIp/MainWindow.h
66d2210ed3aae5084ed6b144b6e79943d0d18063
[]
no_license
AndreMiras/py-qt-geo-ip
9ae25551e594d6fb8730b360066f1049f9b99040
2b98c88363d6184cea5717eb28591dff25f01fc2
refs/heads/master
2020-05-18T04:06:49.944809
2012-10-14T16:22:55
2012-10-14T16:22:55
33,007,696
0
0
null
null
null
null
UTF-8
C++
false
false
2,884
h
/* * File: MainWindow.h * Author: andre * * Created on September 23, 2012, 11:09 PM */ #ifndef _MAINWINDOW_H #define _MAINWINDOW_H #include "ui_main_window_ui.h" #include "CustomMarbleWidget.h" #include "PreferencesForm.h" #include "MapInstallerForm.h" #include <GeoIPCity.h> #include <QTimer> #include <QString> #include <QList> #include <QDir> using namespace Marble; using namespace std; const int defaultZoom = 1500; class MainWindow : public QMainWindow { Q_OBJECT public: static const string defaultGeoIpPath; static const string defaultMapTheme; MainWindow(); virtual ~MainWindow(); static QString getSettingsFilename(); static QString getLocalMarbleMapDir(); static QString getSystemMarbleMapDir(); static QString getRunningAppMapDataDir(); /** * Retrieves map themes files by looking in three locations: * - running application dedicated map data directory * - local Marble map data directory * - system Marble map data directory * @return List of map theme relative paths */ static QList<QString> getAllThemes(); /** * Retrieves the directory where is stored the given theme * @param theme * @return a directory string */ static QString getDirFromTheme(QString theme); private slots: /** * Geocodes IP: * - retrieves IP information * - places map marker from ip lat/long */ void geoCodeIp(); void updateZoom(); void updateMapTheme(); void openSettings(); void openMapInstaller(); void openDownloadMap(); void openDownloadGeoLite(); private: Ui::MainWindow widget; CustomMarbleWidget* marbleWidget; QTimer* updateZoomTimer; PreferencesForm* preferencesForm; MapInstallerForm* mapInstallerForm; static QString settingsFilename; static QDir localMarbleDir; static QDir systemMarbleDir; static QDir runningAppDataDir; void setupSignalsSlots(); /** * Setups marble widget */ void customSetupUi(); /** * Returns the ip information dictionary from ip. * @param ip * @return */ GeoIPRecord* get_ip_record(const string& ip); QString getMapTheme(); /** * Searches for *.dgml files in all sub directories * @param directory, directory to search from * @return a list of found map theme relative paths */ static QList<QString> getAllThemesIn(const QDir& directory); /** * Updates the IP information box labels. * @param record_by_addr */ void update_labels_from_record( const GeoIPRecord* record_by_addr); /** * Adds map marker from ip dictionary information (lat, long). * @param record_by_addr * @param ip */ void update_map_from_record( GeoIPRecord* record_by_addr, const std::string& ip); }; #endif /* _MAINWINDOW_H */
[ "andre.miras@gmail.com" ]
andre.miras@gmail.com
75326c7b2aa704fa700534f781ac24e115fd7314
2ba94892764a44d9c07f0f549f79f9f9dc272151
/Engine/Source/Developer/LogVisualizer/Public/ILogVisualizer.h
f622a3cb338d34896c0f1a457dddf5140368c037
[ "BSD-2-Clause", "LicenseRef-scancode-proprietary-license" ]
permissive
PopCap/GameIdea
934769eeb91f9637f5bf205d88b13ff1fc9ae8fd
201e1df50b2bc99afc079ce326aa0a44b178a391
refs/heads/master
2021-01-25T00:11:38.709772
2018-09-11T03:38:56
2018-09-11T03:38:56
37,818,708
0
0
BSD-2-Clause
2018-09-11T03:39:05
2015-06-21T17:36:44
null
UTF-8
C++
false
false
300
h
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once class ILogVisualizer : public IModuleInterface, public IModularFeature { public: virtual void Goto(float Timestamp, FName LogOwner = NAME_None) = 0; virtual void GotoNextItem() = 0; virtual void GotoPreviousItem() = 0; };
[ "dkroell@acm.org" ]
dkroell@acm.org
82f7a11679decae696adba57519a089f1fb702f1
24de7d4e0be5dd3688dc2f968322ffff86d2b1f9
/Lib.h
236a92d751ba5937ff63b43d653e443380c7da34
[]
no_license
john-smith/neural_network
a321faf66d25979779cf9ce4ecf5769d90488407
59b1c888f7f0c180c8893778837eda654134cf44
refs/heads/master
2020-05-19T10:52:09.329142
2014-02-23T11:59:26
2014-02-23T11:59:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
460
h
#ifndef __LIB_H__ #define __LIB_H__ #ifndef NULL #define NULL 0 #endif #define RELEASE(x) { if((x)) { delete (x); (x) = NULL; }} #define RELEASE_ARRAY(x) { if((x)) { delete [] (x); (x) = NULL; }} class Lib { static bool first; public: static double sigmoid(double input, double* alpha, int alphaSize); static double derivationSigmoid(double input, double* alpha, int alphaSize); static double rand(double min, double max); }; #endif
[ "wakai.hirofumi@gmail.com" ]
wakai.hirofumi@gmail.com
0ebecbe165d900e38f1be7d3ae0976d09298c695
1911d6f70cbaaaedf0321ed66224edcb97ed5767
/libccmyext/src/CCallFuncProxy.cpp
f5c7a98435e5f7737e63b60b12ed3dec9a86091c
[]
no_license
marszaya/huihe
bab451cde0c365defde50cbec2fffe6c8c5cfc0b
d1ac3b292ae588aea73a95cabf44f720c5f4437f
refs/heads/master
2021-01-19T22:33:03.491040
2014-01-22T08:24:23
2014-01-22T08:24:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,278
cpp
#include "CCallFuncProxy.h" CCECallFuncProxy::CCECallFuncProxy(void) { m_saveCmd = -1; } CCECallFuncProxy::CCECallFuncProxy(int cmd, CCEMsgDispatcher* p) { initCCECallFuncProxy(cmd, p); } CCECallFuncProxy::~CCECallFuncProxy(void) { if(m_saveDispatcher) m_saveDispatcher->release(); } CCECallFuncProxy* CCECallFuncProxy::create(int cmd, CCEMsgDispatcher* p) { CCECallFuncProxy *pRet = new CCECallFuncProxy(); if(pRet && pRet->initCCECallFuncProxy(cmd, p)) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; } bool CCECallFuncProxy::initCCECallFuncProxy(int cmd, CCEMsgDispatcher* p) { bool ret=false; do{ m_saveCmd = cmd; m_saveDispatcher = p; if(m_saveDispatcher == NULL) { m_saveDispatcher = CCEMsgDispatcher::getSharedInstance(); } if(!m_saveDispatcher) break; m_saveDispatcher->retain(); ret = true; }while(0); return ret; } void CCECallFuncProxy::callback() { if(m_saveDispatcher) { m_saveDispatcher->invokeCmd(this->m_saveCmd); } } void CCECallFuncProxy::callbackO(CCObject* p) { if(m_saveDispatcher) { m_saveDispatcher->invokeCmd(this->m_saveCmd, p); } } void CCECallFuncProxy::callbackN(CCNode* pn) { if(m_saveDispatcher) { m_saveDispatcher->invokeCmd(this->m_saveCmd, pn); } }
[ "zaya@qq.com" ]
zaya@qq.com
cb108fc3b6459afc3adfff36e2ef6b83ee63c254
5e007aa448d05ef39b1c7731a92be2075df09801
/ProjectWar/GameUI.h
2dfb25dd74981d0bb522c3610e80b2570d7615d1
[]
no_license
AlvaroChambi/ProjectAI
04a881047a1a7feabdd4850b09318c676e1686f1
b5a31d358d91a071ac857afb0c18ce25eb985687
refs/heads/develop
2020-04-03T23:31:43.567379
2016-09-19T10:03:14
2016-09-19T10:03:14
32,091,207
2
0
null
2016-09-12T19:40:59
2015-03-12T17:29:49
C++
UTF-8
C++
false
false
597
h
// // GameUI.h // ProjectWar // // Created by Alvaro Chambi Campos on 11/4/15. // Copyright (c) 2015 Alvaro Chambi Campos. All rights reserved. // #ifndef __ProjectWar__GameUI__ #define __ProjectWar__GameUI__ #include <stdio.h> #include "Layout.h" #include "Text.h" class GameUI : public Layout { public: GameUI(); virtual ~GameUI(); void setPlayerName(std::string playerName); void setPlayerFounds(int playerFounds); void setDay(int day); private: Text* playerName; Text* playerFounds; Text* day; }; #endif /* defined(__ProjectWar__GameUI__) */
[ "alvaro.chambi.campos@gmail.com" ]
alvaro.chambi.campos@gmail.com
9679a0aee58d0421c410eb66d11647579184b7e2
db2a9571cda4541f72d65528e3bb538528a6838c
/src/input_old/scrollers/joystick_scroller.hpp
cafeba1ff73c8138a733d922f37179605d1976fb
[]
no_license
mornage/Maemo-pingus
3b6545041e52adf687ed66caeda26a7768c14273
6bae291e9524c552745c67f2e944358e77ee4bcf
refs/heads/master
2016-09-03T06:58:35.601709
2010-08-10T19:59:08
2010-08-10T19:59:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,783
hpp
// $Id: joystick_scroller.hpp 2986 2007-08-17 16:20:09Z grumbel $ // // Pingus - A free Lemmings clone // Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef HEADER_PINGUS_INPUT_JOYSTICK_SCROLLER_HXX #define HEADER_PINGUS_INPUT_JOYSTICK_SCROLLER_HXX #include "../scroller.hpp" namespace Input { class Axis; namespace Scrollers { /** @brief maps the first two axes of a joystick into a Scroller XML definition: <joystick-scroller id="joystick id" speed="?"/> */ class JoystickScroller : public Scroller { private: int id; Axis* const axis1; Axis* const axis2; const float speed; float x_delta; float y_delta; public: JoystickScroller (int id_, float speed_); ~JoystickScroller (); const float& get_x_delta () const; const float& get_y_delta () const; void get_delta (float& x, float& y) const; void update (float delta); private: JoystickScroller (const JoystickScroller&); JoystickScroller& operator= (const JoystickScroller&); }; } // namespace Pointers } // namespace Input #endif /* EOF */
[ "neilkirk@hotmail.co.uk" ]
neilkirk@hotmail.co.uk
e4b5639b0c14e90d4379d03a8c8bf013177e9c60
515756675f130c5f7cf356fcb187104576bd4abf
/andEnginePhysicsBox2DExtension/src/main/jni/Box2D/Dynamics/b2ContactManager.cpp
fc6dedc0dd93482ddeff9e6187ffe09e4fb24b39
[]
no_license
stephtelolahy/AndEngineDemo
0a87e56b19d3113640ebef2abd1677001f56e7f4
d8a492323479b77c6da80a393e39948bd77376c4
refs/heads/master
2020-12-26T03:01:21.121824
2014-10-29T18:52:08
2014-10-29T19:07:01
25,823,289
2
1
null
null
null
null
UTF-8
C++
false
false
7,280
cpp
/* * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #include "Box2D/Dynamics/b2ContactManager.h" #include "Box2D/Dynamics/b2Body.h" #include "Box2D/Dynamics/b2Fixture.h" #include "Box2D/Dynamics/b2WorldCallbacks.h" #include "Box2D/Dynamics/Contacts/b2Contact.h" b2ContactFilter b2_defaultFilter; b2ContactListener b2_defaultListener; b2ContactManager::b2ContactManager() { m_contactList = NULL; m_contactCount = 0; m_contactFilter = &b2_defaultFilter; m_contactListener = &b2_defaultListener; m_allocator = NULL; } void b2ContactManager::Destroy(b2Contact* c) { b2Fixture* fixtureA = c->GetFixtureA(); b2Fixture* fixtureB = c->GetFixtureB(); b2Body* bodyA = fixtureA->GetBody(); b2Body* bodyB = fixtureB->GetBody(); if (m_contactListener && c->IsTouching()) { m_contactListener->EndContact(c); } // Remove from the world. if (c->m_prev) { c->m_prev->m_next = c->m_next; } if (c->m_next) { c->m_next->m_prev = c->m_prev; } if (c == m_contactList) { m_contactList = c->m_next; } // Remove from body 1 if (c->m_nodeA.prev) { c->m_nodeA.prev->next = c->m_nodeA.next; } if (c->m_nodeA.next) { c->m_nodeA.next->prev = c->m_nodeA.prev; } if (&c->m_nodeA == bodyA->m_contactList) { bodyA->m_contactList = c->m_nodeA.next; } // Remove from body 2 if (c->m_nodeB.prev) { c->m_nodeB.prev->next = c->m_nodeB.next; } if (c->m_nodeB.next) { c->m_nodeB.next->prev = c->m_nodeB.prev; } if (&c->m_nodeB == bodyB->m_contactList) { bodyB->m_contactList = c->m_nodeB.next; } // Call the factory. b2Contact::Destroy(c, m_allocator); --m_contactCount; } // This is the top level collision call for the time step. Here // all the narrow phase collision is processed for the world // contact list. void b2ContactManager::Collide() { // Update awake contacts. b2Contact* c = m_contactList; while (c) { b2Fixture* fixtureA = c->GetFixtureA(); b2Fixture* fixtureB = c->GetFixtureB(); int32 indexA = c->GetChildIndexA(); int32 indexB = c->GetChildIndexB(); b2Body* bodyA = fixtureA->GetBody(); b2Body* bodyB = fixtureB->GetBody(); // Is this contact flagged for filtering? if (c->m_flags & b2Contact::e_filterFlag) { // Should these bodies collide? if (bodyB->ShouldCollide(bodyA) == false) { b2Contact* cNuke = c; c = cNuke->GetNext(); Destroy(cNuke); continue; } // Check user filtering. if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false) { b2Contact* cNuke = c; c = cNuke->GetNext(); Destroy(cNuke); continue; } // Clear the filtering flag. c->m_flags &= ~b2Contact::e_filterFlag; } bool activeA = bodyA->IsAwake() && bodyA->m_type != b2_staticBody; bool activeB = bodyB->IsAwake() && bodyB->m_type != b2_staticBody; // At least one body must be awake and it must be dynamic or kinematic. if (activeA == false && activeB == false) { c = c->GetNext(); continue; } int32 proxyIdA = fixtureA->m_proxies[indexA].proxyId; int32 proxyIdB = fixtureB->m_proxies[indexB].proxyId; bool overlap = m_broadPhase.TestOverlap(proxyIdA, proxyIdB); // Here we destroy contacts that cease to overlap in the broad-phase. if (overlap == false) { b2Contact* cNuke = c; c = cNuke->GetNext(); Destroy(cNuke); continue; } // The contact persists. c->Update(m_contactListener); c = c->GetNext(); } } void b2ContactManager::FindNewContacts() { m_broadPhase.UpdatePairs(this); } void b2ContactManager::AddPair(void* proxyUserDataA, void* proxyUserDataB) { b2FixtureProxy* proxyA = (b2FixtureProxy*)proxyUserDataA; b2FixtureProxy* proxyB = (b2FixtureProxy*)proxyUserDataB; b2Fixture* fixtureA = proxyA->fixture; b2Fixture* fixtureB = proxyB->fixture; int32 indexA = proxyA->childIndex; int32 indexB = proxyB->childIndex; b2Body* bodyA = fixtureA->GetBody(); b2Body* bodyB = fixtureB->GetBody(); // Are the fixtures on the same body? if (bodyA == bodyB) { return; } // TODO_ERIN use a hash table to remove a potential bottleneck when both // bodies have a lot of contacts. // Does a contact already exist? b2ContactEdge* edge = bodyB->GetContactList(); while (edge) { if (edge->other == bodyA) { b2Fixture* fA = edge->contact->GetFixtureA(); b2Fixture* fB = edge->contact->GetFixtureB(); int32 iA = edge->contact->GetChildIndexA(); int32 iB = edge->contact->GetChildIndexB(); if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) { // A contact already exists. return; } if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) { // A contact already exists. return; } } edge = edge->next; } // Does a joint override collision? Is at least one body dynamic? if (bodyB->ShouldCollide(bodyA) == false) { return; } // Check user filtering. if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false) { return; } // Call the factory. b2Contact* c = b2Contact::Create(fixtureA, indexA, fixtureB, indexB, m_allocator); if (c == NULL) { return; } // Contact creation may swap fixtures. fixtureA = c->GetFixtureA(); fixtureB = c->GetFixtureB(); indexA = c->GetChildIndexA(); indexB = c->GetChildIndexB(); bodyA = fixtureA->GetBody(); bodyB = fixtureB->GetBody(); // Insert into the world. c->m_prev = NULL; c->m_next = m_contactList; if (m_contactList != NULL) { m_contactList->m_prev = c; } m_contactList = c; // Connect to island graph. // Connect to body A c->m_nodeA.contact = c; c->m_nodeA.other = bodyB; c->m_nodeA.prev = NULL; c->m_nodeA.next = bodyA->m_contactList; if (bodyA->m_contactList != NULL) { bodyA->m_contactList->prev = &c->m_nodeA; } bodyA->m_contactList = &c->m_nodeA; // Connect to body B c->m_nodeB.contact = c; c->m_nodeB.other = bodyA; c->m_nodeB.prev = NULL; c->m_nodeB.next = bodyB->m_contactList; if (bodyB->m_contactList != NULL) { bodyB->m_contactList->prev = &c->m_nodeB; } bodyB->m_contactList = &c->m_nodeB; // Wake up the bodies bodyA->SetAwake(true); bodyB->SetAwake(true); ++m_contactCount; }
[ "stephano.telolahy@gmail.com" ]
stephano.telolahy@gmail.com
bc93de7e5cfe3f6209703d882c79eaea7da1b22a
b98ab618a740a80f209c9274fc52720b28c88982
/Files/Binary_Files.cpp
1edcc8d7c69e7b65233def913b94072acba2076f
[]
no_license
QuintenBruynseraede/CPlusPlus
bc59e9e56424c893b0f876a6a4f65825fe597beb
429959e56ffb5a38ac6cc2310b0748291877edef
refs/heads/master
2020-11-30T06:22:27.721703
2020-06-10T12:29:40
2020-06-10T12:29:40
230,331,070
0
0
null
null
null
null
UTF-8
C++
false
false
1,229
cpp
#include <iostream> #include <fstream> using namespace std; //Struct to write to file //All members are public by default! //Structs are padded for efficiency //#pragma pack(push,1) disables this padding //Struct is now aligned in chunks of 1 bytes #pragma pack(push,1) struct Person { char name[50]; int age; double weight; }; //Re-enable padding as normal #pragma pack(pop) int main() { Person me = {"Quinten", 21,73.0}; string fileName = "test.bin"; /** WRITE FILE **/ ofstream output; output.open(fileName, ios::binary); if (!output.is_open()) { cout << "Error opening " << fileName << endl; return 1; } //output.write((char *)&me,sizeof(Person)); output.write(reinterpret_cast<char *>(&me),sizeof(Person)); output.close(); /** READ FILE **/ ifstream input; input.open(fileName, ios::binary); if (!input.is_open()) { cout << "Error opening " << fileName << endl; return 1; } Person newPerson; input.read(reinterpret_cast<char *>(&newPerson),sizeof(Person)); cout << newPerson.name << endl; cout << newPerson.age << endl; cout << newPerson.weight << endl; return 0; }
[ "quinten.bruynseraede@student.kuleuven.be" ]
quinten.bruynseraede@student.kuleuven.be
f14b7784354714f61d41d614145d81b3bbb87e58
92636e2579e89b1a292358ab9d161b86beae0a21
/src/ObjCylinder.h
2438539382307ad2f8ace178034c2251bb383ed5
[ "BSD-3-Clause" ]
permissive
khutchins/Naive-Raytracer
2185214cebc544d88cef24c5481528621f2f16d1
fcdb37a611ffecd54ed1aa39ca7e2fd8e190c16d
refs/heads/master
2021-01-01T05:51:23.180092
2016-12-05T23:20:43
2016-12-05T23:20:43
2,922,851
0
0
null
null
null
null
UTF-8
C++
false
false
439
h
#ifndef _CYLINDER_H_ #define _CYLINDER_H_ #include "ObjContainerObject.h" #include "VectorMath.h" #include "StringProcessing.h" #include "Point.h" #include "Material.h" #include "Diagnostic.h" #include "ObjDisk.h" #include "ObjTube.h" #include <fstream> #include <string> #include <queue> #include <cstdlib> using namespace std; class Cylinder : public ContainerObject { public: Vector up; explicit Cylinder(ifstream &f); }; #endif
[ "possessedcow@gmail.com" ]
possessedcow@gmail.com
b0c9257a7d8c63e2398ac295922af38ea4e38562
c6626e631f53930c0b819a5daec1c7af8b28f01b
/PineconesSystemCode/AirQuality.cpp
72d473e074922a9fe22fab16adaae6f1a82ab190
[]
no_license
briah667/Group_GPS_and_Enviromental_Data_System
aa1936a90c6ad5450cf9e79ddb35e0c23cf2e07b
a1acfdaa22736a50bdb2eb022c38c232528ea4d2
refs/heads/master
2020-04-13T13:01:16.466442
2018-12-31T21:20:41
2018-12-31T21:20:41
163,218,307
0
0
null
null
null
null
UTF-8
C++
false
false
3,700
cpp
/* AirQuality library v1.0 2010 Copyright (c) Seeed Technology Inc. All right reserved. Original Author: Bruce.Qin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include"Arduino.h" #include"AirQuality.h" //Get the avg voltage in 5 minutes. void AirQuality::avgVoltage() { if(i==150)//sum 5 minutes { vol_standard=temp/150; temp=0; //Serial.print("Vol_standard in 5 minutes:"); //Serial.println(vol_standard); i=0; } else { temp+=first_vol; i++; } } void AirQuality::init(int pin) { _pin=pin; pinMode(_pin,INPUT); unsigned char i=0; delay(3000); //Serial.println("air qual sys_starting..."); delay(20000);//200000 init_voltage=analogRead(_pin); //Serial.println("The init voltage is ..."); //Serial.println(init_voltage); while(init_voltage) { if(init_voltage<798 && init_voltage>10)// the init voltage is ok { first_vol=analogRead(A0);//initialize first value last_vol=first_vol; vol_standard=last_vol; //Serial.println("Sensor ready."); error=false;; break; } else if(init_voltage>798||init_voltage<=10) { i++; //Serial.println("waitting sensor init..(it takes 60 seconds to init)"); delay(60000);//60000 init_voltage=analogRead(A0); if(i==5) { i=0; error=true; // Serial.println("Sensor Error!"); } } else break; } //init the timer TCCR1A=0;//normal model TCCR1B=0x02;//set clock as 8*(1/16M) TIMSK1=0x01;//enable overflow interrupt //Serial.println("Test begin..."); sei(); } int AirQuality::slope(void) { while(timer_index) { if(first_vol-last_vol>400||first_vol>700) { //Serial.println("High pollution! Force signal active."); timer_index=0; avgVoltage(); return 0; } else if((first_vol-last_vol>400&&first_vol<700)||first_vol-vol_standard>150) { //Serial.println("sensor_value:"); // Serial.println(first_vol); //Serial.println("\t High pollution!"); timer_index=0; avgVoltage(); return 1; } else if((first_vol-last_vol>200&&first_vol<700)||first_vol-vol_standard>50) { //Serial.println(first_vol-last_vol); //Serial.println("sensor_value:"); //Serial.println(first_vol); //Serial.println("\t Low pollution!"); timer_index=0; avgVoltage(); return 2; } else { avgVoltage(); //Serial.println("sensor_value:"); //Serial.println(first_vol); //Serial.println("\t Air fresh"); timer_index=0; return 3; } } return -1; }
[ "noreply@github.com" ]
briah667.noreply@github.com
c52d5250c38021aaf465a326b8ee2c7404bc5979
7896eb703cc63b3af0d52971853cd5ddae2e03f0
/datatype/int256.h
54e6ec22534f77de28aff5725a736e8ae1e91acc
[]
no_license
thiagotei/cudaSpmv
98db5c2ea367b5f9ebd36a4d0484e27896e633eb
b67dd52a17e583431a86aa3e7afbfc9a238908a3
refs/heads/master
2021-05-25T08:39:26.428047
2018-06-08T01:22:07
2018-06-08T01:22:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,322
h
#ifndef INT256 #define INT256 #include <fstream> #include <iostream> using namespace std; class Int256 { public: ulong4 m; __host__ __device__ Int256() { } __host__ __device__ Int256( const int val ) { *this = val; } __host__ __device__ Int256( const ulong4& val ) { m = val; } __host__ __device__ Int256( const uint4 val1, const uint4 val2) { m.x = ((long)val1.y << 32) | val1.x; m.y = ((long)val1.w << 32) | val1.z; m.z = ((long)val2.y << 32) | val2.x; m.w = ((long)val2.w << 32) | val2.z; } __host__ __device__ Int256( const Int256& val ) { *this = val; } __host__ __device__ Int256& operator =(const Int256& input ) { m = input.m; return *this; } __host__ __device__ Int256& operator =( const int& input ) { m = make_ulong4(0, 0, 0, input); return *this; } __host__ __device__ bool operator ==(const unsigned int input) { return (m.x == 0) && (m.y == 0) && (m.z == 0) && (m.w == input); } __host__ __device__ bool operator !=(const unsigned int input ) { return (m.x != 0) || (m.y != 0) || (m.z != 0) || (m.w != input); } __host__ __device__ Int256& operator ^=( const Int256& input ) { m.x^=input.m.x; m.y^=input.m.y; m.z^=input.m.z; m.w^=input.m.w; return *this; } __host__ __device__ Int256 operator ^( const Int256& input ) { ulong4 n; n.x = m.x ^ input.m.x; n.y = m.y ^ input.m.y; n.z = m.z ^ input.m.z; n.w = m.w ^ input.m.w; return Int256(n); } friend ifstream & operator >>(ifstream &ins, Int256 &input) { ins >> input.m.x >> input.m.y >> input.m.z >> input.m.w; return ins; } friend ostream & operator <<(ostream &out, Int256 &input) { out << input.m.x <<" "<<input.m.y<<" "<<input.m.z<<" "<<input.m.w; return out; } __host__ __device__ static void volatile_xor(volatile Int256& input, const Int256& rhs) { input.m.x ^= rhs.m.x; input.m.y ^= rhs.m.y; input.m.z ^= rhs.m.z; input.m.w ^= rhs.m.w; } __host__ __device__ static void volatile_xor(volatile Int256& input, const volatile Int256& rhs) { input.m.x ^= rhs.m.x; input.m.y ^= rhs.m.y; input.m.z ^= rhs.m.z; input.m.w ^= rhs.m.w; } __host__ __device__ static void volatile_set(volatile Int256& input, const Int256& rhs) { input.m.x = rhs.m.x; input.m.y = rhs.m.y; input.m.z = rhs.m.z; input.m.w = rhs.m.w; } __host__ __device__ static void volatile_set(Int256& input, const volatile Int256& rhs) { input.m.x = rhs.m.x; input.m.y = rhs.m.y; input.m.z = rhs.m.z; input.m.w = rhs.m.w; } }; #endif
[ "danghvu@gmail.com" ]
danghvu@gmail.com
c43afea92d5af7c27c5db49423066061ec8206b1
80925e65b4662d35c21485758a298c5962b9cc9e
/openGeeL/dependencies/bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
063b45d548ec1f57db8db081bfd3385a18b4241f
[]
no_license
BobDeng1974/openGeeL
d88fbc3ea9acc6ec42b85e59a74ffc6305f07ee5
b59f0206e30f233c2e2776dd3eebd095300aa0ad
refs/heads/master
2021-09-25T08:53:46.827995
2018-10-19T20:52:12
2018-10-19T20:52:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,568
h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef BT_COLLISION__DISPATCHER_H #define BT_COLLISION__DISPATCHER_H #include "BulletCollision/BroadphaseCollision/btDispatcher.h" #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" #include "BulletCollision/CollisionDispatch/btManifoldResult.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include "LinearMath/btAlignedObjectArray.h" class btIDebugDraw; class btOverlappingPairCache; class btPoolAllocator; class btCollisionConfiguration; #include "btCollisionCreateFunc.h" #define USE_DISPATCH_REGISTRY_ARRAY 1 class btCollisionDispatcher; ///user can override this nearcallback for collision filtering and more finegrained control over collision detection typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo); ///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs. ///RenderTime of Impact, Closest Points and Penetration Depth. class btCollisionDispatcher : public btDispatcher { protected: int m_dispatcherFlags; btAlignedObjectArray<btPersistentManifold*> m_manifoldsPtr; btManifoldResult m_defaultManifoldResult; btNearCallback m_nearCallback; btPoolAllocator* m_collisionAlgorithmPoolAllocator; btPoolAllocator* m_persistentManifoldPoolAllocator; btCollisionAlgorithmCreateFunc* m_doubleDispatchContactPoints[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; btCollisionAlgorithmCreateFunc* m_doubleDispatchClosestPoints[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; btCollisionConfiguration* m_collisionConfiguration; public: enum DispatcherFlags { CD_STATIC_STATIC_REPORTED = 1, CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2, CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4 }; int getDispatcherFlags() const { return m_dispatcherFlags; } void setDispatcherFlags(int flags) { m_dispatcherFlags = flags; } ///registerCollisionCreateFunc allows registration of custom/alternative collision create functions void registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc); void registerClosestPointsCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc); int getNumManifolds() const { return int( m_manifoldsPtr.size()); } btPersistentManifold** getInternalManifoldPointer() { return m_manifoldsPtr.size()? &m_manifoldsPtr[0] : 0; } btPersistentManifold* getManifoldByIndexInternal(int index) { return m_manifoldsPtr[index]; } const btPersistentManifold* getManifoldByIndexInternal(int index) const { return m_manifoldsPtr[index]; } btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration); virtual ~btCollisionDispatcher(); virtual btPersistentManifold* getNewManifold(const btCollisionObject* b0,const btCollisionObject* b1); virtual void releaseManifold(btPersistentManifold* manifold); virtual void clearManifold(btPersistentManifold* manifold); btCollisionAlgorithm* findAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btPersistentManifold* sharedManifold, ebtDispatcherQueryType queryType); virtual bool needsCollision(const btCollisionObject* body0,const btCollisionObject* body1); virtual bool needsResponse(const btCollisionObject* body0,const btCollisionObject* body1); virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ; void setNearCallback(btNearCallback nearCallback) { m_nearCallback = nearCallback; } btNearCallback getNearCallback() const { return m_nearCallback; } //by default, Bullet will use this near callback static void defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo); virtual void* allocateCollisionAlgorithm(int size); virtual void freeCollisionAlgorithm(void* ptr); btCollisionConfiguration* getCollisionConfiguration() { return m_collisionConfiguration; } const btCollisionConfiguration* getCollisionConfiguration() const { return m_collisionConfiguration; } void setCollisionConfiguration(btCollisionConfiguration* config) { m_collisionConfiguration = config; } virtual btPoolAllocator* getInternalManifoldPool() { return m_persistentManifoldPoolAllocator; } virtual const btPoolAllocator* getInternalManifoldPool() const { return m_persistentManifoldPoolAllocator; } }; #endif //BT_COLLISION__DISPATCHER_H
[ "s9rathei@stud.uni-saarland.de" ]
s9rathei@stud.uni-saarland.de
980c0fff12495ec8b9707cd1ccb27a60f8759c8e
0341aa816190faa367c2b97fb016295142f34b49
/tp1/signals/signal-handler/main.cpp
caf202dd9c2c85458eec38c08823d33bb3b015be
[]
no_license
PauloHMattos/distributed-systems
2ce8cc58b64e049b6c57057d0b156d28010f1e31
b094cdc0de9f2768231e3bc8b29d2cc8ef08f1b4
refs/heads/main
2023-08-18T14:29:04.575604
2021-10-13T02:14:19
2021-10-13T02:14:19
389,124,074
0
0
null
2021-10-13T02:14:20
2021-07-24T14:53:04
C++
UTF-8
C++
false
false
1,305
cpp
#include <signal.h> #include <unistd.h> #include <iostream> using namespace std; int received_signum = 0; void signalHandler(int signum) { received_signum = signum; } void registerSignals() { signal(SIGINT, signalHandler); signal(SIGUSR1, signalHandler); signal(SIGUSR2, signalHandler); } int listenForSignals(int execution_mode) { cout << "This process ID is: " << getpid() << "\n"; cout << "Listening for signals SIGINT, SIGUSR1 and SIGUSR2...\n"; while (1) { // Move program to wait state in case the user // has selected blocking wait mode. if (execution_mode == 2) { pause(); } while (received_signum != 0) { if (received_signum == SIGINT) { cout << "Received signal: " << received_signum << "\n"; cout << "Stopping execution...\n"; return 0; } else { cout << "Received signal: " << received_signum << "\n"; received_signum = 0; } } } } int main(void) { int execution_mode; cout << "Pick an execution mode:\n"; cout << " 1 - Busy wait;\n"; cout << " 2 - Blocking wait;\n"; cin >> execution_mode; registerSignals(); return listenForSignals(execution_mode); }
[ "gabriel.oliveira@cern.ch" ]
gabriel.oliveira@cern.ch
6c4d54ced1f34e4dd53c86c098691b0d388434e4
24cebd5d69d035044fb98a990525312cb9814bc1
/library/utility/math/test/average_test.cpp
f1fe7fb575dd681f4a1d1e987d878aa7ffe93e09
[ "Apache-2.0" ]
permissive
harmandersihra/SJSU-Dev2
0a66650649912ca5a2c4e710eab09321e1927be5
d5e71dd4a4c4614a9806c7b45526b108e5b23cda
refs/heads/master
2021-06-23T02:08:22.175064
2020-12-22T20:35:08
2020-12-22T21:25:25
173,637,542
0
0
Apache-2.0
2019-03-03T22:26:49
2019-03-03T22:26:49
null
UTF-8
C++
false
false
2,099
cpp
#include <cstdint> #include "L4_Testing/testing_frameworks.hpp" #include "utility/math/average.hpp" namespace sjsu { #define APPROX_EQUALITY(expected, actual, resolution) \ CHECK(-resolution < (actual - expected)); \ CHECK((actual - expected) < resolution); #define COMPILETIME_STATIC_ASSERT(expected, actual, resolution) \ static_assert(-resolution < (actual-expected)); \ static_assert(resolution > (actual-expected)); TEST_CASE("Testing Average Function") { // Static_assert is used to make sure that the functions work at compile // time. constexpr float kResolution = 0.001f; constexpr float kExpectedZero = 6; constexpr float kAvgZero = Average({6, 6, 6, 6}); APPROX_EQUALITY(kExpectedZero, kAvgZero, kResolution); COMPILETIME_STATIC_ASSERT(kExpectedZero, kAvgZero, kResolution); constexpr float kExpectedOne = 6.34775f; constexpr float kAvgOne = Average({6.12f, 6.45f, 6.366f, 6.455f}); APPROX_EQUALITY(kExpectedOne, kAvgOne, kResolution); COMPILETIME_STATIC_ASSERT(kExpectedOne, kAvgOne, kResolution); constexpr float kExpectedTwo = 2.09325f; constexpr float kAvgTwo = Average({0.6f, 0.003f, 1.77f, 6.0f}); APPROX_EQUALITY(kExpectedTwo, kAvgTwo, kResolution); COMPILETIME_STATIC_ASSERT(kExpectedTwo, kAvgTwo, kResolution); const float kArray[] = {1.1f, 3.4f, 5.2f}; const float kExpectedThree = 3.233f; const float kAvgThree = Average(kArray, std::size(kArray)); APPROX_EQUALITY(kExpectedThree, kAvgThree, kResolution); const float kAvgFour = Average(kArray); APPROX_EQUALITY(kExpectedThree, kAvgFour, kResolution); constexpr float kArray1[] = {100, 450, 200, 67000, 80000}; constexpr float kExpectedFive = 29550; constexpr float kAvgFive = Average(kArray1); APPROX_EQUALITY(kExpectedFive, kAvgFive, kResolution); COMPILETIME_STATIC_ASSERT(kExpectedFive, kAvgFive, kResolution); const float kArray2[] = {1.689f, 450, 2.666f, 6700, 8000}; const float kExpectedSix = 3030.871f; const float kAvgSix = Average(kArray2, std::size(kArray2)); APPROX_EQUALITY(kExpectedSix, kAvgSix, kResolution); } } // namespace sjsu
[ "kammcecorp@gmail.com" ]
kammcecorp@gmail.com
a171f2a9837f72e6efd80eadf98f3de1bd6258b5
cac6a4d25ee7042e4a5e9e410a2b60f4b27798a1
/tests/ParserTests.cpp
8f1d56556eb96128bf96f2f027862d2cc3a63ae6
[ "MIT" ]
permissive
kamilsan/lazy-interpreted-language
0489c7fdc18205bfd72c42db1bf0944c0fc8d78d
8c98da312cbbdd9e5173ba6ad324a5496fe86b83
refs/heads/master
2022-09-08T03:50:31.469439
2020-06-01T13:41:51
2020-06-01T13:41:51
268,524,867
2
0
null
null
null
null
UTF-8
C++
false
false
27,705
cpp
#include <gtest/gtest.h> #include <sstream> #include <functional> #include "Parser.hpp" #include "PrintVisitor.hpp" void setupTest(const std::string& source, std::function<std::unique_ptr<Node>(Parser*)> function, std::unique_ptr<Node> expectedNode) { std::stringstream ss{source}; Parser parser{ss}; const auto result = function(&parser); std::stringstream outputA{}; PrintVisitor visitorA{outputA}; result->accept(visitorA); std::stringstream outputB{}; PrintVisitor visitorB{outputB}; expectedNode->accept(visitorB); EXPECT_EQ(outputA.str(), outputB.str()); } void testThrow(const std::string& source, std::function<std::unique_ptr<Node>(Parser*)> function) { std::stringstream ss{source}; Parser parser{ss}; EXPECT_THROW(function(&parser), std::runtime_error); } TEST(ParserTest, SimpleTerms) { setupTest("42", &Parser::parseTerm, std::make_unique<NumericLiteralNode>(42)); setupTest("12.5", &Parser::parseTerm, std::make_unique<NumericLiteralNode>(12.5)); setupTest("x", &Parser::parseTerm, std::make_unique<VariableNode>("x")); } TEST(ParserTest, FunctionCalls) { const auto func = std::bind(&Parser::parseFunctionCall, std::placeholders::_1, std::optional<Token>{}); std::list<std::shared_ptr<ExpressionNode>> arguments{}; setupTest("f()", func, std::make_unique<FunctionCallNode>("f", std::move(arguments))); arguments = std::list<std::shared_ptr<ExpressionNode>>{}; arguments.push_back(std::make_unique<VariableNode>("x")); setupTest("xyz(x)", func, std::make_unique<FunctionCallNode>("xyz", std::move(arguments))); arguments = std::list<std::shared_ptr<ExpressionNode>>{}; arguments.push_back(std::make_shared<VariableNode>("x")); arguments.push_back(std::make_shared<NumericLiteralNode>(2)); arguments.push_back(std::make_shared<VariableNode>("z")); setupTest("g(x, 2, z)", func, std::make_unique<FunctionCallNode>("g", std::move(arguments))); } TEST(ParserTest, InvalidFunctionCallsThrow) { const auto func = std::bind(&Parser::parseFunctionCall, std::placeholders::_1, std::optional<Token>{}); testThrow("f(", func); testThrow("f)", func); testThrow("f(x,)", func); testThrow("f(x y)", func); testThrow("(x y)", func); } TEST(ParserTest, StringExpressions) { setupTest("\"test\"", &Parser::parseStringExpression, std::make_unique<StringLiteralNode>("test")); auto node = std::make_unique<BinaryOpNode>(std::make_unique<StringLiteralNode>("test"), BinaryOperator::Addition, std::make_unique<NumericLiteralNode>(2)); setupTest("\"test\" : 2", &Parser::parseStringExpression, std::move(node)); node = std::make_unique<BinaryOpNode>(std::make_unique<StringLiteralNode>("test"), BinaryOperator::Addition, std::make_unique<StringLiteralNode>("a")); setupTest("\"test\" : \"a\"", &Parser::parseStringExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<StringLiteralNode>("test"), BinaryOperator::Addition, std::make_unique<NumericLiteralNode>(2)), BinaryOperator::Addition, std::make_unique<StringLiteralNode>("a") ); setupTest("\"test\" : 2 : \"a\"", &Parser::parseStringExpression, std::move(node)); } TEST(ParserTest, SpecialFunctionCalls) { const auto func = std::bind(&Parser::parseFunctionCall, std::placeholders::_1, std::optional<Token>{}); std::list<std::shared_ptr<ExpressionNode>> arguments{}; arguments.push_back(std::make_unique<StringLiteralNode>("test")); setupTest("print(\"test\")", func, std::make_unique<FunctionCallNode>("print", std::move(arguments))); arguments = std::list<std::shared_ptr<ExpressionNode>>{}; arguments.push_back(std::make_unique<NumericLiteralNode>(1)); arguments.push_back(std::make_unique<NumericLiteralNode>(2)); arguments.push_back(std::make_unique<VariableNode>("z")); setupTest("if(1, 2, z)", func, std::make_unique<FunctionCallNode>("if", std::move(arguments))); } TEST(ParserTest, Unary) { auto node = std::make_unique<UnaryNode>(UnaryOperator::Minus, std::make_unique<NumericLiteralNode>(2)); setupTest("-2", &Parser::parseUnary, std::move(node)); node = std::make_unique<UnaryNode>(UnaryOperator::Minus, std::make_unique<VariableNode>("x")); setupTest("-x", &Parser::parseUnary, std::move(node)); node = std::make_unique<UnaryNode>(UnaryOperator::BinaryNegation, std::make_unique<VariableNode>("x")); setupTest("~x", &Parser::parseUnary, std::move(node)); } TEST(ParserTest, InvalidUnaryThrows) { testThrow("+x", &Parser::parseUnary); testThrow("--4", &Parser::parseUnary); } TEST(ParserTest, Factor) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(3)); setupTest("2 * 3", &Parser::parseFactor, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(5), BinaryOperator::Division, std::make_unique<NumericLiteralNode>(3)); setupTest("5 / 3", &Parser::parseFactor, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<UnaryNode>(UnaryOperator::Minus, std::make_unique<VariableNode>("x")), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(2)); setupTest("-x * 2", &Parser::parseFactor, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>(std::make_unique<VariableNode>("y"), BinaryOperator::Division, std::make_unique<VariableNode>("x")), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(2)); setupTest("y / x * 2", &Parser::parseFactor, std::move(node)); } TEST(ParserTest, AddExpr) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<NumericLiteralNode>(3)); setupTest("2 + 3", &Parser::parseAddExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(5), BinaryOperator::Subtraction, std::make_unique<NumericLiteralNode>(3)); setupTest("5 - 3", &Parser::parseAddExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<VariableNode>("x"), BinaryOperator::Modulo, std::make_unique<NumericLiteralNode>(2)); setupTest("x % 2", &Parser::parseAddExpression, std::move(node)); } TEST(ParserTest, ProperOperationOrder) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(3), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(4))); setupTest("2 + 3 * 4", &Parser::parseAddExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<NumericLiteralNode>(3)), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(4)); setupTest("(2 + 3) * 4", &Parser::parseAddExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(3), BinaryOperator::Subtraction, std::make_unique<NumericLiteralNode>(2)), BinaryOperator::Subtraction, std::make_unique<NumericLiteralNode>(1)); setupTest("3 - 2 - 1", &Parser::parseAddExpression, std::move(node)); } TEST(ParserTest, BinaryExpr) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::BinaryAnd, std::make_unique<NumericLiteralNode>(3)); setupTest("2 & 3", &Parser::parseArithmeticExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(5), BinaryOperator::BinaryOr, std::make_unique<NumericLiteralNode>(3)); setupTest("5 | 3", &Parser::parseArithmeticExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<VariableNode>("x"), BinaryOperator::BinaryXor, std::make_unique<NumericLiteralNode>(2)); setupTest("x ^ 2", &Parser::parseArithmeticExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(1), BinaryOperator::ShiftLeft, std::make_unique<NumericLiteralNode>(2)); setupTest("1 << 2", &Parser::parseArithmeticExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(1), BinaryOperator::ShiftRight, std::make_unique<NumericLiteralNode>(2)); setupTest("1 >> 2", &Parser::parseArithmeticExpression, std::move(node)); } TEST(ParserTest, ArithmeticExpr) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(3), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(4))), BinaryOperator::BinaryAnd, std::make_unique<NumericLiteralNode>(3)); setupTest("2 + 3 * 4 & 3", &Parser::parseArithmeticExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<NumericLiteralNode>(3)), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(4)), BinaryOperator::ShiftLeft, std::make_unique<NumericLiteralNode>(2)); setupTest("(2 + 3) * 4 << 2", &Parser::parseArithmeticExpression, std::move(node)); } TEST(ParserTest, InvalidArithmeticExprThrows) { testThrow("+x + 3", &Parser::parseArithmeticExpression); testThrow("42++", &Parser::parseArithmeticExpression); testThrow("10 +", &Parser::parseArithmeticExpression); testThrow("10 * (23 + 3", &Parser::parseArithmeticExpression); } TEST(ParserTest, SimpleComparisonExpr) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Equal, std::make_unique<NumericLiteralNode>(3)); setupTest("2 == 3", &Parser::parseComparisonExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(5), BinaryOperator::NotEqual, std::make_unique<NumericLiteralNode>(3)); setupTest("5 != 3", &Parser::parseComparisonExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<VariableNode>("x"), BinaryOperator::Greater, std::make_unique<NumericLiteralNode>(2)); setupTest("x > 2", &Parser::parseComparisonExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(1), BinaryOperator::Less, std::make_unique<NumericLiteralNode>(2)); setupTest("1 < 2", &Parser::parseComparisonExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(1), BinaryOperator::GreaterEq, std::make_unique<NumericLiteralNode>(2)); setupTest("1 >= 2", &Parser::parseComparisonExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(1), BinaryOperator::LessEq, std::make_unique<NumericLiteralNode>(1)); setupTest("1 <= 1", &Parser::parseComparisonExpression, std::move(node)); } TEST(ParserTest, ComplexComparisonExpr) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<NumericLiteralNode>(3)), BinaryOperator::Greater, std::make_unique<NumericLiteralNode>(5)); setupTest("2 + 3 > 5", &Parser::parseComparisonExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<NumericLiteralNode>(3)), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(4)), BinaryOperator::GreaterEq, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::BinaryXor, std::make_unique<NumericLiteralNode>(4))); setupTest("(2 + 3) * 4 >= 2 ^ 4", &Parser::parseComparisonExpression, std::move(node)); } TEST(ParserTest, UnaryLogical) { std::unique_ptr<ExpressionNode> node = std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Greater, std::make_unique<NumericLiteralNode>(3)); setupTest("(2 > 3)", &Parser::parseUnaryLogical, std::move(node)); node = std::make_unique<UnaryNode>( UnaryOperator::LogicalNot, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Greater, std::make_unique<NumericLiteralNode>(3))); setupTest("!(2 > 3)", &Parser::parseUnaryLogical, std::move(node)); node = std::make_unique<UnaryNode>( UnaryOperator::LogicalNot, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(1), BinaryOperator::Less, std::make_unique<NumericLiteralNode>(3))); setupTest("!1 < 3", &Parser::parseUnaryLogical, std::move(node)); } TEST(ParserTest, LogicalExpression) { auto node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::GreaterEq, std::make_unique<NumericLiteralNode>(5)), BinaryOperator::LogicalAnd, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Equal, std::make_unique<NumericLiteralNode>(2))); setupTest("2 >= 5 && 2 == 2", &Parser::parseLogicalExpression, std::move(node)); node = std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::LessEq, std::make_unique<NumericLiteralNode>(5)), BinaryOperator::LogicalOr, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Equal, std::make_unique<NumericLiteralNode>(2))), BinaryOperator::LogicalAnd, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(4), BinaryOperator::Greater, std::make_unique<NumericLiteralNode>(2))); setupTest("2 <= 5 || 2 == 2 && 4 > 2", &Parser::parseLogicalExpression, std::move(node)); } TEST(ParserTest, VariableDeclaration) { auto node = std::make_unique<VariableDeclarationNode>( "x", TypeName::F32, std::make_unique<NumericLiteralNode>(1) ); setupTest("let x: f32 = 1;", &Parser::parseVariableDeclaration, std::move(node)); node = std::make_unique<VariableDeclarationNode>( "xyz", TypeName::F32, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(2), BinaryOperator::Addition, std::make_unique<BinaryOpNode>( std::make_unique<NumericLiteralNode>(3), BinaryOperator::Multiplication, std::make_unique<NumericLiteralNode>(4)))); setupTest("let xyz: f32 = 2+3*4;", &Parser::parseVariableDeclaration, std::move(node)); } TEST(ParserTest, InvalidVariableDeclThrows) { testThrow("xyz: f32 = 2;", &Parser::parseVariableDeclaration); testThrow("let : f32 = 4;", &Parser::parseVariableDeclaration); testThrow("let x f32 = 6+4;", &Parser::parseVariableDeclaration); testThrow("let y: = 5;", &Parser::parseVariableDeclaration); testThrow("let h: f3fsg2 = 5;", &Parser::parseVariableDeclaration); testThrow("let d: f32 5;", &Parser::parseVariableDeclaration); testThrow("let k: f32 = ;", &Parser::parseVariableDeclaration); testThrow("let l: f32 = 6", &Parser::parseVariableDeclaration); testThrow("let let: f32 = 6;", &Parser::parseVariableDeclaration); testThrow("let if: f32 = 6;", &Parser::parseVariableDeclaration); testThrow("let print: f32 = 6;", &Parser::parseVariableDeclaration); testThrow("let f32: f32 = 6;", &Parser::parseVariableDeclaration); testThrow("let void: f32 = 6;", &Parser::parseVariableDeclaration); testThrow("let fn: f32 = 6;", &Parser::parseVariableDeclaration); testThrow("let function: f32 = 6;", &Parser::parseVariableDeclaration); } TEST(ParserTest, SimpleAssignment) { const auto func = std::bind(&Parser::parseAssignment, std::placeholders::_1, std::optional<Token>{}); const auto test = [func](const std::string& stringOp, AssignmentOperator op) { auto node = std::make_unique<AssignmentNode>( "x", op, std::make_unique<NumericLiteralNode>(3) ); setupTest("x" + stringOp + "3;", func, std::move(node)); }; test("=", AssignmentOperator::Assign); test("+=", AssignmentOperator::PlusEq); test("-=", AssignmentOperator::MinusEq); test("*=", AssignmentOperator::MulEq); test("/=", AssignmentOperator::DivEq); test("&=", AssignmentOperator::AndEq); test("|=", AssignmentOperator::OrEq); test("^=", AssignmentOperator::XorEq); test("<<=", AssignmentOperator::ShiftLeftEq); test(">>=", AssignmentOperator::ShiftRightEq); } TEST(ParserTest, InvalidAssignmentThrows) { const auto func = std::bind(&Parser::parseAssignment, std::placeholders::_1, std::optional<Token>{}); testThrow("= 3;", func); testThrow("y = ;", func); testThrow("y = 3", func); } TEST(ParserTest, ReturnStatement) { auto node = std::make_unique<ReturnNode>(std::make_unique<NumericLiteralNode>(12)); setupTest("ret 12;", &Parser::parseReturnStatement, std::move(node)); } TEST(ParserTest, InvalidReturnThrows) { testThrow("3;", &Parser::parseReturnStatement); testThrow("ret ;", &Parser::parseReturnStatement); testThrow("ret 3", &Parser::parseReturnStatement); } TEST(ParserTest, Block) { auto block = std::make_unique<BlockNode>(); block->addStatement(std::make_unique<ReturnNode>(std::make_unique<NumericLiteralNode>(12))); setupTest("{ ret 12; }", &Parser::parseBlock, std::move(block)); block = std::make_unique<BlockNode>(); block->addStatement( std::make_unique<VariableDeclarationNode>( "x", TypeName::F32, std::make_unique<NumericLiteralNode>(42))); setupTest("{ let x:f32=42; }", &Parser::parseBlock, std::move(block)); block = std::make_unique<BlockNode>(); block->addStatement( std::make_unique<AssignmentNode>( "x", AssignmentOperator::Assign, std::make_unique<NumericLiteralNode>(7))); setupTest("{ x=7; }", &Parser::parseBlock, std::move(block)); block = std::make_unique<BlockNode>(); auto args = std::list<std::shared_ptr<ExpressionNode>>{}; args.push_back(std::make_unique<StringLiteralNode>("test")); block->addStatement( std::make_unique<FunctionCallStatementNode>(std::make_unique<FunctionCallNode>( "print", std::move(args) ))); setupTest("{ print(\"test\"); }", &Parser::parseBlock, std::move(block)); block = std::make_unique<BlockNode>(); block->addStatement( std::make_unique<VariableDeclarationNode>( "x", TypeName::F32, std::make_unique<NumericLiteralNode>(42))); block->addStatement( std::make_unique<AssignmentNode>( "x", AssignmentOperator::Assign, std::make_unique<NumericLiteralNode>(7))); block->addStatement(std::make_unique<ReturnNode>(std::make_unique<NumericLiteralNode>(12))); setupTest("{ let x: f32 = 42; x=7; ret 12; }", &Parser::parseBlock, std::move(block)); } TEST(ParserTest, InvalidBlockThrows) { testThrow(" ret 3; }", &Parser::parseBlock); testThrow("{ f(); ", &Parser::parseBlock); testThrow("{ f(); ggdfh }", &Parser::parseBlock); testThrow("{ 4 }", &Parser::parseBlock); testThrow("{ 4+3; }", &Parser::parseBlock); } TEST(ParserTest, FunctionDeclaration) { std::list<std::pair<std::string, TypeName>> args{}; auto block = std::make_unique<BlockNode>(); auto node = std::make_unique<FunctionDeclarationNode>( "f", TypeName::F32, std::move(args), std::move(block) ); setupTest("fn f(): f32 {}", &Parser::parseFunctionDeclaration, std::move(node)); args = std::list<std::pair<std::string, TypeName>>{}; args.push_back(std::make_pair<std::string, TypeName>("x", TypeName::F32)); block = std::make_unique<BlockNode>(); node = std::make_unique<FunctionDeclarationNode>( "g", TypeName::F32, std::move(args), std::move(block) ); setupTest("fn g(x: f32): f32 {}", &Parser::parseFunctionDeclaration, std::move(node)); args = std::list<std::pair<std::string, TypeName>>{}; args.push_back(std::make_pair<std::string, TypeName>("x", TypeName::F32)); args.push_back(std::make_pair<std::string, TypeName>("y", TypeName::Function)); block = std::make_unique<BlockNode>(); block->addStatement(std::make_unique<ReturnNode>(std::make_unique<NumericLiteralNode>(12))); node = std::make_unique<FunctionDeclarationNode>( "g", TypeName::Void, std::move(args), std::move(block) ); setupTest("fn g(x: f32, y: function): void { ret 12; }", &Parser::parseFunctionDeclaration, std::move(node)); } TEST(ParserTest, InvalidFunctionDeclarationThrows) { testThrow("t(x: f32): f32 { }", &Parser::parseFunctionDeclaration); testThrow("fn (x:f32): f32 {}", &Parser::parseFunctionDeclaration); testThrow("fn t :f32): f32 {}", &Parser::parseFunctionDeclaration); testThrow("fn t(x f32) :f32 {}", &Parser::parseFunctionDeclaration); testThrow("fn f(x: f32) f32 {}", &Parser::parseFunctionDeclaration); testThrow("fn f(x: f32) : {}", &Parser::parseFunctionDeclaration); testThrow("fn f(x: f32, ): f32 {}", &Parser::parseFunctionDeclaration); testThrow("fn f(x: f32, y) : f32 {}", &Parser::parseFunctionDeclaration); testThrow("fn f(x: f32) : f32", &Parser::parseFunctionDeclaration); testThrow("fn f(x: f32) : f32 {", &Parser::parseFunctionDeclaration); testThrow("fn f(x: f32) : f32 }", &Parser::parseFunctionDeclaration); } TEST(ParserTest, LambdaDeclaration) { std::list<std::pair<std::string, TypeName>> args{}; auto block = std::make_unique<BlockNode>(); auto node = std::make_unique<LambdaNode>( TypeName::F32, std::move(args), std::move(block) ); setupTest("\\(): f32 = {}", &Parser::parseLambda, std::move(node)); args = std::list<std::pair<std::string, TypeName>>{}; args.push_back(std::make_pair<std::string, TypeName>("x", TypeName::F32)); block = std::make_unique<BlockNode>(); node = std::make_unique<LambdaNode>( TypeName::Void, std::move(args), std::move(block) ); setupTest("\\(x: f32): void = {}", &Parser::parseLambda, std::move(node)); } TEST(ParserTest, InvalidLambdaDeclarationThrows) { testThrow("(x: f32): f32 = { }", &Parser::parseLambda); testThrow("\\x:f32): f32 = {}", &Parser::parseLambda); testThrow("\\( :f32): f32 = {}", &Parser::parseLambda); testThrow("\\(x f32) :f32 = {}", &Parser::parseLambda); testThrow("\\(x:): f32 = {}", &Parser::parseLambda); testThrow("\\(x: f32) f32 = {}", &Parser::parseLambda); testThrow("\\(x: f32): = {}", &Parser::parseLambda); testThrow("\\(x: f32) : f32 {}", &Parser::parseLambda); testThrow("\\(x: f32) : f32 = {", &Parser::parseLambda); testThrow("\\f(x: f32) : f32 = {}", &Parser::parseLambda); testThrow("\\(x: f32) : f32 = }", &Parser::parseLambda); } TEST(ParserTest, CallingLambda) { const auto func = std::bind(&Parser::parseLambdaCall, std::placeholders::_1, false); std::list<std::pair<std::string, TypeName>> args{}; args.push_back(std::make_pair<std::string, TypeName>("x", TypeName::F32)); auto block = std::make_unique<BlockNode>(); auto lambda = std::make_unique<LambdaNode>( TypeName::Void, std::move(args), std::move(block) ); std::list<std::shared_ptr<ExpressionNode>> callArgs{}; callArgs.push_back(std::make_unique<NumericLiteralNode>(3)); auto node = std::make_unique<LambdaCallNode>(std::move(lambda), std::move(callArgs)); setupTest("(\\(x: f32): void = {})(3)", func, std::move(node)); } TEST(ParserTest, LambdaInVarDecl) { std::list<std::pair<std::string, TypeName>> args{}; args.push_back(std::make_pair<std::string, TypeName>("x", TypeName::F32)); auto block = std::make_unique<BlockNode>(); auto lambda = std::make_unique<LambdaNode>( TypeName::Void, std::move(args), std::move(block) ); auto node = std::make_unique<VariableDeclarationNode>( "x", TypeName::Function, std::move(lambda) ); setupTest("let x: function = \\(x: f32): void = {};", &Parser::parseVariableDeclaration, std::move(node)); } TEST(ParserTest, LambdaAsCallArgument) { const auto func = std::bind(&Parser::parseFunctionCall, std::placeholders::_1, std::optional<Token>{}); std::list<std::pair<std::string, TypeName>> args{}; args.push_back(std::make_pair<std::string, TypeName>("x", TypeName::F32)); auto block = std::make_unique<BlockNode>(); auto lambda = std::make_unique<LambdaNode>( TypeName::F32, std::move(args), std::move(block) ); std::list<std::shared_ptr<ExpressionNode>> callArgs{}; callArgs.push_back(std::move(lambda)); auto node = std::make_unique<FunctionCallNode>( "func", std::move(callArgs) ); setupTest("func(\\(x:f32): f32 = {})", func, std::move(node)); } TEST(ParserTest, AssignLambda) { const auto func = std::bind(&Parser::parseAssignment, std::placeholders::_1, std::optional<Token>{}); std::list<std::pair<std::string, TypeName>> args{}; args.push_back(std::make_pair<std::string, TypeName>("x", TypeName::F32)); auto block = std::make_unique<BlockNode>(); auto lambda = std::make_unique<LambdaNode>( TypeName::F32, std::move(args), std::move(block) ); auto node = std::make_unique<AssignmentNode>( "x", AssignmentOperator::Assign, std::move(lambda) ); setupTest("x = \\(x: f32): f32 = {};", func, std::move(node)); } TEST(ParserTest, InvalidLambdaAssignmentThrows) { testThrow("x += \\(x: f32): f32 = {};", &Parser::parseLambda); testThrow("x -= \\(x: f32): f32 = {};", &Parser::parseLambda); testThrow("x *= \\(x: f32): f32 = {};", &Parser::parseLambda); testThrow("x /= \\(x: f32): f32 = {};", &Parser::parseLambda); testThrow("x &= \\(x: f32): f32 = {};", &Parser::parseLambda); testThrow("x |= \\(x: f32): f32 = {};", &Parser::parseLambda); testThrow("x <<= \\(x: f32): f32 = {};", &Parser::parseLambda); testThrow("x >>= \\(x: f32): f32 = {};", &Parser::parseLambda); } TEST(ParserTest, CallingFunctionResult) { const auto func = std::bind(&Parser::parseFunctionCall, std::placeholders::_1, std::optional<Token>{}); std::list<std::shared_ptr<ExpressionNode>> arguments{}; arguments.push_back(std::make_unique<VariableNode>("x")); arguments.push_back(std::make_unique<NumericLiteralNode>(2)); std::list<std::shared_ptr<ExpressionNode>> args2{}; args2.push_back(std::make_unique<NumericLiteralNode>(10)); auto funcCallNode = std::make_unique<FunctionCallNode>("f", std::move(arguments)); auto node = std::make_unique<FunctionResultCallNode>(std::move(funcCallNode), std::move(args2)); setupTest("f(x, 2)(10)", func, std::move(node)); }
[ "k.przybyla@stud.elka.pw.edu.pl" ]
k.przybyla@stud.elka.pw.edu.pl
1b8f3a25c8c5d2964f98b77819d83d1a653fd099
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/nebula2/src/gui/nguihorisliderboxed_main.cc
9cc715fba8a8b0bb24098504c8b93d1f9d188079
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,355
cc
#include "precompiled/pchngui.h" //------------------------------------------------------------------------------ // nGuiHoriSliderBoxed_main.cc // (C) 2004 RadonLabs GmbH //------------------------------------------------------------------------------ #include "gui/nGuiHoriSliderBoxed.h" #include "gui/nguiserver.h" #include "gui/nguiskin.h" nNebulaClass(nGuiHoriSliderBoxed, "nguiformlayout"); //--- MetaInfo --------------------------------------------------------------- /** @scriptclass nGuiHoriSliderBoxed @cppclass nGuiHoriSliderBoxed @superclass nguiformlayout @classinfo Docs needed. */ //------------------------------------------------------------------------------ /** */ nGuiHoriSliderBoxed::nGuiHoriSliderBoxed() : labelFont("GuiSmall"), minValue(0), maxValue(10), curValue(0), knobSize(1), leftWidth(0.2f), rightWidth(0.1f) { // empty } //------------------------------------------------------------------------------ /** */ nGuiHoriSliderBoxed::~nGuiHoriSliderBoxed() { // empty } //------------------------------------------------------------------------------ /** */ void nGuiHoriSliderBoxed::OnShow() { nGuiSkin* skin = nGuiServer::Instance()->GetSkin(); n_assert(skin); nGuiFormLayout::OnShow(); kernelServer->PushCwd(this); // text entry sizes vector2 textSize = nGuiServer::Instance()->ComputeScreenSpaceBrushSize("textentry_n"); vector2 textMinSize(0.0f, textSize.y); vector2 textMaxSize(1.0f, textSize.y); // create slider widget nGuiSlider2* slider = (nGuiSlider2*) kernelServer->New("nguislider2", "Slider"); n_assert(slider); slider->SetRangeSize(float((this->maxValue - this->minValue) + this->knobSize)); slider->SetVisibleRangeStart(float(this->curValue - this->minValue)); slider->SetVisibleRangeSize(float(this->knobSize)); slider->SetHorizontal(true); this->AttachForm(slider, Top, 0.0f); this->AttachPos(slider, Left, this->leftWidth); this->AttachPos(slider, Right, 1.0f - this->rightWidth); slider->OnShow(); this->refSlider = slider; const vector2& sliderMinSize = slider->GetMinSize(); const vector2& sliderMaxSize = slider->GetMaxSize(); // create left text label nGuiTextLabel* leftLabel = (nGuiTextLabel*) kernelServer->New("nguitextlabel", "LeftLabel"); n_assert(leftLabel); leftLabel->SetText(this->leftText.Get()); leftLabel->SetFont(this->GetLabelFont()); leftLabel->SetAlignment(nGuiTextLabel::Right); leftLabel->SetColor(skin->GetLabelTextColor()); leftLabel->SetMinSize(vector2(0.0f, sliderMinSize.y)); leftLabel->SetMaxSize(vector2(1.0f, sliderMaxSize.y)); this->AttachForm(leftLabel, Top, 0.0f); this->AttachForm(leftLabel, Left, 0.0f); this->AttachPos(leftLabel, Right, this->leftWidth); leftLabel->OnShow(); this->refLeftLabel = leftLabel; // create right text entry nGuiTextEntry* textEntry = (nGuiTextEntry*) kernelServer->New("nguitextentry", "RightEntry"); n_assert(textEntry); textEntry->SetText("0"); textEntry->SetFont("GuiSmall"); textEntry->SetAlignment(nGuiTextLabel::Left); textEntry->SetColor(vector4(0.0f, 0.0f, 0.0f, 1.0f)); textEntry->SetMinSize(textMinSize); textEntry->SetMaxSize(textMaxSize); textEntry->SetDefaultBrush("textentry_n"); textEntry->SetPressedBrush("textentry_p"); textEntry->SetHighlightBrush("textentry_h"); textEntry->SetDisabledBrush("textentry_d"); textEntry->SetCursorBrush("textcursor"); textEntry->SetColor(vector4(0.85f, 0.85f, 0.85f, 1.0f)); this->AttachForm(textEntry, Top, 0.0f); this->AttachForm(textEntry, Right, 0.005f); this->AttachPos(textEntry, Left, 1.0f - this->rightWidth); textEntry->OnShow(); this->refTextEntry = textEntry; kernelServer->PopCwd(); this->SetMinSize(sliderMinSize); this->SetMaxSize(sliderMaxSize); this->UpdateLayout(this->rect); nGuiServer::Instance()->RegisterEventListener(this); } //------------------------------------------------------------------------------ /** */ void nGuiHoriSliderBoxed::SetMaxLength(int l) { this->refTextEntry->SetMaxLength(l); } //------------------------------------------------------------------------------ /** */ void nGuiHoriSliderBoxed::OnHide() { nGuiServer::Instance()->UnregisterEventListener(this); this->ClearAttachRules(); if (this->refSlider.isvalid()) { this->refSlider->Release(); n_assert(!this->refSlider.isvalid()); } if (this->refLeftLabel.isvalid()) { this->refLeftLabel->Release(); n_assert(!this->refLeftLabel.isvalid()); } if (this->refTextEntry.isvalid()) { this->refTextEntry->Release(); n_assert(!this->refTextEntry.isvalid()); } nGuiFormLayout::OnHide(); } //------------------------------------------------------------------------------ /** */ void nGuiHoriSliderBoxed::OnFrame() { if (this->refSlider.isvalid()) { this->curValue = this->minValue + int(this->refSlider->GetVisibleRangeStart()); // update left and right label formatted strings char buf[1024]; snprintf(buf, sizeof(buf), this->leftText.Get(), this->curValue); this->refLeftLabel->SetText(buf); snprintf(buf, sizeof(buf), this->rightText.Get(), this->curValue); if (! this->refTextEntry->GetActive()) { this->refTextEntry->SetText(buf); this->refTextEntry->SetInitialCursorPos(nGuiTextLabel::Right); } } nGuiFormLayout::OnFrame(); } // juanga (from Nebula2SDK_2004) // added 29sept04: replicates the event, allowing handle values WHILE dragging the slider knob void nGuiHoriSliderBoxed::OnEvent(const nGuiEvent& event) { switch(event.GetType()) { case nGuiEvent::Char: case nGuiEvent::KeyUp: { if (this->refTextEntry.isvalid() && (event.GetWidget() == this->refTextEntry)) { // update slider this->SetValue(atoi(this->refTextEntry->GetText())); // replicate event, to process some other changes if needed on derivated classes nGuiEvent event(this, nGuiEvent::SliderChanged); nGuiServer::Instance()->PutEvent(event); } } break; case nGuiEvent::SliderChanged: { if (this->refSlider.isvalid() && (event.GetWidget() == this->refSlider)) { // replicate event nGuiEvent event(this, nGuiEvent::SliderChanged); nGuiServer::Instance()->PutEvent(event); // if the user touches the slider, disable cursor on textentry, so the value will be updated //this->refTextEntry->SetActive(false); } } break; default: { if (event.GetWidget() == this->refTextEntry) { //this->SetValue(atoi(this->refTextEntry->GetText())); } } break; } }
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91
2478374b24405366ed41468510ae095bff0ca847
b4c99a809f50c8891017ecf67086e7f951c8fad1
/test/unittests/compiler/effect-control-linearizer-unittest.cc
cc697734a9872253e7cf43a1c681bf37c2de9f66
[ "SunPro", "BSD-3-Clause", "bzip2-1.0.6" ]
permissive
haigiodhh/v8
dc4bd4c5541aff7976235767d5ef65a945eaa294
b8a06da63f9921488e562e88060e67df04921f42
refs/heads/master
2020-07-18T18:41:22.392598
2016-11-16T11:27:52
2016-11-16T11:28:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,311
cc
// Copyright 2015 the V8 project 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 "src/compiler/effect-control-linearizer.h" #include "src/compiler/access-builder.h" #include "src/compiler/js-graph.h" #include "src/compiler/linkage.h" #include "src/compiler/node-properties.h" #include "src/compiler/schedule.h" #include "src/compiler/simplified-operator.h" #include "test/unittests/compiler/graph-unittest.h" #include "test/unittests/compiler/node-test-utils.h" #include "test/unittests/test-utils.h" #include "testing/gmock-support.h" #include "testing/gmock/include/gmock/gmock.h" namespace v8 { namespace internal { namespace compiler { using testing::Capture; class EffectControlLinearizerTest : public GraphTest { public: EffectControlLinearizerTest() : GraphTest(3), machine_(zone()), javascript_(zone()), simplified_(zone()), jsgraph_(isolate(), graph(), common(), &javascript_, &simplified_, &machine_) {} JSGraph* jsgraph() { return &jsgraph_; } SimplifiedOperatorBuilder* simplified() { return &simplified_; } private: MachineOperatorBuilder machine_; JSOperatorBuilder javascript_; SimplifiedOperatorBuilder simplified_; JSGraph jsgraph_; }; namespace { BasicBlock* AddBlockToSchedule(Schedule* schedule) { BasicBlock* block = schedule->NewBasicBlock(); block->set_rpo_number(static_cast<int32_t>(schedule->rpo_order()->size())); schedule->rpo_order()->push_back(block); return block; } } // namespace TEST_F(EffectControlLinearizerTest, SimpleLoad) { Schedule schedule(zone()); // Create the graph. Node* heap_number = NumberConstant(0.5); Node* load = graph()->NewNode( simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, graph()->start(), graph()->start()); Node* zero = graph()->NewNode(common()->Int32Constant(0)); Node* ret = graph()->NewNode(common()->Return(), zero, load, graph()->start(), graph()->start()); // Build the basic block structure. BasicBlock* start = schedule.start(); schedule.rpo_order()->push_back(start); start->set_rpo_number(0); // Populate the basic blocks with nodes. schedule.AddNode(start, graph()->start()); schedule.AddNode(start, heap_number); schedule.AddNode(start, load); schedule.AddReturn(start, ret); // Run the state effect introducer. EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); introducer.Run(); EXPECT_THAT(load, IsLoadField(AccessBuilder::ForHeapNumberValue(), heap_number, graph()->start(), graph()->start())); // The return should have reconnected effect edge to the load. EXPECT_THAT(ret, IsReturn(load, load, graph()->start())); } TEST_F(EffectControlLinearizerTest, DiamondLoad) { Schedule schedule(zone()); // Create the graph. Node* branch = graph()->NewNode(common()->Branch(), Int32Constant(0), graph()->start()); Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* heap_number = NumberConstant(0.5); Node* vtrue = graph()->NewNode( simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, graph()->start(), if_true); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* vfalse = Float64Constant(2); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); Node* phi = graph()->NewNode( common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge); Node* zero = graph()->NewNode(common()->Int32Constant(0)); Node* ret = graph()->NewNode(common()->Return(), zero, phi, graph()->start(), merge); // Build the basic block structure. BasicBlock* start = schedule.start(); schedule.rpo_order()->push_back(start); start->set_rpo_number(0); BasicBlock* tblock = AddBlockToSchedule(&schedule); BasicBlock* fblock = AddBlockToSchedule(&schedule); BasicBlock* mblock = AddBlockToSchedule(&schedule); // Populate the basic blocks with nodes. schedule.AddNode(start, graph()->start()); schedule.AddBranch(start, branch, tblock, fblock); schedule.AddNode(tblock, if_true); schedule.AddNode(tblock, heap_number); schedule.AddNode(tblock, vtrue); schedule.AddGoto(tblock, mblock); schedule.AddNode(fblock, if_false); schedule.AddNode(fblock, vfalse); schedule.AddGoto(fblock, mblock); schedule.AddNode(mblock, merge); schedule.AddNode(mblock, phi); schedule.AddReturn(mblock, ret); // Run the state effect introducer. EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); introducer.Run(); // The effect input to the return should be an effect phi with the // newly introduced effectful change operators. ASSERT_THAT( ret, IsReturn(phi, IsEffectPhi(vtrue, graph()->start(), merge), merge)); } TEST_F(EffectControlLinearizerTest, FloatingDiamondsControlWiring) { Schedule schedule(zone()); // Create the graph and schedule. Roughly (omitting effects and unimportant // nodes): // // BLOCK 0: // r1: Start // c1: Call // b1: Branch(const0, s1) // | // +-------+------+ // | | // BLOCK 1: BLOCK 2: // t1: IfTrue(b1) f1: IfFalse(b1) // | | // +-------+------+ // | // BLOCK 3: // m1: Merge(t1, f1) // c2: IfSuccess(c1) // b2: Branch(const0 , s1) // | // +-------+------+ // | | // BLOCK 4: BLOCK 5: // t2: IfTrue(b2) f2:IfFalse(b2) // | | // +-------+------+ // | // BLOCK 6: // m2: Merge(t2, f2) // r1: Return(c1, c2) LinkageLocation kLocationSignature[] = { LinkageLocation::ForRegister(0, MachineType::Pointer()), LinkageLocation::ForRegister(1, MachineType::Pointer())}; const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), LinkageLocation::ForRegister(0, MachineType::Pointer()), new (zone()) LocationSignature(1, 1, kLocationSignature), 0, Operator::kNoProperties, 0, 0, CallDescriptor::kNoFlags); Node* p0 = Parameter(0); Node* p1 = Parameter(1); Node* const0 = Int32Constant(0); Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, graph()->start(), graph()->start()); Node* if_success = graph()->NewNode(common()->IfSuccess(), call); // First Floating diamond. Node* branch1 = graph()->NewNode(common()->Branch(), const0, graph()->start()); Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); // Second floating diamond. Node* branch2 = graph()->NewNode(common()->Branch(), const0, graph()->start()); Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2); Node* zero = graph()->NewNode(common()->Int32Constant(0)); Node* ret = graph()->NewNode(common()->Return(), zero, call, graph()->start(), if_success); // Build the basic block structure. BasicBlock* start = schedule.start(); schedule.rpo_order()->push_back(start); start->set_rpo_number(0); BasicBlock* t1block = AddBlockToSchedule(&schedule); BasicBlock* f1block = AddBlockToSchedule(&schedule); BasicBlock* m1block = AddBlockToSchedule(&schedule); BasicBlock* t2block = AddBlockToSchedule(&schedule); BasicBlock* f2block = AddBlockToSchedule(&schedule); BasicBlock* m2block = AddBlockToSchedule(&schedule); // Populate the basic blocks with nodes. schedule.AddNode(start, graph()->start()); schedule.AddNode(start, p0); schedule.AddNode(start, p1); schedule.AddNode(start, const0); schedule.AddNode(start, call); schedule.AddBranch(start, branch1, t1block, f1block); schedule.AddNode(t1block, if_true1); schedule.AddGoto(t1block, m1block); schedule.AddNode(f1block, if_false1); schedule.AddGoto(f1block, m1block); schedule.AddNode(m1block, merge1); // The scheduler does not always put the IfSuccess node to the corresponding // call's block, simulate that here. schedule.AddNode(m1block, if_success); schedule.AddBranch(m1block, branch2, t2block, f2block); schedule.AddNode(t2block, if_true2); schedule.AddGoto(t2block, m2block); schedule.AddNode(f2block, if_false2); schedule.AddGoto(f2block, m2block); schedule.AddNode(m2block, merge2); schedule.AddReturn(m2block, ret); // Run the state effect introducer. EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); introducer.Run(); // The effect input to the return should be an effect phi with the // newly introduced effectful change operators. ASSERT_THAT(ret, IsReturn(call, call, merge2)); ASSERT_THAT(branch2, IsBranch(const0, merge1)); ASSERT_THAT(branch1, IsBranch(const0, if_success)); ASSERT_THAT(if_success, IsIfSuccess(call)); } TEST_F(EffectControlLinearizerTest, LoopLoad) { Schedule schedule(zone()); // Create the graph. Node* loop = graph()->NewNode(common()->Loop(1), graph()->start()); Node* effect_phi = graph()->NewNode(common()->EffectPhi(1), graph()->start(), loop); Node* cond = Int32Constant(0); Node* branch = graph()->NewNode(common()->Branch(), cond, loop); Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); loop->AppendInput(zone(), if_false); NodeProperties::ChangeOp(loop, common()->Loop(2)); effect_phi->InsertInput(zone(), 1, effect_phi); NodeProperties::ChangeOp(effect_phi, common()->EffectPhi(2)); Node* heap_number = NumberConstant(0.5); Node* load = graph()->NewNode( simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, graph()->start(), loop); Node* zero = graph()->NewNode(common()->Int32Constant(0)); Node* ret = graph()->NewNode(common()->Return(), zero, load, effect_phi, if_true); // Build the basic block structure. BasicBlock* start = schedule.start(); schedule.rpo_order()->push_back(start); start->set_rpo_number(0); BasicBlock* lblock = AddBlockToSchedule(&schedule); BasicBlock* fblock = AddBlockToSchedule(&schedule); BasicBlock* rblock = AddBlockToSchedule(&schedule); // Populate the basic blocks with nodes. schedule.AddNode(start, graph()->start()); schedule.AddGoto(start, lblock); schedule.AddNode(lblock, loop); schedule.AddNode(lblock, effect_phi); schedule.AddNode(lblock, heap_number); schedule.AddNode(lblock, load); schedule.AddNode(lblock, cond); schedule.AddBranch(lblock, branch, rblock, fblock); schedule.AddNode(fblock, if_false); schedule.AddGoto(fblock, lblock); schedule.AddNode(rblock, if_true); schedule.AddReturn(rblock, ret); // Run the state effect introducer. EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); introducer.Run(); ASSERT_THAT(ret, IsReturn(load, load, if_true)); EXPECT_THAT(load, IsLoadField(AccessBuilder::ForHeapNumberValue(), heap_number, effect_phi, loop)); } TEST_F(EffectControlLinearizerTest, CloneBranch) { Schedule schedule(zone()); Node* cond0 = Parameter(0); Node* cond1 = Parameter(1); Node* cond2 = Parameter(2); Node* branch0 = graph()->NewNode(common()->Branch(), cond0, start()); Node* control1 = graph()->NewNode(common()->IfTrue(), branch0); Node* control2 = graph()->NewNode(common()->IfFalse(), branch0); Node* merge0 = graph()->NewNode(common()->Merge(2), control1, control2); Node* phi0 = graph()->NewNode(common()->Phi(MachineRepresentation::kBit, 2), cond1, cond2, merge0); Node* branch = graph()->NewNode(common()->Branch(), phi0, merge0); Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); graph()->SetEnd(graph()->NewNode(common()->End(1), merge)); BasicBlock* start = schedule.start(); schedule.rpo_order()->push_back(start); start->set_rpo_number(0); BasicBlock* f1block = AddBlockToSchedule(&schedule); BasicBlock* t1block = AddBlockToSchedule(&schedule); BasicBlock* bblock = AddBlockToSchedule(&schedule); BasicBlock* f2block = AddBlockToSchedule(&schedule); BasicBlock* t2block = AddBlockToSchedule(&schedule); BasicBlock* mblock = AddBlockToSchedule(&schedule); // Populate the basic blocks with nodes. schedule.AddNode(start, graph()->start()); schedule.AddBranch(start, branch0, t1block, f1block); schedule.AddNode(t1block, control1); schedule.AddGoto(t1block, bblock); schedule.AddNode(f1block, control2); schedule.AddGoto(f1block, bblock); schedule.AddNode(bblock, merge0); schedule.AddNode(bblock, phi0); schedule.AddBranch(bblock, branch, t2block, f2block); schedule.AddNode(t2block, if_true); schedule.AddGoto(t2block, mblock); schedule.AddNode(f2block, if_false); schedule.AddGoto(f2block, mblock); schedule.AddNode(mblock, merge); schedule.AddNode(mblock, graph()->end()); EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); introducer.Run(); Capture<Node *> branch1_capture, branch2_capture; EXPECT_THAT( end(), IsEnd(IsMerge(IsMerge(IsIfTrue(CaptureEq(&branch1_capture)), IsIfTrue(CaptureEq(&branch2_capture))), IsMerge(IsIfFalse(AllOf(CaptureEq(&branch1_capture), IsBranch(cond1, control1))), IsIfFalse(AllOf(CaptureEq(&branch2_capture), IsBranch(cond2, control2))))))); } } // namespace compiler } // namespace internal } // namespace v8
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
0f8ad27505c328f25193aa611e8e3794b5fde220
ca539e64fef0b2525f01511f1e8482881918d199
/cfiles/sumskipnan.cpp
b8c2d024ececbdf7c15ba10ae84922e12e37aec7
[]
no_license
eko222/nm
ec776eeaf1b7ce91b48d6cb1feaaaf7fb6379ca7
77bed01b224fba22d0d1d95dd1e2ef725f1e9c43
refs/heads/master
2023-04-23T15:06:07.277242
2021-05-12T22:18:49
2021-05-12T22:18:49
366,855,021
0
0
null
null
null
null
UTF-8
C++
false
false
6,642
cpp
//------------------------------------------------------------------- #pragma hdrstop //------------------------------------------------------------------- // C-MEX implementation of SUMSKIPNAN - this function is part of the NaN-toolbox. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // // sumskipnan: sums all non-NaN values // // Input: // - array to sum // - dimension to sum (1=columns; 2=rows; doesn't work for dim>2!!) // // Output: // - sums // - count of valid elements (optional) // - sums of squares (optional) // - sums of squares of squares (optional) // // Author: Patrick Houweling (phouweling@yahoo.com) // Version: 1.0 // Date: 17 september 2003 // // modified: // Alois Schloegl <a.schloegl@ieee.org> // $Revision: 1.1 $ // $Id: sumskipnan.cpp,v 1.1 2003/10/31 18:13:28 schloegl Exp $ // //------------------------------------------------------------------- //#include <stdlib> #include <math.h> #include "mex.h" //------------------------------------------------------------------- void mexFunction(int POutputCount, mxArray* POutput[], int PInputCount, const mxArray *PInputs[]) { const int *SZ; double* LInput; double* LInputI; double* LOutputSum; double* LOutputSumI; double* LOutputCount; double* LOutputSum2; double* LOutputSum4; double x, x2; unsigned long LCount, LCountI; double LSum, LSum2, LSum4; unsigned DIM = 0; unsigned long D1, D2, D3; // NN; // unsigned ND, ND2; // number of dimensions: input, output unsigned long ix1, ix2; // index to input and output unsigned j, k, l; // running indices int *SZ2; // size of output // check for proper number of input and output arguments if ((PInputCount <= 0) || (PInputCount > 2)) mexErrMsgTxt("SumSkipNan.MEX requires 1 or 2 arguments."); if (POutputCount > 4) mexErrMsgTxt("SumSkipNan.MEX has 1 to 4 output arguments."); // get 1st argument if(!mxIsNumeric(PInputs[0])) mexErrMsgTxt("First argument must be NUMERIC."); if(!mxIsDouble(PInputs[0])) mexErrMsgTxt("First argument must be DOUBLE."); if(mxIsComplex(PInputs[0]) & (POutputCount > 3)) mexErrMsgTxt("More than 3 output arguments only supported for REAL data "); LInput = mxGetPr(PInputs[0]); // get 2nd argument if (PInputCount == 2){ switch (mxGetNumberOfElements(PInputs[1])) { case 0: x = 0.0; // accept empty element break; case 1: x = (mxIsNumeric(PInputs[1]) ? mxGetScalar(PInputs[1]) : -1.0); break; default:x = -1.0; // invalid } if ((x < 0) || (x > 65535) || (x != floor(x))) mexErrMsgTxt("Error SUMSKIPNAN.MEX: DIM-argument must be a positive integer scalar"); DIM = (unsigned)floor(x); } // get size ND = mxGetNumberOfDimensions(PInputs[0]); // NN = mxGetNumberOfElements(PInputs[0]); SZ = mxGetDimensions(PInputs[0]); // if DIM==0 (undefined), look for first dimension with more than 1 element. for (k = 0; (DIM < 1) && (k < ND); k++) if (SZ[k]>1) DIM = k+1; if (DIM < 1) DIM=1; // in case DIM is still undefined ND2 = (ND>DIM ? ND : DIM); // number of dimensions of output SZ2 = (int*)mxCalloc(ND2, sizeof(int)); // allocate memory for output size for (j=0; j<ND; j++) // copy size of input; SZ2[j] = SZ[j]; for (j=ND; j<ND2; j++) // in case DIM > ND, add extra elements 1 SZ2[j] = 1; for (j=0, D1=1; j<DIM-1; D1=D1*SZ2[j++]); // D1 is the number of elements between two elements along dimension DIM D2 = SZ2[DIM-1]; // D2 contains the size along dimension DIM for (j=DIM, D3=1; j<ND; D3=D3*SZ2[j++]); // D3 is the number of blocks containing D1*D2 elements SZ2[DIM-1] = 1; // size of output is same as size of input but SZ(DIM)=1; // create outputs #define TYP mxDOUBLE_CLASS if(mxIsComplex(PInputs[0])) { POutput[0] = mxCreateNumericArray(ND2, SZ2, TYP, mxCOMPLEX); LOutputSum = mxGetPr(POutput[0]); LOutputSumI= mxGetPi(POutput[0]); LInputI = mxGetPi(PInputs[0]); } else { POutput[0] = mxCreateNumericArray(ND2, SZ2, TYP, mxREAL); LOutputSum = mxGetPr(POutput[0]); } if (POutputCount >= 2){ POutput[1] = mxCreateNumericArray(ND2, SZ2, TYP, mxREAL); LOutputCount = mxGetPr(POutput[1]); } if (POutputCount >= 3){ POutput[2] = mxCreateNumericArray(ND2, SZ2, TYP, mxREAL); LOutputSum2 = mxGetPr(POutput[2]); } if (POutputCount >= 4){ POutput[3] = mxCreateNumericArray(ND2, SZ2, TYP, mxREAL); LOutputSum4 = mxGetPr(POutput[3]); } mxFree(SZ2); // OUTER LOOP: along dimensions > DIM for (l = 0; l<D3; l++) { ix2 = l*D1; // index for output ix1 = ix2*D2; // index for input // Inner LOOP: along dimensions < DIM for (k = 0; k<D1; k++, ix1++, ix2++) { LCount = 0; LSum = 0.0; LSum2 = 0.0; LSum4 = 0.0; // LOOP along dimension DIM for (j=0; j<D2; j++) { x = LInput[ix1 + j*D1]; if (!mxIsNaN(x)) { LCount++; LSum += x; x2 = x*x; LSum2 += x2; LSum4 += x2*x2; } } LOutputSum[ix2] = LSum; if (POutputCount >= 2) LOutputCount[ix2] = (double)LCount; if (POutputCount >= 3) LOutputSum2[ix2] = LSum2; if (POutputCount >= 4) LOutputSum4[ix2] = LSum4; if(mxIsComplex(PInputs[0])) { LSum = 0.0; LCountI = 0; LSum2 = 0.0; for (j=0; j<D2; j++) { x = LInputI[ix1 + j*D1]; if (!mxIsNaN(x)) { LCountI++; LSum += x; LSum2 += x*x; } } LOutputSumI[ix2] = LSum; if (LCount != LCountI) mexErrMsgTxt("Number of NaNs is different for REAL and IMAG part"); if (POutputCount >= 3) LOutputSum2[ix2] += LSum2; } } } }
[ "65445062+eko222@users.noreply.github.com" ]
65445062+eko222@users.noreply.github.com
5b700d8f1468656cdc02fb5fe591da9756ba9088
9d90c25cf24a0944ad719a5b2a8be0f3c53d2243
/WLM/ventes.cpp
4d10d7f627fe763cd66f406f8dd09d96724b7ef9
[]
no_license
ChamseddineChennoufi/ElectricInkWLM
52fab3354959fdf149a9459befc650c973d0e89d
36f7c056b7fb0c9baf898d8fad364be12006822a
refs/heads/master
2020-09-21T03:25:05.093775
2019-11-28T14:28:49
2019-11-28T14:28:49
224,664,754
0
0
null
null
null
null
UTF-8
C++
false
false
2,973
cpp
#include "ventes.h" Ventes::Ventes() { ISBN=00000000; Quant=0; Price=0; } Ventes::Ventes(long ISBN, int Quant, double Price) { this->ISBN=ISBN; this->Quant=Quant; this->Price=Price; } /*-----------------------------------------------------------------------------*/ bool Ventes::AddVente() { QSqlQuery qry; QString SISBN=QString::number(ISBN),SQuant=QString::number(Quant),SPrice=QString::number(Price); qry.prepare("insert into Ventes (ISBN, Quant, Price) Values (:ISBN, :Quant, :Price)"); qry.bindValue(":ISBN",SISBN); qry.bindValue(":Quant",SQuant); qry.bindValue(":Price",SPrice); return qry.exec(); } /*-----------------------------------------------------------------------------*/ QSqlQueryModel* Ventes::DisplayVente() { QSqlQueryModel *Model= new QSqlQueryModel(); Model->setQuery("select * from Ventes"); Model->setHeaderData(0,Qt::Horizontal,QObject::tr("ISBN")); Model->setHeaderData(1,Qt::Horizontal,QObject::tr("Quantité")); Model->setHeaderData(3,Qt::Horizontal,QObject::tr("Prix Totale")); return Model; } /*-----------------------------------------------------------------------------*/ QSqlQueryModel* Ventes::SearchISBN() { QSqlQueryModel *Model= new QSqlQueryModel(); //QSqlQuery qry; QString SISBN=QString::number(ISBN); //qDebug("%ld",ISBN); //qry.prepare("Select * from Ventes where ISBN= :ISBN"); //qry.bindValue(":ISBN",SISBN); Model->setQuery("Select * from Ventes where ISBN= "+SISBN+""); Model->setHeaderData(0,Qt::Horizontal,QObject::tr("ISBN")); Model->setHeaderData(1,Qt::Horizontal,QObject::tr("Quantité")); Model->setHeaderData(3,Qt::Horizontal,QObject::tr("Prix Totale")); return Model; } /*-----------------------------------------------------------------------------*/ bool Ventes::RemoveVente() { QSqlQuery qry; QString SISBN=QString::number(ISBN); qry.prepare("delete from Ventes where ISBN= :ISBN"); qry.bindValue(":ISBN",SISBN); return qry.exec(); } /*-----------------------------------------------------------------------------*/ bool Ventes::ModifyVente_Quant() { QSqlQuery qry; QString SISBN=QString::number(ISBN),SQuant=QString::number(Quant); qry.prepare("Update Ventes set Quant= :Quant where ISBN= :ISBN"); qry.bindValue(":Quant",SQuant); qry.bindValue(":ISBN",SISBN); return qry.exec(); } /*-----------------------------------------------------------------------------*/ bool Ventes::ModifyVente_Price() { QSqlQuery qry; QString SISBN=QString::number(ISBN),SPrice=QString::number(Price); qry.prepare("Update Ventes set Price= :Price where ISBN= :ISBN"); qry.bindValue(":Price",SPrice); qry.bindValue(":ISBN",SISBN); return qry.exec(); } Ventes::~Ventes() { }
[ "noreply@github.com" ]
ChamseddineChennoufi.noreply@github.com
f2268b07607132f719c79761b3935988d7356156
ef76cdd5c65f937477297d86a06bad738a329521
/lab 2/main.cpp
6b56cbf503ab9f4d827d89e68ac9ac8cbbd3343d
[]
no_license
vasilypht/Parallel_programming_labs
1f623c36a468d03a9b0f412420f0186e0d6b5af3
0298b2b7f736247c25817f42f03fe153a88dec84
refs/heads/main
2023-08-28T10:42:03.725600
2021-10-15T16:45:28
2021-10-15T16:45:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,184
cpp
#include <iostream> #include <vector> #include <list> #include <string> #include <random> #include <future> using adj_list_t = std::vector<std::vector<uint32_t>>; using path_list_t = std::list<std::vector<uint32_t>>; path_list_t f_thread(const adj_list_t& graph, uint32_t cur_node, uint32_t begin_node, uint32_t end_node); adj_list_t generate_graph(const uint32_t &size); void print_graph(const adj_list_t &graph); void print_paths(const path_list_t &paths); path_list_t dfs(const adj_list_t &graph, std::vector<bool> nodes_condition, std::vector<uint32_t> path, uint32_t curr_node, uint32_t target_node); int main() { path_list_t all_paths; std::vector<std::future<path_list_t>> futures; uint32_t begin = 2; uint32_t end = 4; uint32_t num_of_node = 5; // init graph auto graph = generate_graph(num_of_node); for (const auto &node_id : graph[begin]) { futures.push_back(std::async(std::launch::async, f_thread, std::cref(graph), node_id, begin, end)); } for (auto & paths : futures) { all_paths.merge(paths.get()); } print_graph(graph); print_paths(all_paths); return 0; } path_list_t f_thread(const adj_list_t& graph, uint32_t cur_node, uint32_t begin_node, uint32_t end_node) { path_list_t all_paths; std::vector<bool> nodes_condition(graph.size(), false); std::vector<uint32_t> path; nodes_condition[begin_node] = true; path.push_back(begin_node); all_paths = dfs(graph, nodes_condition, path, cur_node, end_node); return all_paths; } path_list_t dfs(const adj_list_t &graph, std::vector<bool> nodes_condition, std::vector<uint32_t> path, uint32_t curr_node, uint32_t target_node) { path.push_back(curr_node); if (curr_node == target_node) { return path_list_t{path}; } nodes_condition[curr_node] = true; path_list_t all_paths; for (const auto& node : graph[curr_node]) { if (!nodes_condition[node]) { auto paths = dfs(graph, nodes_condition, path, node, target_node); all_paths.merge(paths); } } return all_paths; } adj_list_t generate_graph(const uint32_t &size) { adj_list_t adjacency_list; std::random_device rd; std::mt19937 mersenne(rd()); for (uint32_t i = 0; i < size; i++) { std::vector<uint32_t> nodes; for (uint32_t j = 0; j < size; j++) { uint32_t node_id = mersenne() % size; if (node_id != i and std::count(nodes.rbegin(), nodes.rend(), node_id) == 0) { nodes.push_back(node_id); } } adjacency_list.push_back(nodes); } return adjacency_list; } void print_graph(const adj_list_t &graph) { uint32_t max_indent = 6; uint32_t max_index_indent = std::to_string(graph.size() - 1).size() + 1; if (max_index_indent > max_indent) { max_indent = max_index_indent; } std::cout << "Node" << std::string(max_indent - 4, ' ') << " " << "Nodes" << std::endl; for (uint32_t i = 0; i < graph.size(); i++) { std::cout << i << std::string(max_indent - std::to_string(i).size(), ' ') <<" "; for (const auto &node : graph[i]) { std::cout << node << " "; } std::cout << std::endl; } std::cout << std::endl; } void print_paths(const path_list_t &paths) { if (paths.empty()) { std::cout << "Paths is empty :(" << std::endl << std::endl; return; } auto it = paths.rbegin(); uint32_t begin_node = it->at(0); uint32_t end_node = it->at(it->size() - 1); std::cout << "All path: " << begin_node << " -> " << end_node << std::endl; std::cout << "Number of paths: " << paths.size() << std::endl; for (const auto& path : paths) { for (const auto &node : path) { if (node != end_node) { std::cout << node << " -> "; } else { std::cout << node; } } std::cout << std::endl; } std::cout << std::endl; }
[ "perekhrest-vasily@mail.ru" ]
perekhrest-vasily@mail.ru
9e281757404494dd6496fd4b44359963ab44f05f
e561062002bf81e276deaae138992a551c506794
/ConnectedComponents/ShiloachesVishkinOmp.cpp
104777f312fc7e6b8d534008f770aee2f2fbebb2
[]
no_license
SquareSpheres/CPU-parallel-algorithms
19a2db75141768d84d1c41563c4904f483e564d1
c30560747edaafce888da54d4f06e2ff9958d791
refs/heads/master
2021-09-08T15:17:30.436749
2018-03-10T15:36:02
2018-03-10T15:36:02
85,102,757
0
0
null
null
null
null
UTF-8
C++
false
false
3,192
cpp
#include "ShiloachesVishkinOmp.h" std::vector<int> ShiloachVishkinOmp(std::pair<int, int> *graph, const int numVertices, const int numEdges) { std::vector<int> component(numVertices); /************** Component vector init *************/ #pragma omp parallel for for (int i = 0; i < numVertices; i++) { component[i] = i; } /************** Component vector init *************/ bool hasGrafted = true; while (hasGrafted) { hasGrafted = false; #pragma omp parallel { /************** Grafting *************/ #pragma omp for for (int i = 0; i < numEdges; ++i) { const int fromVertex = graph[i].first; const int toVertex = graph[i].second; int fromComponent = component[fromVertex]; int toComponent = component[toVertex]; if ((fromComponent < toComponent) && (toComponent == component[toComponent])) { if (!hasGrafted) hasGrafted = true; component[toComponent] = fromComponent; } fromComponent = component[toVertex]; toComponent = component[fromVertex]; if ((fromComponent < toComponent) && (toComponent == component[toComponent])) { if (!hasGrafted) hasGrafted = true; component[toComponent] = fromComponent; } } /************** Grafting *************/ /************** Compressing *************/ #pragma omp for for (int i = 0; i < numVertices; ++i) { while (component[i] != component[component[i]]) { component[i] = component[component[i]]; } } /************** Compressing *************/ } } return component; } std::vector<int> ShiloachVishkinUpdtOmp(std::pair<int, int> *graph, const int numVertices, const int numEdges) { std::vector<int> component(numVertices); /************** Component vector init *************/ #pragma omp parallel for for (int i = 0; i < numVertices; i++) { component[i] = i; } /************** Component vector init *************/ bool hasGrafted = true; while (hasGrafted) { hasGrafted = false; #pragma omp parallel { /************** Grafting *************/ #pragma omp for for (int i = 0; i < numEdges; ++i) { int fromVertex = graph[i].first; int toVertex = graph[i].second; if (fromVertex < toVertex && toVertex == component[toVertex]) { if (!hasGrafted) hasGrafted = true; component[toVertex] = fromVertex; } const int temp = fromVertex; fromVertex = toVertex; toVertex = temp; if (fromVertex < toVertex && toVertex == component[toVertex]) { if (!hasGrafted) hasGrafted = true; component[toVertex] = fromVertex; } } /************** Grafting *************/ /************** Compressing *************/ #pragma omp for for (int i = 0; i < numVertices; ++i) { while (component[i] != component[component[i]]) { component[i] = component[component[i]]; } } /************** Compressing *************/ /************** Updating *************/ #pragma omp for for (int i = 0; i < numEdges; ++i) { graph[i].first = component[graph[i].first]; graph[i].second = component[graph[i].second]; } /************** Updating *************/ } } return component; }
[ "yngvenot@gmail.com" ]
yngvenot@gmail.com
a71e283bf4e0b7ac228c183ad05540d3e308a050
92c138c4395ac2c91633d831fecd1f0b1161351c
/网络通信/第一版C网络通信编程实用案例精选源代码/chap3/Neighbor/Neighbor.cpp
68d18791459de0954b361ecff709fb692cd0bb53
[]
no_license
netsill/web-Safety
dc771e20ddb28192e2264777924f161af4bf236f
48d50a434c218d9099510b97cb3785bb80546dd4
refs/heads/master
2022-03-12T11:54:26.900908
2017-08-07T10:03:25
2017-08-07T10:03:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,017
cpp
// Neighbor.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "Neighbor.h" #include "NeighborDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CNeighborApp BEGIN_MESSAGE_MAP(CNeighborApp, CWinApp) //{{AFX_MSG_MAP(CNeighborApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CNeighborApp construction CNeighborApp::CNeighborApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CNeighborApp object CNeighborApp theApp; ///////////////////////////////////////////////////////////////////////////// // CNeighborApp initialization BOOL CNeighborApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CNeighborDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
[ "466217395@qq.com" ]
466217395@qq.com
df84cde7112528509da462c8bce61c8b5a866532
df6a7072020c0cce62a2362761f01c08f1375be7
/doc/quickbook/oglplus/quickref/enums/debug_output_source_class.hpp
4daebeb850ee7a22861afc41c971e13021819f4e
[ "BSL-1.0" ]
permissive
matus-chochlik/oglplus
aa03676bfd74c9877d16256dc2dcabcc034bffb0
76dd964e590967ff13ddff8945e9dcf355e0c952
refs/heads/develop
2023-03-07T07:08:31.615190
2021-10-26T06:11:43
2021-10-26T06:11:43
8,885,160
368
58
BSL-1.0
2018-09-21T16:57:52
2013-03-19T17:52:30
C++
UTF-8
C++
false
false
1,270
hpp
// File doc/quickbook/oglplus/quickref/enums/debug_output_source_class.hpp // // Automatically generated file, DO NOT modify manually. // Edit the source 'source/enums/oglplus/debug_output_source.txt' // or the 'source/enums/make_enum.py' script instead. // // Copyright 2010-2019 Matus Chochlik. // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // //[oglplus_enums_debug_output_source_class #if !__OGLPLUS_NO_ENUM_VALUE_CLASSES namespace enums { template <typename Base, template <__DebugOutputSource> class Transform> class __EnumToClass<Base, __DebugOutputSource, Transform> /*< Specialization of __EnumToClass for the __DebugOutputSource enumeration. >*/ : public Base { public: EnumToClass(); EnumToClass(Base&& base); Transform<DebugOutputSource::API> API; Transform<DebugOutputSource::WindowSystem> WindowSystem; Transform<DebugOutputSource::ShaderCompiler> ShaderCompiler; Transform<DebugOutputSource::ThirdParty> ThirdParty; Transform<DebugOutputSource::Application> Application; Transform<DebugOutputSource::Other> Other; Transform<DebugOutputSource::DontCare> DontCare; }; } // namespace enums #endif //]
[ "chochlik@gmail.com" ]
chochlik@gmail.com
f67f1c821d1a8f75b7a22e2139ef311ea18bb206
b53795b88ab0201e48c5dc5737e97dfd27e07b22
/extern/3rd_party/SpeedTreeRT4.1/Source/SourceCode/LibGlobals_Source/IdvGlobals.h
02c9e917f066667a9d48a3ccaf11b11355f24068
[]
no_license
davidkm2/globalmetin
9cc63395974eb74b5784a1bf5e733622c7303aa4
d1a21b549c68e311416544e03ca6218351e12d2f
refs/heads/main
2023-05-27T08:10:08.506239
2021-05-24T01:57:37
2021-05-24T01:57:37
370,181,109
2
1
null
null
null
null
UTF-8
C++
false
false
2,694
h
/////////////////////////////////////////////////////////////////////// // IdvGlobals.h // // *** INTERACTIVE DATA VISUALIZATION (IDV) CONFIDENTIAL AND PROPRIETARY INFORMATION *** // // This software is supplied under the terms of a license agreement or // nondisclosure agreement with Interactive Data Visualization, Inc. and // may not be copied, disclosed, or exploited except in accordance with // the terms of that agreement. // // Copyright (c) 2003-2007 IDV, Inc. // All rights reserved in all media. // // IDV, Inc. // http://www.idvinc.com #pragma once #if defined(WIN32) || defined(_XBOX) #pragma warning (disable : 4786 4996) #ifdef STRIP_EXCEPTION_HANDLING #pragma warning (disable : 4530) #endif #endif #include <stdexcept> #include <cstdarg> #include <vector> #include "../SpeedTreeMemory.h" // ps3 (vsprintf) #include <stdio.h> #ifdef PS3 #include <errno.h> #endif // // IDV exception classes, derived from standard C++ exception classes // /////////////////////////////////////////////////////////////////////// // class IdvFileError definition class IdvFileError : public st_string { public: IdvFileError(const st_string& strDetails, bool bAppendSystemError = false) : st_string(strDetails + " [" + (bAppendSystemError ? (st_string(strerror(errno))) : "") + "]") { } }; /////////////////////////////////////////////////////////////////////// // class IdvSystemError definition class IdvSystemError : public st_string { public: IdvSystemError(const st_string& strDetails, bool bAppendSystemError = false) : st_string(strDetails + " [" + (bAppendSystemError ? (st_string(strerror(errno))) : "") + "]") { } }; /////////////////////////////////////////////////////////////////////// // class IdvRuntimeError definition class IdvRuntimeError : public st_string { public: IdvRuntimeError(const st_string& strDetails, bool bAppendSystemError = false) : st_string(strDetails + " [" + (bAppendSystemError ? (st_string(strerror(errno))) : "") + "]") { } }; /////////////////////////////////////////////////////////////////////// // IDV type definitions const int c_nIdvMaxStringSize = 1024; typedef char IdvTmpString[c_nIdvMaxStringSize]; /////////////////////////////////////////////////////////////////////// // IDV global function definitions static inline st_string IdvFormatString(const char* pField, ...) { va_list vlArgs; IdvTmpString szBuffer; va_start(vlArgs, pField); (void) vsprintf(szBuffer, pField, vlArgs); return szBuffer; }
[ "davidkm2012@gmail.com" ]
davidkm2012@gmail.com
5c8aed0130f8d69a313b94403afc39a9c81b86d6
ce039e744725692b430e6a84cc42aae2ee9db22a
/classskills.cpp
9163d8fc2e09bd4b0f7f76f1e94cca68fe501521
[]
no_license
fasa1964/fshkkap
adba0cd0e3ae5249833446d6d5c232835ded1ab6
2eacd2dfe1709f5073be2ef3f845a8328977b3c1
refs/heads/master
2023-02-17T09:11:30.723940
2021-01-20T05:52:05
2021-01-20T05:52:05
288,750,188
0
0
null
null
null
null
UTF-8
C++
false
false
5,741
cpp
#include "classskills.h" ClassSkills::ClassSkills() { m_nr = 0; m_name = ""; m_identifier = ""; m_wert = 0; m_date = QDate(); m_evaluationType = CriteriaTypes::projectNode; } QString ClassSkills::name() const { return m_name; } void ClassSkills::setName(const QString &name) { m_name = name; } QDate ClassSkills::date() const { return m_date; } void ClassSkills::setDate(const QDate &date) { m_date = date; } QString ClassSkills::identifier() const { return m_identifier; } void ClassSkills::setIdentifier(const QString &identifier) { m_identifier = identifier; } QMap<QString, ClassProjekt> ClassSkills::getProjektMap() const { return projektMap; } void ClassSkills::setProjektMap(const QMap<QString, ClassProjekt> &value) { projektMap = value; } QDateTime ClassSkills::getCreatedDate() const { return m_createdDate; } void ClassSkills::setCreatedDate(const QDateTime &createdDate) { m_createdDate = createdDate; } int ClassSkills::getWert() const { return m_wert; } void ClassSkills::setWert(int wert) { m_wert = wert; } QString ClassSkills::getKey() { QString key = name()+"."+identifier(); return key; } bool ClassSkills::isValid() { if(name().isEmpty() || identifier().isEmpty()) return false; else return true; } int ClassSkills::maxPoints() { int maxpunkte = 0; QMapIterator<QString, ClassProjekt> it(projektMap); while (it.hasNext()){ it.next(); maxpunkte = maxpunkte + it.value().maxPoints(); } return maxpunkte; } int ClassSkills::points() { int punkte = 0; QMapIterator<QString, ClassProjekt> it(projektMap); while (it.hasNext()){ it.next(); punkte = punkte + it.value().points(); } return punkte; } bool ClassSkills::isEvaluated() { bool status = false; QMapIterator<QString, ClassProjekt> it(projektMap); while (it.hasNext()) { it.next(); if(it.value().getEvaluated()){ status = true; break; } } return status; } void ClassSkills::setEvaluationType(const CriteriaTypes &type) { m_evaluationType = type; } void ClassSkills::setEvaluationType(int index) { if(index == 0) m_evaluationType = CriteriaTypes::projectNode; if(index == 1) m_evaluationType = CriteriaTypes::identifierNode; } int ClassSkills::getEvaluationIndex() const { int index = -1; if(m_evaluationType == CriteriaTypes::projectNode) index = 0; if(m_evaluationType == CriteriaTypes::identifierNode) index = 1; return index; } QString ClassSkills::getEvaluationText(int index) const { QString text; if(index == 0) text = "Nach Projekten"; if(index == 1) text = "Nach Kennung (Fragen)"; return text; } int ClassSkills::getNr() const { return m_nr; } void ClassSkills::setNr(int nr) { m_nr = nr; } bool ClassSkills::containsProject(const QString &proKey) { return projektMap.keys().contains(proKey); } void ClassSkills::insertProjekt(ClassProjekt pro) { projektMap.insert(pro.getKey(), pro); } bool ClassSkills::removeProject(const QString &proKey) { bool status = false; if(projektMap.remove(proKey) == 1) status = true; return status; } QStringList ClassSkills::projectKeyList() { QStringList keyList; foreach (ClassProjekt p, projektMap.values()) { keyList << p.getKey(); } return keyList; } QMap<QString, double> ClassSkills::getIdentMap() const { return identMap; } void ClassSkills::setIdentMap(const QMap<QString, double> &iMap) { identMap = iMap; } void ClassSkills::setIdentFactor(const QString &key, double value) { identMap.insert(key, value); } double ClassSkills::getIdentFactor(const QString &key) { return identMap.value(key); } double ClassSkills::getIdentPercent(const QString &key) { int mp = 0; int point = 0; double percent = 0.0; foreach (ClassProjekt p, getProjektMap().values()) { if(!p.identifierList().isEmpty()) { point += p.getPointsIdent(key); mp += p.getMaxPointsIdent(key); } } percent = point * 100.0 / mp; return percent; } /// !brief Returns identifier items from /// projects QStringList ClassSkills::getIdentifierList() { QStringList iList; if(getIdentMap().isEmpty()) { foreach (ClassProjekt p, getProjektMap().values()) { QStringList list = p.identifierList(); for(int i = 0; i < list.size(); i++) { if(!iList.contains(list.at(i))) iList << list.at(i); } } } else iList = getIdentMap().keys(); return iList; } QDataStream &operator<<(QDataStream &out, const ClassSkills &dat) { out << dat.getNr() << dat.name() << dat.identifier() << dat.date() << dat.getWert() << dat.getCreatedDate() << dat.getProjektMap() << dat.getIdentMap() << dat.getEvaluationIndex(); return out; } QDataStream &operator>>(QDataStream &in, ClassSkills &dat) { int nr; QString name; QString identifier; QDate date; QDateTime createdDate; int wert; QMap<QString, ClassProjekt> pMap; QMap<QString, double> iMap; int evalType; in >> nr >> name >> identifier >> date >> wert >> createdDate >> pMap >> iMap >> evalType; dat.setNr( nr ); dat.setName( name ); dat.setIdentifier( identifier ); dat.setWert( wert ); dat.setDate( date ); dat.setCreatedDate( createdDate ); dat.setProjektMap( pMap ); dat.setIdentMap( iMap ); dat.setEvaluationType(evalType); return in; }
[ "fasa@nb-saberi.ad.bbs-bassgeige.eu" ]
fasa@nb-saberi.ad.bbs-bassgeige.eu
80f2385ba7a65c0a7cd0a45d2dcc7518d6e7b4eb
ac62cdceb0860477a115b787d03559396164fd57
/EPG.h
3c780104eba5f03cd65e6f4c481debaf20a3fa16
[]
no_license
nmickevicius/epgSim
f03e32406222ea1ece2d581c808bc97c6c998b2e
2d9455b6d541ecf719988971d84fad8c31a7a916
refs/heads/master
2022-12-02T01:53:21.521653
2020-08-06T13:07:35
2020-08-06T13:07:35
285,573,135
0
0
null
null
null
null
UTF-8
C++
false
false
2,294
h
#ifndef EPG_H #define EPG_H #endif #include <iostream> #include <complex> using namespace std; class EPG { int nrf; // maximum number of states int nstates; int idxF0; int nz; // number of points along slice-select axis complex<float>** T; // RF transition state operator public: // constructor EPG(int, int, int); // apply RF transition operator void rf(complex<float>***, float*, float); // overloaded apply RF transition operator void rf(complex<float>***, float*, float, int, int); // apply relaxation and recovery void relax(complex<float>***, float, float, float); // overloaded relaxation and recovery method void relax(complex<float>***, float, float, float, int, int); // apply diffusion operator void diffusion(complex<float>***, float, float, float, float); // overloaded diffusion operator void diffusion(complex<float>***, float, float, float, float, int, int); // dephasing/crushing/shifting operator void dephase(complex<float>***, int); // overloaded dephasing operator void dephase(complex<float>***, int, int, int); // sum F0 signal over slice profile complex<float> F0(complex<float>***); // get maximum number of states int getNumStates(); // get index to Z(k=0) int getIdxZ0(); // get k=0 index int getIdxK0(); // destructor ~EPG(); private: // complex-valued matrix multiplication void mtimes(complex<float>**, complex<float>**, complex<float>**, int, int, int); // overloaded complex-valued matrix multiplication void mtimes(complex<float>**, complex<float>**, complex<float>**, int, int, int, int, int); // build RF transition operator void buildRF(float, float); // dephasing with "positive" crusher gradient void dephasePlus(complex<float>**, complex<float>**, int); // overloaded dephasing with "positive" crusher gradient void dephasePlus(complex<float>**, complex<float>**, int, int, int); // dephasing with "negative" crusher gradient void dephaseMinus(complex<float>**, complex<float>**, int); // overloaded dephasing with "negative" crusher gradient void dephaseMinus(complex<float>**, complex<float>**, int, int, int); }; // end of EPG class
[ "nmickevicius@mcw.edu" ]
nmickevicius@mcw.edu
e1593e0484ef194e8adee6c368a407eeadfb3938
c724fdf29ca151c84dc4e46b460fc388c78e654f
/fractiongui.h
f34771dc887b19ff488e901141b397f8f653f93a
[]
no_license
ConnorMassey01/FractionsGUI
d5a11ef502b186041e29b40cee526f3019e48962
53e6abb93717211ce34fa1b3734a3aeff7b1d6b1
refs/heads/main
2023-08-26T02:14:53.418974
2021-10-31T21:38:37
2021-10-31T21:38:37
423,265,675
0
0
null
null
null
null
UTF-8
C++
false
false
628
h
#ifndef FRACTIONGUI_H #define FRACTIONGUI_H #include <QMainWindow> QT_BEGIN_NAMESPACE namespace Ui { class FractionGUI; } QT_END_NAMESPACE class FractionGUI : public QMainWindow { Q_OBJECT public: FractionGUI(QWidget *parent = nullptr); ~FractionGUI(); void keyPressEvent(QKeyEvent *event); void clearAnswer(); private slots: void on_EqualsButton_clicked(); void on_addButton_clicked(); void on_subtractButton_clicked(); void on_multiplyButton_clicked(); void on_devideButton_clicked(); private: Ui::FractionGUI *ui; }; #endif // FRACTIONGUI_H
[ "noreply@github.com" ]
ConnorMassey01.noreply@github.com
4ab6e0bba9eaa6d53f6ba77709529bceaf57cbec
067690553cf7fa81b5911e8dd4fb405baa96b5b7
/1076/1076.cpp
0ec8c556d28abfff4a7f9dd015c0e22f4f8bb3de
[ "MIT" ]
permissive
isac322/BOJ
4c79aab453c884cb253e7567002fc00e605bc69a
35959dd1a63d75ebca9ed606051f7a649d5c0c7b
refs/heads/master
2021-04-18T22:30:05.273182
2019-02-21T11:36:58
2019-02-21T11:36:58
43,806,421
14
9
null
null
null
null
UTF-8
C++
false
false
613
cpp
#include <cstdio> using namespace std; const int arr[] = { 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000 }; char str[9]; int get() { switch (str[0]) { case 'b': switch (str[1]) { case 'l': if (str[2] == 'a') return 0; else return 6; case 'r': return 1; } case 'r': return 2; case 'o': return 3; case 'y': return 4; case 'g': if (str[3] == 'y') return 8; else return 5; case 'v': return 7; case 'w': return 9; } } int main() { gets(str); long long a = get(); gets(str); a = a * 10 + get(); gets(str); printf("%lld", a*arr[get()]); }
[ "isac322@naver.com" ]
isac322@naver.com
5ea5ae117a1c34341511c2c120d87f5aba060d65
370881312084d8d2ce0f9c8dce147b81a3a9a923
/Game_Code/Code/GameSDK/GameDll/PlayerStateLadder.cpp
b38353adff5465178dde22a0e78a93ec8596236b
[]
no_license
ShadowShell/QuestDrake
3030c396cd691be96819eec0f0f376eb8c64ac89
9be472a977882df97612efb9c18404a5d43e76f5
refs/heads/master
2016-09-05T20:23:14.165400
2015-03-06T14:17:22
2015-03-06T14:17:22
31,463,818
3
2
null
2015-02-28T18:26:22
2015-02-28T13:45:52
C++
UTF-8
C++
false
false
30,507
cpp
#include "StdAfx.h" #include "PlayerStateLadder.h" #include "Player.h" #include "PlayerAnimation.h" #include "PlayerStateUtil.h" #include "EntityUtility/EntityScriptCalls.h" #include "Utility/CryWatch.h" #include "PlayerStateEvents.h" #include "Weapon.h" #include "GameCVars.h" #ifndef _RELEASE #define LadderLog(...) do { if (g_pGameCVars->pl_ladderControl.ladder_logVerbosity > 0) { CryLog ("[LADDER] " __VA_ARGS__); } } while(0) #define LadderLogIndent() INDENT_LOG_DURING_SCOPE(g_pGameCVars->pl_ladderControl.ladder_logVerbosity > 0) static AUTOENUM_BUILDNAMEARRAY(s_onOffAnimTypeNames, ladderAnimTypeList); #else #define LadderLog(...) (void)(0) #define LadderLogIndent(...) (void)(0) #endif #define USE_CLIMB_ANIMATIONS 1 static uint32 s_ladderFractionCRC = 0; class CLadderAction : public TPlayerAction { public: CLadderAction(CPlayerStateLadder * ladderState, CPlayer & player, FragmentID fragmentID, CPlayerStateLadder::ELadderAnimType animType, const char* cameraAnimFactorAtStart, const char* cameraAnimFactorAtEnd /*float cameraAnimFactorAtStart, float cameraAnimFactorAtEnd*/) : TPlayerAction(PP_PlayerActionUrgent, fragmentID), m_ladderState(ladderState), m_player(player), m_animType(animType), m_cameraAnimFactorAtStart(0.f), m_cameraAnimFactorAtEnd(0.f), m_duration(0.f), m_interruptable(false) { IEntity* pLadder = gEnv->pEntitySystem->GetEntity(ladderState->GetLadderId()); if ( pLadder ) { EntityScripts::GetEntityProperty(pLadder, "Camera", cameraAnimFactorAtStart, m_cameraAnimFactorAtStart); EntityScripts::GetEntityProperty(pLadder, "Camera", cameraAnimFactorAtEnd, m_cameraAnimFactorAtEnd); } LadderLog ("Constructing %s instance for %s who's %s a ladder", GetName(), player.GetEntity()->GetEntityTextDescription(), player.IsOnLadder() ? "on" : "not on"); #ifndef _RELEASE ladderState->UpdateNumActions(1); #endif } #ifndef _RELEASE ~CLadderAction() { assert (m_ladderState); m_ladderState->UpdateNumActions(-1); } #endif void InitialiseWithParams(const char * directionText, const char * footText) { const CTagDefinition* pFragTagDef = m_context->controllerDef.GetFragmentTagDef(m_fragmentID); LadderLog ("Initializing %s instance for %s performing action defined in '%s' direction=%s, foot=%s", GetName(), m_player.GetEntity()->GetEntityTextDescription(), pFragTagDef->GetFilename(), directionText, footText); LadderLogIndent(); if (directionText) { pFragTagDef->Set(m_fragTags, pFragTagDef->Find(directionText), true); } if (footText) { pFragTagDef->Set(m_fragTags, pFragTagDef->Find(footText), true); } } void OnInitialise() { #ifndef _RELEASE CRY_ASSERT_TRACE (0, ("Unexpected anim type %d (%s) for %s action", m_animType, s_onOffAnimTypeNames[m_animType], GetName())); #endif } virtual void Enter() { LadderLog ("Entering %s instance for %s", GetName(), m_player.GetEntity()->GetEntityTextDescription()); LadderLogIndent(); TPlayerAction::Enter(); IAnimatedCharacter* pAnimChar = m_player.GetAnimatedCharacter(); if (pAnimChar) { EMovementControlMethod method = m_interruptable ? eMCM_Entity : eMCM_Animation; pAnimChar->SetMovementControlMethods(method, method); } m_player.BlendPartialCameraAnim(m_cameraAnimFactorAtStart, 0.1f); m_player.SetCanTurnBody(false); m_ladderState->InformLadderAnimEnter(m_player, this); } virtual void Exit() { LadderLog ("Exiting %s instance for %s", GetName(), m_player.GetEntity()->GetEntityTextDescription()); LadderLogIndent(); TPlayerAction::Exit(); m_ladderState->InformLadderAnimIsDone(m_player, this); } bool GetIsInterruptable() { return m_interruptable; } void UpdateCameraAnimFactor() { if (GetStatus() == IAction::Installed) { const IScope & rootScope = GetRootScope(); const float timeLeft = rootScope.CalculateFragmentTimeRemaining(); const float duration = max(m_duration, timeLeft); float fractionComplete = 1.f; if (duration > 0.0f) { fractionComplete = 1.f - (timeLeft / duration); } m_duration = duration; m_player.BlendPartialCameraAnim(LERP (m_cameraAnimFactorAtStart, m_cameraAnimFactorAtEnd, fractionComplete), 0.1f); } } protected: CPlayer & m_player; CPlayerStateLadder * m_ladderState; CPlayerStateLadder::ELadderAnimType m_animType; float m_cameraAnimFactorAtStart; float m_cameraAnimFactorAtEnd; float m_duration; bool m_interruptable; }; class CActionLadderGetOn : public CLadderAction { public: DEFINE_ACTION("LadderGetOn"); CActionLadderGetOn(CPlayerStateLadder * ladderState, CPlayer &player, CPlayerStateLadder::ELadderAnimType animType) : CLadderAction(ladderState, player, PlayerMannequin.fragmentIDs.LadderGetOn, animType, "cameraAnimFraction_getOn", "cameraAnimFraction_onLadder") { } virtual void OnInitialise() { switch (m_animType) { case CPlayerStateLadder::kLadderAnimType_atBottom: { InitialiseWithParams( "up", NULL); return; } case CPlayerStateLadder::kLadderAnimType_atTopLeftFoot: { InitialiseWithParams( "down", "left"); return; } case CPlayerStateLadder::kLadderAnimType_atTopRightFoot: { InitialiseWithParams( "down", "right"); return; } } CLadderAction::OnInitialise(); } virtual void Exit() { if (IAnimatedCharacter* pAnimChar = m_player.GetAnimatedCharacter()) { Quat animQuat = pAnimChar->GetAnimLocation().q; m_player.SetViewRotation(animQuat); } CLadderAction::Exit(); } }; class CActionLadderGetOff : public CLadderAction { public: DEFINE_ACTION("LadderGetOff"); CActionLadderGetOff(CPlayerStateLadder * ladderState, CPlayer &player, CPlayerStateLadder::ELadderAnimType animType) : CLadderAction(ladderState, player, PlayerMannequin.fragmentIDs.LadderGetOff, animType, "cameraAnimFraction_onLadder", "cameraAnimFraction_getOff") { } virtual void OnInitialise() { switch (m_animType) { case CPlayerStateLadder::kLadderAnimType_atBottom: { InitialiseWithParams( "down", NULL); return; } case CPlayerStateLadder::kLadderAnimType_atTopLeftFoot: { InitialiseWithParams( "up", "left"); return; } case CPlayerStateLadder::kLadderAnimType_atTopRightFoot: { InitialiseWithParams( "up", "right"); return; } } CLadderAction::OnInitialise(); } virtual void Exit() { if (IAnimatedCharacter* pAnimChar = m_player.GetAnimatedCharacter()) { Quat animQuat = pAnimChar->GetAnimLocation().q; m_player.SetViewRotation(animQuat); } CLadderAction::Exit(); } }; class CActionLadderClimbUpDown : public CLadderAction { public: DEFINE_ACTION("LadderClimbUpDown"); CActionLadderClimbUpDown(CPlayerStateLadder * ladderState, CPlayer &player) : CLadderAction(ladderState, player, PlayerMannequin.fragmentIDs.LadderClimb, CPlayerStateLadder::kLadderAnimType_upLoop, "cameraAnimFraction_onLadder", "cameraAnimFraction_onLadder") { m_interruptable = true; } virtual void OnInitialise() { InitialiseWithParams("up", "loop"); } }; CPlayerStateLadder::CPlayerStateLadder() { #ifndef _RELEASE m_dbgNumActions = 0; #endif m_mostRecentlyEnteredAction = NULL; if (s_ladderFractionCRC == 0) { s_ladderFractionCRC = gEnv->pSystem->GetCrc32Gen()->GetCRC32Lowercase("LadderFraction"); } } void CPlayerStateLadder::SetClientPlayerOnLadder(IEntity * pLadder, bool onOff) { bool renderLadderLast = false; EntityScripts::GetEntityProperty(pLadder, "Camera", "bRenderLadderLast", renderLadderLast); const uint32 applyRenderFlags[2] = {0, ENTITY_SLOT_RENDER_NEAREST}; const uint32 oldFlags = pLadder->GetSlotFlags(0); const uint32 newFlags = (oldFlags & ~ENTITY_SLOT_RENDER_NEAREST) | applyRenderFlags[onOff && renderLadderLast]; pLadder->SetSlotFlags(0, newFlags); } void CPlayerStateLadder::OnUseLadder(CPlayer& player, IEntity* pLadder) { assert (pLadder); LadderLog ("%s has started using ladder %s", player.GetEntity()->GetEntityTextDescription(), pLadder->GetEntityTextDescription()); LadderLogIndent(); #ifndef _RELEASE CRY_ASSERT_TRACE(m_dbgNumActions == 0, ("%s shouldn't have any leftover ladder actions but has %d", player.GetEntity()->GetEntityTextDescription(), m_dbgNumActions)); #endif assert (player.IsOnLadder()); player.UpdateVisibility(); m_playerIsThirdPerson = player.IsThirdPerson(); if (player.IsClient()) { player.GetPlayerInput()->AddInputCancelHandler(this); SetClientPlayerOnLadder(pLadder, true); } const Vec3 worldPos(pLadder->GetWorldPos()); const Vec3 direction(pLadder->GetWorldTM().GetColumn1()); const Vec3 playerEntityPos(player.GetEntity()->GetWorldPos()); float height = 0.f; float horizontalViewLimit = 0.f; float stopClimbingDistanceFromBottom = 0.f; float stopClimbingDistanceFromTop = 0.f; float playerHorizontalOffset = 0.f; float distanceBetweenRungs = 0.f; float verticalUpViewLimit = 0.f; float verticalDownViewLimit = 0.f; float getOnDistanceAwayTop = 0.f; float getOnDistanceAwayBottom = 0.f; bool ladderUseThirdPerson = false; EntityScripts::GetEntityProperty(pLadder, "height", height); EntityScripts::GetEntityProperty(pLadder, "ViewLimits", "horizontalViewLimit", horizontalViewLimit); EntityScripts::GetEntityProperty(pLadder, "Offsets", "stopClimbDistanceFromBottom", stopClimbingDistanceFromBottom); EntityScripts::GetEntityProperty(pLadder, "Offsets", "stopClimbDistanceFromTop", stopClimbingDistanceFromTop); EntityScripts::GetEntityProperty(pLadder, "Offsets", "playerHorizontalOffset", playerHorizontalOffset); EntityScripts::GetEntityProperty(pLadder, "Camera", "distanceBetweenRungs", distanceBetweenRungs); EntityScripts::GetEntityProperty(pLadder, "ViewLimits", "verticalUpViewLimit", verticalUpViewLimit); EntityScripts::GetEntityProperty(pLadder, "ViewLimits", "verticalDownViewLimit", verticalDownViewLimit); EntityScripts::GetEntityProperty(pLadder, "Offsets", "getOnDistanceAwayTop", getOnDistanceAwayTop); EntityScripts::GetEntityProperty(pLadder, "Offsets", "getOnDistanceAwayBottom", getOnDistanceAwayBottom); EntityScripts::GetEntityProperty(pLadder, "Camera", "bUseThirdPersonCamera", ladderUseThirdPerson); const float heightOffsetBottom = stopClimbingDistanceFromBottom; const float heightOffsetTop = stopClimbingDistanceFromTop; m_ladderBottom = worldPos + (direction * playerHorizontalOffset); m_ladderBottom.z += heightOffsetBottom; float ladderClimbableHeight = height - heightOffsetTop - heightOffsetBottom; m_playGetOffAnim = kLadderAnimType_none; m_playGetOnAnim = kLadderAnimType_none; SetMostRecentlyEnteredAction(NULL); m_ladderEntityId = pLadder->GetId(); m_numRungsFromBottomPosition = 0; m_fractionBetweenRungs = 0.f; m_climbInertia = 0.f; m_scaleSettle = 0.f; SendLadderFlowgraphEvent(player, pLadder, "PlayerOn"); const float numberOfRungsFloat = ladderClimbableHeight / distanceBetweenRungs; m_topRungNumber = (uint32) max(0.f, numberOfRungsFloat + 0.5f); player.SetCanTurnBody(false); player.GetActorParams().viewLimits.SetViewLimit(-direction, DEG2RAD(horizontalViewLimit), 0.f, DEG2RAD(verticalUpViewLimit), DEG2RAD(verticalDownViewLimit), SViewLimitParams::eVLS_Ladder); CPlayerStateUtil::PhySetFly( player ); CPlayerStateUtil::CancelCrouchAndProneInputs( player ); IAnimatedCharacter* pAnimChar = player.GetAnimatedCharacter(); if (pAnimChar) { pAnimChar->RequestPhysicalColliderMode(eColliderMode_Disabled, eColliderModeLayer_Game, "CPlayerStateLadder::OnUseLadder"); pAnimChar->EnableRigidCollider(0.45f); } Vec3 snapPlayerToPosition = m_ladderBottom; Quat snapPlayerToRotation = pLadder->GetWorldRotation(); bool playLowerAnimation = true; if (playerEntityPos.z > m_ladderBottom.z + ladderClimbableHeight - 0.1f) { snapPlayerToPosition.z += height; snapPlayerToPosition -= direction * getOnDistanceAwayTop; m_playGetOnAnim = (m_topRungNumber & 1) ? kLadderAnimType_atTopRightFoot : kLadderAnimType_atTopLeftFoot; m_numRungsFromBottomPosition = m_topRungNumber; } else if (playerEntityPos.z < m_ladderBottom.z + 0.1f) { snapPlayerToPosition.z -= heightOffsetBottom; snapPlayerToPosition += direction * getOnDistanceAwayBottom; snapPlayerToRotation *= Quat::CreateRotationZ(gf_PI); m_playGetOnAnim = kLadderAnimType_atBottom; } else { snapPlayerToPosition.z = clamp_tpl(playerEntityPos.z, m_ladderBottom.z, m_ladderBottom.z + ladderClimbableHeight); snapPlayerToRotation *= Quat::CreateRotationZ(gf_PI); playLowerAnimation = false; m_playGetOnAnim = kLadderAnimType_midAirGrab; } if(player.IsInPickAndThrowMode()) { player.HolsterItem(true); } else { CWeapon * pCurrentWeapon = player.GetWeapon(player.GetCurrentItemId()); if (pCurrentWeapon) { pCurrentWeapon->SetPlaySelectAction(playLowerAnimation); } } //player.ScheduleItemSwitch(player.FindOrGiveItem(CEntityClassPtr::NoWeapon)); player.GetEntity()->SetPosRotScale(snapPlayerToPosition, snapPlayerToRotation, Vec3(1.f, 1.f, 1.f)); if (ladderUseThirdPerson) { player.SetThirdPerson(true); } float heightFrac = (m_numRungsFromBottomPosition + m_fractionBetweenRungs) / m_topRungNumber; player.OnUseLadder(m_ladderEntityId, heightFrac); } // Called when the player finishes his exit animation (or from OnExit if it triggers no exit animation) static void LadderExitIsComplete(CPlayer & player) { LadderLog ("Ladder exit is complete"); LadderLogIndent(); assert (! player.IsOnLadder()); player.BlendPartialCameraAnim(0.0f, 0.1f); player.SetCanTurnBody(true); //player.SelectLastValidItem(); if (!player.IsCinematicFlagActive(SPlayerStats::eCinematicFlag_HolsterWeapon)) { player.HolsterItem(false); } IAnimatedCharacter* pAnimChar = player.GetAnimatedCharacter(); if( pAnimChar ) { pAnimChar->SetMovementControlMethods(eMCM_Entity, eMCM_Entity); pAnimChar->ForceRefreshPhysicalColliderMode(); pAnimChar->RequestPhysicalColliderMode(eColliderMode_Undefined, eColliderModeLayer_Game, "CPlayerStateLadder::OnExit()"); pAnimChar->DisableRigidCollider(); } } void CPlayerStateLadder::OnExit( CPlayer& player ) { LadderLog ("%s has stopped using ladder (%s)", player.GetEntity()->GetEntityTextDescription(), s_onOffAnimTypeNames[m_playGetOffAnim]); LadderLogIndent(); assert (! player.IsOnLadder()); player.UpdateVisibility(); IPlayerInput * pPlayerInput = player.GetPlayerInput(); if (pPlayerInput) { pPlayerInput->RemoveInputCancelHandler(this); } IEntity * pLadder = gEnv->pEntitySystem->GetEntity(m_ladderEntityId); if (pLadder) { if (player.IsClient()) { SetClientPlayerOnLadder(pLadder, false); } SendLadderFlowgraphEvent(player, pLadder, "PlayerOff"); } m_ladderBottom.zero(); m_ladderEntityId = 0; player.GetActorParams().viewLimits.ClearViewLimit(SViewLimitParams::eVLS_Ladder); pe_player_dynamics simPar; IPhysicalEntity* piPhysics = player.GetEntity()->GetPhysics(); if (!piPhysics || piPhysics->GetParams(&simPar) == 0) { return; } IAnimatedCharacter* pAnimChar = player.GetAnimatedCharacter(); //player.GetActorStats()->gravity = simPar.gravity; CPlayerStateUtil::PhySetNoFly( player, simPar.gravity ); CPlayerStateUtil::CancelCrouchAndProneInputs( player ); InterruptCurrentAnimation(); SetMostRecentlyEnteredAction(NULL); if (m_playGetOffAnim) { QueueLadderAction (player, new CActionLadderGetOff(this, player, m_playGetOffAnim)); } else { // Finishing the above 'get off' animation will retrieve the player's weapon... if we're not playing one then we unholster it now QueueLadderAction (player, NULL); LadderExitIsComplete(player); } bool ladderUseThirdPerson = false; EntityScripts::GetEntityProperty(pLadder, "Camera", "bUseThirdPersonCamera", ladderUseThirdPerson); if (ladderUseThirdPerson && !m_playerIsThirdPerson) { player.SetThirdPerson(false); } ELadderLeaveLocation loc = eLLL_Drop; if (m_playGetOffAnim == kLadderAnimType_atBottom) { loc = eLLL_Bottom; } else if (m_playGetOffAnim == kLadderAnimType_atTopLeftFoot || m_playGetOffAnim == kLadderAnimType_atTopRightFoot) { loc = eLLL_Top; } player.OnLeaveLadder(loc); } void CPlayerStateLadder::InterruptCurrentAnimation() { if (m_mostRecentlyEnteredAction) { m_mostRecentlyEnteredAction->ForceFinish(); } } void CPlayerStateLadder::QueueLadderAction(CPlayer& player, CLadderAction * action) { LadderLog ("Queuing %s ladder anim '%s'", player.GetEntity()->GetEntityTextDescription(), action ? action->GetName() : "NULL"); LadderLogIndent(); if (action) { player.GetAnimatedCharacter()->GetActionController()->Queue(action); } } void CPlayerStateLadder::SendLadderFlowgraphEvent(CPlayer & player, IEntity * pLadderEntity, const char * eventName) { SEntityEvent event( ENTITY_EVENT_SCRIPT_EVENT ); event.nParam[0] = (INT_PTR)eventName; event.nParam[1] = IEntityClass::EVT_ENTITY; EntityId entityId = player.GetEntityId(); event.nParam[2] = (INT_PTR)&entityId; pLadderEntity->SendEvent(event); } bool CPlayerStateLadder::OnPrePhysicsUpdate( CPlayer& player, const SActorFrameMovementParams &movement, float frameTime ) { Vec3 requiredMovement(ZERO); IEntity * pLadder = gEnv->pEntitySystem->GetEntity(m_ladderEntityId); assert (player.IsOnLadder()); #ifndef _RELEASE if (g_pGameCVars->pl_ladderControl.ladder_logVerbosity) { CryWatch ("[LADDER] RUNG=$3%u/%u$o FRAC=$3%.2f$o: %s is %.2fm up a ladder, move=%.2f - %s, %s, %s, camAnim=%.2f, $7INERTIA=%.2f SETTLE=%.2f", m_numRungsFromBottomPosition, m_topRungNumber, m_fractionBetweenRungs, player.GetEntity()->GetEntityTextDescription(), player.GetEntity()->GetWorldPos().z - m_ladderBottom.z, requiredMovement.z, player.CanTurnBody() ? "$4can turn body$o" : "$3cannot turn body$o", (player.GetEntity()->GetSlotFlags(0) & ENTITY_SLOT_RENDER_NEAREST) ? "render nearest" : "render normal", player.IsOnLadder() ? "$3on a ladder$o" : "$4not on a ladder$o", player.GetActorStats()->partialCameraAnimFactor, m_climbInertia, m_scaleSettle); if (m_mostRecentlyEnteredAction && m_mostRecentlyEnteredAction->GetStatus() == IAction::Installed) { const IScope & animScope = m_mostRecentlyEnteredAction->GetRootScope(); const float timeRemaining = animScope.CalculateFragmentTimeRemaining(); CryWatch ("[LADDER] Animation: '%s' (timeActive=%.2f timeRemaining=%.2f speed=%.2f)", m_mostRecentlyEnteredAction->GetName(), m_mostRecentlyEnteredAction->GetActiveTime(), timeRemaining, m_mostRecentlyEnteredAction->GetSpeedBias()); } else { CryWatch ("[LADDER] Animation: %s", m_mostRecentlyEnteredAction ? "NOT PLAYING" : "NONE"); } } #endif IScriptTable * pEntityScript = pLadder ? pLadder->GetScriptTable() : NULL; SmartScriptTable propertiesTable; if (pEntityScript) { pEntityScript->GetValue("Properties", propertiesTable); } int bUsable = 0; if (pLadder == NULL || (propertiesTable->GetValue("bUsable", bUsable) && bUsable == 0)) { player.StateMachineHandleEventMovement(SStateEventLeaveLadder(eLLL_Drop)); } else if (m_playGetOnAnim != kLadderAnimType_none) { if (!player.IsCinematicFlagActive(SPlayerStats::eCinematicFlag_HolsterWeapon)) { player.HolsterItem(true); } IItem * pItem = player.GetCurrentItem(); bool canPlayGetOnAnim = (pItem == NULL /*|| pItem->GetEntity()->GetClass() == CEntityClassPtr::NoWeapon*/); if (! canPlayGetOnAnim) { // Waiting for player to switch to 'NoWeapon' item - check this is still happening! (If not, warn and play the get on animation anyway - let's not get stuck here!) EntityId switchingToItemID = player.GetActorStats()->exchangeItemStats.switchingToItemID; IEntity * pEntity = gEnv->pEntitySystem->GetEntity(switchingToItemID); if (pEntity == NULL /*|| pEntity->GetClass() != CEntityClassPtr::NoWeapon*/) { GameWarning ("!%s should be switching to 'NoWeapon' but is using %s and switching to %s", player.GetEntity()->GetEntityTextDescription(), pItem->GetEntity()->GetClass()->GetName(), pEntity ? pEntity->GetClass()->GetName() : "<NULL>"); //player.SelectItemByClass(CEntityClassPtr::NoWeapon); canPlayGetOnAnim = true; } } if (canPlayGetOnAnim) { // Currently we don't have a mid-air grab animation, so let's just go straight to the climbing anim if that's why we're here if (m_playGetOnAnim != kLadderAnimType_midAirGrab) { QueueLadderAction (player, new CActionLadderGetOn(this, player, m_playGetOnAnim)); } QueueLadderAction (player, new CActionLadderClimbUpDown(this, player)); m_playGetOnAnim = kLadderAnimType_none; } } else if (m_mostRecentlyEnteredAction && !m_mostRecentlyEnteredAction->GetIsInterruptable()) { m_mostRecentlyEnteredAction->UpdateCameraAnimFactor(); } else if (player.GetActorStats()) { float pushUpDown = movement.desiredVelocity.y; const float deflection = fabsf(pushUpDown); float movementInertiaDecayRate = 0.f; float movementAcceleration = 0.f; float movementSettleSpeed = 0.f; float movementSpeedUpwards = 0.f; float movementSpeedDownwards = 0.f; EntityScripts::GetEntityProperty(pLadder, "Movement", "movementInertiaDecayRate", movementInertiaDecayRate); EntityScripts::GetEntityProperty(pLadder, "Movement", "movementAcceleration", movementAcceleration); EntityScripts::GetEntityProperty(pLadder, "Movement", "movementSettleSpeed", movementSettleSpeed); EntityScripts::GetEntityProperty(pLadder, "Movement", "movementSpeedUpwards", movementSpeedUpwards); EntityScripts::GetEntityProperty(pLadder, "Movement", "movementSpeedDownwards", movementSpeedDownwards); const float inertiaDecayAmount = frameTime * movementInertiaDecayRate * (1.f - deflection); if (m_climbInertia >= 0.f) { if (m_fractionBetweenRungs > 0.5f || m_climbInertia < 0.0001f) { m_climbInertia = max(0.f, m_climbInertia - inertiaDecayAmount); } else { m_climbInertia = min(1.f, m_climbInertia + inertiaDecayAmount * 0.1f); } } else { if (m_fractionBetweenRungs <= 0.5f || m_climbInertia > -0.0001f) { m_climbInertia = min(0.f, m_climbInertia + inertiaDecayAmount); } else { m_climbInertia = max(-1.f, m_climbInertia - inertiaDecayAmount * 0.1f); } } m_climbInertia = clamp_tpl(m_climbInertia + pushUpDown * movementAcceleration * frameTime, -1.f, 1.f); m_scaleSettle = min (m_scaleSettle + inertiaDecayAmount, 1.f - fabsf(m_climbInertia)); const float maxAutoSettleMovement = frameTime * m_scaleSettle * movementSettleSpeed; float settleToHere = (m_fractionBetweenRungs > 0.5f) ? 1.f : 0.f; const float settleOffset = (settleToHere - m_fractionBetweenRungs); m_fractionBetweenRungs += frameTime * m_climbInertia * (float)__fsel (m_climbInertia, movementSpeedUpwards, movementSpeedDownwards) + clamp_tpl(settleOffset, -maxAutoSettleMovement, maxAutoSettleMovement); if (m_fractionBetweenRungs < 0.f) { if (m_numRungsFromBottomPosition > 0) { -- m_numRungsFromBottomPosition; m_fractionBetweenRungs += 1.f; } else { m_fractionBetweenRungs = 0.f; if (pushUpDown < -0.5f) { m_playGetOffAnim = kLadderAnimType_atBottom; } } } else { if (m_fractionBetweenRungs >= 1.f) { ++ m_numRungsFromBottomPosition; m_fractionBetweenRungs -= 1.f; } if (m_topRungNumber == m_numRungsFromBottomPosition) { m_fractionBetweenRungs = 0.f; if (pushUpDown > 0.5f) { int topBlockedValue = 0; const bool bTopIsBlocked = propertiesTable->GetValue("bTopBlocked", topBlockedValue) && topBlockedValue; if (bTopIsBlocked == false) { m_playGetOffAnim = (m_topRungNumber & 1) ? kLadderAnimType_atTopRightFoot : kLadderAnimType_atTopLeftFoot; } #ifndef _RELEASE else if (g_pGameCVars->pl_ladderControl.ladder_logVerbosity) { CryWatch ("[LADDER] %s can't climb up and off %s - top is blocked", player.GetEntity()->GetName(), pLadder->GetEntityTextDescription()); } #endif } } float heightFrac = (m_numRungsFromBottomPosition + m_fractionBetweenRungs) / m_topRungNumber; player.OnLadderPositionUpdated(heightFrac); } float distanceBetweenRungs = 0.f; EntityScripts::GetEntityProperty(pLadder, "Camera", "distanceBetweenRungs", distanceBetweenRungs); const Vec3 stopAtPosBottom = m_ladderBottom; const float distanceUpLadder = (m_numRungsFromBottomPosition + m_fractionBetweenRungs) * /*g_pGameCVars->pl_ladderControl.ladder_*/distanceBetweenRungs; const Vec3 setThisPosition(stopAtPosBottom.x, stopAtPosBottom.y, stopAtPosBottom.z + distanceUpLadder); player.GetEntity()->SetPos(setThisPosition); if (m_mostRecentlyEnteredAction) { const float animFraction = m_fractionBetweenRungs * 0.5f + ((m_numRungsFromBottomPosition & 1) ? 0.5f : 0.0f); #ifndef _RELEASE if (g_pGameCVars->pl_ladderControl.ladder_logVerbosity) { CryWatch ("[LADDER] $7Setting anim fraction to %.4f", animFraction); } #endif m_mostRecentlyEnteredAction->SetParam(s_ladderFractionCRC, animFraction); } } return m_playGetOffAnim == kLadderAnimType_none; } void CPlayerStateLadder::LeaveLadder(CPlayer& player, ELadderLeaveLocation leaveLocation) { switch (leaveLocation) { case eLLL_Drop: player.GetMoveRequest().velocity = Vec3(0.f, 0.f, -1.f); player.GetMoveRequest().type = eCMT_Impulse; break; case eLLL_Top: m_playGetOffAnim = (m_topRungNumber & 1) ? kLadderAnimType_atTopRightFoot : kLadderAnimType_atTopLeftFoot; break; case eLLL_Bottom: m_playGetOffAnim = kLadderAnimType_atBottom; break; } } void CPlayerStateLadder::SetHeightFrac(CPlayer& player, float heightFrac) { heightFrac *= m_topRungNumber; m_numRungsFromBottomPosition = (int)heightFrac; m_fractionBetweenRungs = heightFrac - m_numRungsFromBottomPosition; } bool CPlayerStateLadder::IsUsableLadder(CPlayer& player, IEntity* pLadder, const SmartScriptTable& ladderProperties) { bool retVal = false; if(pLadder && !player.IsOnLadder() && player.CanTurnBody()) { float height = 0.f; ladderProperties->GetValue("height", height); if(height > 0.f) { const Matrix34& ladderTM = pLadder->GetWorldTM(); Vec3 ladderPos = ladderTM.GetTranslation(); Vec3 playerPos = player.GetEntity()->GetWorldPos(); const char* angleVariable = ((playerPos.z + 0.1f) > (ladderPos.z + height)) ? "approachAngleTop" : "approachAngle"; float angleRange = 0.f; ladderProperties->GetValue(angleVariable, angleRange); retVal = true; if(angleRange != 0.f) { Vec2 ladderToPlayer((playerPos - ladderPos)); Vec2 ladderDirection(ladderTM.GetColumn1()); ladderToPlayer.Normalize(); ladderDirection.Normalize(); if(angleRange < 0.f) { //negative angle means you want the middle of the available range to be from the opposite direction angleRange = -angleRange; ladderToPlayer = -ladderToPlayer; } if(ladderToPlayer.Dot(ladderDirection) < cos(DEG2RAD(angleRange))) { retVal = false; } } } } #ifndef _RELEASE if (g_pGameCVars->pl_ladderControl.ladder_logVerbosity) { if (pLadder) { float distanceBetweenRungs = 0.f; float stopClimbingDistanceFromBottom = 0.f; EntityScripts::GetEntityProperty(pLadder, "Camera", "distanceBetweenRungs", distanceBetweenRungs); EntityScripts::GetEntityProperty(pLadder, "Offsets", "stopClimbDistanceFromBottom", stopClimbingDistanceFromBottom); ColorB ladderColour(150, 150, 255, 150); IRenderAuxGeom * pGeom = gEnv->pRenderer->GetIRenderAuxGeom(); const Vec3 ladderBasePos = pLadder->GetWorldPos(); const Matrix34& ladderTM = pLadder->GetWorldTM(); //const float distanceBetweenRungs = /*g_pGameCVars->pl_ladderControl.ladder_*/_distanceBetweenRungs; float height = 0.f; AABB entityBounds; pLadder->GetLocalBounds(entityBounds); const Vec3 rungEndSideways = ladderTM.GetColumn0() * entityBounds.GetSize().x * 0.5f; EntityScripts::GetEntityProperty(pLadder, "height", height); const Vec3 offsetToTop = height * ladderTM.GetColumn2(); for (float rungHeight = stopClimbingDistanceFromBottom; rungHeight < height; rungHeight += distanceBetweenRungs) { const Vec3 rungCentre(ladderBasePos.x, ladderBasePos.y, ladderBasePos.z + rungHeight); pGeom->DrawLine(rungCentre - rungEndSideways, ladderColour, rungCentre + rungEndSideways, ladderColour, 20.f); } pGeom->DrawLine(ladderBasePos - rungEndSideways, ladderColour, ladderBasePos - rungEndSideways + offsetToTop, ladderColour, 20.f); pGeom->DrawLine(ladderBasePos + rungEndSideways, ladderColour, ladderBasePos + rungEndSideways + offsetToTop, ladderColour, 20.f); } CryWatch ("[LADDER] Is %s usable by %s? %s", pLadder ? pLadder->GetEntityTextDescription() : "<NULL ladder entity>", player.GetEntity()->GetEntityTextDescription(), retVal ? "$3YES$o" : "$4NO$o"); } #endif return retVal; } void CPlayerStateLadder::SetMostRecentlyEnteredAction(CLadderAction * thisAction) { if (thisAction) { thisAction->AddRef(); } if (m_mostRecentlyEnteredAction) { m_mostRecentlyEnteredAction->Release(); } m_mostRecentlyEnteredAction = thisAction; } void CPlayerStateLadder::InformLadderAnimEnter(CPlayer & player, CLadderAction * thisAction) { assert (thisAction); LadderLog ("Action '%s' has been entered", thisAction->GetName()); LadderLogIndent(); SetMostRecentlyEnteredAction(thisAction); } void CPlayerStateLadder::InformLadderAnimIsDone(CPlayer & player, CLadderAction * thisAction) { assert (thisAction); LadderLog ("Action '%s' is done", thisAction->GetName()); LadderLogIndent(); if (player.IsClient()) { if (player.IsOnLadder()) { if (IEntity * pLadder = gEnv->pEntitySystem->GetEntity(m_ladderEntityId)) { SetClientPlayerOnLadder(pLadder, true); } } } if (thisAction == m_mostRecentlyEnteredAction) { //SetMostRecentlyEnteredAction(NULL); if (player.IsOnLadder() == false && thisAction->GetIsInterruptable() == false) { LadderExitIsComplete(player); } } } bool CPlayerStateLadder::HandleCancelInput(CPlayer & player, TCancelButtonBitfield cancelButtonPressed) { assert (player.IsOnLadder()); if ((cancelButtonPressed & (kCancelPressFlag_switchItem)) == 0) { if (m_mostRecentlyEnteredAction && m_mostRecentlyEnteredAction->GetIsInterruptable()) { player.StateMachineHandleEventMovement(SStateEventLeaveLadder(eLLL_Drop)); } return true; } return false; } #ifndef _RELEASE void CPlayerStateLadder::UpdateNumActions(int change) { assert (change == 1 || change == -1); assert (m_dbgNumActions >= 0); m_dbgNumActions += change; assert (m_dbgNumActions >= 0); } #endif
[ "cloudcodexmain@gmail.com" ]
cloudcodexmain@gmail.com
4f798ec2e6642a90764beff22ec8f76cc2c194ec
96cfaaa771c2d83fc0729d8c65c4d4707235531a
/OnlineDB/ESCondDB/src/ODScanCycle.cc
b7064ee8b216484af91eed41a5da5324c8366e92
[]
no_license
khotilov/cmssw
a22a160023c7ce0e4d59d15ef1f1532d7227a586
7636f72278ee0796d0203ac113b492b39da33528
refs/heads/master
2021-01-15T18:51:30.061124
2013-04-20T17:18:07
2013-04-20T17:18:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,533
cc
#include <stdexcept> #include "OnlineDB/Oracle/interface/Oracle.h" #include "OnlineDB/ESCondDB/interface/ODScanCycle.h" using namespace std; using namespace oracle::occi; ODScanCycle::ODScanCycle() { m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; // m_ID = 0; m_scan_config_id = 0; } ODScanCycle::~ODScanCycle() { } void ODScanCycle::prepareWrite() throw(runtime_error) { this->checkConnection(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO Es_Scan_Cycle (cycle_id, scan_id ) " "VALUES (:1, :2 )"); } catch (SQLException &e) { throw(runtime_error("ODScanCycle::prepareWrite(): "+e.getMessage())); } } void ODScanCycle::writeDB() throw(runtime_error) { this->checkConnection(); this->checkPrepare(); try { m_writeStmt->setInt(1, this->getId()); m_writeStmt->setInt(2, this->getScanConfigurationID()); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(runtime_error("ODScanCycle::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(runtime_error("ODScanCycle::writeDB: Failed to write")); } } void ODScanCycle::clear(){ m_scan_config_id=0; } int ODScanCycle::fetchID() throw(runtime_error) { // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT cycle_id, scan_id FROM es_scan_cycle " "WHERE cycle_id = :1 "); stmt->setInt(1, m_ID); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); m_scan_config_id = rset->getInt(2); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(runtime_error("ODScanCycle::fetchID: "+e.getMessage())); } return m_ID; } void ODScanCycle::setByID(int id) throw(std::runtime_error) { this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT cycle_id, scan_configuration_id FROM es_scan_cycle " "WHERE cycle_id = :1 "); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); m_scan_config_id = rset->getInt(2); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(runtime_error("ODScanCycle::fetchID: "+e.getMessage())); } } void ODScanCycle::fetchData(ODScanCycle * result) throw(runtime_error) { this->checkConnection(); result->clear(); if(result->getId()==0){ throw(runtime_error("ODScanConfig::fetchData(): no Id defined for this ODScanConfig ")); } try { m_readStmt->setSQL("SELECT scan_configuration_id FROM es_scan_cycle " "WHERE cycle_id = :1 "); m_readStmt->setInt(1, result->getId()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); result->setScanConfigurationID( rset->getInt(1) ); } catch (SQLException &e) { throw(runtime_error("ODScanCycle::fetchData(): "+e.getMessage())); } } void ODScanCycle::insertConfig() throw(std::runtime_error) { try { prepareWrite(); writeDB(); m_conn->commit(); terminateWriteStatement(); } catch (std::runtime_error &e) { m_conn->rollback(); throw(e); } catch (...) { m_conn->rollback(); throw(std::runtime_error("ESCondDBInterface::insertDataSet: Unknown exception caught")); } }
[ "sha1-ff850ba3eb60f38a59d1cf352544350e07f17d5b@cern.ch" ]
sha1-ff850ba3eb60f38a59d1cf352544350e07f17d5b@cern.ch
7c82fa35088b091bf3c51e60fcd8024f81ae280d
5583a6c9556ac5b96148f276573894e242ce1e3f
/src/IO_tools.hpp
abe40350bde3cad220714c5a5746d1fc7fb6a516
[]
no_license
wphu/FV_with_petsc
19e060d2f9578fcf6e66ddf377f1c2a6e541025d
eb6b9262e7e33073b8a9e8229c823c8a7374a4ef
refs/heads/master
2020-03-22T22:56:11.272363
2017-12-18T22:12:30
2017-12-18T22:28:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,358
hpp
// Most of this was copy-pasted from Ryan Davis's PADI software: // https://github.com/rsdavis/ParallelDiffuseInterface-PADI // It provides utilities for reading input parameters from a text file. // The logging code has been removed. #ifndef IO_TOOLS_H #define IO_TOOLS_H #include <map> #include <string> #include "bc.hpp" // Process boundary condition types input from the input file. BC_type convert_to_BCtype(std::string name); // utility function for appending numbers to hdf5 filenames, if there is a series std::string number_filename(std::string base_filename, int counter); template <typename T> // primary template void unpack(std::map<std::string, std::string> params, std::string name, T &parameter); template <> // explicit specialization for T = double void unpack(std::map<std::string, std::string> hash, std::string name, double &parameter); template <> // explicit specialization for T = int void unpack(std::map<std::string, std::string> hash, std::string name, int &parameter); template <> // explicit specialization for T = BC void unpack(std::map<std::string, std::string> hash, std::string name, BC &parameter); void unpack(std::map<std::string, int> name_index, std::string name, int &index); void read_parameters(std::map<std::string, std::string> &params, std::string input_file="input.txt"); #endif
[ "alta@princeton.edu" ]
alta@princeton.edu
94c46e8ada4e108147a67598d0aab4331ae13415
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_5/Z6.0+dmb.ld+dmb.st+dmb.sy.c.cbmc.cpp
995dd249dde68c4f9cdb2871fee0de51429939f6
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
39,965
cpp
// Global variabls: // 4:atom_2_X2_0:1 // 0:vars:3 // 3:atom_1_X0_1:1 // Local global variabls: // 0:thr0:1 // 1:thr1:1 // 2:thr2:1 #define ADDRSIZE 5 #define LOCALADDRSIZE 3 #define NTHREAD 4 #define NCONTEXT 5 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // Declare arrays for intial value version in contexts int local_mem[LOCALADDRSIZE]; // Dumping initializations local_mem[0+0] = 0; local_mem[1+0] = 0; local_mem[2+0] = 0; int cstart[NTHREAD]; int creturn[NTHREAD]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NTHREAD*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NTHREAD*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NTHREAD*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NTHREAD*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NTHREAD*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NTHREAD*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NTHREAD*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NTHREAD*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NTHREAD*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NTHREAD]; int cdy[NTHREAD]; int cds[NTHREAD]; int cdl[NTHREAD]; int cisb[NTHREAD]; int caddr[NTHREAD]; int cctrl[NTHREAD]; __LOCALS__ buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); buff(3,0) = 0; pw(3,0) = 0; cr(3,0) = 0; iw(3,0) = 0; cw(3,0) = 0; cx(3,0) = 0; is(3,0) = 0; cs(3,0) = 0; crmax(3,0) = 0; buff(3,1) = 0; pw(3,1) = 0; cr(3,1) = 0; iw(3,1) = 0; cw(3,1) = 0; cx(3,1) = 0; is(3,1) = 0; cs(3,1) = 0; crmax(3,1) = 0; buff(3,2) = 0; pw(3,2) = 0; cr(3,2) = 0; iw(3,2) = 0; cw(3,2) = 0; cx(3,2) = 0; is(3,2) = 0; cs(3,2) = 0; crmax(3,2) = 0; buff(3,3) = 0; pw(3,3) = 0; cr(3,3) = 0; iw(3,3) = 0; cw(3,3) = 0; cx(3,3) = 0; is(3,3) = 0; cs(3,3) = 0; crmax(3,3) = 0; buff(3,4) = 0; pw(3,4) = 0; cr(3,4) = 0; iw(3,4) = 0; cw(3,4) = 0; cx(3,4) = 0; is(3,4) = 0; cs(3,4) = 0; crmax(3,4) = 0; cl[3] = 0; cdy[3] = 0; cds[3] = 0; cdl[3] = 0; cisb[3] = 0; caddr[3] = 0; cctrl[3] = 0; cstart[3] = get_rng(0,NCONTEXT-1); creturn[3] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(4+0,0) = 0; mem(0+0,0) = 0; mem(0+1,0) = 0; mem(0+2,0) = 0; mem(3+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; mem(0,1) = meminit(0,1); co(0,1) = coinit(0,1); delta(0,1) = deltainit(0,1); mem(0,2) = meminit(0,2); co(0,2) = coinit(0,2); delta(0,2) = deltainit(0,2); mem(0,3) = meminit(0,3); co(0,3) = coinit(0,3); delta(0,3) = deltainit(0,3); mem(0,4) = meminit(0,4); co(0,4) = coinit(0,4); delta(0,4) = deltainit(0,4); co(1,0) = 0; delta(1,0) = -1; mem(1,1) = meminit(1,1); co(1,1) = coinit(1,1); delta(1,1) = deltainit(1,1); mem(1,2) = meminit(1,2); co(1,2) = coinit(1,2); delta(1,2) = deltainit(1,2); mem(1,3) = meminit(1,3); co(1,3) = coinit(1,3); delta(1,3) = deltainit(1,3); mem(1,4) = meminit(1,4); co(1,4) = coinit(1,4); delta(1,4) = deltainit(1,4); co(2,0) = 0; delta(2,0) = -1; mem(2,1) = meminit(2,1); co(2,1) = coinit(2,1); delta(2,1) = deltainit(2,1); mem(2,2) = meminit(2,2); co(2,2) = coinit(2,2); delta(2,2) = deltainit(2,2); mem(2,3) = meminit(2,3); co(2,3) = coinit(2,3); delta(2,3) = deltainit(2,3); mem(2,4) = meminit(2,4); co(2,4) = coinit(2,4); delta(2,4) = deltainit(2,4); co(3,0) = 0; delta(3,0) = -1; mem(3,1) = meminit(3,1); co(3,1) = coinit(3,1); delta(3,1) = deltainit(3,1); mem(3,2) = meminit(3,2); co(3,2) = coinit(3,2); delta(3,2) = deltainit(3,2); mem(3,3) = meminit(3,3); co(3,3) = coinit(3,3); delta(3,3) = deltainit(3,3); mem(3,4) = meminit(3,4); co(3,4) = coinit(3,4); delta(3,4) = deltainit(3,4); co(4,0) = 0; delta(4,0) = -1; mem(4,1) = meminit(4,1); co(4,1) = coinit(4,1); delta(4,1) = deltainit(4,1); mem(4,2) = meminit(4,2); co(4,2) = coinit(4,2); delta(4,2) = deltainit(4,2); mem(4,3) = meminit(4,3); co(4,3) = coinit(4,3); delta(4,3) = deltainit(4,3); mem(4,4) = meminit(4,4); co(4,4) = coinit(4,4); delta(4,4) = deltainit(4,4); // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !36, metadata !DIExpression()), !dbg !45 // br label %label_1, !dbg !46 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !44), !dbg !47 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !37, metadata !DIExpression()), !dbg !48 // call void @llvm.dbg.value(metadata i64 1, metadata !40, metadata !DIExpression()), !dbg !48 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !49 // ST: Guess iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l20_c3 old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l20_c3 // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; ASSUME(creturn[1] >= cw(1,0)); // call void (...) @dmbld(), !dbg !50 // dumbld: Guess cdl[1] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdl[1] >= cdy[1]); ASSUME(cdl[1] >= cr(1,4+0)); ASSUME(cdl[1] >= cr(1,0+0)); ASSUME(cdl[1] >= cr(1,0+1)); ASSUME(cdl[1] >= cr(1,0+2)); ASSUME(cdl[1] >= cr(1,3+0)); ASSUME(creturn[1] >= cdl[1]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !41, metadata !DIExpression()), !dbg !51 // call void @llvm.dbg.value(metadata i64 1, metadata !43, metadata !DIExpression()), !dbg !51 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !52 // ST: Guess iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l22_c3 old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l22_c3 // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; ASSUME(creturn[1] >= cw(1,0+1*1)); // ret i8* null, !dbg !53 ret_thread_1 = (- 1); goto T1BLOCK_END; T1BLOCK_END: // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !56, metadata !DIExpression()), !dbg !66 // br label %label_2, !dbg !48 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !65), !dbg !68 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !58, metadata !DIExpression()), !dbg !69 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !51 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l28_c15 // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); // Update creg_r0 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r0 = buff(2,0+1*1); ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0)); ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0)); ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0)); ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0)); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r0 = mem(0+1*1,cr(2,0+1*1)); } ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !60, metadata !DIExpression()), !dbg !69 // %conv = trunc i64 %0 to i32, !dbg !52 // call void @llvm.dbg.value(metadata i32 %conv, metadata !57, metadata !DIExpression()), !dbg !66 // call void (...) @dmbst(), !dbg !53 // dumbst: Guess cds[2] = get_rng(0,NCONTEXT-1); // Check ASSUME(cds[2] >= cdy[2]); ASSUME(cds[2] >= cw(2,4+0)); ASSUME(cds[2] >= cw(2,0+0)); ASSUME(cds[2] >= cw(2,0+1)); ASSUME(cds[2] >= cw(2,0+2)); ASSUME(cds[2] >= cw(2,3+0)); ASSUME(creturn[2] >= cds[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !61, metadata !DIExpression()), !dbg !73 // call void @llvm.dbg.value(metadata i64 1, metadata !63, metadata !DIExpression()), !dbg !73 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !55 // ST: Guess iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l30_c3 old_cw = cw(2,0+2*1); cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l30_c3 // Check ASSUME(active[iw(2,0+2*1)] == 2); ASSUME(active[cw(2,0+2*1)] == 2); ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(cw(2,0+2*1) >= iw(2,0+2*1)); ASSUME(cw(2,0+2*1) >= old_cw); ASSUME(cw(2,0+2*1) >= cr(2,0+2*1)); ASSUME(cw(2,0+2*1) >= cl[2]); ASSUME(cw(2,0+2*1) >= cisb[2]); ASSUME(cw(2,0+2*1) >= cdy[2]); ASSUME(cw(2,0+2*1) >= cdl[2]); ASSUME(cw(2,0+2*1) >= cds[2]); ASSUME(cw(2,0+2*1) >= cctrl[2]); ASSUME(cw(2,0+2*1) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,0+2*1) = 1; mem(0+2*1,cw(2,0+2*1)) = 1; co(0+2*1,cw(2,0+2*1))+=1; delta(0+2*1,cw(2,0+2*1)) = -1; ASSUME(creturn[2] >= cw(2,0+2*1)); // %cmp = icmp eq i32 %conv, 1, !dbg !56 creg__r0__1_ = max(0,creg_r0); // %conv1 = zext i1 %cmp to i32, !dbg !56 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !64, metadata !DIExpression()), !dbg !66 // store i32 %conv1, i32* @atom_1_X0_1, align 4, !dbg !57, !tbaa !58 // ST: Guess iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l32_c15 old_cw = cw(2,3); cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l32_c15 // Check ASSUME(active[iw(2,3)] == 2); ASSUME(active[cw(2,3)] == 2); ASSUME(sforbid(3,cw(2,3))== 0); ASSUME(iw(2,3) >= creg__r0__1_); ASSUME(iw(2,3) >= 0); ASSUME(cw(2,3) >= iw(2,3)); ASSUME(cw(2,3) >= old_cw); ASSUME(cw(2,3) >= cr(2,3)); ASSUME(cw(2,3) >= cl[2]); ASSUME(cw(2,3) >= cisb[2]); ASSUME(cw(2,3) >= cdy[2]); ASSUME(cw(2,3) >= cdl[2]); ASSUME(cw(2,3) >= cds[2]); ASSUME(cw(2,3) >= cctrl[2]); ASSUME(cw(2,3) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,3) = (r0==1); mem(3,cw(2,3)) = (r0==1); co(3,cw(2,3))+=1; delta(3,cw(2,3)) = -1; ASSUME(creturn[2] >= cw(2,3)); // ret i8* null, !dbg !62 ret_thread_2 = (- 1); goto T2BLOCK_END; T2BLOCK_END: // Dumping thread 3 int ret_thread_3 = 0; cdy[3] = get_rng(0,NCONTEXT-1); ASSUME(cdy[3] >= cstart[3]); T3BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !84, metadata !DIExpression()), !dbg !94 // br label %label_3, !dbg !48 goto T3BLOCK1; T3BLOCK1: // call void @llvm.dbg.label(metadata !93), !dbg !96 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !85, metadata !DIExpression()), !dbg !97 // call void @llvm.dbg.value(metadata i64 2, metadata !87, metadata !DIExpression()), !dbg !97 // store atomic i64 2, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !51 // ST: Guess iw(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l38_c3 old_cw = cw(3,0+2*1); cw(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l38_c3 // Check ASSUME(active[iw(3,0+2*1)] == 3); ASSUME(active[cw(3,0+2*1)] == 3); ASSUME(sforbid(0+2*1,cw(3,0+2*1))== 0); ASSUME(iw(3,0+2*1) >= 0); ASSUME(iw(3,0+2*1) >= 0); ASSUME(cw(3,0+2*1) >= iw(3,0+2*1)); ASSUME(cw(3,0+2*1) >= old_cw); ASSUME(cw(3,0+2*1) >= cr(3,0+2*1)); ASSUME(cw(3,0+2*1) >= cl[3]); ASSUME(cw(3,0+2*1) >= cisb[3]); ASSUME(cw(3,0+2*1) >= cdy[3]); ASSUME(cw(3,0+2*1) >= cdl[3]); ASSUME(cw(3,0+2*1) >= cds[3]); ASSUME(cw(3,0+2*1) >= cctrl[3]); ASSUME(cw(3,0+2*1) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,0+2*1) = 2; mem(0+2*1,cw(3,0+2*1)) = 2; co(0+2*1,cw(3,0+2*1))+=1; delta(0+2*1,cw(3,0+2*1)) = -1; ASSUME(creturn[3] >= cw(3,0+2*1)); // call void (...) @dmbsy(), !dbg !52 // dumbsy: Guess old_cdy = cdy[3]; cdy[3] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[3] >= old_cdy); ASSUME(cdy[3] >= cisb[3]); ASSUME(cdy[3] >= cdl[3]); ASSUME(cdy[3] >= cds[3]); ASSUME(cdy[3] >= cctrl[3]); ASSUME(cdy[3] >= cw(3,4+0)); ASSUME(cdy[3] >= cw(3,0+0)); ASSUME(cdy[3] >= cw(3,0+1)); ASSUME(cdy[3] >= cw(3,0+2)); ASSUME(cdy[3] >= cw(3,3+0)); ASSUME(cdy[3] >= cr(3,4+0)); ASSUME(cdy[3] >= cr(3,0+0)); ASSUME(cdy[3] >= cr(3,0+1)); ASSUME(cdy[3] >= cr(3,0+2)); ASSUME(cdy[3] >= cr(3,3+0)); ASSUME(creturn[3] >= cdy[3]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !89, metadata !DIExpression()), !dbg !100 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !54 // LD: Guess old_cr = cr(3,0); cr(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l40_c15 // Check ASSUME(active[cr(3,0)] == 3); ASSUME(cr(3,0) >= iw(3,0)); ASSUME(cr(3,0) >= 0); ASSUME(cr(3,0) >= cdy[3]); ASSUME(cr(3,0) >= cisb[3]); ASSUME(cr(3,0) >= cdl[3]); ASSUME(cr(3,0) >= cl[3]); // Update creg_r1 = cr(3,0); crmax(3,0) = max(crmax(3,0),cr(3,0)); caddr[3] = max(caddr[3],0); if(cr(3,0) < cw(3,0)) { r1 = buff(3,0); ASSUME((!(( (cw(3,0) < 1) && (1 < crmax(3,0)) )))||(sforbid(0,1)> 0)); ASSUME((!(( (cw(3,0) < 2) && (2 < crmax(3,0)) )))||(sforbid(0,2)> 0)); ASSUME((!(( (cw(3,0) < 3) && (3 < crmax(3,0)) )))||(sforbid(0,3)> 0)); ASSUME((!(( (cw(3,0) < 4) && (4 < crmax(3,0)) )))||(sforbid(0,4)> 0)); } else { if(pw(3,0) != co(0,cr(3,0))) { ASSUME(cr(3,0) >= old_cr); } pw(3,0) = co(0,cr(3,0)); r1 = mem(0,cr(3,0)); } ASSUME(creturn[3] >= cr(3,0)); // call void @llvm.dbg.value(metadata i64 %0, metadata !91, metadata !DIExpression()), !dbg !100 // %conv = trunc i64 %0 to i32, !dbg !55 // call void @llvm.dbg.value(metadata i32 %conv, metadata !88, metadata !DIExpression()), !dbg !94 // %cmp = icmp eq i32 %conv, 0, !dbg !56 creg__r1__0_ = max(0,creg_r1); // %conv1 = zext i1 %cmp to i32, !dbg !56 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !92, metadata !DIExpression()), !dbg !94 // store i32 %conv1, i32* @atom_2_X2_0, align 4, !dbg !57, !tbaa !58 // ST: Guess iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l42_c15 old_cw = cw(3,4); cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l42_c15 // Check ASSUME(active[iw(3,4)] == 3); ASSUME(active[cw(3,4)] == 3); ASSUME(sforbid(4,cw(3,4))== 0); ASSUME(iw(3,4) >= creg__r1__0_); ASSUME(iw(3,4) >= 0); ASSUME(cw(3,4) >= iw(3,4)); ASSUME(cw(3,4) >= old_cw); ASSUME(cw(3,4) >= cr(3,4)); ASSUME(cw(3,4) >= cl[3]); ASSUME(cw(3,4) >= cisb[3]); ASSUME(cw(3,4) >= cdy[3]); ASSUME(cw(3,4) >= cdl[3]); ASSUME(cw(3,4) >= cds[3]); ASSUME(cw(3,4) >= cctrl[3]); ASSUME(cw(3,4) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,4) = (r1==0); mem(4,cw(3,4)) = (r1==0); co(4,cw(3,4))+=1; delta(4,cw(3,4)) = -1; ASSUME(creturn[3] >= cw(3,4)); // ret i8* null, !dbg !62 ret_thread_3 = (- 1); goto T3BLOCK_END; T3BLOCK_END: // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // %thr2 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !113, metadata !DIExpression()), !dbg !139 // call void @llvm.dbg.value(metadata i8** %argv, metadata !114, metadata !DIExpression()), !dbg !139 // %0 = bitcast i64* %thr0 to i8*, !dbg !67 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #6, !dbg !67 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !115, metadata !DIExpression()), !dbg !141 // %1 = bitcast i64* %thr1 to i8*, !dbg !69 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #6, !dbg !69 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !119, metadata !DIExpression()), !dbg !143 // %2 = bitcast i64* %thr2 to i8*, !dbg !71 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #6, !dbg !71 // call void @llvm.dbg.declare(metadata i64* %thr2, metadata !120, metadata !DIExpression()), !dbg !145 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !121, metadata !DIExpression()), !dbg !146 // call void @llvm.dbg.value(metadata i64 0, metadata !123, metadata !DIExpression()), !dbg !146 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !74 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l51_c3 old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l51_c3 // Check ASSUME(active[iw(0,0+2*1)] == 0); ASSUME(active[cw(0,0+2*1)] == 0); ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(cw(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cw(0,0+2*1) >= old_cw); ASSUME(cw(0,0+2*1) >= cr(0,0+2*1)); ASSUME(cw(0,0+2*1) >= cl[0]); ASSUME(cw(0,0+2*1) >= cisb[0]); ASSUME(cw(0,0+2*1) >= cdy[0]); ASSUME(cw(0,0+2*1) >= cdl[0]); ASSUME(cw(0,0+2*1) >= cds[0]); ASSUME(cw(0,0+2*1) >= cctrl[0]); ASSUME(cw(0,0+2*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+2*1) = 0; mem(0+2*1,cw(0,0+2*1)) = 0; co(0+2*1,cw(0,0+2*1))+=1; delta(0+2*1,cw(0,0+2*1)) = -1; ASSUME(creturn[0] >= cw(0,0+2*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !124, metadata !DIExpression()), !dbg !148 // call void @llvm.dbg.value(metadata i64 0, metadata !126, metadata !DIExpression()), !dbg !148 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !76 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l52_c3 old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l52_c3 // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !127, metadata !DIExpression()), !dbg !150 // call void @llvm.dbg.value(metadata i64 0, metadata !129, metadata !DIExpression()), !dbg !150 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !78 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l53_c3 old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l53_c3 // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // store i32 0, i32* @atom_1_X0_1, align 4, !dbg !79, !tbaa !80 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l54_c15 old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l54_c15 // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // store i32 0, i32* @atom_2_X2_0, align 4, !dbg !84, !tbaa !80 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l55_c15 old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l55_c15 // Check ASSUME(active[iw(0,4)] == 0); ASSUME(active[cw(0,4)] == 0); ASSUME(sforbid(4,cw(0,4))== 0); ASSUME(iw(0,4) >= 0); ASSUME(iw(0,4) >= 0); ASSUME(cw(0,4) >= iw(0,4)); ASSUME(cw(0,4) >= old_cw); ASSUME(cw(0,4) >= cr(0,4)); ASSUME(cw(0,4) >= cl[0]); ASSUME(cw(0,4) >= cisb[0]); ASSUME(cw(0,4) >= cdy[0]); ASSUME(cw(0,4) >= cdl[0]); ASSUME(cw(0,4) >= cds[0]); ASSUME(cw(0,4) >= cctrl[0]); ASSUME(cw(0,4) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,4) = 0; mem(4,cw(0,4)) = 0; co(4,cw(0,4))+=1; delta(4,cw(0,4)) = -1; ASSUME(creturn[0] >= cw(0,4)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #6, !dbg !85 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call5 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #6, !dbg !86 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %call6 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #6, !dbg !87 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[3] >= cdy[0]); // %3 = load i64, i64* %thr0, align 8, !dbg !88, !tbaa !89 r3 = local_mem[0]; // %call7 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !91 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %4 = load i64, i64* %thr1, align 8, !dbg !92, !tbaa !89 r4 = local_mem[1]; // %call8 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !93 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // %5 = load i64, i64* %thr2, align 8, !dbg !94, !tbaa !89 r5 = local_mem[2]; // %call9 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !95 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[3]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !131, metadata !DIExpression()), !dbg !165 // %6 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !97 // LD: Guess old_cr = cr(0,0+2*1); cr(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l65_c12 // Check ASSUME(active[cr(0,0+2*1)] == 0); ASSUME(cr(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cr(0,0+2*1) >= 0); ASSUME(cr(0,0+2*1) >= cdy[0]); ASSUME(cr(0,0+2*1) >= cisb[0]); ASSUME(cr(0,0+2*1) >= cdl[0]); ASSUME(cr(0,0+2*1) >= cl[0]); // Update creg_r6 = cr(0,0+2*1); crmax(0,0+2*1) = max(crmax(0,0+2*1),cr(0,0+2*1)); caddr[0] = max(caddr[0],0); if(cr(0,0+2*1) < cw(0,0+2*1)) { r6 = buff(0,0+2*1); ASSUME((!(( (cw(0,0+2*1) < 1) && (1 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,1)> 0)); ASSUME((!(( (cw(0,0+2*1) < 2) && (2 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,2)> 0)); ASSUME((!(( (cw(0,0+2*1) < 3) && (3 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,3)> 0)); ASSUME((!(( (cw(0,0+2*1) < 4) && (4 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,4)> 0)); } else { if(pw(0,0+2*1) != co(0+2*1,cr(0,0+2*1))) { ASSUME(cr(0,0+2*1) >= old_cr); } pw(0,0+2*1) = co(0+2*1,cr(0,0+2*1)); r6 = mem(0+2*1,cr(0,0+2*1)); } ASSUME(creturn[0] >= cr(0,0+2*1)); // call void @llvm.dbg.value(metadata i64 %6, metadata !133, metadata !DIExpression()), !dbg !165 // %conv = trunc i64 %6 to i32, !dbg !98 // call void @llvm.dbg.value(metadata i32 %conv, metadata !130, metadata !DIExpression()), !dbg !139 // %cmp = icmp eq i32 %conv, 2, !dbg !99 creg__r6__2_ = max(0,creg_r6); // %conv10 = zext i1 %cmp to i32, !dbg !99 // call void @llvm.dbg.value(metadata i32 %conv10, metadata !134, metadata !DIExpression()), !dbg !139 // %7 = load i32, i32* @atom_1_X0_1, align 4, !dbg !100, !tbaa !80 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l67_c12 // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r7 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r7 = buff(0,3); ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0)); ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0)); ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0)); ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0)); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r7 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i32 %7, metadata !135, metadata !DIExpression()), !dbg !139 // %8 = load i32, i32* @atom_2_X2_0, align 4, !dbg !101, !tbaa !80 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l68_c13 // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r8 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r8 = buff(0,4); ASSUME((!(( (cw(0,4) < 1) && (1 < crmax(0,4)) )))||(sforbid(4,1)> 0)); ASSUME((!(( (cw(0,4) < 2) && (2 < crmax(0,4)) )))||(sforbid(4,2)> 0)); ASSUME((!(( (cw(0,4) < 3) && (3 < crmax(0,4)) )))||(sforbid(4,3)> 0)); ASSUME((!(( (cw(0,4) < 4) && (4 < crmax(0,4)) )))||(sforbid(4,4)> 0)); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r8 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // call void @llvm.dbg.value(metadata i32 %8, metadata !136, metadata !DIExpression()), !dbg !139 // %and = and i32 %7, %8, !dbg !102 creg_r9 = max(creg_r7,creg_r8); r9 = r7 & r8; // call void @llvm.dbg.value(metadata i32 %and, metadata !137, metadata !DIExpression()), !dbg !139 // %and11 = and i32 %conv10, %and, !dbg !103 creg_r10 = max(creg__r6__2_,creg_r9); r10 = (r6==2) & r9; // call void @llvm.dbg.value(metadata i32 %and11, metadata !138, metadata !DIExpression()), !dbg !139 // %cmp12 = icmp eq i32 %and11, 1, !dbg !104 creg__r10__1_ = max(0,creg_r10); // br i1 %cmp12, label %if.then, label %if.end, !dbg !106 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg__r10__1_); if((r10==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0), i32 noundef 71, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #7, !dbg !107 // unreachable, !dbg !107 r11 = 1; goto T0BLOCK_END; T0BLOCK2: // %9 = bitcast i64* %thr2 to i8*, !dbg !110 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #6, !dbg !110 // %10 = bitcast i64* %thr1 to i8*, !dbg !110 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #6, !dbg !110 // %11 = bitcast i64* %thr0 to i8*, !dbg !110 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #6, !dbg !110 // ret i32 0, !dbg !111 ret_thread_0 = 0; goto T0BLOCK_END; T0BLOCK_END: ASSUME(meminit(0,1) == mem(0,0)); ASSUME(coinit(0,1) == co(0,0)); ASSUME(deltainit(0,1) == delta(0,0)); ASSUME(meminit(0,2) == mem(0,1)); ASSUME(coinit(0,2) == co(0,1)); ASSUME(deltainit(0,2) == delta(0,1)); ASSUME(meminit(0,3) == mem(0,2)); ASSUME(coinit(0,3) == co(0,2)); ASSUME(deltainit(0,3) == delta(0,2)); ASSUME(meminit(0,4) == mem(0,3)); ASSUME(coinit(0,4) == co(0,3)); ASSUME(deltainit(0,4) == delta(0,3)); ASSUME(meminit(1,1) == mem(1,0)); ASSUME(coinit(1,1) == co(1,0)); ASSUME(deltainit(1,1) == delta(1,0)); ASSUME(meminit(1,2) == mem(1,1)); ASSUME(coinit(1,2) == co(1,1)); ASSUME(deltainit(1,2) == delta(1,1)); ASSUME(meminit(1,3) == mem(1,2)); ASSUME(coinit(1,3) == co(1,2)); ASSUME(deltainit(1,3) == delta(1,2)); ASSUME(meminit(1,4) == mem(1,3)); ASSUME(coinit(1,4) == co(1,3)); ASSUME(deltainit(1,4) == delta(1,3)); ASSUME(meminit(2,1) == mem(2,0)); ASSUME(coinit(2,1) == co(2,0)); ASSUME(deltainit(2,1) == delta(2,0)); ASSUME(meminit(2,2) == mem(2,1)); ASSUME(coinit(2,2) == co(2,1)); ASSUME(deltainit(2,2) == delta(2,1)); ASSUME(meminit(2,3) == mem(2,2)); ASSUME(coinit(2,3) == co(2,2)); ASSUME(deltainit(2,3) == delta(2,2)); ASSUME(meminit(2,4) == mem(2,3)); ASSUME(coinit(2,4) == co(2,3)); ASSUME(deltainit(2,4) == delta(2,3)); ASSUME(meminit(3,1) == mem(3,0)); ASSUME(coinit(3,1) == co(3,0)); ASSUME(deltainit(3,1) == delta(3,0)); ASSUME(meminit(3,2) == mem(3,1)); ASSUME(coinit(3,2) == co(3,1)); ASSUME(deltainit(3,2) == delta(3,1)); ASSUME(meminit(3,3) == mem(3,2)); ASSUME(coinit(3,3) == co(3,2)); ASSUME(deltainit(3,3) == delta(3,2)); ASSUME(meminit(3,4) == mem(3,3)); ASSUME(coinit(3,4) == co(3,3)); ASSUME(deltainit(3,4) == delta(3,3)); ASSUME(meminit(4,1) == mem(4,0)); ASSUME(coinit(4,1) == co(4,0)); ASSUME(deltainit(4,1) == delta(4,0)); ASSUME(meminit(4,2) == mem(4,1)); ASSUME(coinit(4,2) == co(4,1)); ASSUME(deltainit(4,2) == delta(4,1)); ASSUME(meminit(4,3) == mem(4,2)); ASSUME(coinit(4,3) == co(4,2)); ASSUME(deltainit(4,3) == delta(4,2)); ASSUME(meminit(4,4) == mem(4,3)); ASSUME(coinit(4,4) == co(4,3)); ASSUME(deltainit(4,4) == delta(4,3)); ASSERT(r11== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
4847e08334596aeba7ee9524840047774ee898ca
703cc1b788895b98331f52dc6e87ac6ec1910e35
/src/descriptor/countryavailabilitydescriptor.cpp
a91025a00cecc434810461f9476fc02186d0158d
[]
no_license
ioxuy/dvb_si_psi_parser
1509942fb116ec23cb0ded94fffa24788864526b
75f8fb87734ff6211e895356d4e1f8087c6fbf54
refs/heads/master
2021-06-04T22:13:06.628804
2016-09-08T05:17:47
2016-09-08T05:17:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,648
cpp
/* *Original Author: shko */ #include <countryavailabilitydescriptor.h> CountryAvailabilityDescriptor::Country::Country(const std::string countryCode) : countryCode(countryCode) { ; } CountryAvailabilityDescriptor::Country::~Country(void) { ; } std::string CountryAvailabilityDescriptor::Country::getCountryCode() { return countryCode; } CountryAvailabilityDescriptor::CountryAvailabilityDescriptor(const char* buffer, const int offset, const TableSection* parent) : Descriptor(buffer, offset, parent), country_availability_flag((Utils::getInt(buffer, offset + 2, 1, 0x80) >> 7) ? true : false) { int t = 0; while (t < (descriptorLength - 1)) { const std::string languageCode = std::string((char*)&buffer[offset + t + 3], 3); Country* s = new Country(languageCode); countryVector.push_back(s); t += 3; } } CountryAvailabilityDescriptor::~CountryAvailabilityDescriptor(void) { for(CountryIterator i = countryVector.begin(); i != countryVector.end(); ++i) delete *i; } bool CountryAvailabilityDescriptor::getCountryAvailabilityFlag() { return country_availability_flag; } std::vector<CountryAvailabilityDescriptor::Country*>* CountryAvailabilityDescriptor::getCountryVector() { return &countryVector; } std::string CountryAvailabilityDescriptor::getCountryAvailabilityFlagString(const int flag) { switch (flag) { case 0x00: return "reception of the service is not intended"; case 0x01: return "reception of the service is intended"; default: return "Illegal value"; } }
[ "sh.ko@lge.com" ]
sh.ko@lge.com
07db102e8ba3cd377d571dac137a880ab0afbe8b
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_win_linux.cc
0010c7bfa601deedbfb141c54dd541cceabf178f
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
30,059
cc
// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/views/web_apps/web_app_integration_test_driver.h" #include "content/public/test/browser_test.h" namespace web_app::integration_tests { namespace { using WebAppIntegration = WebAppIntegrationTest; // Manual tests: // Generated tests: IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29NotPromotableWindowed_12NotPromotable_7NotPromotable_1NotPromotable_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kNotPromotable, WindowOptions::kWindowed); helper_.CheckAppInListWindowed(Site::kNotPromotable); helper_.CheckPlatformShortcutAndIcon(Site::kNotPromotable); helper_.LaunchFromPlatformShortcut(Site::kNotPromotable); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_1Standalone_79StandaloneStandaloneOriginal_24_26) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckWindowDisplayStandalone(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_149Standalone_11Standalone_1Standalone_22One_163Standalone) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.SetOpenInTabFromAppSettings(Site::kStandalone); helper_.CheckAppInListTabbed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckTabCreated(Number::kOne); helper_.CheckAppLoadedInTab(Site::kStandalone); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_147Standalone_11Standalone_1Standalone_22One_163Standalone) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.SetOpenInTabFromAppHome(Site::kStandalone); helper_.CheckAppInListTabbed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckTabCreated(Number::kOne); helper_.CheckAppLoadedInTab(Site::kStandalone); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_74Standalone_72Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.DeletePlatformShortcut(Site::kStandalone); helper_.CreateShortcutsFromList(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_32StandaloneNoShortcutBrowserWebApp_7Standalone_12Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kNoShortcut, WindowOptions::kBrowser, InstallMode::kWebApp); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_32StandaloneWithShortcutBrowserWebApp_12Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kWithShortcut, WindowOptions::kBrowser, InstallMode::kWebApp); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_116StandaloneBrowser_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kBrowser); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_31Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_116StandaloneMinimalUi_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallOmniboxIcon(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kMinimalUi); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_1Standalone_79StandaloneStandaloneOriginal_24_26) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckWindowDisplayStandalone(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_149Standalone_11Standalone_1Standalone_22One_163Standalone) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.SetOpenInTabFromAppSettings(Site::kStandalone); helper_.CheckAppInListTabbed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckTabCreated(Number::kOne); helper_.CheckAppLoadedInTab(Site::kStandalone); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_147Standalone_11Standalone_1Standalone_22One_163Standalone) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.SetOpenInTabFromAppHome(Site::kStandalone); helper_.CheckAppInListTabbed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckTabCreated(Number::kOne); helper_.CheckAppLoadedInTab(Site::kStandalone); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_74Standalone_72Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.DeletePlatformShortcut(Site::kStandalone); helper_.CreateShortcutsFromList(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_32StandaloneNoShortcutBrowserWebApp_7Standalone_12Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kNoShortcut, WindowOptions::kBrowser, InstallMode::kWebApp); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_32StandaloneWithShortcutBrowserWebApp_12Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kWithShortcut, WindowOptions::kBrowser, InstallMode::kWebApp); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_116StandaloneBrowser_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kBrowser); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_47Standalone_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_116StandaloneMinimalUi_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallMenuOption(InstallableSite::kStandalone); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kMinimalUi); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_32StandaloneWithShortcutWindowedWebApp_79StandaloneStandaloneOriginal_12Standalone_7Standalone_116StandaloneBrowser_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kWithShortcut, WindowOptions::kWindowed, InstallMode::kWebApp); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kBrowser); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_32StandaloneWithShortcutWindowedWebApp_79StandaloneStandaloneOriginal_12Standalone_7Standalone_116StandaloneMinimalUi_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kWithShortcut, WindowOptions::kWindowed, InstallMode::kWebApp); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kMinimalUi); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_1Standalone_24_26) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckWindowDisplayStandalone(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_149Standalone_11Standalone_1Standalone_22One_163Standalone) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.SetOpenInTabFromAppSettings(Site::kStandalone); helper_.CheckAppInListTabbed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckTabCreated(Number::kOne); helper_.CheckAppLoadedInTab(Site::kStandalone); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_147Standalone_11Standalone_1Standalone_22One_163Standalone) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.SetOpenInTabFromAppHome(Site::kStandalone); helper_.CheckAppInListTabbed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckTabCreated(Number::kOne); helper_.CheckAppLoadedInTab(Site::kStandalone); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_74Standalone_72Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.DeletePlatformShortcut(Site::kStandalone); helper_.CreateShortcutsFromList(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_32StandaloneNoShortcutBrowserWebApp_7Standalone_12Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kNoShortcut, WindowOptions::kBrowser, InstallMode::kWebApp); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_32StandaloneWithShortcutBrowserWebApp_12Standalone_1Standalone_24) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.InstallPolicyApp(Site::kStandalone, ShortcutOptions::kWithShortcut, WindowOptions::kBrowser, InstallMode::kWebApp); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_116StandaloneBrowser_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kBrowser); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } IN_PROC_BROWSER_TEST_F( WebAppIntegration, WAI_29StandaloneWindowed_79StandaloneStandaloneOriginal_24_12Standalone_7Standalone_112StandaloneNotShown_116StandaloneMinimalUi_117Standalone_1Standalone_24_94_25) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); helper_.CheckAppTitle(Site::kStandalone, Title::kStandaloneOriginal); helper_.CheckWindowCreated(); helper_.CheckAppInListWindowed(Site::kStandalone); helper_.CheckPlatformShortcutAndIcon(Site::kStandalone); helper_.CheckWindowControlsOverlayToggle(Site::kStandalone, IsShown::kNotShown); helper_.ManifestUpdateDisplay(Site::kStandalone, Display::kMinimalUi); helper_.AwaitManifestUpdate(Site::kStandalone); helper_.LaunchFromPlatformShortcut(Site::kStandalone); helper_.CheckWindowCreated(); helper_.CheckTabNotCreated(); helper_.CheckWindowDisplayMinimal(); } } // namespace } // namespace web_app::integration_tests
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
d1b02607d927ebbad8db83b372ced7f9b545fb58
428c5d8bdf6a9ba1a051c22c96830858593521b9
/relations/Item.cpp
620c424d116cbe2cfac355dfc63a44ce52cce739
[]
no_license
annn31051984/bcw4.04.10.2020
04f9bef708150c67aec826a9105442802386c273
1629cdfb463ae3da614b4237b0272c04844e9eda
refs/heads/master
2022-12-26T05:07:43.728451
2020-10-04T16:57:21
2020-10-04T16:57:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
856
cpp
#include "Item.h" Item::Item(const char* title, double price, Category* category) : title(title), price(price), category(category) { this->category->addItem(this); } Item::~Item() { this->category->removeItem(this); } const char* Item::getTitle() const { return this->title; } double Item::getPrice() const { return this->price; } const Category& Item::getCategory() const { return *(this->category); } void Item::setTitle(const char* title) { this->title = title; } void Item::setPrice(double price) { this->price = price; } void Item::setCategory(Category* category) { this->category = category; } std::ostream& operator<<(std::ostream& out, const Item& item) { out << item.getTitle() << "("; out << item.getCategory().getTitle() << ", "; out << item.getPrice() << ")"; return out; }
[ "me@caiman.dev" ]
me@caiman.dev
8456a880d1445c406f04640a541f9ed522340331
bc7e05dc6be0cd3c613991664d03107a58ec2b9c
/aoapc-bac2nd/ch10/UVa11440.cpp
307e889ffc57d767025eba1d10c8b6618811c11b
[]
no_license
4ker/aoapc-book
cba435a4aee65e7d95c7e62e7fedab333ecf0a79
addedfedd8be907e67229a2af6732f48c0f74dbd
refs/heads/master
2021-01-17T22:47:09.027018
2016-08-29T16:55:03
2016-08-29T16:55:03
65,923,801
0
0
null
2016-08-17T16:27:54
2016-08-17T16:27:53
null
UTF-8
C++
false
false
793
cpp
// UVa11440 Help Mr. Tomisu // Rujia Liu #include<cstdio> #include<cmath> #include<cstring> const int maxn = 10000000 + 10; const int MOD = 100000007; int vis[maxn], phifac[maxn]; void gen_primes(int n) { int m = (int)sqrt(n+0.5); int c = 0; memset(vis, 0, sizeof(vis)); for(int i = 2; i <= m; i++) if(!vis[i]) { for(int j = i*i; j <= n; j+=i) vis[j] = 1; } } int main() { int n, m; gen_primes(10000000); phifac[1] = phifac[2] = 1; for(int i = 3; i <= 10000000; i++) phifac[i] = (long long)phifac[i-1] * (vis[i] ? i : i-1) % MOD; while(scanf("%d%d", &n, &m) == 2 && n) { int ans = phifac[m]; for(int i = m+1; i <= n; i++) ans = (long long)ans * i % MOD; printf("%d\n", (ans-1+MOD)%MOD); } return 0; }
[ "dvorak4tzx@qq.com" ]
dvorak4tzx@qq.com
23d5013593984f41b9427d577e7805a16cf7da0c
a2ba5bb5afe7c397162e48988a3d6a10180061da
/ClassicIE9/ClassicIE9DLL/SettingsUI.cpp
40789dacb4de3e5b88ce0926493bf7975a87b47e
[ "MIT" ]
permissive
jebeld17/ClassicShell
140e4d4d707b25caa6053850f5f540ecf0f394be
c7d4bac036d7da8e053bc12decfcd2e3744e0e76
refs/heads/master
2021-01-22T11:11:00.312078
2015-08-28T22:45:46
2015-08-28T22:45:46
92,674,274
1
0
null
2017-05-28T16:52:29
2017-05-28T16:52:29
null
UTF-8
C++
false
false
6,625
cpp
// Classic Shell (c) 2009-2013, Ivo Beltchev // The sources for Classic Shell are distributed under the MIT open source license #include "stdafx.h" #include "Settings.h" #include "SettingsUIHelper.h" #include "ResourceHelper.h" #include "Translations.h" #include "resource.h" #include "dllmain.h" #include "ClassicIE9DLL.h" #include <dwmapi.h> #include <vssym32.h> /////////////////////////////////////////////////////////////////////////////// static CSetting g_Settings[]={ {L"Basic",CSetting::TYPE_GROUP,IDS_BASIC_SETTINGS}, {L"EnableSettings",CSetting::TYPE_BOOL,0,0,1,CSetting::FLAG_HIDDEN}, {L"LogLevel",CSetting::TYPE_INT,0,0,0,CSetting::FLAG_HIDDEN}, {L"TitleBar",CSetting::TYPE_GROUP,IDS_TITLE_SETTINGS}, {L"ShowCaption",CSetting::TYPE_BOOL,IDS_SHOW_CAPTION,IDS_SHOW_CAPTION_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"ShowIcon",CSetting::TYPE_BOOL,IDS_SHOW_ICON,IDS_SHOW_ICON_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC,L"ShowCaption"}, {L"CenterCaption",CSetting::TYPE_BOOL,IDS_CENTER_CAPTION,IDS_CENTER_CAPTION_TIP,0,CSetting::FLAG_WARM|CSetting::FLAG_BASIC,L"ShowCaption"}, {L"CaptionFont",CSetting::TYPE_FONT,IDS_CAPTION_FONT,IDS_CAPTION_FONT_TIP,L"Segoe UI, normal, 9",CSetting::FLAG_WARM,L"ShowCaption"}, {L"TextColor",CSetting::TYPE_COLOR,IDS_TEXT_COLOR,IDS_TEXT_COLOR_TIP,0,CSetting::FLAG_WARM,L"ShowCaption"}, {L"MaxColor",CSetting::TYPE_COLOR,IDS_MAXTEXT_COLOR,IDS_MAXTEXT_COLOR_TIP,0,CSetting::FLAG_WARM|(1<<24),L"ShowCaption"}, {L"InactiveColor",CSetting::TYPE_COLOR,IDS_INTEXT_COLOR,IDS_INTEXT_COLOR_TIP,0,CSetting::FLAG_WARM|(2<<24),L"ShowCaption"}, {L"InactiveMaxColor",CSetting::TYPE_COLOR,IDS_MAXINTEXT_COLOR,IDS_MAXINTEXT_COLOR_TIP,0,CSetting::FLAG_WARM|(3<<24),L"ShowCaption"}, {L"Glow",CSetting::TYPE_BOOL,IDS_GLOW,IDS_GLOW_TIP,0,CSetting::FLAG_WARM,L"ShowCaption"}, {L"GlowColor",CSetting::TYPE_COLOR,IDS_GLOW_COLOR,IDS_GLOW_COLOR_TIP,0xFFFFFF,CSetting::FLAG_WARM|(4<<24),L"#Glow"}, {L"MaxGlow",CSetting::TYPE_BOOL,IDS_MAXGLOW,IDS_MAXGLOW_TIP,0,CSetting::FLAG_WARM,L"ShowCaption"}, {L"MaxGlowColor",CSetting::TYPE_COLOR,IDS_MAXGLOW_COLOR,IDS_MAXGLOW_COLOR_TIP,0xFFFFFF,CSetting::FLAG_WARM|(5<<24),L"#MaxGlow"}, {L"StatusBar",CSetting::TYPE_GROUP,IDS_STATUS_SETTINGS}, {L"ShowProgress",CSetting::TYPE_BOOL,IDS_SHOW_PROGRESS,IDS_SHOW_PROGRESS_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"ShowZone",CSetting::TYPE_BOOL,IDS_SHOW_ZONE,IDS_SHOW_ZONE_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"ShowProtected",CSetting::TYPE_BOOL,IDS_SHOW_PROTECTED,IDS_SHOW_PROTECTED_TIP,1,CSetting::FLAG_WARM,L"ShowZone"}, {L"Language",CSetting::TYPE_GROUP,IDS_LANGUAGE_SETTINGS,0,0,0,NULL,GetLanguageSettings()}, {L"Language",CSetting::TYPE_STRING,0,0,L"",CSetting::FLAG_SHARED}, {NULL} }; void UpdateSettings( void ) { bool bVista=(GetWinVersion()==WIN_VER_VISTA); bool bWin8=(GetWinVersion()>=WIN_VER_WIN8); BOOL bComposition=0; if (FAILED(DwmIsCompositionEnabled(&bComposition))) bComposition=FALSE; if (bComposition && bWin8) { // check for High Contrast theme on Win8 HIGHCONTRAST contrast={sizeof(contrast)}; if (SystemParametersInfo(SPI_GETHIGHCONTRAST,sizeof(contrast),&contrast,0) && (contrast.dwFlags&HCF_HIGHCONTRASTON)) bComposition=FALSE; else { // check for Basic theme DWORD color; BOOL opaque; if (SUCCEEDED(DwmGetColorizationColor(&color,&opaque)) && opaque) bComposition=FALSE; } } UpdateSetting(L"Glow",CComVariant(bComposition?1:0),false); UpdateSetting(L"MaxGlow",CComVariant((bComposition && !bVista)?1:0),false); UpdateSetting(L"CenterCaption",CComVariant(bWin8?1:0),false); // create a dummy window to get a theme HWND hwnd=CreateWindow(L"#32770",L"",WS_OVERLAPPEDWINDOW,0,0,0,0,NULL,NULL,NULL,0); HTHEME theme=OpenThemeData(hwnd,L"Window"); if (theme) { HDC hdc=GetDC(NULL); int dpi=GetDeviceCaps(hdc,LOGPIXELSY); ReleaseDC(NULL,hdc); LOGFONT font; GetThemeSysFont(theme,TMT_CAPTIONFONT,&font); wchar_t text[256]; const wchar_t *type=font.lfItalic?L"italic":L"normal"; if (font.lfWeight>=FW_BOLD) type=font.lfItalic?L"bold_italic":L"bold"; Sprintf(text,_countof(text),L"%s, %s, %d",font.lfFaceName,type,(-font.lfHeight*72+dpi/2)/dpi); UpdateSetting(L"CaptionFont",CComVariant(text),false); int color=GetThemeSysColor(theme,COLOR_CAPTIONTEXT); UpdateSetting(L"TextColor",CComVariant(color),false); UpdateSetting(L"MaxColor",CComVariant((bVista && bComposition)?0xFFFFFF:color),false); if (bVista || bWin8) color=GetThemeSysColor(theme,COLOR_INACTIVECAPTIONTEXT); UpdateSetting(L"InactiveColor",CComVariant(color),false); UpdateSetting(L"InactiveMaxColor",CComVariant((bVista && bComposition)?0xFFFFFF:color),false); CloseThemeData(theme); } else { int color=GetSysColor(COLOR_CAPTIONTEXT); UpdateSetting(L"TextColor",CComVariant(color),false); UpdateSetting(L"MaxColor",CComVariant(color),false); color=GetSysColor(COLOR_INACTIVECAPTIONTEXT); UpdateSetting(L"InactiveColor",CComVariant(color),false); UpdateSetting(L"InactiveMaxColor",CComVariant(color),false); } DestroyWindow(hwnd); CRegKey regKey; wchar_t language[100]=L""; if (regKey.Open(HKEY_LOCAL_MACHINE,L"Software\\IvoSoft\\ClassicShell",KEY_READ|KEY_WOW64_64KEY)==ERROR_SUCCESS) { ULONG size=_countof(language); if (regKey.QueryStringValue(L"DefaultLanguage",language,&size)!=ERROR_SUCCESS) language[0]=0; } UpdateSetting(L"Language",language,false); } void InitSettings( void ) { InitSettings(g_Settings,COMPONENT_IE9); } void ClosingSettings( HWND hWnd, int flags, int command ) { if (command==IDOK) { if (flags&CSetting::FLAG_WARM) { if (FindWindow(L"IEFrame",NULL)) MessageBox(hWnd,LoadStringEx(IDS_NEW_SETTINGS),LoadStringEx(IDS_APP_TITLE),MB_OK|MB_ICONINFORMATION); } } } CSIE9API void ShowIE9Settings( void ) { if (!GetSettingBool(L"EnableSettings")) return; wchar_t title[100]; DWORD ver=GetVersionEx(g_Instance); if (ver) Sprintf(title,_countof(title),LoadStringEx(IDS_SETTINGS_TITLE_VER),ver>>24,(ver>>16)&0xFF,ver&0xFFFF); else Sprintf(title,_countof(title),LoadStringEx(IDS_SETTINGS_TITLE)); EditSettings(title,true,0); } CSIE9API DWORD GetIE9Settings( void ) { DWORD res=0; if (GetSettingBool(L"ShowCaption")) res|=IE9_SETTING_CAPTION; if (GetSettingBool(L"ShowProgress")) res|=IE9_SETTING_PROGRESS; if (GetSettingBool(L"ShowZone")) res|=IE9_SETTING_ZONE; if (GetSettingBool(L"ShowProtected")) res|=IE9_SETTING_PROTECTED; return res; }
[ "steven.edwards@hightail.com" ]
steven.edwards@hightail.com
8aedd9283299ef8a302def241682e2c05b53093c
a885c7bceafa7b3d6c5a756230fe08ecec6e011f
/ionGUI/imGUI.cpp
ce78bcef01758e7aa96849be4a187b4b19a97331
[ "MIT" ]
permissive
GSerralara/ionEngine
38984960db4d4300c4176974c0564348abb777b3
7ce3394dafbabf0e0bb9f5d07dbfae31161800d4
refs/heads/master
2021-10-09T13:00:04.123300
2018-12-28T10:46:33
2018-12-28T10:46:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
100
cpp
#include "imGUI.h" #include <imgui.cpp> #include <imgui_draw.cpp> #include <imgui_demo.cpp>
[ "iondune@gmail.com" ]
iondune@gmail.com
6344d4ec524fe00ed8fcf51bce6fa41303575fde
54b9e493500440edbcd8a3fac8876260f25c4d92
/vectors/main.cpp
e0e18025d4ca2b1d7666b3a3f18bc43684a843bb
[]
no_license
element2112/cpp_udemy_course
3f35b117b7f007385d560ceeb2002eff3c0d47c8
23f1fdf78e15f7725716fc5e39925f8010f9fc90
refs/heads/master
2022-08-19T14:34:17.634055
2020-05-25T23:55:23
2020-05-25T23:55:23
252,863,739
0
0
null
null
null
null
UTF-8
C++
false
false
1,936
cpp
#include <iostream> #include <vector> using namespace std; // a vector is just a dynamic array like an arraylist // vectors are an object int main() { vector <char> vowels; vector <int> test_scores {100, 95, 99, 87, 88}; vector <char> more_vowels (5); // constructor initialization. initalizing arraylist to 5 vector <char> some_vowels {'a', 'e', 'i', 'o', 'u'}; vector <double> hi_temps (365, 90.5); // 365 indicies and initializing them all to 90.5 cout << "First score: " << test_scores[0] << endl; cout << "Second score: " << test_scores[1] << endl; // etc etc cout << "First score " << test_scores.at(0) << endl; cout << "Second score " << test_scores.at(1) << endl; cout << "Third score " << test_scores.at(2) << endl; cout << "Enter 5 scores " << endl; cin >> test_scores.at(0); cin >> test_scores.at(1); cin >> test_scores.at(2); cin >> test_scores.at(3); cin >> test_scores.at(4); test_scores.push_back(80); test_scores.push_back(100); cout << test_scores.at(5) << endl; cout << test_scores.at(6) << endl; cout << "Size of vector: " << test_scores.size() << endl; for (int i = 0; i < test_scores.size(); i++) { if (test_scores.at(i) < 50) test_scores.push_back(70); cout << "Score: " << test_scores.at(i) << endl; } // 2D vector (vector of vectors) vector <vector<int>> my_vect { {1,2,3,4}, {5,6,7,8,9}, {10, 11, 12} }; int n = my_vect.size(); for (int i = 0; i < n; i++) { int k = my_vect.at(i).size(); for (int j = 0; j < k; j++) { cout << "Element: " << my_vect.at(i).at(j) << endl; } } return 0; }
[ "bs009@live.com" ]
bs009@live.com
4ef3c8361063514758e933f6b1e4a6324bb56a64
23177c3166b3d6d801c09d846b731425c77788da
/Intermediate/Build/Win64/UE4/Inc/Assignment/MainAnimInstance.gen.cpp
63f44834bb79c1672a8dd65d88cc47f98d99210c
[]
no_license
ffEuryale/Unreal_Portfolio
143340df29e004ca147c89431e79374200adf97f
272e111066999b26baaaa7e03bb5c611e91b7b06
refs/heads/main
2023-03-21T07:21:29.023017
2021-03-03T12:06:46
2021-03-03T12:06:46
342,631,540
0
0
null
null
null
null
UTF-8
C++
false
false
10,442
cpp
// Copyright Epic Games, Inc. All Rights Reserved. /*=========================================================================== Generated code exported from UnrealHeaderTool. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "UObject/GeneratedCppIncludes.h" #include "Assignment/MainAnimInstance.h" #include "Engine/Classes/Components/SkeletalMeshComponent.h" #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4883) #endif PRAGMA_DISABLE_DEPRECATION_WARNINGS void EmptyLinkFunctionForGeneratedCodeMainAnimInstance() {} // Cross Module References ASSIGNMENT_API UClass* Z_Construct_UClass_UMainAnimInstance_NoRegister(); ASSIGNMENT_API UClass* Z_Construct_UClass_UMainAnimInstance(); ENGINE_API UClass* Z_Construct_UClass_UAnimInstance(); UPackage* Z_Construct_UPackage__Script_Assignment(); ASSIGNMENT_API UClass* Z_Construct_UClass_AMainCharacter_NoRegister(); ENGINE_API UClass* Z_Construct_UClass_APawn_NoRegister(); // End Cross Module References DEFINE_FUNCTION(UMainAnimInstance::execUpdateAnimationProperties) { P_FINISH; P_NATIVE_BEGIN; P_THIS->UpdateAnimationProperties(); P_NATIVE_END; } void UMainAnimInstance::StaticRegisterNativesUMainAnimInstance() { UClass* Class = UMainAnimInstance::StaticClass(); static const FNameNativePtrPair Funcs[] = { { "UpdateAnimationProperties", &UMainAnimInstance::execUpdateAnimationProperties }, }; FNativeFunctionRegistrar::RegisterFunctions(Class, Funcs, UE_ARRAY_COUNT(Funcs)); } struct Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties_Statics { #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam Function_MetaDataParams[]; #endif static const UE4CodeGen_Private::FFunctionParams FuncParams; }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties_Statics::Function_MetaDataParams[] = { { "Category", "AnimationProperties" }, { "ModuleRelativePath", "MainAnimInstance.h" }, }; #endif const UE4CodeGen_Private::FFunctionParams Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties_Statics::FuncParams = { (UObject*(*)())Z_Construct_UClass_UMainAnimInstance, nullptr, "UpdateAnimationProperties", nullptr, nullptr, 0, nullptr, 0, RF_Public|RF_Transient|RF_MarkAsNative, (EFunctionFlags)0x04020401, 0, 0, METADATA_PARAMS(Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties_Statics::Function_MetaDataParams, UE_ARRAY_COUNT(Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties_Statics::Function_MetaDataParams)) }; UFunction* Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties() { static UFunction* ReturnFunction = nullptr; if (!ReturnFunction) { UE4CodeGen_Private::ConstructUFunction(ReturnFunction, Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties_Statics::FuncParams); } return ReturnFunction; } UClass* Z_Construct_UClass_UMainAnimInstance_NoRegister() { return UMainAnimInstance::StaticClass(); } struct Z_Construct_UClass_UMainAnimInstance_Statics { static UObject* (*const DependentSingletons[])(); static const FClassFunctionLinkInfo FuncInfo[]; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam Class_MetaDataParams[]; #endif #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_Main_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_Main; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_Pawn_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_Pawn; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_bIsInAir_MetaData[]; #endif static void NewProp_bIsInAir_SetBit(void* Obj); static const UE4CodeGen_Private::FBoolPropertyParams NewProp_bIsInAir; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_MovementSpeed_MetaData[]; #endif static const UE4CodeGen_Private::FFloatPropertyParams NewProp_MovementSpeed; static const UE4CodeGen_Private::FPropertyParamsBase* const PropPointers[]; static const FCppClassTypeInfoStatic StaticCppClassTypeInfo; static const UE4CodeGen_Private::FClassParams ClassParams; }; UObject* (*const Z_Construct_UClass_UMainAnimInstance_Statics::DependentSingletons[])() = { (UObject* (*)())Z_Construct_UClass_UAnimInstance, (UObject* (*)())Z_Construct_UPackage__Script_Assignment, }; const FClassFunctionLinkInfo Z_Construct_UClass_UMainAnimInstance_Statics::FuncInfo[] = { { &Z_Construct_UFunction_UMainAnimInstance_UpdateAnimationProperties, "UpdateAnimationProperties" }, // 3483567489 }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_UMainAnimInstance_Statics::Class_MetaDataParams[] = { { "Comment", "/**\n * \n */" }, { "HideCategories", "AnimInstance" }, { "IncludePath", "MainAnimInstance.h" }, { "ModuleRelativePath", "MainAnimInstance.h" }, }; #endif #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Main_MetaData[] = { { "Category", "Movement" }, { "ModuleRelativePath", "MainAnimInstance.h" }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Main = { "Main", nullptr, (EPropertyFlags)0x0010000000000015, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(UMainAnimInstance, Main), Z_Construct_UClass_AMainCharacter_NoRegister, METADATA_PARAMS(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Main_MetaData, UE_ARRAY_COUNT(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Main_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Pawn_MetaData[] = { { "Category", "Movement" }, { "ModuleRelativePath", "MainAnimInstance.h" }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Pawn = { "Pawn", nullptr, (EPropertyFlags)0x0010000000000015, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(UMainAnimInstance, Pawn), Z_Construct_UClass_APawn_NoRegister, METADATA_PARAMS(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Pawn_MetaData, UE_ARRAY_COUNT(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Pawn_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_bIsInAir_MetaData[] = { { "Category", "Movement" }, { "ModuleRelativePath", "MainAnimInstance.h" }, }; #endif void Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_bIsInAir_SetBit(void* Obj) { ((UMainAnimInstance*)Obj)->bIsInAir = 1; } const UE4CodeGen_Private::FBoolPropertyParams Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_bIsInAir = { "bIsInAir", nullptr, (EPropertyFlags)0x0010000000000015, UE4CodeGen_Private::EPropertyGenFlags::Bool | UE4CodeGen_Private::EPropertyGenFlags::NativeBool, RF_Public|RF_Transient|RF_MarkAsNative, 1, sizeof(bool), sizeof(UMainAnimInstance), &Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_bIsInAir_SetBit, METADATA_PARAMS(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_bIsInAir_MetaData, UE_ARRAY_COUNT(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_bIsInAir_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_MovementSpeed_MetaData[] = { { "Category", "Movement" }, { "ModuleRelativePath", "MainAnimInstance.h" }, }; #endif const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_MovementSpeed = { "MovementSpeed", nullptr, (EPropertyFlags)0x0010000000000015, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(UMainAnimInstance, MovementSpeed), METADATA_PARAMS(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_MovementSpeed_MetaData, UE_ARRAY_COUNT(Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_MovementSpeed_MetaData)) }; const UE4CodeGen_Private::FPropertyParamsBase* const Z_Construct_UClass_UMainAnimInstance_Statics::PropPointers[] = { (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Main, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_Pawn, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_bIsInAir, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_UMainAnimInstance_Statics::NewProp_MovementSpeed, }; const FCppClassTypeInfoStatic Z_Construct_UClass_UMainAnimInstance_Statics::StaticCppClassTypeInfo = { TCppClassTypeTraits<UMainAnimInstance>::IsAbstract, }; const UE4CodeGen_Private::FClassParams Z_Construct_UClass_UMainAnimInstance_Statics::ClassParams = { &UMainAnimInstance::StaticClass, nullptr, &StaticCppClassTypeInfo, DependentSingletons, FuncInfo, Z_Construct_UClass_UMainAnimInstance_Statics::PropPointers, nullptr, UE_ARRAY_COUNT(DependentSingletons), UE_ARRAY_COUNT(FuncInfo), UE_ARRAY_COUNT(Z_Construct_UClass_UMainAnimInstance_Statics::PropPointers), 0, 0x009000A8u, METADATA_PARAMS(Z_Construct_UClass_UMainAnimInstance_Statics::Class_MetaDataParams, UE_ARRAY_COUNT(Z_Construct_UClass_UMainAnimInstance_Statics::Class_MetaDataParams)) }; UClass* Z_Construct_UClass_UMainAnimInstance() { static UClass* OuterClass = nullptr; if (!OuterClass) { UE4CodeGen_Private::ConstructUClass(OuterClass, Z_Construct_UClass_UMainAnimInstance_Statics::ClassParams); } return OuterClass; } IMPLEMENT_CLASS(UMainAnimInstance, 2809650281); template<> ASSIGNMENT_API UClass* StaticClass<UMainAnimInstance>() { return UMainAnimInstance::StaticClass(); } static FCompiledInDefer Z_CompiledInDefer_UClass_UMainAnimInstance(Z_Construct_UClass_UMainAnimInstance, &UMainAnimInstance::StaticClass, TEXT("/Script/Assignment"), TEXT("UMainAnimInstance"), false, nullptr, nullptr, nullptr); DEFINE_VTABLE_PTR_HELPER_CTOR(UMainAnimInstance); PRAGMA_ENABLE_DEPRECATION_WARNINGS #ifdef _MSC_VER #pragma warning (pop) #endif
[ "tyhbvfg0108@gmail.com" ]
tyhbvfg0108@gmail.com
6ed6cc15292a021cb95aa9be3e707a27e21a9ee1
adad161dfff829f10aaf5e41a49d9f4ef5275857
/top_down_test/grid_datastructure.cpp
7d6f33148ea35a60af98a418968ab6c7cf4c06dd
[]
no_license
rmitra/Masters-Project
e8ec19dcda1c9ec2845ba546c36cc691fc0438c0
62109d29a53f23dcec5089c8969cad754a13dab7
refs/heads/master
2020-04-30T07:40:44.510278
2015-01-22T17:33:40
2015-01-22T17:33:40
23,255,696
5
5
null
null
null
null
UTF-8
C++
false
false
6,968
cpp
#include <iostream> #include <cstdio> #include <cmath> #include <vector> /* point cloud header fils */ #include <pcl/io/pcd_io.h> #include <pcl/io/ply_io.h> #include <pcl/point_types.h> /* end of header files */ #ifndef GRID_HEADER #define GRID_HEADER #define EPS 0.001 using namespace std; class grid_element { // element for every grid node public: pcl::PointCloud<pcl::PointXYZ>::Ptr p_list; // list of those points. pcl::PointCloud<pcl::Normal>::Ptr n_list; // list of normals. //int rep[3]; bool used; grid_element(){ // constructor p_list = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>); n_list = pcl::PointCloud<pcl::Normal>::Ptr(new pcl::PointCloud<pcl::Normal>); used = false; } /*void setRep(int x, int y, int z){ rep[0] = x; rep[1] = y; rep[2] = z; }*/ }; class grid { public: // pcl::PointXYZ resolution; // dimension of a cubical voxel double resolution; grid_element *** data; int length, width, height; // dimension of the grid pcl::PointXYZ ref_point; // here the min point is taken as the reference point /* Constructor taking resolution and min and max point of the point cloud and determines the no. voxels in length, width and height. */ grid(pcl::PointXYZ res, pcl::PointXYZ minPoint, pcl::PointXYZ maxPoint){ // resolution = res; if(res.x < res.y){ if(res.x < res.z) resolution = res.x; else resolution = res.z; } else{ if(res.y < res.z) resolution = res.y; else resolution = res.z; } // double xdiff_int = (int)( ((maxPoint.x - minPoint.x)/resolution) + 1.0f ); // double xdiff = (maxPoint.x - minPoint.x)/resolution; //if( xdiff_int - xdiff < 0.00001f) // length = (int)( ((maxPoint.x - minPoint.x)/resolution) + 1.5f); //else length = (int)( ((maxPoint.x - minPoint.x)/resolution) + 1.0f); // double ydiff_int = (int)( ((maxPoint.y - minPoint.y)/resolution) + 1.0f ); // double ydiff = (maxPoint.y - minPoint.y)/resolution; //if( ydiff_int - ydiff < 0.00001f) // width = (int)( ((maxPoint.y - minPoint.y)/resolution) + 1.5f); //else width = (int)( ((maxPoint.y - minPoint.y)/resolution) + 1.0f); // double zdiff_int = (int)( ((maxPoint.z - minPoint.z)/resolution) + 1.0f ); // double zdiff = (maxPoint.z - minPoint.z)/resolution; //if( zdiff_int - zdiff < 0.00001f) // height = (int)( ((maxPoint.z - minPoint.z)/resolution) + 1.5f); //else height = (int)( ((maxPoint.z - minPoint.z)/resolution) + 1.0f); data = new grid_element** [length]; for(int i = 0; i < length; i++) { data[i] = new grid_element* [width]; for( int j = 0; j < width; j++) data[i][j] = new grid_element[height]; } ref_point = minPoint; } void display_dimensions(){ cout<<"Length: "<<length<<endl; cout<<"Width: "<<width<<endl; cout<<"Height: "<<height<<endl; cout<<"Resolution: "<<resolution<<"\n"; //<<" "<<resolution.y<<" "<<resolution.z<<endl<<endl; cout<<"Ref Point: x: "<<ref_point.x<<endl; cout<<"Ref Point: y: "<<ref_point.y<<endl; cout<<"Ref Point: z: "<<ref_point.z<<endl; } /* function allocates a points of a cloud to a voxel in the grid * Input point cloud */ void allocate_points_to_grid( pcl::PointCloud<pcl::PointXYZ> cloud, pcl::PointCloud<pcl::Normal> cloud_normals ){ double xdiff, ydiff, zdiff; int xindex, yindex, zindex; for(int i = 0; i < cloud.points.size(); i++){ xdiff = (cloud.points[i].x - ref_point.x)/resolution ; ydiff = (cloud.points[i].y - ref_point.y)/resolution ; zdiff = (cloud.points[i].z - ref_point.z)/resolution ; xindex = (int)(xdiff); // + 1.0f); yindex = (int)(ydiff); // + 1.0f); zindex = (int)(zdiff); // + 1.0f); //if(xindex - xdiff > 0.00001f) // xindex = xindex -1; //if(yindex - ydiff > 0.00001f) // yindex = yindex - 1; //if(zindex - zdiff > 0.00001f) // zindex = zindex - 1; data[xindex][yindex][zindex].p_list->points.push_back(cloud.points[i]); data[xindex][yindex][zindex].n_list->points.push_back(cloud_normals.points[i]); } return; } void remove_voxels(int threshold){ long voxel_used_count = 0; for(int i = 0; i < length; i++){ for(int j = 0; j < width; j++){ for(int k = 0; k < height; k++){ if(data[i][j][k].p_list->points.size() >= threshold){ data[i][j][k].used = true; voxel_used_count++; } } } } // cout<<"Voxel used after thresholding: "<<voxel_used_count<<endl; return; } }; class Block{ public: int x; int y; int z; int length; int width; int height; Block(){ x = y = z = 0; length = width = height = 1; } Block(const Block &b){ x = b.x; y = b.y; z = b.z; length = b.length; width = b.width; height = b.height; } Block(int x_i, int y_i, int z_i, int l_i, int w_i, int h_i ){ x = x_i; y = y_i; z = z_i; length = l_i; width = w_i; height = h_i; } }; class Training_block{ public: double asp_1; double asp_2; double asp_3; int model_number; int is_splited; //double cut_frac; double x_1, y_1, z_1; double x_2, y_2, z_2; double l_1, w_1, h_1; double l_2, w_2, h_2; string model_name; Training_block(){ asp_1 = asp_2 = asp_3 = 0.0; x_1 = y_1 = z_1 = l_1 = w_1 = h_1 = -1; x_2 = y_2 = z_2 = l_2 = w_2 = h_2 = -1; model_number = -1; is_splited = -1; } Training_block(double _asp_1, double _asp_2, double _asp_3, int _model_number, double _x_1, double _y_1, double _z_1, double _l_1, double _w_1, double _h_1, double _x_2, double _y_2, double _z_2, double _l_2, double _w_2, double _h_2){ asp_1 = _asp_1; asp_2 = _asp_2; asp_3 = _asp_3; x_1 = _x_1; y_1 = _y_1; z_1 = _z_1; l_1 = _l_1; w_1 = _w_1; h_1 = _h_1; x_2 = _x_2; y_2 = _y_2; z_2 = _z_2; l_2 = _l_2; w_2 = _w_2; h_2 = _h_2; model_number = _model_number; } Training_block(const Training_block &b){ asp_1 = b.asp_1; asp_2 = b.asp_2; asp_3 = b.asp_3; //plane = b.plane; //cut_frac = b.cut_frac; x_1 = b.x_1; y_1 = b.y_1; z_1 = b.z_1; l_1 = b.l_1; w_1 = b.w_1; h_1 = b.h_1; x_2 = b.x_2; y_2 = b.y_2; z_2 = b.z_2; l_2 = b.l_2; w_2 = b.w_2; h_2 = b.h_2; is_splited = b.is_splited; model_number = b.model_number; model_name = b.model_name; } }; int search_block(string model_name, int model_number, vector<Training_block> &tr_data_list){ for(int i = 0; i < tr_data_list.size(); i++){ if( tr_data_list[i].model_name.compare(model_name) == 0 && tr_data_list[i].model_number == model_number) return i; } return -1; } #endif
[ "rahulm9999@gmail.com" ]
rahulm9999@gmail.com
6793a05eb16a7be71280a12293fa062e584882d5
3d424a8d682d4e056668b5903206ccc603f6e997
/NeoScriptTools/debugging/qscriptdebuggerstackmodel_p.h
b71a8540602d39d4a7b2818ba5c7a4db76fb306a
[]
no_license
markus851/NeoLoader
515e238b385354b83bbc4f7399a85524d5b03d12
67c9b642054ead500832406a9c301a7b4cbfffd3
refs/heads/master
2022-04-22T07:51:15.418184
2015-05-08T11:37:53
2015-05-08T11:37:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,895
h
/**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSCriptTools module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** This file may be used under the terms of the GNU Lesser General Public ** License version 2.1 as published by the Free Software Foundation and ** appearing in the file LICENSE.LGPL included in the packaging of this ** file. Please review the following information to ensure the GNU Lesser ** General Public License version 2.1 requirements will be met: ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU General ** Public License version 3.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of this ** file. Please review the following information to ensure the GNU General ** Public License version 3.0 requirements will be met: ** http://www.gnu.org/copyleft/gpl.html. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QSCRIPTDEBUGGERSTACKMODEL_P_H #define QSCRIPTDEBUGGERSTACKMODEL_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include <QtCore/qabstractitemmodel.h> #include <QtCore/qlist.h> QT_BEGIN_NAMESPACE class QScriptDebuggerContextInfo; class QScriptDebuggerStackModelPrivate; class Q_AUTOTEST_EXPORT QScriptDebuggerStackModel : public QAbstractTableModel { public: QScriptDebuggerStackModel(QObject *parent = 0); ~QScriptDebuggerStackModel(); QList<QScriptDebuggerContextInfo> contextInfos() const; void setContextInfos(const QList<QScriptDebuggerContextInfo> &infos); int columnCount(const QModelIndex &parent) const; int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation, int role) const; private: Q_DECLARE_PRIVATE(QScriptDebuggerStackModel) Q_DISABLE_COPY(QScriptDebuggerStackModel) }; QT_END_NAMESPACE #endif
[ "David@X.com" ]
David@X.com
2a8f2299ed4b3ff677a38dcfcc777133bc3bfc35
7be1f02caba12f7a4ccc9a16a5c65b104aa124cf
/Collada.cpp
78b876b63219b9cae977a9180db9056bffa2a2bd
[]
no_license
sungsoosmess/ColladaVR
6c720a00e75bd24ad459923e48f99da8fd6cbc9c
df3335e71ae1708093332fc8f779bfa56e7e7472
refs/heads/master
2022-03-28T08:35:37.302964
2019-12-31T22:08:36
2019-12-31T22:08:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,265
cpp
// Collada.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "Collada.h" #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name // Forward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_COLLADA, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_COLLADA)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_COLLADA)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = MAKEINTRESOURCE(IDC_COLLADA); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HINSTANCE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Message handler for about box. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: return (INT_PTR)TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; } break; } return (INT_PTR)FALSE; }
[ "turnerevansd@janelia.hhmi.org" ]
turnerevansd@janelia.hhmi.org
4fdbe9bc92233169a10b359e5cad46e09d26cfbf
6b18884327584cd84e677b53a5c1c121cbed7aaf
/2D Physics Engine ERawlings/RenderData.h
2839e008afa2a5104e405fc72608220b28583584
[ "MIT" ]
permissive
EmmaRawlings/2D-Physics-Engine-ERawlings
dfa9ef64d71ac71aed0c57cfa88ade5e9859a85d
63e1c330321bb7f826049ca12dfa95c4ddb346e8
refs/heads/master
2021-11-27T00:32:03.064186
2017-02-07T20:21:42
2017-02-07T20:21:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,469
h
#pragma once #include "Vector2.h" #include <list> #include <string> //blend mode? struct Position{ int x; int y; int z; }; struct Colour { int r; int g; int b; int a; }; struct Point { Position position; Colour colour; int size; }; struct Line { int x1; int y1; int z1; int x2; int y2; int z2; Colour colour; int width; }; /* struct Lines { std::list<Position> positions; Colour colour; int width; };*/ /* struct Sprite { int id; Position position; int a; int top; int left; int bottom; int right; //transformations };*/ struct Text { std::string text; int size; Position position; //font type Colour colour; int a; //transformations }; class RenderData { public: RenderData(void); RenderData(const RenderData& rData); RenderData& operator=(const RenderData& rData); void addRenderData(const RenderData& rData); void addRenderData(const RenderData& rData, const Position& position); void addPoint(const int x, const int y, const int z, const int r, const int g, const int b, const int a, const int size); void addLine(const int x1, const int y1, const int z1, const int x2, const int y2, const int z2, const int r, const int g, const int b, const int a, const int width); void addText(const int x, const int y, const int z, const int r, const int g, const int b, const int a, const int size, const std::string text); ~RenderData(void); std::list<Point>* points; std::list<Line>* lines; std::list<Text>* texts; };
[ "espio.vx@gmail.com" ]
espio.vx@gmail.com
4d15b54be7f45be4dc13f0422901c96490967507
6772d6815b80b4f5b13a004b1105ee4f26bcfa3b
/tensorflow/compiler/xla/service/gpu/done_event_thunk.h
393683d49ca8944a20ed054f30cca1346eea57f1
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause" ]
permissive
alpa-projects/tensorflow-alpa
b9e5dfde4e19798e7600013803b80f4eabeb2de8
c079cc2805a0c3ba57be8eb5e4bf95840bd6e08b
refs/heads/master
2023-05-23T03:22:32.201790
2023-02-05T23:29:37
2023-02-05T23:29:37
353,536,264
21
25
Apache-2.0
2023-05-10T15:00:05
2021-04-01T01:24:18
C++
UTF-8
C++
false
false
861
h
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_GPU_DONE_EVENT_THUNK_H_ #define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_DONE_EVENT_THUNK_H_ #include "tensorflow/compiler/xla/service/gpu/alpa_events.h" #include "tensorflow/compiler/xla/service/gpu/thunk.h" namespace xla { namespace gpu { // Thunk to record an early done of a buffer class DoneEventThunk : public Thunk { public: DoneEventThunk(ThunkInfo thunk_info, size_t index); Status Initialize(const GpuExecutable& executable, se::StreamExecutor* executor) override; Status ExecuteOnStream(const ExecuteParams& params) override; private: const size_t output_index; std::shared_ptr<DoneEventStats> event_stats; absl::Mutex mu_; RunId cur_run_id ABSL_GUARDED_BY(mu_); }; } // namespace gpu } // namespace xla #endif // TENSORFLOW_COMPILER_XLA_SERVICE_GPU_DONE_EVENT_THUNK_H_
[ "noreply@github.com" ]
alpa-projects.noreply@github.com
024fce5710bdc87664dad80ca0092cddd289d791
bd1b37597a9e4baac3913f73f28ee5e897b33e76
/plugins/matchmaker/pluginsrc/matchmaker_plugin.cpp
7a77d548b4adfb4fc3072a64d18ded976ebea8b1
[ "BSD-2-Clause" ]
permissive
pretty-wise/link
3f3b00b9ca9d17dad0a9d5db6cd3063633918587
16a4241c4978136d8c4bd1caab20bdf37df9caaf
refs/heads/master
2023-01-13T08:33:20.969484
2019-11-29T01:43:34
2019-11-29T01:43:34
58,286,721
0
0
null
2023-01-04T05:22:28
2016-05-07T22:20:45
C++
UTF-8
C++
false
false
2,764
cpp
/* * Copywrite 2014-2015 Krzysztof Stasik. All rights reserved. */ #include "matchmaker_plugin.h" #include "link/plugin_log.h" #include "tinyxml2.h" #include "common/protobuf_stream.h" #include "common/json/json_writer.h" //#include "protocol/gate.pb.h" namespace Link { namespace Matchmaker { MatchmakerPlugin::MatchmakerPlugin() : SimplePlugin(kUpdateDeltaMs) { m_recv_buffer = malloc(kRecvBufferSize); } MatchmakerPlugin::~MatchmakerPlugin() { free(m_recv_buffer); } bool MatchmakerPlugin::OnStartup(const char* config, streamsize nbytes) { if(!config || nbytes == 0) { PLUGIN_ERROR("no config"); return false; } tinyxml2::XMLDocument doc; tinyxml2::XMLError err = doc.Parse(config, nbytes); if(err != tinyxml2::XML_SUCCESS){ PLUGIN_ERROR("problem parsing config: %s(%d)", doc.ErrorName(), err); return false; } /* u16 port = 0; tinyxml2::XMLElement* root = doc.RootElement(); if(root->Attribute("port")) { port = root->IntAttribute("port"); PLUGIN_INFO("port read %d", port); } else { PLUGIN_WARN("no port specified, defaulting to 0"); } if(!root->Attribute("max_connections")) { PLUGIN_ERROR("maximum connection count not specified"); return false; } u32 max_connections = root->IntAttribute("max_connections"); PLUGIN_INFO("maximum number of connections: %d", max_connections); */ return true; } void MatchmakerPlugin::OnShutdown() { } void MatchmakerPlugin::OnUpdate(unsigned int dt) { (void)dt; } void MatchmakerPlugin::OnRecvReady(const ConnectionNotification& notif) { SimplePlugin::Recv(notif.handle, m_recv_buffer, kRecvBufferSize, [&](void* buffer, unsigned int nbytes){ ParseDataReceived(buffer, nbytes, notif.handle, notif.endpoint); }); } void MatchmakerPlugin::OnNotification(const Notification& notif) { ProcessNotification(notif); } void MatchmakerPlugin::OnPluginConnected(const ConnectionNotification& notif) { if(GetRestConnection() == notif.handle) { return; // ignore rest plugin connection. } } void MatchmakerPlugin::OnConnected(const ConnectionNotification& notif) { if(GetRestConnection() == notif.handle) { return; // ignore rest plugin connection. } } void MatchmakerPlugin::OnDisconnected(const ConnectionNotification& notif) { if(GetRestConnection() == notif.handle) { return; // ignore rest plugin connection. } } void MatchmakerPlugin::ParseDataReceived(void* buffer, unsigned int nbytes, ConnectionHandle connection, PluginHandle plugin) { } } // namespace Matchmaker } // namespace Link const char* SimplePlugin::Name = "match"; const char* SimplePlugin::Version = "0.1"; SimplePlugin* SimplePlugin::CreatePlugin() { return new Link::Matchmaker::MatchmakerPlugin(); } void SimplePlugin::DestroyPlugin(SimplePlugin* plugin) { delete plugin; }
[ "krzysiek.stasik@gmail.com" ]
krzysiek.stasik@gmail.com
2bcbe0f2f66fa7f38e8d1c4b20e5b469132dc932
7abd1d2bccc8848bc2d42cc12351b7e745b9ef7b
/objects/Flower.h
2676e745388187f06846021a0c38eb675f609bfb
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
vinz9/vstvisframework
f98f48ab064cef7c908a262810bd3e0ca4dfd696
0c4e1508d313c8deb588def77aa1a23f131c9333
refs/heads/master
2021-07-15T21:10:38.230197
2016-09-16T21:02:49
2016-09-16T21:02:49
8,673,426
14
0
null
null
null
null
UTF-8
C++
false
false
723
h
/* flower code from http://asilvast.kapsi.fi/pseudotoad/projects */ #ifndef FLOWER_H_ #define FLOWER_H_ #include "Object3d.h" typedef float Vect[3]; class Flower : public Object3d { public: Flower(); Flower(AudioEffect* effect, int m, float stg1, float stg2); ~Flower(); void draw(); void setInput(int input); private: float* audiobars; void spline3DMorph(float factor, float poikkeama); void splineTCP(float u, Vect * control, Vect * result); void updateActive(); int active[12]; float tension, continuity, bias; float tension_new, continuity_new, bias_new; float spd; float posz, posz_new; float timef; int montime, in, mode, freq, np, nbands; float timeinput, st1, st2, def; }; #endif
[ "vince.houze@gmail.com" ]
vince.houze@gmail.com
29aa7059b3c5566f6a3fb1ba756aeffbc3663853
4b9dd6830cf2857de6dc273eee9255d2b6b9d7e5
/剑指offer/52-两个链表的第一个公共结点/JZ52.cpp
aac68727d0dca77619d2ba60b9ba497b1fbdef53
[ "MIT" ]
permissive
ZhuchaWenjiu/coding-for-algorithms
2aa0eaa5f40b93f68426ee3a007f6bda75a638df
f2ca1addaa0b41ae62a8d71e2bec9635161cfe6a
refs/heads/master
2022-12-01T09:14:10.766258
2020-08-13T06:36:35
2020-08-13T06:36:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,183
cpp
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* FindFirstCommonNode( ListNode* pHead1, ListNode* pHead2) { if (!(pHead1 && pHead2)) return nullptr; unsigned int length1 = getListLength(pHead1); unsigned int length2 = getListLength(pHead2); ListNode *pLong, *pShort; // 在 if...else...里定义 pLong 和 pShort 可不行,因为 {} 的作用域有限 if (length1 >= length2) { pLong = pHead1; pShort = pHead2; } else { pLong = pHead2; pShort = pHead1; } for (int i = 0; i < abs(int(length1 - length2)); ++i) pLong = pLong->next; while (pLong && pShort && pLong != pShort) { pLong = pLong->next; pShort = pShort->next; } return pLong; } unsigned int getListLength(ListNode* head) { unsigned int length = 0; ListNode* p = head; while (p) { length++; p = p->next; } return length; } };
[ "33092119+jinbooooom@users.noreply.github.com" ]
33092119+jinbooooom@users.noreply.github.com
ed2f55b2910df75307eea363169beab209bd1676
1c390cd4fd3605046914767485b49a929198b470
/luogu/P2209.cpp
91ca8ed43df9a18858f47994b5248f4223f19459
[]
no_license
wwwwodddd/Zukunft
f87fe736b53506f69ab18db674311dd60de04a43
03ffffee9a76e99f6e00bba6dbae91abc6994a34
refs/heads/master
2023-01-24T06:14:35.691292
2023-01-21T15:42:32
2023-01-21T15:42:32
163,685,977
7
8
null
null
null
null
UTF-8
C++
false
false
973
cpp
#include <bits/stdc++.h> using namespace std; int n, g, b, d; long long z; pair<int, int> a[50020]; deque<pair<int, int> > q; int main() { scanf("%d%d%d%d", &n, &g, &b, &d); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i].first, &a[i].second); } sort(a + 1, a + n + 1); a[n + 1].first = d; q.push_back(make_pair(b, 0)); for (int i = 1; i <= n + 1; i++) { int l = a[i].first - a[i - 1].first; while (l > 0 && q.size() > 0) { if (q.front().first > l) { z += (long long)l * q.front().second; b -= l; q.front().first -= l; l = 0; } else { z += (long long)q.front().first * q.front().second; b -= q.front().first; l -= q.front().first; q.pop_front(); } } if (l > 0) { printf("-1\n"); return 0; } while (q.size() > 0 && a[i].second <= q.back().second) { b -= q.back().first; q.pop_back(); } q.push_back(make_pair(g - b, a[i].second)); b = g; } printf("%lld\n", z); return 0; }
[ "wwwwodddd@gmail.com" ]
wwwwodddd@gmail.com
3f5f9af4f11da5491f34eca5320dfb4304e842f4
c0f5d7ef2b590c155af58d83e8cbbf0854a3f995
/include/caffe/layers/tanh_layer.hpp
8d18b8f8e8adbd2fdb82e056bac28bfe375e4984
[ "LicenseRef-scancode-generic-cla", "BSD-2-Clause", "BSD-3-Clause", "LicenseRef-scancode-public-domain" ]
permissive
JiahaoLi-gdut/CAFFE-DACH
c8a039d437775b65c6ed6f4508b47acc66e025d4
388c826d8019f66bf0657acb2041dfccf4797fc9
refs/heads/master
2023-03-27T16:00:10.865638
2021-03-30T15:18:51
2021-03-30T15:18:51
353,027,719
0
0
null
null
null
null
UTF-8
C++
false
false
2,681
hpp
#ifndef CAFFE_TANH_LAYER_HPP_ #define CAFFE_TANH_LAYER_HPP_ #include <vector> #include "caffe/blob.hpp" #include "caffe/layer.hpp" #include "caffe/proto/caffe.pb.h" #include "caffe/layers/neuron_layer.hpp" namespace caffe { /** * @brief TanH hyperbolic tangent non-linearity @f$ * y = \frac{\exp(2x) - 1}{\exp(2x) + 1} * @f$, popular in auto-encoders. * * Note that the gradient vanishes as the values move away from 0. * The ReLULayer is often a better choice for this reason. */ template <typename Dtype> class TanHLayer : public NeuronLayer<Dtype> { public: explicit TanHLayer(const LayerParameter& param) : NeuronLayer<Dtype>(param) {} virtual inline const char* type() const { return "TanH"; } protected: /** * @param bottom input Blob vector (length 1) * -# @f$ (N \times C \times H \times W) @f$ * the inputs @f$ x @f$ * @param top output Blob vector (length 1) * -# @f$ (N \times C \times H \times W) @f$ * the computed outputs @f$ * y = \frac{\exp(2x) - 1}{\exp(2x) + 1} * @f$ */ virtual void Forward_cpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top, const bool preforward_flag); virtual void Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top, const bool preforward_flag); /** * @brief Computes the error gradient w.r.t. the sigmoid inputs. * * @param top output Blob vector (length 1), providing the error gradient with * respect to the outputs * -# @f$ (N \times C \times H \times W) @f$ * containing error gradients @f$ \frac{\partial E}{\partial y} @f$ * with respect to computed outputs @f$ y @f$ * @param propagate_down see Layer::Backward. * @param bottom input Blob vector (length 1) * -# @f$ (N \times C \times H \times W) @f$ * the inputs @f$ x @f$; Backward fills their diff with * gradients @f$ * \frac{\partial E}{\partial x} * = \frac{\partial E}{\partial y} * \left(1 - \left[\frac{\exp(2x) - 1}{exp(2x) + 1} \right]^2 \right) * = \frac{\partial E}{\partial y} (1 - y^2) * @f$ if propagate_down[0] */ virtual void Backward_cpu( const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom, const bool prebackward_flag); virtual void Backward_gpu( const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom, const bool prebackward_flag); }; } // namespace caffe #endif // CAFFE_TANH_LAYER_HPP_
[ "jiahaoli.gdut@gmail.com" ]
jiahaoli.gdut@gmail.com
a541781f97d76fe3468289a3386769b2bcba3244
2e09ae7a5bea9be801045a3e52c23917d201587c
/source/Operations/RasterPosition.h
8ebcba2aee5640679aa87f733c274ec5bbc1ea50
[]
no_license
rpethes/terRAIN
62f6cd28a635b8abdbcd022998e420386fd264e8
1f2b586ad632a31e8e1713eee90e53653c9ee113
refs/heads/master
2016-09-06T11:49:15.590676
2015-11-16T19:01:40
2015-11-16T19:01:40
33,692,680
0
1
null
null
null
null
UTF-8
C++
false
false
634
h
#ifndef RASTERPOSITION_H #define RASTERPOSITION_H #include <ostream> namespace TR { class RasterPosition { private: size_t _row; size_t _col; public: RasterPosition():_row(0), _col(0){} RasterPosition(size_t row, size_t col) :_row(row), _col(col){} inline void set(size_t row, size_t col) { _row = row; _col = col; } inline size_t getCol() const { return _col; } size_t getRow() const { return _row; } friend std::ostream & operator<<(std::ostream & os, RasterPosition & rasterPos) { os<<"[ "; os<< rasterPos.getRow(); os<<","; os<< rasterPos.getCol(); os<<" ]"; return os; } }; } #endif
[ "pethes.robert@gmail.com" ]
pethes.robert@gmail.com
f42ade96f15aabf89b53cc8451f886b68302cdb9
579dbb681f772870d692f468322470612fa553aa
/third-party/Eigen/src/Eigenvalues/ComplexSchur_MKL.h
1607dcd0b27db616576c324ac64572f159fecdfb
[]
no_license
chipbuster/niftyreg
eb69441dc3ee76930da08d580f61550fd448271d
d9bd674a1cdae37688444777cc07862dec366228
refs/heads/master
2021-01-11T08:50:14.626799
2016-12-16T20:46:28
2016-12-16T20:46:28
76,684,058
0
0
null
2016-12-16T20:37:50
2016-12-16T20:37:50
null
UTF-8
C++
false
false
4,014
h
/* Copyright (c) 2011, Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************** * Content : Eigen bindings to Intel(R) MKL * Complex Schur needed to complex unsymmetrical eigenvalues/eigenvectors. ******************************************************************************** */ #ifndef EIGEN_COMPLEX_SCHUR_MKL_H #define EIGEN_COMPLEX_SCHUR_MKL_H #include "Eigen/src/Core/util/MKL_support.h" namespace Eigen { /** \internal Specialization for the data types supported by MKL */ #define EIGEN_MKL_SCHUR_COMPLEX(EIGTYPE, MKLTYPE, MKLPREFIX, MKLPREFIX_U, EIGCOLROW, MKLCOLROW) \ template<> inline \ ComplexSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >& \ ComplexSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW>& matrix, bool computeU) \ { \ typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> MatrixType; \ typedef MatrixType::Scalar Scalar; \ typedef MatrixType::RealScalar RealScalar; \ typedef std::complex<RealScalar> ComplexScalar; \ \ eigen_assert(matrix.cols() == matrix.rows()); \ \ m_matUisUptodate = false; \ if(matrix.cols() == 1) \ { \ m_matT = matrix.cast<ComplexScalar>(); \ if(computeU) m_matU = ComplexMatrixType::Identity(1,1); \ m_info = Success; \ m_isInitialized = true; \ m_matUisUptodate = computeU; \ return *this; \ } \ lapack_int n = matrix.cols(), sdim, info; \ lapack_int lda = matrix.outerStride(); \ lapack_int matrix_order = MKLCOLROW; \ char jobvs, sort='N'; \ LAPACK_##MKLPREFIX_U##_SELECT1 select = 0; \ jobvs = (computeU) ? 'V' : 'N'; \ m_matU.resize(n, n); \ lapack_int ldvs = m_matU.outerStride(); \ m_matT = matrix; \ Matrix<EIGTYPE, Dynamic, Dynamic> w; \ w.resize(n, 1);\ info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)w.data(), (MKLTYPE*)m_matU.data(), ldvs ); \ if(info == 0) \ m_info = Success; \ else \ m_info = NoConvergence; \ \ m_isInitialized = true; \ m_matUisUptodate = computeU; \ return *this; \ \ } EIGEN_MKL_SCHUR_COMPLEX(dcomplex, MKL_Complex16, z, Z, ColMajor, LAPACK_COL_MAJOR) EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, ColMajor, LAPACK_COL_MAJOR) EIGEN_MKL_SCHUR_COMPLEX(dcomplex, MKL_Complex16, z, Z, RowMajor, LAPACK_ROW_MAJOR) EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, RowMajor, LAPACK_ROW_MAJOR) } // end namespace Eigen #endif // EIGEN_COMPLEX_SCHUR_MKL_H
[ "m.modat@ucl.ac.uk" ]
m.modat@ucl.ac.uk
bdffb036a95b305c393e902c7da1f2054ab61d37
f12f4aeca340c2183704377fc6ce6ff4131fc5a0
/Source/Wesley_S_Final/Final_GameStateBase.cpp
63ddb9484fb3d7babd5d8a238767e5bbc4dfa79b
[]
no_license
WesleySweazey/Wesley_S_Final
04b8a0fa0afa63035e494edac91a71a35d467465
d765927ff53b35946dcc692e7c8e7ba72b64a025
refs/heads/master
2020-05-01T19:13:22.887974
2019-03-29T00:47:27
2019-03-29T00:47:27
177,642,555
0
0
null
null
null
null
UTF-8
C++
false
false
1,401
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "Final_GameStateBase.h" #include "GameFramework/GameStateBase.h" #include "Net/UnrealNetwork.h" AFinal_GameStateBase::AFinal_GameStateBase() { bIsPlayerOneLoggedIn = false; bIsPlayerTwoLoggedIn = false; //SetReplicates(true); } void AFinal_GameStateBase::Multicast_SetScoreTeamOne_Implementation(int Score) { TeamOneScore = Score; } void AFinal_GameStateBase::Multicast_SetScoreTeamTwo_Implementation(int Score) { TeamTwoScore = Score; } //TODO Week 7: REPLICATE Variables void AFinal_GameStateBase::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); //REPLICATE //DOREPLIFETIME(AFinal_GameStateBase, TeamsEnabled); DOREPLIFETIME(AFinal_GameStateBase, TeamOneScore); DOREPLIFETIME(AFinal_GameStateBase, TeamTwoScore); DOREPLIFETIME(AFinal_GameStateBase, bIsPlayerOneLoggedIn); DOREPLIFETIME(AFinal_GameStateBase, bIsPlayerTwoLoggedIn); //DOREPLIFETIME(ABaseGameState, TeamOneSize); //DOREPLIFETIME(ABaseGameState, TeamTwoSize); //DOREPLIFETIME(ABaseGameState, GameTime); DOREPLIFETIME(AFinal_GameStateBase, TeamOnePMaterials); DOREPLIFETIME(AFinal_GameStateBase, TeamTwoPMaterials); DOREPLIFETIME(AFinal_GameStateBase, TeamThreePMaterials); }
[ "sweazey48@gmail.com" ]
sweazey48@gmail.com
7a08a66476650b44fd91f9b9aafc06029e2e7989
c4f63f5d2a8efcbec26a133de8aea70e060bfccf
/Lecture 11/PureVirtualFunction.cpp
726dccaae9070e331531382096054f72fa6c2b53
[]
no_license
BitTeam01/CS215
3a4b4091ef1d2d805047e85278d7546338e151e3
8955ca74ef832407acd657149033b621068f12be
refs/heads/master
2020-05-05T12:29:17.152923
2019-04-10T22:25:58
2019-04-10T22:25:58
180,030,721
0
0
null
null
null
null
UTF-8
C++
false
false
803
cpp
#include <iostream> using namespace std; class Shape { protected: double width, height; public: void set_data (double a, double b) { width = a; height = b; } virtual double area() = 0; }; class Rectangle: public Shape { public: double area () { return (width * height); } }; class Triangle: public Shape { public: double area () { return (width * height)/2; } }; int main () { Shape *sPtr; Rectangle Rect; sPtr = &Rect; sPtr -> set_data (5,3); cout << "Area of Rectangle is " << sPtr -> area() << endl; Triangle Tri; sPtr = &Tri; sPtr -> set_data (4,6); cout << "Area of Triangle is " << sPtr -> area() << endl; return 0; }
[ "noreply@github.com" ]
BitTeam01.noreply@github.com
b7a27bbfb48106843ee73d62f02cb8ec9b497a8f
1d0a700bbd7e8542a1f45a133b5e146cad35a9d1
/Ponto.cpp
a88a94690b5530c8076ce4c30b1ec7c6e0500cc2
[]
no_license
rbpimenta/CG-2015-UFES-TC1
3674c533739a3b324114ff2256a864cf27c046e2
317e043ad2d0b03d0a984c4b038d095dab36c67d
refs/heads/master
2022-02-19T14:25:57.801847
2022-02-08T12:47:47
2022-02-08T12:47:47
43,628,402
0
0
null
null
null
null
UTF-8
C++
false
false
600
cpp
/* * Ponto.cpp * * Created on: 20/08/2015 * Author: rodrigo */ #include "Ponto.h" Ponto::Ponto(int x, int y, int id) { // TODO Auto-generated constructor stub this->x = x; this->y = y; this->identificador = id; } Ponto::~Ponto() { // TODO Auto-generated destructor stub } float Ponto::getX(){ return this->x; } void Ponto::setX(float x) { this->x = x; } float Ponto::getY () { return this->y; } void Ponto::setY (float y) { this->y = y; } int Ponto::getIdentificador() { return this->identificador; } void Ponto::setIdentificador(int id) { this->identificador = id; }
[ "rodrigopimenta2@gmail.com" ]
rodrigopimenta2@gmail.com
9abc41d8d846b05335da7807f49359a553d84907
412e41b21e0f93b4a89c49a62c5501b54e3818fe
/examples/Advanced/Display/UTFT_demo/UTFT_demo.ino
4acfe6a6d68a72849e212ba581d178fe05a07861
[ "MIT" ]
permissive
UT2UH/MaixAmigo
11f3d3c269765f0357d0d8645846eb2f892b0c45
0bd593dd2b9591960d6fdb079a7356266d0a8d3d
refs/heads/main
2023-01-07T19:50:53.679766
2020-11-13T09:25:55
2020-11-13T09:25:55
312,208,128
9
1
null
null
null
null
UTF-8
C++
false
false
7,144
ino
// Demo based on: // UTFT_Demo_320x240 by Henning Karlsen // web: http://www.henningkarlsen.com/electronics // /* This sketch uses the GLCD and font 2 only. Make sure all the display driver and pin comnenctions are correct by editting the User_Setup.h file in the TFT_eSPI library folder. ######################################################################### ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### ######################################################################### */ #include <MaixAmigo.h> #define TFT_GREY 0x7BEF unsigned long runTime = 0; void setup() { randomSeed(analogRead(A0)); // Setup the LCD MA.begin(); // MA.Lcd.setRotation(1); } void loop() { randomSeed(millis()); //randomSeed(1234); // This ensure test is repeatable with exact same draws each loop int buf[318]; int x, x2; int y, y2; int r; runTime = millis(); // Clear the screen and draw the frame MA.Lcd.fillScreen(TFT_BLACK); MA.Lcd.fillRect(0, 0, 319, 14,TFT_RED); MA.Lcd.fillRect(0, 226, 319, 14,TFT_GREY); MA.Lcd.setTextColor(TFT_BLACK,TFT_RED); MA.Lcd.drawCentreString("* TFT_eSPI *", 160, 4, 1); MA.Lcd.setTextColor(TFT_YELLOW,TFT_GREY); MA.Lcd.drawCentreString("Adapted by Bodmer", 160, 228,1); MA.Lcd.drawRect(0, 14, 319, 211, TFT_BLUE); // Draw crosshairs MA.Lcd.drawLine(159, 15, 159, 224,TFT_BLUE); MA.Lcd.drawLine(1, 119, 318, 119,TFT_BLUE); for (int i=9; i<310; i+=10) MA.Lcd.drawLine(i, 117, i, 121,TFT_BLUE); for (int i=19; i<220; i+=10) MA.Lcd.drawLine(157, i, 161, i,TFT_BLUE); // Draw sin-, cos- and tan-lines MA.Lcd.setTextColor(TFT_CYAN); MA.Lcd.drawString("Sin", 5, 15,2); for (int i=1; i<318; i++) { MA.Lcd.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95),TFT_CYAN); } MA.Lcd.setTextColor(TFT_RED); MA.Lcd.drawString("Cos", 5, 30,2); for (int i=1; i<318; i++) { MA.Lcd.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95),TFT_RED); } MA.Lcd.setTextColor(TFT_YELLOW); MA.Lcd.drawString("Tan", 5, 45,2); for (int i=1; i<318; i++) { MA.Lcd.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)),TFT_YELLOW); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); MA.Lcd.drawLine(159, 15, 159, 224,TFT_BLUE); MA.Lcd.drawLine(1, 119, 318, 119,TFT_BLUE); int col = 0; // Draw a moving sinewave x=1; for (int i=1; i<(317*20); i++) { x++; if (x==318) x=1; if (i>318) { if ((x==159)||(buf[x-1]==119)) col = TFT_BLUE; else MA.Lcd.drawPixel(x,buf[x-1],TFT_BLACK); } y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100))); MA.Lcd.drawPixel(x,y,TFT_BLUE); buf[x-1]=y; } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // Draw some filled rectangles for (int i=1; i<6; i++) { switch (i) { case 1: col = TFT_MAGENTA; break; case 2: col = TFT_RED; break; case 3: col = TFT_GREEN; break; case 4: col = TFT_BLUE; break; case 5: col = TFT_YELLOW; break; } MA.Lcd.fillRect(70+(i*20), 30+(i*20), 60, 60,col); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // Draw some filled, rounded rectangles for (int i=1; i<6; i++) { switch (i) { case 1: col = TFT_MAGENTA; break; case 2: col = TFT_RED; break; case 3: col = TFT_GREEN; break; case 4: col = TFT_BLUE; break; case 5: col = TFT_YELLOW; break; } MA.Lcd.fillRoundRect(190-(i*20), 30+(i*20), 60,60, 3,col); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // Draw some filled circles for (int i=1; i<6; i++) { switch (i) { case 1: col = TFT_MAGENTA; break; case 2: col = TFT_RED; break; case 3: col = TFT_GREEN; break; case 4: col = TFT_BLUE; break; case 5: col = TFT_YELLOW; break; } MA.Lcd.fillCircle(100+(i*20),60+(i*20), 30,col); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // Draw some lines in a pattern for (int i=15; i<224; i+=5) { MA.Lcd.drawLine(1, i, (i*1.44)-10, 223,TFT_RED); } for (int i=223; i>15; i-=5) { MA.Lcd.drawLine(317, i, (i*1.44)-11, 15,TFT_RED); } for (int i=223; i>15; i-=5) { MA.Lcd.drawLine(1, i, 331-(i*1.44), 15,TFT_CYAN); } for (int i=15; i<224; i+=5) { MA.Lcd.drawLine(317, i, 330-(i*1.44), 223,TFT_CYAN); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // Draw some random circles for (int i=0; i<100; i++) { x=32+random(256); y=45+random(146); r=random(30); MA.Lcd.drawCircle(x, y, r,random(0xFFFF)); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // Draw some random rectangles for (int i=0; i<100; i++) { x=2+random(316); y=16+random(207); x2=2+random(316); y2=16+random(207); if (x2<x) { r=x;x=x2;x2=r; } if (y2<y) { r=y;y=y2;y2=r; } MA.Lcd.drawRect(x, y, x2-x, y2-y,random(0xFFFF)); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // Draw some random rounded rectangles for (int i=0; i<100; i++) { x=2+random(316); y=16+random(207); x2=2+random(316); y2=16+random(207); // We need to get the width and height and do some window checking if (x2<x) { r=x;x=x2;x2=r; } if (y2<y) { r=y;y=y2;y2=r; } // We need a minimum size of 6 if((x2-x)<6) x2=x+6; if((y2-y)<6) y2=y+6; MA.Lcd.drawRoundRect(x, y, x2-x,y2-y, 3,random(0xFFFF)); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); //randomSeed(1234); int colour = 0; for (int i=0; i<100; i++) { x=2+random(316); y=16+random(209); x2=2+random(316); y2=16+random(209); colour=random(0xFFFF); MA.Lcd.drawLine(x, y, x2, y2,colour); } delay(1000); MA.Lcd.fillRect(1,15,317,209,TFT_BLACK); // This test has been modified as it takes more time to calculate the random numbers // than to draw the pixels (3 seconds to produce 30,000 randoms)! for (int i=0; i<10000; i++) { MA.Lcd.drawPixel(2+random(316), 16+random(209),random(0xFFFF)); } // Draw 10,000 pixels to fill a 100x100 pixel box // use the coords as the colour to produce the banding //byte i = 100; //while (i--) { // byte j = 100; // while (j--) MA.Lcd.drawPixel(i+110,j+70,i+j); // //while (j--) MA.Lcd.drawPixel(i+110,j+70,0xFFFF); //} delay(1000); MA.Lcd.fillScreen(TFT_BLUE); MA.Lcd.fillRoundRect(80, 70, 239-80,169-70, 3,TFT_RED); MA.Lcd.setTextColor(TFT_WHITE,TFT_RED); MA.Lcd.drawCentreString("That's it!", 160, 93,2); MA.Lcd.drawCentreString("Restarting in a", 160, 119,2); MA.Lcd.drawCentreString("few seconds...", 160, 132,2); runTime = millis()-runTime; MA.Lcd.setTextColor(TFT_GREEN,TFT_BLUE); MA.Lcd.drawCentreString("Runtime: (msecs)", 160, 210,2); MA.Lcd.setTextDatum(TC_DATUM); MA.Lcd.drawNumber(runTime, 160, 225,2); delay (5000); }
[ "oles@yaremenko.ws" ]
oles@yaremenko.ws
b70fab9e23853c653aefbd9acb43978bdd93f8b8
9d8629da31c36bc1a7a527bff2d2a706fcb2ffff
/ClientList.h
f7625f22f1a7bf7c90eed4500fabd4d0345ed489
[]
no_license
Kostizer/work
a587bd7b06beef83207ef6c7bfa50882e05e18f6
502d207110f7814353b96867b3d8a43700a3b562
refs/heads/main
2023-02-06T09:43:11.033616
2020-12-28T16:42:42
2020-12-28T16:42:42
324,889,176
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
469
h
#ifndef CLIENTLIST_H #define CLIENTLIST_H #include <list> #include "Client.h" class ClientList //список клиентов { private: list <Client*> setPtrsClients; // контейнер список клиентов list <Client*>::iterator iter; //итератор public: ~ClientList(); void insertClient(Client*); //внесение клиента в список void display(); //отображение на экране }; #endif
[ "kostik_563@mail.ru" ]
kostik_563@mail.ru
12e17e494987c7c392af8626487fdecf52ba4153
9da1021aefc6c162d43ddc3c05b184e4cb8d4a5c
/rabin_miller_primality.cpp
aaa00b12f6e1fb9e27e6e4fa7925fcbd58c7f1cb
[]
no_license
phattd15/hacktober_polarity
d4627d2bc2a9869ef7e0fb107d4fb9ed6cc3810e
4f09fd4cc34d4e6c835006f980160bfcb427c739
refs/heads/master
2023-08-15T11:02:48.698650
2021-10-07T18:55:50
2021-10-07T18:55:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
969
cpp
using u64 = uint64_t; using u128 = __uint128_t; u64 binpower(u64 base, u64 e, u64 mod) { u64 result = 1; base %= mod; while (e) { if (e & 1) result = (u128)result * base % mod; base = (u128)base * base % mod; e >>= 1; } return result; } bool check_composite(u64 n, u64 a, u64 d, int s) { u64 x = binpower(a, d, n); if (x == 1 || x == n - 1) return false; for (int r = 1; r < s; r++) { x = (u128)x * x % n; if (x == n - 1) return false; } return true; }; bool MillerRabin(u64 n) { // returns true if n is probably prime, else returns false. if (n < 4) return n == 2 || n == 3; int s = 0; u64 d = n - 1; while ((d & 1) == 0) { d >>= 1; s++; } for (int i = 0; i < iter; i++) { int a = 2 + rand() % (n - 3); if (check_composite(n, a, d, s)) return false; } return true; }
[ "noreply@github.com" ]
phattd15.noreply@github.com
9329b542909a92a9f22a928b6c5ecb5481ae1859
59179e4f655a40b421fa9aeda9c90736b8c11b1b
/compiler/.history/lab1/lexical_20210412111549.cpp
9e749358afe8ee6b26bee1829b3f104bd2421c51
[]
no_license
wjw136/course_designing_project
ccd39da420f0de22b39fa2fea032054f4cbe8bfd
2614928bd779bc0d996857b123e2862836d81333
refs/heads/master
2023-06-04T12:52:40.501335
2021-06-17T13:19:23
2021-06-17T13:19:23
374,384,252
0
0
null
null
null
null
UTF-8
C++
false
false
2,311
cpp
#include <iostream> #include <windows.h> #include <string.h> #include <queue> #include <math.h> #include "stdio.h" #define ll long long #define inf 100000 #define clr1(a) memset(a,-1,sizeof(a)) # define clr(a) memset(a, 0, sizeof(a)) using namespace std; //reserved word static char reserveword[35][20]={ "and","array","begin","bool","call","case", "char","constant","dim","do","else","end", "false","for","if","input","integer","not", "of","or","output","procedure","program","read", "real","repeat","set","stop","then","to","true", "until","var","while","write" }; //operator static char myoperator[22][10]={ "(",")","*","*/","+",",","-", "..","/","/*",":",":=",";","<", "<=","<>","=",">",">=","[","]" }; bool isDigit(char ch){ if(ch>='0'&&ch<='9') return true; else { return false; } } bool isLetter(char ch){ if((ch>='a'&&ch<='z')||(ch<='Z'&&ch>='A')||ch=='_') return true; else { return false; } } int isReserve(char *s){ for(int i=0;i<35;++i){ if(strcmp(reserveword[i],s)==0){ return i+1; } } return -1; } //filter void filter(char *s,int len){ char tmp[10000]; int p=0; for(int i=0;i<len;++i){ //注释 if(s[i]=='/'&&s[i+1]=='*'){ i+=2; while(s[i]!='*'||s[i+1]!='/'){ if(s[i]=='\0'&&s[i]=='\n'){ cout<<"Annotation error!"; exit(0); } i++; } i+=2; } //去除换行等 if(s[i]!='\n'&&s[i]!='\t'&&s[i]!='\v'&&s[i]!='r'){ tmp[p]=s[i]; p++; //i++; } } tmp[p]='\0'; strcpy(s,tmp); } //scanner void scannner(int &syn,char *project,char *token,int &p){ int count=0; char ch; ch=project[p]; while(cjh==" "){//white space ++p; ch=project[p]; } for(int i=0;i<20;i++){ token[i]='\0'; } if(isLetter(project[p])){ token[count++]=project[p++]; while(isLetter(project[p]||isDigit(project[p]))){ token[count++]=project[p++]; } } } int main(){ // string s="sss"; // cout<<(s[1]=='\0'); //system("pause"); return 0; }
[ "2831419633@qq.com" ]
2831419633@qq.com
2a4c22eb9d41d7343e0e3eb83a824e1ae063b130
15fd495f617071de89a066f7d13199a0eca45be5
/old2/initial_separation.hpp
b0b23de445a89adc20f980e497617e772ee9a866
[]
no_license
V-Italy/optical_flow
5176f221a4822398cacc0ce98cc968970a3955e3
5b07f43a5e76136283ab471b85d29fc351725042
refs/heads/master
2021-01-16T19:33:58.171269
2015-05-15T17:30:36
2015-05-15T17:30:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,111
hpp
#ifndef INITIAL_SEPARATION_HPP #define INITIAL_SEPARATION_HPP #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include "types.hpp" #include <iostream> #include <string> #include <unordered_map> #include "tensor_computation.hpp" #include "misc.hpp" void initial_segmentation(const cv::Mat_<cv::Vec2d> &flowfield, cv::Mat_<double> &phi, const std::unordered_map<std::string, parameter> &parameters, cv::Vec6d &dominantmotion ); void segementFlowfield(const cv::Mat_<cv::Vec2d> &f, cv::Mat_<double> &phi, const std::unordered_map<std::string, parameter> &parameters, cv::Vec6d &dominantmotion); bool are_close_blocks(cv::Vec6d a1, cv::Vec6d a2, double Tm, double r); void choose_better_affine( const cv::Mat_<bool> &merged_blocks, const cv::Vec6d &p_new, cv::Vec6d &p_old, const cv::Mat_<cv::Vec2d> &f, int blocksize ); double error_block(int i, int j, int blocksize, const cv::Vec6d &a_p, const cv::Mat_<cv::Vec2d> &flow); #endif
[ "moritz.hamann@deepr.de" ]
moritz.hamann@deepr.de
ed5972250da6a52b159b3fcaeaec504522629a4e
483194ec10e6149c3245ff48c1857f48deba1578
/External/asio/buffer.hpp
8d415b7b464c3c9d157bfe20b446b1124592a77e
[]
no_license
davidroze/StormWebrtc
3efc68c9e16b34da0728716f460f44ca8a50f59d
cd471d5107c3bfe0cb885caf81063915ad4d386a
refs/heads/master
2021-05-08T16:43:43.539787
2018-02-04T10:05:43
2018-02-04T10:05:43
120,167,513
0
0
null
2018-02-04T08:24:11
2018-02-04T08:24:11
null
UTF-8
C++
false
false
89,021
hpp
// // buffer.hpp // ~~~~~~~~~~ // // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef ASIO_BUFFER_HPP #define ASIO_BUFFER_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #include <cstddef> #include <cstring> #include <limits> #include <stdexcept> #include <string> #include <vector> #include "asio/detail/array_fwd.hpp" #include "asio/detail/is_buffer_sequence.hpp" #include "asio/detail/throw_exception.hpp" #include "asio/detail/type_traits.hpp" #if defined(ASIO_MSVC) # if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0) # if !defined(ASIO_DISABLE_BUFFER_DEBUGGING) # define ASIO_ENABLE_BUFFER_DEBUGGING # endif // !defined(ASIO_DISABLE_BUFFER_DEBUGGING) # endif // defined(_HAS_ITERATOR_DEBUGGING) #endif // defined(ASIO_MSVC) #if defined(__GNUC__) # if defined(_GLIBCXX_DEBUG) # if !defined(ASIO_DISABLE_BUFFER_DEBUGGING) # define ASIO_ENABLE_BUFFER_DEBUGGING # endif // !defined(ASIO_DISABLE_BUFFER_DEBUGGING) # endif // defined(_GLIBCXX_DEBUG) #endif // defined(__GNUC__) #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) # include "asio/detail/functional.hpp" #endif // ASIO_ENABLE_BUFFER_DEBUGGING #if defined(ASIO_HAS_BOOST_WORKAROUND) # include <boost/detail/workaround.hpp> # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) \ || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) # define ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND # endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) // || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) #endif // defined(ASIO_HAS_BOOST_WORKAROUND) #if defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) # include "asio/detail/type_traits.hpp" #endif // defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) #include "asio/detail/push_options.hpp" namespace asio { class mutable_buffer; class const_buffer; namespace detail { void* buffer_cast_helper(const mutable_buffer&); const void* buffer_cast_helper(const const_buffer&); std::size_t buffer_size_helper(const mutable_buffer&); std::size_t buffer_size_helper(const const_buffer&); } // namespace detail /// Holds a buffer that can be modified. /** * The mutable_buffer class provides a safe representation of a buffer that can * be modified. It does not own the underlying data, and so is cheap to copy or * assign. * * @par Accessing Buffer Contents * * The contents of a buffer may be accessed using the @ref buffer_size * and @ref buffer_cast functions: * * @code asio::mutable_buffer b1 = ...; * std::size_t s1 = asio::buffer_size(b1); * unsigned char* p1 = asio::buffer_cast<unsigned char*>(b1); * @endcode * * The asio::buffer_cast function permits violations of type safety, so * uses of it in application code should be carefully considered. */ class mutable_buffer { public: /// Construct an empty buffer. mutable_buffer() : data_(0), size_(0) { } /// Construct a buffer to represent a given memory range. mutable_buffer(void* data, std::size_t size) : data_(data), size_(size) { } #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) mutable_buffer(void* data, std::size_t size, asio::detail::function<void()> debug_check) : data_(data), size_(size), debug_check_(debug_check) { } const asio::detail::function<void()>& get_debug_check() const { return debug_check_; } #endif // ASIO_ENABLE_BUFFER_DEBUGGING private: friend void* asio::detail::buffer_cast_helper( const mutable_buffer& b); friend std::size_t asio::detail::buffer_size_helper( const mutable_buffer& b); void* data_; std::size_t size_; #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) asio::detail::function<void()> debug_check_; #endif // ASIO_ENABLE_BUFFER_DEBUGGING }; namespace detail { inline void* buffer_cast_helper(const mutable_buffer& b) { #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) if (b.size_ && b.debug_check_) b.debug_check_(); #endif // ASIO_ENABLE_BUFFER_DEBUGGING return b.data_; } inline std::size_t buffer_size_helper(const mutable_buffer& b) { return b.size_; } } // namespace detail /// Adapts a single modifiable buffer so that it meets the requirements of the /// MutableBufferSequence concept. class mutable_buffers_1 : public mutable_buffer { public: /// The type for each element in the list of buffers. typedef mutable_buffer value_type; /// A random-access iterator type that may be used to read elements. typedef const mutable_buffer* const_iterator; /// Construct to represent a given memory range. mutable_buffers_1(void* data, std::size_t size) : mutable_buffer(data, size) { } /// Construct to represent a single modifiable buffer. explicit mutable_buffers_1(const mutable_buffer& b) : mutable_buffer(b) { } /// Get a random-access iterator to the first element. const_iterator begin() const { return this; } /// Get a random-access iterator for one past the last element. const_iterator end() const { return begin() + 1; } }; /// Holds a buffer that cannot be modified. /** * The const_buffer class provides a safe representation of a buffer that cannot * be modified. It does not own the underlying data, and so is cheap to copy or * assign. * * @par Accessing Buffer Contents * * The contents of a buffer may be accessed using the @ref buffer_size * and @ref buffer_cast functions: * * @code asio::const_buffer b1 = ...; * std::size_t s1 = asio::buffer_size(b1); * const unsigned char* p1 = asio::buffer_cast<const unsigned char*>(b1); * @endcode * * The asio::buffer_cast function permits violations of type safety, so * uses of it in application code should be carefully considered. */ class const_buffer { public: /// Construct an empty buffer. const_buffer() : data_(0), size_(0) { } /// Construct a buffer to represent a given memory range. const_buffer(const void* data, std::size_t size) : data_(data), size_(size) { } /// Construct a non-modifiable buffer from a modifiable one. const_buffer(const mutable_buffer& b) : data_(asio::detail::buffer_cast_helper(b)), size_(asio::detail::buffer_size_helper(b)) #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , debug_check_(b.get_debug_check()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING { } #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) const_buffer(const void* data, std::size_t size, asio::detail::function<void()> debug_check) : data_(data), size_(size), debug_check_(debug_check) { } const asio::detail::function<void()>& get_debug_check() const { return debug_check_; } #endif // ASIO_ENABLE_BUFFER_DEBUGGING private: friend const void* asio::detail::buffer_cast_helper( const const_buffer& b); friend std::size_t asio::detail::buffer_size_helper( const const_buffer& b); const void* data_; std::size_t size_; #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) asio::detail::function<void()> debug_check_; #endif // ASIO_ENABLE_BUFFER_DEBUGGING }; namespace detail { inline const void* buffer_cast_helper(const const_buffer& b) { #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) if (b.size_ && b.debug_check_) b.debug_check_(); #endif // ASIO_ENABLE_BUFFER_DEBUGGING return b.data_; } inline std::size_t buffer_size_helper(const const_buffer& b) { return b.size_; } } // namespace detail /// Adapts a single non-modifiable buffer so that it meets the requirements of /// the ConstBufferSequence concept. class const_buffers_1 : public const_buffer { public: /// The type for each element in the list of buffers. typedef const_buffer value_type; /// A random-access iterator type that may be used to read elements. typedef const const_buffer* const_iterator; /// Construct to represent a given memory range. const_buffers_1(const void* data, std::size_t size) : const_buffer(data, size) { } /// Construct to represent a single non-modifiable buffer. explicit const_buffers_1(const const_buffer& b) : const_buffer(b) { } /// Get a random-access iterator to the first element. const_iterator begin() const { return this; } /// Get a random-access iterator for one past the last element. const_iterator end() const { return begin() + 1; } }; /// Trait to determine whether a type satisfies the MutableBufferSequence /// requirements. template <typename T> struct is_mutable_buffer_sequence #if defined(GENERATING_DOCUMENTATION) : integral_constant<bool, automatically_determined> #else // defined(GENERATING_DOCUMENTATION) : asio::detail::is_buffer_sequence<T, mutable_buffer> #endif // defined(GENERATING_DOCUMENTATION) { }; /// Trait to determine whether a type satisfies the ConstBufferSequence /// requirements. template <typename T> struct is_const_buffer_sequence #if defined(GENERATING_DOCUMENTATION) : integral_constant<bool, automatically_determined> #else // defined(GENERATING_DOCUMENTATION) : asio::detail::is_buffer_sequence<T, const_buffer> #endif // defined(GENERATING_DOCUMENTATION) { }; /// Trait to determine whether a type satisfies the DynamicBufferSequence /// requirements. template <typename T> struct is_dynamic_buffer_sequence #if defined(GENERATING_DOCUMENTATION) : integral_constant<bool, automatically_determined> #else // defined(GENERATING_DOCUMENTATION) : asio::detail::is_dynamic_buffer_sequence<T> #endif // defined(GENERATING_DOCUMENTATION) { }; /// (Deprecated: Use the socket/descriptor wait() and async_wait() member /// functions.) An implementation of both the ConstBufferSequence and /// MutableBufferSequence concepts to represent a null buffer sequence. class null_buffers { public: /// The type for each element in the list of buffers. typedef mutable_buffer value_type; /// A random-access iterator type that may be used to read elements. typedef const mutable_buffer* const_iterator; /// Get a random-access iterator to the first element. const_iterator begin() const { return &buf_; } /// Get a random-access iterator for one past the last element. const_iterator end() const { return &buf_; } private: mutable_buffer buf_; }; /** @defgroup buffer_size asio::buffer_size * * @brief The asio::buffer_size function determines the total number of * bytes in a buffer or buffer sequence. */ /*@{*/ /// Get the number of bytes in a modifiable buffer. inline std::size_t buffer_size(const mutable_buffer& b) { return detail::buffer_size_helper(b); } /// Get the number of bytes in a modifiable buffer. inline std::size_t buffer_size(const mutable_buffers_1& b) { return detail::buffer_size_helper(b); } /// Get the number of bytes in a non-modifiable buffer. inline std::size_t buffer_size(const const_buffer& b) { return detail::buffer_size_helper(b); } /// Get the number of bytes in a non-modifiable buffer. inline std::size_t buffer_size(const const_buffers_1& b) { return detail::buffer_size_helper(b); } /// Get the total number of bytes in a buffer sequence. /** * The @c BufferSequence template parameter may meet either of the @c * ConstBufferSequence or @c MutableBufferSequence type requirements. */ template <typename BufferSequence> inline std::size_t buffer_size(const BufferSequence& b, typename enable_if< is_const_buffer_sequence<BufferSequence>::value >::type* = 0) { std::size_t total_buffer_size = 0; typename BufferSequence::const_iterator iter = b.begin(); typename BufferSequence::const_iterator end = b.end(); for (; iter != end; ++iter) total_buffer_size += detail::buffer_size_helper(*iter); return total_buffer_size; } /*@}*/ /** @defgroup buffer_cast asio::buffer_cast * * @brief The asio::buffer_cast function is used to obtain a pointer to * the underlying memory region associated with a buffer. * * @par Examples: * * To access the memory of a non-modifiable buffer, use: * @code asio::const_buffer b1 = ...; * const unsigned char* p1 = asio::buffer_cast<const unsigned char*>(b1); * @endcode * * To access the memory of a modifiable buffer, use: * @code asio::mutable_buffer b2 = ...; * unsigned char* p2 = asio::buffer_cast<unsigned char*>(b2); * @endcode * * The asio::buffer_cast function permits violations of type safety, so * uses of it in application code should be carefully considered. */ /*@{*/ /// Cast a non-modifiable buffer to a specified pointer to POD type. template <typename PointerToPodType> inline PointerToPodType buffer_cast(const mutable_buffer& b) { return static_cast<PointerToPodType>(detail::buffer_cast_helper(b)); } /// Cast a non-modifiable buffer to a specified pointer to POD type. template <typename PointerToPodType> inline PointerToPodType buffer_cast(const const_buffer& b) { return static_cast<PointerToPodType>(detail::buffer_cast_helper(b)); } /*@}*/ /// Create a new modifiable buffer that is offset from the start of another. /** * @relates mutable_buffer */ inline mutable_buffer operator+(const mutable_buffer& b, std::size_t start) { if (start > buffer_size(b)) return mutable_buffer(); char* new_data = buffer_cast<char*>(b) + start; std::size_t new_size = buffer_size(b) - start; return mutable_buffer(new_data, new_size #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , b.get_debug_check() #endif // ASIO_ENABLE_BUFFER_DEBUGGING ); } /// Create a new modifiable buffer that is offset from the start of another. /** * @relates mutable_buffer */ inline mutable_buffer operator+(std::size_t start, const mutable_buffer& b) { if (start > buffer_size(b)) return mutable_buffer(); char* new_data = buffer_cast<char*>(b) + start; std::size_t new_size = buffer_size(b) - start; return mutable_buffer(new_data, new_size #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , b.get_debug_check() #endif // ASIO_ENABLE_BUFFER_DEBUGGING ); } /// Create a new non-modifiable buffer that is offset from the start of another. /** * @relates const_buffer */ inline const_buffer operator+(const const_buffer& b, std::size_t start) { if (start > buffer_size(b)) return const_buffer(); const char* new_data = buffer_cast<const char*>(b) + start; std::size_t new_size = buffer_size(b) - start; return const_buffer(new_data, new_size #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , b.get_debug_check() #endif // ASIO_ENABLE_BUFFER_DEBUGGING ); } /// Create a new non-modifiable buffer that is offset from the start of another. /** * @relates const_buffer */ inline const_buffer operator+(std::size_t start, const const_buffer& b) { if (start > buffer_size(b)) return const_buffer(); const char* new_data = buffer_cast<const char*>(b) + start; std::size_t new_size = buffer_size(b) - start; return const_buffer(new_data, new_size #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , b.get_debug_check() #endif // ASIO_ENABLE_BUFFER_DEBUGGING ); } #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) namespace detail { template <typename Iterator> class buffer_debug_check { public: buffer_debug_check(Iterator iter) : iter_(iter) { } ~buffer_debug_check() { #if defined(ASIO_MSVC) && (ASIO_MSVC == 1400) // MSVC 8's string iterator checking may crash in a std::string::iterator // object's destructor when the iterator points to an already-destroyed // std::string object, unless the iterator is cleared first. iter_ = Iterator(); #endif // defined(ASIO_MSVC) && (ASIO_MSVC == 1400) } void operator()() { *iter_; } private: Iterator iter_; }; } // namespace detail #endif // ASIO_ENABLE_BUFFER_DEBUGGING /** @defgroup buffer asio::buffer * * @brief The asio::buffer function is used to create a buffer object to * represent raw memory, an array of POD elements, a vector of POD elements, * or a std::string. * * A buffer object represents a contiguous region of memory as a 2-tuple * consisting of a pointer and size in bytes. A tuple of the form <tt>{void*, * size_t}</tt> specifies a mutable (modifiable) region of memory. Similarly, a * tuple of the form <tt>{const void*, size_t}</tt> specifies a const * (non-modifiable) region of memory. These two forms correspond to the classes * mutable_buffer and const_buffer, respectively. To mirror C++'s conversion * rules, a mutable_buffer is implicitly convertible to a const_buffer, and the * opposite conversion is not permitted. * * The simplest use case involves reading or writing a single buffer of a * specified size: * * @code sock.send(asio::buffer(data, size)); @endcode * * In the above example, the return value of asio::buffer meets the * requirements of the ConstBufferSequence concept so that it may be directly * passed to the socket's write function. A buffer created for modifiable * memory also meets the requirements of the MutableBufferSequence concept. * * An individual buffer may be created from a builtin array, std::vector, * std::array or boost::array of POD elements. This helps prevent buffer * overruns by automatically determining the size of the buffer: * * @code char d1[128]; * size_t bytes_transferred = sock.receive(asio::buffer(d1)); * * std::vector<char> d2(128); * bytes_transferred = sock.receive(asio::buffer(d2)); * * std::array<char, 128> d3; * bytes_transferred = sock.receive(asio::buffer(d3)); * * boost::array<char, 128> d4; * bytes_transferred = sock.receive(asio::buffer(d4)); @endcode * * In all three cases above, the buffers created are exactly 128 bytes long. * Note that a vector is @e never automatically resized when creating or using * a buffer. The buffer size is determined using the vector's <tt>size()</tt> * member function, and not its capacity. * * @par Accessing Buffer Contents * * The contents of a buffer may be accessed using the @ref buffer_size and * @ref buffer_cast functions: * * @code asio::mutable_buffer b1 = ...; * std::size_t s1 = asio::buffer_size(b1); * unsigned char* p1 = asio::buffer_cast<unsigned char*>(b1); * * asio::const_buffer b2 = ...; * std::size_t s2 = asio::buffer_size(b2); * const void* p2 = asio::buffer_cast<const void*>(b2); @endcode * * The asio::buffer_cast function permits violations of type safety, so * uses of it in application code should be carefully considered. * * For convenience, the @ref buffer_size function also works on buffer * sequences (that is, types meeting the ConstBufferSequence or * MutableBufferSequence type requirements). In this case, the function returns * the total size of all buffers in the sequence. * * @par Buffer Copying * * The @ref buffer_copy function may be used to copy raw bytes between * individual buffers and buffer sequences. * * In particular, when used with the @ref buffer_size, the @ref buffer_copy * function can be used to linearise a sequence of buffers. For example: * * @code vector<const_buffer> buffers = ...; * * vector<unsigned char> data(asio::buffer_size(buffers)); * asio::buffer_copy(asio::buffer(data), buffers); @endcode * * Note that @ref buffer_copy is implemented in terms of @c memcpy, and * consequently it cannot be used to copy between overlapping memory regions. * * @par Buffer Invalidation * * A buffer object does not have any ownership of the memory it refers to. It * is the responsibility of the application to ensure the memory region remains * valid until it is no longer required for an I/O operation. When the memory * is no longer available, the buffer is said to have been invalidated. * * For the asio::buffer overloads that accept an argument of type * std::vector, the buffer objects returned are invalidated by any vector * operation that also invalidates all references, pointers and iterators * referring to the elements in the sequence (C++ Std, 23.2.4) * * For the asio::buffer overloads that accept an argument of type * std::basic_string, the buffer objects returned are invalidated according to * the rules defined for invalidation of references, pointers and iterators * referring to elements of the sequence (C++ Std, 21.3). * * @par Buffer Arithmetic * * Buffer objects may be manipulated using simple arithmetic in a safe way * which helps prevent buffer overruns. Consider an array initialised as * follows: * * @code boost::array<char, 6> a = { 'a', 'b', 'c', 'd', 'e' }; @endcode * * A buffer object @c b1 created using: * * @code b1 = asio::buffer(a); @endcode * * represents the entire array, <tt>{ 'a', 'b', 'c', 'd', 'e' }</tt>. An * optional second argument to the asio::buffer function may be used to * limit the size, in bytes, of the buffer: * * @code b2 = asio::buffer(a, 3); @endcode * * such that @c b2 represents the data <tt>{ 'a', 'b', 'c' }</tt>. Even if the * size argument exceeds the actual size of the array, the size of the buffer * object created will be limited to the array size. * * An offset may be applied to an existing buffer to create a new one: * * @code b3 = b1 + 2; @endcode * * where @c b3 will set to represent <tt>{ 'c', 'd', 'e' }</tt>. If the offset * exceeds the size of the existing buffer, the newly created buffer will be * empty. * * Both an offset and size may be specified to create a buffer that corresponds * to a specific range of bytes within an existing buffer: * * @code b4 = asio::buffer(b1 + 1, 3); @endcode * * so that @c b4 will refer to the bytes <tt>{ 'b', 'c', 'd' }</tt>. * * @par Buffers and Scatter-Gather I/O * * To read or write using multiple buffers (i.e. scatter-gather I/O), multiple * buffer objects may be assigned into a container that supports the * MutableBufferSequence (for read) or ConstBufferSequence (for write) concepts: * * @code * char d1[128]; * std::vector<char> d2(128); * boost::array<char, 128> d3; * * boost::array<mutable_buffer, 3> bufs1 = { * asio::buffer(d1), * asio::buffer(d2), * asio::buffer(d3) }; * bytes_transferred = sock.receive(bufs1); * * std::vector<const_buffer> bufs2; * bufs2.push_back(asio::buffer(d1)); * bufs2.push_back(asio::buffer(d2)); * bufs2.push_back(asio::buffer(d3)); * bytes_transferred = sock.send(bufs2); @endcode */ /*@{*/ /// Create a new modifiable buffer from an existing buffer. /** * @returns <tt>mutable_buffers_1(b)</tt>. */ inline mutable_buffers_1 buffer(const mutable_buffer& b) { return mutable_buffers_1(b); } /// Create a new modifiable buffer from an existing buffer. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * buffer_cast<void*>(b), * min(buffer_size(b), max_size_in_bytes)); @endcode */ inline mutable_buffers_1 buffer(const mutable_buffer& b, std::size_t max_size_in_bytes) { return mutable_buffers_1( mutable_buffer(buffer_cast<void*>(b), buffer_size(b) < max_size_in_bytes ? buffer_size(b) : max_size_in_bytes #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , b.get_debug_check() #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new non-modifiable buffer from an existing buffer. /** * @returns <tt>const_buffers_1(b)</tt>. */ inline const_buffers_1 buffer(const const_buffer& b) { return const_buffers_1(b); } /// Create a new non-modifiable buffer from an existing buffer. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * buffer_cast<const void*>(b), * min(buffer_size(b), max_size_in_bytes)); @endcode */ inline const_buffers_1 buffer(const const_buffer& b, std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(buffer_cast<const void*>(b), buffer_size(b) < max_size_in_bytes ? buffer_size(b) : max_size_in_bytes #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , b.get_debug_check() #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new modifiable buffer that represents the given memory range. /** * @returns <tt>mutable_buffers_1(data, size_in_bytes)</tt>. */ inline mutable_buffers_1 buffer(void* data, std::size_t size_in_bytes) { return mutable_buffers_1(mutable_buffer(data, size_in_bytes)); } /// Create a new non-modifiable buffer that represents the given memory range. /** * @returns <tt>const_buffers_1(data, size_in_bytes)</tt>. */ inline const_buffers_1 buffer(const void* data, std::size_t size_in_bytes) { return const_buffers_1(const_buffer(data, size_in_bytes)); } /// Create a new modifiable buffer that represents the given POD array. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * static_cast<void*>(data), * N * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline mutable_buffers_1 buffer(PodType (&data)[N]) { return mutable_buffers_1(mutable_buffer(data, N * sizeof(PodType))); } /// Create a new modifiable buffer that represents the given POD array. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * static_cast<void*>(data), * min(N * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline mutable_buffers_1 buffer(PodType (&data)[N], std::size_t max_size_in_bytes) { return mutable_buffers_1( mutable_buffer(data, N * sizeof(PodType) < max_size_in_bytes ? N * sizeof(PodType) : max_size_in_bytes)); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * static_cast<const void*>(data), * N * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(const PodType (&data)[N]) { return const_buffers_1(const_buffer(data, N * sizeof(PodType))); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * static_cast<const void*>(data), * min(N * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(const PodType (&data)[N], std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(data, N * sizeof(PodType) < max_size_in_bytes ? N * sizeof(PodType) : max_size_in_bytes)); } #if defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) // Borland C++ and Sun Studio think the overloads: // // unspecified buffer(boost::array<PodType, N>& array ...); // // and // // unspecified buffer(boost::array<const PodType, N>& array ...); // // are ambiguous. This will be worked around by using a buffer_types traits // class that contains typedefs for the appropriate buffer and container // classes, based on whether PodType is const or non-const. namespace detail { template <bool IsConst> struct buffer_types_base; template <> struct buffer_types_base<false> { typedef mutable_buffer buffer_type; typedef mutable_buffers_1 container_type; }; template <> struct buffer_types_base<true> { typedef const_buffer buffer_type; typedef const_buffers_1 container_type; }; template <typename PodType> struct buffer_types : public buffer_types_base<is_const<PodType>::value> { }; } // namespace detail template <typename PodType, std::size_t N> inline typename detail::buffer_types<PodType>::container_type buffer(boost::array<PodType, N>& data) { typedef typename asio::detail::buffer_types<PodType>::buffer_type buffer_type; typedef typename asio::detail::buffer_types<PodType>::container_type container_type; return container_type( buffer_type(data.c_array(), data.size() * sizeof(PodType))); } template <typename PodType, std::size_t N> inline typename detail::buffer_types<PodType>::container_type buffer(boost::array<PodType, N>& data, std::size_t max_size_in_bytes) { typedef typename asio::detail::buffer_types<PodType>::buffer_type buffer_type; typedef typename asio::detail::buffer_types<PodType>::container_type container_type; return container_type( buffer_type(data.c_array(), data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes)); } #else // defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) /// Create a new modifiable buffer that represents the given POD array. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * data.data(), * data.size() * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline mutable_buffers_1 buffer(boost::array<PodType, N>& data) { return mutable_buffers_1( mutable_buffer(data.c_array(), data.size() * sizeof(PodType))); } /// Create a new modifiable buffer that represents the given POD array. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * data.data(), * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline mutable_buffers_1 buffer(boost::array<PodType, N>& data, std::size_t max_size_in_bytes) { return mutable_buffers_1( mutable_buffer(data.c_array(), data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes)); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * data.size() * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(boost::array<const PodType, N>& data) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType))); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(boost::array<const PodType, N>& data, std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes)); } #endif // defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * data.size() * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(const boost::array<PodType, N>& data) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType))); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(const boost::array<PodType, N>& data, std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes)); } #if defined(ASIO_HAS_STD_ARRAY) || defined(GENERATING_DOCUMENTATION) /// Create a new modifiable buffer that represents the given POD array. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * data.data(), * data.size() * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline mutable_buffers_1 buffer(std::array<PodType, N>& data) { return mutable_buffers_1( mutable_buffer(data.data(), data.size() * sizeof(PodType))); } /// Create a new modifiable buffer that represents the given POD array. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * data.data(), * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline mutable_buffers_1 buffer(std::array<PodType, N>& data, std::size_t max_size_in_bytes) { return mutable_buffers_1( mutable_buffer(data.data(), data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes)); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * data.size() * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(std::array<const PodType, N>& data) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType))); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(std::array<const PodType, N>& data, std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes)); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * data.size() * sizeof(PodType)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(const std::array<PodType, N>& data) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType))); } /// Create a new non-modifiable buffer that represents the given POD array. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode */ template <typename PodType, std::size_t N> inline const_buffers_1 buffer(const std::array<PodType, N>& data, std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes)); } #endif // defined(ASIO_HAS_STD_ARRAY) || defined(GENERATING_DOCUMENTATION) /// Create a new modifiable buffer that represents the given POD vector. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * data.size() ? &data[0] : 0, * data.size() * sizeof(PodType)); @endcode * * @note The buffer is invalidated by any vector operation that would also * invalidate iterators. */ template <typename PodType, typename Allocator> inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data) { return mutable_buffers_1( mutable_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(PodType) #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::vector<PodType, Allocator>::iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new modifiable buffer that represents the given POD vector. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * data.size() ? &data[0] : 0, * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode * * @note The buffer is invalidated by any vector operation that would also * invalidate iterators. */ template <typename PodType, typename Allocator> inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data, std::size_t max_size_in_bytes) { return mutable_buffers_1( mutable_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::vector<PodType, Allocator>::iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new non-modifiable buffer that represents the given POD vector. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.size() ? &data[0] : 0, * data.size() * sizeof(PodType)); @endcode * * @note The buffer is invalidated by any vector operation that would also * invalidate iterators. */ template <typename PodType, typename Allocator> inline const_buffers_1 buffer( const std::vector<PodType, Allocator>& data) { return const_buffers_1( const_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(PodType) #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::vector<PodType, Allocator>::const_iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new non-modifiable buffer that represents the given POD vector. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.size() ? &data[0] : 0, * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode * * @note The buffer is invalidated by any vector operation that would also * invalidate iterators. */ template <typename PodType, typename Allocator> inline const_buffers_1 buffer( const std::vector<PodType, Allocator>& data, std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(PodType) < max_size_in_bytes ? data.size() * sizeof(PodType) : max_size_in_bytes #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::vector<PodType, Allocator>::const_iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new modifiable buffer that represents the given string. /** * @returns <tt>mutable_buffers_1(data.size() ? &data[0] : 0, * data.size() * sizeof(Elem))</tt>. * * @note The buffer is invalidated by any non-const operation called on the * given string object. */ template <typename Elem, typename Traits, typename Allocator> inline mutable_buffers_1 buffer( std::basic_string<Elem, Traits, Allocator>& data) { return mutable_buffers_1(mutable_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(Elem) #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::basic_string<Elem, Traits, Allocator>::iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new non-modifiable buffer that represents the given string. /** * @returns A mutable_buffers_1 value equivalent to: * @code mutable_buffers_1( * data.size() ? &data[0] : 0, * min(data.size() * sizeof(Elem), max_size_in_bytes)); @endcode * * @note The buffer is invalidated by any non-const operation called on the * given string object. */ template <typename Elem, typename Traits, typename Allocator> inline mutable_buffers_1 buffer( std::basic_string<Elem, Traits, Allocator>& data, std::size_t max_size_in_bytes) { return mutable_buffers_1( mutable_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(Elem) < max_size_in_bytes ? data.size() * sizeof(Elem) : max_size_in_bytes #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::basic_string<Elem, Traits, Allocator>::iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new non-modifiable buffer that represents the given string. /** * @returns <tt>const_buffers_1(data.data(), data.size() * sizeof(Elem))</tt>. * * @note The buffer is invalidated by any non-const operation called on the * given string object. */ template <typename Elem, typename Traits, typename Allocator> inline const_buffers_1 buffer( const std::basic_string<Elem, Traits, Allocator>& data) { return const_buffers_1(const_buffer(data.data(), data.size() * sizeof(Elem) #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::basic_string<Elem, Traits, Allocator>::const_iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /// Create a new non-modifiable buffer that represents the given string. /** * @returns A const_buffers_1 value equivalent to: * @code const_buffers_1( * data.data(), * min(data.size() * sizeof(Elem), max_size_in_bytes)); @endcode * * @note The buffer is invalidated by any non-const operation called on the * given string object. */ template <typename Elem, typename Traits, typename Allocator> inline const_buffers_1 buffer( const std::basic_string<Elem, Traits, Allocator>& data, std::size_t max_size_in_bytes) { return const_buffers_1( const_buffer(data.data(), data.size() * sizeof(Elem) < max_size_in_bytes ? data.size() * sizeof(Elem) : max_size_in_bytes #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) , detail::buffer_debug_check< typename std::basic_string<Elem, Traits, Allocator>::const_iterator >(data.begin()) #endif // ASIO_ENABLE_BUFFER_DEBUGGING )); } /*@}*/ /// Adapt a basic_string to the DynamicBufferSequence requirements. /** * Requires that <tt>sizeof(Elem) == 1</tt>. */ template <typename Elem, typename Traits, typename Allocator> class dynamic_string_buffer { public: /// The type used to represent the input sequence as a list of buffers. typedef const_buffers_1 const_buffers_type; /// The type used to represent the output sequence as a list of buffers. typedef mutable_buffers_1 mutable_buffers_type; /// Construct a dynamic buffer from a string. /** * @param s The string to be used as backing storage for the dynamic buffer. * Any existing data in the string is treated as the dynamic buffer's input * sequence. The object stores a reference to the string and the user is * responsible for ensuring that the string object remains valid until the * dynamic_string_buffer object is destroyed. * * @param maximum_size Specifies a maximum size for the buffer, in bytes. */ explicit dynamic_string_buffer(std::basic_string<Elem, Traits, Allocator>& s, std::size_t maximum_size = (std::numeric_limits<std::size_t>::max)()) : string_(s), size_(string_.size()), max_size_(maximum_size) { } #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move construct a dynamic buffer. dynamic_string_buffer(dynamic_string_buffer&& other) : string_(other.string_), size_(other.size_), max_size_(other.max_size_) { } #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Get the size of the input sequence. std::size_t size() const ASIO_NOEXCEPT { return size_; } /// Get the maximum size of the dynamic buffer. /** * @returns The allowed maximum of the sum of the sizes of the input sequence * and output sequence. */ std::size_t max_size() const ASIO_NOEXCEPT { return max_size_; } /// Get the current capacity of the dynamic buffer. /** * @returns The current total capacity of the buffer, i.e. for both the input * sequence and output sequence. */ std::size_t capacity() const ASIO_NOEXCEPT { return string_.capacity(); } /// Get a list of buffers that represents the input sequence. /** * @returns An object of type @c const_buffers_type that satisfies * ConstBufferSequence requirements, representing the basic_string memory in * input sequence. * * @note The returned object is invalidated by any @c dynamic_string_buffer * or @c basic_string member function that modifies the input sequence or * output sequence. */ const_buffers_type data() const ASIO_NOEXCEPT { return asio::buffer(string_, size_); } /// Get a list of buffers that represents the output sequence, with the given /// size. /** * Ensures that the output sequence can accommodate @c n bytes, resizing the * basic_string object as necessary. * * @returns An object of type @c mutable_buffers_type that satisfies * MutableBufferSequence requirements, representing basic_string memory * at the start of the output sequence of size @c n. * * @throws std::length_error If <tt>size() + n > max_size()</tt>. * * @note The returned object is invalidated by any @c dynamic_string_buffer * or @c basic_string member function that modifies the input sequence or * output sequence. */ mutable_buffers_type prepare(std::size_t n) { if (size () > max_size() || max_size() - size() < n) { std::length_error ex("dynamic_string_buffer too long"); asio::detail::throw_exception(ex); } string_.resize(size_ + n); return asio::buffer(asio::buffer(string_) + size_, n); } /// Move bytes from the output sequence to the input sequence. /** * @param n The number of bytes to append from the start of the output * sequence to the end of the input sequence. The remainder of the output * sequence is discarded. * * Requires a preceding call <tt>prepare(x)</tt> where <tt>x >= n</tt>, and * no intervening operations that modify the input or output sequence. * * @note If @c n is greater than the size of the output sequence, the entire * output sequence is moved to the input sequence and no error is issued. */ void commit(std::size_t n) { size_ += (std::min)(n, string_.size() - size_); string_.resize(size_); } /// Remove characters from the input sequence. /** * Removes @c n characters from the beginning of the input sequence. * * @note If @c n is greater than the size of the input sequence, the entire * input sequence is consumed and no error is issued. */ void consume(std::size_t n) { std::size_t consume_length = (std::min)(n, size_); string_.erase(consume_length); size_ -= consume_length; } private: std::basic_string<Elem, Traits, Allocator>& string_; std::size_t size_; const std::size_t max_size_; }; /// Adapt a vector to the DynamicBufferSequence requirements. /** * Requires that <tt>sizeof(Elem) == 1</tt>. */ template <typename Elem, typename Allocator> class dynamic_vector_buffer { public: /// The type used to represent the input sequence as a list of buffers. typedef const_buffers_1 const_buffers_type; /// The type used to represent the output sequence as a list of buffers. typedef mutable_buffers_1 mutable_buffers_type; /// Construct a dynamic buffer from a string. /** * @param v The vector to be used as backing storage for the dynamic buffer. * Any existing data in the vector is treated as the dynamic buffer's input * sequence. The object stores a reference to the vector and the user is * responsible for ensuring that the vector object remains valid until the * dynamic_vector_buffer object is destroyed. * * @param maximum_size Specifies a maximum size for the buffer, in bytes. */ explicit dynamic_vector_buffer(std::vector<Elem, Allocator>& v, std::size_t maximum_size = (std::numeric_limits<std::size_t>::max)()) : vector_(v), size_(vector_.size()), max_size_(maximum_size) { } #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move construct a dynamic buffer. dynamic_vector_buffer(dynamic_vector_buffer&& other) : vector_(other.vector_), size_(other.size_), max_size_(other.max_size_) { } #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Get the size of the input sequence. std::size_t size() const ASIO_NOEXCEPT { return size_; } /// Get the maximum size of the dynamic buffer. /** * @returns The allowed maximum of the sum of the sizes of the input sequence * and output sequence. */ std::size_t max_size() const ASIO_NOEXCEPT { return max_size_; } /// Get the current capacity of the dynamic buffer. /** * @returns The current total capacity of the buffer, i.e. for both the input * sequence and output sequence. */ std::size_t capacity() const ASIO_NOEXCEPT { return vector_.capacity(); } /// Get a list of buffers that represents the input sequence. /** * @returns An object of type @c const_buffers_type that satisfies * ConstBufferSequence requirements, representing the basic_string memory in * input sequence. * * @note The returned object is invalidated by any @c dynamic_vector_buffer * or @c basic_string member function that modifies the input sequence or * output sequence. */ const_buffers_type data() const ASIO_NOEXCEPT { return asio::buffer(vector_, size_); } /// Get a list of buffers that represents the output sequence, with the given /// size. /** * Ensures that the output sequence can accommodate @c n bytes, resizing the * basic_string object as necessary. * * @returns An object of type @c mutable_buffers_type that satisfies * MutableBufferSequence requirements, representing basic_string memory * at the start of the output sequence of size @c n. * * @throws std::length_error If <tt>size() + n > max_size()</tt>. * * @note The returned object is invalidated by any @c dynamic_vector_buffer * or @c basic_string member function that modifies the input sequence or * output sequence. */ mutable_buffers_type prepare(std::size_t n) { if (size () > max_size() || max_size() - size() < n) { std::length_error ex("dynamic_vector_buffer too long"); asio::detail::throw_exception(ex); } vector_.resize(size_ + n); return asio::buffer(asio::buffer(vector_) + size_, n); } /// Move bytes from the output sequence to the input sequence. /** * @param n The number of bytes to append from the start of the output * sequence to the end of the input sequence. The remainder of the output * sequence is discarded. * * Requires a preceding call <tt>prepare(x)</tt> where <tt>x >= n</tt>, and * no intervening operations that modify the input or output sequence. * * @note If @c n is greater than the size of the output sequence, the entire * output sequence is moved to the input sequence and no error is issued. */ void commit(std::size_t n) { size_ += (std::min)(n, vector_.size() - size_); vector_.resize(size_); } /// Remove characters from the input sequence. /** * Removes @c n characters from the beginning of the input sequence. * * @note If @c n is greater than the size of the input sequence, the entire * input sequence is consumed and no error is issued. */ void consume(std::size_t n) { std::size_t consume_length = (std::min)(n, size_); vector_.erase(consume_length); size_ -= consume_length; } private: std::vector<Elem, Allocator>& vector_; std::size_t size_; const std::size_t max_size_; }; /** @defgroup dynamic_buffer asio::dynamic_buffer * * @brief The asio::dynamic_buffer function is used to create a * dynamically resized buffer from a @c std::basic_string or @c std::vector. */ /*@{*/ /// Create a new dynamic buffer that represents the given string. /** * @returns <tt>dynamic_string_buffer<Elem, Traits, Allocator>(data)</tt>. */ template <typename Elem, typename Traits, typename Allocator> inline dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer( std::basic_string<Elem, Traits, Allocator>& data) { return dynamic_string_buffer<Elem, Traits, Allocator>(data); } /// Create a new dynamic buffer that represents the given string. /** * @returns <tt>dynamic_string_buffer<Elem, Traits, Allocator>(data, * max_size)</tt>. */ template <typename Elem, typename Traits, typename Allocator> inline dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer( std::basic_string<Elem, Traits, Allocator>& data, std::size_t max_size) { return dynamic_string_buffer<Elem, Traits, Allocator>(data, max_size); } /// Create a new dynamic buffer that represents the given vector. /** * @returns <tt>dynamic_vector_buffer<Elem, Allocator>(data)</tt>. */ template <typename Elem, typename Allocator> inline dynamic_vector_buffer<Elem, Allocator> dynamic_buffer( std::vector<Elem, Allocator>& data) { return dynamic_vector_buffer<Elem, Allocator>(data); } /// Create a new dynamic buffer that represents the given vector. /** * @returns <tt>dynamic_vector_buffer<Elem, Allocator>(data, max_size)</tt>. */ template <typename Elem, typename Allocator> inline dynamic_vector_buffer<Elem, Allocator> dynamic_buffer( std::vector<Elem, Allocator>& data, std::size_t max_size) { return dynamic_vector_buffer<Elem, Allocator>(data, max_size); } /*@}*/ /** @defgroup buffer_copy asio::buffer_copy * * @brief The asio::buffer_copy function is used to copy bytes from a * source buffer (or buffer sequence) to a target buffer (or buffer sequence). * * The @c buffer_copy function is available in two forms: * * @li A 2-argument form: @c buffer_copy(target, source) * * @li A 3-argument form: @c buffer_copy(target, source, max_bytes_to_copy) * * Both forms return the number of bytes actually copied. The number of bytes * copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c If specified, @c max_bytes_to_copy. * * This prevents buffer overflow, regardless of the buffer sizes used in the * copy operation. * * Note that @ref buffer_copy is implemented in terms of @c memcpy, and * consequently it cannot be used to copy between overlapping memory regions. */ /*@{*/ /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const const_buffer& source) { using namespace std; // For memcpy. std::size_t target_size = buffer_size(target); std::size_t source_size = buffer_size(source); std::size_t n = target_size < source_size ? target_size : source_size; memcpy(buffer_cast<void*>(target), buffer_cast<const void*>(source), n); return n; } /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const const_buffers_1& source) { return buffer_copy(target, static_cast<const const_buffer&>(source)); } /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const mutable_buffer& source) { return buffer_copy(target, const_buffer(source)); } /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const mutable_buffers_1& source) { return buffer_copy(target, const_buffer(source)); } /// Copies bytes from a source buffer sequence to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer sequence representing the memory * regions from which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename ConstBufferSequence> std::size_t buffer_copy(const mutable_buffer& target, const ConstBufferSequence& source, typename enable_if< is_const_buffer_sequence<ConstBufferSequence>::value >::type* = 0) { std::size_t total_bytes_copied = 0; typename ConstBufferSequence::const_iterator source_iter = source.begin(); typename ConstBufferSequence::const_iterator source_end = source.end(); for (mutable_buffer target_buffer(target); buffer_size(target_buffer) && source_iter != source_end; ++source_iter) { const_buffer source_buffer(*source_iter); std::size_t bytes_copied = buffer_copy(target_buffer, source_buffer); total_bytes_copied += bytes_copied; target_buffer = target_buffer + bytes_copied; } return total_bytes_copied; } /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const const_buffer& source) { return buffer_copy(static_cast<const mutable_buffer&>(target), source); } /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const const_buffers_1& source) { return buffer_copy(static_cast<const mutable_buffer&>(target), static_cast<const const_buffer&>(source)); } /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const mutable_buffer& source) { return buffer_copy(static_cast<const mutable_buffer&>(target), const_buffer(source)); } /// Copies bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const mutable_buffers_1& source) { return buffer_copy(static_cast<const mutable_buffer&>(target), const_buffer(source)); } /// Copies bytes from a source buffer sequence to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer sequence representing the memory * regions from which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename ConstBufferSequence> inline std::size_t buffer_copy(const mutable_buffers_1& target, const ConstBufferSequence& source, typename enable_if< is_const_buffer_sequence<ConstBufferSequence>::value >::type* = 0) { return buffer_copy(static_cast<const mutable_buffer&>(target), source); } /// Copies bytes from a source buffer to a target buffer sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> std::size_t buffer_copy(const MutableBufferSequence& target, const const_buffer& source, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { std::size_t total_bytes_copied = 0; typename MutableBufferSequence::const_iterator target_iter = target.begin(); typename MutableBufferSequence::const_iterator target_end = target.end(); for (const_buffer source_buffer(source); buffer_size(source_buffer) && target_iter != target_end; ++target_iter) { mutable_buffer target_buffer(*target_iter); std::size_t bytes_copied = buffer_copy(target_buffer, source_buffer); total_bytes_copied += bytes_copied; source_buffer = source_buffer + bytes_copied; } return total_bytes_copied; } /// Copies bytes from a source buffer to a target buffer sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> inline std::size_t buffer_copy(const MutableBufferSequence& target, const const_buffers_1& source, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { return buffer_copy(target, static_cast<const const_buffer&>(source)); } /// Copies bytes from a source buffer to a target buffer sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> inline std::size_t buffer_copy(const MutableBufferSequence& target, const mutable_buffer& source, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { return buffer_copy(target, const_buffer(source)); } /// Copies bytes from a source buffer to a target buffer sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> inline std::size_t buffer_copy(const MutableBufferSequence& target, const mutable_buffers_1& source, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { return buffer_copy(target, const_buffer(source)); } /// Copies bytes from a source buffer sequence to a target buffer sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A non-modifiable buffer sequence representing the memory * regions from which the bytes will be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence, typename ConstBufferSequence> std::size_t buffer_copy(const MutableBufferSequence& target, const ConstBufferSequence& source, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value && is_const_buffer_sequence<ConstBufferSequence>::value >::type* = 0) { std::size_t total_bytes_copied = 0; typename MutableBufferSequence::const_iterator target_iter = target.begin(); typename MutableBufferSequence::const_iterator target_end = target.end(); std::size_t target_buffer_offset = 0; typename ConstBufferSequence::const_iterator source_iter = source.begin(); typename ConstBufferSequence::const_iterator source_end = source.end(); std::size_t source_buffer_offset = 0; while (target_iter != target_end && source_iter != source_end) { mutable_buffer target_buffer = mutable_buffer(*target_iter) + target_buffer_offset; const_buffer source_buffer = const_buffer(*source_iter) + source_buffer_offset; std::size_t bytes_copied = buffer_copy(target_buffer, source_buffer); total_bytes_copied += bytes_copied; if (bytes_copied == buffer_size(target_buffer)) { ++target_iter; target_buffer_offset = 0; } else target_buffer_offset += bytes_copied; if (bytes_copied == buffer_size(source_buffer)) { ++source_iter; source_buffer_offset = 0; } else source_buffer_offset += bytes_copied; } return total_bytes_copied; } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const const_buffer& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const const_buffers_1& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const mutable_buffer& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffer& target, const mutable_buffers_1& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer sequence to a target /// buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer sequence representing the memory * regions from which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename ConstBufferSequence> inline std::size_t buffer_copy(const mutable_buffer& target, const ConstBufferSequence& source, std::size_t max_bytes_to_copy, typename enable_if< is_const_buffer_sequence<ConstBufferSequence>::value >::type* = 0) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const const_buffer& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const const_buffers_1& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const mutable_buffer& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ inline std::size_t buffer_copy(const mutable_buffers_1& target, const mutable_buffers_1& source, std::size_t max_bytes_to_copy) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer sequence to a target /// buffer. /** * @param target A modifiable buffer representing the memory region to which * the bytes will be copied. * * @param source A non-modifiable buffer sequence representing the memory * regions from which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename ConstBufferSequence> inline std::size_t buffer_copy(const mutable_buffers_1& target, const ConstBufferSequence& source, std::size_t max_bytes_to_copy, typename enable_if< is_const_buffer_sequence<ConstBufferSequence>::value >::type* = 0) { return buffer_copy(buffer(target, max_bytes_to_copy), source); } /// Copies a limited number of bytes from a source buffer to a target buffer /// sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> inline std::size_t buffer_copy(const MutableBufferSequence& target, const const_buffer& source, std::size_t max_bytes_to_copy, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { return buffer_copy(target, buffer(source, max_bytes_to_copy)); } /// Copies a limited number of bytes from a source buffer to a target buffer /// sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A non-modifiable buffer representing the memory region from * which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> inline std::size_t buffer_copy(const MutableBufferSequence& target, const const_buffers_1& source, std::size_t max_bytes_to_copy, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { return buffer_copy(target, buffer(source, max_bytes_to_copy)); } /// Copies a limited number of bytes from a source buffer to a target buffer /// sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> inline std::size_t buffer_copy(const MutableBufferSequence& target, const mutable_buffer& source, std::size_t max_bytes_to_copy, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { return buffer_copy(target, buffer(source, max_bytes_to_copy)); } /// Copies a limited number of bytes from a source buffer to a target buffer /// sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A modifiable buffer representing the memory region from which * the bytes will be copied. The contents of the source buffer will not be * modified. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence> inline std::size_t buffer_copy(const MutableBufferSequence& target, const mutable_buffers_1& source, std::size_t max_bytes_to_copy, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value >::type* = 0) { return buffer_copy(target, buffer(source, max_bytes_to_copy)); } /// Copies a limited number of bytes from a source buffer sequence to a target /// buffer sequence. /** * @param target A modifiable buffer sequence representing the memory regions to * which the bytes will be copied. * * @param source A non-modifiable buffer sequence representing the memory * regions from which the bytes will be copied. * * @param max_bytes_to_copy The maximum number of bytes to be copied. * * @returns The number of bytes copied. * * @note The number of bytes copied is the lesser of: * * @li @c buffer_size(target) * * @li @c buffer_size(source) * * @li @c max_bytes_to_copy * * This function is implemented in terms of @c memcpy, and consequently it * cannot be used to copy between overlapping memory regions. */ template <typename MutableBufferSequence, typename ConstBufferSequence> std::size_t buffer_copy(const MutableBufferSequence& target, const ConstBufferSequence& source, std::size_t max_bytes_to_copy, typename enable_if< is_mutable_buffer_sequence<MutableBufferSequence>::value && is_const_buffer_sequence<ConstBufferSequence>::value >::type* = 0) { std::size_t total_bytes_copied = 0; typename MutableBufferSequence::const_iterator target_iter = target.begin(); typename MutableBufferSequence::const_iterator target_end = target.end(); std::size_t target_buffer_offset = 0; typename ConstBufferSequence::const_iterator source_iter = source.begin(); typename ConstBufferSequence::const_iterator source_end = source.end(); std::size_t source_buffer_offset = 0; while (total_bytes_copied != max_bytes_to_copy && target_iter != target_end && source_iter != source_end) { mutable_buffer target_buffer = mutable_buffer(*target_iter) + target_buffer_offset; const_buffer source_buffer = const_buffer(*source_iter) + source_buffer_offset; std::size_t bytes_copied = buffer_copy(target_buffer, source_buffer, max_bytes_to_copy - total_bytes_copied); total_bytes_copied += bytes_copied; if (bytes_copied == buffer_size(target_buffer)) { ++target_iter; target_buffer_offset = 0; } else target_buffer_offset += bytes_copied; if (bytes_copied == buffer_size(source_buffer)) { ++source_iter; source_buffer_offset = 0; } else source_buffer_offset += bytes_copied; } return total_bytes_copied; } /*@}*/ } // namespace asio #include "asio/detail/pop_options.hpp" #endif // ASIO_BUFFER_HPP
[ "nick.weihs@gmail.com" ]
nick.weihs@gmail.com
68c1f3492321d6c392930137815027e79acb2db1
636f92553b5077f82e9c2b6dfa84508a7d7ede0a
/Happic Engine/Src/Platform/Windows/Win32Input.h
c6a6e59acfc866b52cfd18ae42377adca5c1eca5
[]
no_license
Happic-Games/Happic-Game-Engine
c7f3edaa88ca9388ea4b295775d0bad06ecdb3a8
18af6621abf43883640d14e815cd0bc7819c761e
refs/heads/master
2020-04-20T08:36:59.879767
2019-02-03T06:04:20
2019-02-03T06:04:20
168,744,549
0
1
null
null
null
null
UTF-8
C++
false
false
515
h
#pragma once #include "../../Core/IDisplayInput.h" #define WIN32_LEAN_AND_MEAN #include <windows.h> namespace Happic { namespace Core { class Win32Input : public IDisplayInput { public: Win32Input(const HWND& handle); Math::Vector2f GetCursorPosition() const override; void SetCursorPosition(const Math::Vector2f& pos) const override; void SetCursorVisible(bool visible) const override; bool IsCursorVisible() const override; private: HWND m_handle; mutable bool m_isCursorVisible; }; } }
[ "eunoiagamess@gmail.com" ]
eunoiagamess@gmail.com
2a1fb4641c92acbc5bff6165c23261bd00c63cad
8191afce54f369c18f98c602b1ee99fcb5a75004
/Composite/Leaf.h
45f73608ae43cf657c68867da18b4ad661c7ad85
[]
no_license
KoiKomei/INGSW
07f9a49a9c735ec0bba10537840b9e3ae4d0811f
456b6f366177772c3340bf2c469f01dd218171d9
refs/heads/master
2020-04-01T17:24:29.858283
2018-11-14T18:04:52
2018-11-14T18:04:52
153,427,765
0
0
null
null
null
null
UTF-8
C++
false
false
236
h
#pragma once #ifndef LEAF_H #define LEAF_H #include "Component.h" class Leaf :public Component { public: Leaf(int val) { value = val; } void traverse() { cout << value << ' '; } private: int value; }; #endif // !LEAF_H
[ "alex.parisella@gmail.com" ]
alex.parisella@gmail.com
d0190dde961e85b3b39073997fc9b4cf65f8c2d3
bf798d5af7effdb06f373ac653e98cb4dd145a5c
/src/qif191/QIFDocument/type_t.CStatsNumericalBaseType.h
5f4a39139d939aa5977a1ca815d08d2e774e6625
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
QualityInformationFramework/QIFResourcesEditor
73387fca4f4280cc1145fae32438c5d2fdc63cd5
4ff1de9d1dd20d9c43eaa9cc320caeff1c57760e
refs/heads/master
2022-07-29T15:57:04.341916
2021-08-04T16:36:42
2021-08-04T16:36:42
298,856,948
0
0
null
null
null
null
UTF-8
C++
false
false
9,057
h
#pragma once #include "type_t.CStatsBaseType.h" namespace qif191 { namespace t { class CStatsNumericalBaseType : public ::qif191::t::CStatsBaseType { public: QIF191_EXPORT CStatsNumericalBaseType(xercesc::DOMNode* const& init); QIF191_EXPORT CStatsNumericalBaseType(CStatsNumericalBaseType const& init); void operator=(CStatsNumericalBaseType const& other) { m_node = other.m_node; } static altova::meta::ComplexType StaticInfo() { return altova::meta::ComplexType(types + _altova_ti_t_altova_CStatsNumericalBaseType); } MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Average> Average; struct Average { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CSubgroupDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_SubgroupAverage> SubgroupAverage; struct SubgroupAverage { typedef Iterator<t::CSubgroupDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Difference> Difference; struct Difference { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CSubgroupDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_SubgroupDifference> SubgroupDifference; struct SubgroupDifference { typedef Iterator<t::CSubgroupDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_RootMeanSquare> RootMeanSquare; struct RootMeanSquare { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Maximum> Maximum; struct Maximum { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CQIFReferenceFullType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_MaximumId> MaximumId; struct MaximumId { typedef Iterator<t::CQIFReferenceFullType> iterator; }; MemberElement<t::CSubgroupDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_SubgroupMaximum> SubgroupMaximum; struct SubgroupMaximum { typedef Iterator<t::CSubgroupDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Minimum> Minimum; struct Minimum { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CQIFReferenceFullType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_MinimumId> MinimumId; struct MinimumId { typedef Iterator<t::CQIFReferenceFullType> iterator; }; MemberElement<t::CSubgroupDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_SubgroupMinimum> SubgroupMinimum; struct SubgroupMinimum { typedef Iterator<t::CSubgroupDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Range> Range; struct Range { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CSubgroupDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_SubgroupRange> SubgroupRange; struct SubgroupRange { typedef Iterator<t::CSubgroupDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_AverageRange> AverageRange; struct AverageRange { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_StandardDeviation> StandardDeviation; struct StandardDeviation { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Skew> Skew; struct Skew { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Kurtosis> Kurtosis; struct Kurtosis { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Normality> Normality; struct Normality { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_ProcessVariation> ProcessVariation; struct ProcessVariation { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_EstimatedStandardDeviation> EstimatedStandardDeviation; struct EstimatedStandardDeviation { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_UpperControlLimit> UpperControlLimit; struct UpperControlLimit { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_LowerControlLimit> LowerControlLimit; struct LowerControlLimit { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_UpperControlLimitRange> UpperControlLimitRange; struct UpperControlLimitRange { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_LowerControlLimitRange> LowerControlLimitRange; struct LowerControlLimitRange { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<xs::CnonNegativeIntegerType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_NumberOutOfControl> NumberOutOfControl; struct NumberOutOfControl { typedef Iterator<xs::CnonNegativeIntegerType> iterator; }; MemberElement<t::CArrayReferenceFullType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_OutOfControlIds> OutOfControlIds; struct OutOfControlIds { typedef Iterator<t::CArrayReferenceFullType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_AppraiserVariation> AppraiserVariation; struct AppraiserVariation { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_EquipmentVariation> EquipmentVariation; struct EquipmentVariation { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Interaction> Interaction; struct Interaction { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_GageRandR> GageRandR; struct GageRandR { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_PartVariation> PartVariation; struct PartVariation { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_TotalVariation> TotalVariation; struct TotalVariation { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Linearity> Linearity; struct Linearity { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_Bias> Bias; struct Bias { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_RelativeLinearity> RelativeLinearity; struct RelativeLinearity { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_RelativeBias> RelativeBias; struct RelativeBias { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_GoodnessOfFit> GoodnessOfFit; struct GoodnessOfFit { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_RegressionSlope> RegressionSlope; struct RegressionSlope { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_RegressionIntercept> RegressionIntercept; struct RegressionIntercept { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_UpperConfidenceLimit> UpperConfidenceLimit; struct UpperConfidenceLimit { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_LowerConfidenceLimit> LowerConfidenceLimit; struct LowerConfidenceLimit { typedef Iterator<t::CActualDecimalType> iterator; }; MemberElement<t::CActualDecimalType, _altova_mi_t_altova_CStatsNumericalBaseType_altova_TDistribution> TDistribution; struct TDistribution { typedef Iterator<t::CActualDecimalType> iterator; }; QIF191_EXPORT void SetXsiType(); }; } // namespace t } // namespace qif191 //#endif // _ALTOVA_INCLUDED_QIFDocument_ALTOVA_t_ALTOVA_CStatsNumericalBaseType
[ "dc@capvidia.com" ]
dc@capvidia.com
75c791d96d328bde914eede19276e9f4751d49c0
67efc5a1259f2ea7f592bbf37f05e0cd5542cea6
/PA9_KendraKendall/Square.cpp
54ac4c0bf4bb9bdb466459507ab58450e4ef0a91
[]
no_license
kylerlittle/worlds-hardest-game
c96e7a7ed7a618c7609232ea9727e1a8e35b5c9d
403be2795a984982e7bd5d9da7945b48f4f8e74c
refs/heads/master
2021-07-06T14:44:04.622126
2017-09-26T22:58:27
2017-09-26T22:58:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
212
cpp
#include "Square.h" /*Default constructor*/ Square::Square() : RectangleShape(sf::Vector2f(SQUARE_LEN, SQUARE_LEN)) { setFillColor(sf::Color::Red); setOutlineThickness(1); setOutlineColor(sf::Color::Black); }
[ "Kyler Little@DESKTOP-KQ9SPFN" ]
Kyler Little@DESKTOP-KQ9SPFN
854f41ff4f8f4acbdd604002d18634484387eaa2
6e892420c9f690d6e6204170889085639005f16c
/parallel_algos/array_sum/parallel_sum2.cpp
913848e345700c4ecc11caf3c6401e014529b168
[]
no_license
yashagarwal23/hpclabwork
582ade526855e1a2a88c2c2306985249498ba154
e7a08fb73208e57eef108fbff9ab6b97d9b5d173
refs/heads/master
2020-07-07T17:42:49.433645
2020-01-14T11:40:37
2020-01-14T11:40:37
203,425,485
0
0
null
null
null
null
UTF-8
C++
false
false
1,529
cpp
#include <iostream> #include <utility> #include <numeric> #include <pthread.h> using namespace std; typedef long long ll; int n; ll *arr; struct sum_struct { int startIndex; int endIndex; ll answer; }; void* sum(void* arg) { sum_struct* sum_arg = (sum_struct*)arg; int startIndex = sum_arg->startIndex; int endIndex = sum_arg->endIndex; if(endIndex - startIndex <= 10) { ll ans = 0; for(int i = startIndex; i <= endIndex; i++) ans += arr[i]; sum_arg->answer = ans; return NULL; } int mid = (startIndex + endIndex)/2; sum_struct left_sum_arg; left_sum_arg.startIndex = startIndex; left_sum_arg.endIndex = mid; sum_struct right_sum_arg; right_sum_arg.startIndex = mid+1; right_sum_arg.endIndex = endIndex; pthread_t left, right; pthread_create(&left, NULL, sum, (void*)&left_sum_arg); pthread_create(&right, NULL, sum, (void*)&right_sum_arg); pthread_join(left, NULL); pthread_join(right, NULL); sum_arg->answer = left_sum_arg.answer + right_sum_arg.answer; return NULL; } // parallel sum each thread dividing task into 2 different threads int main() { cout << "Enter Number of elements : "; cin >> n; cout << "Enter array elements : "; arr = new ll[n]; for (int i = 0; i < n; i++) cin >> arr[i]; sum_struct arg; arg.startIndex = 0; arg.endIndex = n-1; sum((void*)&arg); cout << "sum : " << arg.answer << endl; return 0; }
[ "yash23.agarwal@gmail.com" ]
yash23.agarwal@gmail.com
2f5587c0eb73a1dbbbe76741ddbd0314207c4f45
24b143ea43bb3a74b9c329c8a9a0ecd4ca71413c
/Serpinski challenges/serpinski 3_01/main.cpp
662063e45e1509764ed563620eabce16c9a0bf16
[]
no_license
xiaorine/Graphics-Programming
7bc1d3f607a648aa119d3434bd8be475fcfe1434
2eaffb782333b6f652cd6c470f14eedaefdca022
refs/heads/master
2021-12-28T09:14:16.110481
2013-01-16T23:31:38
2013-01-16T23:31:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,832
cpp
#pragma comment(lib, "GLFW") #pragma comment(lib, "OpenGL32") #include <GL\glfw.h> #include <glm\glm.hpp> #include <glm\gtc\matrix_transform.hpp> #include <glm\gtc\type_ptr.hpp> #include <glm\gtx\constants.hpp> #include "geometry.h" #include <cstdlib> bool running = true; render_object cube; render_object tetrahedron; geometry geom; void initialise() { glClearColor(0.0f, 1.0f, 1.0f, 1.0f); glm::mat4 projection = glm::perspective(10.0f, 800.0f/600.0f, 0.1f, 10000.0f); glMatrixMode(GL_PROJECTION); glLoadMatrixf(glm::value_ptr(projection)); glMatrixMode(GL_MODELVIEW); glEnable(GL_DEPTH_TEST); glEnable(GL_VERTEX_ARRAY); //geometry* geom = createBox();//call to create box //geometry* geom = createPyramid(); //geometry* geom = createTetrahedron(); //geometry* geom = createDisk(200); //geometry* geom = createCylinder(5, 10); //geometry* geom = createSphere(20, 20); //geometry* geom = createTorus(5.0f, 10, 30); //geometry* geom = createPlane(20, 20); geometry* geom = createSierpinski(5); cube.geometry = geom; cube.colour = glm::vec3(1.0f, 0.0f, 0.0f); cube.transform.position = glm::vec3(0.0f, 0.5f, 0.0f); } void update(double deltaTime) { //running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED); //cube.transform.rotate(-glm::pi<float>() / 400.0f, glm::vec3(0.0f, 0.0f, 1.0f)); //Self roation code //cube.transform.rotate(-glm::pi<float>() / 400.0f, glm::vec3(1.0f, 0.0f, 0.0f)); //cube.transform.rotate(glm::pi<float>() / 400.0f, glm::vec3(0.0f, 1.0f, 0.0f)); //manual rotation code if (glfwGetKey(GLFW_KEY_UP)) cube.transform.rotate(0.1f,glm::vec3(0.0, 0.0, 0.1)); if (glfwGetKey(GLFW_KEY_DOWN)) cube.transform.rotate(-0.1f,glm::vec3(0.1, 0.0, 0.1)); if (glfwGetKey(GLFW_KEY_LEFT)) cube.transform.rotate(-0.1f,glm::vec3(0.1, 0.0, 0.0)); if (glfwGetKey(GLFW_KEY_RIGHT)) cube.transform.rotate(0.1f,glm::vec3(0.1, 0.0, 0.0)); if (glfwGetKey('W')) cube.transform.rotate(0.1f, glm::vec3(0.0f, 0.1f, 0.0f)); if (glfwGetKey('S')) cube.transform.rotate(-0.1f, glm::vec3(0.0f, 0.1f, 0.0f)); } void render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glm::mat4 view = glm::lookAt(glm::vec3(10.0f, 10.0f, 10.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); glMatrixMode(GL_MODELVIEW); cube.render(view); glfwSwapBuffers(); } int main() { if (!glfwInit()) exit(EXIT_FAILURE); if (!glfwOpenWindow(800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) { glfwTerminate(); exit(EXIT_FAILURE); } initialise(); double prevTimeStamp = glfwGetTime(); double currentTimeStamp; while (running) { currentTimeStamp = glfwGetTime(); update(currentTimeStamp - prevTimeStamp); render(); prevTimeStamp = currentTimeStamp; } glfwTerminate(); exit(EXIT_SUCCESS); }
[ "10004794@napier.ac.uk" ]
10004794@napier.ac.uk
4add068c487baff7302a727264b819bddc447e3e
ff3683f5507e90cc04aef75fc467504e4a77c8fc
/pjsip_android/build/platforms/android-3/arch-arm/usr/include/media/AudioSystem.h
77c90ba7fc1fef4d31d6d29d9cb2e2cb0e398f4f
[]
no_license
zzjs2001702/csip
f23ecad4e17aedc5e12a71fbedc1001a48bcabc0
83d75fd556e4146d9df5a95b8e23587238637337
refs/heads/master
2021-12-30T07:43:11.356552
2013-02-02T19:35:14
2013-02-02T19:35:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,389
h
/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_AUDIOSYSTEM_H_ #define ANDROID_AUDIOSYSTEM_H_ #include <utils/RefBase.h> #include <utils/threads.h> #include <media/IAudioFlinger.h> namespace android { typedef void (*audio_error_callback)(status_t err); class AudioSystem { public: enum stream_type { DEFAULT =-1, VOICE_CALL = 0, SYSTEM = 1, RING = 2, MUSIC = 3, ALARM = 4, NOTIFICATION = 5, BLUETOOTH_SCO = 6, NUM_STREAM_TYPES }; enum audio_output_type { AUDIO_OUTPUT_DEFAULT =-1, AUDIO_OUTPUT_HARDWARE = 0, AUDIO_OUTPUT_A2DP = 1, NUM_AUDIO_OUTPUT_TYPES }; enum audio_format { FORMAT_DEFAULT = 0, PCM_16_BIT, PCM_8_BIT, INVALID_FORMAT }; enum audio_mode { MODE_INVALID = -2, MODE_CURRENT = -1, MODE_NORMAL = 0, MODE_RINGTONE, MODE_IN_CALL, NUM_MODES // not a valid entry, denotes end-of-list }; enum audio_routes { ROUTE_EARPIECE = (1 << 0), ROUTE_SPEAKER = (1 << 1), ROUTE_BLUETOOTH_SCO = (1 << 2), ROUTE_HEADSET = (1 << 3), ROUTE_BLUETOOTH_A2DP = (1 << 4), ROUTE_ALL = -1UL, }; enum audio_in_acoustics { AGC_ENABLE = 0x0001, AGC_DISABLE = 0, NS_ENABLE = 0x0002, NS_DISABLE = 0, TX_IIR_ENABLE = 0x0004, TX_DISABLE = 0 }; /* These are static methods to control the system-wide AudioFlinger * only privileged processes can have access to them */ // routing helper functions static status_t speakerphone(bool state); static status_t isSpeakerphoneOn(bool* state); static status_t bluetoothSco(bool state); static status_t isBluetoothScoOn(bool* state); static status_t muteMicrophone(bool state); static status_t isMicrophoneMuted(bool *state); static status_t setMasterVolume(float value); static status_t setMasterMute(bool mute); static status_t getMasterVolume(float* volume); static status_t getMasterMute(bool* mute); static status_t setStreamVolume(int stream, float value); static status_t setStreamMute(int stream, bool mute); static status_t getStreamVolume(int stream, float* volume); static status_t getStreamMute(int stream, bool* mute); static status_t setMode(int mode); static status_t getMode(int* mode); static status_t setRouting(int mode, uint32_t routes, uint32_t mask); static status_t getRouting(int mode, uint32_t* routes); static status_t isMusicActive(bool *state); // Temporary interface, do not use // TODO: Replace with a more generic key:value get/set mechanism static status_t setParameter(const char* key, const char* value); static void setErrorCallback(audio_error_callback cb); // helper function to obtain AudioFlinger service handle static const sp<IAudioFlinger>& get_audio_flinger(); static float linearToLog(int volume); static int logToLinear(float volume); static status_t getOutputSamplingRate(int* samplingRate, int stream = DEFAULT); static status_t getOutputFrameCount(int* frameCount, int stream = DEFAULT); static status_t getOutputLatency(uint32_t* latency, int stream = DEFAULT); static bool routedToA2dpOutput(int streamType); static status_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount, size_t* buffSize); // ---------------------------------------------------------------------------- private: class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient { public: AudioFlingerClient() { } // DeathRecipient virtual void binderDied(const wp<IBinder>& who); // IAudioFlingerClient virtual void a2dpEnabledChanged(bool enabled); }; static int getOutput(int streamType); static sp<AudioFlingerClient> gAudioFlingerClient; friend class AudioFlingerClient; static Mutex gLock; static sp<IAudioFlinger> gAudioFlinger; static audio_error_callback gAudioErrorCallback; static int gOutSamplingRate[NUM_AUDIO_OUTPUT_TYPES]; static int gOutFrameCount[NUM_AUDIO_OUTPUT_TYPES]; static uint32_t gOutLatency[NUM_AUDIO_OUTPUT_TYPES]; static bool gA2dpEnabled; static size_t gInBuffSize; // previous parameters for recording buffer size queries static uint32_t gPrevInSamplingRate; static int gPrevInFormat; static int gPrevInChannelCount; }; }; // namespace android #endif /*ANDROID_AUDIOSYSTEM_H_*/
[ "r3gis3r@9f815046-5998-e9c0-b7e2-ac03a23edfa4" ]
r3gis3r@9f815046-5998-e9c0-b7e2-ac03a23edfa4
1d4f4d0cc45c957d1f2deac425720308b4f8f8b2
73b8d67dcf86c4aaa8b005e4f270c62c60c2cdba
/Combinatorics/排列的逆序.cpp
cb788973c12cdcdc432422d489ed2f8e2e8ed89b
[]
no_license
DaDaMrX/Sophomore
822b750c8bff0490a7f200facd907e8e854ccaaa
bf724064f6a3ca107c0f950042d681f265b00a2f
refs/heads/master
2021-01-12T04:34:24.793104
2017-04-02T11:33:18
2017-04-02T11:33:18
83,888,762
2
2
null
null
null
null
UTF-8
C++
false
false
601
cpp
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; const int N = 15; int a[N], b[N]; int main() { int T; scanf("%d", &T); while (T--) { int n; ll k; scanf("%d%lld", &n, &k); k--; for (int i = 1; i <= n; i++) { b[n + 1 - i] = k % i; k /= i; } memset(a, 0, sizeof(a)); for (int i = 1; i <= n; i++) { int j = 0, s = 0; while (s <= b[i]) { j++; if (a[j] == 0) s++; } a[j] = i; } for (int i = 1; i < n; i++) printf("%d ", a[i]); printf("%d\n", a[n]); } return 0; }
[ "dadamrxx@gmail.com" ]
dadamrxx@gmail.com
3bd86ff317413bcd0786f4b5352373e6245f56a7
83552346a7d778e88569fdc16d686576836a1977
/Plan/main.cpp
0732972378ade10c53ec99576a6e85ad0bac7b55
[]
no_license
Berezowski-Dominik/Plan_generator
75baddb2a4aadf6543e64b6fdef70889a683419f
66edc08eb6c5428bf733f77b3e8e4f3400c6e225
refs/heads/master
2023-08-22T22:58:06.735671
2021-10-10T19:00:07
2021-10-10T19:00:07
415,674,221
0
0
null
null
null
null
UTF-8
C++
false
false
66,307
cpp
#include <stdio.h> #include <iostream> #include <vector> #include <fstream> #include <sstream> #include <cmath> #include <map> #include <cmath> #include <set> #include <ctime> #include <algorithm> #include <sys/stat.h> #include "Przedmiot.h" #include "Nauczyciel.h" #include "Nad_grupa.h" #include "Grupa.h" #include "Zajecia.h" #include "Sala.h" using namespace std; int Wczytanie_Przedmiotow(vector<vector<Przedmiot>>&Przedmioty_Lab,vector<vector<Przedmiot>>&Przedmioty_Cw,vector<vector<Przedmiot>>&Przedmioty_Wykl); int Wczytanie_Nauczycieli(vector < Nauczyciel> &Nauczyciele); void Wczytanie_Grup(vector <vector<Nad_grupa>> &Grupy_Wyk, vector <vector<Nad_grupa>> &Grupy_Cw, vector<vector<Grupa>> &Grupy_Lab); void Wczytanie_Sal(vector <Sala> &Sala_Wykl,vector <Sala> &Sala_Cw,vector <Sala> &Sala_Lab); int Czy_istnieje_plik(const char* nazwa_pliku); void Podzial_nauczycieli_i_przedmiotow(); void Dop_godz_nauczycieli(vector < Nauczyciel> &Nauczyciele); void Niedop_godz_nauczycieli(vector < Nauczyciel> &Nauczyciele); void Grup_Wyk_Podz(vector <vector<Nad_grupa>> &Grupy_Wyk,vector <vector<Grupa>> &Grupy_Lab,vector <vector<Nad_grupa>> &Grupy_Cw); void Grup_Cw_Podz(vector<vector<Nad_grupa>> &Grupy_Cw, vector <vector<Grupa>> &Grupy_Lab); void Wczytanie_nauczycieli_wykladow(vector <vector<Przedmiot>> &Przedmioty_Wykl,vector <Nauczyciel> &Nauczyciele); void Wczytanie_nauczycieli_cwiczen(vector <vector<Przedmiot>> &Przedmioty_Cw,vector < Nauczyciel> &Nauczyciele); void Wczytanie_nauczycieli_laborek(vector <vector<Przedmiot>> &Przedmioty_Lab,vector < Nauczyciel> &Nauczyciele); void Zajecia_wykladowe(vector <Zajecia> &Zajecie,vector<vector<Przedmiot>> &Przedmioty_Wykl,vector <vector<Nad_grupa>> &Grupy_Wyk,vector<Sala> &Sala_Wykl,int &il_wykl); void Zajecia_cwiczeniowe(vector <Zajecia> &Zajecie,vector<vector<Przedmiot>> &Przedmioty_Cw,vector <vector<Nad_grupa>> &Grupy_Cw,vector<Sala> &Sala_Cw, int &il_wykl_i_cw); void Zajecia_laborki(vector <Zajecia> &Zajecie,vector <vector<Przedmiot>> &Przedmioty_Lab,vector <vector<Grupa>> &Grupy_Lab,vector<Sala> &Sala_Lab); void Zajecia_nauczyciele(vector<Zajecia> &Zajecie,vector<Nauczyciel> &Nauczyciele,int il_wykl,int il_wykl_i_cw); void Tworzenie_harmonogramu(vector <Zajecia> &Zajecie); void Wypisanie_danych_harmonogramu(vector <Zajecia> &Zajecie,vector <vector<Grupa>> &Grupy_Lab, vector <Nauczyciel> &Nauczyciele); float Kara_laczna_grup(vector<vector<Grupa>> &Grupy_Lab); float Kara_laczna_nauczycieli(vector <Nauczyciel> &Nauczyciele); float Ogolna_kara_planu(vector <vector<Grupa>> &Grupy_Lab,vector <Nauczyciel> &Nauczyciele); void Poprawianie_grupy(vector <Zajecia> &Zajecie,vector <float>::iterator &it, vector <float> &kara_grupy, vector <Grupa*> &Grupy_Lab, int &najg_grupa); void Poprawianie_nauczycieli(vector <Zajecia> &Zajecie,vector <float>::iterator &it, vector <float> &kara_nauczy, vector <Nauczyciel> &Nauczyciele, int &najg_nauczy); void Poprawianie_harmonogramu(vector <Zajecia> &Zajecie,vector <vector<Grupa>> &Grupy_Lab,vector <Nauczyciel> &Nauczyciele, vector <Sala> Sala_Lab, int ile_popraw); void Wypisywanie_planow_grup(vector <vector<Grupa>> &Grupy_Lab,vector <Zajecia> &Zajecie_Naj); void Wypisywanie_planow_nauczycieli(vector <Nauczyciel> &Nauczyciele_Naj,vector <Zajecia> &Zajecie_Naj); int main(int argc, char **argv) { srand(time(NULL)); fstream plik; vector<vector<Przedmiot>>Przedmioty_Lab; vector<vector<Przedmiot>>Przedmioty_Cw; vector<vector<Przedmiot>>Przedmioty_Wykl; vector<vector<Grupa>>Grupy_Lab; vector<vector<Nad_grupa>>Grupy_Cw; vector<vector<Nad_grupa>>Grupy_Wykl; vector <Sala> Sala_Wykl; vector <Sala> Sala_Cw; vector <Sala> Sala_Lab; vector <Zajecia> Zajecie; vector<Nauczyciel>Nauczyciele; int il_wykl = 0; int il_wykl_i_cw = 0; if(Czy_istnieje_plik("wyklady_nauczyciele.csv") == 0) { cout << "Brak koniecznych pilkow do stworzenia planiu !!!" << endl; cout << "Uzupelnij stworzone plik w katalogu programu: " << endl; cout << "wyklady_nauczyciele.csv,cwiczenia_nauczyciele.csv,laborki_nauczyciele.csv" << endl; Podzial_nauczycieli_i_przedmiotow(); } else if(Czy_istnieje_plik("wyklady_nauczyciele.csv") != 0) { Wczytanie_Przedmiotow(Przedmioty_Lab,Przedmioty_Cw,Przedmioty_Wykl); Wczytanie_Nauczycieli(Nauczyciele); Wczytanie_Grup(Grupy_Wykl,Grupy_Cw,Grupy_Lab); Wczytanie_Sal(Sala_Wykl,Sala_Cw,Sala_Lab); Grup_Wyk_Podz(Grupy_Wykl,Grupy_Lab,Grupy_Cw); Grup_Cw_Podz(Grupy_Cw,Grupy_Lab); Wczytanie_nauczycieli_wykladow(Przedmioty_Wykl,Nauczyciele); Wczytanie_nauczycieli_cwiczen(Przedmioty_Cw,Nauczyciele); Wczytanie_nauczycieli_laborek(Przedmioty_Lab,Nauczyciele); Zajecia_wykladowe(Zajecie,Przedmioty_Wykl,Grupy_Wykl,Sala_Wykl,il_wykl); Zajecia_cwiczeniowe(Zajecie,Przedmioty_Cw,Grupy_Cw,Sala_Cw,il_wykl_i_cw); Zajecia_laborki(Zajecie,Przedmioty_Lab,Grupy_Lab,Sala_Lab); Zajecia_nauczyciele(Zajecie,Nauczyciele,il_wykl,il_wykl_i_cw); Tworzenie_harmonogramu(Zajecie); Poprawianie_harmonogramu(Zajecie,Grupy_Lab,Nauczyciele,Sala_Lab,10); cout <<"Kara najlepszego rozwiazania wynosi: " << Ogolna_kara_planu(Grupy_Lab,Nauczyciele) << endl; Wypisywanie_planow_grup(Grupy_Lab,Zajecie); Wypisywanie_planow_nauczycieli(Nauczyciele,Zajecie); } return 0; } void Wypisywanie_planow_nauczycieli(vector <Nauczyciel> &Nauczyciele,vector <Zajecia> &Zajecie) { int ilosc_nauczycieli = Nauczyciele.size(); string nazwa_pliku; ofstream plik; nazwa_pliku.append("plany_nauczycieli.csv"); plik.open(nazwa_pliku,ios::out); string do_pliku; for(int i = 0; i < ilosc_nauczycieli; i++) { do_pliku.append(Nauczyciele[i].Zwroc_imie_i_nazwisko()); do_pliku.append("\n"); for(int j = 0; j < 4; j++) { for(int k = 0; k < 20; k+=4) { if(Nauczyciele[i].Numer_zajecia(k+j) != 0) { do_pliku.append(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].przedmiot()->Zwroc_nazwe()); do_pliku.append(" "); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].sala()->Zwroc_numer())); do_pliku.append(" "); if(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].nad_grupa() == NULL) { do_pliku.append(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].grupa()->Zwroc_kierunek()); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].grupa()->Zwroc_stopien())); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].grupa()->Zwroc_rocznik())); do_pliku.append(to_string(3)); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].grupa()->Zwroc_numer())); } if(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].nad_grupa() != NULL) { do_pliku.append(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].nad_grupa()->grupa_lab(0)->Zwroc_kierunek()); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].nad_grupa()->grupa_lab(0)->Zwroc_stopien())); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].nad_grupa()->grupa_lab(0)->Zwroc_rocznik())); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].nad_grupa()->Zwroc_rodzaj())); do_pliku.append(to_string(Zajecie[Nauczyciele[i].Numer_zajecia(k+j)-1].nad_grupa()->Zwroc_numer_grupy())); } do_pliku.append(","); } else { do_pliku.append("Wolne,"); } } do_pliku.append("\n"); plik << do_pliku; do_pliku.clear(); } do_pliku.append("\n"); } plik.close(); } void Wypisywanie_planow_grup(vector <vector<Grupa>> &Grupy_Lab,vector <Zajecia> &Zajecie) { int ilosc_zbiorow_grup = Grupy_Lab.size(); int ilosc_grup = 0; string nazwa_pliku; ofstream plik; for(int l = 0; l < ilosc_zbiorow_grup; l++) { nazwa_pliku.append(Grupy_Lab[l][0].Zwroc_kierunek()); nazwa_pliku.append(to_string(Grupy_Lab[l][0].Zwroc_stopien())); nazwa_pliku.append(to_string(Grupy_Lab[l][0].Zwroc_rocznik())); nazwa_pliku.append(".csv"); plik.open(nazwa_pliku,ios::out); nazwa_pliku.clear(); string do_pliku; ilosc_grup = Grupy_Lab[l].size(); for(int i = 0; i < ilosc_grup; i++) { do_pliku.append("Grupa"); do_pliku.append(to_string(Grupy_Lab[l][i].Zwroc_numer())); do_pliku.append("\n"); for(int j = 0; j < 4; j++) { for(int k = 0; k < 20; k+=4) { if(Grupy_Lab[l][i].Zwroc_numer_zaj(k+j) != 0) { do_pliku.append(Zajecie[Grupy_Lab[l][i].Zwroc_numer_zaj(k+j)-1].przedmiot()->Zwroc_nazwe()); do_pliku.append(" "); do_pliku.append(Zajecie[Grupy_Lab[l][i].Zwroc_numer_zaj(k+j)-1].Zwroc_imie_i_nazwisko_nauczyciela()); do_pliku.append(" "); do_pliku.append(to_string(Zajecie[Grupy_Lab[l][i].Zwroc_numer_zaj(k+j)-1].sala()->Zwroc_numer())); do_pliku.append(","); } else { do_pliku.append("Wolne,"); } } do_pliku.append("\n"); plik << do_pliku; do_pliku.clear(); } do_pliku.append("\n"); } plik.close(); } } void Podzial_nauczycieli_i_przedmiotow() { vector<Nauczyciel> nauczyciele; vector<vector<Przedmiot>> przedmioty_lab; vector<vector<Przedmiot>> przedmioty_cw; vector<vector<Przedmiot>> przedmioty_wykl; vector<vector<Grupa>> grupy_lab; vector<vector<Nad_grupa>> grupy_cw; vector<vector<Nad_grupa>> grupy_wykl; Wczytanie_Nauczycieli(nauczyciele); Wczytanie_Przedmiotow(przedmioty_lab,przedmioty_cw,przedmioty_wykl); Wczytanie_Grup(grupy_wykl,grupy_cw,grupy_lab); int ilosc_zbiorow_wykladow = przedmioty_wykl.size(); int ilosc_zbiorow_cwiczen = przedmioty_cw.size(); int ilosc_zbiorow_laborek = przedmioty_lab.size(); int ilosc_nauczycieli = nauczyciele.size(); int ilosc_wykladow = 0; int ilosc_cwiczen = 0; int ilosc_laborek = 0; ofstream plik; plik.open("wyklady_nauczyciele.csv",ios::out); for(int i = 0; i < ilosc_zbiorow_wykladow; i++) { ilosc_wykladow = przedmioty_wykl[i].size(); for(int j = 0; j < ilosc_wykladow; j++) { plik << ","; plik << przedmioty_wykl[i][j].Zwroc_nazwe(); } plik << ",Ilosc grup-"; plik << grupy_wykl[i].size(); plik << ","; } plik << "\n"; for(int i = 0; i < ilosc_nauczycieli; i++) { plik << nauczyciele[i].Zwroc_imie_i_nazwisko(); plik << ",\n"; } plik.close(); plik.open("cwiczenia_nauczyciele.csv",ios::out); for(int i = 0; i < ilosc_zbiorow_cwiczen; i++) { ilosc_cwiczen = przedmioty_cw[i].size(); for(int j = 0; j < ilosc_cwiczen; j++) { plik << ","; plik << przedmioty_cw[i][j].Zwroc_nazwe(); } plik << ",Ilosc grup-"; plik << grupy_cw[i].size(); plik << ","; } plik << "\n"; for(int i = 0; i < ilosc_nauczycieli; i++) { plik << nauczyciele[i].Zwroc_imie_i_nazwisko(); plik << ",\n"; } plik.close(); plik.open("laborki_nauczyciele.csv",ios::out); for(int i = 0; i < ilosc_zbiorow_laborek; i++) { ilosc_laborek = przedmioty_lab[i].size(); for(int j = 0; j < ilosc_laborek; j++) { plik << ","; plik << przedmioty_lab[i][j].Zwroc_nazwe(); } plik << ",Ilosc grup-"; plik << grupy_lab[i].size(); plik << ","; } plik << "\n"; for(int i = 0; i < ilosc_nauczycieli; i++) { plik << nauczyciele[i].Zwroc_imie_i_nazwisko(); plik << ",\n"; } plik.close(); } float Ogolna_kara_planu(vector <vector<Grupa>> &Grupy_Lab,vector <Nauczyciel> &Nauczyciele) { return Kara_laczna_grup(Grupy_Lab) + Kara_laczna_nauczycieli(Nauczyciele); } void Poprawianie_nauczycieli(vector <Zajecia> &Zajecie,vector <float>::iterator &it, vector <float> &kara_nauczy, vector <Nauczyciel> &Nauczyciele, int &najg_nauczy) { vector <int> pozyc_labek; vector <int> sprawdz_nauczy; int labki = 0; int ile_spraw_naucz = 0; int i = 0; while(i == 0) { int ilosc_labek = Nauczyciele[najg_nauczy].Ile_lab_w_planie(); for(int i = 0; i < ilosc_labek; i++) { pozyc_labek.push_back(Nauczyciele[najg_nauczy].Termin_labek(i)); } ilosc_labek++; pozyc_labek.push_back(20); labki = ilosc_labek-1; do { pozyc_labek.erase(pozyc_labek.begin()+labki); ilosc_labek--; labki = rand() % ilosc_labek; }while((!Zajecie[Nauczyciele[najg_nauczy].Numer_zajecia(pozyc_labek[labki])-1].Mozliwosc_zmiany()) || (ilosc_labek == 0)); if(ilosc_labek == 0) { i--; kara_nauczy[najg_nauczy] = 0; sprawdz_nauczy.push_back(najg_nauczy); it = max_element(kara_nauczy.begin(),kara_nauczy.end()); najg_nauczy = distance(kara_nauczy.begin(), it); } else { Zajecie[Nauczyciele[najg_nauczy].Numer_zajecia(pozyc_labek[labki])-1].Zmiana_terminu(); kara_nauczy[najg_nauczy] = Nauczyciele[najg_nauczy].Zwroc_kare(); ile_spraw_naucz = sprawdz_nauczy.size(); for(int i = 0; i < ile_spraw_naucz; i++) { kara_nauczy[sprawdz_nauczy[i]] = Nauczyciele[sprawdz_nauczy[i]].Zwroc_kare(); } } sprawdz_nauczy.clear(); pozyc_labek.clear(); it = max_element(kara_nauczy.begin(),kara_nauczy.end()); najg_nauczy = distance(kara_nauczy.begin(), it); i++; } } void Poprawianie_grupy(vector <Zajecia> &Zajecie,vector <float>::iterator &it, vector <float> &kara_grupy, vector <Grupa*> &Grupy_Lab,int &najg_grupa) { vector <int> pozyc_labek; vector <int> sprawdzone_grupy; int labki = 0; int ile_spraw_grup = 0; int i = 0; while(i == 0) { int ilosc_labek = Grupy_Lab[najg_grupa]->Ile_lab_w_planie(); for(int i = 0; i < ilosc_labek; i++) { pozyc_labek.push_back(Grupy_Lab[najg_grupa]->Termin_labek(i)); } ilosc_labek++; pozyc_labek.push_back(20); labki = ilosc_labek-1; do { pozyc_labek.erase(pozyc_labek.begin()+labki); ilosc_labek--; labki = rand() % ilosc_labek; }while((!Zajecie[Grupy_Lab[najg_grupa]->Zwroc_numer_zaj(pozyc_labek[labki])-1].Mozliwosc_zmiany()) || (ilosc_labek == 0)); if(ilosc_labek == 0) { i--; kara_grupy[najg_grupa] = 0; sprawdzone_grupy.push_back(najg_grupa); it = max_element(kara_grupy.begin(),kara_grupy.end()); najg_grupa = distance(kara_grupy.begin(), it); } else { Zajecie[Grupy_Lab[najg_grupa]->Zwroc_numer_zaj(pozyc_labek[labki])-1].Zmiana_terminu(); kara_grupy[najg_grupa] = Grupy_Lab[najg_grupa]->Zwroc_kare(); ile_spraw_grup = sprawdzone_grupy.size(); for(int i = 0; i < ile_spraw_grup; i++) { kara_grupy[sprawdzone_grupy[i]] = Grupy_Lab[sprawdzone_grupy[i]]->Zwroc_kare(); } } sprawdzone_grupy.clear(); pozyc_labek.clear(); it = max_element(kara_grupy.begin(),kara_grupy.end()); najg_grupa = distance(kara_grupy.begin(), it); i++; } } float Kara_laczna_grup(vector<vector<Grupa>> &Grupy_Lab) { int ilosc_zbiorow_grup = Grupy_Lab.size(); float suma_kar = 0; for(int j = 0; j < ilosc_zbiorow_grup;j++) { int ilosc_grup = Grupy_Lab[j].size(); for(int i = 0; i < ilosc_grup; i++) { suma_kar += Grupy_Lab[j][i].Oblicz_kare(); } } return suma_kar; } float Kara_laczna_nauczycieli(vector < Nauczyciel> &Nauczyciele) { int ilosc_nauczycieli = Nauczyciele.size(); float suma_kar = 0; for(int i = 0; i < ilosc_nauczycieli; i++) { suma_kar += Nauczyciele[i].Oblicz_kare(); } return suma_kar; } void Grup_Cw_Podz(vector <Nad_grupa> &Grupy_Cw, vector <Grupa> &Grupy_Lab,vector <Nad_grupa> &Grupy_Wyk) { int Wszystkie_gr_lab = Grupy_Lab.size(); float nie_przydzielone_gr_lab = Grupy_Lab.size(); int ilosc_gr_do_stworzenia = Grupy_Cw.size(); float wielkosc_nowa_gr_cwiczeniowa = 0; for (int i = ilosc_gr_do_stworzenia; i > 0; i--) { wielkosc_nowa_gr_cwiczeniowa = round(nie_przydzielone_gr_lab / i); for(int j = 0; j < wielkosc_nowa_gr_cwiczeniowa; j++) { Grupy_Cw[ilosc_gr_do_stworzenia - i].grupa_lab()->push_back(&Grupy_Lab[j + Wszystkie_gr_lab - nie_przydzielone_gr_lab]); } nie_przydzielone_gr_lab -= wielkosc_nowa_gr_cwiczeniowa; } } int Wczytanie_Nauczycieli(vector < Nauczyciel> &Nauczyciele) { fstream plik; plik.open("nauczyciele.csv", ios::in | ios::out); if(plik.is_open()) { cout << "Poprawne otwarcie pliku z nauczycielami" << endl; string linia; string czesc; vector <string> dane; int i = 0; while(!plik.eof()) { plik >> linia; if(linia == ";") { break; return 1; } else { if(linia == "") cout << "Blad w wierszu " << i << endl; else Nauczyciele.push_back({linia}); } i++; } plik.close(); } else cout<<"Nie udało się otworzyć pliku z nauczycielami"; return 1; } void Dop_godz_nauczycieli(vector < Nauczyciel> &Nauczyciele) { fstream plik; plik.open("dop_term_nauczycieli.csv", ios::in | ios::out); int numer = 0; if(plik.is_open()) { cout << "Plik z dopuszczalnymi terminami nauczycieli otwarty" << endl << endl; string linia; string czesc; vector <string> dane; int ile_godzin = 0; while(!plik.eof()) { plik >> linia; if(linia == ";") break; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] == "") { dane.erase(dane.begin(), dane.end()); numer++; continue; } else if(dane[0] != "") { ile_godzin = dane.size(); for(int i = 0; i < ile_godzin; i++) { Nauczyciele[numer].Dodanie_dop_terminu(stoi(dane[i])-1); } dane.erase(dane.begin(), dane.end()); numer++; } } plik.close(); } else cout<<"Nie udało się otworzyć pliku z dopuszczalnymi terminami nauczycieli"; } void Niedop_godz_nauczycieli(vector < Nauczyciel> &Nauczyciele) { fstream plik; plik.open("niedop_term_nauczycieli.csv", ios::in | ios::out); int numer = 0; if(plik.is_open()) { cout << "Plik z niedopuszczalnymi terminami nauczycieli otwarty" << endl << endl; string linia; string czesc; vector <string> dane; int ile_godzin = 0; while(!plik.eof()) { plik >> linia; if(linia == ";") break; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] == "") { dane.erase(dane.begin(), dane.end()); numer++; continue; } else if(dane[0] != "") { ile_godzin = dane.size(); for(int i = 0; i < ile_godzin; i++) { Nauczyciele[numer].Dodanie_niedos_terminu(stoi(dane[i])-1); Nauczyciele[numer].Dodanie_zaj_terminu(stoi(dane[i])-1); } dane.erase(dane.begin(), dane.end()); numer++; } } plik.close(); } else cout<<"Nie udało się otworzyć pliku z niedopuszczalnymi terminami nauczycieli"; } int Wczytanie_Przedmiotow(vector<vector<Przedmiot>>&Przedmioty_Lab,vector<vector<Przedmiot>>&Przedmioty_Cw,vector<vector<Przedmiot>>&Przedmioty_Wykl) { string linia; string czesc; vector <string> dane; int numer_wyk = 0; int numer_cw = 0; int numer_lab = 0; int przedmioty = 0; int numer_wiersza = 1; Przedmioty_Wykl.push_back(vector<Przedmiot>()); Przedmioty_Cw.push_back(vector<Przedmiot>()); Przedmioty_Lab.push_back(vector<Przedmiot>()); fstream plik; plik.open("przedmioty.csv", ios::in | ios::out); if(plik.is_open()) { cout << "Poprawne otwarcie pliku z przedmiotami" << endl; while(!plik.eof()) { plik >> linia; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] == "" && dane[1] == "") { Przedmioty_Wykl.push_back(vector<Przedmiot>()); Przedmioty_Cw.push_back(vector<Przedmiot>()); Przedmioty_Lab.push_back(vector<Przedmiot>()); przedmioty++; } else if(dane[0] == ";") { break; return 1; } else { if(dane[0] == "") {cout << "Brak nazwy przedmiotu w wierszu " << numer_wiersza << endl; return 0;} if((dane[1] == "") || ((dane[1] != "1") && (dane[1] != "2") && (dane[1] != "3"))) {cout << "Bledna wartosc w 2 kolumnie wiersza " << numer_wiersza << endl; return 0;} if((dane[2] == "") || ((dane[2] != "1") && (dane[2] != "2"))) {cout << "Bledna wartosc w 3 kolumnie wiersza " << numer_wiersza << endl; return 0;} if(stoi(dane[1]) == 1) { Przedmioty_Wykl[przedmioty].push_back({dane[0],stoi(dane[1]),stoi(dane[2]),numer_wyk}); numer_wyk++; } else if(stoi(dane[1]) == 2) { Przedmioty_Cw[przedmioty].push_back({dane[0],stoi(dane[1]),stoi(dane[2]),numer_cw}); numer_cw++; } else if(stoi(dane[1]) == 3) { Przedmioty_Lab[przedmioty].push_back({dane[0],stoi(dane[1]),stoi(dane[2]),numer_lab}); numer_lab++; } } numer_wiersza++; dane.erase(dane.begin(), dane.end()); } plik.close(); } else cout<<"Nie udało się otworzyć pliku z przedmiotami"; return 1; } int Czy_istnieje_plik(const char* nazwa_pliku) { struct stat bufor; if (stat(nazwa_pliku,&bufor) == 0) return 1; else return 0; } void Wczytanie_Grup(vector<vector<Nad_grupa>>&Grupy_Wyk, vector<vector<Nad_grupa>>&Grupy_Cw, vector<vector<Grupa>>&Grupy_Lab) { string linia; string czesc; vector <string> dane; int zbior_grup = 0; int j = 0; fstream plik; plik.open("grupy.csv", ios::in | ios::out); if(plik.is_open()) { while(!plik.eof()) { plik >> linia; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] != "" && dane[0] != ";") { Grupy_Wyk.push_back(vector<Nad_grupa>()); Grupy_Cw.push_back(vector<Nad_grupa>()); Grupy_Lab.push_back(vector<Grupa>()); if(dane[1] == "" || dane[2] == "" || dane[3] == "" || dane[4] == "" || dane[5] == "") cout << "Blad w wierszu " << j << endl; else { for(int i = 0; i < stoi(dane[3]); i++) { Grupy_Wyk[zbior_grup].push_back({1,i+1}); } for(int i = 0; i < stoi(dane[4]); i++) { Grupy_Cw[zbior_grup].push_back({2,i+1}); } for(int i = 0; i < stoi(dane[5]); i++) { Grupy_Lab[zbior_grup].push_back({dane[0],stoi(dane[1]),stoi(dane[2]),i+1}); } zbior_grup++; } } else if(dane[0] == ";") { break; } j++; dane.erase(dane.begin(), dane.end()); } plik.close(); } else cout<<"Nie udało się otworzyć pliku z przedmiotami"; } void Wczytanie_Sal(vector <Sala> &Sala_Wykl,vector <Sala> &Sala_Cw,vector <Sala> &Sala_Lab) { fstream plik; plik.open("sale.csv", ios::in | ios::out); if(plik.is_open()) { string linia; string czesc; vector <string> dane; while(!plik.eof()) { plik >> linia; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] != "" && dane[0] != ";") { if(stoi(dane[0]) == 1) { for(int i = 0; i < stoi(dane[1]); i++) { if(dane[2+i] == "") { cout << "Brak numeru sali wykladowej" << endl; } else { Sala_Wykl.push_back({stoi(dane[2+i])}); } } } else if(stoi(dane[0]) == 2) { for(int i = 0; i < stoi(dane[1]); i++) { if(dane[2+i] == "") { cout << "Brak numeru sali cwiczeniowej" << endl; } else { Sala_Cw.push_back({stoi(dane[2+i])}); } } } else if(stoi(dane[0]) == 3) { for(int i = 0; i < stoi(dane[1]); i++) { if(dane[2+i] == "") { cout << "Brak numeru sali laboratoryjnej" << endl; } else { Sala_Lab.push_back({stoi(dane[2+i])}); } } } } else if(dane[0] == ";") { break; } dane.erase(dane.begin(), dane.end()); } plik.close(); } else cout<<"Nie udało się otworzyć pliku z salami"; } void Grup_Wyk_Podz(vector<vector<Nad_grupa>> &Grupy_Wyk,vector<vector<Grupa>> &Grupy_Lab,vector <vector<Nad_grupa>> &Grupy_Cw) { int ilosc_rocznikow = Grupy_Wyk.size(); for(int k = 0; k < ilosc_rocznikow; k++) { int Wszystkie_gr_lab = Grupy_Lab[k].size(); int nie_przydzielone_gr_lab = Grupy_Lab[k].size(); int Wszystkie_gr_cw = Grupy_Cw[k].size(); int nie_przydzielone_gr_cw = Grupy_Cw[k].size(); int ilosc_gr_do_stworzenia = Grupy_Wyk[k].size(); int wielkosc_nowa_gr_wykladowa = 0; for (int i = ilosc_gr_do_stworzenia; i > 0; i--) { wielkosc_nowa_gr_wykladowa = round(nie_przydzielone_gr_cw / i); for(int j = 0; j < wielkosc_nowa_gr_wykladowa; j++) { Grupy_Wyk[k][ilosc_gr_do_stworzenia - i].grupa_cw()->push_back(&Grupy_Cw[k][j + Wszystkie_gr_cw - nie_przydzielone_gr_cw]); } nie_przydzielone_gr_cw -= wielkosc_nowa_gr_wykladowa; } for (int i = ilosc_gr_do_stworzenia; i > 0; i--) { wielkosc_nowa_gr_wykladowa = round(nie_przydzielone_gr_lab / i); for(int j = 0; j < wielkosc_nowa_gr_wykladowa; j++) { Grupy_Wyk[k][ilosc_gr_do_stworzenia - i].grupa_lab()->push_back(&Grupy_Lab[k][j + Wszystkie_gr_lab - nie_przydzielone_gr_lab]); } nie_przydzielone_gr_lab -= wielkosc_nowa_gr_wykladowa; } } } void Grup_Cw_Podz(vector<vector<Nad_grupa>> &Grupy_Cw, vector <vector<Grupa>> &Grupy_Lab) { int ilosc_rocznikow = Grupy_Cw.size(); for(int k = 0; k < ilosc_rocznikow; k++) { int Wszystkie_gr_lab = Grupy_Lab[k].size(); float nie_przydzielone_gr_lab = Grupy_Lab[k].size(); int ilosc_gr_do_stworzenia = Grupy_Cw[k].size(); float wielkosc_nowa_gr_cwiczeniowa = 0; for (int i = ilosc_gr_do_stworzenia; i > 0; i--) { wielkosc_nowa_gr_cwiczeniowa = round(nie_przydzielone_gr_lab / i); for(int j = 0; j < wielkosc_nowa_gr_cwiczeniowa; j++) { Grupy_Cw[k][ilosc_gr_do_stworzenia - i].grupa_lab()->push_back(&Grupy_Lab[k][j + Wszystkie_gr_lab - nie_przydzielone_gr_lab]); } nie_przydzielone_gr_lab -= wielkosc_nowa_gr_cwiczeniowa; } } } void Wczytanie_nauczycieli_wykladow(vector <vector<Przedmiot>> &Przedmioty_Wykl,vector <Nauczyciel> &Nauczyciele) { fstream plik; plik.open("wyklady_nauczyciele.csv", ios::in | ios::out); if(plik.is_open()) { cout << "Plik z nauczycielami wykladow otwarty" << endl << endl; string linia; string czesc; int numer_nauczyciela = 0; int numer_wykladu = 0; int ile_wykladow = 0; int ile_wykl_wcze = 0; vector <string> dane; int il_zbiorow_wykladow = Przedmioty_Wykl.size(); while(!plik.eof()) { plik >> linia; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] != "" && dane[0] != ";") { numer_wykladu = 0; ile_wykladow = Przedmioty_Wykl[0].size(); ile_wykl_wcze = 0; for(int j = 0; j < il_zbiorow_wykladow;j++) { for(int i = numer_wykladu; i < ile_wykladow; i++) { if(stoi(dane[i]) != 0) { Nauczyciele[numer_nauczyciela].Godziny_wykl(i,stoi(dane[i])); Przedmioty_Wykl[j][i-ile_wykl_wcze].Dodaj_nauczyciela(numer_nauczyciela); } else if(stoi(dane[i]) == "") { cout << "Blad w pliku nauczyciele_wykladow wiersz " << numer_nauczyciela << endl; } numer_wykladu++; } ile_wykl_wcze = ile_wykladow; ile_wykladow += Przedmioty_Wykl[j+1].size(); } } else if(dane[0] == ";") { break; } dane.erase(dane.begin(), dane.end()); numer_nauczyciela++; } plik.close(); } else cout<<"Nie udało się otworzyć pliku z nauczycielami wykladow przedmiotow"; } void Wczytanie_nauczycieli_cwiczen(vector<vector<Przedmiot>> &Przedmioty_Cw,vector <Nauczyciel> &Nauczyciele) { fstream plik; plik.open("cwiczenia_nauczyciele.csv", ios::in | ios::out); if(plik.is_open()) { cout << "Plik z nauczycielami cwiczeniami otwarty" << endl << endl; string linia; string czesc; int numer_nauczyciela = 0; int numer_cwiczenia = 0; int ile_cwiczen = 0; int ile_cw_wcze = 0; vector <string> dane; int il_zbiorow_cwiczen = Przedmioty_Cw.size(); while(!plik.eof()) { plik >> linia; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] != "" && dane[0] != ";") { numer_cwiczenia = 0; ile_cwiczen = Przedmioty_Cw[0].size(); ile_cw_wcze = 0; for(int j = 0; j < il_zbiorow_cwiczen;j++) { for(int i = numer_cwiczenia; i < ile_cwiczen; i++) { if(stoi(dane[i]) != 0) { Nauczyciele[numer_nauczyciela].Godziny_cw(i,stoi(dane[i])); Przedmioty_Cw[j][i-ile_cw_wcze].Dodaj_nauczyciela(numer_nauczyciela); } else if(stoi(dane[i]) == "") { cout << "Blad w pliku nauczyciele_cwiczen wiersz:" << numer_nauczyciela << endl; } numer_cwiczenia++; } ile_cw_wcze = ile_cwiczen; ile_cwiczen += Przedmioty_Cw[j+1].size(); } } else if(dane[0] == ";") { break; } dane.erase(dane.begin(), dane.end()); numer_nauczyciela++; } plik.close(); } else cout<<"Nie udało się otworzyć pliku z nauczycielami cwiczen przedmiotow"; } void Wczytanie_nauczycieli_laborek(vector <vector<Przedmiot>> &Przedmioty_Lab,vector < Nauczyciel> &Nauczyciele) { fstream plik; plik.open("laborki_nauczyciele.csv", ios::in | ios::out); if(plik.is_open()) { cout << "Plik z nauczycielami laborek otwarty" << endl << endl; string linia; string czesc; int numer_nauczyciela = 0; int numer_laborek = 0; int ile_laborek = 0; int ile_lab_wcze = 0; vector <string> dane; int il_zbiorow_labek = Przedmioty_Lab.size(); while(!plik.eof()) { plik >> linia; stringstream strumien(linia); while(getline(strumien,czesc,',')) { dane.push_back(czesc); } if(dane[0] != "" && dane[0] != ";") { numer_laborek = 0; ile_laborek = Przedmioty_Lab[0].size(); ile_lab_wcze = 0; for(int j = 0; j < il_zbiorow_labek;j++) { for(int i = numer_laborek; i < ile_laborek; i++) { if(stoi(dane[i]) != 0) { Nauczyciele[numer_nauczyciela].Godziny_labek(i,stoi(dane[i])); Przedmioty_Lab[j][i-ile_lab_wcze].Dodaj_nauczyciela(numer_nauczyciela); } else if(stoi(dane[i]) == "") { cout << "Blad w pliku nauczyciele_laborek wiersz: " << numer_nauczyciela << endl; } numer_laborek++; } ile_lab_wcze = ile_laborek; ile_laborek += Przedmioty_Lab[j+1].size(); } } else if(dane[0] == ";") { break; } dane.erase(dane.begin(), dane.end()); numer_nauczyciela++; } plik.close(); } else cout<<"Nie udało się otworzyć pliku z nauczycielami laborek przedmiotow"; } void Zajecia_wykladowe(vector <Zajecia>&Zajecie,vector<vector<Przedmiot>>&Przedmioty_Wykl,vector<vector<Nad_grupa>>&Grupy_Wykl,vector<Sala>&Sala_Wykl,int &il_wykl) { int ile_zbior_gr_wykl = Grupy_Wykl.size(); int ile_zbior_wykl = Przedmioty_Wykl.size(); int ilosc_wykladow = 0; int ilosc_grup = 0; int maks_ile_grup = 0; int maks_ile_wykl = 0; vector<vector<Przedmiot>>::iterator it1 = Przedmioty_Wykl.begin(); vector<vector<Nad_grupa>>::iterator it2 = Grupy_Wykl.begin(); for(;it1 != Przedmioty_Wykl.end() && it2 != Grupy_Wykl.end();it1++,it2++) { ilosc_wykladow = it1->size(); ilosc_grup = it2->size(); if(maks_ile_wykl < ilosc_wykladow) maks_ile_wykl = ilosc_wykladow; if(maks_ile_grup < ilosc_grup) maks_ile_grup = ilosc_grup; } int numer_zajecia = 0; if(ile_zbior_gr_wykl == ile_zbior_wykl) { for(int k = 0; k < maks_ile_wykl; k++) { for(int i = 0; i < maks_ile_grup; i++) { for(int j = 0; j < ile_zbior_wykl; j++) { ilosc_wykladow = Przedmioty_Wykl[j].size(); ilosc_grup = Grupy_Wykl[j].size(); if(k < ilosc_wykladow && i < ilosc_grup) { Zajecie.push_back({{&Przedmioty_Wykl[j][k]},{NULL},{&Grupy_Wykl[j][i]},(numer_zajecia+1)}); numer_zajecia++; } } } } int sala_wykl = 0; int ilosc_sal = Sala_Wykl.size(); int ilosc_zajec = Zajecie.size(); for(int i = 0; i < ilosc_zajec; i++) { if(sala_wykl == ilosc_sal) sala_wykl = 0; Zajecie[i].dodaj_sale()->push_back({&Sala_Wykl[sala_wykl]}); sala_wykl++; } il_wykl = Zajecie.size(); } else { cout << "Zbiory wykladow i grup wykladowych nie sa sobie rowne" << endl; } } void Zajecia_cwiczeniowe(vector <Zajecia> &Zajecie,vector<vector<Przedmiot>> &Przedmioty_Cw,vector <vector<Nad_grupa>> &Grupy_Cw,vector<Sala> &Sala_Cw,int &il_wykl_i_cw) { int ile_zbior_gr_cw = Grupy_Cw.size(); int ile_zbior_cw = Przedmioty_Cw.size(); int ilosc_cwiczen = 0; int ilosc_grup = 0; int maks_ile_grup = 0; int maks_ile_cw = 0; vector<vector<Przedmiot>>::iterator it1 = Przedmioty_Cw.begin(); vector<vector<Nad_grupa>>::iterator it2 = Grupy_Cw.begin(); for(;it1 != Przedmioty_Cw.end() && it2 != Grupy_Cw.end();it1++,it2++) { ilosc_cwiczen = it1->size(); ilosc_grup = it2->size(); if(maks_ile_cw < ilosc_cwiczen) maks_ile_cw = ilosc_cwiczen; if(maks_ile_grup < ilosc_grup) maks_ile_grup = ilosc_grup; } int numer_zajecia = Zajecie.size(); int ilosc_wykladow = Zajecie.size(); if(ile_zbior_gr_cw == ile_zbior_cw) { for(int k = 0; k < maks_ile_cw; k++) { for(int i = 0; i < maks_ile_grup; i++) { for(int j = 0; j < ile_zbior_cw; j++) { ilosc_cwiczen = Przedmioty_Cw[j].size(); ilosc_grup = Grupy_Cw[j].size(); if(k < ilosc_cwiczen && i < ilosc_grup) { Zajecie.push_back({{&Przedmioty_Cw[j][k]},{NULL},{&Grupy_Cw[j][i]},(numer_zajecia+1)}); numer_zajecia++; } } } } int sala_cw = 0; int ilosc_sal = Sala_Cw.size(); int ilosc_zajec = Zajecie.size(); for(int i = ilosc_wykladow; i < ilosc_zajec; i++) { if(sala_cw == ilosc_sal) sala_cw = 0; Zajecie[i].dodaj_sale()->push_back({&Sala_Cw[sala_cw]}); sala_cw++; } il_wykl_i_cw = Zajecie.size(); } else { cout << "Zbiory cwiczen i grup cwiczeniowych nie sa sobie rowne" << endl; } } void Zajecia_laborki(vector <Zajecia> &Zajecie,vector <vector<Przedmiot>> &Przedmioty_Lab,vector<vector<Grupa>> &Grupy_Lab,vector<Sala> &Sala_Lab) { int ile_zbior_gr_lab = Grupy_Lab.size(); int ile_zbior_lab = Przedmioty_Lab.size(); int ilosc_laborek = 0; int ilosc_grup = 0; int maks_ile_grup = 0; int maks_ile_lab = 0; vector<vector<Przedmiot>>::iterator it1 = Przedmioty_Lab.begin(); vector<vector<Grupa>>::iterator it2 = Grupy_Lab.begin(); for(;it1 != Przedmioty_Lab.end() && it2 != Grupy_Lab.end();it1++,it2++) { ilosc_laborek = it1->size(); ilosc_grup = it2->size(); if(maks_ile_lab < ilosc_laborek) maks_ile_lab = ilosc_laborek; if(maks_ile_grup < ilosc_grup) maks_ile_grup = ilosc_grup; } int numer_zajecia = Zajecie.size(); int ilosc_wykl_i_cw = Zajecie.size(); if(ile_zbior_gr_lab == ile_zbior_lab) { for(int k = 0; k < maks_ile_lab; k++) { for(int i = 0; i < maks_ile_grup; i++) { for(int j = 0; j < ile_zbior_lab; j++) { ilosc_laborek = Przedmioty_Lab[j].size(); ilosc_grup = Grupy_Lab[j].size(); if(k < ilosc_laborek && i < ilosc_grup) { Zajecie.push_back({{&Przedmioty_Lab[j][k]},{&Grupy_Lab[j][i]},{NULL},numer_zajecia+1}); numer_zajecia++; } } } } int sala_lab = 0; int ilosc_sal = Sala_Lab.size(); int ilosc_zajec = Zajecie.size(); for(int i = ilosc_wykl_i_cw; i < ilosc_zajec; i++) { if(sala_lab == ilosc_sal) sala_lab = 0; Zajecie[i].dodaj_sale()->push_back({&Sala_Lab[sala_lab]}); sala_lab++; } } else { cout << "Zbiory laborek i grup laboratoryjnych nie sa sobie rowne" << endl; } } void Zajecia_nauczyciele(vector<Zajecia> &Zajecie,vector<Nauczyciel> &Nauczyciele,int il_wykl,int il_wykl_i_cw) { int ilosc_zajec = Zajecie.size(); for(int i = 0; i < il_wykl; i++) { if(Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()].Dostepny_wykl(Zajecie[i].przedmiot()->Zwroc_numer())) { Zajecie[i].nauczyciel()->push_back(&Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()]); } else { Zajecie[i].przedmiot()->Nastepny_nauczyciel(); Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()].Dostepny_wykl(Zajecie[i].przedmiot()->Zwroc_numer()); Zajecie[i].nauczyciel()->push_back(&Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()]); } } for(int i = il_wykl; i < il_wykl_i_cw; i++) { if(Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()].Dostepny_cw(Zajecie[i].przedmiot()->Zwroc_numer())) { Zajecie[i].nauczyciel()->push_back(&Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()]); } else { Zajecie[i].przedmiot()->Nastepny_nauczyciel(); Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()].Dostepny_cw(Zajecie[i].przedmiot()->Zwroc_numer()); Zajecie[i].nauczyciel()->push_back(&Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()]); } } for(int i = il_wykl_i_cw; i < ilosc_zajec; i++) { if(Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()].Dostepny_lab(Zajecie[i].przedmiot()->Zwroc_numer())) { Zajecie[i].nauczyciel()->push_back(&Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()]); } else { Zajecie[i].przedmiot()->Nastepny_nauczyciel(); Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()].Dostepny_lab(Zajecie[i].przedmiot()->Zwroc_numer()); Zajecie[i].nauczyciel()->push_back(&Nauczyciele[Zajecie[i].przedmiot()->Zwroc_nauczyciela()]); } } } void Tworzenie_harmonogramu(vector <Zajecia> &Zajecie) { int ilosc_zajec = Zajecie.size(); for(int i = 0; i < ilosc_zajec; i++) { int losowa = rand() % 2; Zajecie[i].Termin_zajec(losowa); } } void Wypisanie_danych_harmonogramu(vector <Zajecia> &Zajecie,vector <vector<Grupa>> &Grupy_Lab, vector <Nauczyciel> &Nauczyciele) { int ilosc_nauczycieli = Nauczyciele.size(); int ilosc_zajec = 0; set <int>::iterator it; for(int i = 0; i < ilosc_nauczycieli; i++) { cout << "Plan nauczyciela " << i+1 << endl; for(int j = 0; j < 20; j++) { Nauczyciele[i].Wypisz_poz_w_plan(j); } cout << endl; ilosc_zajec = Nauczyciele[i].Ile_zajec(); cout << "Ilosc zajec nauczyciela: " << ilosc_zajec << endl; it = Nauczyciele[i].Pierwszy_zaj_termin(); cout << "Zajecie pierwsze: " << *it << endl; it = --Nauczyciele[i].Ostatni_zaj_termin(); cout << "Zajecie ostatnie: " << *it << endl; cout << "Kara: " << Nauczyciele[i].Oblicz_kare() << endl; cout << "Godziny dopuszczalne: "; for(it = Nauczyciele[i].Pierwszy_dop_termin(); it != Nauczyciele[i].Ostatni_dop_termin(); it++) { cout << *it << " "; } cout << endl; cout << "Terminy wykluczone: "; for(it = Nauczyciele[i].Pierwszy_niedop_termin(); it != Nauczyciele[i].Ostatni_niedop_termin(); it++) { cout << *it << " "; } cout << endl; cout << "Zajete terminy: "; for(it = Nauczyciele[i].Pierwszy_zaj_termin(); it != Nauczyciele[i].Ostatni_zaj_termin(); it++) { cout << *it << " "; } cout << endl << endl; } cout << "Suma kar dla nauczycieli: " << Kara_laczna_nauczycieli(Nauczyciele) << endl << endl; int ile_zbior_grup = Grupy_Lab.size(); int ilosc_grup = 0; for(int k = 0; k < ile_zbior_grup; k++) { ilosc_grup = Grupy_Lab[k].size(); for(int i = 0; i < ilosc_grup; i++) { cout << "Plan Grupy " << i+1 << endl; for(int j = 0; j < 20; j++) { cout << Grupy_Lab[k][i].Zwroc_numer_zaj(j) << " "; } cout << endl; ilosc_zajec = Grupy_Lab[k][i].Ile_zajec(); cout << "Ilosc zajec grup: " << ilosc_zajec << endl; it = Grupy_Lab[k][i].Pierwszy_zaj_termin(); cout << "Zajecie pierwsze: " << *it << endl; it = --Grupy_Lab[k][i].Ostatni_zaj_termin(); cout << "Zajecie ostatnie: " << *it << endl; cout << "Kara planu: " << Grupy_Lab[k][i].Oblicz_kare() << endl; cout << "Zajete terminy: "; for(it = Grupy_Lab[k][i].Pierwszy_zaj_termin(); it != Grupy_Lab[k][i].Ostatni_zaj_termin(); it++) { cout << *it << " "; } cout << endl << endl; } } cout << "Suma kar dla grup: " << Kara_laczna_grup(Grupy_Lab) << endl << endl; cout << "Kara laczna dla grup i nauczycieli: " << Kara_laczna_nauczycieli(Nauczyciele) + Kara_laczna_grup(Grupy_Lab) << endl << endl; } void Poprawianie_harmonogramu(vector <Zajecia> &Zajecie,vector <vector<Grupa>> &Grupy_Lab,vector <Nauczyciel> &Nauczyciele, vector <Sala> Sala_Lab, int ile_popraw) { vector <Sala> Sala_Lab_Naj = Sala_Lab; vector <vector<Grupa>> Grupy_Lab_Naj = Grupy_Lab; vector <Nauczyciel> Nauczyciele_Naj = Nauczyciele; vector <Zajecia> Zajecie_Naj = Zajecie; vector <float> kara_grupy; vector <float> kara_nauczyciel; vector <float>::iterator it; vector <Nauczyciel*> nauczyciele_labek; vector <Grupa*> grupy; int ilosc_zbiorow_grup = Grupy_Lab.size(); int ilosc_grup = 0; int ilosc_nauczy = Nauczyciele.size(); int il_nauczy_lab = 0; int najg_nauczy = 0; int najg_grupa = 0; int ile_zmian = 0; for(int i = 0; i < ilosc_zbiorow_grup; i++) { ilosc_grup = Grupy_Lab[i].size(); for(int j = 0; j < ilosc_grup; j++) { grupy.push_back({&Grupy_Lab[i][j]}); } } ilosc_grup = grupy.size(); for(int i = 0; i < ilosc_grup; i++) { kara_grupy.push_back({grupy[i]->Oblicz_kare()}); } cout << endl; it = max_element(kara_grupy.begin(),kara_grupy.end()); najg_grupa = distance(kara_grupy.begin(), it); for(int i = 0; i < ilosc_nauczy; i++) { if(Nauczyciele[i].Ile_lab_w_planie() != 0) nauczyciele_labek.push_back({&Nauczyciele[i]}); } il_nauczy_lab = nauczyciele_labek.size(); for(int i = 0; i < il_nauczy_lab; i++) { kara_nauczyciel.push_back(nauczyciele_labek[i]->Oblicz_kare()); } it = max_element(kara_nauczyciel.begin(),kara_nauczyciel.end()); najg_nauczy = distance(kara_nauczyciel.begin(), it); cout << "Ogolna wartosc kary planu: " << Ogolna_kara_planu(Grupy_Lab,Nauczyciele) << endl; for(int i = 0; i < ile_popraw; i++) { Poprawianie_grupy(Zajecie,it,kara_grupy,grupy,najg_grupa); Poprawianie_nauczycieli(Zajecie,it,kara_nauczyciel,Nauczyciele,najg_nauczy); if(Ogolna_kara_planu(Grupy_Lab,Nauczyciele) < Ogolna_kara_planu(Grupy_Lab_Naj,Nauczyciele_Naj)) { Sala_Lab_Naj = Sala_Lab; Grupy_Lab_Naj = Grupy_Lab; Nauczyciele_Naj = Nauczyciele; Zajecie_Naj = Zajecie; ile_zmian = 0; } else if(ile_zmian == 2) { Sala_Lab = Sala_Lab_Naj; Grupy_Lab = Grupy_Lab_Naj; Nauczyciele = Nauczyciele_Naj; Zajecie = Zajecie_Naj; for(int i = 0; i < ilosc_grup; i++) { kara_grupy[i] = grupy[i]->Zwroc_kare(); } for(int i = 0; i < il_nauczy_lab; i++) { kara_nauczyciel[i] = Nauczyciele[i].Zwroc_kare(); } ile_zmian = 0; } cout << "Ogolna wartosc kary planu: " << Ogolna_kara_planu(Grupy_Lab,Nauczyciele) << endl; } Sala_Lab = Sala_Lab_Naj; Grupy_Lab = Grupy_Lab_Naj; Nauczyciele = Nauczyciele_Naj; Zajecie = Zajecie_Naj; }
[ "d.berezowski95@gmail.com" ]
d.berezowski95@gmail.com
f5e5fbaec7699770d69f36d7f0405fe2cc42c653
abf463fdb8a7c7631fb1db4380807e336f039ea6
/c++/pointerstofunction.cpp
93ed02f826d163fb363b2f16df12b66e61fa70d2
[]
no_license
Jayad/Program_practise
ea1a16bf17519e581d75978c062c2f31a960c7a2
6de6f5cf8ebb24b264f999853cb11925c00ac746
refs/heads/master
2021-06-16T08:33:50.630104
2017-03-27T16:12:41
2017-03-27T16:12:41
8,859,196
0
0
null
null
null
null
UTF-8
C++
false
false
580
cpp
#include<iostream> using namespace std; int addition(int a, int b) { return (a+b); } int subtraction(int a, int b) { return (a-b); } int operation(int a, int b, int (*func)(int a, int b)) { int g; g=(*func)(a,b); return g; } int main() { int m,n,p; //minus is a pointer to a function that has two parameters of type int. It is immediately assigned to point to the function subtraction, all in a single line: int (*minus)(int,int) =subtraction; m=operation(5,6,addition); n=operation(25,m,minus); p=operation(25,m,subtraction); cout << n <<endl; cout << p <<endl; return 0; }
[ "jayad@yahoo-inc.com" ]
jayad@yahoo-inc.com
e7fe513735ca9bb29ae4c652941f342b7b211cac
367012d9c5656d78ee1c013adf99fa41c6d3339c
/Chap5/Chap5/Stacks/ragnarstest.cpp
479c84f7ca51f0e6e580627ba7c7fd05b5c5a1f4
[]
no_license
alflinusjonsson/DALGO-Drawing
6fedf45630e0fbe5ea2852535910e4570e38c102
e3e64c43c8d1bedd7b6b36a7a5799c26024c83e5
refs/heads/master
2022-05-16T06:09:06.960659
2020-04-29T07:15:47
2020-04-29T07:15:47
259,852,708
0
0
null
null
null
null
UTF-8
C++
false
false
3,359
cpp
#include "ragnarstest.h" #include "student2_arrstack.h" #include "student1_liststack.h" #include <iostream> #include <string> #include <QThread> #include <QElapsedTimer> #include <assert.h> using namespace std; template<class CStack> bool stackTest1(int recursionDepth=0) { QThread::msleep(300); cout << " stackTest1 (recursionDepth " << recursionDepth << ")" << endl; const int size = 100; float arr[size]; for (int i=0;i<size;++i) arr[i] = (float) rand()/RAND_MAX; CStack stack; for (int i=0; i<size ;++i){ int z = stack.size(); if (z!=i) { cout << "Fel storlek på stacken!! "<< z << " i st för "<< i <<endl;; return false; } stack.pushBack( arr[i] ); } if (recursionDepth==0 && stackTest1<CStack>(1)==false)// Testar att stacken kan användas i en rekursion. return false; for (int i=size; i>0 ;i--) { if (stack.size()!=i){ cout << "Fel stackstorlek, vid poppningen\n"; return false; } if (stack.back()!=arr[i-1]){ cout << "Fel TOP-värde p stacken\n"; return false; } stack.popBack(); } return true; }// stackTest template<class CStack> bool stackTest2(){ cout << " stackTest2 (tidtagning)" << endl; const int big = 1000000; CStack stack; QElapsedTimer myTimer; myTimer.start(); for (int i=0;i<big ; ++i){ stack.pushBack( 1.2 ); if (big%100==0){ int duration = myTimer.elapsed(); if (duration>1000){ cout << "BUG: Stacken är för långsam!!!" << endl; cout << " testen avslutades vid i=" << i << "av ("<<big<<")" << endl; return false; } } } int duration = myTimer.elapsed(); cout << " stackTest2 avslutades inom " << duration << " ms." << endl; return true; }//stackTest2 bool testStart( const char *testName, const char *studentName ){ cout << endl << endl; cout << "------------------------------------------\n"; cout << "Testing " << testName << " for student:" << studentName << endl; assert( string("Homer Simpson") != studentName ); return true; } bool testStop( const char *testName, bool success ){ QThread::msleep(500); cout << endl << testName << " " << (success? "Lyckades" : "MISSLYCKADES\7") << endl; cout << "------------------------------------------\n"; assert( success ); return true; } //*********************************************************************** // ANROP: ragnarsTest( ); // VERSION: 2010-01-15 // UPPFIFT: Testar en eller flera rutiner som studenten har skrivit. //*********************************************************************** bool ragnarsTest(){ setlocale(LC_ALL, "Swedish" ); cout << "\n\n ragnarsTest" << endl; bool ok = true; // testStart("LStack" , nameOfStudentLStack() ); // ok = ok && stackTest1<LStack>(); // ok = ok && stackTest2<LStack>(); // testStop("LStack", ok); testStart("AStack" , nameOfStudentAStack() ); ok = ok && stackTest1<AStack>(); ok = ok && stackTest2<AStack>(); testStop("AStack", ok); if (ok) cout << "(självtesten lyckades!)" << endl; return ok; }// ragnarsTest
[ "alflinusjonsson@gmail.com" ]
alflinusjonsson@gmail.com
bd23a417f929fbe61f9532b724581b0b5138391c
cd99ca9461435d1417cb146d966e54272fbcc7ad
/3rd party/maxsdk/samples/systems/sunlight/PhysicalSunSkyEnv_UI.h
835e3a73d76e02d0da3b8f152ec6c1e6b49f011e
[]
no_license
mortany/xray15
eacce7965e785dd71d1877eae25c1f9eff680eec
72a13fb24e9b388850bc769427c231da8f599228
refs/heads/master
2020-08-02T20:45:23.493981
2019-10-14T18:48:48
2019-10-14T18:48:48
211,499,718
0
0
null
2019-09-28T12:50:47
2019-09-28T12:50:46
null
UTF-8
C++
false
false
1,664
h
////////////////////////////////////////////////////////////////////////////// // // Copyright 2015 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // ////////////////////////////////////////////////////////////////////////////// #pragma once // local #include "PhysicalSunSkyEnv.h" // Max SDK #include <Qt/QMaxParamBlockWidget.h> // Qt #include "ui_PhysSunSky.h" #include <QtWidgets/QWidget> //================================================================================================== // class PhysicalSunSkyEnv::MainPanelWidget // // Qt widget that implements the UI for the main panel of the physical sun & sky environment. // class PhysicalSunSkyEnv::MainPanelWidget : public MaxSDK::QMaxParamBlockWidget { Q_OBJECT public: explicit MainPanelWidget(IParamBlock2& param_block); ~MainPanelWidget(); // -- inherited from QMaxParamBlockWidget virtual void SetParamBlock(ReferenceMaker* owner, IParamBlock2* const param_block) override; virtual void UpdateUI(const TimeValue t) override; virtual void UpdateParameterUI(const TimeValue t, const ParamID param_id, const int tab_index) override; protected slots: void create_sun_positioner_button_clicked(); private: void update_illuminance_model_controls(const TimeValue t); private: // UI designer object Ui_PhysSunSky m_ui_builder; IParamBlock2* m_param_block; };
[ "cheatmaster1@mail.ru" ]
cheatmaster1@mail.ru
351df11b35b05c1a9134770f71a3a679e69feec2
bc92c058b0c2dd2877648e30156245e36ee571a4
/source/common/xproto/framework/third_party/aarch64/opencv/include/opencv2/core/hal/intrin_neon.hpp
6eb43abc6e2a4fc5c0f791e5ddfe87d30db7496a
[ "BSD-2-Clause" ]
permissive
robort-yuan/AI-EXPRESS
c1783f5f155b918dcc6da11956c842ae5467de8e
56f86d03afbb09f42c21958c8cd9f2f1c6437f48
refs/heads/master
2023-02-09T03:51:44.775020
2021-01-02T15:15:37
2021-01-02T15:15:37
309,591,131
0
0
BSD-2-Clause
2020-12-08T07:48:54
2020-11-03T06:11:06
null
UTF-8
C++
false
false
64,403
hpp
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. // Copyright (C) 2013, OpenCV Foundation, all rights reserved. // Copyright (C) 2015, Itseez Inc., all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's 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. // // * The name of the copyright holders may not be used to endorse or promote products // derived from this software without specific prior written permission. // // This software is provided by the copyright holders and contributors "as is" and // any express or implied warranties, including, but not limited to, the implied // warranties of merchantability and fitness for a particular purpose are disclaimed. // In no event shall the Intel Corporation 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. // //M*/ #ifndef OPENCV_HAL_INTRIN_NEON_HPP #define OPENCV_HAL_INTRIN_NEON_HPP #include <algorithm> #include "opencv2/core/utility.hpp" namespace cv { //! @cond IGNORED CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN #define CV_SIMD128 1 #if defined(__aarch64__) #define CV_SIMD128_64F 1 #else #define CV_SIMD128_64F 0 #endif #if CV_SIMD128_64F #define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) \ template <typename T> static inline \ _Tpv vreinterpretq_##suffix##_f64(T a) { return (_Tpv) a; } \ template <typename T> static inline \ float64x2_t vreinterpretq_f64_##suffix(T a) { return (float64x2_t) a; } OPENCV_HAL_IMPL_NEON_REINTERPRET(uint8x16_t, u8) OPENCV_HAL_IMPL_NEON_REINTERPRET(int8x16_t, s8) OPENCV_HAL_IMPL_NEON_REINTERPRET(uint16x8_t, u16) OPENCV_HAL_IMPL_NEON_REINTERPRET(int16x8_t, s16) OPENCV_HAL_IMPL_NEON_REINTERPRET(uint32x4_t, u32) OPENCV_HAL_IMPL_NEON_REINTERPRET(int32x4_t, s32) OPENCV_HAL_IMPL_NEON_REINTERPRET(uint64x2_t, u64) OPENCV_HAL_IMPL_NEON_REINTERPRET(int64x2_t, s64) OPENCV_HAL_IMPL_NEON_REINTERPRET(float32x4_t, f32) #endif struct v_uint8x16 { typedef uchar lane_type; enum { nlanes = 16 }; v_uint8x16() {} explicit v_uint8x16(uint8x16_t v) : val(v) {} v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) { uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; val = vld1q_u8(v); } uchar get0() const { return vgetq_lane_u8(val, 0); } uint8x16_t val; }; struct v_int8x16 { typedef schar lane_type; enum { nlanes = 16 }; v_int8x16() {} explicit v_int8x16(int8x16_t v) : val(v) {} v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) { schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; val = vld1q_s8(v); } schar get0() const { return vgetq_lane_s8(val, 0); } int8x16_t val; }; struct v_uint16x8 { typedef ushort lane_type; enum { nlanes = 8 }; v_uint16x8() {} explicit v_uint16x8(uint16x8_t v) : val(v) {} v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) { ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; val = vld1q_u16(v); } ushort get0() const { return vgetq_lane_u16(val, 0); } uint16x8_t val; }; struct v_int16x8 { typedef short lane_type; enum { nlanes = 8 }; v_int16x8() {} explicit v_int16x8(int16x8_t v) : val(v) {} v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) { short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; val = vld1q_s16(v); } short get0() const { return vgetq_lane_s16(val, 0); } int16x8_t val; }; struct v_uint32x4 { typedef unsigned lane_type; enum { nlanes = 4 }; v_uint32x4() {} explicit v_uint32x4(uint32x4_t v) : val(v) {} v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) { unsigned v[] = {v0, v1, v2, v3}; val = vld1q_u32(v); } unsigned get0() const { return vgetq_lane_u32(val, 0); } uint32x4_t val; }; struct v_int32x4 { typedef int lane_type; enum { nlanes = 4 }; v_int32x4() {} explicit v_int32x4(int32x4_t v) : val(v) {} v_int32x4(int v0, int v1, int v2, int v3) { int v[] = {v0, v1, v2, v3}; val = vld1q_s32(v); } int get0() const { return vgetq_lane_s32(val, 0); } int32x4_t val; }; struct v_float32x4 { typedef float lane_type; enum { nlanes = 4 }; v_float32x4() {} explicit v_float32x4(float32x4_t v) : val(v) {} v_float32x4(float v0, float v1, float v2, float v3) { float v[] = {v0, v1, v2, v3}; val = vld1q_f32(v); } float get0() const { return vgetq_lane_f32(val, 0); } float32x4_t val; }; struct v_uint64x2 { typedef uint64 lane_type; enum { nlanes = 2 }; v_uint64x2() {} explicit v_uint64x2(uint64x2_t v) : val(v) {} v_uint64x2(uint64 v0, uint64 v1) { uint64 v[] = {v0, v1}; val = vld1q_u64(v); } uint64 get0() const { return vgetq_lane_u64(val, 0); } uint64x2_t val; }; struct v_int64x2 { typedef int64 lane_type; enum { nlanes = 2 }; v_int64x2() {} explicit v_int64x2(int64x2_t v) : val(v) {} v_int64x2(int64 v0, int64 v1) { int64 v[] = {v0, v1}; val = vld1q_s64(v); } int64 get0() const { return vgetq_lane_s64(val, 0); } int64x2_t val; }; #if CV_SIMD128_64F struct v_float64x2 { typedef double lane_type; enum { nlanes = 2 }; v_float64x2() {} explicit v_float64x2(float64x2_t v) : val(v) {} v_float64x2(double v0, double v1) { double v[] = {v0, v1}; val = vld1q_f64(v); } double get0() const { return vgetq_lane_f64(val, 0); } float64x2_t val; }; #endif #if CV_FP16 // Workaround for old compilers static inline int16x4_t vreinterpret_s16_f16(float16x4_t a) { return (int16x4_t)a; } static inline float16x4_t vreinterpret_f16_s16(int16x4_t a) { return (float16x4_t)a; } static inline float16x4_t cv_vld1_f16(const void* ptr) { #ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro return vreinterpret_f16_s16(vld1_s16((const short*)ptr)); #else return vld1_f16((const __fp16*)ptr); #endif } static inline void cv_vst1_f16(void* ptr, float16x4_t a) { #ifndef vst1_f16 // APPLE compiler defines vst1_f16 as macro vst1_s16((short*)ptr, vreinterpret_s16_f16(a)); #else vst1_f16((__fp16*)ptr, a); #endif } #ifndef vdup_n_f16 #define vdup_n_f16(v) (float16x4_t){v, v, v, v} #endif #endif // CV_FP16 #if CV_FP16 inline v_float32x4 v128_load_fp16_f32(const short* ptr) { float16x4_t a = cv_vld1_f16((const __fp16*)ptr); return v_float32x4(vcvt_f32_f16(a)); } inline void v_store_fp16(short* ptr, const v_float32x4& a) { float16x4_t fp16 = vcvt_f16_f32(a.val); cv_vst1_f16((short*)ptr, fp16); } #endif #define OPENCV_HAL_IMPL_NEON_INIT(_Tpv, _Tp, suffix) \ inline v_##_Tpv v_setzero_##suffix() { return v_##_Tpv(vdupq_n_##suffix((_Tp)0)); } \ inline v_##_Tpv v_setall_##suffix(_Tp v) { return v_##_Tpv(vdupq_n_##suffix(v)); } \ inline _Tpv##_t vreinterpretq_##suffix##_##suffix(_Tpv##_t v) { return v; } \ inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return v_uint8x16(vreinterpretq_u8_##suffix(v.val)); } \ inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return v_int8x16(vreinterpretq_s8_##suffix(v.val)); } \ inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return v_uint16x8(vreinterpretq_u16_##suffix(v.val)); } \ inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return v_int16x8(vreinterpretq_s16_##suffix(v.val)); } \ inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return v_uint32x4(vreinterpretq_u32_##suffix(v.val)); } \ inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return v_int32x4(vreinterpretq_s32_##suffix(v.val)); } \ inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return v_uint64x2(vreinterpretq_u64_##suffix(v.val)); } \ inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return v_int64x2(vreinterpretq_s64_##suffix(v.val)); } \ inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return v_float32x4(vreinterpretq_f32_##suffix(v.val)); } OPENCV_HAL_IMPL_NEON_INIT(uint8x16, uchar, u8) OPENCV_HAL_IMPL_NEON_INIT(int8x16, schar, s8) OPENCV_HAL_IMPL_NEON_INIT(uint16x8, ushort, u16) OPENCV_HAL_IMPL_NEON_INIT(int16x8, short, s16) OPENCV_HAL_IMPL_NEON_INIT(uint32x4, unsigned, u32) OPENCV_HAL_IMPL_NEON_INIT(int32x4, int, s32) OPENCV_HAL_IMPL_NEON_INIT(uint64x2, uint64, u64) OPENCV_HAL_IMPL_NEON_INIT(int64x2, int64, s64) OPENCV_HAL_IMPL_NEON_INIT(float32x4, float, f32) #if CV_SIMD128_64F #define OPENCV_HAL_IMPL_NEON_INIT_64(_Tpv, suffix) \ inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2(vreinterpretq_f64_##suffix(v.val)); } OPENCV_HAL_IMPL_NEON_INIT(float64x2, double, f64) OPENCV_HAL_IMPL_NEON_INIT_64(uint8x16, u8) OPENCV_HAL_IMPL_NEON_INIT_64(int8x16, s8) OPENCV_HAL_IMPL_NEON_INIT_64(uint16x8, u16) OPENCV_HAL_IMPL_NEON_INIT_64(int16x8, s16) OPENCV_HAL_IMPL_NEON_INIT_64(uint32x4, u32) OPENCV_HAL_IMPL_NEON_INIT_64(int32x4, s32) OPENCV_HAL_IMPL_NEON_INIT_64(uint64x2, u64) OPENCV_HAL_IMPL_NEON_INIT_64(int64x2, s64) OPENCV_HAL_IMPL_NEON_INIT_64(float32x4, f32) OPENCV_HAL_IMPL_NEON_INIT_64(float64x2, f64) #endif #define OPENCV_HAL_IMPL_NEON_PACK(_Tpvec, _Tp, hreg, suffix, _Tpwvec, pack, mov, rshr) \ inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \ { \ hreg a1 = mov(a.val), b1 = mov(b.val); \ return _Tpvec(vcombine_##suffix(a1, b1)); \ } \ inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ { \ hreg a1 = mov(a.val); \ vst1_##suffix(ptr, a1); \ } \ template<int n> inline \ _Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \ { \ hreg a1 = rshr(a.val, n); \ hreg b1 = rshr(b.val, n); \ return _Tpvec(vcombine_##suffix(a1, b1)); \ } \ template<int n> inline \ void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ { \ hreg a1 = rshr(a.val, n); \ vst1_##suffix(ptr, a1); \ } OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_uint16x8, pack, vqmovn_u16, vqrshrn_n_u16) OPENCV_HAL_IMPL_NEON_PACK(v_int8x16, schar, int8x8_t, s8, v_int16x8, pack, vqmovn_s16, vqrshrn_n_s16) OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_uint32x4, pack, vqmovn_u32, vqrshrn_n_u32) OPENCV_HAL_IMPL_NEON_PACK(v_int16x8, short, int16x4_t, s16, v_int32x4, pack, vqmovn_s32, vqrshrn_n_s32) OPENCV_HAL_IMPL_NEON_PACK(v_uint32x4, unsigned, uint32x2_t, u32, v_uint64x2, pack, vmovn_u64, vrshrn_n_u64) OPENCV_HAL_IMPL_NEON_PACK(v_int32x4, int, int32x2_t, s32, v_int64x2, pack, vmovn_s64, vrshrn_n_s64) OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_int16x8, pack_u, vqmovun_s16, vqrshrun_n_s16) OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_int32x4, pack_u, vqmovun_s32, vqrshrun_n_s32) // pack boolean inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) { uint8x16_t ab = vcombine_u8(vmovn_u16(a.val), vmovn_u16(b.val)); return v_uint8x16(ab); } inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, const v_uint32x4& c, const v_uint32x4& d) { uint16x8_t nab = vcombine_u16(vmovn_u32(a.val), vmovn_u32(b.val)); uint16x8_t ncd = vcombine_u16(vmovn_u32(c.val), vmovn_u32(d.val)); return v_uint8x16(vcombine_u8(vmovn_u16(nab), vmovn_u16(ncd))); } inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, const v_uint64x2& g, const v_uint64x2& h) { uint32x4_t ab = vcombine_u32(vmovn_u64(a.val), vmovn_u64(b.val)); uint32x4_t cd = vcombine_u32(vmovn_u64(c.val), vmovn_u64(d.val)); uint32x4_t ef = vcombine_u32(vmovn_u64(e.val), vmovn_u64(f.val)); uint32x4_t gh = vcombine_u32(vmovn_u64(g.val), vmovn_u64(h.val)); uint16x8_t abcd = vcombine_u16(vmovn_u32(ab), vmovn_u32(cd)); uint16x8_t efgh = vcombine_u16(vmovn_u32(ef), vmovn_u32(gh)); return v_uint8x16(vcombine_u8(vmovn_u16(abcd), vmovn_u16(efgh))); } inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, const v_float32x4& m1, const v_float32x4& m2, const v_float32x4& m3) { float32x2_t vl = vget_low_f32(v.val), vh = vget_high_f32(v.val); float32x4_t res = vmulq_lane_f32(m0.val, vl, 0); res = vmlaq_lane_f32(res, m1.val, vl, 1); res = vmlaq_lane_f32(res, m2.val, vh, 0); res = vmlaq_lane_f32(res, m3.val, vh, 1); return v_float32x4(res); } inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, const v_float32x4& m1, const v_float32x4& m2, const v_float32x4& a) { float32x2_t vl = vget_low_f32(v.val), vh = vget_high_f32(v.val); float32x4_t res = vmulq_lane_f32(m0.val, vl, 0); res = vmlaq_lane_f32(res, m1.val, vl, 1); res = vmlaq_lane_f32(res, m2.val, vh, 0); res = vaddq_f32(res, a.val); return v_float32x4(res); } #define OPENCV_HAL_IMPL_NEON_BIN_OP(bin_op, _Tpvec, intrin) \ inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ { \ return _Tpvec(intrin(a.val, b.val)); \ } \ inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ { \ a.val = intrin(a.val, b.val); \ return a; \ } OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint8x16, vqaddq_u8) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint8x16, vqsubq_u8) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int8x16, vqaddq_s8) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int8x16, vqsubq_s8) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint16x8, vqaddq_u16) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint16x8, vqsubq_u16) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int16x8, vqaddq_s16) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int16x8, vqsubq_s16) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int32x4, vaddq_s32) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int32x4, vsubq_s32) OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_int32x4, vmulq_s32) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint32x4, vaddq_u32) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint32x4, vsubq_u32) OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_uint32x4, vmulq_u32) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_float32x4, vaddq_f32) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_float32x4, vsubq_f32) OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_float32x4, vmulq_f32) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int64x2, vaddq_s64) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int64x2, vsubq_s64) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint64x2, vaddq_u64) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint64x2, vsubq_u64) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float32x4, vdivq_f32) OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_float64x2, vaddq_f64) OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_float64x2, vsubq_f64) OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_float64x2, vmulq_f64) OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float64x2, vdivq_f64) #else inline v_float32x4 operator / (const v_float32x4& a, const v_float32x4& b) { float32x4_t reciprocal = vrecpeq_f32(b.val); reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); return v_float32x4(vmulq_f32(a.val, reciprocal)); } inline v_float32x4& operator /= (v_float32x4& a, const v_float32x4& b) { float32x4_t reciprocal = vrecpeq_f32(b.val); reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); a.val = vmulq_f32(a.val, reciprocal); return a; } #endif // saturating multiply 8-bit, 16-bit #define OPENCV_HAL_IMPL_NEON_MUL_SAT(_Tpvec, _Tpwvec) \ inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ { \ _Tpwvec c, d; \ v_mul_expand(a, b, c, d); \ return v_pack(c, d); \ } \ inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ { a = a * b; return a; } OPENCV_HAL_IMPL_NEON_MUL_SAT(v_int8x16, v_int16x8) OPENCV_HAL_IMPL_NEON_MUL_SAT(v_uint8x16, v_uint16x8) OPENCV_HAL_IMPL_NEON_MUL_SAT(v_int16x8, v_int32x4) OPENCV_HAL_IMPL_NEON_MUL_SAT(v_uint16x8, v_uint32x4) // Multiply and expand inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, v_int16x8& c, v_int16x8& d) { c.val = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); d.val = vmull_s8(vget_high_s8(a.val), vget_high_s8(b.val)); } inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, v_uint16x8& c, v_uint16x8& d) { c.val = vmull_u8(vget_low_u8(a.val), vget_low_u8(b.val)); d.val = vmull_u8(vget_high_u8(a.val), vget_high_u8(b.val)); } inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, v_int32x4& c, v_int32x4& d) { c.val = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); d.val = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)); } inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, v_uint32x4& c, v_uint32x4& d) { c.val = vmull_u16(vget_low_u16(a.val), vget_low_u16(b.val)); d.val = vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)); } inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, v_uint64x2& c, v_uint64x2& d) { c.val = vmull_u32(vget_low_u32(a.val), vget_low_u32(b.val)); d.val = vmull_u32(vget_high_u32(a.val), vget_high_u32(b.val)); } inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) { return v_int16x8(vcombine_s16( vshrn_n_s32(vmull_s16( vget_low_s16(a.val), vget_low_s16(b.val)), 16), vshrn_n_s32(vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)), 16) )); } inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) { return v_uint16x8(vcombine_u16( vshrn_n_u32(vmull_u16( vget_low_u16(a.val), vget_low_u16(b.val)), 16), vshrn_n_u32(vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)), 16) )); } inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) { int32x4_t c = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); int32x4_t d = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)); int32x4x2_t cd = vuzpq_s32(c, d); return v_int32x4(vaddq_s32(cd.val[0], cd.val[1])); } inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) { v_int32x4 s = v_dotprod(a, b); return v_int32x4(vaddq_s32(s.val , c.val)); } #define OPENCV_HAL_IMPL_NEON_LOGIC_OP(_Tpvec, suffix) \ OPENCV_HAL_IMPL_NEON_BIN_OP(&, _Tpvec, vandq_##suffix) \ OPENCV_HAL_IMPL_NEON_BIN_OP(|, _Tpvec, vorrq_##suffix) \ OPENCV_HAL_IMPL_NEON_BIN_OP(^, _Tpvec, veorq_##suffix) \ inline _Tpvec operator ~ (const _Tpvec& a) \ { \ return _Tpvec(vreinterpretq_##suffix##_u8(vmvnq_u8(vreinterpretq_u8_##suffix(a.val)))); \ } OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint8x16, u8) OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int8x16, s8) OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint16x8, u16) OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int16x8, s16) OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint32x4, u32) OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int32x4, s32) OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint64x2, u64) OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int64x2, s64) #define OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(bin_op, intrin) \ inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ { \ return v_float32x4(vreinterpretq_f32_s32(intrin(vreinterpretq_s32_f32(a.val), vreinterpretq_s32_f32(b.val)))); \ } \ inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ { \ a.val = vreinterpretq_f32_s32(intrin(vreinterpretq_s32_f32(a.val), vreinterpretq_s32_f32(b.val))); \ return a; \ } OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(&, vandq_s32) OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(|, vorrq_s32) OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(^, veorq_s32) inline v_float32x4 operator ~ (const v_float32x4& a) { return v_float32x4(vreinterpretq_f32_s32(vmvnq_s32(vreinterpretq_s32_f32(a.val)))); } #if CV_SIMD128_64F inline v_float32x4 v_sqrt(const v_float32x4& x) { return v_float32x4(vsqrtq_f32(x.val)); } inline v_float32x4 v_invsqrt(const v_float32x4& x) { v_float32x4 one = v_setall_f32(1.0f); return one / v_sqrt(x); } #else inline v_float32x4 v_sqrt(const v_float32x4& x) { float32x4_t x1 = vmaxq_f32(x.val, vdupq_n_f32(FLT_MIN)); float32x4_t e = vrsqrteq_f32(x1); e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); return v_float32x4(vmulq_f32(x.val, e)); } inline v_float32x4 v_invsqrt(const v_float32x4& x) { float32x4_t e = vrsqrteq_f32(x.val); e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x.val, e), e), e); e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x.val, e), e), e); return v_float32x4(e); } #endif #define OPENCV_HAL_IMPL_NEON_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \ inline _Tpuvec v_abs(const _Tpsvec& a) { return v_reinterpret_as_##usuffix(_Tpsvec(vabsq_##ssuffix(a.val))); } OPENCV_HAL_IMPL_NEON_ABS(v_uint8x16, v_int8x16, u8, s8) OPENCV_HAL_IMPL_NEON_ABS(v_uint16x8, v_int16x8, u16, s16) OPENCV_HAL_IMPL_NEON_ABS(v_uint32x4, v_int32x4, u32, s32) inline v_float32x4 v_abs(v_float32x4 x) { return v_float32x4(vabsq_f32(x.val)); } #if CV_SIMD128_64F #define OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(bin_op, intrin) \ inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ { \ return v_float64x2(vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val)))); \ } \ inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ { \ a.val = vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val))); \ return a; \ } OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(&, vandq_s64) OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(|, vorrq_s64) OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(^, veorq_s64) inline v_float64x2 operator ~ (const v_float64x2& a) { return v_float64x2(vreinterpretq_f64_s32(vmvnq_s32(vreinterpretq_s32_f64(a.val)))); } inline v_float64x2 v_sqrt(const v_float64x2& x) { return v_float64x2(vsqrtq_f64(x.val)); } inline v_float64x2 v_invsqrt(const v_float64x2& x) { v_float64x2 one = v_setall_f64(1.0f); return one / v_sqrt(x); } inline v_float64x2 v_abs(v_float64x2 x) { return v_float64x2(vabsq_f64(x.val)); } #endif // TODO: exp, log, sin, cos #define OPENCV_HAL_IMPL_NEON_BIN_FUNC(_Tpvec, func, intrin) \ inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ { \ return _Tpvec(intrin(a.val, b.val)); \ } OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_min, vminq_u8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_max, vmaxq_u8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_min, vminq_s8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_max, vmaxq_s8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_min, vminq_u16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_max, vmaxq_u16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_min, vminq_s16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_max, vmaxq_s16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_min, vminq_u32) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_max, vmaxq_u32) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_min, vminq_s32) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_max, vmaxq_s32) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_min, vminq_f32) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_max, vmaxq_f32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_min, vminq_f64) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_max, vmaxq_f64) #endif #if CV_SIMD128_64F inline int64x2_t vmvnq_s64(int64x2_t a) { int64x2_t vx = vreinterpretq_s64_u32(vdupq_n_u32(0xFFFFFFFF)); return veorq_s64(a, vx); } inline uint64x2_t vmvnq_u64(uint64x2_t a) { uint64x2_t vx = vreinterpretq_u64_u32(vdupq_n_u32(0xFFFFFFFF)); return veorq_u64(a, vx); } #endif #define OPENCV_HAL_IMPL_NEON_INT_CMP_OP(_Tpvec, cast, suffix, not_suffix) \ inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(cast(vceqq_##suffix(a.val, b.val))); } \ inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(cast(vmvnq_##not_suffix(vceqq_##suffix(a.val, b.val)))); } \ inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(cast(vcltq_##suffix(a.val, b.val))); } \ inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(cast(vcgtq_##suffix(a.val, b.val))); } \ inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(cast(vcleq_##suffix(a.val, b.val))); } \ inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(cast(vcgeq_##suffix(a.val, b.val))); } OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint8x16, OPENCV_HAL_NOP, u8, u8) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int8x16, vreinterpretq_s8_u8, s8, u8) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint16x8, OPENCV_HAL_NOP, u16, u16) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int16x8, vreinterpretq_s16_u16, s16, u16) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint32x4, OPENCV_HAL_NOP, u32, u32) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int32x4, vreinterpretq_s32_u32, s32, u32) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float32x4, vreinterpretq_f32_u32, f32, u32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint64x2, OPENCV_HAL_NOP, u64, u64) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int64x2, vreinterpretq_s64_u64, s64, u64) OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float64x2, vreinterpretq_f64_u64, f64, u64) #endif inline v_float32x4 v_not_nan(const v_float32x4& a) { return v_float32x4(vreinterpretq_f32_u32(vceqq_f32(a.val, a.val))); } #if CV_SIMD128_64F inline v_float64x2 v_not_nan(const v_float64x2& a) { return v_float64x2(vreinterpretq_f64_u64(vceqq_f64(a.val, a.val))); } #endif OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_add_wrap, vaddq_u8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_add_wrap, vaddq_s8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_add_wrap, vaddq_u16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_add_wrap, vaddq_s16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_sub_wrap, vsubq_u8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_sub_wrap, vsubq_s8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_sub_wrap, vsubq_u16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_sub_wrap, vsubq_s16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_mul_wrap, vmulq_u8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_mul_wrap, vmulq_s8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_mul_wrap, vmulq_u16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_mul_wrap, vmulq_s16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_absdiff, vabdq_u8) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_absdiff, vabdq_u16) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_absdiff, vabdq_u32) OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_absdiff, vabdq_f32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_absdiff, vabdq_f64) #endif /** Saturating absolute difference **/ inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) { return v_int8x16(vqabsq_s8(vqsubq_s8(a.val, b.val))); } inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) { return v_int16x8(vqabsq_s16(vqsubq_s16(a.val, b.val))); } #define OPENCV_HAL_IMPL_NEON_BIN_FUNC2(_Tpvec, _Tpvec2, cast, func, intrin) \ inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \ { \ return _Tpvec2(cast(intrin(a.val, b.val))); \ } OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int8x16, v_uint8x16, vreinterpretq_u8_s8, v_absdiff, vabdq_s8) OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int16x8, v_uint16x8, vreinterpretq_u16_s16, v_absdiff, vabdq_s16) OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int32x4, v_uint32x4, vreinterpretq_u32_s32, v_absdiff, vabdq_s32) inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) { v_float32x4 x(vmlaq_f32(vmulq_f32(a.val, a.val), b.val, b.val)); return v_sqrt(x); } inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) { return v_float32x4(vmlaq_f32(vmulq_f32(a.val, a.val), b.val, b.val)); } inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) { #if CV_SIMD128_64F // ARMv8, which adds support for 64-bit floating-point (so CV_SIMD128_64F is defined), // also adds FMA support both for single- and double-precision floating-point vectors return v_float32x4(vfmaq_f32(c.val, a.val, b.val)); #else return v_float32x4(vmlaq_f32(c.val, a.val, b.val)); #endif } inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) { return v_int32x4(vmlaq_s32(c.val, a.val, b.val)); } inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) { return v_fma(a, b, c); } inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) { return v_fma(a, b, c); } #if CV_SIMD128_64F inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) { v_float64x2 x(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val))); return v_sqrt(x); } inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) { return v_float64x2(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val))); } inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) { return v_float64x2(vfmaq_f64(c.val, a.val, b.val)); } inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) { return v_fma(a, b, c); } #endif // trade efficiency for convenience #define OPENCV_HAL_IMPL_NEON_SHIFT_OP(_Tpvec, suffix, _Tps, ssuffix) \ inline _Tpvec operator << (const _Tpvec& a, int n) \ { return _Tpvec(vshlq_##suffix(a.val, vdupq_n_##ssuffix((_Tps)n))); } \ inline _Tpvec operator >> (const _Tpvec& a, int n) \ { return _Tpvec(vshlq_##suffix(a.val, vdupq_n_##ssuffix((_Tps)-n))); } \ template<int n> inline _Tpvec v_shl(const _Tpvec& a) \ { return _Tpvec(vshlq_n_##suffix(a.val, n)); } \ template<int n> inline _Tpvec v_shr(const _Tpvec& a) \ { return _Tpvec(vshrq_n_##suffix(a.val, n)); } \ template<int n> inline _Tpvec v_rshr(const _Tpvec& a) \ { return _Tpvec(vrshrq_n_##suffix(a.val, n)); } OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint8x16, u8, schar, s8) OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int8x16, s8, schar, s8) OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint16x8, u16, short, s16) OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int16x8, s16, short, s16) OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint32x4, u32, int, s32) OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int32x4, s32, int, s32) OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint64x2, u64, int64, s64) OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int64x2, s64, int64, s64) #define OPENCV_HAL_IMPL_NEON_ROTATE_OP(_Tpvec, suffix) \ template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a) \ { return _Tpvec(vextq_##suffix(a.val, vdupq_n_##suffix(0), n)); } \ template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a) \ { return _Tpvec(vextq_##suffix(vdupq_n_##suffix(0), a.val, _Tpvec::nlanes - n)); } \ template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ { return a; } \ template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(vextq_##suffix(a.val, b.val, n)); } \ template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ { return _Tpvec(vextq_##suffix(b.val, a.val, _Tpvec::nlanes - n)); } \ template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ { CV_UNUSED(b); return a; } OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint8x16, u8) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int8x16, s8) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint16x8, u16) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int16x8, s16) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint32x4, u32) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int32x4, s32) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_float32x4, f32) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint64x2, u64) OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int64x2, s64) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_float64x2, f64) #endif #define OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(_Tpvec, _Tp, suffix) \ inline _Tpvec v_load(const _Tp* ptr) \ { return _Tpvec(vld1q_##suffix(ptr)); } \ inline _Tpvec v_load_aligned(const _Tp* ptr) \ { return _Tpvec(vld1q_##suffix(ptr)); } \ inline _Tpvec v_load_low(const _Tp* ptr) \ { return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr), vdup_n_##suffix((_Tp)0))); } \ inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ { return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr0), vld1_##suffix(ptr1))); } \ inline void v_store(_Tp* ptr, const _Tpvec& a) \ { vst1q_##suffix(ptr, a.val); } \ inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ { vst1q_##suffix(ptr, a.val); } \ inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ { vst1q_##suffix(ptr, a.val); } \ inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ { vst1q_##suffix(ptr, a.val); } \ inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ { vst1_##suffix(ptr, vget_low_##suffix(a.val)); } \ inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ { vst1_##suffix(ptr, vget_high_##suffix(a.val)); } OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint8x16, uchar, u8) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int8x16, schar, s8) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint16x8, ushort, u16) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int16x8, short, s16) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint32x4, unsigned, u32) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int32x4, int, s32) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint64x2, uint64, u64) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int64x2, int64, s64) OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64) #endif #define OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ inline scalartype v_reduce_##func(const _Tpvec& a) \ { \ _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ a0 = vp##vectorfunc##_##suffix(a0, a0); \ return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, a0),0); \ } OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, unsigned short, sum, add, u16) OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, unsigned short, max, max, u16) OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, unsigned short, min, min, u16) OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, sum, add, s16) OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, max, max, s16) OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, min, min, s16) #define OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ inline scalartype v_reduce_##func(const _Tpvec& a) \ { \ _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, vget_high_##suffix(a.val)),0); \ } OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, sum, add, u32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, max, max, u32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, min, min, u32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, sum, add, s32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, max, max, s32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, min, min, s32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, sum, add, f32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, max, max, f32) OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, min, min, f32) #if CV_SIMD128_64F inline double v_reduce_sum(const v_float64x2& a) { return vgetq_lane_f64(a.val, 0) + vgetq_lane_f64(a.val, 1); } #endif inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c, const v_float32x4& d) { float32x4x2_t ab = vtrnq_f32(a.val, b.val); float32x4x2_t cd = vtrnq_f32(c.val, d.val); float32x4_t u0 = vaddq_f32(ab.val[0], ab.val[1]); // a0+a1 b0+b1 a2+a3 b2+b3 float32x4_t u1 = vaddq_f32(cd.val[0], cd.val[1]); // c0+c1 d0+d1 c2+c3 d2+d3 float32x4_t v0 = vcombine_f32(vget_low_f32(u0), vget_low_f32(u1)); float32x4_t v1 = vcombine_f32(vget_high_f32(u0), vget_high_f32(u1)); return v_float32x4(vaddq_f32(v0, v1)); } inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) { uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vabdq_u8(a.val, b.val))); uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); return vget_lane_u32(vpadd_u32(t1, t1), 0); } inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) { uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vreinterpretq_u8_s8(vabdq_s8(a.val, b.val)))); uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); return vget_lane_u32(vpadd_u32(t1, t1), 0); } inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) { uint32x4_t t0 = vpaddlq_u16(vabdq_u16(a.val, b.val)); uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); return vget_lane_u32(vpadd_u32(t1, t1), 0); } inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) { uint32x4_t t0 = vpaddlq_u16(vreinterpretq_u16_s16(vabdq_s16(a.val, b.val))); uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); return vget_lane_u32(vpadd_u32(t1, t1), 0); } inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) { uint32x4_t t0 = vabdq_u32(a.val, b.val); uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); return vget_lane_u32(vpadd_u32(t1, t1), 0); } inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) { uint32x4_t t0 = vreinterpretq_u32_s32(vabdq_s32(a.val, b.val)); uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); return vget_lane_u32(vpadd_u32(t1, t1), 0); } inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) { float32x4_t t0 = vabdq_f32(a.val, b.val); float32x2_t t1 = vpadd_f32(vget_low_f32(t0), vget_high_f32(t0)); return vget_lane_f32(vpadd_f32(t1, t1), 0); } #define OPENCV_HAL_IMPL_NEON_POPCOUNT(_Tpvec, cast) \ inline v_uint32x4 v_popcount(const _Tpvec& a) \ { \ uint8x16_t t = vcntq_u8(cast(a.val)); \ uint16x8_t t0 = vpaddlq_u8(t); /* 16 -> 8 */ \ uint32x4_t t1 = vpaddlq_u16(t0); /* 8 -> 4 */ \ return v_uint32x4(t1); \ } OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint8x16, OPENCV_HAL_NOP) OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint16x8, vreinterpretq_u8_u16) OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint32x4, vreinterpretq_u8_u32) OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int8x16, vreinterpretq_u8_s8) OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int16x8, vreinterpretq_u8_s16) OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int32x4, vreinterpretq_u8_s32) inline int v_signmask(const v_uint8x16& a) { int8x8_t m0 = vcreate_s8(CV_BIG_UINT(0x0706050403020100)); uint8x16_t v0 = vshlq_u8(vshrq_n_u8(a.val, 7), vcombine_s8(m0, m0)); uint64x2_t v1 = vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(v0))); return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 8); } inline int v_signmask(const v_int8x16& a) { return v_signmask(v_reinterpret_as_u8(a)); } inline int v_signmask(const v_uint16x8& a) { int16x4_t m0 = vcreate_s16(CV_BIG_UINT(0x0003000200010000)); uint16x8_t v0 = vshlq_u16(vshrq_n_u16(a.val, 15), vcombine_s16(m0, m0)); uint64x2_t v1 = vpaddlq_u32(vpaddlq_u16(v0)); return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 4); } inline int v_signmask(const v_int16x8& a) { return v_signmask(v_reinterpret_as_u16(a)); } inline int v_signmask(const v_uint32x4& a) { int32x2_t m0 = vcreate_s32(CV_BIG_UINT(0x0000000100000000)); uint32x4_t v0 = vshlq_u32(vshrq_n_u32(a.val, 31), vcombine_s32(m0, m0)); uint64x2_t v1 = vpaddlq_u32(v0); return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 2); } inline int v_signmask(const v_int32x4& a) { return v_signmask(v_reinterpret_as_u32(a)); } inline int v_signmask(const v_float32x4& a) { return v_signmask(v_reinterpret_as_u32(a)); } #if CV_SIMD128_64F inline int v_signmask(const v_uint64x2& a) { int64x1_t m0 = vdup_n_s64(0); uint64x2_t v0 = vshlq_u64(vshrq_n_u64(a.val, 63), vcombine_s64(m0, m0)); return (int)vgetq_lane_u64(v0, 0) + ((int)vgetq_lane_u64(v0, 1) << 1); } inline int v_signmask(const v_float64x2& a) { return v_signmask(v_reinterpret_as_u64(a)); } #endif #define OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(_Tpvec, suffix, shift) \ inline bool v_check_all(const v_##_Tpvec& a) \ { \ _Tpvec##_t v0 = vshrq_n_##suffix(vmvnq_##suffix(a.val), shift); \ uint64x2_t v1 = vreinterpretq_u64_##suffix(v0); \ return (vgetq_lane_u64(v1, 0) | vgetq_lane_u64(v1, 1)) == 0; \ } \ inline bool v_check_any(const v_##_Tpvec& a) \ { \ _Tpvec##_t v0 = vshrq_n_##suffix(a.val, shift); \ uint64x2_t v1 = vreinterpretq_u64_##suffix(v0); \ return (vgetq_lane_u64(v1, 0) | vgetq_lane_u64(v1, 1)) != 0; \ } OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint8x16, u8, 7) OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint16x8, u16, 15) OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint32x4, u32, 31) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint64x2, u64, 63) #endif inline bool v_check_all(const v_int8x16& a) { return v_check_all(v_reinterpret_as_u8(a)); } inline bool v_check_all(const v_int16x8& a) { return v_check_all(v_reinterpret_as_u16(a)); } inline bool v_check_all(const v_int32x4& a) { return v_check_all(v_reinterpret_as_u32(a)); } inline bool v_check_all(const v_float32x4& a) { return v_check_all(v_reinterpret_as_u32(a)); } inline bool v_check_any(const v_int8x16& a) { return v_check_any(v_reinterpret_as_u8(a)); } inline bool v_check_any(const v_int16x8& a) { return v_check_any(v_reinterpret_as_u16(a)); } inline bool v_check_any(const v_int32x4& a) { return v_check_any(v_reinterpret_as_u32(a)); } inline bool v_check_any(const v_float32x4& a) { return v_check_any(v_reinterpret_as_u32(a)); } #if CV_SIMD128_64F inline bool v_check_all(const v_int64x2& a) { return v_check_all(v_reinterpret_as_u64(a)); } inline bool v_check_all(const v_float64x2& a) { return v_check_all(v_reinterpret_as_u64(a)); } inline bool v_check_any(const v_int64x2& a) { return v_check_any(v_reinterpret_as_u64(a)); } inline bool v_check_any(const v_float64x2& a) { return v_check_any(v_reinterpret_as_u64(a)); } #endif #define OPENCV_HAL_IMPL_NEON_SELECT(_Tpvec, suffix, usuffix) \ inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ { \ return _Tpvec(vbslq_##suffix(vreinterpretq_##usuffix##_##suffix(mask.val), a.val, b.val)); \ } OPENCV_HAL_IMPL_NEON_SELECT(v_uint8x16, u8, u8) OPENCV_HAL_IMPL_NEON_SELECT(v_int8x16, s8, u8) OPENCV_HAL_IMPL_NEON_SELECT(v_uint16x8, u16, u16) OPENCV_HAL_IMPL_NEON_SELECT(v_int16x8, s16, u16) OPENCV_HAL_IMPL_NEON_SELECT(v_uint32x4, u32, u32) OPENCV_HAL_IMPL_NEON_SELECT(v_int32x4, s32, u32) OPENCV_HAL_IMPL_NEON_SELECT(v_float32x4, f32, u32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_SELECT(v_float64x2, f64, u64) #endif #define OPENCV_HAL_IMPL_NEON_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix) \ inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ { \ b0.val = vmovl_##suffix(vget_low_##suffix(a.val)); \ b1.val = vmovl_##suffix(vget_high_##suffix(a.val)); \ } \ inline _Tpwvec v_expand_low(const _Tpvec& a) \ { \ return _Tpwvec(vmovl_##suffix(vget_low_##suffix(a.val))); \ } \ inline _Tpwvec v_expand_high(const _Tpvec& a) \ { \ return _Tpwvec(vmovl_##suffix(vget_high_##suffix(a.val))); \ } \ inline _Tpwvec v_load_expand(const _Tp* ptr) \ { \ return _Tpwvec(vmovl_##suffix(vld1_##suffix(ptr))); \ } OPENCV_HAL_IMPL_NEON_EXPAND(v_uint8x16, v_uint16x8, uchar, u8) OPENCV_HAL_IMPL_NEON_EXPAND(v_int8x16, v_int16x8, schar, s8) OPENCV_HAL_IMPL_NEON_EXPAND(v_uint16x8, v_uint32x4, ushort, u16) OPENCV_HAL_IMPL_NEON_EXPAND(v_int16x8, v_int32x4, short, s16) OPENCV_HAL_IMPL_NEON_EXPAND(v_uint32x4, v_uint64x2, uint, u32) OPENCV_HAL_IMPL_NEON_EXPAND(v_int32x4, v_int64x2, int, s32) inline v_uint32x4 v_load_expand_q(const uchar* ptr) { uint8x8_t v0 = vcreate_u8(*(unsigned*)ptr); uint16x4_t v1 = vget_low_u16(vmovl_u8(v0)); return v_uint32x4(vmovl_u16(v1)); } inline v_int32x4 v_load_expand_q(const schar* ptr) { int8x8_t v0 = vcreate_s8(*(unsigned*)ptr); int16x4_t v1 = vget_low_s16(vmovl_s8(v0)); return v_int32x4(vmovl_s16(v1)); } #if defined(__aarch64__) #define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \ inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ { \ b0.val = vzip1q_##suffix(a0.val, a1.val); \ b1.val = vzip2q_##suffix(a0.val, a1.val); \ } \ inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ { \ return v_##_Tpvec(vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val))); \ } \ inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ { \ return v_##_Tpvec(vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val))); \ } \ inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ { \ c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \ d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \ } #else #define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \ inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ { \ _Tpvec##x2_t p = vzipq_##suffix(a0.val, a1.val); \ b0.val = p.val[0]; \ b1.val = p.val[1]; \ } \ inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ { \ return v_##_Tpvec(vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val))); \ } \ inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ { \ return v_##_Tpvec(vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val))); \ } \ inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ { \ c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \ d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \ } #endif OPENCV_HAL_IMPL_NEON_UNPACKS(uint8x16, u8) OPENCV_HAL_IMPL_NEON_UNPACKS(int8x16, s8) OPENCV_HAL_IMPL_NEON_UNPACKS(uint16x8, u16) OPENCV_HAL_IMPL_NEON_UNPACKS(int16x8, s16) OPENCV_HAL_IMPL_NEON_UNPACKS(uint32x4, u32) OPENCV_HAL_IMPL_NEON_UNPACKS(int32x4, s32) OPENCV_HAL_IMPL_NEON_UNPACKS(float32x4, f32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_UNPACKS(float64x2, f64) #endif #define OPENCV_HAL_IMPL_NEON_EXTRACT(_Tpvec, suffix) \ template <int s> \ inline v_##_Tpvec v_extract(const v_##_Tpvec& a, const v_##_Tpvec& b) \ { \ return v_##_Tpvec(vextq_##suffix(a.val, b.val, s)); \ } OPENCV_HAL_IMPL_NEON_EXTRACT(uint8x16, u8) OPENCV_HAL_IMPL_NEON_EXTRACT(int8x16, s8) OPENCV_HAL_IMPL_NEON_EXTRACT(uint16x8, u16) OPENCV_HAL_IMPL_NEON_EXTRACT(int16x8, s16) OPENCV_HAL_IMPL_NEON_EXTRACT(uint32x4, u32) OPENCV_HAL_IMPL_NEON_EXTRACT(int32x4, s32) OPENCV_HAL_IMPL_NEON_EXTRACT(uint64x2, u64) OPENCV_HAL_IMPL_NEON_EXTRACT(int64x2, s64) OPENCV_HAL_IMPL_NEON_EXTRACT(float32x4, f32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_EXTRACT(float64x2, f64) #endif #if CV_SIMD128_64F inline v_int32x4 v_round(const v_float32x4& a) { float32x4_t a_ = a.val; int32x4_t result; __asm__ ("fcvtns %0.4s, %1.4s" : "=w"(result) : "w"(a_) : /* No clobbers */); return v_int32x4(result); } #else inline v_int32x4 v_round(const v_float32x4& a) { static const int32x4_t v_sign = vdupq_n_s32(1 << 31), v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f)); int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(a.val))); return v_int32x4(vcvtq_s32_f32(vaddq_f32(a.val, vreinterpretq_f32_s32(v_addition)))); } #endif inline v_int32x4 v_floor(const v_float32x4& a) { int32x4_t a1 = vcvtq_s32_f32(a.val); uint32x4_t mask = vcgtq_f32(vcvtq_f32_s32(a1), a.val); return v_int32x4(vaddq_s32(a1, vreinterpretq_s32_u32(mask))); } inline v_int32x4 v_ceil(const v_float32x4& a) { int32x4_t a1 = vcvtq_s32_f32(a.val); uint32x4_t mask = vcgtq_f32(a.val, vcvtq_f32_s32(a1)); return v_int32x4(vsubq_s32(a1, vreinterpretq_s32_u32(mask))); } inline v_int32x4 v_trunc(const v_float32x4& a) { return v_int32x4(vcvtq_s32_f32(a.val)); } #if CV_SIMD128_64F inline v_int32x4 v_round(const v_float64x2& a) { static const int32x2_t zero = vdup_n_s32(0); return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero)); } inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) { return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), vmovn_s64(vcvtaq_s64_f64(b.val)))); } inline v_int32x4 v_floor(const v_float64x2& a) { static const int32x2_t zero = vdup_n_s32(0); int64x2_t a1 = vcvtq_s64_f64(a.val); uint64x2_t mask = vcgtq_f64(vcvtq_f64_s64(a1), a.val); a1 = vaddq_s64(a1, vreinterpretq_s64_u64(mask)); return v_int32x4(vcombine_s32(vmovn_s64(a1), zero)); } inline v_int32x4 v_ceil(const v_float64x2& a) { static const int32x2_t zero = vdup_n_s32(0); int64x2_t a1 = vcvtq_s64_f64(a.val); uint64x2_t mask = vcgtq_f64(a.val, vcvtq_f64_s64(a1)); a1 = vsubq_s64(a1, vreinterpretq_s64_u64(mask)); return v_int32x4(vcombine_s32(vmovn_s64(a1), zero)); } inline v_int32x4 v_trunc(const v_float64x2& a) { static const int32x2_t zero = vdup_n_s32(0); return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero)); } #endif #define OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(_Tpvec, suffix) \ inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \ const v_##_Tpvec& a2, const v_##_Tpvec& a3, \ v_##_Tpvec& b0, v_##_Tpvec& b1, \ v_##_Tpvec& b2, v_##_Tpvec& b3) \ { \ /* m00 m01 m02 m03 */ \ /* m10 m11 m12 m13 */ \ /* m20 m21 m22 m23 */ \ /* m30 m31 m32 m33 */ \ _Tpvec##x2_t t0 = vtrnq_##suffix(a0.val, a1.val); \ _Tpvec##x2_t t1 = vtrnq_##suffix(a2.val, a3.val); \ /* m00 m10 m02 m12 */ \ /* m01 m11 m03 m13 */ \ /* m20 m30 m22 m32 */ \ /* m21 m31 m23 m33 */ \ b0.val = vcombine_##suffix(vget_low_##suffix(t0.val[0]), vget_low_##suffix(t1.val[0])); \ b1.val = vcombine_##suffix(vget_low_##suffix(t0.val[1]), vget_low_##suffix(t1.val[1])); \ b2.val = vcombine_##suffix(vget_high_##suffix(t0.val[0]), vget_high_##suffix(t1.val[0])); \ b3.val = vcombine_##suffix(vget_high_##suffix(t0.val[1]), vget_high_##suffix(t1.val[1])); \ } OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(uint32x4, u32) OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(int32x4, s32) OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(float32x4, f32) #define OPENCV_HAL_IMPL_NEON_INTERLEAVED(_Tpvec, _Tp, suffix) \ inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \ { \ _Tpvec##x2_t v = vld2q_##suffix(ptr); \ a.val = v.val[0]; \ b.val = v.val[1]; \ } \ inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \ { \ _Tpvec##x3_t v = vld3q_##suffix(ptr); \ a.val = v.val[0]; \ b.val = v.val[1]; \ c.val = v.val[2]; \ } \ inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \ v_##_Tpvec& c, v_##_Tpvec& d) \ { \ _Tpvec##x4_t v = vld4q_##suffix(ptr); \ a.val = v.val[0]; \ b.val = v.val[1]; \ c.val = v.val[2]; \ d.val = v.val[3]; \ } \ inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ { \ _Tpvec##x2_t v; \ v.val[0] = a.val; \ v.val[1] = b.val; \ vst2q_##suffix(ptr, v); \ } \ inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ const v_##_Tpvec& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ { \ _Tpvec##x3_t v; \ v.val[0] = a.val; \ v.val[1] = b.val; \ v.val[2] = c.val; \ vst3q_##suffix(ptr, v); \ } \ inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ const v_##_Tpvec& c, const v_##_Tpvec& d, \ hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ { \ _Tpvec##x4_t v; \ v.val[0] = a.val; \ v.val[1] = b.val; \ v.val[2] = c.val; \ v.val[3] = d.val; \ vst4q_##suffix(ptr, v); \ } #define OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(tp, suffix) \ inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, v_##tp##x2& b ) \ { \ tp##x1_t a0 = vld1_##suffix(ptr); \ tp##x1_t b0 = vld1_##suffix(ptr + 1); \ tp##x1_t a1 = vld1_##suffix(ptr + 2); \ tp##x1_t b1 = vld1_##suffix(ptr + 3); \ a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ } \ \ inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, \ v_##tp##x2& b, v_##tp##x2& c ) \ { \ tp##x1_t a0 = vld1_##suffix(ptr); \ tp##x1_t b0 = vld1_##suffix(ptr + 1); \ tp##x1_t c0 = vld1_##suffix(ptr + 2); \ tp##x1_t a1 = vld1_##suffix(ptr + 3); \ tp##x1_t b1 = vld1_##suffix(ptr + 4); \ tp##x1_t c1 = vld1_##suffix(ptr + 5); \ a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ c = v_##tp##x2(vcombine_##suffix(c0, c1)); \ } \ \ inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, v_##tp##x2& b, \ v_##tp##x2& c, v_##tp##x2& d ) \ { \ tp##x1_t a0 = vld1_##suffix(ptr); \ tp##x1_t b0 = vld1_##suffix(ptr + 1); \ tp##x1_t c0 = vld1_##suffix(ptr + 2); \ tp##x1_t d0 = vld1_##suffix(ptr + 3); \ tp##x1_t a1 = vld1_##suffix(ptr + 4); \ tp##x1_t b1 = vld1_##suffix(ptr + 5); \ tp##x1_t c1 = vld1_##suffix(ptr + 6); \ tp##x1_t d1 = vld1_##suffix(ptr + 7); \ a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ c = v_##tp##x2(vcombine_##suffix(c0, c1)); \ d = v_##tp##x2(vcombine_##suffix(d0, d1)); \ } \ \ inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, const v_##tp##x2& b, \ hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ { \ vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ vst1_##suffix(ptr + 2, vget_high_##suffix(a.val)); \ vst1_##suffix(ptr + 3, vget_high_##suffix(b.val)); \ } \ \ inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, \ const v_##tp##x2& b, const v_##tp##x2& c, \ hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ { \ vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ vst1_##suffix(ptr + 2, vget_low_##suffix(c.val)); \ vst1_##suffix(ptr + 3, vget_high_##suffix(a.val)); \ vst1_##suffix(ptr + 4, vget_high_##suffix(b.val)); \ vst1_##suffix(ptr + 5, vget_high_##suffix(c.val)); \ } \ \ inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, const v_##tp##x2& b, \ const v_##tp##x2& c, const v_##tp##x2& d, \ hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ { \ vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ vst1_##suffix(ptr + 2, vget_low_##suffix(c.val)); \ vst1_##suffix(ptr + 3, vget_low_##suffix(d.val)); \ vst1_##suffix(ptr + 4, vget_high_##suffix(a.val)); \ vst1_##suffix(ptr + 5, vget_high_##suffix(b.val)); \ vst1_##suffix(ptr + 6, vget_high_##suffix(c.val)); \ vst1_##suffix(ptr + 7, vget_high_##suffix(d.val)); \ } OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint8x16, uchar, u8) OPENCV_HAL_IMPL_NEON_INTERLEAVED(int8x16, schar, s8) OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint16x8, ushort, u16) OPENCV_HAL_IMPL_NEON_INTERLEAVED(int16x8, short, s16) OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint32x4, unsigned, u32) OPENCV_HAL_IMPL_NEON_INTERLEAVED(int32x4, int, s32) OPENCV_HAL_IMPL_NEON_INTERLEAVED(float32x4, float, f32) #if CV_SIMD128_64F OPENCV_HAL_IMPL_NEON_INTERLEAVED(float64x2, double, f64) #endif OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(int64, s64) OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(uint64, u64) inline v_float32x4 v_cvt_f32(const v_int32x4& a) { return v_float32x4(vcvtq_f32_s32(a.val)); } #if CV_SIMD128_64F inline v_float32x4 v_cvt_f32(const v_float64x2& a) { float32x2_t zero = vdup_n_f32(0.0f); return v_float32x4(vcombine_f32(vcvt_f32_f64(a.val), zero)); } inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) { return v_float32x4(vcombine_f32(vcvt_f32_f64(a.val), vcvt_f32_f64(b.val))); } inline v_float64x2 v_cvt_f64(const v_int32x4& a) { return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_low_s32(a.val)))); } inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) { return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_high_s32(a.val)))); } inline v_float64x2 v_cvt_f64(const v_float32x4& a) { return v_float64x2(vcvt_f64_f32(vget_low_f32(a.val))); } inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) { return v_float64x2(vcvt_f64_f32(vget_high_f32(a.val))); } #endif ////////////// Lookup table access //////////////////// inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) { int CV_DECL_ALIGNED(32) elems[4] = { tab[vgetq_lane_s32(idxvec.val, 0)], tab[vgetq_lane_s32(idxvec.val, 1)], tab[vgetq_lane_s32(idxvec.val, 2)], tab[vgetq_lane_s32(idxvec.val, 3)] }; return v_int32x4(vld1q_s32(elems)); } inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) { float CV_DECL_ALIGNED(32) elems[4] = { tab[vgetq_lane_s32(idxvec.val, 0)], tab[vgetq_lane_s32(idxvec.val, 1)], tab[vgetq_lane_s32(idxvec.val, 2)], tab[vgetq_lane_s32(idxvec.val, 3)] }; return v_float32x4(vld1q_f32(elems)); } inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) { /*int CV_DECL_ALIGNED(32) idx[4]; v_store(idx, idxvec); float32x4_t xy02 = vcombine_f32(vld1_f32(tab + idx[0]), vld1_f32(tab + idx[2])); float32x4_t xy13 = vcombine_f32(vld1_f32(tab + idx[1]), vld1_f32(tab + idx[3])); float32x4x2_t xxyy = vuzpq_f32(xy02, xy13); x = v_float32x4(xxyy.val[0]); y = v_float32x4(xxyy.val[1]);*/ int CV_DECL_ALIGNED(32) idx[4]; v_store_aligned(idx, idxvec); x = v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); y = v_float32x4(tab[idx[0]+1], tab[idx[1]+1], tab[idx[2]+1], tab[idx[3]+1]); } #if CV_SIMD128_64F inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) { double CV_DECL_ALIGNED(32) elems[2] = { tab[vgetq_lane_s32(idxvec.val, 0)], tab[vgetq_lane_s32(idxvec.val, 1)], }; return v_float64x2(vld1q_f64(elems)); } inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) { int CV_DECL_ALIGNED(32) idx[4]; v_store_aligned(idx, idxvec); x = v_float64x2(tab[idx[0]], tab[idx[1]]); y = v_float64x2(tab[idx[0]+1], tab[idx[1]+1]); } #endif ////// FP16 suport /////// #if CV_FP16 inline v_float32x4 v_load_expand(const float16_t* ptr) { float16x4_t v = #ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro (float16x4_t)vld1_s16((const short*)ptr); #else vld1_f16((const __fp16*)ptr); #endif return v_float32x4(vcvt_f32_f16(v)); } inline void v_pack_store(float16_t* ptr, const v_float32x4& v) { float16x4_t hv = vcvt_f16_f32(v.val); #ifndef vst1_f16 // APPLE compiler defines vst1_f16 as macro vst1_s16((short*)ptr, (int16x4_t)hv); #else vst1_f16((__fp16*)ptr, hv); #endif } #else inline v_float32x4 v_load_expand(const float16_t* ptr) { const int N = 4; float buf[N]; for( int i = 0; i < N; i++ ) buf[i] = (float)ptr[i]; return v_load(buf); } inline void v_pack_store(float16_t* ptr, const v_float32x4& v) { const int N = 4; float buf[N]; v_store(buf, v); for( int i = 0; i < N; i++ ) ptr[i] = float16_t(buf[i]); } #endif inline void v_cleanup() {} //! @name Check SIMD support //! @{ //! @brief Check CPU capability of SIMD operation static inline bool hasSIMD128() { return (CV_CPU_HAS_SUPPORT_NEON) ? true : false; } //! @} CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END //! @endcond } #endif
[ "qingpeng.liu@horizon.ai" ]
qingpeng.liu@horizon.ai
fb2f013c32dab39a97caef773ef5ba626ae401ec
e50b5f066628ef65fd7f79078b4b1088f9d11e87
/llvm/tools/clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp
7c9714584ae4154586106fb09845266cc5a24e23
[ "NCSA" ]
permissive
uzleo/coast
1471e03b2a1ffc9883392bf80711e6159917dca1
04bd688ac9a18d2327c59ea0c90f72e9b49df0f4
refs/heads/master
2020-05-16T11:46:24.870750
2019-04-23T13:57:53
2019-04-23T13:57:53
183,025,687
0
0
null
2019-04-23T13:52:28
2019-04-23T13:52:27
null
UTF-8
C++
false
false
1,213
cpp
// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -o - %s | FileCheck %s // CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5 // CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0 // CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8 // CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8 // CHECK: %[[BLOCK_CAPTURED1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK]], i32 0, i32 6 // CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], %[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1 // CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8 // CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8 void foo1(int &, int &); void block_in_lambda(int &s1, int &s2) { auto lambda = [&s1, &s2]() { auto block = ^{ foo1(s1, s2); }; block(); }; lambda(); }
[ "jeffrey.goeders@gmail.com" ]
jeffrey.goeders@gmail.com