blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
a556f373223b8e189a6d500780339cf9427758b7
ac54df7515acffb0b490d30d9a7a93109ba1e987
/策略模式(Strategy Pattern)/策略模式(Strategy Pattern)/context.h
0ef1dcc44969e0a0df443753a591f688f1c73e2b
[]
no_license
letwant/Design-pattern
504a4a60e3783346af1da5f37b446c4d621b47e2
34685a74fc65530432e28874781d1fd689d837a6
refs/heads/master
2020-06-20T03:19:45.318263
2019-07-18T08:07:11
2019-07-18T08:07:11
196,972,988
1
0
null
null
null
null
UTF-8
C++
false
false
196
h
#pragma once #include "strategy.h" class Context { public: Context(IStragegy *strategy) { m_pStrategy = strategy; } void Travel() { m_pStrategy->Travel(); } private: IStragegy *m_pStrategy; };
[ "xiafei@originqc.com" ]
xiafei@originqc.com
f1611d3abd410f391fd7c9b69cfd5c597f43aaa5
1dd397fa88b66877c669711f8a479c2fe61de440
/regression/cpp-from-CVS/static_cast3/main.cpp
72c01c11d25500c1ea32ea5a6808dcc4833034ad
[ "MIT", "BSD-2-Clause" ]
permissive
fanhy2114/yogar-cbmc
bc707ccb927f6e5a2c23c188619e7bb997d9369e
4e61ef2853158bf183f9fe31b12bf048cefa643a
refs/heads/master
2020-04-17T10:27:50.033647
2019-12-30T13:43:35
2019-12-30T13:43:35
166,502,179
1
1
NOASSERTION
2019-01-19T03:32:21
2019-01-19T03:32:21
null
UTF-8
C++
false
false
233
cpp
struct A { int i; }; struct B { char j; }; struct C: A, B { bool k; }; int main() { C c; c.k = true; B& b = c; assert((static_cast<C&>(b)).k == true); B* pb = &c; static_cast<C*>(pb)->k = false; assert(c.k==false); }
[ "yinliangze@163.com" ]
yinliangze@163.com
a1b47c91ffd9ca60137b43d0257d53a08aa4f626
5c209f260337fd080bccd8b3a60fee6cf5243635
/ShowGraf/GraphItem.cpp
8a405c94b1d6a3bf83844067f0b02c280d6769f6
[]
no_license
Sopel97/Big-Numbers
c1b22458c166fcde54c8532b8489534bf88a6839
a83dfaaf1d19eee5c075a20bf270b28c770f2d35
refs/heads/master
2020-07-26T03:06:26.093330
2018-10-28T13:49:11
2018-10-28T13:49:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,424
cpp
#include "stdafx.h" #include "GraphItem.h" GraphItem::GraphItem(Graph *g) { m_graph = g; m_graph->setVisible(true); } COLORREF getComplementColor(COLORREF color) { return RGB(255-GetRValue(color),255-GetGValue(color),255-GetBValue(color)); } void GraphItem::paintButton(CDC &dc, bool selected) const { const CString buttonText = m_graph->getParam().getDisplayName().cstr(); dc.FillSolidRect(&m_buttonRect,m_graph->getParam().m_color); CRect tr = m_buttonRect; tr.left += 5; tr.top += 4; tr.right -= 3; tr.bottom -= 3; COLORREF color = m_graph->getParam().m_color; dc.SetBkColor(color); // CSize cs = dc.GetTextExtent(buttonText.cstr()); COLORREF textColor = getComplementColor(color); dc.SetTextColor(textColor); dc.DrawText(buttonText, &tr, DT_END_ELLIPSIS); // dc.TextOut(m_buttonRect.left + (m_buttonRect.Width()-cs.cx)/2,m_buttonRect.top+3,buttonText.cstr()); DrawEdge(dc.m_hDC,&m_buttonRect,EDGE_RAISED,BF_RECT); if(selected) { CRect fr = m_buttonRect; fr.top +=3; fr.left += 3; fr.bottom -= 3; fr.right -= 3; DrawFocusRect(dc.m_hDC,&fr); } } void GraphItem::paint(CCoordinateSystem &cs, CFont &buttonFont, bool selected) const { Viewport2D &vp = cs.getViewport(); if(m_graph->isVisible()) { vp.setClipping(true); m_graph->paint(cs); vp.setClipping(false); } CDC &dc = *vp.getDC(); dc.SelectObject(buttonFont); paintButton(dc, selected); }
[ "jesper.gr.mikkelsen@gmail.com" ]
jesper.gr.mikkelsen@gmail.com
1734f7a06460e1f252ece0ceaf6efcc1e3b5413f
f25242e9c9b3e6741d714a3d8741c2f56b216951
/md5/src/md5.h
776de69b57323b5c3132036ce3aeca449a823475
[]
no_license
soloapple/c_sock_basic_tools
9edc53bcc1891f5080698fbe6fbe915bc1702e14
f94431c398492969ee1859134f0f3467ed74302b
refs/heads/master
2021-01-24T01:35:12.772767
2017-07-05T07:49:34
2017-07-05T07:49:34
68,290,620
0
0
null
null
null
null
GB18030
C++
false
false
3,286
h
/****************************************************************************** * Copyright (C), 2017, X Co., Ltd. * * Filename: pp_md5.h * Description: * Version: 1.0 * Created: soloapple 2017年06月08日 22时35分48秒 * Revision: none * * History: <author> <time> <version > <desc> * soloapple 2017年06月08日 build this moudle *****************************************************************************/ /** * @file md5.h * @The header file of md5. * @author Jiewei Wei * @mail weijieweijerry@163.com * @github https://github.com/JieweiWei * @data Oct 19 2014 * */ #ifndef MD5_H #define MD5_H /* Parameters of MD5. */ #define s11 7 #define s12 12 #define s13 17 #define s14 22 #define s21 5 #define s22 9 #define s23 14 #define s24 20 #define s31 4 #define s32 11 #define s33 16 #define s34 23 #define s41 6 #define s42 10 #define s43 15 #define s44 21 /** * @Basic MD5 functions. * * @param there bit32. * * @return one bit32. */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) /** * @Rotate Left. * * @param {num} the raw number. * * @param {n} rotate left n. * * @return the number after rotated left. */ #define ROTATELEFT(num, n) (((num) << (n)) | ((num) >> (32-(n)))) /** * @Transformations for rounds 1, 2, 3, and 4. */ #define FF(a, b, c, d, x, s, ac) { \ (a) += F ((b), (c), (d)) + (x) + ac; \ (a) = ROTATELEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ (a) += G ((b), (c), (d)) + (x) + ac; \ (a) = ROTATELEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ (a) += H ((b), (c), (d)) + (x) + ac; \ (a) = ROTATELEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ (a) += I ((b), (c), (d)) + (x) + ac; \ (a) = ROTATELEFT ((a), (s)); \ (a) += (b); \ } #include <string> #include <cstring> using std::string; /* Define of btye.*/ typedef unsigned char byte; /* Define of byte. */ typedef unsigned int bit32; class MD5 { public: /* Construct a MD5 object with a string. */ MD5(const string& message); /* Generate md5 digest. */ const byte* getDigest(); /* Convert digest to string value */ string toStr(); private: /* Initialization the md5 object, processing another message block, * and updating the context.*/ void init(const byte* input, size_t len); /* MD5 basic transformation. Transforms state based on block. */ void transform(const byte block[64]); /* Encodes input (usigned long) into output (byte). */ void encode(const bit32* input, byte* output, size_t length); /* Decodes input (byte) into output (usigned long). */ void decode(const byte* input, bit32* output, size_t length); private: /* Flag for mark whether calculate finished. */ bool finished; /* state (ABCD). */ bit32 state[4]; /* number of bits, low-order word first. */ bit32 count[2]; /* input buffer. */ byte buffer[64]; /* message digest. */ byte digest[16]; /* padding for calculate. */ static const byte PADDING[64]; /* Hex numbers. */ static const char HEX_NUMBERS[16]; }; #endif // MD5_H
[ "491870666@qq.com" ]
491870666@qq.com
7aaff00b37f6e70f06d0395c42600cab68050679
2485ffe62134cd39d4c5cf12f8e73ca9ef781dd1
/contrib/boost/container/bench/bench_vectors.cpp
e0bd66520f879131818f1093a98c445584033a71
[ "BSL-1.0", "MIT" ]
permissive
alesapin/XMorphy
1aed0c8e0f8e74efac9523f4d6e585e5223105ee
aaf1d5561cc9227691331a515ca3bc94ed6cc0f1
refs/heads/master
2023-04-16T09:27:58.731844
2023-04-08T17:15:26
2023-04-08T17:15:26
97,373,549
37
5
MIT
2023-04-08T17:15:27
2017-07-16T09:35:41
C++
UTF-8
C++
false
false
10,129
cpp
////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2007-2013. 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) // // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// #include <vector> #include <deque> #include <boost/container/vector.hpp> #include <boost/container/deque.hpp> #include <boost/container/devector.hpp> #include <boost/container/small_vector.hpp> #include <boost/container/stable_vector.hpp> #include <iomanip> #include <memory> //std::allocator #include <iostream> //std::cout, std::endl #include <cstring> //std::strcmp #include <boost/move/detail/nsec_clock.hpp> #include <typeinfo> #if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-result" #endif //capacity #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME capacity #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace test { #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0 #include <boost/intrusive/detail/has_member_function_callable_with.hpp> //#pragma GCC diagnostic ignored "-Wunused-result" #if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #pragma GCC diagnostic pop #endif using boost::move_detail::cpu_timer; using boost::move_detail::cpu_times; using boost::move_detail::nanosecond_type; namespace bc = boost::container; class MyInt { int int_; public: BOOST_CONTAINER_FORCEINLINE explicit MyInt(int i = 0) : int_(i) {} BOOST_CONTAINER_FORCEINLINE MyInt(const MyInt &other) : int_(other.int_) {} BOOST_CONTAINER_FORCEINLINE MyInt & operator=(const MyInt &other) { int_ = other.int_; return *this; } BOOST_CONTAINER_FORCEINLINE ~MyInt() { int_ = 0; } }; template<class C, bool = boost::container::test:: has_member_function_callable_with_capacity<C>::value> struct capacity_wrapper { BOOST_CONTAINER_FORCEINLINE static typename C::size_type get_capacity(const C &c) { return c.capacity(); } BOOST_CONTAINER_FORCEINLINE static void set_reserve(C &c, typename C::size_type cp) { c.reserve(cp); } }; template<class C> struct capacity_wrapper<C, false> { BOOST_CONTAINER_FORCEINLINE static typename C::size_type get_capacity(const C &) { return 0u; } BOOST_CONTAINER_FORCEINLINE static void set_reserve(C &, typename C::size_type ) { } }; const std::size_t RangeSize = 5; struct insert_end_range { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return RangeSize; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C &c, int) { c.insert(c.end(), &a[0], &a[0]+RangeSize); } const char *name() const { return "insert_end_range"; } MyInt a[RangeSize]; }; struct insert_end_repeated { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return RangeSize; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C &c, int i) { c.insert(c.end(), RangeSize, MyInt(i)); } BOOST_CONTAINER_FORCEINLINE const char *name() const { return "insert_end_repeated"; } MyInt a[RangeSize]; }; struct push_back { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return 1; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C &c, int i) { c.push_back(MyInt(i)); } BOOST_CONTAINER_FORCEINLINE const char *name() const { return "push_back"; } }; struct emplace_back { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return 1; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C &c, int i) { c.emplace_back(i); } BOOST_CONTAINER_FORCEINLINE const char *name() const { return "emplace_back"; } }; struct insert_near_end_repeated { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return RangeSize; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C &c, int i) { c.insert(c.size() >= 2*RangeSize ? c.end()-2*RangeSize : c.begin(), RangeSize, MyInt(i)); } BOOST_CONTAINER_FORCEINLINE const char *name() const { return "insert_near_end_repeated"; } }; struct insert_near_end_range { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return RangeSize; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C &c, int) { c.insert(c.size() >= 2*RangeSize ? c.end()-2*RangeSize : c.begin(), &a[0], &a[0]+RangeSize); } BOOST_CONTAINER_FORCEINLINE const char *name() const { return "insert_near_end_range"; } MyInt a[RangeSize]; }; struct insert_near_end { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return 1; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C &c, int i) { typedef typename C::iterator it_t; it_t it (c.end()); it -= static_cast<typename C::difference_type>(c.size() >= 2)*2; c.insert(it, MyInt(i)); } BOOST_CONTAINER_FORCEINLINE const char *name() const { return "insert_near_end"; } }; struct emplace_near_end { BOOST_CONTAINER_FORCEINLINE std::size_t capacity_multiplier() const { return 1; } template<class C> BOOST_CONTAINER_FORCEINLINE void operator()(C& c, int i) { typedef typename C::iterator it_t; it_t it(c.end()); it -= static_cast<typename C::difference_type>(c.size() >= 2) * 2; c.emplace(it, i); } BOOST_CONTAINER_FORCEINLINE const char* name() const { return "emplace_near_end"; } }; template<class Container, class Operation> void vector_test_template(std::size_t num_iterations, std::size_t num_elements, const char *cont_name, bool prereserve = true) { typedef capacity_wrapper<Container> cpw_t; Operation op; const typename Container::size_type multiplier = op.capacity_multiplier(); Container c; if (prereserve) { cpw_t::set_reserve(c, num_elements); } cpu_timer timer; const std::size_t max = num_elements/multiplier; for(std::size_t r = 0; r != num_iterations; ++r){ //Unroll the loop to avoid noise from loop code int i = 0; if (r > 0) //Exclude first iteration to avoid noise timer.resume(); for(std::size_t e = 0; e < max/16; ++e){ op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); op(c, static_cast<int>(i++)); } if (r > 0) timer.stop(); c.clear(); } timer.stop(); std::size_t capacity = cpw_t::get_capacity(c); nanosecond_type nseconds = timer.elapsed().wall; std::cout << cont_name << "->" << op.name() <<" ns: " << std::setw(8) << float(nseconds)/float((num_iterations-1)*num_elements) << '\t' << "Capacity: " << capacity << std::endl; } template<class Operation> void test_vectors() { //#define SINGLE_TEST #define SIMPLE_IT #ifdef SINGLE_TEST #ifdef NDEBUG std::size_t numit [] = { 1000 }; #else std::size_t numit [] = { 20 }; #endif std::size_t numele [] = { 100000 }; #elif defined SIMPLE_IT std::size_t numit [] = { 100 }; std::size_t numele [] = { 100000 }; #else #ifdef NDEBUG unsigned int numit [] = { 1000, 10000, 100000, 1000000 }; #else unsigned int numit [] = { 100, 1000, 10000, 100000 }; #endif unsigned int numele [] = { 10000, 1000, 100, 10 }; #endif //#define PRERESERVE_ONLY #ifdef PRERESERVE_ONLY #define P_INIT 1 #else #define P_INIT 0 #endif for (unsigned p = P_INIT; p != 2; ++p) { std::cout << Operation().name() << ", prereserve: " << (p ? "1" : "0") << "\n" << std::endl; const bool bp =p != 0; for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template< std::vector<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "std::vector ", bp); vector_test_template< bc::vector<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i] , "vector ", bp); vector_test_template< bc::small_vector<MyInt, 0, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "small_vector ", bp); vector_test_template< bc::devector<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "devector ", bp); //vector_test_template< std::deque<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "std::deque ", bp); vector_test_template< bc::deque<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "deque ", bp); } std::cout << "---------------------------------\n---------------------------------\n"; } } int main() { //end test_vectors<push_back>(); test_vectors<insert_end_range>(); test_vectors<insert_end_repeated>(); //near end test_vectors<insert_near_end>(); test_vectors<insert_near_end_range>(); test_vectors<insert_near_end_repeated>(); #if BOOST_CXX_VERSION >= 201103L test_vectors<emplace_back>(); test_vectors<emplace_near_end>(); #endif return 0; }
[ "alesapin@gmail.com" ]
alesapin@gmail.com
e1ff9c9a92bfb5a5c860d52af2244c53a766023e
19fb0eb26f5a6d2180a323cf242ce00f5e4e1c6d
/src/zegg/zeggtracker.h
62947d699ebcea745b9f326bb8124606aa116f1d
[ "MIT" ]
permissive
j00v/NestEGG
bd4c9555f6473cc655e203531c6ab4d0dc795b61
8c507974a5d49f5ffa7000fa8b864a528dcb9c3e
refs/heads/master
2022-12-03T09:16:14.732378
2020-08-12T15:25:31
2020-08-12T15:25:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,280
h
// Copyright (c) 2018-2020 The NESTEGG developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef NESTEGG_ZEGGTRACKER_H #define NESTEGG_ZEGGTRACKER_H #include "zerocoin.h" #include "witness.h" #include "sync.h" #include <list> class CDeterministicMint; class CzEGGWallet; class CzEGGTracker { private: bool fInitialized; std::string strWalletFile; std::map<uint256, CMintMeta> mapSerialHashes; std::map<uint256, uint256> mapPendingSpends; //serialhash, txid of spend bool UpdateStatusInternal(const std::set<uint256>& setMempool, CMintMeta& mint); public: CzEGGTracker(std::string strWalletFile); ~CzEGGTracker(); void Add(const CDeterministicMint& dMint, bool isNew = false, bool isArchived = false, CzEGGWallet* zEGGWallet = NULL); void Add(const CZerocoinMint& mint, bool isNew = false, bool isArchived = false); bool Archive(CMintMeta& meta); bool HasPubcoin(const CBigNum& bnValue) const; bool HasPubcoinHash(const uint256& hashPubcoin) const; bool HasSerial(const CBigNum& bnSerial) const; bool HasSerialHash(const uint256& hashSerial) const; bool HasMintTx(const uint256& txid); bool IsEmpty() const { return mapSerialHashes.empty(); } void Init(); CMintMeta Get(const uint256& hashSerial); CMintMeta GetMetaFromPubcoin(const uint256& hashPubcoin); bool GetMetaFromStakeHash(const uint256& hashStake, CMintMeta& meta) const; CAmount GetBalance(bool fConfirmedOnly, bool fUnconfirmedOnly) const; std::vector<uint256> GetSerialHashes(); std::vector<CMintMeta> GetMints(bool fConfirmedOnly) const; CAmount GetUnconfirmedBalance() const; std::set<CMintMeta> ListMints(bool fUnusedOnly, bool fMatureOnly, bool fUpdateStatus, bool fWrongSeed = false, bool fExcludeV1 = false); void RemovePending(const uint256& txid); void SetPubcoinUsed(const uint256& hashPubcoin, const uint256& txid); void SetPubcoinNotUsed(const uint256& hashPubcoin); bool UnArchive(const uint256& hashPubcoin, bool isDeterministic); bool UpdateZerocoinMint(const CZerocoinMint& mint); bool UpdateState(const CMintMeta& meta); void Clear(); }; #endif //NESTEGG_ZEGGTRACKER_H
[ "shamim.ice.ewu@gmail.com" ]
shamim.ice.ewu@gmail.com
c34369558b35e5c2ec7fba0fdeae72b1d9b8ca78
e433566a524fd56b871bdd93685e0b8f2985574c
/bebop_ws/devel/include/bebop_msgs/CommonAccessoryStateSupportedAccessoriesListChanged.h
7baeaab043912a6960e1666bbfa74ef90f6d5c73
[]
no_license
JarrettPhilips/self_landing_drone
000b2f386302555f1876fbc38ada71d12451f8e0
7e497492941d9f642d4991c3fbc5be20e63f965e
refs/heads/master
2021-09-14T13:20:14.536053
2017-12-20T00:16:55
2017-12-20T00:16:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,291
h
// Generated by gencpp from file bebop_msgs/CommonAccessoryStateSupportedAccessoriesListChanged.msg // DO NOT EDIT! #ifndef BEBOP_MSGS_MESSAGE_COMMONACCESSORYSTATESUPPORTEDACCESSORIESLISTCHANGED_H #define BEBOP_MSGS_MESSAGE_COMMONACCESSORYSTATESUPPORTEDACCESSORIESLISTCHANGED_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <std_msgs/Header.h> namespace bebop_msgs { template <class ContainerAllocator> struct CommonAccessoryStateSupportedAccessoriesListChanged_ { typedef CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> Type; CommonAccessoryStateSupportedAccessoriesListChanged_() : header() , accessory(0) { } CommonAccessoryStateSupportedAccessoriesListChanged_(const ContainerAllocator& _alloc) : header(_alloc) , accessory(0) { (void)_alloc; } typedef ::std_msgs::Header_<ContainerAllocator> _header_type; _header_type header; typedef uint8_t _accessory_type; _accessory_type accessory; enum { accessory_NO_ACCESSORY = 0u }; enum { accessory_STD_WHEELS = 1u }; enum { accessory_TRUCK_WHEELS = 2u }; enum { accessory_HULL = 3u }; enum { accessory_HYDROFOIL = 4u }; typedef boost::shared_ptr< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> const> ConstPtr; }; // struct CommonAccessoryStateSupportedAccessoriesListChanged_ typedef ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<std::allocator<void> > CommonAccessoryStateSupportedAccessoriesListChanged; typedef boost::shared_ptr< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged > CommonAccessoryStateSupportedAccessoriesListChangedPtr; typedef boost::shared_ptr< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged const> CommonAccessoryStateSupportedAccessoriesListChangedConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> & v) { ros::message_operations::Printer< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace bebop_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True} // {'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'bebop_msgs': ['/home/anthony/Documents/Final/bebop_ws/src/bebop_autonomy/bebop_msgs/msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> const> : TrueType { }; template<class ContainerAllocator> struct MD5Sum< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > { static const char* value() { return "5c5ca2fc44e5f348a92c49ef9e03b7d2"; } static const char* value(const ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x5c5ca2fc44e5f348ULL; static const uint64_t static_value2 = 0xa92c49ef9e03b7d2ULL; }; template<class ContainerAllocator> struct DataType< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > { static const char* value() { return "bebop_msgs/CommonAccessoryStateSupportedAccessoriesListChanged"; } static const char* value(const ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > { static const char* value() { return "# CommonAccessoryStateSupportedAccessoriesListChanged\n\ # auto-generated from up stream XML files at\n\ # github.com/Parrot-Developers/libARCommands/tree/master/Xml\n\ # To check upstream commit hash, refer to last_build_info file\n\ # Do not modify this file by hand. Check scripts/meta folder for generator files.\n\ #\n\ # SDK Comment: Supported accessories list.\n\ \n\ Header header\n\ \n\ # Accessory configurations supported by the product.\n\ uint8 accessory_NO_ACCESSORY=0 # No accessory.\n\ uint8 accessory_STD_WHEELS=1 # Standard wheels\n\ uint8 accessory_TRUCK_WHEELS=2 # Truck wheels\n\ uint8 accessory_HULL=3 # Hull\n\ uint8 accessory_HYDROFOIL=4 # Hydrofoil\n\ uint8 accessory\n\ \n\ ================================================================================\n\ MSG: std_msgs/Header\n\ # Standard metadata for higher-level stamped data types.\n\ # This is generally used to communicate timestamped data \n\ # in a particular coordinate frame.\n\ # \n\ # sequence ID: consecutively increasing ID \n\ uint32 seq\n\ #Two-integer timestamp that is expressed as:\n\ # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\ # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\ # time-handling sugar is provided by the client library\n\ time stamp\n\ #Frame this data is associated with\n\ # 0: no frame\n\ # 1: global frame\n\ string frame_id\n\ "; } static const char* value(const ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.header); stream.next(m.accessory); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct CommonAccessoryStateSupportedAccessoriesListChanged_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::bebop_msgs::CommonAccessoryStateSupportedAccessoriesListChanged_<ContainerAllocator>& v) { s << indent << "header: "; s << std::endl; Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header); s << indent << "accessory: "; Printer<uint8_t>::stream(s, indent + " ", v.accessory); } }; } // namespace message_operations } // namespace ros #endif // BEBOP_MSGS_MESSAGE_COMMONACCESSORYSTATESUPPORTEDACCESSORIESLISTCHANGED_H
[ "Anke5631@colorado.edu" ]
Anke5631@colorado.edu
a3915bdebfe2a7dd232da647f177302c328b9bed
2504cb95b9643b15469822283e8569cdbb5f4992
/DPGAnalysis/SiStripTools/plugins/MultiplicityInvestigator.cc
c0c4062f40ac56e0999e6e524473e3f913cc55fd
[]
no_license
Sam-Harper/cmssw
c58e12be2a1ca1d4720edb1499780908009b65d1
6414f697cccaf3b0a19433dede86b6f466f4b814
refs/heads/6_1_2_SLHC2_L1EGIsol_SLHCUpgradeSim
2023-07-20T17:34:32.029505
2014-02-10T12:53:05
2014-02-10T12:53:05
15,676,551
0
0
null
2022-02-21T12:25:23
2014-01-06T14:56:25
C++
UTF-8
C++
false
false
5,300
cc
// -*- C++ -*- // // Package: MultiplicityInvestigator // Class: MultiplicityInvestigator // /**\class MultiplicityInvestigator MultiplicityInvestigator.cc myTKAnalyses/DigiInvestigator/src/MultiplicityInvestigator.cc Description: <one line class summary> Implementation: <Notes on implementation> */ // // Original Author: Andrea Venturi // Created: Mon Oct 27 17:37:53 CET 2008 // $Id: MultiplicityInvestigator.cc,v 1.4 2011/12/11 09:59:11 venturia Exp $ // // // system include files #include <memory> // user include files #include <vector> #include <map> #include <limits> #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Run.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DPGAnalysis/SiStripTools/interface/DigiInvestigatorHistogramMaker.h" #include "DPGAnalysis/SiStripTools/interface/DigiVertexCorrHistogramMaker.h" #include "DPGAnalysis/SiStripTools/interface/DigiLumiCorrHistogramMaker.h" #include "DPGAnalysis/SiStripTools/interface/DigiPileupCorrHistogramMaker.h" // // class decleration // class MultiplicityInvestigator : public edm::EDAnalyzer { public: explicit MultiplicityInvestigator(const edm::ParameterSet&); ~MultiplicityInvestigator(); private: virtual void beginJob() ; virtual void analyze(const edm::Event&, const edm::EventSetup&); virtual void beginRun(const edm::Run&, const edm::EventSetup&); virtual void endRun(const edm::Run&, const edm::EventSetup&); virtual void endJob() ; // ----------member data --------------------------- const bool m_wantInvestHist; const bool m_wantVtxCorrHist; const bool m_wantLumiCorrHist; const bool m_wantPileupCorrHist; DigiInvestigatorHistogramMaker m_digiinvesthmevent; DigiVertexCorrHistogramMaker m_digivtxcorrhmevent; DigiLumiCorrHistogramMaker m_digilumicorrhmevent; DigiPileupCorrHistogramMaker m_digipileupcorrhmevent; edm::InputTag m_multiplicityMap; edm::InputTag m_vertexCollection; }; // // constants, enums and typedefs // // // static data member definitions // // // constructors and destructor // MultiplicityInvestigator::MultiplicityInvestigator(const edm::ParameterSet& iConfig): // m_digiinvesthmevent(iConfig.getParameter<edm::ParameterSet>("digiInvestConfig")), m_wantInvestHist(iConfig.getParameter<bool>("wantInvestHist")), m_wantVtxCorrHist(iConfig.getParameter<bool>("wantVtxCorrHist")), m_wantLumiCorrHist(iConfig.getParameter<bool>("wantLumiCorrHist")), m_wantPileupCorrHist(iConfig.getParameter<bool>("wantPileupCorrHist")), m_digiinvesthmevent(iConfig), m_digivtxcorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiVtxCorrConfig")), m_digilumicorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiLumiCorrConfig")), m_digipileupcorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiPileupCorrConfig")), m_multiplicityMap(iConfig.getParameter<edm::InputTag>("multiplicityMap")), m_vertexCollection(iConfig.getParameter<edm::InputTag>("vertexCollection")) { //now do what ever initialization is needed if(m_wantInvestHist) m_digiinvesthmevent.book("EventProcs"); if(m_wantVtxCorrHist) m_digivtxcorrhmevent.book("VtxCorr"); if(m_wantLumiCorrHist) m_digilumicorrhmevent.book("LumiCorr"); if(m_wantPileupCorrHist) m_digipileupcorrhmevent.book("PileupCorr"); } MultiplicityInvestigator::~MultiplicityInvestigator() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } // // member functions // // ------------ method called to for each event ------------ void MultiplicityInvestigator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; Handle<std::map<unsigned int, int> > mults; iEvent.getByLabel(m_multiplicityMap,mults); if(m_wantInvestHist) m_digiinvesthmevent.fill(iEvent.orbitNumber(),*mults); if(m_wantVtxCorrHist) { Handle<reco::VertexCollection> vertices; iEvent.getByLabel(m_vertexCollection,vertices); m_digivtxcorrhmevent.fill(iEvent,vertices->size(),*mults); } if(m_wantLumiCorrHist) m_digilumicorrhmevent.fill(iEvent,*mults); if(m_wantPileupCorrHist) m_digipileupcorrhmevent.fill(iEvent,*mults); } // ------------ method called once each job just before starting event loop ------------ void MultiplicityInvestigator::beginJob() { } void MultiplicityInvestigator::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { m_digiinvesthmevent.beginRun(iRun.run()); m_digivtxcorrhmevent.beginRun(iRun); m_digilumicorrhmevent.beginRun(iRun); } void MultiplicityInvestigator::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { } // ------------ method called once each job just after ending the event loop ------------ void MultiplicityInvestigator::endJob() { } //define this as a plug-in DEFINE_FWK_MODULE(MultiplicityInvestigator);
[ "sha1-71af2bda94b31c8bb1d8f97d0062b66e7418ae83@cern.ch" ]
sha1-71af2bda94b31c8bb1d8f97d0062b66e7418ae83@cern.ch
7b0dd0c23ef7fbaeff9f0b4798cdefe63d2a5ffa
925b21d9c3db1fcbae52ee4f129c56f33fd1b931
/Company's Interview tester together/Huawei Tests/Q31_longest_symmetry/main.cpp
55129614fb593909cb85b444c4cc9e9adea8f1d1
[]
no_license
Jerrysun7617/Study-Materails
6432c50c016348024a54e00e31691fb5a648e963
1a391736bc7dd2dbbe60af571ba8b8929ee9980d
refs/heads/master
2021-09-07T20:35:23.838624
2018-02-28T17:32:21
2018-02-28T17:32:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,295
cpp
#include <iostream> #include <string.h> using namespace std; struct symetry{ int num; int position; }; int main() { char str[1000]; while(cin>>str) { int i,j,k; int length = strlen(str); struct symetry sy[1000] ={0};; //choose the centre for(i = 1;i < length - 1; i++) { j = i - 1; k = i + 1; sy[i].num = 0; sy[i].position = i; while(j>=0 && k<length) { if(str[j--] == str[k++]){ sy[ i].num++; } else break; } } for(i = 0; i < length - 1;i++) for(j = i +1;j <length; j++) { if(sy[i].num < sy[j].num) { struct symetry md; md = sy[i]; sy[i] = sy[j]; sy[j] = md ; } } // the 0 for(i = 0; i < length;i++) { if(sy[0].num == sy[i].num){ for(j = sy[i].position - sy[i].num; j < 1 + sy[i].num + sy[i].position;j++) cout<<str[j]; cout<<endl; } } } cout << "Hello world!" << endl; return 0; }
[ "jerrysun7617@gmail.com" ]
jerrysun7617@gmail.com
9649fc0642ca3f52acf3c0790fecdac7740dff69
c553f0edb3f031b196bfb785688d3c762fbd34c1
/B. Hungry Sequence.cpp
9e38daa86cb0f549c1e260d438fa8eaf69e61980
[]
no_license
akashksinghal/My-Codeforces-Archive
320b7f82768817dd81c0452a9635541d38b47f77
114750ba1c43f4f3a95d3ad73be105b0c2a59187
refs/heads/master
2022-12-03T16:34:39.471771
2020-08-17T09:24:38
2020-08-17T09:24:38
241,869,193
1
0
null
null
null
null
UTF-8
C++
false
false
1,386
cpp
// I'm a f*cking looser #include<bits/stdc++.h> using namespace std; #define ll long long #define fasino ios_base::sync_with_stdio(false); cin.tie(0); #define asc(A) sort(A.begin(),A.end()) #define dsc(A) sort(A.begin(),A.end(),greater<ll>()) #define input(A,N) for(ll i=0;i<N;i++) cin>>A[i]; const long long mxN = 10000000; // bool prime[mxN+2]; vector<long long> primes; void seive(){ // cout<<N<<' '; // auto start = high_resolution_clock::now(); prime[0]=prime[1]=true; for(long long i=4;i<=mxN;i+=2){ prime[i] = true; } for(long long i=6;i<=mxN;i+=3){ prime[i] = true; } for(long long i=5;i*i<=mxN;i++){ if(!prime[i]){ for(long long j=i*i;j<=mxN;j+=i){ prime[j] = true; } } } for(int i=2;i<=mxN;i++){ if(!prime[i]){ primes.push_back(i); } } // auto stop = high_resolution_clock::now(); // auto duration = duration_cast<microseconds>(stop - start); // cout << "Time taken by function: " << duration.count() << " microseconds" << endl; //cout<<primes.size()<<' '<<primes[primes.size()-1]<<'\n'; } int main() { fasino #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif seive(); ll n; cin>>n; for(int i=0;i<n;i++){ cout<<primes[i]<<' '; } return 0; }
[ "akashksinghalnewdelhi@gmail.com" ]
akashksinghalnewdelhi@gmail.com
b837af567a3ab1fff01a873f9b17f5a343b40c39
da0be25099cf38f16ea61b269985686801223719
/day17/day17.cpp
d3e8d951d11256e50522ce6f63111a51b89a21b6
[]
no_license
rebornkumar/30-Day-LeetCoding-Challenge
a3ed908fa6c2cb01a4a4b56c2b4da6b9c1612d37
3d26baf0a33737c026a4be497899ce053cc2e75e
refs/heads/master
2023-01-04T13:35:18.196707
2020-10-20T19:07:21
2020-10-20T19:07:21
252,844,693
1
1
null
null
null
null
UTF-8
C++
false
false
1,265
cpp
class Solution { vector<int> moveX = {0,-1,0,1}; vector<int> moveY = {1,0,-1,0}; int R = 0,C = 0; bool isValid(int r,int c) { if(r >= 0 && c >= 0 && r < R && c < C) { return true; } else { return false; } } void dfs(vector<vector<char>>&graph,vector<vector<bool>>&vis,int srcX,int srcY) { if(vis[srcX][srcY] == true) { return; } vis[srcX][srcY] = true; for(int i = 0; i < 4;i++) { int X = moveX[i] + srcX; int Y = moveY[i] + srcY; if(isValid(X,Y) == true && graph[X][Y] == '1' && vis[X][Y] == false) { dfs(graph,vis,X,Y); } } } public: int numIslands(vector<vector<char>>& grid) { R = grid.size(); if(R == 0) { return 0; } C = grid[0].size(); int ans = 0; vector<vector<bool>>vis(R,vector<bool>(C,false)); for(int i = 0;i < R;i++) { for(int j = 0;j < C;j++) { if(grid[i][j] == '1' && vis[i][j] == false) { dfs(grid,vis,i,j); ans++; } } } return ans; } };
[ "iitr.anujkumar@gmail.com" ]
iitr.anujkumar@gmail.com
0bd04c33fbc7107135812405da7f1251c4319b7d
252ed0371ecc0685a5027780b702fb864ae6a1b1
/Samples/NetworkMediaStreamer/NetworkMediaStreamerBase/inc/NwMediaStreamSinkBase.h
32f6598ffc994c4980f6f9a95e83dbe55b9ff220
[ "LicenseRef-scancode-proprietary-license", "MIT", "LicenseRef-scancode-generic-cla" ]
permissive
microsoft/Windows-Camera
64a6236ccdea904e1e962d6ac1abe18b637cc5e4
eb7bfd7b02fd3985ab4a187feb1187a0b0d56d94
refs/heads/master
2023-08-21T05:56:02.289672
2023-06-07T18:14:21
2023-06-07T18:14:21
128,274,185
134
58
MIT
2023-04-08T00:31:00
2018-04-05T23:09:58
C#
UTF-8
C++
false
false
2,160
h
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for more information #pragma once #define RETURN_IF_SHUTDOWN if(m_bIsShutdown) return MF_E_SHUTDOWN; #define RETURN_IF_NULL(p) if(!p) return E_POINTER; #define HRESULT_EXCEPTION_BOUNDARY_FUNC catch(...) { auto hr = winrt::to_hresult(); return hr;} class NwMediaStreamSinkBase : public winrt::implements<NwMediaStreamSinkBase, INetworkMediaStreamSink, IMFStreamSink, IMFMediaEventGenerator> { protected: uint8_t* m_pVideoHeader; uint32_t m_VideoHeaderSize; bool m_bIsShutdown; winrt::weak_ref<IMFMediaSink> m_spParentSink; winrt::com_ptr<IMFMediaEventQueue> m_spEventQueue; winrt::com_ptr<IMFMediaTypeHandler> m_spMTHandler; DWORD m_dwStreamID; NwMediaStreamSinkBase(IMFMediaType* pMediaType, IMFMediaSink* pParent, DWORD dwStreamID); virtual ~NwMediaStreamSinkBase(); virtual STDMETHODIMP PacketizeAndSend(IMFSample* pSample) = 0; public: // INetworkStreamSink STDMETHODIMP Start(MFTIME hnsSystemTime, LONGLONG llClockStartOffset); STDMETHODIMP Stop(MFTIME hnsSystemTime); STDMETHODIMP Pause(MFTIME hnsSystemTime); STDMETHODIMP Shutdown(); // IMFMediaEventGenerator STDMETHODIMP BeginGetEvent(IMFAsyncCallback* pCallback, IUnknown* pState); STDMETHODIMP EndGetEvent(IMFAsyncResult* pResult, IMFMediaEvent** ppEvent); STDMETHODIMP GetEvent(DWORD dwFlags, IMFMediaEvent** ppEvent); STDMETHODIMP QueueEvent( MediaEventType met, REFGUID extendedType, HRESULT hrStatus, const PROPVARIANT* pvValue); // IMFStreamSink STDMETHODIMP GetMediaSink(IMFMediaSink** ppMediaSink); STDMETHODIMP GetIdentifier(DWORD* pdwIdentifier); STDMETHODIMP GetMediaTypeHandler(IMFMediaTypeHandler** ppHandler); STDMETHODIMP ProcessSample(IMFSample* pSample); STDMETHODIMP PlaceMarker( MFSTREAMSINK_MARKER_TYPE eMarkerType, const PROPVARIANT* pvarMarkerValue, const PROPVARIANT* pvarContextValue); STDMETHODIMP Flush(void); };
[ "susohoni@microsoft.com" ]
susohoni@microsoft.com
831d118245a13cc6510b286afb7c8e9d9cf9d868
c1d6f79edb2bec9f2f31046f319e1f952b67756e
/Miscellaneous/Minimum_Domino_Rotations_For_Equal_Row.cpp
be8ad14eb1a67f4dbacef71373bfce4381bd41a5
[]
no_license
nishchay121/Scaler-Academy-1
dfed677bd7fe8cf8bf7da25dd105a8183751ea90
b803cedc78ab1d82bfee20e203ff24a4237b4bc2
refs/heads/master
2023-04-09T14:10:59.256311
2021-04-24T16:39:55
2021-04-24T16:39:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,702
cpp
class Solution { public: int minDominoRotations(vector<int>& A, vector<int>& B) { int len = A.size(); if(len == 1) return 0; int first = A[0]; int second = B[0]; bool flag1 = true, flag2 = true; for(int i=1;i<len;i++) { if(A[i] != first && B[i] != first) { flag1 = false; } } for(int i=1;i<len;i++) { if(A[i] != second && B[i] != second) { flag2 = false; } } if(!flag1 && !flag2) return -1; int min_answer = INT_MAX; if(flag1) { int answer = 0; for(int i=1;i<len;i++) { if(A[i] == first) continue; answer++; } min_answer = min(min_answer, answer); } if(flag2) { int answer = 0; for(int i=1;i<len;i++) { if(B[i] == second) continue; answer++; } min_answer = min(min_answer, answer); } swap(first, second); if(flag2) { int answer = 1; for(int i=1;i<len;i++) { if(A[i] == first) continue; answer++; } min_answer = min(min_answer, answer); } if(flag1) { int answer = 1; for(int i=1;i<len;i++) { if(B[i] == second) continue; answer++; } min_answer = min(min_answer, answer); } return min_answer; } };
[ "yash1998sarda@gmail.com" ]
yash1998sarda@gmail.com
0f08b324c690220b703d8693a08243af68e4ec52
9606f101d9cc735ef84dea07d8c76a865be72c76
/SimpleShooter/Source/SimpleShooter/Gun.h
e65590e9f4ce59fa083285df2a15545c02caba7f
[]
no_license
EthanHuston/Udemy_SimpleShooter
7c713903c45722968e5fff7a33d98f5570bf6754
d517cb1a5c5562549eb5a3c7062db65f0a4718f2
refs/heads/master
2023-04-16T11:42:30.433612
2021-04-29T03:11:01
2021-04-29T03:11:01
337,753,216
0
0
null
null
null
null
UTF-8
C++
false
false
1,064
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "Gun.generated.h" UCLASS() class SIMPLESHOOTER_API AGun : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AGun(); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; void PullTrigger(); private: UPROPERTY(VisibleAnywhere) USceneComponent* Root; UPROPERTY(VisibleAnywhere) USkeletalMeshComponent* Mesh; UPROPERTY(EditAnywhere) UParticleSystem* MuzzleFlash; UPROPERTY(EditAnywhere) UParticleSystem* ImpactEffect; UPROPERTY(EditAnywhere) USoundBase* MuzzleSound; UPROPERTY(EditAnywhere) USoundBase* ImpactSound; UPROPERTY(EditAnywhere) float MaxRange = 1000; UPROPERTY(EditAnywhere) float Damage = 10; bool GunTrace(FHitResult& Hit, FVector& ShotDirection); AController* GetOwnerController() const; };
[ "ethanghuston@gmail.com" ]
ethanghuston@gmail.com
8b3abd11723022f640d38c2b4d1d4e223faaa5d9
9934512da4a541a3e6654dd3a71512df9a9bfe14
/CRUISE5/satellite_functions.cpp
dd2d6dbb9272e76b210f554e7b79226c81821e58
[]
no_license
missiondesignsolutions/CADAC
a534eda151c6d8d3afba8e5d48d60201a2a591ff
8aa2f73e551554a48abeac5416d1ec3a34ae660f
refs/heads/main
2023-05-01T04:32:40.710534
2021-05-24T07:44:03
2021-05-24T07:44:03
370,660,263
3
1
null
2021-05-25T10:55:36
2021-05-25T10:55:36
null
UTF-8
C++
false
false
9,723
cpp
/////////////////////////////////////////////////////////////////////////////// //FILE: 'satellite_functions.cpp' // Contains utilitiy functions for the 'Satellite' class: // array sizing // writing data to output // //010810 Created by Peter H Zipfel /////////////////////////////////////////////////////////////////////////////// #include "class_hierarchy.hpp" using namespace std; /////////////////////////////////////////////////////////////////////////////// //Reading input data from input file 'input.asc' for each vehicle object //Assigning initial values to module-variables of 'round3' and 'satellite' arrays //Reading aero and propulsion decks // //The first vehicle 'SATELLITE3' of 'input.asc' reads until the first 'END' after //'SATELLITE3'. The second vehicle object reads untile the second 'END', etc until //the data for all vehicle objects are read // //Output: satellite3_name ('Satellite' data member) // round3[] data values (Round3 data member) // satellite[] data values ('Satellite' data member) // //Limitation: real and integer variables only (could be expanded to vectors) // //010810 Created by Peter Zipfel /////////////////////////////////////////////////////////////////////////////// void Satellite::vehicle_data(fstream &input) { char line_clear[CHARL]; char read[CHARN]; //name of variable read from input.asc char *buff; //name of module-variable double data; //data of module-variable char *comment ="//"; char *integer; int int_data; int file_ptr=NULL; int e(0); char *watchpoint=NULL; input.getline(satellite3_name,CHARL,'\n'); //reading data until END is encountered do { //reading variable data into module-variable arrays input>>read; if(strpbrk(comment,read)) { input.getline(line_clear,CHARL,'\n'); } else { int i; for(i=0;i<NROUND3;i++) { buff=round3[i].get_name(); if(!strcmp(buff,read)) { input>>data; //checking for integers integer=round3[i].get_type(); if(!strcmp(integer,"int")) { //loading interger value int_data=(int)data; round3[i].gets(int_data); input.getline(line_clear,CHARL,'\n'); } else { //loading real value round3[i].gets(data); input.getline(line_clear,CHARL,'\n'); } } } for(i=0;i<NSATELLITE;i++) { buff=satellite[i].get_name(); if(!strcmp(buff,read)) { input>>data; //checking for integers integer=satellite[i].get_type(); if(!strcmp(integer,"int")) { //loading interger value int_data=(int)data; satellite[i].gets(int_data); input.getline(line_clear,CHARL,'\n'); } else { //loading real value satellite[i].gets(data); input.getline(line_clear,CHARL,'\n'); } } } } //end of reading non-comment lines }while(strcmp(read,"END")); //reached 'END' of first vehicle object //diagnostic: file pointer file_ptr=int(input.tellg()); } /////////////////////////////////////////////////////////////////////////////// //Determining dimensions of arrays: 'com_satellite' // //Out to Satellite:: round3_com_count, satellite_com_count, ncom_satellite3 , // //010810 Created by Peter Zipfel /////////////////////////////////////////////////////////////////////////////// void Satellite::sizing_arrays() { char *key4="com"; round3_com_count=0; satellite_com_count=0; int i(0); //counting in 'round3' array for(i=0;i<NROUND3;i++) { if(strstr(round3[i].get_out(),key4)) round3_com_count++; } //counting in 'satellite' array for(i=0;i<NSATELLITE;i++) { if(strstr(satellite[i].get_out(),key4)) satellite_com_count++; } //output to Satellite::protected ncom_satellite3=round3_com_count+satellite_com_count; } /////////////////////////////////////////////////////////////////////////////// //Building index array of those 'round3[]' and satellite[] variables //that are output to 'combus' 'data' // //Out to Satellite::round3_com_ind[], satellite_com_ind[] // //010810 Created by Peter Zipfel /////////////////////////////////////////////////////////////////////////////// void Satellite::com_index_arrays() { const char *test="com"; int i(0); int k=0; for(i=0;i<NROUND3;i++) { if(strstr(round3[i].get_out(),test)) { round3_com_ind[k]=i; k++; } } int l=0; for(i=0;i<NSATELLITE;i++) { if(strstr(satellite[i].get_out(),test)) { satellite_com_ind[l]=i; l++; } } } /////////////////////////////////////////////////////////////////////////////// //Initializing loading 'packet' of satellite // //uses C-code 'sprintf' function to convert 'int' to 'char' //differs from 'loading_packet' only by initializing 'status=1' // //010810 Created by Peter H Zipfel /////////////////////////////////////////////////////////////////////////////// Packet Satellite::loading_packet_init(int num_cruise,int num_target,int num_satellite) { string id; char object[4]; static int c_count=0; int index; int i(0); int j(0); c_count++; if(c_count==(num_satellite+1))c_count=1; sprintf(object,"%i",c_count); id="s"+string(object); //building 'data' array of module-variables for(i=0;i<round3_com_count;i++) { index=round3_com_ind[i]; com_satellite3[i]=round3[index]; } for(j=0;j<satellite_com_count;j++) { index=satellite_com_ind[j]; com_satellite3[i+j]=satellite[index]; } //refreshing the packet packet.set_id(id); packet.set_status(1); packet.set_data(com_satellite3); packet.set_ndata(ncom_satellite3); return packet; } /////////////////////////////////////////////////////////////////////////////// //Loading 'packet' of satellite // //uses C-code 'sprintf' function to convert int to char // //010810 Created by Peter H Zipfel /////////////////////////////////////////////////////////////////////////////// Packet Satellite::loading_packet(int num_cruise,int num_target,int num_satellite) { int index(0); int i(0); int j(0); /* string id; char object[4]; static int c_count=0; c_count++; if(c_count==(num_satellite+1))c_count=1; sprintf(object,"%i",c_count); id="t"+string(object); */ //building 'data' array of module-variables for(i=0;i<round3_com_count;i++) { index=round3_com_ind[i]; com_satellite3[i]=round3[index]; } for(j=0;j<satellite_com_count;j++) { index=satellite_com_ind[j]; com_satellite3[i+j]=satellite[index]; } //refreshing the packet packet.set_data(com_satellite3); packet.set_ndata(ncom_satellite3); return packet; } /////////////////////////////////////////////////////////////////////////////// //Composing documention on file 'doc.asc' //Listing 'satellite' module-variable arrays // //010214 Created by Peter Zipfel //020911 Added module-variable error flagging, PZi //060929 Modification to accomodate C++8, PZi /////////////////////////////////////////////////////////////////////////////// void Satellite::document(ostream &fdoc,char *title,Document *doc_satellite3) { int i(0); int j(0); fdoc<<"\n\n Satellite Module-Variable Array \n\n"; fdoc<<"---------------------------------------------------------------------------------------------------------------------\n"; fdoc<<"|LOC| NAME | DEFINITION | MODULE | PURPOSE | OUTPUT |\n"; fdoc<<"---------------------------------------------------------------------------------------------------------------------\n"; char name_error_code[]="A"; for(i=0;i<NSATELLITE;i++) { for(j=0;j<i;j++){ if(!strcmp(satellite[i].get_name(),satellite[j].get_name())&&strcmp(satellite[i].get_name(),"empty")) satellite[i].put_error(name_error_code); } if(!strcmp(satellite[i].get_error(),"A")) cout<<" *** Error code 'A': duplicate name in satellite[] array, see 'doc.asc' ***\n"; if(!strcmp(satellite[i].get_error(),"*")) cout<<" *** Error code '*': duplicate location in satellite[] array, see 'doc.asc' ***\n"; fdoc<<satellite[i].get_error(); fdoc.setf(ios::left); fdoc.width(4);fdoc<<i; if(!strcmp(satellite[i].get_type(),"int")) { fdoc.width(15);fdoc<<satellite[i].get_name(); fdoc.width(5);fdoc<<" int "; } else { fdoc.width(20);fdoc<<satellite[i].get_name(); } fdoc.width(54);fdoc<<satellite[i].get_def(); fdoc.width(13);fdoc<<satellite[i].get_mod(); fdoc.width(10);fdoc<<satellite[i].get_role(); fdoc<<satellite[i].get_out(); fdoc<<"\n"; if(!((i+1)%10))fdoc<<"----------------------------------------------------------------------------------------------------------------------\n"; } //building doc_satellite3[] for documenting 'input.asc' and eliminating 'empty' slots int counter=0; for(i=0;i<NSATELLITE;i++){ if(strcmp(satellite[i].get_name(),"empty")){ doc_satellite3[counter].put_doc_offset(counter); doc_satellite3[counter].put_name(satellite[i].get_name()); //z060929 doc_satellite3[counter].put_type(satellite[i].get_type()); char *dum; dum=satellite[i].get_type(); if(*dum!=-51) doc_satellite3[counter].put_type(dum); //z060929-end doc_satellite3[counter].put_def(satellite[i].get_def()); doc_satellite3[counter].put_mod(satellite[i].get_mod()); counter++; } } for(i=0;i<NROUND3;i++){ if(strcmp(round3[i].get_name(),"empty")){ doc_satellite3[counter].put_doc_offset(counter); doc_satellite3[counter].put_name(round3[i].get_name()); //z060929 doc_satellite3[counter].put_type(round3[i].get_type()); char *dum; dum=round3[i].get_type(); if(*dum!=-51) doc_satellite3[counter].put_type(dum); //z060929-end doc_satellite3[counter].put_def(round3[i].get_def()); doc_satellite3[counter].put_mod(round3[i].get_mod()); counter++; } } }
[ "rads2995@gmail.com" ]
rads2995@gmail.com
160b1086afc51ebd90221d5fdd156179ecc8fc50
45d0623d95c0138bb35f40f8e166900146c17b40
/Pirate/BSPSceneNode.cpp
2bbfa60e4838928c551c86383cfcded61726d64c
[]
no_license
menchi/pirate3d
be5d706b856f3dde52d69468efaa67c7ef9e79aa
d4d3851cb7b43e3557248949375ae3434468c9b0
refs/heads/master
2018-12-29T20:10:57.061093
2015-09-25T08:20:38
2015-09-25T08:20:38
41,402,654
0
0
null
null
null
null
UTF-8
C++
false
false
4,505
cpp
#include "BSPSceneNode.h" #include "D3D9Driver.h" #include "SceneManager.h" #include "D3D9HLSLShader.h" #include "SMesh.h" #include "BSPFileLoader.h" #include "OS.h" namespace Pirate { //! constructor BSPSceneNode::BSPSceneNode(BSPTree* tree, SMesh* mesh, SceneNode* parent, SceneManager* mgr, s32 id, const vector3df& position, const vector3df& rotation, const vector3df& scale) : MeshSceneNode(mesh, parent, mgr, id, position, rotation, scale), m_pBSPTree(0), m_iLastCluster(-1) { #ifdef _DEBUG SetDebugName("BSPSceneNode"); #endif SetBSPTree(tree); } //! destructor BSPSceneNode::~BSPSceneNode() { if (m_pBSPTree) m_pBSPTree->Drop(); } //! frame void BSPSceneNode::OnRegisterSceneNode() { if (m_bIsVisible) { // because this node supports rendering of mixed mode meshes consisting of // transparent and solid material at the same time, we need to go through all // materials, check of what type they are and register this node for the right // render pass according to that. D3D9Driver* driver = m_pSceneManager->GetVideoDriver(); m_pSceneManager->RegisterNodeForRendering(this, ESNRP_SOLID); // m_pSceneManager->RegisterNodeForRendering(this, ESNRP_TRANSPARENT); SceneNode::OnRegisterSceneNode(); } } //! renders the node. void BSPSceneNode::Render() { D3D9Driver* driver = m_pSceneManager->GetVideoDriver(); if (!m_pMesh || !driver) return; BOOL isTransparentPass = m_pSceneManager->GetSceneNodeRenderPass() == ESNRP_TRANSPARENT; driver->SetTransform(ETS_WORLD, m_AbsoluteTransformation); m_Box = m_pMesh->GetBoundingBox(); CameraSceneNode* pCamera = m_pSceneManager->GetActiveCamera(); FindVisibleMeshBuffers(pCamera->GetPosition()); vector3df camPos = pCamera->GetAbsolutePosition(); for (u32 i=0; i<m_pMesh->GetMeshBufferCount(); ++i) { SD3D9MeshBuffer* mb = m_pMesh->GetMeshBuffer(i); if (mb && (m_pBSPTree->m_Flags[i] & BSPTree::EFF_VISIBLE) ) { if ( m_pBSPTree->m_FaceNormals[i].dotProduct(mb->GetBoundingBox().MinEdge - camPos) > 0.0f && m_pBSPTree->m_FaceNormals[i].dotProduct(mb->GetBoundingBox().MaxEdge - camPos) > 0.0f) continue; const SMaterial& material = mb->GetMaterial(); D3D9HLSLShader* rnd = driver->GetMaterialRenderer(material.ShaderType); BOOL transparent = (rnd && rnd->IsTransparent()); // only render transparent buffer if this is the transparent render pass // and solid only in solid pass if (transparent == isTransparentPass) { driver->SetMaterial(material); driver->DrawMeshBuffer(mb); } } } } //! returns the axis aligned bounding box of this node const aabbox3d<f32>& BSPSceneNode::GetBoundingBox() const { return m_pBSPTree->m_Nodes[0].Bounding; } //! Sets a new bsp tree void BSPSceneNode::SetBSPTree(BSPTree* tree) { if (!tree) return; // won't set null mesh if (m_pBSPTree) m_pBSPTree->Drop(); m_pBSPTree = tree; if (m_pBSPTree) m_pBSPTree->Grab(); } void BSPSceneNode::FindVisibleMeshBuffers(vector3df camera) { s16 cluster = m_pBSPTree->m_Leaves[m_pBSPTree->GetLeafByPoint(camera, 0)].Cluster; if (cluster == m_iLastCluster) return; m_iLastCluster = cluster; /* if (!m_pBSPTree->m_Flags.size()) { m_pBSPTree->m_Flags.reallocate(m_pMesh->GetMeshBufferCount()); m_pBSPTree->m_Flags.set_used(m_pMesh->GetMeshBufferCount()); } */ for (u32 i=0; i<m_pMesh->GetMeshBufferCount(); i++) m_pBSPTree->m_Flags[i] &= 0xFE; if (cluster == -1) { for (u32 i=0; i<m_pBSPTree->m_Flags.size(); i++) m_pBSPTree->m_Flags[i] |= BSPTree::EFF_VISIBLE; return; } s32 num_clusters = *m_pBSPTree->m_pVisLump; s32 v = *(m_pBSPTree->m_pVisLump + 2 * cluster + 1); u8* pvs_buffer = (u8*)m_pBSPTree->m_pVisLump; for (s32 c = 0; c < num_clusters; v++) { if (pvs_buffer[v] == 0) { v++; c += 8 * pvs_buffer[v]; } else { for (u8 bit = 1; bit != 0; bit *= 2, c++) { if (pvs_buffer[v] & bit) { s32 leaf_index = m_pBSPTree->GetLeafByCluster(c); u32 num_leaffaces = m_pBSPTree->m_Leaves[leaf_index].Leaffaces.size(); for (u32 i=0; i<num_leaffaces; i++) { u16 visibleFace = m_pBSPTree->m_Leaves[leaf_index].Leaffaces[i]; if (!(m_pBSPTree->m_Flags[visibleFace] & BSPTree::EFF_SPECIAL_MATERIAL)) m_pBSPTree->m_Flags[visibleFace] |= 0x01; } } } } } } } // end namespace
[ "MenchiOnLine@de39f430-7830-0410-8fa4-f3971a2249f0" ]
MenchiOnLine@de39f430-7830-0410-8fa4-f3971a2249f0
b34120e2bfd8c8d468f0729d80a73985c9b0bc0f
21042c8a26009a3940ead744ba0f0550e4f6c216
/Fireworks/Fireworks/Background.cpp
935f573568aa7eeef8f14e601a8d9b05f250dccf
[]
no_license
VeryNiceGuy/opengl-samples
c565f4c9de7e00c6501dfd2e30452def215b10c2
de247ebbb29297be834aa7cf5704cbacad35c9ed
refs/heads/master
2021-01-15T13:19:01.152553
2017-08-08T09:23:18
2017-08-08T09:23:18
99,670,071
0
1
null
null
null
null
UTF-8
C++
false
false
3,369
cpp
#include "Background.h" #include "Vector2.h" #include "Bitmap.h" struct Vertex { GLfloat x, y; GLfloat u, v; }; const GLchar* BackgroundVS = "\ #version 450 core\n\ layout(location = 0) in vec2 in_Position;\n\ layout(location = 1) in vec2 in_UV;\n\ out vec2 UV;\n\ void main() {\n\ gl_Position = vec4(in_Position, 0.0, 1.0);\n\ UV = in_UV;\n\ }"; const GLchar* BackgroundFS = "\ #version 450 core\n\ uniform sampler2D tex;\n\ in vec2 UV;\n\ out vec4 colorOut;\n\ void main() {\n\ colorOut = texture(tex, UV);\n\ }"; Background::Background() { program = glCreateProgram(); GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(vertexShader, 1, &BackgroundVS, NULL); glShaderSource(fragmentShader, 1, &BackgroundFS, NULL); glCompileShader(vertexShader); glCompileShader(fragmentShader); glAttachShader(program, vertexShader); glAttachShader(program, fragmentShader); glLinkProgram(program); glDetachShader(program, vertexShader); glDetachShader(program, fragmentShader); glDeleteShader(vertexShader); glDeleteShader(fragmentShader); Bitmap bitmap(L"background.jpg", true); float halfWidth = 1.0f; float halfheight = 1.0f; Vertex vertices[4] = { { -halfWidth, -halfheight, 0.0f, 0.0f}, { -halfWidth, halfheight, 0.0f, 1.0f}, { halfWidth, halfheight, 1.0f, 1.0f}, { halfWidth, -halfheight, 1.0f, 0.0f} }; GLuint indices[6] = { 0,1,2,0,2,3 }; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); if (bitmap.getPixelFormat() == GL_BGR) { glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGB, bitmap.getWidth(), bitmap.getHeight()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bitmap.getWidth(), bitmap.getHeight(), GL_BGR, GL_UNSIGNED_BYTE, bitmap.getPixels()); } else if(bitmap.getPixelFormat() == GL_BGRA) { glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA, bitmap.getWidth(), bitmap.getHeight()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bitmap.getWidth(), bitmap.getHeight(), GL_BGR, GL_UNSIGNED_BYTE, bitmap.getPixels()); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glActiveTexture(GL_TEXTURE0); glGenVertexArrays(1, &vertexArray); glGenBuffers(1, &vertexBuffer); glGenBuffers(1, &indexBuffer); glBindVertexArray(vertexArray); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * 4, vertices, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, false, sizeof(Vertex), 0); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 2, GL_FLOAT, false, sizeof(Vertex), (GLvoid*)(sizeof(GLfloat) * 2)); glBindVertexArray(0); glBindTexture(GL_TEXTURE_2D, 0); } Background::~Background() { glDeleteTextures(1, &texture); glDeleteBuffers(1, &vertexBuffer); glDeleteBuffers(1, &indexBuffer); glDeleteVertexArrays(1, &vertexArray); } void Background::render() { glDisable(GL_DEPTH_TEST); glUseProgram(program); glBindTexture(GL_TEXTURE_2D, texture); glBindVertexArray(vertexArray); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glBindVertexArray(0); glUseProgram(0); glEnable(GL_DEPTH_TEST); }
[ "killingmesoftlywithchainsaw@gmail.com" ]
killingmesoftlywithchainsaw@gmail.com
b341c09dac087fa7d90b7d11e670874083a1bcf1
95231ce7e41b970b8dc8d452d91b6db8f7e7bedc
/src/lib-centurion/gl-items/gl_unit_sprite.h
df05b436926f3183066741b870039d4324a4d2ea
[]
no_license
bmjoy/centurion
1d47bcae88ccef0a27826436b586774293fbe639
5ba6a9ee7f200abc819ec5719bedfae0246609af
refs/heads/master
2022-04-16T18:00:53.984006
2020-04-17T09:35:59
2020-04-17T09:35:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
846
h
/* * --------------------------- * CENTURION * [2019] - [2020] Rattlesmake * All Rights Reserved. * --------------------------- */ #ifndef GL_UNIT_SPRITE_H #define GL_UNIT_SPRITE_H #include "gl_object_sprite.h" class glUnitSprite : public glObjectSprite { public: struct UnitData { std::map<int, int[2]> spriteSize; std::map<int, int> Frames; std::map<int, int> Durations; std::map<std::string, int> States; glm::vec3 playerColor; glm::vec3 pickingColor; std::string className; int hitBox[2]; GLint currentState; int currentFrame; int currentDir; int yOffset; int maxDirections; GLuint textureID; }; glUnitSprite(); void create(); void getTextureInfo(UnitData *uData); void render(UnitData d, glm::vec3 &pos, bool picking); ~glUnitSprite(); private: std::map<std::string, int[2]> spriteSize; }; #endif
[ "39345385+fabiomarigo7@users.noreply.github.com" ]
39345385+fabiomarigo7@users.noreply.github.com
36762857b84476f0aee8c9772016ca55cb05c053
45a392a9c51fb9f56b1c27c4b5859b00856a9080
/Barbarian.cpp
b25540ce22482f5054b0dd0df1673cb8f8db166a
[]
no_license
ScareyStory/Fantasy-Combat-2.0
8e4d9d14c131a8931fa5f9ea2fa204a13e33ccaa
b6116b31bc1f68db257b700770f0d3d0c913a8a5
refs/heads/master
2020-04-25T19:06:39.668221
2019-03-02T02:26:21
2019-03-02T02:26:21
173,007,678
0
0
null
null
null
null
UTF-8
C++
false
false
2,279
cpp
/************************************************************************** ** Program Name: Barbarian.hpp ** Name: Story Caplain ** Date: 02/07/19 ** Description: This is the .cpp file for the Barbarian class. ** It handles its specific attack and defend functions. **************************************************************************/ #include <iostream> #include <random> #include "Barbarian.hpp" Barbarian::Barbarian(int atk, int def, int arm, int str) : Character(atk,def,arm,str) {} //returns a value 2 to 12 int Barbarian::attacking() { int die1 = rand(); int die2 = rand(); //two six-sided dice means range is 2-12 die1 = (die1 % 6) + 1; die2 = (die2 % 6) + 1; int roll = die1 + die2; std::cout <<"\n"<<name<<" attacks with a roll of "<< roll << std::endl; return roll; } //returns a value 2 to 12 int Barbarian::defending() { int die1 = rand(); int die2 = rand(); //two six-sided dice means range is 2-12 die1 = (die1 % 6) + 1; die2 = (die2 % 6) + 1; int roll = die1 + die2; std::cout <<"\n"<<name<<" defends with a roll of "<< roll << std::endl; return roll; } //Updates strength value void Barbarian::setStrength(int s) { strength -= s; if(strength <= 0 && strength > -100) { strength = 0; std::cout << "\n"<<name<<" falls and clutches his fatal wound...\n"; std::cout << "He looks out to the horizon, where he knows his quest\n"; std::cout << "now failed, would have taken him. He falls to his back\n"; std::cout << "and looks up to the skies, content with a warrior's" << " death\n"; } else if(strength <= -100) { strength = 0; std::cout << "\n"<<name<<" feels his body hardening to stone...\n"; std::cout << "He yells and runs towards Medusa sword overhead!\n"; std::cout << "But freezes to stone before taking but two steps...\n"; std::cout << "Medusa laughs, and thinking it a nice statue, brings\n"; std::cout << "her foe, now of stone, back to her lair...\n"; } } //Lets a winning vampire recover some health void Barbarian::recover() { std::cout << std::endl; std::cout<<name<<" feels the rush of victory in battle!\n"; std::cout<<"...and recovers to full strength!\n\n"; strength = 12; }
[ "noreply@github.com" ]
noreply@github.com
5a66031510b2b454b41f7bd6601b54c45b999003
eaf5c173ec669b26c95f7babad40306f2c7ea459
/abc127/abc127_f.cpp
0570ae715f04fb38650cb99195e08809b3263310
[]
no_license
rikuTanide/atcoder_endeavor
657cc3ba7fbf361355376a014e3e49317fe96def
6b5dc43474d5183d8eecb8cb13bf45087c7ed195
refs/heads/master
2023-02-02T11:49:06.679743
2020-12-21T04:51:10
2020-12-21T04:51:10
318,676,396
0
0
null
null
null
null
UTF-8
C++
false
false
2,450
cpp
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; using namespace std; const double PI = 3.14159265358979323846; typedef long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) typedef pair<ll, ll> P; const ll INF = 10e17; #define cmin(x, y) x = min(x, y) #define cmax(x, y) x = max(x, y) #define ret() return 0; double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; } std::istream &operator>>(std::istream &in, set<int> &o) { int a; in >> a; o.insert(a); return in; } std::istream &operator>>(std::istream &in, queue<int> &o) { ll a; in >> a; o.push(a); return in; } bool contain(set<int> &s, int a) { return s.find(a) != s.end(); } typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK; ll f(vector<P> &fs, int k, ll x) { if (k == 0) return 0; return f(fs, k - 1, x) + abs(x - fs[k - 1].first) + fs[k - 1].second; } struct Half { priority_queue<ll> left; PQ_ASK right; ll left_sum = 0, right_sum = 0; ll half() { if (left.empty()) return 0; return left.top(); } void right_push(ll v) { right.push(v); right_sum += v; while (left.size() < right.size()) { left_sum += right.top(); right_sum -= right.top(); left.push(right.top()); right.pop(); } } void left_push(ll v) { left.push(v); left_sum += v; while (left.size() > right.size() + 1) { right_sum += left.top(); left_sum -= left.top(); right.push(left.top()); left.pop(); } } void push(ll v) { if (v >= half()) { right_push(v); } else { left_push(v); } } ll diffSum() { ll rdiffsum = right_sum - half() * right.size(); ll ldiffsum = half() * left.size() - left_sum; return rdiffsum + ldiffsum; } }; int main() { vector<P> fs; Half as; ll bsum = 0; int q; cin >> q; rep(_, q) { int method; cin >> method; if (method == 1) { ll a, b; cin >> a >> b; as.push(a); bsum += b; } else { ll t = as.half(); ll k = as.diffSum(); printf("%lld %lld\n", t, k + bsum); } } }
[ "riku@tanide.net" ]
riku@tanide.net
8cef85ab7bd3c0cc6dfd97552c89d501b49d51e8
a49f8ef3e9b5e2a2cd35f0a10db1e87903f2bf91
/doc/3.7.3/MPG/kakuro.cpp
7ff5483037cb84e80ec1ec0cd07f85b50a3071e0
[ "MIT" ]
permissive
Gecode/gecode.github.io
03008605c67c2adf30197a3fa64d0f222520a0ef
80d66747da11ce866e20cfff29669f37aa3185eb
refs/heads/master
2023-08-04T06:53:52.102092
2021-07-14T23:05:02
2021-07-14T23:05:02
119,788,513
2
4
NOASSERTION
2020-12-17T04:17:27
2018-02-01T05:41:48
HTML
UTF-8
C++
false
false
5,069
cpp
/* * Authors: * Christian Schulte <schulte@gecode.org> * Mikael Lagerkvist <lagerkvist@gecode.org> * * Copyright: * Christian Schulte, 2008-2012 * Mikael Lagerkvist, 2008-2012 * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software, to deal in the software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the software, * and to permit persons to whom the software is furnished to do so, subject * to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include <gecode/driver.hh> #include <gecode/int.hh> #include <gecode/minimodel.hh> using namespace Gecode; const int board[] = { // Dimension w x h 12, 10, // Vertical hints 3, 0, 3, 7, 4, 0, 6,21, 7, 0, 4,29, 8, 0, 2,17, 10, 0, 4,29, 11, 0, 3,23, 2, 1, 3, 6, 6, 1, 2,16, 9, 1, 4,14, 1, 2, 2, 4, 5, 2, 2, 3, 8, 3, 6,22, 3, 4, 4,10, 2, 5, 4,11, 5, 5, 4,10, 7, 5, 2,10, 10, 5, 3,24, 11, 5, 2,16, 1, 6, 3, 7, 6, 6, 2, 9, 9, 6, 3,23, 4, 7, 2, 4, -1, // Horizontal hints 2, 1, 2, 4, 6, 1, 2,17, 9, 1, 2,16, 1, 2, 3, 6, 5, 2, 6,39, 0, 3, 7,28, 8, 3, 3,24, 0, 4, 2, 3, 3, 4, 2, 3, 6, 4, 4,20, 2, 5, 2, 9, 7, 5, 2, 4, 1, 6, 4,10, 6, 6, 2, 3, 9, 6, 2,16, 0, 7, 3, 6, 4, 7, 7,42, 0, 8, 6,21, 7, 8, 3,21, 0, 9, 2, 4, 3, 9, 2, 3, 7, 9, 2,16, -1 }; class DistinctLinear : public Space { protected: IntVarArray x; public: // distinct linear script DistinctLinear(int n, int s) : x(*this,n,1,9) { distinct(*this, x); linear(*this, x, IRT_EQ, s); branch(*this, x, INT_VAR_NONE, INT_VAL_SPLIT_MIN); } // returning a solution IntArgs solution(void) const { IntArgs s(x.size()); for (int i=0; i<x.size(); i++) s[i]=x[i].val(); return s; } DistinctLinear(bool share, DistinctLinear& s) : Space(share,s) { x.update(*this, share, s.x); } virtual Space* copy(bool share) { return new DistinctLinear(share,*this); } }; void distinctlinear(Home home, const IntVarArgs& x, int c) { // set up search engine DistinctLinear* e = new DistinctLinear(x.size(),c); DFS<DistinctLinear> d(e); delete e; // compute tuple set TupleSet ts; while (DistinctLinear* s = d.next()) { ts.add(s->solution()); delete s; } ts.finalize(); // post extensional constraint extensional(home, x, ts); } class Kakuro : public Script { protected: const int w, h; IntVarArray f; public: IntVar init(IntVar& x) { if (x.min() == 0) x = IntVar(*this,1,9); return x; } // posting hint constraints void hint(const IntVarArgs& x, int s) { switch (x.size()) { case 0: break; case 1: rel(*this, x[0], IRT_EQ, s); break; case 8: rel(*this, x, IRT_NQ, 9*(9+1)/2 - s); case 9: distinct(*this, x, ICL_DOM); break; default: distinctlinear(*this, x, s); break; } } Kakuro(const Options& opt) : w(board[0]), h(board[1]), f(*this,w*h) { IntVar black(*this,0,0); for (int i=0; i<w*h; i++) f[i] = black; Matrix<IntVarArray> b(f,w,h); const int* k = &board[2]; while (*k >= 0) { int x=*k++; int y=*k++; int n=*k++; int s=*k++; IntVarArgs col(n); for (int i=0; i<n; i++) col[i]=init(b(x,y+i+1)); hint(col,s); } k++; while (*k >= 0) { int x=*k++; int y=*k++; int n=*k++; int s=*k++; IntVarArgs row(n); for (int i=0; i<n; i++) row[i]=init(b(x+i+1,y)); hint(row,s); } branch(*this, f, INT_VAR_SIZE_AFC_MIN, INT_VAL_SPLIT_MIN); } // Constructor for cloning s Kakuro(bool share, Kakuro& s) : Script(share,s), w(s.w), h(s.h) { f.update(*this, share, s.f); } // Perform copying during cloning virtual Space* copy(bool share) { return new Kakuro(share,*this); } // Print solution virtual void print(std::ostream& os) const { Matrix<IntVarArray> b(f,w,h); for (int y=0; y<h; y++) { os << '\t'; for (int x=0; x<w; x++) if (b(x,y).min() == 0) os << ". "; else os << b(x,y) << ' '; os << std::endl; } } }; int main(int argc, char* argv[]) { Options opt("Kakuro"); opt.parse(argc,argv); Script::run<Kakuro,DFS,Options>(opt); return 0; }
[ "cschulte@sics.se" ]
cschulte@sics.se
4c10cf4569ed987f147a65fea84aae48b817a753
a81c07a5663d967c432a61d0b4a09de5187be87b
/content/browser/process_internals/process_internals_handler_impl.cc
ef1c861746859d8b05f53085e8915427f4884a57
[ "BSD-3-Clause" ]
permissive
junxuezheng/chromium
c401dec07f19878501801c9e9205a703e8643031
381ce9d478b684e0df5d149f59350e3bc634dad3
refs/heads/master
2023-02-28T17:07:31.342118
2019-09-03T01:42:42
2019-09-03T01:42:42
205,967,014
2
0
BSD-3-Clause
2019-09-03T01:48:23
2019-09-03T01:48:23
null
UTF-8
C++
false
false
6,476
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/process_internals/process_internals_handler_impl.h" #include <utility> #include <vector> #include "base/strings/string_piece.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/process_internals/process_internals.mojom.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/site_isolation_policy.h" #include "content/public/browser/web_contents.h" namespace content { namespace { using IsolatedOriginSource = ChildProcessSecurityPolicy::IsolatedOriginSource; ::mojom::FrameInfoPtr FrameTreeNodeToFrameInfo(FrameTreeNode* ftn) { RenderFrameHost* frame = ftn->current_frame_host(); auto frame_info = ::mojom::FrameInfo::New(); frame_info->routing_id = frame->GetRoutingID(); frame_info->process_id = frame->GetProcess()->GetID(); frame_info->last_committed_url = frame->GetLastCommittedURL().is_valid() ? base::make_optional(frame->GetLastCommittedURL()) : base::nullopt; SiteInstanceImpl* site_instance = static_cast<SiteInstanceImpl*>(frame->GetSiteInstance()); frame_info->site_instance = ::mojom::SiteInstanceInfo::New(); frame_info->site_instance->id = site_instance->GetId(); auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); frame_info->site_instance->locked = !policy->GetOriginLock(site_instance->GetProcess()->GetID()).is_empty(); frame_info->site_instance->site_url = site_instance->HasSite() ? base::make_optional(site_instance->GetSiteURL()) : base::nullopt; for (size_t i = 0; i < ftn->child_count(); ++i) { frame_info->subframes.push_back(FrameTreeNodeToFrameInfo(ftn->child_at(i))); } return frame_info; } std::string IsolatedOriginSourceToString(IsolatedOriginSource source) { switch (source) { case IsolatedOriginSource::BUILT_IN: return "Built-in"; case IsolatedOriginSource::COMMAND_LINE: return "Command line"; case IsolatedOriginSource::FIELD_TRIAL: return "Field trial"; case IsolatedOriginSource::POLICY: return "Device policy"; case IsolatedOriginSource::TEST: return "Test"; case IsolatedOriginSource::USER_TRIGGERED: return "User-triggered"; default: NOTREACHED(); return ""; } } } // namespace ProcessInternalsHandlerImpl::ProcessInternalsHandlerImpl( BrowserContext* browser_context, mojo::InterfaceRequest<::mojom::ProcessInternalsHandler> request) : browser_context_(browser_context), binding_(this, std::move(request)) {} ProcessInternalsHandlerImpl::~ProcessInternalsHandlerImpl() = default; void ProcessInternalsHandlerImpl::GetIsolationMode( GetIsolationModeCallback callback) { std::vector<base::StringPiece> modes; if (SiteIsolationPolicy::UseDedicatedProcessesForAllSites()) modes.push_back("Site Per Process"); if (SiteIsolationPolicy::AreIsolatedOriginsEnabled()) modes.push_back("Isolate Origins"); if (SiteIsolationPolicy::IsStrictOriginIsolationEnabled()) modes.push_back("Strict Origin Isolation"); // Retrieve any additional site isolation modes controlled by the embedder. std::vector<std::string> additional_modes = GetContentClient()->browser()->GetAdditionalSiteIsolationModes(); std::move(additional_modes.begin(), additional_modes.end(), std::back_inserter(modes)); std::move(callback).Run(modes.empty() ? "Disabled" : base::JoinString(modes, ", ")); } void ProcessInternalsHandlerImpl::GetUserTriggeredIsolatedOrigins( GetUserTriggeredIsolatedOriginsCallback callback) { // Retrieve serialized user-triggered isolated origins for the current // profile (i.e., profile from which chrome://process-internals is shown). // Note that this may differ from the list of stored user-triggered isolated // origins if the user clears browsing data. Clearing browsing data clears // stored isolated origins right away, but the corresponding origins in // ChildProcessSecurityPolicy will stay active until next restart, and hence // they will still be present in this list. auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); std::vector<std::string> serialized_origins; for (const auto& origin : policy->GetIsolatedOrigins( IsolatedOriginSource::USER_TRIGGERED, browser_context_)) { serialized_origins.push_back(origin.Serialize()); } std::move(callback).Run(std::move(serialized_origins)); } void ProcessInternalsHandlerImpl::GetGloballyIsolatedOrigins( GetGloballyIsolatedOriginsCallback callback) { auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); std::vector<::mojom::IsolatedOriginInfoPtr> origins; // The following global isolated origin sources are safe to show to the user. // Any new sources should only be added here if they are ok to be shown on // chrome://process-internals. for (IsolatedOriginSource source : {IsolatedOriginSource::BUILT_IN, IsolatedOriginSource::COMMAND_LINE, IsolatedOriginSource::FIELD_TRIAL, IsolatedOriginSource::POLICY, IsolatedOriginSource::TEST}) { for (const auto& origin : policy->GetIsolatedOrigins(source)) { auto info = ::mojom::IsolatedOriginInfo::New(); info->origin = origin.Serialize(); info->source = IsolatedOriginSourceToString(source); origins.push_back(std::move(info)); } } std::move(callback).Run(std::move(origins)); } void ProcessInternalsHandlerImpl::GetAllWebContentsInfo( GetAllWebContentsInfoCallback callback) { std::vector<::mojom::WebContentsInfoPtr> infos; std::vector<WebContentsImpl*> all_contents = WebContentsImpl::GetAllWebContents(); for (WebContentsImpl* web_contents : all_contents) { // Do not return WebContents that don't belong to the current // BrowserContext to avoid leaking data between contexts. if (web_contents->GetBrowserContext() != browser_context_) continue; auto info = ::mojom::WebContentsInfo::New(); info->title = base::UTF16ToUTF8(web_contents->GetTitle()); info->root_frame = FrameTreeNodeToFrameInfo(web_contents->GetFrameTree()->root()); infos.push_back(std::move(info)); } std::move(callback).Run(std::move(infos)); } } // namespace content
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
74d5244f5fede11a3da466ecdedc427b3efd1c41
fe81ec78a27895f0ff98450dc2b7e4a42a35b1ab
/biped controller 2D/proj279-code/proj279/src/Cartwheel/WorldOracle.cpp
44da31631b246036c801319286ced0afcd71c8d1
[]
no_license
lillianwang16/biped_walk_controller
a4a1cb79a6c87c4d1cdbda8c9da2911a64cca56e
e408162c3e7af87d081a5e70eb97c245e6cdff07
refs/heads/master
2021-01-23T02:15:06.825074
2017-03-26T04:43:42
2017-03-26T04:43:42
85,972,812
0
1
null
null
null
null
UTF-8
C++
false
false
85
cpp
#include "Cartwheel/WorldOracle.h" b2Vec2 WorldOracle::debug_point_ = b2Vec2(0, 0);
[ "lillianwang16@gmail.com" ]
lillianwang16@gmail.com
0a2656bf4928e316cea7f3d2fa30892ec35b436e
db405d500ae599ffc8ee34d01fe6f78f155c02bc
/src/JustAClass.h
22e77c2635db3e19ed3a2be84f5a373dcbae1c33
[]
no_license
sr26551/demo_pointers_vectors
5c434ee64a6de730cb8f3193d1c89f7e0b6ecc44
b01b179b3291beeeca8461753bf3a276e9d6c998
refs/heads/master
2023-04-17T22:08:06.916930
2019-11-01T11:29:42
2019-11-01T11:29:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
257
h
/* * JustAClass.h * * Created on: Nov 1, 2017 * Author: keith */ #ifndef JUSTACLASS_H_ #define JUSTACLASS_H_ class JustAClass { public: JustAClass(int i); virtual ~JustAClass(); void speak(); private: int i; }; #endif /* JUSTACLASS_H_ */
[ "kperkins411@gmail.com" ]
kperkins411@gmail.com
c553190d75e2868b9ae5b1d9ec75a3e7c831fadd
5af425947667c8309695b5dea5ca9a7c834801df
/analysis/src/topAnalysis.h
2519d8a407773c0a51492801efea93e6103810db
[]
no_license
CPLUOS/nanoOld
223f0e2343e7afcf1ba0c057b53f6b05f435eba5
9d6e22b88784c41180e1c4df66aa1073ece33590
refs/heads/master
2020-03-07T00:40:36.833370
2018-04-01T15:17:31
2018-04-01T15:17:31
127,163,331
0
0
null
null
null
null
UTF-8
C++
false
false
42,037
h
////////////////////////////////////////////////////////// // This class has been automatically generated on // Thu Jan 18 21:36:33 2018 by ROOT version 6.10/09 // from TTree Events/Events // found on file: /home/nanoAOD/run2_2016v3/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/RunIISummer16MiniAODv2-PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6_ext2-v1/180117_180123/0000/nanoAOD_111.root ////////////////////////////////////////////////////////// #ifndef topAnalysis_h #define topAnalysis_h #include <TROOT.h> #include <TChain.h> #include <TFile.h> #include <TLorentzVector.h> #include <TParticle.h> #include <TH1D.h> #include <vector> #include "RoccoR.cc" #include "pileUpTool.h" #include "MuonScaleFactorEvaluator.h" #include "ElecScaleFactorEvaluator.h" #include "json.h" #include "lumiTool.h" #include "BTagWeightEvaluator.h" //#include "TopTriggerSF.h" //#include "TTbarModeDefs.h" // Header file for the classes stored in the TTree if any. class topAnalysis { //Output Variables private: TFile* m_output; //Tree TTree* m_tree; //histogram TH1D* h_nevents; TH1D* h_genweights; TH1D* h_weights; TH1D* h_cutFlow; //Variables TLorentzVector b_lep1, b_lep2, b_dilep, b_jet1, b_jet2; TParticle recolep1, recolep2; int b_lep1_pid, b_lep2_pid; float b_jet1_CSVInclV2, b_jet2_CSVInclV2; std::vector<Float_t> b_csvweights; int b_nvertex, b_step, b_channel, b_njet, b_nbjet; bool b_step1, b_step2, b_step3, b_step4, b_step5, b_step6, b_step7; float b_met, b_weight, b_genweight, b_puweight, b_btagweight; float b_mueffweight, b_mueffweight_up, b_mueffweight_dn, b_eleffweight, b_eleffweight_up, b_eleffweight_dn; //float b_tri, b_tri_up, b_tri_dn; //Triggers Bool_t b_trig_m, b_trig_m2, b_trig_e, b_trig_mm, b_trig_em, b_trig_ee; // Tools RoccoR* m_rocCor; TH1D* hist_mc; MuonScaleFactorEvaluator muonSF_; ElecScaleFactorEvaluator elecSF_; BTagWeightEvaluator m_btagSF; pileUpTool *m_pileUp; lumiTool* m_lumi; //LumiMap std::map<UInt_t, std::vector<std::array<UInt_t, 2>>> lumiMap; //Making output branch void MakeBranch(TTree* t); void resetBranch(); void analysis(); //For Selection Bool_t lumiCheck(); enum TTLLChannel { CH_NOLL = 0, CH_MUEL, CH_ELEL, CH_MUMU }; std::vector<TParticle> muonSelection(); std::vector<TParticle> elecSelection(); std::vector<TLorentzVector> recoleps; std::vector<TParticle> jetSelection(); std::vector<TParticle> bjetSelection(); Double_t roccoR(TLorentzVector m, int q, int nGen, int nTrackerLayers); public : //set output file void setOutput(std::string outputName); void LoadModules(pileUpTool* pileUp, lumiTool* lumi); TTree *fChain; //!pointer to the analyzed TTree or TChain Int_t fCurrent; //!current Tree number in a TChain Bool_t m_isMC; Bool_t m_isDL; Bool_t m_isSL_e; Bool_t m_isSL_m; // Fixed size dimensions of array or collections stored in the TTree if any. // Declaration of leaf types UInt_t run; UInt_t luminosityBlock; ULong64_t event; Float_t CaloMET_phi; Float_t CaloMET_pt; Float_t CaloMET_sumEt; UInt_t ncmeson; Float_t cmeson_dca[63]; //[ncmeson] Float_t cmeson_angleXY[63]; //[ncmeson] Float_t cmeson_angleXYZ[63]; //[ncmeson] Float_t cmeson_trk_normalizedChi2[63]; //[ncmeson] Float_t cmeson_trk_nHits[63]; //[ncmeson] Float_t cmeson_trk_pt[63]; //[ncmeson] Float_t cmeson_trk_ipsigXY[63]; //[ncmeson] Float_t cmeson_trk_ipsigZ[63]; //[ncmeson] Float_t cmeson_lxy[63]; //[ncmeson] Float_t cmeson_lxySig[63]; //[ncmeson] Float_t cmeson_l3D[63]; //[ncmeson] Float_t cmeson_l3DSig[63]; //[ncmeson] Float_t cmeson_jetDR[63]; //[ncmeson] Float_t cmeson_legDR[63]; //[ncmeson] Float_t cmeson_diffMass[63]; //[ncmeson] Int_t cmeson_nJet[63]; //[ncmeson] Int_t cmeson_mcMatch[63]; //[ncmeson] UInt_t nElectron; Float_t Electron_deltaEtaSC[6]; //[nElectron] Float_t Electron_dr03EcalRecHitSumEt[6]; //[nElectron] Float_t Electron_dr03HcalDepth1TowerSumEt[6]; //[nElectron] Float_t Electron_dr03TkSumPt[6]; //[nElectron] Float_t Electron_dxy[6]; //[nElectron] Float_t Electron_dxyErr[6]; //[nElectron] Float_t Electron_dz[6]; //[nElectron] Float_t Electron_dzErr[6]; //[nElectron] Float_t Electron_eCorr[6]; //[nElectron] Float_t Electron_eInvMinusPInv[6]; //[nElectron] Float_t Electron_energyErr[6]; //[nElectron] Float_t Electron_eta[6]; //[nElectron] Float_t Electron_hoe[6]; //[nElectron] Float_t Electron_ip3d[6]; //[nElectron] Float_t Electron_mass[6]; //[nElectron] Float_t Electron_miniPFRelIso_all[6]; //[nElectron] Float_t Electron_miniPFRelIso_chg[6]; //[nElectron] Float_t Electron_mvaSpring16GP[6]; //[nElectron] Float_t Electron_mvaSpring16HZZ[6]; //[nElectron] Float_t Electron_pfRelIso03_all[6]; //[nElectron] Float_t Electron_pfRelIso03_chg[6]; //[nElectron] Float_t Electron_phi[6]; //[nElectron] Float_t Electron_pt[6]; //[nElectron] Float_t Electron_r9[6]; //[nElectron] Float_t Electron_sieie[6]; //[nElectron] Float_t Electron_sip3d[6]; //[nElectron] Float_t Electron_mvaTTH[6]; //[nElectron] Int_t Electron_charge[6]; //[nElectron] Int_t Electron_cutBased[6]; //[nElectron] Int_t Electron_cutBased_HLTPreSel[6]; //[nElectron] Int_t Electron_jetIdx[6]; //[nElectron] Int_t Electron_pdgId[6]; //[nElectron] Int_t Electron_photonIdx[6]; //[nElectron] Int_t Electron_tightCharge[6]; //[nElectron] Int_t Electron_vidNestedWPBitmap[6]; //[nElectron] Bool_t Electron_convVeto[6]; //[nElectron] Bool_t Electron_cutBased_HEEP[6]; //[nElectron] Bool_t Electron_isPFcand[6]; //[nElectron] UChar_t Electron_lostHits[6]; //[nElectron] Bool_t Electron_mvaSpring16GP_WP80[6]; //[nElectron] Bool_t Electron_mvaSpring16GP_WP90[6]; //[nElectron] Bool_t Electron_mvaSpring16HZZ_WPL[6]; //[nElectron] UInt_t nGenPart; Float_t GenPart_eta[102]; //[nGenPart] Float_t GenPart_mass[102]; //[nGenPart] Float_t GenPart_phi[102]; //[nGenPart] Float_t GenPart_pt[102]; //[nGenPart] Int_t GenPart_genPartIdxMother[102]; //[nGenPart] Int_t GenPart_pdgId[102]; //[nGenPart] Int_t GenPart_status[102]; //[nGenPart] Int_t GenPart_statusFlags[102]; //[nGenPart] Float_t Generator_scalePDF; Float_t Generator_x1; Float_t Generator_x2; Float_t Generator_xpdf1; Float_t Generator_xpdf2; Int_t Generator_id1; Int_t Generator_id2; Float_t genWeight; UInt_t nJet; Float_t Jet_area[35]; //[nJet] Float_t Jet_btagCMVA[35]; //[nJet] Float_t Jet_btagCSVV2[35]; //[nJet] Float_t Jet_btagDeepB[35]; //[nJet] Float_t Jet_btagDeepC[35]; //[nJet] Float_t Jet_chEmEF[35]; //[nJet] Float_t Jet_chHEF[35]; //[nJet] Float_t Jet_eta[35]; //[nJet] Float_t Jet_mass[35]; //[nJet] Float_t Jet_neEmEF[35]; //[nJet] Float_t Jet_neHEF[35]; //[nJet] Float_t Jet_phi[35]; //[nJet] Float_t Jet_pt[35]; //[nJet] Float_t Jet_qgl[35]; //[nJet] Float_t Jet_rawFactor[35]; //[nJet] Float_t Jet_bReg[35]; //[nJet] Int_t Jet_electronIdx1[35]; //[nJet] Int_t Jet_electronIdx2[35]; //[nJet] Int_t Jet_jetId[35]; //[nJet] Int_t Jet_muonIdx1[35]; //[nJet] Int_t Jet_muonIdx2[35]; //[nJet] Int_t Jet_nConstituents[35]; //[nJet] Int_t Jet_nElectrons[35]; //[nJet] Int_t Jet_nMuons[35]; //[nJet] Int_t Jet_puId[35]; //[nJet] Float_t MET_MetUnclustEnUpDeltaX; Float_t MET_MetUnclustEnUpDeltaY; Float_t MET_covXX; Float_t MET_covXY; Float_t MET_covYY; Float_t MET_phi; Float_t MET_pt; Float_t MET_significance; Float_t MET_sumEt; UInt_t nMuon; Float_t Muon_dxy[10]; //[nMuon] Float_t Muon_dxyErr[10]; //[nMuon] Float_t Muon_dz[10]; //[nMuon] Float_t Muon_dzErr[10]; //[nMuon] Float_t Muon_eta[10]; //[nMuon] Float_t Muon_ip3d[10]; //[nMuon] Float_t Muon_mass[10]; //[nMuon] Float_t Muon_miniPFRelIso_all[10]; //[nMuon] Float_t Muon_miniPFRelIso_chg[10]; //[nMuon] Float_t Muon_pfRelIso03_all[10]; //[nMuon] Float_t Muon_pfRelIso03_chg[10]; //[nMuon] Float_t Muon_pfRelIso04_all[10]; //[nMuon] Float_t Muon_phi[10]; //[nMuon] Float_t Muon_pt[10]; //[nMuon] Float_t Muon_ptErr[10]; //[nMuon] Float_t Muon_segmentComp[10]; //[nMuon] Float_t Muon_sip3d[10]; //[nMuon] Float_t Muon_mvaTTH[10]; //[nMuon] Int_t Muon_charge[10]; //[nMuon] Int_t Muon_jetIdx[10]; //[nMuon] Int_t Muon_nStations[10]; //[nMuon] Int_t Muon_nTrackerLayers[10]; //[nMuon] Int_t Muon_pdgId[10]; //[nMuon] Int_t Muon_tightCharge[10]; //[nMuon] Bool_t Muon_globalMu[10]; //[nMuon] UChar_t Muon_highPtId[10]; //[nMuon] Bool_t Muon_isPFcand[10]; //[nMuon] Bool_t Muon_mediumId[10]; //[nMuon] Bool_t Muon_softId[10]; //[nMuon] Bool_t Muon_tightId[10]; //[nMuon] Bool_t Muon_trackerMu[10]; //[nMuon] Int_t Pileup_nPU; Float_t Pileup_nTrueInt; UInt_t nTrigObj; Float_t TrigObj_pt[28]; //[nTrigObj] Float_t TrigObj_eta[28]; //[nTrigObj] Float_t TrigObj_phi[28]; //[nTrigObj] Float_t TrigObj_l1pt[28]; //[nTrigObj] Float_t TrigObj_l1pt_2[28]; //[nTrigObj] Float_t TrigObj_l2pt[28]; //[nTrigObj] Int_t TrigObj_id[28]; //[nTrigObj] Int_t TrigObj_l1iso[28]; //[nTrigObj] Int_t TrigObj_l1charge[28]; //[nTrigObj] Int_t TrigObj_filterBits[28]; //[nTrigObj] Int_t genTtbarId; UInt_t nOtherPV; Float_t OtherPV_z[3]; //[nOtherPV] Float_t PV_ndof; Float_t PV_x; Float_t PV_y; Float_t PV_z; Float_t PV_chi2; Float_t PV_score; Int_t PV_npvs; Float_t cmeson_chi2[63]; //[ncmeson] Float_t cmeson_eta[63]; //[ncmeson] Float_t cmeson_mass[63]; //[ncmeson] Float_t cmeson_phi[63]; //[ncmeson] Float_t cmeson_pt[63]; //[ncmeson] Float_t cmeson_x[63]; //[ncmeson] Float_t cmeson_y[63]; //[ncmeson] Float_t cmeson_z[63]; //[ncmeson] Int_t cmeson_ndof[63]; //[ncmeson] Int_t cmeson_pdgId[63]; //[ncmeson] Int_t Electron_genPartIdx[6]; //[nElectron] UChar_t Electron_genPartFlav[6]; //[nElectron] Int_t Jet_genJetIdx[35]; //[nJet] Int_t Jet_hadronFlavour[35]; //[nJet] Int_t Jet_partonFlavour[35]; //[nJet] Int_t Muon_genPartIdx[10]; //[nMuon] UChar_t Muon_genPartFlav[10]; //[nMuon] UChar_t Electron_cleanmask[6]; //[nElectron] UChar_t Jet_cleanmask[35]; //[nJet] UChar_t Muon_cleanmask[10]; //[nMuon] Bool_t HLT_Ele27_WPTight_Gsf; Bool_t HLT_IsoMu24; Bool_t HLT_IsoTkMu24; Bool_t HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL; Bool_t HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ; Bool_t HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL; Bool_t HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ; Bool_t HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ; Bool_t HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL; Bool_t HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ; Bool_t HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL; Bool_t HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ; // List of branches TBranch *b_run; //! TBranch *b_luminosityBlock; //! TBranch *b_event; //! TBranch *b_CaloMET_phi; //! TBranch *b_CaloMET_pt; //! TBranch *b_CaloMET_sumEt; //! TBranch *b_ncmeson; //! TBranch *b_cmeson_dca; //! TBranch *b_cmeson_angleXY; //! TBranch *b_cmeson_angleXYZ; //! TBranch *b_cmeson_trk_normalizedChi2; //! TBranch *b_cmeson_trk_nHits; //! TBranch *b_cmeson_trk_pt; //! TBranch *b_cmeson_trk_ipsigXY; //! TBranch *b_cmeson_trk_ipsigZ; //! TBranch *b_cmeson_lxy; //! TBranch *b_cmeson_lxySig; //! TBranch *b_cmeson_l3D; //! TBranch *b_cmeson_l3DSig; //! TBranch *b_cmeson_jetDR; //! TBranch *b_cmeson_legDR; //! TBranch *b_cmeson_diffMass; //! TBranch *b_cmeson_nJet; //! TBranch *b_cmeson_mcMatch; //! TBranch *b_nElectron; //! TBranch *b_Electron_deltaEtaSC; //! TBranch *b_Electron_dr03EcalRecHitSumEt; //! TBranch *b_Electron_dr03HcalDepth1TowerSumEt; //! TBranch *b_Electron_dr03TkSumPt; //! TBranch *b_Electron_dxy; //! TBranch *b_Electron_dxyErr; //! TBranch *b_Electron_dz; //! TBranch *b_Electron_dzErr; //! TBranch *b_Electron_eCorr; //! TBranch *b_Electron_eInvMinusPInv; //! TBranch *b_Electron_energyErr; //! TBranch *b_Electron_eta; //! TBranch *b_Electron_hoe; //! TBranch *b_Electron_ip3d; //! TBranch *b_Electron_mass; //! TBranch *b_Electron_miniPFRelIso_all; //! TBranch *b_Electron_miniPFRelIso_chg; //! TBranch *b_Electron_mvaSpring16GP; //! TBranch *b_Electron_mvaSpring16HZZ; //! TBranch *b_Electron_pfRelIso03_all; //! TBranch *b_Electron_pfRelIso03_chg; //! TBranch *b_Electron_phi; //! TBranch *b_Electron_pt; //! TBranch *b_Electron_r9; //! TBranch *b_Electron_sieie; //! TBranch *b_Electron_sip3d; //! TBranch *b_Electron_mvaTTH; //! TBranch *b_Electron_charge; //! TBranch *b_Electron_cutBased; //! TBranch *b_Electron_cutBased_HLTPreSel; //! TBranch *b_Electron_jetIdx; //! TBranch *b_Electron_pdgId; //! TBranch *b_Electron_photonIdx; //! TBranch *b_Electron_tightCharge; //! TBranch *b_Electron_vidNestedWPBitmap; //! TBranch *b_Electron_convVeto; //! TBranch *b_Electron_cutBased_HEEP; //! TBranch *b_Electron_isPFcand; //! TBranch *b_Electron_lostHits; //! TBranch *b_Electron_mvaSpring16GP_WP80; //! TBranch *b_Electron_mvaSpring16GP_WP90; //! TBranch *b_Electron_mvaSpring16HZZ_WPL; //! TBranch *b_nGenPart; //! TBranch *b_GenPart_eta; //! TBranch *b_GenPart_mass; //! TBranch *b_GenPart_phi; //! TBranch *b_GenPart_pt; //! TBranch *b_GenPart_genPartIdxMother; //! TBranch *b_GenPart_pdgId; //! TBranch *b_GenPart_status; //! TBranch *b_GenPart_statusFlags; //! TBranch *b_Generator_scalePDF; //! TBranch *b_Generator_x1; //! TBranch *b_Generator_x2; //! TBranch *b_Generator_xpdf1; //! TBranch *b_Generator_xpdf2; //! TBranch *b_Generator_id1; //! TBranch *b_Generator_id2; //! TBranch *b_genWeight; //! TBranch *b_nJet; //! TBranch *b_Jet_area; //! TBranch *b_Jet_btagCMVA; //! TBranch *b_Jet_btagCSVV2; //! TBranch *b_Jet_btagDeepB; //! TBranch *b_Jet_btagDeepC; //! TBranch *b_Jet_chEmEF; //! TBranch *b_Jet_chHEF; //! TBranch *b_Jet_eta; //! TBranch *b_Jet_mass; //! TBranch *b_Jet_neEmEF; //! TBranch *b_Jet_neHEF; //! TBranch *b_Jet_phi; //! TBranch *b_Jet_pt; //! TBranch *b_Jet_qgl; //! TBranch *b_Jet_rawFactor; //! TBranch *b_Jet_bReg; //! TBranch *b_Jet_electronIdx1; //! TBranch *b_Jet_electronIdx2; //! TBranch *b_Jet_jetId; //! TBranch *b_Jet_muonIdx1; //! TBranch *b_Jet_muonIdx2; //! TBranch *b_Jet_nConstituents; //! TBranch *b_Jet_nElectrons; //! TBranch *b_Jet_nMuons; //! TBranch *b_Jet_puId; //! TBranch *b_MET_MetUnclustEnUpDeltaX; //! TBranch *b_MET_MetUnclustEnUpDeltaY; //! TBranch *b_MET_covXX; //! TBranch *b_MET_covXY; //! TBranch *b_MET_covYY; //! TBranch *b_MET_phi; //! TBranch *b_MET_pt; //! TBranch *b_MET_significance; //! TBranch *b_MET_sumEt; //! TBranch *b_nMuon; //! TBranch *b_Muon_dxy; //! TBranch *b_Muon_dxyErr; //! TBranch *b_Muon_dz; //! TBranch *b_Muon_dzErr; //! TBranch *b_Muon_eta; //! TBranch *b_Muon_ip3d; //! TBranch *b_Muon_mass; //! TBranch *b_Muon_miniPFRelIso_all; //! TBranch *b_Muon_miniPFRelIso_chg; //! TBranch *b_Muon_pfRelIso03_all; //! TBranch *b_Muon_pfRelIso03_chg; //! TBranch *b_Muon_pfRelIso04_all; //! TBranch *b_Muon_phi; //! TBranch *b_Muon_pt; //! TBranch *b_Muon_ptErr; //! TBranch *b_Muon_segmentComp; //! TBranch *b_Muon_sip3d; //! TBranch *b_Muon_mvaTTH; //! TBranch *b_Muon_charge; //! TBranch *b_Muon_jetIdx; //! TBranch *b_Muon_nStations; //! TBranch *b_Muon_nTrackerLayers; //! TBranch *b_Muon_pdgId; //! TBranch *b_Muon_tightCharge; //! TBranch *b_Muon_globalMu; //! TBranch *b_Muon_highPtId; //! TBranch *b_Muon_isPFcand; //! TBranch *b_Muon_mediumId; //! TBranch *b_Muon_softId; //! TBranch *b_Muon_tightId; //! TBranch *b_Muon_trackerMu; //! TBranch *b_Pileup_nPU; //! TBranch *b_Pileup_nTrueInt; //! TBranch *b_nTrigObj; //! TBranch *b_TrigObj_pt; //! TBranch *b_TrigObj_eta; //! TBranch *b_TrigObj_phi; //! TBranch *b_TrigObj_l1pt; //! TBranch *b_TrigObj_l1pt_2; //! TBranch *b_TrigObj_l2pt; //! TBranch *b_TrigObj_id; //! TBranch *b_TrigObj_l1iso; //! TBranch *b_TrigObj_l1charge; //! TBranch *b_TrigObj_filterBits; //! TBranch *b_genTtbarId; //! TBranch *b_nOtherPV; //! TBranch *b_OtherPV_z; //! TBranch *b_PV_ndof; //! TBranch *b_PV_x; //! TBranch *b_PV_y; //! TBranch *b_PV_z; //! TBranch *b_PV_chi2; //! TBranch *b_PV_score; //! TBranch *b_PV_npvs; //! TBranch *b_cmeson_chi2; //! TBranch *b_cmeson_eta; //! TBranch *b_cmeson_mass; //! TBranch *b_cmeson_phi; //! TBranch *b_cmeson_pt; //! TBranch *b_cmeson_x; //! TBranch *b_cmeson_y; //! TBranch *b_cmeson_z; //! TBranch *b_cmeson_ndof; //! TBranch *b_cmeson_pdgId; //! TBranch *b_Electron_genPartIdx; //! TBranch *b_Electron_genPartFlav; //! TBranch *b_Jet_genJetIdx; //! TBranch *b_Jet_hadronFlavour; //! TBranch *b_Jet_partonFlavour; //! TBranch *b_Muon_genPartIdx; //! TBranch *b_Muon_genPartFlav; //! TBranch *b_Electron_cleanmask; //! TBranch *b_Jet_cleanmask; //! TBranch *b_Muon_cleanmask; //! TBranch *b_HLT_Ele27_WPTight_Gsf; //! TBranch *b_HLT_IsoMu24; //! TBranch *b_HLT_IsoTkMu24; //! TBranch *b_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL; //! TBranch *b_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ; //! TBranch *b_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL; //! TBranch *b_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ; //! TBranch *b_HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ; TBranch *b_HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL; //! TBranch *b_HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ; //! TBranch *b_HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL; //! TBranch *b_HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ; //! topAnalysis(TTree *tree=0, Bool_t flag = false, Bool_t dl = false, Bool_t sle = false, Bool_t slm = false); virtual ~topAnalysis(); virtual Int_t Cut(Long64_t entry); virtual Int_t GetEntry(Long64_t entry); virtual Long64_t LoadTree(Long64_t entry); virtual void Init(TTree *tree); virtual void Loop(); virtual Bool_t Notify(); virtual void Show(Long64_t entry = -1); }; #endif #ifdef topAnalysis_cxx topAnalysis::topAnalysis(TTree *tree, Bool_t flag, Bool_t dl, Bool_t sle, Bool_t slm) : fChain(0), m_isMC(flag), m_isDL(dl), m_isSL_e(sle), m_isSL_m(slm) { // if parameter tree is not specified (or zero), connect the file // used to generate this class and read the Tree. if (tree == 0) { TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/home/nanoAOD/run2_2016v3/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/RunIISummer16MiniAODv2-PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6_ext2-v1/180117_180123/0000/nanoAOD_111.root"); if (!f || !f->IsOpen()) { f = TFile::Open("/home/nanoAOD/run2_2016v3/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/RunIISummer16MiniAODv2-PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6_ext2-v1/180117_180123/0000/nanoAOD_111.root"); } f->GetObject("Events",tree); } Init(tree); } topAnalysis::~topAnalysis() { if (!fChain) return; delete fChain->GetCurrentFile(); m_output->Write(); m_output->Close(); } Int_t topAnalysis::GetEntry(Long64_t entry) { // Read contents of entry. if (!fChain) return 0; return fChain->GetEntry(entry); } Long64_t topAnalysis::LoadTree(Long64_t entry) { // Set the environment to read one entry if (!fChain) return -5; Long64_t centry = fChain->LoadTree(entry); if (centry < 0) return centry; if (fChain->GetTreeNumber() != fCurrent) { fCurrent = fChain->GetTreeNumber(); Notify(); } return centry; } void topAnalysis::Init(TTree *tree) { // The Init() function is called when the selector needs to initialize // a new tree or chain. Typically here the branch addresses and branch // pointers of the tree will be set. // It is normally not necessary to make changes to the generated // code, but the routine can be extended by the user if needed. // Init() will be called many times when running on PROOF // (once per file to be processed). // Set branch addresses and branch pointers if (!tree) return; fChain = tree; fCurrent = -1; fChain->SetMakeClass(1); fChain->SetBranchAddress("run", &run, &b_run); fChain->SetBranchAddress("luminosityBlock", &luminosityBlock, &b_luminosityBlock); fChain->SetBranchAddress("event", &event, &b_event); fChain->SetBranchAddress("CaloMET_phi", &CaloMET_phi, &b_CaloMET_phi); fChain->SetBranchAddress("CaloMET_pt", &CaloMET_pt, &b_CaloMET_pt); fChain->SetBranchAddress("CaloMET_sumEt", &CaloMET_sumEt, &b_CaloMET_sumEt); fChain->SetBranchAddress("ncmeson", &ncmeson, &b_ncmeson); fChain->SetBranchAddress("cmeson_dca", cmeson_dca, &b_cmeson_dca); fChain->SetBranchAddress("cmeson_angleXY", cmeson_angleXY, &b_cmeson_angleXY); fChain->SetBranchAddress("cmeson_angleXYZ", cmeson_angleXYZ, &b_cmeson_angleXYZ); fChain->SetBranchAddress("cmeson_trk_normalizedChi2", cmeson_trk_normalizedChi2, &b_cmeson_trk_normalizedChi2); fChain->SetBranchAddress("cmeson_trk_nHits", cmeson_trk_nHits, &b_cmeson_trk_nHits); fChain->SetBranchAddress("cmeson_trk_pt", cmeson_trk_pt, &b_cmeson_trk_pt); fChain->SetBranchAddress("cmeson_trk_ipsigXY", cmeson_trk_ipsigXY, &b_cmeson_trk_ipsigXY); fChain->SetBranchAddress("cmeson_trk_ipsigZ", cmeson_trk_ipsigZ, &b_cmeson_trk_ipsigZ); fChain->SetBranchAddress("cmeson_lxy", cmeson_lxy, &b_cmeson_lxy); fChain->SetBranchAddress("cmeson_lxySig", cmeson_lxySig, &b_cmeson_lxySig); fChain->SetBranchAddress("cmeson_l3D", cmeson_l3D, &b_cmeson_l3D); fChain->SetBranchAddress("cmeson_l3DSig", cmeson_l3DSig, &b_cmeson_l3DSig); fChain->SetBranchAddress("cmeson_jetDR", cmeson_jetDR, &b_cmeson_jetDR); fChain->SetBranchAddress("cmeson_legDR", cmeson_legDR, &b_cmeson_legDR); fChain->SetBranchAddress("cmeson_diffMass", cmeson_diffMass, &b_cmeson_diffMass); fChain->SetBranchAddress("cmeson_nJet", cmeson_nJet, &b_cmeson_nJet); fChain->SetBranchAddress("cmeson_mcMatch", cmeson_mcMatch, &b_cmeson_mcMatch); fChain->SetBranchAddress("nElectron", &nElectron, &b_nElectron); fChain->SetBranchAddress("Electron_deltaEtaSC", Electron_deltaEtaSC, &b_Electron_deltaEtaSC); fChain->SetBranchAddress("Electron_dr03EcalRecHitSumEt", Electron_dr03EcalRecHitSumEt, &b_Electron_dr03EcalRecHitSumEt); fChain->SetBranchAddress("Electron_dr03HcalDepth1TowerSumEt", Electron_dr03HcalDepth1TowerSumEt, &b_Electron_dr03HcalDepth1TowerSumEt); fChain->SetBranchAddress("Electron_dr03TkSumPt", Electron_dr03TkSumPt, &b_Electron_dr03TkSumPt); fChain->SetBranchAddress("Electron_dxy", Electron_dxy, &b_Electron_dxy); fChain->SetBranchAddress("Electron_dxyErr", Electron_dxyErr, &b_Electron_dxyErr); fChain->SetBranchAddress("Electron_dz", Electron_dz, &b_Electron_dz); fChain->SetBranchAddress("Electron_dzErr", Electron_dzErr, &b_Electron_dzErr); fChain->SetBranchAddress("Electron_eCorr", Electron_eCorr, &b_Electron_eCorr); fChain->SetBranchAddress("Electron_eInvMinusPInv", Electron_eInvMinusPInv, &b_Electron_eInvMinusPInv); fChain->SetBranchAddress("Electron_energyErr", Electron_energyErr, &b_Electron_energyErr); fChain->SetBranchAddress("Electron_eta", Electron_eta, &b_Electron_eta); fChain->SetBranchAddress("Electron_hoe", Electron_hoe, &b_Electron_hoe); fChain->SetBranchAddress("Electron_ip3d", Electron_ip3d, &b_Electron_ip3d); fChain->SetBranchAddress("Electron_mass", Electron_mass, &b_Electron_mass); fChain->SetBranchAddress("Electron_miniPFRelIso_all", Electron_miniPFRelIso_all, &b_Electron_miniPFRelIso_all); fChain->SetBranchAddress("Electron_miniPFRelIso_chg", Electron_miniPFRelIso_chg, &b_Electron_miniPFRelIso_chg); fChain->SetBranchAddress("Electron_mvaSpring16GP", Electron_mvaSpring16GP, &b_Electron_mvaSpring16GP); fChain->SetBranchAddress("Electron_mvaSpring16HZZ", Electron_mvaSpring16HZZ, &b_Electron_mvaSpring16HZZ); fChain->SetBranchAddress("Electron_pfRelIso03_all", Electron_pfRelIso03_all, &b_Electron_pfRelIso03_all); fChain->SetBranchAddress("Electron_pfRelIso03_chg", Electron_pfRelIso03_chg, &b_Electron_pfRelIso03_chg); fChain->SetBranchAddress("Electron_phi", Electron_phi, &b_Electron_phi); fChain->SetBranchAddress("Electron_pt", Electron_pt, &b_Electron_pt); fChain->SetBranchAddress("Electron_r9", Electron_r9, &b_Electron_r9); fChain->SetBranchAddress("Electron_sieie", Electron_sieie, &b_Electron_sieie); fChain->SetBranchAddress("Electron_sip3d", Electron_sip3d, &b_Electron_sip3d); fChain->SetBranchAddress("Electron_mvaTTH", Electron_mvaTTH, &b_Electron_mvaTTH); fChain->SetBranchAddress("Electron_charge", Electron_charge, &b_Electron_charge); fChain->SetBranchAddress("Electron_cutBased", Electron_cutBased, &b_Electron_cutBased); fChain->SetBranchAddress("Electron_cutBased_HLTPreSel", Electron_cutBased_HLTPreSel, &b_Electron_cutBased_HLTPreSel); fChain->SetBranchAddress("Electron_jetIdx", Electron_jetIdx, &b_Electron_jetIdx); fChain->SetBranchAddress("Electron_pdgId", Electron_pdgId, &b_Electron_pdgId); fChain->SetBranchAddress("Electron_photonIdx", Electron_photonIdx, &b_Electron_photonIdx); fChain->SetBranchAddress("Electron_tightCharge", Electron_tightCharge, &b_Electron_tightCharge); fChain->SetBranchAddress("Electron_vidNestedWPBitmap", Electron_vidNestedWPBitmap, &b_Electron_vidNestedWPBitmap); fChain->SetBranchAddress("Electron_convVeto", Electron_convVeto, &b_Electron_convVeto); fChain->SetBranchAddress("Electron_cutBased_HEEP", Electron_cutBased_HEEP, &b_Electron_cutBased_HEEP); fChain->SetBranchAddress("Electron_isPFcand", Electron_isPFcand, &b_Electron_isPFcand); fChain->SetBranchAddress("Electron_lostHits", Electron_lostHits, &b_Electron_lostHits); fChain->SetBranchAddress("Electron_mvaSpring16GP_WP80", Electron_mvaSpring16GP_WP80, &b_Electron_mvaSpring16GP_WP80); fChain->SetBranchAddress("Electron_mvaSpring16GP_WP90", Electron_mvaSpring16GP_WP90, &b_Electron_mvaSpring16GP_WP90); fChain->SetBranchAddress("Electron_mvaSpring16HZZ_WPL", Electron_mvaSpring16HZZ_WPL, &b_Electron_mvaSpring16HZZ_WPL); fChain->SetBranchAddress("nGenPart", &nGenPart, &b_nGenPart); fChain->SetBranchAddress("GenPart_eta", GenPart_eta, &b_GenPart_eta); fChain->SetBranchAddress("GenPart_mass", GenPart_mass, &b_GenPart_mass); fChain->SetBranchAddress("GenPart_phi", GenPart_phi, &b_GenPart_phi); fChain->SetBranchAddress("GenPart_pt", GenPart_pt, &b_GenPart_pt); fChain->SetBranchAddress("GenPart_genPartIdxMother", GenPart_genPartIdxMother, &b_GenPart_genPartIdxMother); fChain->SetBranchAddress("GenPart_pdgId", GenPart_pdgId, &b_GenPart_pdgId); fChain->SetBranchAddress("GenPart_status", GenPart_status, &b_GenPart_status); fChain->SetBranchAddress("GenPart_statusFlags", GenPart_statusFlags, &b_GenPart_statusFlags); fChain->SetBranchAddress("Generator_scalePDF", &Generator_scalePDF, &b_Generator_scalePDF); fChain->SetBranchAddress("Generator_x1", &Generator_x1, &b_Generator_x1); fChain->SetBranchAddress("Generator_x2", &Generator_x2, &b_Generator_x2); fChain->SetBranchAddress("Generator_xpdf1", &Generator_xpdf1, &b_Generator_xpdf1); fChain->SetBranchAddress("Generator_xpdf2", &Generator_xpdf2, &b_Generator_xpdf2); fChain->SetBranchAddress("Generator_id1", &Generator_id1, &b_Generator_id1); fChain->SetBranchAddress("Generator_id2", &Generator_id2, &b_Generator_id2); fChain->SetBranchAddress("genWeight", &genWeight, &b_genWeight); fChain->SetBranchAddress("nJet", &nJet, &b_nJet); fChain->SetBranchAddress("Jet_area", Jet_area, &b_Jet_area); fChain->SetBranchAddress("Jet_btagCMVA", Jet_btagCMVA, &b_Jet_btagCMVA); fChain->SetBranchAddress("Jet_btagCSVV2", Jet_btagCSVV2, &b_Jet_btagCSVV2); fChain->SetBranchAddress("Jet_btagDeepB", Jet_btagDeepB, &b_Jet_btagDeepB); fChain->SetBranchAddress("Jet_btagDeepC", Jet_btagDeepC, &b_Jet_btagDeepC); fChain->SetBranchAddress("Jet_chEmEF", Jet_chEmEF, &b_Jet_chEmEF); fChain->SetBranchAddress("Jet_chHEF", Jet_chHEF, &b_Jet_chHEF); fChain->SetBranchAddress("Jet_eta", Jet_eta, &b_Jet_eta); fChain->SetBranchAddress("Jet_mass", Jet_mass, &b_Jet_mass); fChain->SetBranchAddress("Jet_neEmEF", Jet_neEmEF, &b_Jet_neEmEF); fChain->SetBranchAddress("Jet_neHEF", Jet_neHEF, &b_Jet_neHEF); fChain->SetBranchAddress("Jet_phi", Jet_phi, &b_Jet_phi); fChain->SetBranchAddress("Jet_pt", Jet_pt, &b_Jet_pt); fChain->SetBranchAddress("Jet_qgl", Jet_qgl, &b_Jet_qgl); fChain->SetBranchAddress("Jet_rawFactor", Jet_rawFactor, &b_Jet_rawFactor); fChain->SetBranchAddress("Jet_bReg", Jet_bReg, &b_Jet_bReg); fChain->SetBranchAddress("Jet_electronIdx1", Jet_electronIdx1, &b_Jet_electronIdx1); fChain->SetBranchAddress("Jet_electronIdx2", Jet_electronIdx2, &b_Jet_electronIdx2); fChain->SetBranchAddress("Jet_jetId", Jet_jetId, &b_Jet_jetId); fChain->SetBranchAddress("Jet_muonIdx1", Jet_muonIdx1, &b_Jet_muonIdx1); fChain->SetBranchAddress("Jet_muonIdx2", Jet_muonIdx2, &b_Jet_muonIdx2); fChain->SetBranchAddress("Jet_nConstituents", Jet_nConstituents, &b_Jet_nConstituents); fChain->SetBranchAddress("Jet_nElectrons", Jet_nElectrons, &b_Jet_nElectrons); fChain->SetBranchAddress("Jet_nMuons", Jet_nMuons, &b_Jet_nMuons); fChain->SetBranchAddress("Jet_puId", Jet_puId, &b_Jet_puId); fChain->SetBranchAddress("MET_MetUnclustEnUpDeltaX", &MET_MetUnclustEnUpDeltaX, &b_MET_MetUnclustEnUpDeltaX); fChain->SetBranchAddress("MET_MetUnclustEnUpDeltaY", &MET_MetUnclustEnUpDeltaY, &b_MET_MetUnclustEnUpDeltaY); fChain->SetBranchAddress("MET_covXX", &MET_covXX, &b_MET_covXX); fChain->SetBranchAddress("MET_covXY", &MET_covXY, &b_MET_covXY); fChain->SetBranchAddress("MET_covYY", &MET_covYY, &b_MET_covYY); fChain->SetBranchAddress("MET_phi", &MET_phi, &b_MET_phi); fChain->SetBranchAddress("MET_pt", &MET_pt, &b_MET_pt); fChain->SetBranchAddress("MET_significance", &MET_significance, &b_MET_significance); fChain->SetBranchAddress("MET_sumEt", &MET_sumEt, &b_MET_sumEt); fChain->SetBranchAddress("nMuon", &nMuon, &b_nMuon); fChain->SetBranchAddress("Muon_dxy", Muon_dxy, &b_Muon_dxy); fChain->SetBranchAddress("Muon_dxyErr", Muon_dxyErr, &b_Muon_dxyErr); fChain->SetBranchAddress("Muon_dz", Muon_dz, &b_Muon_dz); fChain->SetBranchAddress("Muon_dzErr", Muon_dzErr, &b_Muon_dzErr); fChain->SetBranchAddress("Muon_eta", Muon_eta, &b_Muon_eta); fChain->SetBranchAddress("Muon_ip3d", Muon_ip3d, &b_Muon_ip3d); fChain->SetBranchAddress("Muon_mass", Muon_mass, &b_Muon_mass); fChain->SetBranchAddress("Muon_miniPFRelIso_all", Muon_miniPFRelIso_all, &b_Muon_miniPFRelIso_all); fChain->SetBranchAddress("Muon_miniPFRelIso_chg", Muon_miniPFRelIso_chg, &b_Muon_miniPFRelIso_chg); fChain->SetBranchAddress("Muon_pfRelIso03_all", Muon_pfRelIso03_all, &b_Muon_pfRelIso03_all); fChain->SetBranchAddress("Muon_pfRelIso03_chg", Muon_pfRelIso03_chg, &b_Muon_pfRelIso03_chg); fChain->SetBranchAddress("Muon_pfRelIso04_all", Muon_pfRelIso04_all, &b_Muon_pfRelIso04_all); fChain->SetBranchAddress("Muon_phi", Muon_phi, &b_Muon_phi); fChain->SetBranchAddress("Muon_pt", Muon_pt, &b_Muon_pt); fChain->SetBranchAddress("Muon_ptErr", Muon_ptErr, &b_Muon_ptErr); fChain->SetBranchAddress("Muon_segmentComp", Muon_segmentComp, &b_Muon_segmentComp); fChain->SetBranchAddress("Muon_sip3d", Muon_sip3d, &b_Muon_sip3d); fChain->SetBranchAddress("Muon_mvaTTH", Muon_mvaTTH, &b_Muon_mvaTTH); fChain->SetBranchAddress("Muon_charge", Muon_charge, &b_Muon_charge); fChain->SetBranchAddress("Muon_jetIdx", Muon_jetIdx, &b_Muon_jetIdx); fChain->SetBranchAddress("Muon_nStations", Muon_nStations, &b_Muon_nStations); fChain->SetBranchAddress("Muon_nTrackerLayers", Muon_nTrackerLayers, &b_Muon_nTrackerLayers); fChain->SetBranchAddress("Muon_pdgId", Muon_pdgId, &b_Muon_pdgId); fChain->SetBranchAddress("Muon_tightCharge", Muon_tightCharge, &b_Muon_tightCharge); fChain->SetBranchAddress("Muon_globalMu", Muon_globalMu, &b_Muon_globalMu); fChain->SetBranchAddress("Muon_highPtId", Muon_highPtId, &b_Muon_highPtId); fChain->SetBranchAddress("Muon_isPFcand", Muon_isPFcand, &b_Muon_isPFcand); fChain->SetBranchAddress("Muon_mediumId", Muon_mediumId, &b_Muon_mediumId); fChain->SetBranchAddress("Muon_softId", Muon_softId, &b_Muon_softId); fChain->SetBranchAddress("Muon_tightId", Muon_tightId, &b_Muon_tightId); fChain->SetBranchAddress("Muon_trackerMu", Muon_trackerMu, &b_Muon_trackerMu); fChain->SetBranchAddress("Pileup_nPU", &Pileup_nPU, &b_Pileup_nPU); fChain->SetBranchAddress("Pileup_nTrueInt", &Pileup_nTrueInt, &b_Pileup_nTrueInt); fChain->SetBranchAddress("nTrigObj", &nTrigObj, &b_nTrigObj); fChain->SetBranchAddress("TrigObj_pt", TrigObj_pt, &b_TrigObj_pt); fChain->SetBranchAddress("TrigObj_eta", TrigObj_eta, &b_TrigObj_eta); fChain->SetBranchAddress("TrigObj_phi", TrigObj_phi, &b_TrigObj_phi); fChain->SetBranchAddress("TrigObj_l1pt", TrigObj_l1pt, &b_TrigObj_l1pt); fChain->SetBranchAddress("TrigObj_l1pt_2", TrigObj_l1pt_2, &b_TrigObj_l1pt_2); fChain->SetBranchAddress("TrigObj_l2pt", TrigObj_l2pt, &b_TrigObj_l2pt); fChain->SetBranchAddress("TrigObj_id", TrigObj_id, &b_TrigObj_id); fChain->SetBranchAddress("TrigObj_l1iso", TrigObj_l1iso, &b_TrigObj_l1iso); fChain->SetBranchAddress("TrigObj_l1charge", TrigObj_l1charge, &b_TrigObj_l1charge); fChain->SetBranchAddress("TrigObj_filterBits", TrigObj_filterBits, &b_TrigObj_filterBits); fChain->SetBranchAddress("genTtbarId", &genTtbarId, &b_genTtbarId); fChain->SetBranchAddress("nOtherPV", &nOtherPV, &b_nOtherPV); fChain->SetBranchAddress("OtherPV_z", OtherPV_z, &b_OtherPV_z); fChain->SetBranchAddress("PV_ndof", &PV_ndof, &b_PV_ndof); fChain->SetBranchAddress("PV_x", &PV_x, &b_PV_x); fChain->SetBranchAddress("PV_y", &PV_y, &b_PV_y); fChain->SetBranchAddress("PV_z", &PV_z, &b_PV_z); fChain->SetBranchAddress("PV_chi2", &PV_chi2, &b_PV_chi2); fChain->SetBranchAddress("PV_score", &PV_score, &b_PV_score); fChain->SetBranchAddress("PV_npvs", &PV_npvs, &b_PV_npvs); fChain->SetBranchAddress("cmeson_chi2", cmeson_chi2, &b_cmeson_chi2); fChain->SetBranchAddress("cmeson_eta", cmeson_eta, &b_cmeson_eta); fChain->SetBranchAddress("cmeson_mass", cmeson_mass, &b_cmeson_mass); fChain->SetBranchAddress("cmeson_phi", cmeson_phi, &b_cmeson_phi); fChain->SetBranchAddress("cmeson_pt", cmeson_pt, &b_cmeson_pt); fChain->SetBranchAddress("cmeson_x", cmeson_x, &b_cmeson_x); fChain->SetBranchAddress("cmeson_y", cmeson_y, &b_cmeson_y); fChain->SetBranchAddress("cmeson_z", cmeson_z, &b_cmeson_z); fChain->SetBranchAddress("cmeson_ndof", cmeson_ndof, &b_cmeson_ndof); fChain->SetBranchAddress("cmeson_pdgId", cmeson_pdgId, &b_cmeson_pdgId); fChain->SetBranchAddress("Electron_genPartIdx", Electron_genPartIdx, &b_Electron_genPartIdx); fChain->SetBranchAddress("Electron_genPartFlav", Electron_genPartFlav, &b_Electron_genPartFlav); fChain->SetBranchAddress("Jet_genJetIdx", Jet_genJetIdx, &b_Jet_genJetIdx); fChain->SetBranchAddress("Jet_hadronFlavour", Jet_hadronFlavour, &b_Jet_hadronFlavour); fChain->SetBranchAddress("Jet_partonFlavour", Jet_partonFlavour, &b_Jet_partonFlavour); fChain->SetBranchAddress("Muon_genPartIdx", Muon_genPartIdx, &b_Muon_genPartIdx); fChain->SetBranchAddress("Muon_genPartFlav", Muon_genPartFlav, &b_Muon_genPartFlav); fChain->SetBranchAddress("Electron_cleanmask", Electron_cleanmask, &b_Electron_cleanmask); fChain->SetBranchAddress("Jet_cleanmask", Jet_cleanmask, &b_Jet_cleanmask); fChain->SetBranchAddress("Muon_cleanmask", Muon_cleanmask, &b_Muon_cleanmask); fChain->SetBranchAddress("HLT_Ele27_WPTight_Gsf", &HLT_Ele27_WPTight_Gsf, &b_HLT_Ele27_WPTight_Gsf); fChain->SetBranchAddress("HLT_IsoMu24", &HLT_IsoMu24, &b_HLT_IsoMu24); fChain->SetBranchAddress("HLT_IsoTkMu24", &HLT_IsoTkMu24, &b_HLT_IsoTkMu24); fChain->SetBranchAddress("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL", &HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL, &b_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL); fChain->SetBranchAddress("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ", &HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ, &b_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ); fChain->SetBranchAddress("HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL", &HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL, &b_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL); fChain->SetBranchAddress("HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ", &HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ, &b_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ); fChain->SetBranchAddress("HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ", &HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ, &b_HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ); fChain->SetBranchAddress("HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL", &HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL, &b_HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL); fChain->SetBranchAddress("HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ", &HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ, &b_HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ); fChain->SetBranchAddress("HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL", &HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL, &b_HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL); fChain->SetBranchAddress("HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ", &HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ, &b_HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ); Notify(); } Bool_t topAnalysis::Notify() { // The Notify() function is called when a new file is opened. This // can be either for a new TTree in a TChain or when when a new TTree // is started when using PROOF. It is normally not necessary to make changes // to the generated code, but the routine can be extended by the // user if needed. The return value is currently not used. return kTRUE; } void topAnalysis::Show(Long64_t entry) { // Print contents of entry. // If entry is not specified, print current entry if (!fChain) return; fChain->Show(entry); } Int_t topAnalysis::Cut(Long64_t entry) { // This function may be called from Loop. // returns 1 if entry is accepted. // returns -1 otherwise. return 1; } #endif // #ifdef topAnalysis_cxx
[ "jason.lee@cern.ch" ]
jason.lee@cern.ch
6d97ab2818734867f1c62634639d88d5b8b8137d
cc590640dbf30c1914857cf4fb832db8bce177bc
/OpenGL_1/Mesh.h
79d03fddcb739a639f9bd9b28794dbbb52fbe168
[]
no_license
Inzuki/Engine
0285bf3546b1a268f75eabdae750f80c923a92aa
d3280ce1eebb0c848fa7b94859599d05de16aa22
refs/heads/master
2021-09-07T09:09:10.862470
2018-02-20T20:45:18
2018-02-20T20:45:18
113,218,635
2
0
null
null
null
null
UTF-8
C++
false
false
6,774
h
#ifndef MESH_H #define MESH_H #include "INCLUDES.h" #include "Material.h" class Mesh { private: int vertexCount; GLuint obj, vertBuff, texBuff, normBuff; Material material; public: Mesh(){ material.set_color(glm::vec3(1.f)); material.set_specular_intensity(1.f); material.set_specular_exponent(8.f); } void load_mesh(const char *objName){ // get setup to read OBJ std::vector<glm::vec2> tempTextures; std::vector<glm::vec3> tempVertices, tempNormals; std::vector<glm::vec2> textures; std::vector<glm::vec3> vertices, normals; std::vector<unsigned int> vertIndices, texIndices, normIndices; // open OBJ file and begin reading the OBJ's contents char objFile[256]; sprintf(objFile, "res/models/%s", objName); FILE *file = fopen(objFile, "r"); while(true){ char lineHeader[128]; int res = fscanf(file, "%s", lineHeader); if(res == EOF) break; if(strcmp(lineHeader, "v") == 0){ glm::vec3 vertex; fscanf(file, "%f %f %f\n", &vertex.x, &vertex.y, &vertex.z); tempVertices.push_back(vertex); }else if(strcmp(lineHeader, "vt") == 0){ glm::vec2 texture; fscanf(file, "%f %f\n", &texture.x, &texture.y); tempTextures.push_back(texture); }else if(strcmp(lineHeader, "vn") == 0){ glm::vec3 normal; fscanf(file, "%f %f %f\n", &normal.x, &normal.y, &normal.z); tempNormals.push_back(normal); }else if(strcmp(lineHeader, "f") == 0){ std::string vertex1, vertex2, vertex3; unsigned int vertexIndex[3], textureIndex[3], normalIndex[3]; int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n", &vertexIndex[0], &textureIndex[0], &normalIndex[0], &vertexIndex[1], &textureIndex[1], &normalIndex[1], &vertexIndex[2], &textureIndex[2], &normalIndex[2] ); if(matches != 9) printf("File cannot be read correctly.\n"); vertIndices.push_back(vertexIndex[0]); vertIndices.push_back(vertexIndex[1]); vertIndices.push_back(vertexIndex[2]); texIndices.push_back(textureIndex[0]); texIndices.push_back(textureIndex[1]); texIndices.push_back(textureIndex[2]); normIndices.push_back(normalIndex[0]); normIndices.push_back(normalIndex[1]); normIndices.push_back(normalIndex[2]); }else { char garbage[1024]; fgets(garbage, 1024, file); } } fclose(file); for(unsigned int i = 0; i < vertIndices.size(); i++){ unsigned int vertexIndex = vertIndices[i], texIndex = texIndices[i], normalIndex = normIndices[i]; glm::vec3 vertex = tempVertices[vertexIndex - 1]; glm::vec2 texture = tempTextures[texIndex - 1]; glm::vec3 normal = tempNormals[normalIndex - 1]; vertices.push_back(vertex); textures.push_back(texture); normals.push_back(normal); } vertexCount = vertices.size(); glGenVertexArrays(1, &obj); glGenBuffers(1, &vertBuff); glGenBuffers(1, &texBuff); glGenBuffers(1, &normBuff); // create vertex array object glBindVertexArray(obj); // vertices glBindBuffer(GL_ARRAY_BUFFER, vertBuff); glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(glm::vec3), &vertices[0], GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0 * sizeof(GLfloat), (GLvoid*)(0 * sizeof(GLfloat))); glEnableVertexAttribArray(0); // texture coordinates glBindBuffer(GL_ARRAY_BUFFER, texBuff); glBufferData(GL_ARRAY_BUFFER, textures.size() * sizeof(glm::vec2), &textures[0], GL_STATIC_DRAW); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0 * sizeof(GLfloat), (GLvoid*)(0 * sizeof(GLfloat))); glEnableVertexAttribArray(1); // normals glBindBuffer(GL_ARRAY_BUFFER, normBuff); glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(glm::vec3), &normals[0], GL_STATIC_DRAW); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0 * sizeof(GLfloat), (GLvoid*)(0 * sizeof(GLfloat))); glEnableVertexAttribArray(2); glBindVertexArray(0); } void load_texture(const char *textureFile){ material.set_texture(textureFile); } Material get_material(){ return material; } void set_color(glm::vec3 color){ material.set_color(color); } void set_specular_intensity(float intensity){ material.set_specular_intensity(intensity); } void set_specular_exponent(float exponent){ material.set_specular_exponent(exponent); } void draw(){ //glActiveTexture(GL_TEXTURE0); if(material.get_texture()) glBindTexture(GL_TEXTURE_2D, material.get_texture()); glBindVertexArray(obj); glDrawArrays(GL_TRIANGLES, 0, vertexCount); glBindVertexArray(0); } }; class Plane { private: GLuint VBO, VAO, EBO; Material material; public: Plane(){ float vertices[] = { // positions normals texture coords 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 3.0f, 0.0f, -1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 3.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 3.0f, 3.0f }; unsigned int indices[] = { 0, 1, 2, // first Triangle 0, 3, 1 // second Triangle }; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); glGenBuffers(1, &EBO); glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); // vertices glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0); glEnableVertexAttribArray(0); // textures glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float))); glEnableVertexAttribArray(1); // normals glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float))); glEnableVertexAttribArray(2); glBindVertexArray(0); } void applyTexture(const char *texture){ material.set_texture(texture); } Material get_material(){ return material; } void set_color(glm::vec3 color){ material.set_color(color); } void set_specular_intensity(float intensity){ material.set_specular_intensity(intensity); } void set_specular_exponent(float exponent){ material.set_specular_exponent(exponent); } void draw(){ if(material.get_texture()){ //glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, material.get_texture()); } glBindVertexArray(VAO); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glBindVertexArray(0); } }; #endif
[ "teh_inzuki@hotmail.com" ]
teh_inzuki@hotmail.com
2263fe8a70bf8941330a26f01d1ac1937f5c758b
9d9c217d265515738bd2889cf7512d796169c243
/Problems/codeforces/954-A/954-A-36554334.cpp
5cf58f898edcb9e89c6d6d0c691c9b2c1a478910
[]
no_license
Evalir/Algorithms
f4d70f6b5cb7a20b5304a8543dd9dd443d2e7d7d
c58507d9f79eb388dd98b8e22302598eb29876e0
refs/heads/master
2021-07-08T16:52:15.820629
2019-09-21T23:45:52
2019-09-21T23:45:52
99,495,180
0
0
null
2017-10-24T22:07:37
2017-08-06T15:20:17
Makefile
UTF-8
C++
false
false
410
cpp
#include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string S; cin >> S; int mans = 0; for(int i = 0; i < N-1; i++) { if ((S[i] == 'U' && S[i+1] == 'R') || (S[i] == 'R' && S[i+1] == 'U')) { mans++; S[i] = '-'; S[i+1] = '-'; } } cout << N-mans << endl; return 0; }
[ "hievalir@gmail.com" ]
hievalir@gmail.com
30e5208ceb94c6c44aaba8931bdc84a861da527a
1df91eee891b9c33224057ac33c23c5af23370a9
/ScriptDrawing/src/scripter.cpp
5ead6e58f86b64191e71d89db68001bf816a3807
[]
no_license
Frowsty/ScriptDrawing
2c587ad703e56b698a7280343b62223299384569
ea62edc46fd73bf4e8cf7f74b17d04064f54410b
refs/heads/main
2023-07-31T00:08:13.161449
2021-10-01T01:41:49
2021-10-01T01:41:49
403,775,122
0
0
null
null
null
null
UTF-8
C++
false
false
2,306
cpp
#include "headers/scripter.h" void ScriptHandler::add_keywords(std::vector<std::string> keywords) { this->keywords = keywords; } std::pair<std::string ,std::string> ScriptHandler::check_syntax(std::string& keyword) { auto return_message = std::make_pair(std::string(), std::string()); bool found_cmd = false; std::string command_found; for (auto& command : keywords) { auto found = keyword.find(command); if (found == 0 && found != std::string::npos) { command_found = keyword.substr(found, command.size()); found_cmd = true; } } if (found_cmd) { if (return_message.first != "error") { if (keyword[command_found.size()] != '(') { return_message.first = "error"; return_message.second = "Missing opening '(' before parameters"; } else if (keyword.back() != ')') { return_message.first = "error"; return_message.second = "Missing closing ')' after parameters"; } if (return_message.first != "error") { return_message.first = command_found; auto parameters_size = keyword.size() - (command_found.size() + 1); return_message.second = keyword.substr(command_found.size() + 1, parameters_size - 1); } } } else { return_message.first = "error"; return_message.second = "Trying to execute an unknown function"; } syntax_results = return_message; return return_message; } std::vector<int> ScriptHandler::extract_data(std::string& keyword) { std::vector<int> params; std::stringstream ss; std::replace(syntax_results.second.begin(), syntax_results.second.end(), ',', ' '); std::replace(syntax_results.second.begin(), syntax_results.second.end(), '(', ' '); std::replace(syntax_results.second.begin(), syntax_results.second.end(), ')', ' '); ss << syntax_results.second; std::string temp; float found; while (!ss.eof()) { ss >> temp; if (std::stringstream(temp) >> found) { params.push_back(found); temp = ""; } } return params; }
[ "daniel_barbis@hotmail.com" ]
daniel_barbis@hotmail.com
8dee67d00da51113de85073c8da762fc83d7f39a
be85fffb3da2b14d36461ba46879385a004a0240
/SPOJ/dirvs/a.cpp
ee4cc63a613d2deb2bb41845ae6738960a6a7b47
[]
no_license
r0ck1n70sh/competitive
d46d6d37cb6e55fa5ff1a68b2d9ffbf769b91216
2ce731ef5eec096760cf4bee50339f570a58edb3
refs/heads/master
2022-11-23T11:37:47.822087
2022-11-09T16:56:39
2022-11-09T16:56:39
226,349,977
0
0
null
null
null
null
UTF-8
C++
false
false
622
cpp
#include <bits/stdc++.h> #define maxl 200 #define PPI pair<int,int> #define F(i,a,b) for(int i=(int)(a); i<(int)(b); i++) int G[maxl+1][maxl+1] int P, Q, x1, y1, x2, y2; int bfs(); int main() { int T ,ans; scanf("%d",&T); while(T) { scanf("%d%d",&P,&Q); F(i,1,P+1) F(j,1,F+1) scanf("%d",&G[i][j]); scanf("%d%d%d%d", &x1, &y1, &x2, &y2); ans=bfs(); if(ans>=0) printf("The shortest path is %d steps long.\n"); else printf("Mission Impossible!\n"); T--; } return 0; } int bfs() { stack<PII> S; bool vis[maxl+1][maxl+1]; memset(vis, 0, sizeof vis); if(x1==x2&&y1==y2) return 0; }
[ "r0ck1n70sh@gmail.com" ]
r0ck1n70sh@gmail.com
a9a701b38a959ab34cdd9376a2d1ccb095600b6b
600df3590cce1fe49b9a96e9ca5b5242884a2a70
/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
1ab10361a2bd78de6a4ce22d4c646c3e3bd28363
[ "BSD-3-Clause" ]
permissive
metux/chromium-suckless
efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a
72a05af97787001756bae2511b7985e61498c965
refs/heads/orig
2022-12-04T23:53:58.681218
2017-04-30T10:59:06
2017-04-30T23:35:58
89,884,931
5
3
BSD-3-Clause
2022-11-23T20:52:53
2017-05-01T00:09:08
null
UTF-8
C++
false
false
19,341
cc
// 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. // Create a service process that uses a Mock to respond to the browser in order // to test launching the browser using the cloud print policy check command // line switch. #include <stdint.h> #include <memory> #include <utility> #include "base/bind.h" #include "base/command_line.h" #include "base/message_loop/message_loop.h" #include "base/process/kill.h" #include "base/process/process.h" #include "base/rand_util.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/test/multiprocess_test.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/default_tick_clock.h" #include "base/time/time.h" #include "build/build_config.h" #include "chrome/browser/chrome_content_browser_client.h" #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/service_process/service_process_control.h" #include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/service_messages.h" #include "chrome/common/service_process_util.h" #include "chrome/service/service_ipc_server.h" #include "chrome/service/service_process.h" #include "chrome/test/base/chrome_unit_test_suite.h" #include "chrome/test/base/test_launcher_utils.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_io_thread_state.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" #include "components/syncable_prefs/testing_pref_service_syncable.h" #include "content/public/browser/notification_service.h" #include "content/public/common/content_paths.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_utils.h" #include "ipc/ipc_channel_mojo.h" #include "ipc/ipc_descriptors.h" #include "ipc/ipc_multiprocess_test.h" #include "mojo/edk/embedder/embedder.h" #include "mojo/edk/embedder/named_platform_handle.h" #include "mojo/edk/embedder/named_platform_handle_utils.h" #include "mojo/edk/embedder/scoped_ipc_support.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/multiprocess_func_list.h" #if defined(OS_MACOSX) #include "chrome/common/mac/mock_launchd.h" #endif #if defined(OS_POSIX) #include "base/posix/global_descriptors.h" #endif using ::testing::AnyNumber; using ::testing::Assign; using ::testing::AtLeast; using ::testing::DoAll; using ::testing::Invoke; using ::testing::Mock; using ::testing::Property; using ::testing::Return; using ::testing::WithoutArgs; using ::testing::_; using content::BrowserThread; namespace { enum MockServiceProcessExitCodes { kMissingSwitch = 1, kInitializationFailure, kExpectationsNotMet, kShutdownNotGood }; #if defined(OS_MACOSX) const char kTestExecutablePath[] = "test-executable-path"; #endif bool g_good_shutdown = false; void ShutdownTask() { g_good_shutdown = true; g_service_process->Shutdown(); } class TestStartupClientChannelListener : public IPC::Listener { public: bool OnMessageReceived(const IPC::Message& message) override { return false; } }; void ConnectOnBlockingPool(mojo::ScopedMessagePipeHandle handle, mojo::edk::NamedPlatformHandle os_pipe) { mojo::edk::ScopedPlatformHandle os_pipe_handle = mojo::edk::CreateClientHandle(os_pipe); if (!os_pipe_handle.is_valid()) return; mojo::FuseMessagePipes( mojo::edk::ConnectToPeerProcess(std::move(os_pipe_handle)), std::move(handle)); } const char kProcessChannelID[] = "process-channel-id"; } // namespace class TestServiceProcess : public ServiceProcess { public: TestServiceProcess() { } ~TestServiceProcess() override {} bool Initialize(base::MessageLoopForUI* message_loop, ServiceProcessState* state); }; bool TestServiceProcess::Initialize(base::MessageLoopForUI* message_loop, ServiceProcessState* state) { main_message_loop_ = message_loop; service_process_state_.reset(state); base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); io_thread_.reset(new base::Thread("TestServiceProcess_IO")); return io_thread_->StartWithOptions(options); } // This mocks the service side IPC message handler, allowing us to have a // minimal service process. class MockServiceIPCServer : public ServiceIPCServer { public: static std::string EnabledUserId(); MockServiceIPCServer( ServiceIPCServer::Client* client, const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, base::WaitableEvent* shutdown_event) : ServiceIPCServer(client, io_task_runner, shutdown_event), enabled_(true) {} MOCK_METHOD1(OnMessageReceived, bool(const IPC::Message& message)); MOCK_METHOD1(OnChannelConnected, void(int32_t peer_pid)); MOCK_METHOD0(OnChannelError, void()); void SetServiceEnabledExpectations(); void SetWillBeDisabledExpectations(); void CallServiceOnChannelConnected(int32_t peer_pid) { ServiceIPCServer::OnChannelConnected(peer_pid); } bool SendInfo(); private: cloud_print::CloudPrintProxyInfo info_; bool enabled_; }; // static std::string MockServiceIPCServer::EnabledUserId() { return std::string("kitteh@canhazcheezburger.cat"); } void MockServiceIPCServer::SetServiceEnabledExpectations() { EXPECT_CALL(*this, OnChannelConnected(_)).Times(1) .WillRepeatedly( Invoke(this, &MockServiceIPCServer::CallServiceOnChannelConnected)); EXPECT_CALL(*this, OnChannelError()).Times(0); EXPECT_CALL(*this, OnMessageReceived(_)).Times(0); EXPECT_CALL(*this, OnMessageReceived(Property( &IPC::Message::type, static_cast<int32_t>(ServiceMsg_GetCloudPrintProxyInfo::ID)))) .Times(AnyNumber()) .WillRepeatedly( WithoutArgs(Invoke(this, &MockServiceIPCServer::SendInfo))); EXPECT_CALL(*this, OnMessageReceived(Property( &IPC::Message::type, static_cast<int32_t>(ServiceMsg_Shutdown::ID)))) .Times(1) .WillOnce(DoAll( Assign(&g_good_shutdown, true), WithoutArgs(Invoke(g_service_process, &ServiceProcess::Shutdown)), Return(true))); } void MockServiceIPCServer::SetWillBeDisabledExpectations() { SetServiceEnabledExpectations(); EXPECT_CALL(*this, OnMessageReceived(Property( &IPC::Message::type, static_cast<int32_t>(ServiceMsg_DisableCloudPrintProxy::ID)))) .Times(AtLeast(1)) .WillRepeatedly(DoAll(Assign(&enabled_, false), Return(true))); } bool MockServiceIPCServer::SendInfo() { if (enabled_) { info_.enabled = true; info_.email = EnabledUserId(); EXPECT_TRUE(Send(new ServiceHostMsg_CloudPrintProxy_Info(info_))); } else { info_.enabled = false; info_.email = std::string(); EXPECT_TRUE(Send(new ServiceHostMsg_CloudPrintProxy_Info(info_))); } return true; } typedef base::Callback<void(MockServiceIPCServer* server)> SetExpectationsCallback; // The return value from this routine is used as the exit code for the mock // service process. Any non-zero return value will be printed out and can help // determine the failure. int CloudPrintMockService_Main(SetExpectationsCallback set_expectations) { base::PlatformThread::SetName("Main Thread"); base::MessageLoopForUI main_message_loop; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); content::RegisterPathProvider(); base::FilePath user_data_dir = command_line->GetSwitchValuePath(switches::kUserDataDir); CHECK(!user_data_dir.empty()); CHECK(test_launcher_utils::OverrideUserDataDir(user_data_dir)); #if defined(OS_MACOSX) if (!command_line->HasSwitch(kTestExecutablePath)) return kMissingSwitch; base::FilePath executable_path = command_line->GetSwitchValuePath(kTestExecutablePath); EXPECT_FALSE(executable_path.empty()); MockLaunchd mock_launchd(executable_path, &main_message_loop, true, true); Launchd::ScopedInstance use_mock(&mock_launchd); #endif ServiceProcessState* state(new ServiceProcessState); bool service_process_state_initialized = state->Initialize(); EXPECT_TRUE(service_process_state_initialized); if (!service_process_state_initialized) return kInitializationFailure; TestServiceProcess service_process; EXPECT_EQ(&service_process, g_service_process); // Takes ownership of the pointer, but we can use it since we have the same // lifetime. EXPECT_TRUE(service_process.Initialize(&main_message_loop, state)); // Needed for IPC. mojo::edk::Init(); mojo::edk::ScopedIPCSupport ipc_support(service_process.io_task_runner()); MockServiceIPCServer server(&service_process, service_process.io_task_runner(), service_process.GetShutdownEventForTesting()); // Here is where the expectations/mock responses need to be set up. set_expectations.Run(&server); EXPECT_TRUE(server.Init()); EXPECT_TRUE(state->SignalReady(service_process.io_task_runner().get(), base::Bind(&ShutdownTask))); #if defined(OS_MACOSX) mock_launchd.SignalReady(); #endif // Connect up the parent/child IPC channel to signal that the test can // continue. TestStartupClientChannelListener listener; EXPECT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( kProcessChannelID)); std::string startup_channel_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( kProcessChannelID); std::unique_ptr<IPC::ChannelProxy> startup_channel; startup_channel = IPC::ChannelProxy::Create(startup_channel_name, IPC::Channel::MODE_CLIENT, &listener, service_process.io_task_runner()); base::RunLoop().Run(); if (!Mock::VerifyAndClearExpectations(&server)) return kExpectationsNotMet; if (!g_good_shutdown) return kShutdownNotGood; return 0; } void SetServiceEnabledExpectations(MockServiceIPCServer* server) { server->SetServiceEnabledExpectations(); } MULTIPROCESS_IPC_TEST_MAIN(CloudPrintMockService_StartEnabledWaitForQuit) { return CloudPrintMockService_Main( base::Bind(&SetServiceEnabledExpectations)); } void SetServiceWillBeDisabledExpectations(MockServiceIPCServer* server) { server->SetWillBeDisabledExpectations(); } MULTIPROCESS_IPC_TEST_MAIN(CloudPrintMockService_StartEnabledExpectDisabled) { return CloudPrintMockService_Main( base::Bind(&SetServiceWillBeDisabledExpectations)); } class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest, public IPC::Listener { public: CloudPrintProxyPolicyStartupTest(); ~CloudPrintProxyPolicyStartupTest() override; void SetUp() override; void TearDown() override; scoped_refptr<base::SingleThreadTaskRunner> IOTaskRunner() { return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); } base::Process Launch(const std::string& name); void WaitForConnect(); bool Send(IPC::Message* message); void ShutdownAndWaitForExitWithTimeout(base::Process process); // IPC::Listener implementation bool OnMessageReceived(const IPC::Message& message) override { return false; } void OnChannelConnected(int32_t peer_pid) override; // MultiProcessTest implementation. base::CommandLine MakeCmdLine(const std::string& procname) override; bool LaunchBrowser(const base::CommandLine& command_line, Profile* profile) { StartupBrowserCreator browser_creator; return browser_creator.ProcessCmdLineImpl( command_line, base::FilePath(), false, profile, StartupBrowserCreator::Profiles()); } protected: content::TestBrowserThreadBundle thread_bundle_; base::ScopedTempDir temp_user_data_dir_; std::string startup_channel_id_; std::unique_ptr<IPC::ChannelProxy> startup_channel_; std::unique_ptr<ChromeContentClient> content_client_; std::unique_ptr<ChromeContentBrowserClient> browser_content_client_; #if defined(OS_MACOSX) base::ScopedTempDir temp_dir_; base::FilePath executable_path_, bundle_path_; std::unique_ptr<MockLaunchd> mock_launchd_; std::unique_ptr<Launchd::ScopedInstance> scoped_launchd_instance_; #endif private: class WindowedChannelConnectionObserver { public: WindowedChannelConnectionObserver() : seen_(false), running_(false) { } void Wait() { if (seen_) return; running_ = true; content::RunMessageLoop(); } void Notify() { seen_ = true; if (running_) base::MessageLoopForUI::current()->QuitWhenIdle(); } private: bool seen_; bool running_; }; WindowedChannelConnectionObserver observer_; }; CloudPrintProxyPolicyStartupTest::CloudPrintProxyPolicyStartupTest() : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD) { // Although is really a unit test which runs in the browser_tests binary, it // doesn't get the unit setup which normally happens in the unit test binary. ChromeUnitTestSuite::InitializeProviders(); ChromeUnitTestSuite::InitializeResourceBundle(); } CloudPrintProxyPolicyStartupTest::~CloudPrintProxyPolicyStartupTest() { } void CloudPrintProxyPolicyStartupTest::SetUp() { content_client_.reset(new ChromeContentClient); content::SetContentClient(content_client_.get()); browser_content_client_.reset(new ChromeContentBrowserClient()); content::SetBrowserClientForTesting(browser_content_client_.get()); TestingBrowserProcess::CreateInstance(); // Ensure test does not use the standard profile directory. This is copied // from InProcessBrowserTest::SetUp(). These tests require a more complex // process startup so they are unable to just inherit from // InProcessBrowserTest. base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::FilePath user_data_dir = command_line->GetSwitchValuePath(switches::kUserDataDir); if (user_data_dir.empty()) { ASSERT_TRUE(temp_user_data_dir_.CreateUniqueTempDir() && temp_user_data_dir_.IsValid()) << "Could not create temporary user data directory \"" << temp_user_data_dir_.GetPath().value() << "\"."; user_data_dir = temp_user_data_dir_.GetPath(); command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); } ASSERT_TRUE(test_launcher_utils::OverrideUserDataDir(user_data_dir)); #if defined(OS_MACOSX) EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); EXPECT_TRUE(MockLaunchd::MakeABundle(temp_dir_.GetPath(), "CloudPrintProxyTest", &bundle_path_, &executable_path_)); mock_launchd_.reset(new MockLaunchd(executable_path_, base::MessageLoopForUI::current(), true, false)); scoped_launchd_instance_.reset( new Launchd::ScopedInstance(mock_launchd_.get())); #endif } void CloudPrintProxyPolicyStartupTest::TearDown() { browser_content_client_.reset(); content_client_.reset(); content::SetContentClient(NULL); TestingBrowserProcess::DeleteInstance(); } base::Process CloudPrintProxyPolicyStartupTest::Launch( const std::string& name) { EXPECT_FALSE(CheckServiceProcessReady()); startup_channel_id_ = base::StringPrintf("%d.%p.%d", base::GetCurrentProcId(), this, base::RandInt(0, std::numeric_limits<int>::max())); startup_channel_ = IPC::ChannelProxy::Create(startup_channel_id_, IPC::Channel::MODE_SERVER, this, IOTaskRunner()); #if defined(OS_POSIX) base::FileHandleMappingVector ipc_file_list; ipc_file_list.push_back(std::make_pair( startup_channel_->TakeClientFileDescriptor().release(), kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); base::LaunchOptions options; options.fds_to_remap = &ipc_file_list; base::Process process = SpawnChildWithOptions(name, options); #else base::Process process = SpawnChild(name); #endif EXPECT_TRUE(process.IsValid()); return process; } void CloudPrintProxyPolicyStartupTest::WaitForConnect() { observer_.Wait(); EXPECT_TRUE(CheckServiceProcessReady()); EXPECT_TRUE(base::ThreadTaskRunnerHandle::Get().get()); mojo::MessagePipe pipe; BrowserThread::PostBlockingPoolTask( FROM_HERE, base::Bind(&ConnectOnBlockingPool, base::Passed(&pipe.handle1), mojo::edk::NamedPlatformHandle( GetServiceProcessChannel().name))); ServiceProcessControl::GetInstance()->SetChannel( IPC::ChannelProxy::Create(IPC::ChannelMojo::CreateClientFactory( std::move(pipe.handle0), IOTaskRunner()), this, IOTaskRunner())); } bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) { return ServiceProcessControl::GetInstance()->Send(message); } void CloudPrintProxyPolicyStartupTest::ShutdownAndWaitForExitWithTimeout( base::Process process) { ASSERT_TRUE(Send(new ServiceMsg_Shutdown())); int exit_code = -100; bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), &exit_code); EXPECT_TRUE(exited); EXPECT_EQ(exit_code, 0); } void CloudPrintProxyPolicyStartupTest::OnChannelConnected(int32_t peer_pid) { observer_.Notify(); } base::CommandLine CloudPrintProxyPolicyStartupTest::MakeCmdLine( const std::string& procname) { base::CommandLine cl = MultiProcessTest::MakeCmdLine(procname); cl.AppendSwitchASCII(kProcessChannelID, startup_channel_id_); #if defined(OS_MACOSX) cl.AppendSwitchASCII(kTestExecutablePath, executable_path_.value()); #endif return cl; } TEST_F(CloudPrintProxyPolicyStartupTest, StartAndShutdown) { mojo::edk::Init(); mojo::edk::ScopedIPCSupport ipc_support( BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) ->task_runner()); TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal(); TestingProfileManager profile_manager(browser_process); ASSERT_TRUE(profile_manager.SetUp()); // Must be created after the TestingProfileManager since that creates the // LocalState for the BrowserProcess. Must be created before profiles are // constructed. chrome::TestingIOThreadState testing_io_thread_state; base::Process process = Launch("CloudPrintMockService_StartEnabledWaitForQuit"); WaitForConnect(); ShutdownAndWaitForExitWithTimeout(std::move(process)); ServiceProcessControl::GetInstance()->Disconnect(); content::RunAllPendingInMessageLoop(); }
[ "enrico.weigelt@gr13.net" ]
enrico.weigelt@gr13.net
e4e2acfe057991e3465d49a86ce3e1c2e4d9a22a
4b2aa0114449523ca9d98e9e25005c130d64547b
/ICPC/test/howard/438.cc
f99b2ed8f2fe90fc443f2f3d66aed18fcdf1ad31
[]
no_license
HowardChengUleth/codelibrary
7793d86df4f82994770e8f1c19c7d240cadac9cd
d93fa3fc94792276c6f2cf2b480a445ec0bb8c32
refs/heads/master
2023-03-06T00:45:23.522994
2023-03-02T01:45:22
2023-03-02T01:45:22
136,532,622
10
5
null
null
null
null
UTF-8
C++
false
false
1,366
cc
/* @JUDGE_ID: 1102NT 438 C "" */ #include <cstdio> #include <cstdlib> #include <cmath> #include <cassert> const double EPS = 1e-8; bool dEqual(double x,double y) { return fabs(x-y) < EPS; } struct Point { double x, y; bool operator==(const Point &p) const { return dEqual(x, p.x) && dEqual(y, p.y); } bool operator<(const Point &p) const { return y < p.y || (y == p.y && x < p.x); } }; Point operator-(Point p,Point q){ p.x -= q.x; p.y -= q.y; return p; } Point operator+(Point p,Point q){ p.x += q.x; p.y += q.y; return p; } Point operator*(double r,Point p){ p.x *= r; p.y *= r; return p; } double operator*(Point p,Point q){ return p.x*q.x + p.y*q.y; } double len(Point p){ return sqrt(p*p); } double cross(Point p,Point q){ return p.x*q.y - q.x*p.y; } Point inv(Point p){ Point q = {-p.y,p.x}; return q; } bool circle3pt(Point a, Point b, Point c, Point &center, double &r) { double g = 2*cross((b-a),(c-b)); if (dEqual(g, 0)) return false; // colinear points double e = (b-a)*(b+a)/g, f = (c-a)*(c+a)/g; center = inv(f*(b-a) - e*(c-a)); r = len(a-center); return true; } int main(void) { Point p1, p2, p3, center; double r, pi; pi = atan(1)*4; while (scanf("%lf %lf %lf %lf %lf %lf", &p1.x, &p1.y, &p2.x, &p2.y, &p3.x, &p3.y) == 6) { circle3pt(p1, p2, p3, center, r); printf("%0.2f\n", 2*r*pi); } return 0; }
[ "howard.cheng@uleth.ca" ]
howard.cheng@uleth.ca
f1fe99113c48ca48bb04bfc2c7099fd1120fe149
93343c49771b6e6f2952d03df7e62e6a4ea063bb
/HDOJ/3506_autoAC.cpp
cc0d6c1f709c213147e50b18fbbbea05cda1c074
[]
no_license
Kiritow/OJ-Problems-Source
5aab2c57ab5df01a520073462f5de48ad7cb5b22
1be36799dda7d0e60bd00448f3906b69e7c79b26
refs/heads/master
2022-10-21T08:55:45.581935
2022-09-24T06:13:47
2022-09-24T06:13:47
55,874,477
36
9
null
2018-07-07T00:03:15
2016-04-10T01:06:42
C++
UTF-8
C++
false
false
1,366
cpp
#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxx=2002; int dp[maxx][maxx],mark[maxx][maxx],sum[maxx][maxx]; int data[maxx]; int min(int a,int b){ return a<b?a:b; } int main() { int n; while (scanf("%d",&n)!=EOF) { for (int i=1;i<=n;i++) { scanf("%d",&data[i]); data[i+n]=data[i]; } memset(sum,0,sizeof(sum)); for (int i=1;i<2*n;i++) { dp[i][i]=0; mark[i][i]=i; for (int j=i;j<=n+i;j++) { sum[i][j]=sum[i][j-1]+data[j]; } } for (int st=2;st<=n;st++) { for (int i=1;i+st<=2*n+1;i++) { int j=i+st-1; dp[i][j]=99999999; for (int k=mark[i][j-1];k<=mark[i+1][j];k++) { int temp=dp[i][k]+dp[k+1][j]+sum[i][j]; if (dp[i][j]>temp) { dp[i][j]=temp; mark[i][j]=k; } } } } int ans=9999999; for (int i=1;i<=n;i++) { ans=min(ans,dp[i][i+n-1]); } printf("%d\n",ans); } return 0; }
[ "noreply@github.com" ]
noreply@github.com
610c20add45b8ae93787d3d7bcbe5be45c79a5fb
5e31e553f91166e0e1fbd4bba233401513e40bdb
/기현/RollingDice.cpp
f3e83f57a1f22f773eaedd3262f75a6e9c02378e
[]
no_license
StarJins/SWCodingTest
63792157baadfb0a36e80d6466a526dc4f4db2fe
c67b81b204f0ee934d78d5dc490353e255ad8fb7
refs/heads/master
2020-04-29T02:40:16.973426
2019-10-08T16:27:17
2019-10-08T16:27:17
175,779,609
0
2
null
null
null
null
UHC
C++
false
false
2,507
cpp
#include <iostream> #include <vector> using namespace std; bool OutCheck(int mdf, int arrlen) { if (mdf >= arrlen || mdf < 0) return false; else return true; } /*void PrintDice(int * dice) { cout << "상단: " << dice[0] << endl; cout << "앞쪽: " << dice[1] << endl; cout << "오른쪽: " << dice[2] << endl; cout << "뒤쪽: " << dice[3] << endl; cout << "왼쪽: " << dice[4] << endl; cout << "하단: " << dice[5] << endl; }*/ void changeDice(int& below, int& map) { if (map == 0) { map = below; } else { below = map; map = 0; } } int main() { int M, N; int x, y; int cmd; int dir; int temp; int dice[6] = { 0,0,0,0,0,0 }; cin >> N >> M >> x >> y >> cmd; vector<vector<int>>arr(N, vector<int>(M)); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin >> arr[i][j]; } } /*for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cout << arr[i][j] << ' '; } cout << endl; } cout << endl;*/ vector<int> cmdArr(cmd); for (int i = 0; i < cmd; i++) { cin >> dir; cmdArr[i] = dir; } for(int i=0; i<cmd; i++){ switch (cmdArr[i]) { case 1: if (OutCheck(y + 1, M)) { temp = dice[0]; dice[0] = dice[4]; dice[4] = dice[5]; dice[5] = dice[2]; dice[2] = temp; changeDice(dice[5], arr[x][++y]); //PrintDice(dice); cout << dice[0] << endl; } break; case 2: if (OutCheck(y - 1, M)) { temp = dice[0]; dice[0] = dice[2]; dice[2] = dice[5]; dice[5] = dice[4]; dice[4] = temp; changeDice(dice[5], arr[x][--y]); //PrintDice(dice); cout << dice[0] << endl; } break; case 3: if (OutCheck(x - 1, N)) { temp = dice[0]; dice[0] = dice[1]; dice[1] = dice[5]; dice[5] = dice[3]; dice[3] = temp; changeDice(dice[5], arr[--x][y]); //PrintDice(dice); cout << dice[0] << endl; } break; case 4: if (OutCheck(x + 1, N)) { temp = dice[0]; dice[0] = dice[3]; dice[3] = dice[5]; dice[5] = dice[1]; dice[1] = temp; changeDice(dice[5], arr[++x][y]); //PrintDice(dice); cout << dice[0] << endl; } break; } /*for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cout << arr[i][j] << ' '; } cout << endl; } cout << "====================" << endl;*/ } return 0; }
[ "noreply@github.com" ]
noreply@github.com
ffc6add2e87a5a9256657063ba9a582422fb1f41
78f48aad42523fb1d41341b5ab960e0f7bbf9acb
/TelaContinuar.cpp
1c2ea504b71571ffe141a31eaf5c671ab32b7960
[]
no_license
ArturEndress/AdventureGame
6ca1274172130df425ce55b3cb32ff5d40e673b9
0e44f9b7b86a9eb18f4f366c3a0627dea71f02a8
refs/heads/master
2020-04-28T12:26:01.237078
2019-03-12T18:51:09
2019-03-12T18:51:09
175,275,945
1
0
null
null
null
null
ISO-8859-1
C++
false
false
1,556
cpp
#include "TelaContinuar.h" TelaContinuar::TelaContinuar() { } TelaContinuar::~TelaContinuar() { } void TelaContinuar::inicializar(stack<Tela*>* telas) { this->telas = telas; // Fundo da tela if (!gRecursos.carregouSpriteSheet("telaC")) { gRecursos.carregarSpriteSheet("telaC", "telas/TelaContinuar.png"); } fundo.setSpriteSheet("telaC"); } void TelaContinuar::atualizar() { desenhar(); if (gTeclado.pressionou[TECLA_2]) { // Desempilha a tela de seleção para que a do topo seja a do Menu telas->pop(); // Cria e empilha tela de jogo TelaJogo *telaJogo = new TelaJogo; telaJogo->inicializar(telas); //telaJogo->setLoaded(); for (int i = 0; i < 15; i++) { telaJogo->salas2.push(new Sala); telaJogo->salas2.top()->setLoaded(); telaJogo->salas2.top()->load(14 - i); } telaJogo->salas.push(telaJogo->salas2.top()); telaJogo->salas2.pop(); while (telaJogo->salas.top()->getSalaAtual() != telaJogo->salas.top()->getSalaSave()) { telaJogo->salas.push(telaJogo->salas2.top()); telaJogo->salas2.pop(); } telas->push(telaJogo); } // Botão Voltar bVoltar.atualizar(); if (bVoltar.estaClicado()) { telas->pop(); // desempilha a tela de seleção e volta para o Menu } } void TelaContinuar::desenhar() { // Fundo fundo.desenhar(gJanela.getLargura() / 2, gJanela.getAltura() / 2); // Botão Voltar bVoltar.setPos(gJanela.getLargura() / 2, 700); bVoltar.desenhar(); // Slots // ... } void TelaContinuar::finalizar() { gRecursos.descarregarSpriteSheet("telaC"); }
[ "artur-efo@live.com" ]
artur-efo@live.com
51448e6d3af91398ef6f355e3ac2692849126d46
458361fecc8b40fc581e758df632765bb26292e3
/debug/moc_widget.cpp
df51cde0d8ae701ced06ab3a4ea720dfcb0a9a2a
[]
no_license
crazyshare/flappy-bird
f6829de8000769dddb8abc0bfd5c3edbe96b64e3
f8d566d17d7992004a28bf6f21d2eeb75650325e
refs/heads/master
2020-03-27T08:23:43.027137
2018-08-21T15:45:33
2018-08-21T15:45:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,365
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'widget.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.3.2) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../widget.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'widget.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.3.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_Widget_t { QByteArrayData data[6]; char stringdata[35]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_Widget_t, stringdata) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_Widget_t qt_meta_stringdata_Widget = { { QT_MOC_LITERAL(0, 0, 6), QT_MOC_LITERAL(1, 7, 12), QT_MOC_LITERAL(2, 20, 0), QT_MOC_LITERAL(3, 21, 2), QT_MOC_LITERAL(4, 24, 5), QT_MOC_LITERAL(5, 30, 4) }, "Widget\0SendKeyPress\0\0Do\0frame\0View" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_Widget[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 2, // signalCount // signals: name, argc, parameters, tag, flags 1, 0, 34, 2, 0x06 /* Public */, 3, 0, 35, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags 4, 0, 36, 2, 0x0a /* Public */, 5, 0, 37, 2, 0x0a /* Public */, // signals: parameters QMetaType::Void, QMetaType::Void, // slots: parameters QMetaType::Void, QMetaType::Void, 0 // eod }; void Widget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Widget *_t = static_cast<Widget *>(_o); switch (_id) { case 0: _t->SendKeyPress(); break; case 1: _t->Do(); break; case 2: _t->frame(); break; case 3: _t->View(); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast<int *>(_a[0]); void **func = reinterpret_cast<void **>(_a[1]); { typedef void (Widget::*_t)(); if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Widget::SendKeyPress)) { *result = 0; } } { typedef void (Widget::*_t)(); if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Widget::Do)) { *result = 1; } } } Q_UNUSED(_a); } const QMetaObject Widget::staticMetaObject = { { &QGLWidget::staticMetaObject, qt_meta_stringdata_Widget.data, qt_meta_data_Widget, qt_static_metacall, 0, 0} }; const QMetaObject *Widget::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *Widget::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_Widget.stringdata)) return static_cast<void*>(const_cast< Widget*>(this)); return QGLWidget::qt_metacast(_clname); } int Widget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QGLWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 4) qt_static_metacall(this, _c, _id, _a); _id -= 4; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 4) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 4; } return _id; } // SIGNAL 0 void Widget::SendKeyPress() { QMetaObject::activate(this, &staticMetaObject, 0, 0); } // SIGNAL 1 void Widget::Do() { QMetaObject::activate(this, &staticMetaObject, 1, 0); } QT_END_MOC_NAMESPACE
[ "42065449+Cirno0@users.noreply.github.com" ]
42065449+Cirno0@users.noreply.github.com
ff83a137ea277d45eff43915b8d446c15a77f39d
21643ba7ca6331f9990cd0c6d894eef667bdd98f
/AyushkaAlgo/Graph/06_Dijkstra_AdjMatrix.cpp
6dbbcda375998034627127576ed50ae43f99a8eb
[]
no_license
Cazaimi/geeksforgeeks
e83fce617751c1bc56a4d2e67abfbfdb9fc285ab
e7c7923b74cc56fc232c15c082aefecbdb716fd7
refs/heads/master
2021-01-19T17:10:36.260610
2017-12-31T07:20:58
2017-12-31T07:20:58
101,054,719
1
0
null
null
null
null
UTF-8
C++
false
false
1,434
cpp
/* Please note that it's Function problem i.e. you need to write your solution in the form of Function(s) only. Driver Code to call/invoke your function would be added by GfG's Online Judge.*/ /* The function prints V space separated integers where the ith integer denote the shortest distance of ith vertex from source vertex */ #define loop(i,a,n) for(int i = a;i < n;i++) void dijkstra(int graph[MAX][MAX], int s,int V) { //Your code here /* <weight, <u,v>> : min_heap */ priority_queue < pair <int,int>, vector <pair <int,int> >, greater<pair <int,int> > > pq; vector <int> visited(V); loop(i,0,V){ pq.push(make_pair(0,s)); //if(graph[s][i]) pq.push(make_pair(0+graph[s][i],i)); } vector <int> weights(V); while(!pq.empty()){ pair <int,int> p = pq.top(); int weight = p.first; int currNode = p.second; //cout << "weight:" << weight << " currNode:" << currNode << endl; pq.pop(); if(!visited[currNode]){ loop(i,0,V){ if(!visited[i] and graph[currNode][i]){ pq.push(make_pair(weight+graph[currNode][i],i)); } } weights[currNode] = weight; //cout << weight << " "; visited[currNode] = 1; } } loop(i,0,V) cout << weights[i] << " "; //cout << endl; }
[ "anmol01shukla@gmail.com" ]
anmol01shukla@gmail.com
5613d448321269487fb8535ff878b5947364b701
b06bd58597b538dd50d46e0c49ca43eca53b833a
/labs/lab10/lab10-tache3/etape6.cpp
3bad5c3b3e6d4e99d4aaf03272097a145f552e0a
[ "MIT" ]
permissive
MFarradji/inf3105
e5b6ab8f1c074eae6a1733d2f20c11fd234d1e47
93ffd6a237acbb67072d69fb5a8be02439f59a04
refs/heads/master
2020-06-24T06:16:57.823902
2019-03-13T00:47:45
2019-03-13T00:47:45
198,876,599
0
3
null
2019-07-25T17:43:04
2019-07-25T17:43:04
null
UTF-8
C++
false
false
3,145
cpp
/* INF3105 / Lab10 -- Exercices sur l'héritage et les conteneurs. Étape 6 : l'héritage et les tableaux dynamiques etape5.cpp --> Équipe avait une taille fixe. etape6.cpp --> Examinons le cas avec un tableau dynamique. */ #include <iostream> using namespace std; class Personne{ public: Personne(const string& nom="?"); virtual void afficher() const; protected: string nom; }; class Etudiant : public Personne{ public: Etudiant(const string& nom_, const string& programme_, float moyenne_); virtual void afficher() const; protected: string programme; float moyenne; }; class Employe : public Personne{ public: Employe(const string& nom_, const string& departement_, float salaire_); void afficher() const; protected: string departement; float salaire; }; //***** Début des définitions (implémentations des constructeurs et fonctions) *************/ Personne::Personne(const string& nom_) : nom(nom_) { } void Personne::afficher() const{ cout << "Personne: nom=" << nom << std::endl; } Etudiant::Etudiant(const string& nom_, const string& programme_, float moyenne_) : Personne(nom_), programme(programme_), moyenne(moyenne_) //Personne(nom) : comme Etudiant dérive de Personne, il faut construire la partie Personne // on appelle donc le constructeur Personne(const string&) { } void Etudiant::afficher() const{ cout << "Etudiant: nom=" << nom << ", programme=" << programme << ", moyenne=" << moyenne << "/4.3" << std::endl; } Employe::Employe(const string& nom_, const string& departement_, float salaire_) : Personne(nom_), departement(departement_), salaire(salaire_) //Personne(nom) : comme Employe dérive de Personne, il faut construire la partie Personne // on appelle donc le constructeur Personne(const string&) { } void Employe::afficher() const{ cout << "Employe: nom=" << nom << ", departement=" << departement << ", salaire=" << salaire << "$/an" << std::endl; } //***** Fin des définitions *************/ int main() { Personne** equipe = new Personne*[5]; // tableau créé dynamiquement equipe[0] = new Personne("marc"); equipe[1] = new Etudiant("marie", "medecine", 4.1f); equipe[2] = new Etudiant("sophie", "informatique", 3.5); equipe[3] = new Employe("robert", "finances", 62400); equipe[4] = new Employe("anne", "ingenerie", 67400); for(int i=0;i<5;i++){ cout << "[" << i << "] "; equipe[i]->afficher(); } // Libération de la mémoire // C'est maintenant un peu plus compliqué // On ne peut pas seulement faire 'delete []equipe' car cela libère le tableau de pointeurs // mais laisse les 5 objets créés for(int i=0;i<5;i++) delete equipe[i]; // l'objet pointé par equipe[i] n'est pas un tableau, donc il ne faut pas faire delete[] equipe[i]; // Il faut aussi libérer la mémoire de equipe, car ce tableau n'est plus créé sur la pile, mais sur le heap // et il faut le faire après avec les delete sur les objets delete[] equipe; return 0; }
[ "charlantfr@gmail.com" ]
charlantfr@gmail.com
d27012469e10d8fcf4c0e4bb24f0f3f21b878744
0fc6eadc8811a6990e0bd41e9a23bf698e738c88
/比赛/队内赛/补题/cf877e.cpp
e26f9fa500664f8afbd62db9df9678919367ea4b
[]
no_license
bossxu/acm
f88ee672736709f75739522d7e0f000ac86a31de
871f8096086e53aadaf48cd098267dfbe6b51e19
refs/heads/master
2018-12-27T22:20:27.307185
2018-12-20T04:41:51
2018-12-20T04:41:51
108,379,456
0
0
null
null
null
null
UTF-8
C++
false
false
2,667
cpp
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<queue> #include<stack> #include<vector> #include<cmath> #include<set> #include<cstdlib> #include<functional> #include<climits> #include<cctype> #include<iomanip> using namespace std; typedef long long ll; #define INF 0x3f3f3f3f const int mod = 1e9+7 ; #define clr(a,x) memset(a,x,sizeof(a)) #define cle(a,n) for(int i=1;i<=n;i++) a.clear(); const double eps = 1e-6; int shu[200005]; vector<int>t[200005]; vector<int>path[200005]; int tot; void dfs(int st) { path[st].push_back(tot+1); for(int i = 0;i<t[st].size();i++) { dfs(t[st][i]); } tot++; path[st].push_back(tot); } #define lson rt<<1 #define rson rt<<1|1 //区间更新模板题 这是区间变一个值 const int maxn = 200005; ll a[maxn]; int lazy[maxn]; struct node { int l,r; ll s; }tree[maxn<<2]; void pushup(int rt) { tree[rt].s = tree[lson].s+tree[rson].s; } void pushdown(int rt) { if(lazy[rt]) { lazy[lson]^=1; lazy[rson]^=1; tree[lson].s = tree[lson].r+1-tree[lson].l - tree[lson].s; tree[rson].s = tree[rson].r+1-tree[rson].l - tree[rson].s; lazy[rt] = 0; } } void build(int rt, int l, int r)//建树 { tree[rt].l = l; tree[rt].r = r; if(l == r) { tree[rt].s = shu[l]; return ; } int mid = (l+r)>>1; build(lson,l,mid); build(rson,mid+1,r); pushup(rt); } void duan_up(int rt,int l,int r,int m) { if(tree[rt].l>=l && tree[rt].r<=r) { lazy[rt] ^= m; tree[rt].s = tree[rt].r-tree[rt].l+1-tree[rt].s; return; } pushdown(rt); int mid = (tree[rt].l+tree[rt].r)>>1; if(l<=mid) duan_up(lson,l,r,m); if(r>mid) duan_up(rson,l,r,m); pushup(rt); } int query(int rt,int l,int r) { //cout<<l<<r<<endl; if(l <= tree[rt].l && r >= tree[rt].r) return tree[rt].s; pushdown(rt); int mid = (tree[rt].l+tree[rt].r)/2; int ans= 0; if(l <= mid) ans+= query(lson,l,r); if(r>mid) ans+= query(rson,l,r); return ans; } int main() { freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); std::ios::sync_with_stdio(false); cin.tie(0); int n; while(cin>>n) { int pre; for(int i = 2;i<=n;i++) { cin>>pre; t[pre].push_back(i); } tot = 0; dfs(1); int a; for(int i = 1;i<=n;i++) { cin>>a; shu[path[i][1]] = a; } build(1,1,n); int m; cin>>m; while(m--) { int quan; char s[10]; cin>>s>>quan; if(s[0] == 'g') { cout<<query(1,path[quan][0],path[quan][1])<<endl; } else { duan_up(1,path[quan][0],path[quan][1],1); } } } return 0; }
[ "756753676@qq.com" ]
756753676@qq.com
1db38914d80064f5a22ad231ec715e7847bb57ac
f5a8254ab9f6b68768d4309e48a387a142935162
/DomainPTU/smartsoft/src-gen/DomainPTU/CommPTUMoveResponseACE.cc
9dd1b891446b93a5be82a0dec6b68beefa2409f2
[ "BSD-3-Clause" ]
permissive
canonical-robots/DomainModelsRepositories
9839a3f4a305d3a94d4a284d7ba208cd1e5bf87f
68b9286d84837e5feb7b200833b158ab9c2922a4
refs/heads/master
2022-12-26T16:33:58.843240
2020-10-02T08:54:50
2020-10-02T08:54:50
287,251,257
0
0
BSD-3-Clause
2020-08-13T10:39:30
2020-08-13T10:39:29
null
UTF-8
C++
false
false
2,100
cc
//-------------------------------------------------------------------------- // Code generated by the SmartSoft MDSD Toolchain // The SmartSoft Toolchain has been developed by: // // Service Robotics Research Center // University of Applied Sciences Ulm // Prittwitzstr. 10 // 89075 Ulm (Germany) // // Information about the SmartSoft MDSD Toolchain is available at: // www.servicerobotik-ulm.de // // Please do not modify this file. It will be re-generated // running the code generator. //-------------------------------------------------------------------------- #include "DomainPTU/CommPTUMoveResponseACE.hh" #include <ace/SString.h> #include "CommBasicObjects/CommBaseStateACE.hh" #include "DomainPTU/enumPTUMoveStatusData.hh" #include "CommBasicObjects/CommPose3dACE.hh" // serialization operator for element CommPTUMoveResponse ACE_CDR::Boolean operator<<(ACE_OutputCDR &cdr, const DomainPTUIDL::CommPTUMoveResponse &data) { ACE_CDR::Boolean good_bit = true; // serialize list-element devicePose good_bit = good_bit && cdr << data.devicePose; // serialize list-element stateBase good_bit = good_bit && cdr << data.stateBase; // serialize list-element status good_bit = good_bit && cdr.write_long(data.status); return good_bit; } // de-serialization operator for element CommPTUMoveResponse ACE_CDR::Boolean operator>>(ACE_InputCDR &cdr, DomainPTUIDL::CommPTUMoveResponse &data) { ACE_CDR::Boolean good_bit = true; // deserialize type element devicePose good_bit = good_bit && cdr >> data.devicePose; // deserialize type element stateBase good_bit = good_bit && cdr >> data.stateBase; // deserialize type element status good_bit = good_bit && cdr.read_long(data.status); return good_bit; } // serialization operator for CommunicationObject CommPTUMoveResponse ACE_CDR::Boolean operator<<(ACE_OutputCDR &cdr, const DomainPTU::CommPTUMoveResponse &obj) { return cdr << obj.get(); } // de-serialization operator for CommunicationObject CommPTUMoveResponse ACE_CDR::Boolean operator>>(ACE_InputCDR &cdr, DomainPTU::CommPTUMoveResponse &obj) { return cdr >> obj.set(); }
[ "lotz@hs-ulm.de" ]
lotz@hs-ulm.de
dacf65aa123e30290fba8d56f97a7fc7524295b5
d696223e33a04fa9a3f0aded54d0cd612f32601f
/src/common.h
1154f5bd842af0206b270cf5ca8e81a1e01330e1
[]
no_license
gokhanettin/PardusImageWriter
d896e3ee406b5cc755b697b31869ae6b5fa494b2
3e3057be8ea4f8a98aff1a21a83067bdf81c8efd
refs/heads/master
2021-09-18T13:17:40.252226
2018-07-14T23:47:56
2018-07-14T23:53:04
115,549,308
0
0
null
2017-12-27T18:59:08
2017-12-27T18:59:08
null
UTF-8
C++
false
false
3,693
h
#ifndef COMMON_H #define COMMON_H //////////////////////////////////////////////////////////////////////////////// // This file contains some commonly-used constants and function declarations #include <QObject> #include <QString> #include <QList> #include <type_traits> #include "src/platform.h" class UsbDevice; // Default unit to be used when displaying file/device sizes (MB) const quint64 DEFAULT_UNIT = 1048576; // Pointer to correctly typed application instance // #define mApp (static_cast<MainApplication*>qApp) // Returns the number of blocks required to contain some number of bytes // Input: // T - any integer type // val - number of bytes // factor - size of the block // Returns: // the number of blocks of size <factor> required for <val> to fit in template <typename T> T alignNumberDiv(T val, T factor) { static_assert(std::is_integral<T>::value, "Only integer types are supported!"); return ((val + factor - 1) / factor); } // Returns the total size of blocks required to contain some number of bytes // Input: // T - any integer type // val - number of bytes // factor - size of the block // Returns: // the total size of blocks of size <factor> required for <val> to fit in template <typename T> T alignNumber(T val, T factor) { static_assert(std::is_integral<T>::value, "Only integer types are supported!"); return alignNumberDiv(val, factor) * factor; } #if defined(Q_OS_WIN32) // Converts the WinAPI and COM error code into text message // Input: // errorCode - error code (GetLastError() is used by default) // Returns: // system error message for the errorCode QString errorMessageFromCode(DWORD errorCode = GetLastError()); // Converts the WinAPI and COM error code into text message // Input: // prefixMessage - error description // errorCode - error code (GetLastError() is used by default) // Returns: // prefixMessage followed by a newline and the system error message for the errorCode QString formatErrorMessageFromCode(QString prefixMessage, DWORD errorCode = GetLastError()); #endif // Gets the contents of the specified file // Input: // fileName - path to the file to read // Returns: // the file contents or empty string if an error occurred QString readFileContents(const QString& fileName); // Callback function type for platformEnumFlashDevices (see below) // Input: // cbParam - parameter passed to the enumeration function // DeviceVendor - vendor of the USB device // DeviceName - name of the USB device // PhysicalDevice - OS-specific path to the physical device // Volumes - list of volumes this device contains // NumVolumes - number of volumes in the list // Size - size of the disk in bytes // SectorSize - sector size of the device // Returns: // nothing typedef void (*AddFlashDeviceCallbackProc)(void* cbParam, UsbDevice* device); // Performs platform-specific enumeration of USB flash disks and calls the callback // function for adding these devices into the application GUI structure // Input: // callback - callback function to be called for each new device // cbParam - parameter to be passed to this callback function // Returns: // true if enumeration completed successfully, false otherwise QList<UsbDevice> platformEnumFlashDevices(); // Checks the application privileges and if they are not sufficient, restarts // itself requesting higher privileges // Input: // appPath - path to the application executable // Returns: // true if already running elevated // false if error occurs // does not return if elevation request succeeded (the current instance terminates) bool ensureElevated(); #endif // COMMON_H
[ "yunusemre.senturk@pardus.org.tr" ]
yunusemre.senturk@pardus.org.tr
0d524ed721c4c0d2c239966243a988323800df24
65db42733d7a66ab0791711e306f51a8cdf77562
/src/living.h
4878be73c9091795094f378a73ec1b56a37bcd90
[ "MIT" ]
permissive
ccoale/Aspen
53423a06cd9ede5f669110d7124dcc919e0db8be
e5464b1e6838de27ca62a833af0e44077a45f478
refs/heads/master
2021-01-18T11:30:29.776575
2015-03-27T23:23:07
2015-03-27T23:23:07
32,852,991
0
0
null
2015-03-25T08:54:45
2015-03-25T08:54:45
null
UTF-8
C++
false
false
1,830
h
/* *The main living class *Holds functions needed for both players and mobs. */ #pragma once #ifndef LIVING_H #define LIVING_H #include <queue> #include <vector> #include <tinyxml.h> #include "mud.h" #include "conf.h" #include "event.h" #include "entity.h" #include "attribute.h" #include "affect.h" struct _aff_comp { bool operator()(Affect* a, Affect* b) { return ((a->GetDuration() > b->GetDuration()) ? true : false); } }; enum class Gender { Male=1, Female }; class Living:public Entity { int _level; POSITION _position; Gender _gender; std::vector<Attribute*> _attributes; std::priority_queue<Affect*, std::vector<Affect*>, _aff_comp> _taffects; std::vector<Affect*> _paffects; public: Living(); virtual ~Living(); /* *This is called when an object enters or leaves the game environment */ virtual void EnterGame(); virtual void LeaveGame(); /* *This is updated on a set interval to keep the objects up-to-date. *This includes heartbeat, removing uneeded objects, etc. */ virtual void Update(); /* *Find out what type of living this is *Return: False *Note: Should overwrite this for player and NPC objects to return true for each object. */ virtual BOOL IsLiving() const; /*getters and setters*/ Gender GetGender() const; void SetGender(Gender gender); int GetLevel() const; void SetLevel(int level); bool AddAttribute(Attribute* attr); void FindAttribute(AttributeApplication apply, int id, std::vector<Attribute*> &results); void FindAttribute(AttributeType type, std::vector<Attribute*>& results); bool RemoveAttribute(AttributeType type, int id); virtual void Serialize(TiXmlElement* root); virtual void Deserialize(TiXmlElement* root); }; #endif
[ "tyler@tysdomain.com" ]
tyler@tysdomain.com
99fa5e4cf2d0c47a58e56ffb010e47f41b5dd3da
d6e49af6572fe9327014735fff5ed5429ad62e5d
/src/gamelogic.h
65e33a284f1194a82b2aeb98c6f6a04c8f3fe5cd
[]
no_license
Kert/Platformer
428311f6e492b4a4863f95395bf36aaeb3187ed5
bc147d0b8dadebcc60f776ca2480a3f05fa72a30
refs/heads/master
2023-06-11T01:04:04.546393
2023-05-30T08:23:43
2023-05-30T08:23:43
157,845,255
1
0
null
null
null
null
UTF-8
C++
false
false
1,047
h
#ifndef _gamelogic_h_ #define _gamelogic_h_ #include <SDL.h> #include "entities.h" #include "globals.h" #include "level.h" namespace Game { Player* GetPlayer(); Player* CreatePlayer(); void RemovePlayer(); Level* GetLevel(); void CreateLevel(std::string fileName); void RemoveLevel(); void SetDebug(bool toggle); GAMESTATES GetState(); void SetState(GAMESTATES state); void ChangeState(GAMESTATES state); void Start(); GAME_OVER_REASONS GetGameOverReason(); void GameOver(GAME_OVER_REASONS reason); void Update(double ticks); void Reset(); void AddTime(); void OnLevelExit(); int GetTimeLimit(); int GetPlayerLivesLeft(); void ResetPlayerLives(); bool IsGameEndRequested(); void SetGameEndFlag(); bool IsDebug(); } namespace Fading { int GetVal(); FADING_STATES GetState(); void Update(double ticks); void Remove(); void Init(FADING_STATES state, int start, int end, double sec); void Init(FADING_STATES state, int start, int end, double sec, GAMESTATES to); } #endif
[ "kertwaii@gmail.com" ]
kertwaii@gmail.com
a506745c2aa018a307bea42548c549c1240d5567
01da296e834ef6d292c132d2633d8b05f35d3bb2
/code/finaly/code/Smulewicz.cpp
759060831f8c31c4fc0b7fda34874958a218b88a
[]
no_license
cuber2460/acmlib07
07732ddc210912fbd6a112aaad39171f457f2e18
954ed6e8471c62d40c3f0ee6a42c125af1ccd77e
refs/heads/master
2021-06-20T00:34:07.923798
2019-11-24T19:11:07
2019-11-24T19:11:07
154,525,341
6
0
null
null
null
null
UTF-8
C++
false
false
1,650
cpp
#define int ll//jeśli long longi potrzebne struct SPFA{ int n; vector<int> odl, oj, czok; vector<vector<pair<int,int>>> d; vector<vector<int>> d2; const int inf = 1e9; SPFA(int _n):n(_n+1){ odl.resize(n, inf); oj.resize(n); czok.resize(n); d.resize(n); d2.resize(n); } vector<int> cykl; int root; bool us(int nr){ if(nr == root) return 1; czok[nr] = 0; for(int ak:d2[nr]){ if(oj[ak] == nr){ if(us(ak)){ cykl.push_back(nr); //numeracja od zera return 1; } } } d2[nr].clear(); return 0; } bool licz_sciezki(int s){ // false, gdy z s da sie dojsc do ujemnego cyklu vector<int> st, st2; // znaleziony cykl jest w wektorze cykl odl[s] = 0; czok[s] = 1; st.push_back(s); while(st.size()){ for(int i=0; i<(int)st.size(); i++){ int ak = st[i]; if(czok[ak]) for(pair<int,int> x:d[ak]){ int nei, cost; tie(nei, cost) = x; if(odl[ak] + cost < odl[nei]){ root = ak; if(us(nei)){ cykl.push_back(ak); reverse(cykl.begin(), cykl.end()); return 0; } odl[nei] = odl[ak] + cost; oj[nei] = ak; d2[ak].push_back(nei); czok[nei] = 1; st2.push_back(nei); } } } st.clear(); swap(st, st2); } return 1; } vector<int> ujemny_cykl(){ for (int i=0; i<n-1; i++) add_edge(n-1, i, 0); if (licz_sciezki(n-1)){ return {}; } else { return cykl; } } void add_edge(int a, int b, int cost){ d[a].push_back({b, cost}); } }; #undef int
[ "mtszrdck@gmail.com" ]
mtszrdck@gmail.com
0597154902937d0d357ac8cdc2a516fc2313bee0
d8480bac32001bd0f4130a2b3864c4645b456444
/SearchApp/OptionsDlg.h
63397da55bfc243f9b87d96ec9551a92321549dd
[]
no_license
Feoggou/searchapp
4cfbd487ee3a272495c0da3cd071f28ec539754c
022b842578eb14037fe581de9df8c8e74c7084ad
refs/heads/master
2020-06-09T05:25:21.826966
2013-04-02T19:37:48
2013-04-02T19:37:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,377
h
#pragma once #ifndef OPTIONSDLG_H #define OPTIONSDLG_H #include <windows.h> #include "SearchAppDlg.h" class COptionsDlg { private: //private data: static WNDPROC OldEditTimeProc; FILETIME m_ftCreatedSince, m_ftWrittenSince, m_ftAccessedSince; FILETIME m_ftCreatedUntil, m_ftWrittenUntil, m_ftAccessedUntil; HWND m_hCreatedSince, m_hCreatedUntil; HWND m_hWrittenSince, m_hWrittenUntil; HWND m_hAccessedSince, m_hAccessedUntil; CONDITION* m_pCondition; enum KEYWORD { Anytime, //months January, February, March, April, May, June, July, August, September, October, November, December, //days of the week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, //this: Today, ThisWeek, ThisMonth, ThisYear, //last Yesterday, LastWeek, LastMonth, LastYear, //counts DaysAgo, WeeksAgo, MonthsAgo, YearsAgo, }; struct KEY { KEYWORD nID; WCHAR wsText[10]; }; public: //public data: HWND m_hWnd; //private functions private: static INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //the procedure of a time edit static LRESULT CALLBACK NewEditTimeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR OnInitDialog(); BOOL OnOK(); //checks to see if every "time" is set correctly BOOL CheckTimes(void); //checks the time text. BOOL CheckTimeText(WCHAR* wsText, int len, FILETIME& fileTime, BOOL bIsSince); //transforms a day-of-the-week into a date BOOL CalcDay(int iChosenDay, SYSTEMTIME& localTime, FILETIME& fileTime); //decrease by a number of months void DecMonth(WORD nCountDec, SYSTEMTIME& localTime); //decrease by a number of days BOOL DecDays(WORD nCountDec, SYSTEMTIME& localTime, FILETIME& fileTime); //decrease by a number of weeks BOOL DecWeeks(WORD nCountDec, SYSTEMTIME& localTime, FILETIME& fileTime); //retrieves the next integer from the string and returns the position after the end of the integer BOOL GetNextInt(int& nr, WCHAR** wPos); //retrieves the keyword of the string that follows and returns the position after the end of that string. BOOL GetNextString(WCHAR*& wPos, KEYWORD& key); //initializes the time boxes with the data set before. void InitializeTimeBoxes(void); public: //public functions: COptionsDlg(void); ~COptionsDlg(void); INT_PTR DoModal(HWND hParent, CONDITION* pCondition); }; #endif//OPTIONSDLG_H
[ "samuel.ghinet@moredevs.ro" ]
samuel.ghinet@moredevs.ro
a402c16de4ae08bf0f542e4de27d0f375e151973
a8bb78006e24bc53741cd604552f424615295ed4
/Project2/Project2/load_shaders.cpp
80808cdf9484482ac52dd45dd51173f3f4df2fa8
[]
no_license
buttburger/Collada-Parser
a541b2a6b42cdb5f228de9054898287bfd6552d1
5d8c07b105bd803942fc4072612e125e471323fa
refs/heads/master
2020-04-05T04:06:59.028098
2019-07-31T07:10:26
2019-07-31T07:10:26
156,537,973
0
0
null
null
null
null
UTF-8
C++
false
false
3,658
cpp
#include "Common.h" GLuint vert_hdlr, frag_hdlr; //char*copy; //char*copypointer[] = {copy}; void printInfoLog(GLuint obj) { int log_size = 0; int bytes_written = 0; glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &log_size); if(!log_size)return; char*infoLog = new char[log_size]; glGetProgramInfoLog(obj, log_size, &bytes_written, infoLog); printf("%s\n", infoLog); delete[]infoLog; } bool read_n_compile_shader(const char *filename, GLuint &hdlr, GLenum shaderType) { FILE*file; fopen_s(&file, filename, "rb"); if(!file) { perror("ERROR: Cannot open file\n"); return "\0"; } fseek(file, 0L, SEEK_END); //Tell file size unsigned long shaderFileSize; shaderFileSize = ftell(file); //printf("DEBUG shaderFileSize: %lu\n", shaderFileSize); rewind(file); char*buffer = (char*)malloc(sizeof(char)*(shaderFileSize+1UL)); if(!buffer) { perror("ERROR: Failed to allocate memory\n"); return "\0"; } int c, i = 0; while((c = fgetc(file))!= EOF)buffer[i++] = c; buffer[shaderFileSize] = '\0'; //Put '\0' at the end of the buffer(required for OpenGL) //printf("Buffer:\n%s\n", buffer); //printf("strlen: %d\n", strlen(buffer)); fclose(file); hdlr = glCreateShader(shaderType); glShaderSource(hdlr, 1, (const GLchar**)&buffer, NULL); glCompileShader(hdlr); printf("Loading info for: %s\n", filename); /* copy = (char*)malloc(sizeof(char)*(shaderFileSize+1UL)); strcpy(copy, buffer); copypointer[2] = copy; printf("COPYTEST: %s\n", copypointer[2]); */ //printInfoLog(hdlr); delete[]buffer; return true; } void loadShaders(GLuint &prog_hdlr, const char*vsfile, const char*fsfile) { /* //size_t shaderNameSize = strlen(shaderStr); const char*shaderStr = vsfile; int shaderNameSize = 0; while(shaderStr[shaderNameSize] != '\0')shaderNameSize++; char*copytest = (char*)malloc(sizeof(char)*(shaderNameSize+1UL)); printf("SHADERNAMESIZE: %d\n", shaderNameSize); getchar(); char*copypointertest[] = {copytest}; strcpy(copytest, vsfile); copypointertest[0] = copytest; strcpy(copytest, fsfile); copypointertest[1] = copytest; printf("COPYTEST: %s - %s\n", copypointertest[0], copypointertest[1]); */ read_n_compile_shader(vsfile, vert_hdlr, GL_VERTEX_SHADER); read_n_compile_shader(fsfile, frag_hdlr, GL_FRAGMENT_SHADER); prog_hdlr = glCreateProgram(); glAttachShader(prog_hdlr, frag_hdlr); glAttachShader(prog_hdlr, vert_hdlr); glLinkProgram(prog_hdlr); //printf("Loading linked program: vs: %d fs: %d prog_hdlr: %d\n", vert_hdlr, frag_hdlr, prog_hdlr); glUseProgram(prog_hdlr); //printInfoLog(prog_hdlr); glDetachShader(prog_hdlr, vert_hdlr); glDetachShader(prog_hdlr, frag_hdlr); //glDeleteShader(vert_hdlr); //glDeleteShader(frag_hdlr); } void setShaders(GLuint &set_prog_hdlr, GLuint set_vert_hdlr, GLuint set_frag_hdlr) { //set_prog_hdlr = glCreateProgram(); glAttachShader(set_prog_hdlr, set_frag_hdlr); glAttachShader(set_prog_hdlr, set_vert_hdlr); glLinkProgram(set_prog_hdlr); //printf("SETSHADER: vs: %d fs: %d prog_hdlr: %d\n", set_vert_hdlr, set_frag_hdlr, set_prog_hdlr); glUseProgram(set_prog_hdlr); //printInfoLog(set_prog_hdlr); glDetachShader(set_prog_hdlr, set_vert_hdlr); glDetachShader(set_prog_hdlr, set_frag_hdlr); } /* std::ifstream is(filename, std::ios::in|std::ios::binary|std::ios::ate); if(!is.is_open()) { printf("Unable to open file %s\n", filename); return false; } long size = (long)is.tellg(); char*buffer = new char[size+1]; is.seekg(0, std::ios::beg); is.read (buffer, size); is.close(); buffer[size] = 0; */
[ "noreply@github.com" ]
noreply@github.com
2f5b5a5fae55db7dca9d66725a6246e6b804fde7
3b65b755b472a71d705fe48bb0f2a2b33345686b
/klee/lib/Core/ExecutionState.cpp
8cf907de23e3f720e465326e770158b36c16a5a9
[ "NCSA" ]
permissive
ntauth/kleespectre
40b32a86e4e8ae6e2beac942d5750c34509b4f4d
0eca358b27cf7cd624fd4cbd49e187d57cf835dc
refs/heads/master
2022-04-06T01:41:25.070063
2020-02-28T05:05:00
2020-02-28T05:05:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,366
cpp
//===-- ExecutionState.cpp ------------------------------------------------===// // // The KLEE Symbolic Virtual Machine // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "Memory.h" #include "klee/ExecutionState.h" #include "klee/Expr.h" #include "klee/Internal/Module/Cell.h" #include "klee/Internal/Module/InstructionInfoTable.h" #include "klee/Internal/Module/KInstruction.h" #include "klee/Internal/Module/KModule.h" #include "klee/OptionCategories.h" #include "klee/Internal/Support/ErrorHandling.h" #include "CacheState.h" #include "llvm/IR/Function.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" #include <cassert> #include <iomanip> #include <map> #include <set> #include <sstream> #include <stdarg.h> using namespace llvm; using namespace klee; namespace { cl::opt<bool> DebugLogStateMerge( "debug-log-state-merge", cl::init(false), cl::desc("Debug information for underlying state merging (default=false)"), cl::cat(MergeCat)); } /***/ StackFrame::StackFrame(KInstIterator _caller, KFunction *_kf) : caller(_caller), kf(_kf), callPathNode(0), minDistToUncoveredOnReturn(0), varargs(0) { locals = new Cell[kf->numRegisters]; } StackFrame::StackFrame(const StackFrame &s) : caller(s.caller), kf(s.kf), callPathNode(s.callPathNode), allocas(s.allocas), minDistToUncoveredOnReturn(s.minDistToUncoveredOnReturn), varargs(s.varargs) { locals = new Cell[s.kf->numRegisters]; for (unsigned i=0; i<s.kf->numRegisters; i++) locals[i] = s.locals[i]; } StackFrame::~StackFrame() { delete[] locals; } /***/ /// Initialized the state count uint64_t ExecutionState::count = 0; uint64_t ExecutionState::spCount = 1; ExecutionState::ExecutionState(KFunction *kf) : pc(kf->instructions), prevPC(pc), weight(1), depth(0), instsSinceCovNew(0), coveredNew(false), forkDisabled(false), ptreeNode(0), steppedInstructions(0), isSpeculative(false), specInstCount(0), pSpecState(0) { tag = count; pTag = -1; count += 2; pushFrame(0, kf); cacheState = new CacheState(*this); } ExecutionState::ExecutionState(const std::vector<ref<Expr> > &assumptions) : constraints(assumptions), ptreeNode(0) {} ExecutionState::~ExecutionState() { for (unsigned int i=0; i<symbolics.size(); i++) { const MemoryObject *mo = symbolics[i].first; assert(mo->refCount > 0); mo->refCount--; if (mo->refCount == 0) delete mo; } for (auto cur_mergehandler: openMergeStack){ cur_mergehandler->removeOpenState(this); } delete cacheState; while (!stack.empty()) popFrame(); } ExecutionState::ExecutionState(const ExecutionState& state): fnAliases(state.fnAliases), pc(state.pc), prevPC(state.prevPC), stack(state.stack), incomingBBIndex(state.incomingBBIndex), addressSpace(state.addressSpace), constraints(state.constraints), queryCost(state.queryCost), weight(state.weight), depth(state.depth), pathOS(state.pathOS), symPathOS(state.symPathOS), instsSinceCovNew(state.instsSinceCovNew), coveredNew(state.coveredNew), forkDisabled(state.forkDisabled), coveredLines(state.coveredLines), ptreeNode(state.ptreeNode), symbolics(state.symbolics), arrayNames(state.arrayNames), openMergeStack(state.openMergeStack), steppedInstructions(state.steppedInstructions), isSpeculative(state.isSpeculative), specInstCount(state.specInstCount), pSpecState(0), cacheState(0) { if (isSpeculative) { tag = spCount; spCount += 2; } else { tag = count; count += 2; } //assert(tag != 169835); pTag = -1; cacheState = new CacheState(*this, *(state.cacheState)); for (unsigned int i=0; i<symbolics.size(); i++) symbolics[i].first->refCount++; for (auto cur_mergehandler: openMergeStack) cur_mergehandler->addOpenState(this); } ExecutionState::ExecutionState(const ExecutionState& state, bool ispec): fnAliases(state.fnAliases), pc(state.pc), prevPC(state.prevPC), stack(state.stack), incomingBBIndex(state.incomingBBIndex), addressSpace(state.addressSpace), constraints(state.constraints), queryCost(state.queryCost), weight(state.weight), depth(state.depth), pathOS(state.pathOS), symPathOS(state.symPathOS), instsSinceCovNew(state.instsSinceCovNew), coveredNew(state.coveredNew), forkDisabled(state.forkDisabled), coveredLines(state.coveredLines), ptreeNode(state.ptreeNode), symbolics(state.symbolics), arrayNames(state.arrayNames), openMergeStack(state.openMergeStack), steppedInstructions(state.steppedInstructions), isSpeculative(ispec), specInstCount(state.specInstCount), pSpecState(0) { if (isSpeculative) { tag = spCount; spCount += 2; } else { tag = count; count += 2; } if (state.isSpeculative) { cacheState = new CacheState(*this, *(state.cacheState)); } else { cacheState = new CacheState(*this); } for (unsigned int i=0; i<symbolics.size(); i++) symbolics[i].first->refCount++; for (auto cur_mergehandler: openMergeStack) cur_mergehandler->addOpenState(this); } ExecutionState *ExecutionState::specBranch(int sew) { ExecutionState *speState = new ExecutionState(*this, true); speState->coveredNew = false; speState->coveredLines.clear(); //klee_message("Fork sp state: %ld -> %ld", this->tag, speState->tag); if (!this->isSpeculative) { speState->specInstCount = sew; } weight *= .5; speState->weight -= weight; return speState; } ExecutionState *ExecutionState::branch() { depth++; ExecutionState *falseState = new ExecutionState(*this); falseState->coveredNew = false; falseState->coveredLines.clear(); //klee_message("Fork normal state: %ld -> %ld", this->tag, falseState->tag); weight *= .5; falseState->weight -= weight; return falseState; } void ExecutionState::pushFrame(KInstIterator caller, KFunction *kf) { stack.push_back(StackFrame(caller,kf)); } void ExecutionState::popFrame() { StackFrame &sf = stack.back(); for (std::vector<const MemoryObject*>::iterator it = sf.allocas.begin(), ie = sf.allocas.end(); it != ie; ++it) addressSpace.unbindObject(*it); stack.pop_back(); } void ExecutionState::addSymbolic(const MemoryObject *mo, const Array *array) { mo->refCount++; symbolics.push_back(std::make_pair(mo, array)); } /// std::string ExecutionState::getFnAlias(std::string fn) { std::map < std::string, std::string >::iterator it = fnAliases.find(fn); if (it != fnAliases.end()) return it->second; else return ""; } void ExecutionState::addFnAlias(std::string old_fn, std::string new_fn) { fnAliases[old_fn] = new_fn; } void ExecutionState::removeFnAlias(std::string fn) { fnAliases.erase(fn); } /**/ llvm::raw_ostream &klee::operator<<(llvm::raw_ostream &os, const MemoryMap &mm) { os << "{"; MemoryMap::iterator it = mm.begin(); MemoryMap::iterator ie = mm.end(); if (it!=ie) { os << "MO" << it->first->id << ":" << it->second; for (++it; it!=ie; ++it) os << ", MO" << it->first->id << ":" << it->second; } os << "}"; return os; } bool ExecutionState::merge(const ExecutionState &b) { if (DebugLogStateMerge) llvm::errs() << "-- attempting merge of A:" << this << " with B:" << &b << "--\n"; if (pc != b.pc) return false; // XXX is it even possible for these to differ? does it matter? probably // implies difference in object states? if (symbolics!=b.symbolics) return false; { std::vector<StackFrame>::const_iterator itA = stack.begin(); std::vector<StackFrame>::const_iterator itB = b.stack.begin(); while (itA!=stack.end() && itB!=b.stack.end()) { // XXX vaargs? if (itA->caller!=itB->caller || itA->kf!=itB->kf) return false; ++itA; ++itB; } if (itA!=stack.end() || itB!=b.stack.end()) return false; } std::set< ref<Expr> > aConstraints(constraints.begin(), constraints.end()); std::set< ref<Expr> > bConstraints(b.constraints.begin(), b.constraints.end()); std::set< ref<Expr> > commonConstraints, aSuffix, bSuffix; std::set_intersection(aConstraints.begin(), aConstraints.end(), bConstraints.begin(), bConstraints.end(), std::inserter(commonConstraints, commonConstraints.begin())); std::set_difference(aConstraints.begin(), aConstraints.end(), commonConstraints.begin(), commonConstraints.end(), std::inserter(aSuffix, aSuffix.end())); std::set_difference(bConstraints.begin(), bConstraints.end(), commonConstraints.begin(), commonConstraints.end(), std::inserter(bSuffix, bSuffix.end())); if (DebugLogStateMerge) { llvm::errs() << "\tconstraint prefix: ["; for (std::set<ref<Expr> >::iterator it = commonConstraints.begin(), ie = commonConstraints.end(); it != ie; ++it) llvm::errs() << *it << ", "; llvm::errs() << "]\n"; llvm::errs() << "\tA suffix: ["; for (std::set<ref<Expr> >::iterator it = aSuffix.begin(), ie = aSuffix.end(); it != ie; ++it) llvm::errs() << *it << ", "; llvm::errs() << "]\n"; llvm::errs() << "\tB suffix: ["; for (std::set<ref<Expr> >::iterator it = bSuffix.begin(), ie = bSuffix.end(); it != ie; ++it) llvm::errs() << *it << ", "; llvm::errs() << "]\n"; } // We cannot merge if addresses would resolve differently in the // states. This means: // // 1. Any objects created since the branch in either object must // have been free'd. // // 2. We cannot have free'd any pre-existing object in one state // and not the other if (DebugLogStateMerge) { llvm::errs() << "\tchecking object states\n"; llvm::errs() << "A: " << addressSpace.objects << "\n"; llvm::errs() << "B: " << b.addressSpace.objects << "\n"; } std::set<const MemoryObject*> mutated; MemoryMap::iterator ai = addressSpace.objects.begin(); MemoryMap::iterator bi = b.addressSpace.objects.begin(); MemoryMap::iterator ae = addressSpace.objects.end(); MemoryMap::iterator be = b.addressSpace.objects.end(); for (; ai!=ae && bi!=be; ++ai, ++bi) { if (ai->first != bi->first) { if (DebugLogStateMerge) { if (ai->first < bi->first) { llvm::errs() << "\t\tB misses binding for: " << ai->first->id << "\n"; } else { llvm::errs() << "\t\tA misses binding for: " << bi->first->id << "\n"; } } return false; } if (ai->second != bi->second) { if (DebugLogStateMerge) llvm::errs() << "\t\tmutated: " << ai->first->id << "\n"; mutated.insert(ai->first); } } if (ai!=ae || bi!=be) { if (DebugLogStateMerge) llvm::errs() << "\t\tmappings differ\n"; return false; } // merge stack ref<Expr> inA = ConstantExpr::alloc(1, Expr::Bool); ref<Expr> inB = ConstantExpr::alloc(1, Expr::Bool); for (std::set< ref<Expr> >::iterator it = aSuffix.begin(), ie = aSuffix.end(); it != ie; ++it) inA = AndExpr::create(inA, *it); for (std::set< ref<Expr> >::iterator it = bSuffix.begin(), ie = bSuffix.end(); it != ie; ++it) inB = AndExpr::create(inB, *it); // XXX should we have a preference as to which predicate to use? // it seems like it can make a difference, even though logically // they must contradict each other and so inA => !inB std::vector<StackFrame>::iterator itA = stack.begin(); std::vector<StackFrame>::const_iterator itB = b.stack.begin(); for (; itA!=stack.end(); ++itA, ++itB) { StackFrame &af = *itA; const StackFrame &bf = *itB; for (unsigned i=0; i<af.kf->numRegisters; i++) { ref<Expr> &av = af.locals[i].value; const ref<Expr> &bv = bf.locals[i].value; if (av.isNull() || bv.isNull()) { // if one is null then by implication (we are at same pc) // we cannot reuse this local, so just ignore } else { av = SelectExpr::create(inA, av, bv); } } } for (std::set<const MemoryObject*>::iterator it = mutated.begin(), ie = mutated.end(); it != ie; ++it) { const MemoryObject *mo = *it; const ObjectState *os = addressSpace.findObject(mo); const ObjectState *otherOS = b.addressSpace.findObject(mo); assert(os && !os->readOnly && "objects mutated but not writable in merging state"); assert(otherOS); ObjectState *wos = addressSpace.getWriteable(mo, os); for (unsigned i=0; i<mo->size; i++) { ref<Expr> av = wos->read8(i); ref<Expr> bv = otherOS->read8(i); wos->write(i, SelectExpr::create(inA, av, bv)); } } constraints = ConstraintManager(); for (std::set< ref<Expr> >::iterator it = commonConstraints.begin(), ie = commonConstraints.end(); it != ie; ++it) constraints.addConstraint(*it); constraints.addConstraint(OrExpr::create(inA, inB)); return true; } void ExecutionState::addSpeState(ExecutionState *_state) { //klee_message("Add a speculative state: %d -> %d", this->tag, _state->tag); //assert(false); specStates.push(_state); } ExecutionState &ExecutionState::selectSpState() { assert(specStates.size() != 0); return *specStates.front(); } void ExecutionState::removeHeadState(bool isCacheEnable) { ExecutionState *es = specStates.front(); specStates.pop(); if (isCacheEnable) { finishedSpecStates.push_back(es); if (specStates.size() == 0) { this->cacheState->mergeSpecCacheState(); } } else { delete (es); } } void ExecutionState::dumpStack(llvm::raw_ostream &out) const { unsigned idx = 0; const KInstruction *target = prevPC; out << "=== STACK DUMP, tag: " <<this->tag<<"===\n"; for (ExecutionState::stack_ty::const_reverse_iterator it = stack.rbegin(), ie = stack.rend(); it != ie; ++it) { const StackFrame &sf = *it; Function *f = sf.kf->function; const InstructionInfo &ii = *target->info; out << "\t#" << idx++; std::stringstream AssStream; AssStream << std::setw(8) << std::setfill('0') << ii.assemblyLine; out << AssStream.str(); out << " in " << f->getName().str() << " ("; // Yawn, we could go up and print varargs if we wanted to. unsigned index = 0; for (Function::arg_iterator ai = f->arg_begin(), ae = f->arg_end(); ai != ae; ++ai) { if (ai!=f->arg_begin()) out << ", "; out << ai->getName().str(); // XXX should go through function ref<Expr> value = sf.locals[sf.kf->getArgRegister(index++)].value; if (value.get() && isa<ConstantExpr>(value)) out << "=" << value; } out << ")"; if (ii.file != "") out << " at " << ii.file << ":" << ii.line; out << "\n"; target = sf.caller; } out << "=== STACK DUMP END ===\n"; }
[ "guanhua@comp.nus.edu.sg" ]
guanhua@comp.nus.edu.sg
1837d9fdf7c6667464cc5ef162511a108903d891
55ea5937b72314d8471f97152da338a721e8ebd6
/shelf.cpp
be19b5ca422d8c25f0d72a76bd8d2d742f37dda5
[]
no_license
METrimble/Lab4-Demo
ae674e756b5e0d8a83b6d688150bd0bf1f1c2874
db2417d6ea2bf922eb93280b7a90b88362ffe841
refs/heads/main
2023-02-22T06:52:30.928205
2021-01-26T23:42:14
2021-01-26T23:42:14
333,247,161
0
0
null
null
null
null
UTF-8
C++
false
false
1,423
cpp
#include "shelf.h" Shelf::Shelf(){ this->num_books = 0; this->books = NULL; } void Shelf::create_shelf(){ cout << "How many book are on the shelf? "; cin >> this->num_books; this->books = new Book [this->num_books]; for(int i = 0; i < this->num_books; i++){ cout << "Book " << i << ":" << endl; this->books[i].create_books(); cout << "-------------------------" << endl; } } //getters and setters int Shelf::get_num_books(){ return this->num_books; } void Shelf::set_num_books(int num_books){ this->num_books = num_books; } //big three Shelf::~Shelf(){ cout << "Shelf destructor running" << endl; delete [] books; books = NULL; } Shelf::Shelf(const Shelf& old_shelf){ cout << "Shelf CC running" << endl; this->num_books = old_shelf.num_books; this->books = new Book [this->num_books]; for(int i = 0; i < this->num_books; i++){ this->books[i] = old_shelf.books[i]; } } Shelf& Shelf::operator= (const Shelf& old_shelf){ cout << "Shelf assignment operator running" << endl; if(this != &old_shelf){ this->num_books = old_shelf.num_books; if(this->books != NULL){ delete [] this->books; } this->books = new Book [this->num_books]; for(int i = 0; i < this->num_books; i++){ this->books[i] = old_shelf.books[i]; } } return *this; }
[ "noreply@github.com" ]
noreply@github.com
4d8fe2633b1d4b9cd5a60a7b454a9af401ff1c5a
66fd6ae9f53478134ec368467e485e7214a6e66c
/benliu.cpp
3ff94b76d20702d74158584e7d72804eae862442
[]
no_license
soldierbenliu/hello-world
c34adaa2bdf6e3864b5b13da339fe53ae8936dd1
d59b3a53d90a614eabfcd2d810dd164f97d08a92
refs/heads/master
2020-05-18T04:24:51.785834
2019-04-30T02:41:50
2019-04-30T02:41:50
184,172,657
0
0
null
2019-04-30T01:52:26
2019-04-30T01:52:26
null
UTF-8
C++
false
false
62
cpp
renbenliu renbenliu add string by Benliu add string by GM
[ "18310179637@163.com" ]
18310179637@163.com
af7b3e35525ef3e52070db9f1b82688ae9ee7c2c
bcf3af8ffd1afcd076dc4012a109bb52fb3c57d9
/URI/PUM/main.cpp
35ba1bc38ab7161c3f8f9a4461198f0361e820d7
[]
no_license
AmirHaytham/Online-Judges-Solutions
d9b938f8672addc93dca6624a7a77c43e489f9e4
11d66a4ca01e6a50330e81c7b618c48712474992
refs/heads/master
2021-05-24T09:14:27.693897
2020-08-25T18:34:07
2020-08-25T18:34:07
253,489,374
0
0
null
null
null
null
UTF-8
C++
false
false
359
cpp
#include <bits/stdc++.h> #include <iomanip> using namespace std; int main() { int n; int k = 1; cin >> n; for (int j = 1 ; j <= n ; ++j) { for(int i = 1 ; i <= 3 ; ++i) { cout << k <<" "; k+=1; } cout << "PUM\n"; k+=1; } return 0; }
[ "amir.haytham.salama@gmail.com" ]
amir.haytham.salama@gmail.com
68742743408668e80bd1a8535f1508a317268118
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir7941/dir22441/dir22442/dir22443/dir22444/dir22869/dir23624/file23746.cpp
dfd0c90e91ca77874539afc8fb4ba5832e7f58b4
[]
no_license
tgeng/HugeProject
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
4488d3b765e8827636ce5e878baacdf388710ef2
refs/heads/master
2022-08-21T16:58:54.161627
2020-05-28T01:54:03
2020-05-28T01:54:03
267,468,475
0
0
null
null
null
null
UTF-8
C++
false
false
115
cpp
#ifndef file23746 #error "macro file23746 must be defined" #endif static const char* file23746String = "file23746";
[ "tgeng@google.com" ]
tgeng@google.com
f27dd701d03a3754a38e86ced32bf5ce7803cfd8
4e84888d529286a97813cdc0c580c8e7213831c3
/objeto-ply.cpp
e174acad8c0339d59e7527dd84024886792fbcaa
[]
no_license
Roglerto/SolarSystem
39deb02225b9c7ff16da9e2a5b197b05b8c5f504
1523fad389e0f55462aed38873b33ef77b31ab80
refs/heads/master
2021-01-10T15:29:18.574578
2016-04-08T22:34:50
2016-04-08T22:34:50
55,796,563
0
0
null
null
null
null
UTF-8
C++
false
false
9,634
cpp
#include <ctype.h> #include <cmath> #include <iostream> #include <vector> #include <GL/gl.h> #include <GL/glut.h> #include "jpg_imagen.hpp" #include "materiales.hpp" #include "objetos-4.hpp" #include "objeto-ply.hpp" using namespace std; //********************************************************************** // // Clase TexObjetoPly // ------------------ // clase para la textura del objeto ply // //********************************************************************** class TexObjetoPly : public Textura { public: TexObjetoPly( const std::string & p_nom_fich_jpg, const float p_coefs_s[4], const float p_coefs_t[4] ) ; } ; //---------------------------------------------------------------------- TexObjetoPly::TexObjetoPly( const std::string & p_nom_fich_jpg, const float p_coefs_s[4], const float p_coefs_t[4] ) : Textura(p_nom_fich_jpg) // 'marmol.jpg' : http://www.shareaec.com/images/large/13621.jpg { // establecer modo de generación de coordenadas de textura // (coordenadas de objeto) assert( p_coefs_s != NULL && p_coefs_t != NULL ) ; modo_gen_ct = mgct_coords_objeto ; for( unsigned i = 0 ; i < 4 ; i++ ) { coefs_s[i] = p_coefs_s[i] ; coefs_t[i] = p_coefs_t[i] ; } } //********************************************************************** // // Clase MatObjetoPly // ------------------ // clase para el material del objeto ply // //********************************************************************** const float refl_amb_ini = 0.1 , refl_dif_ini = 0.7 , refl_esp_ini = 1.0 , exp_brillo_ini = 80.0 ; //---------------------------------------------------------------------- class MatObjetoPly: public Material { public: MatObjetoPly( const std::string & p_nom_fich_jpg, const float coefs_s[4], const float coefs_t[4] ) ; } ; //---------------------------------------------------------------------- MatObjetoPly::MatObjetoPly( const std::string & p_nom_fich_jpg, const float coefs_s[4], const float coefs_t[4] ) { coloresCero() ; // color = vectorRGB(1.0,1.0,1.0); iluminacion = true ; tex = new TexObjetoPly(p_nom_fich_jpg,coefs_s,coefs_t) ; tra.ambiente = vectorRGB( 0.05,0.05,0.05 ) ; tra.difusa = vectorRGB( 0.10,0.10,0.10 ) ; tra.especular = vectorRGB( 0.0,0.0,0.0 ) ; tra.exp_brillo = 50 ; } //********************************************************************** // clase ObjetoPLY //---------------------------------------------------------------------- ObjetoPLY::ObjetoPLY( const std::string & p_nom_fich_ply , const std::string & p_nom_fich_jpg ) : _ply_triangles_object3D( p_nom_fich_ply ) { if(!Vertices_normals_computed) compute_vertices_normals(); for(int i=0;i<Vertices.size();i++){ Nuevos_Vertices.push_back(Vertices[i].x); Nuevos_Vertices.push_back(Vertices[i].y); Nuevos_Vertices.push_back(Vertices[i].z); } for( int w=0;w<Faces_vertices.size();w++){ Nuevos_Faces_vertices.push_back(Faces_vertices[w].x); Nuevos_Faces_vertices.push_back(Faces_vertices[w].y); Nuevos_Faces_vertices.push_back(Faces_vertices[w].z); } for(int ko=0;ko<Vertices_normals.size();ko++){ Nuevos_Vertices_normals.push_back(Vertices_normals[ko].x); Nuevos_Vertices_normals.push_back(Vertices_normals[ko].y); Nuevos_Vertices_normals.push_back(Vertices_normals[ko].z); } for( int lol=0;lol<Vertices_tex_coords.size();lol++){ Nuevos_Vertices_tex_coords.push_back(Vertices_tex_coords[lol].x); Nuevos_Vertices_tex_coords.push_back(Vertices_tex_coords[lol].y); } rotacionvar=0; orbitavar=90; eventorotacion=false; camara=false; // calcular parámetros de la caja englobante _vertex3f centro, pmin, pmax ; float max_dim = 10.0f ; compute_bounding_box( centro, pmin, pmax, max_dim ) ; cout<< "máxima dimensión del objeto ply == " << max_dim << endl ; // situar el objeto en el centro y con ancho unidad const float fesc = 1.0/max_dim ; for( unsigned long i = 0 ; i < Vertices.size() ; i++ ) { Vertices[i] -= centro ; Vertices[i] *= fesc ; } // ajustar los parámetros de la caja englobante pmin -= centro ; pmax -= centro ; pmin *= fesc ; pmax *= fesc ; // calcular coeficientes de generacion automática de texturas const float fsx = 1.0f/(pmax.x-pmin.x) , fty = 1.0f/(pmax.y-pmin.y) ; const float coefs_s[4] = {fsx,0.0,0.0,-fsx*pmin.x} , coefs_t[4] = {0.0,fty,0.0,-fty*pmin.y} ; // crear material material = new MatObjetoPly(p_nom_fich_jpg,coefs_s,coefs_t) ; // incializar reflectividades del material refl_amb = refl_amb_ini ; refl_dif = refl_dif_ini ; refl_esp = refl_esp_ini ; exp_brillo = exp_brillo_ini ; actualizar_refls() ; } //---------------------------------------------------------------------- void ObjetoPLY::compute_bounding_box( _vertex3f & centro, _vertex3f & pmin, _vertex3f & pmax, float max_dim ) { assert( Vertices.size() > 0.0 ) ; // calcular centro y máxima dimension de la caja englobante pmin = Vertices[0] ; pmax = Vertices[0] ; for( unsigned long i = 1 ; i < Vertices.size() ; i++ ) { const _vertex3f & v = Vertices[i] ; if ( v.x < pmin.x ) pmin.x = v.x ; if ( v.y < pmin.y ) pmin.y = v.y ; if ( v.z < pmin.z ) pmin.z = v.z ; if ( pmax.x < v.x ) pmax.x = v.x ; if ( pmax.y < v.y ) pmax.y = v.y ; if ( pmax.z < v.z ) pmax.z = v.z ; } assert( 0.0 < pmax.x - pmin.x || 0.0 < pmax.y - pmin.y || 0.0 < pmax.z - pmin.z ); centro = _vertex3f( 0.5*(pmin.x+pmax.x), 0.5*(pmin.y+pmax.y), 0.5*(pmin.z+pmax.z) ); max_dim = pmax.x - pmin.x ; if ( max_dim < pmax.y-pmin.y ) max_dim = pmax.y - pmin.y ; if ( max_dim < pmax.z-pmin.z ) max_dim = pmax.z - pmin.z ; } //---------------------------------------------------------------------- void ObjetoPLY::actualizar_refls() { assert( material != NULL ); material->del.ambiente = vectorRGB( refl_amb,refl_amb,refl_amb ); material->del.difusa = vectorRGB( refl_dif,refl_dif,refl_dif ) ; material->del.especular = vectorRGB( refl_esp,refl_esp,refl_esp ) ; material->del.exp_brillo = exp_brillo ; } //---------------------------------------------------------------------- const float incr = 0.01f ; //---------------------------------------------------------------------- inline void incre( float & v ) { v += incr ; if ( v > 1.0 ) v = 1.0 ; } //---------------------------------------------------------------------- inline void decre( float & v ) { v -= incr ; if ( v < 0.0 ) v = 0.0 ; } //---------------------------------------------------------------------- bool ObjetoPLY::gestionarEventoTeclaEspecial( int key ) { using namespace std ; bool actualizar = true ; assert( material != NULL ) ; switch( key ) { case GLUT_KEY_UP : incre( refl_amb ) ; break ; case GLUT_KEY_DOWN : decre( refl_amb ) ; break ; case GLUT_KEY_RIGHT : incre( refl_dif ) ; break ; case GLUT_KEY_LEFT : decre( refl_dif ) ; break ; case GLUT_KEY_PAGE_UP : incre( refl_esp ) ; break ; case GLUT_KEY_PAGE_DOWN : decre( refl_esp ) ; break ; case GLUT_KEY_INSERT : exp_brillo *= 1.01 ; if ( exp_brillo > 128.0 ) exp_brillo = 128.0 ; break ; case GLUT_KEY_END : exp_brillo /= 1.01; break ; case GLUT_KEY_HOME : refl_amb = refl_amb_ini ; refl_dif = refl_dif_ini ; refl_esp = refl_esp_ini ; exp_brillo = exp_brillo_ini ; break ; default: actualizar = false ; cout << "tecla especial no usada en este modo" << endl << flush ; break ; } if ( actualizar ) { actualizar_refls() ; cout << "material del objeto ply: amb == " << refl_amb << ", dif == " << refl_dif << ", esp == " << refl_esp << ", exp == " << exp_brillo << endl << flush ; } return actualizar ; } void ObjetoPLY::draw_solid_material_gouroud() { int Vertex_1,Vertex_2,Vertex_3,j=0; glShadeModel(GL_SMOOTH); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); material->activar(); glEnableClientState( GL_VERTEX_ARRAY ); glVertexPointer(3, GL_FLOAT, 0, &Vertices[0] ); glEnableClientState( GL_INDEX_ARRAY ); glIndexPointer( GL_UNSIGNED_INT, 0,&Faces_vertices[0] ); glEnableClientState( GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT,0,&Vertices_normals[0]); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, &Vertices_tex_coords[0]); glInitNames(); glPushMatrix(); if(camara) glScaled(0.1,0.1,0.1); else{ glScaled(0.01,0.01,0.01); glTranslatef( -500, -30, 0); } //glRotatef(90,1,0,0); glRotatef(orbitavar,0,1,0); glTranslatef( -40, -30, 0); glRotatef(-45,0,1,0); if(eventorotacion){ glRotatef(rotacionvar,0,1,0); } glPushName(69); glDrawElements( GL_TRIANGLES, Faces_vertices.size()*3, GL_UNSIGNED_INT, &Faces_vertices[0] ); glPopName(); glPopMatrix(); } void ObjetoPLY::rotacion(){ rotacionvar=rotacionvar+1; } void ObjetoPLY::orbita(){ orbitavar=orbitavar+1; } void ObjetoPLY::activarrotacion(){ eventorotacion=true; } void ObjetoPLY::desactivarrotacion(){ eventorotacion=false; } void ObjetoPLY::ampliar_cam(){ camara=true; } void ObjetoPLY::disminuir_cam(){ camara=false; }
[ "roglerto@gmail.com" ]
roglerto@gmail.com
1e136a879b7580eaa23ccf7dd3abc14084bb7af2
44ea665a0cb3ec7359cf7e776576a8c7323f1bd5
/library/include/OgreProceduralShapeGenerators.h
76eddf046331d9fbf95570796948066484f07c70
[]
no_license
JulianVolodia/ogre-procedural
b8e82763e904309c47be78b1e39c265bab17d09d
e87de9709752f0c23f67510b3404a0168e619eda
refs/heads/master
2021-05-26T15:56:03.508230
2011-07-28T20:44:16
2011-07-28T20:44:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,413
h
/* ----------------------------------------------------------------------------- This source file is part of ogre-procedural For the latest info, see http://code.google.com/p/ogre-procedural/ Copyright (c) 2010 Michael Broutin 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 PROCEDURAL_SHAPE_GENERATORS_INCLUDED #define PROCEDURAL_SHAPE_GENERATORS_INCLUDED #include "OgreProceduralShape.h" namespace OgreProcedural { //----------------------------------------------------------------------- /// Base class for Shape generators template<class T> class BaseSpline2 { protected: /// The number of segments between 2 control points unsigned int mNumSeg; /// Whether the shape will be closed or not bool mClosed; /// The "out" side of the shape Side mOutSide; public: /// Default constructor BaseSpline2() : mNumSeg(4), mClosed(false), mOutSide(SIDE_RIGHT) {} /// Sets the out side of the shape T& setOutSide(Side outSide) { mOutSide = outSide; return (T&)*this; } /// Gets the out side of the shape Side getOutSide() const { return mOutSide; } /// Sets the number of segments between 2 control points T& setNumSeg(int numSeg) { assert(numSeg>=1); mNumSeg = numSeg; return (T&)*this; } /// Closes the spline T& close() { mClosed = true; return (T&)*this; } }; //----------------------------------------------------------------------- /** * Produces a shape from Cubic Hermite control points */ class _ProceduralExport CubicHermiteSpline2 : public BaseSpline2<CubicHermiteSpline2> { struct ControlPoint { Ogre::Vector2 position; Ogre::Vector2 tangentBefore; Ogre::Vector2 tangentAfter; ControlPoint(Ogre::Vector2 p, Ogre::Vector2 before, Ogre::Vector2 after) : position(p), tangentBefore(before), tangentAfter(after) {} }; std::vector<ControlPoint> mPoints; public: /// Adds a control point void addPoint(Ogre::Vector2 p, Ogre::Vector2 before, Ogre::Vector2 after) { mPoints.push_back(ControlPoint(p, before, after)); } /// Safely gets a control point const ControlPoint& safeGetPoint(int i) const { if (mClosed) return mPoints[Utils::modulo(i,mPoints.size())]; return mPoints[Utils::cap(i,0,mPoints.size()-1)]; } /** * Builds a shape from control points */ Shape realizeShape(); }; //----------------------------------------------------------------------- /** * Builds a shape from a Catmull-Rom Spline. * A catmull-rom smoothly interpolates position between control points */ class _ProceduralExport CatmullRomSpline2 : public BaseSpline2<CatmullRomSpline2> { std::vector<Ogre::Vector2> mPoints; public: /// Adds a control point CatmullRomSpline2& addPoint(const Ogre::Vector2& pt) { mPoints.push_back(pt); return *this; } /// Adds a control point CatmullRomSpline2& addPoint(Ogre::Real x, Ogre::Real y) { mPoints.push_back(Ogre::Vector2(x,y)); return *this; } /// Safely gets a control point const Ogre::Vector2& safeGetPoint(int i) const { if (mClosed) return mPoints[Utils::modulo(i,mPoints.size())]; return mPoints[Utils::cap(i,0,mPoints.size()-1)]; } /** * Build a shape from bezier control points */ Shape realizeShape(); }; //----------------------------------------------------------------------- /** * Builds a shape from a Kochanek Bartels spline. * * More details here : http://en.wikipedia.org/wiki/Kochanek%E2%80%93Bartels_spline */ class _ProceduralExport KochanekBartelsSpline2 : public BaseSpline2<KochanekBartelsSpline2> { struct ControlPoint { Ogre::Vector2 position; Ogre::Real tension; Ogre::Real bias; Ogre::Real continuity; ControlPoint(Ogre::Vector2 p, Ogre::Real t, Ogre::Real b, Ogre::Real c) : position(p), tension(t), bias(b), continuity(c) {} ControlPoint(Ogre::Vector2 p) : position(p), tension(0.), bias(0.), continuity(0.) {} }; std::vector<ControlPoint> mPoints; public: /// Adds a control point KochanekBartelsSpline2& addPoint(Ogre::Real x, Ogre::Real y) { mPoints.push_back(ControlPoint(Ogre::Vector2(x,y))); return *this; } /// Adds a control point KochanekBartelsSpline2& addPoint(Ogre::Vector2 p) { mPoints.push_back(ControlPoint(p)); return *this; } /// Safely gets a control point const ControlPoint& safeGetPoint(int i) const { if (mClosed) return mPoints[Utils::modulo(i,mPoints.size())]; return mPoints[Utils::cap(i,0,mPoints.size()-1)]; } /** * Adds a control point to the spline * @arg p Point position * @arg t Tension +1 = Tight -1 = Round * @arg b Bias +1 = Post-shoot -1 = Pre-shoot * @arg c Continuity +1 = Inverted Corners -1 = Box Corners */ KochanekBartelsSpline2& addPoint(Ogre::Vector2 p, Ogre::Real t, Ogre::Real b, Ogre::Real c) { mPoints.push_back(ControlPoint(p,t,b,c)); return *this; } /** * Builds a shape from control points */ Shape realizeShape(); }; //----------------------------------------------------------------------- /** * Builds a rectangular shape */ class _ProceduralExport RectangleShape { Ogre::Real mWidth,mHeight; public: /// Default constructor RectangleShape() : mWidth(1.0), mHeight(1.0) {} /// Sets width RectangleShape& setWidth(Ogre::Real width) { mWidth = width; return *this; } /// Sets height RectangleShape& setHeight(Ogre::Real height) { mHeight = height; return *this; } /// Builds the shape Shape realizeShape() { Shape s; s.addPoint(-.5f*mWidth,-.5f*mHeight) .addPoint(.5f*mWidth,-.5f*mHeight) .addPoint(.5f*mWidth,.5f*mHeight) .addPoint(-.5f*mWidth,.5f*mHeight) .close(); return s; } }; //----------------------------------------------------------------------- /** * Builds a circular shape */ class _ProceduralExport CircleShape { Ogre::Real mRadius; unsigned int mNumSeg; public: /// Default constructor CircleShape() : mRadius(1.0), mNumSeg(8) {} /// Sets radius CircleShape& setRadius(Ogre::Real radius) { mRadius = radius; return *this; } /// Sets number of segments CircleShape& setNumSeg(unsigned int numSeg) { mNumSeg = numSeg; return *this; } /// Builds the shape Shape realizeShape() { Shape s; Ogre::Real deltaAngle = Ogre::Math::TWO_PI/(Ogre::Real)mNumSeg; for (unsigned int i = 0; i < mNumSeg; ++i) { s.addPoint(mRadius*cosf(i*deltaAngle), mRadius*sinf(i*deltaAngle)); } s.close(); return s; } }; } #endif
[ "sh@lutzhaase.com" ]
sh@lutzhaase.com
9434ca4a3b6d04ba652347d0a3d229e2264aaf41
56ac24da9214311ac63fd3629c685fe5ce8ab8a7
/matvec/matvec/pipeline_compute_outermost/syn/systemc/tiled_matvec_A_memcore.h
f649be09a4209e29089bfbd76d8022c0f426500c
[]
no_license
leakim-tsp/stageCircuit2
c9033f28e3eeab428441c0c0793e3c47a8fe9321
1ab16ba184f34b7420b347132cacf31c13b87216
refs/heads/master
2022-10-08T13:50:34.279773
2020-06-08T13:57:18
2020-06-08T13:57:18
268,814,118
0
0
null
null
null
null
UTF-8
C++
false
false
3,161
h
// ============================================================== // Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2019.2 (64-bit) // Copyright 1986-2019 Xilinx, Inc. All Rights Reserved. // ============================================================== #ifndef __tiled_matvec_A_memcore_H__ #define __tiled_matvec_A_memcore_H__ #include <systemc> using namespace sc_core; using namespace sc_dt; #include <iostream> #include <fstream> struct tiled_matvec_A_memcore_ram : public sc_core::sc_module { static const unsigned DataWidth = 32; static const unsigned AddressRange = 4; static const unsigned AddressWidth = 2; //latency = 1 //input_reg = 1 //output_reg = 0 sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in <sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in<sc_logic> we0; sc_core::sc_in<sc_lv<DataWidth> > d0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in <sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; sc_lv<DataWidth> ram[AddressRange]; SC_CTOR(tiled_matvec_A_memcore_ram) { for (unsigned i = 0; i < 4; i = i + 1) { ram[i] = 0; } SC_METHOD(prc_write_0); sensitive<<clk.pos(); SC_METHOD(prc_write_1); sensitive<<clk.pos(); } void prc_write_0() { if (ce0.read() == sc_dt::Log_1) { if (we0.read() == sc_dt::Log_1) { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) { ram[address0.read().to_uint()] = d0.read(); q0 = d0.read(); } else q0 = sc_lv<DataWidth>(); } else { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) q0 = ram[address0.read().to_uint()]; else q0 = sc_lv<DataWidth>(); } } } void prc_write_1() { if (ce1.read() == sc_dt::Log_1) { if(address1.read().is_01() && address1.read().to_uint()<AddressRange) q1 = ram[address1.read().to_uint()]; else q1 = sc_lv<DataWidth>(); } } }; //endmodule SC_MODULE(tiled_matvec_A_memcore) { static const unsigned DataWidth = 32; static const unsigned AddressRange = 4; static const unsigned AddressWidth = 2; sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in<sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in<sc_logic> we0; sc_core::sc_in<sc_lv<DataWidth> > d0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in<sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; tiled_matvec_A_memcore_ram* meminst; SC_CTOR(tiled_matvec_A_memcore) { meminst = new tiled_matvec_A_memcore_ram("tiled_matvec_A_memcore_ram"); meminst->address0(address0); meminst->ce0(ce0); meminst->q0(q0); meminst->we0(we0); meminst->d0(d0); meminst->address1(address1); meminst->ce1(ce1); meminst->q1(q1); meminst->reset(reset); meminst->clk(clk); } ~tiled_matvec_A_memcore() { delete meminst; } };//endmodule #endif
[ "mickael.boichot@telecom-sudparis.eu" ]
mickael.boichot@telecom-sudparis.eu
878581ea005e443ab610b3fdb17780d7d73dad3f
311dbd85c6deca7c4d0bbbeabf47f6f7bf2e10ce
/pr11-20 - derived classes.cpp
5bf77a9324e05553ce0c884973cbd48a1b0aa59c
[]
no_license
upstate-csci-238-master/chap11-oop
29969eb927b3e6e07f87cac4b74cab9dced49859
f732a30b0ff98cdc73c9303bf9a7c6b18a7eca9f
refs/heads/master
2022-04-09T12:39:31.334878
2020-03-20T18:32:01
2020-03-20T18:32:01
248,600,313
0
0
null
null
null
null
UTF-8
C++
false
false
1,090
cpp
//This program demonstrates the use of //objects of derived classes. #include "inheritance1.h" #include <iostream> #include <memory> using namespace std; // These arrays of string are used to print // values of enumerated types const string dName[] = { "Archeology", "Biology", "Computer Science" }; const string cName[] = { "Freshman", "Sophomore", "Junior", "Senior" }; int main() { // Create Faculty and Student objects shared_ptr<Faculty> prof = make_shared<Faculty>("Indiana Jones", Discipline::ARCHEOLOGY); shared_ptr<Student> st = make_shared<Student>("Sean Bolster", Discipline::ARCHEOLOGY, prof); cout << "Professor " << prof->getName() << " teaches " << dName[static_cast<int>(prof->getDepartment())] << "." << endl; //Get student's advisor shared_ptr<Person> pAdvisor = st->getAdvisor(); cout << st->getName() << "\'s advisor is " << pAdvisor->getName() << "."; cout << endl; return 0; }
[ "noreply@github.com" ]
noreply@github.com
9babcfe36a8e50b1745d4f239e7a359a03d743c0
5390eac0ac54d2c3c1c664ae525881fa988e2cf9
/include/Pothos/serialization/impl/mpl/aux_/preprocessed/plain/and.hpp
c5e94007bdbefef59d00dd3bc3a867bdb1b90459
[ "BSL-1.0" ]
permissive
pothosware/pothos-serialization
2935b8ab1fe51299a6beba2a3e11611928186849
c59130f916a3e5b833a32ba415063f9cb306a8dd
refs/heads/master
2021-08-16T15:22:12.642058
2015-12-10T03:32:04
2015-12-10T03:32:04
19,961,886
1
0
null
null
null
null
UTF-8
C++
false
false
1,160
hpp
// Copyright Aleksey Gurtovoy 2000-2004 // // 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) // // Preprocessed version of "boost/mpl/and.hpp" header // -- DO NOT modify by hand! namespace Pothos { namespace mpl { namespace aux { template< bool C_, typename T1, typename T2, typename T3, typename T4 > struct and_impl : false_ { }; template< typename T1, typename T2, typename T3, typename T4 > struct and_impl< true,T1,T2,T3,T4 > : and_impl< POTHOS_MPL_AUX_NESTED_TYPE_WKND(T1)::value , T2, T3, T4 , true_ > { }; template<> struct and_impl< true , true_, true_, true_, true_ > : true_ { }; } // namespace aux template< typename POTHOS_MPL_AUX_NA_PARAM(T1) , typename POTHOS_MPL_AUX_NA_PARAM(T2) , typename T3 = true_, typename T4 = true_, typename T5 = true_ > struct and_ : aux::and_impl< POTHOS_MPL_AUX_NESTED_TYPE_WKND(T1)::value , T2, T3, T4, T5 > { }; POTHOS_MPL_AUX_NA_SPEC2( 2 , 5 , and_ ) }}
[ "josh@joshknows.com" ]
josh@joshknows.com
4708c3126da0dbc73f158150893dbcbf27561c7e
45c84e64a486a3c48bd41a78e28252acbc0cc1b0
/src/third_party/blink/renderer/modules/xr/xr_reference_space.cc
a9a045fb0436a9e7e2c5bc8bddb9f633268042b9
[ "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "MIT", "Apache-2.0" ]
permissive
stanleywxc/chromium-noupdator
47f9cccc6256b1e5b0cb22c598b7a86f5453eb42
637f32e9bf9079f31430c9aa9c64a75247993a71
refs/heads/master
2022-12-03T22:00:20.940455
2019-10-04T16:29:31
2019-10-04T16:29:31
212,851,250
1
2
MIT
2022-11-17T09:51:04
2019-10-04T15:49:33
null
UTF-8
C++
false
false
8,556
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/renderer/modules/xr/xr_reference_space.h" #include "device/vr/public/mojom/vr_service.mojom-blink.h" #include "third_party/blink/renderer/modules/xr/xr_pose.h" #include "third_party/blink/renderer/modules/xr/xr_reference_space_event.h" #include "third_party/blink/renderer/modules/xr/xr_rigid_transform.h" #include "third_party/blink/renderer/modules/xr/xr_session.h" #include "third_party/blink/renderer/modules/xr/xr_utils.h" namespace blink { // Rough estimate of avg human eye height in meters. const double kDefaultEmulationHeightMeters = 1.6; XRReferenceSpace::Type XRReferenceSpace::StringToReferenceSpaceType( const String& reference_space_type) { if (reference_space_type == "viewer") { return XRReferenceSpace::Type::kTypeViewer; } else if (reference_space_type == "local") { return XRReferenceSpace::Type::kTypeLocal; } else if (reference_space_type == "local-floor") { return XRReferenceSpace::Type::kTypeLocalFloor; } else if (reference_space_type == "bounded-floor") { return XRReferenceSpace::Type::kTypeBoundedFloor; } else if (reference_space_type == "unbounded") { return XRReferenceSpace::Type::kTypeUnbounded; } NOTREACHED(); return Type::kTypeViewer; } // origin offset starts as identity transform XRReferenceSpace::XRReferenceSpace(XRSession* session, Type type) : XRReferenceSpace(session, MakeGarbageCollected<XRRigidTransform>(nullptr, nullptr), type) {} XRReferenceSpace::XRReferenceSpace(XRSession* session, XRRigidTransform* origin_offset, Type type) : XRSpace(session), origin_offset_(origin_offset), type_(type) {} XRReferenceSpace::~XRReferenceSpace() = default; XRPose* XRReferenceSpace::getPose( XRSpace* other_space, const TransformationMatrix* mojo_from_viewer) { if (type_ == Type::kTypeViewer) { std::unique_ptr<TransformationMatrix> offsetspace_from_viewer = other_space->SpaceFromViewerWithDefaultAndOffset(mojo_from_viewer); if (!offsetspace_from_viewer) { return nullptr; } return MakeGarbageCollected<XRPose>(*offsetspace_from_viewer, session()->EmulatedPosition()); } else { return XRSpace::getPose(other_space, mojo_from_viewer); } } void XRReferenceSpace::SetFloorFromMojo() { const device::mojom::blink::VRDisplayInfoPtr& display_info = session()->GetVRDisplayInfo(); if (display_info && display_info->stage_parameters) { // Use the transform given by xrDisplayInfo's stage_parameters if available. floor_from_mojo_ = std::make_unique<TransformationMatrix>( display_info->stage_parameters->standing_transform.matrix()); } else { // Otherwise, create a transform based on the default emulated height. floor_from_mojo_ = std::make_unique<TransformationMatrix>(); floor_from_mojo_->Translate3d(0, kDefaultEmulationHeightMeters, 0); } display_info_id_ = session()->DisplayInfoPtrId(); } // Returns a default viewer pose if no actual viewer pose is available. Only // applicable to viewer reference spaces. std::unique_ptr<TransformationMatrix> XRReferenceSpace::DefaultViewerPose() { // A viewer reference space always returns an identity matrix. return type_ == Type::kTypeViewer ? std::make_unique<TransformationMatrix>() : nullptr; } std::unique_ptr<TransformationMatrix> XRReferenceSpace::SpaceFromMojo( const TransformationMatrix& mojo_from_viewer) { switch (type_) { case Type::kTypeLocal: // Currently 'local' space is equivalent to mojo space. return std::make_unique<TransformationMatrix>(); case Type::kTypeLocalFloor: // Currently all base poses are 'local' space, so use of 'local-floor' // reference spaces requires adjustment. Ideally the service will // eventually provide poses in the requested space directly, avoiding the // need to do additional transformation here. // Check first to see if the xrDisplayInfo has updated since the last // call. If so, update the floor-level transform. if (display_info_id_ != session()->DisplayInfoPtrId()) SetFloorFromMojo(); return std::make_unique<TransformationMatrix>(*floor_from_mojo_); case Type::kTypeViewer: // Return viewer_from_mojo which is the inverse of mojo_from_viewer. return std::make_unique<TransformationMatrix>(mojo_from_viewer.Inverse()); case Type::kTypeUnbounded: // For now we assume that poses returned by systems that support unbounded // reference spaces are already in the correct space. Return an identity. return std::make_unique<TransformationMatrix>(); case Type::kTypeBoundedFloor: NOTREACHED() << "kTypeBoundedFloor should be handled by subclass"; break; } return nullptr; } // Returns the refspace-from-viewerspace transform, corresponding to the pose of // the viewer in this space. This takes the mojo_from_viewer transform (viewer // pose in mojo space) as input, and left-multiplies space_from_mojo onto that. std::unique_ptr<TransformationMatrix> XRReferenceSpace::SpaceFromViewer( const TransformationMatrix& mojo_from_viewer) { if (type_ == Type::kTypeViewer) { // Special case for viewer space, always return an identity matrix // explicitly. In theory the default behavior of multiplying SpaceFromMojo * // MojoFromViewer would be equivalent, but that would likely return an // almost-identity due to rounding errors. return std::make_unique<TransformationMatrix>(); } // Return space_from_viewer = space_from_mojo * mojo_from_viewer auto space_from_viewer = SpaceFromMojo(mojo_from_viewer); if (!space_from_viewer) return nullptr; space_from_viewer->Multiply(mojo_from_viewer); return space_from_viewer; } std::unique_ptr<TransformationMatrix> XRReferenceSpace::SpaceFromInputForViewer( const TransformationMatrix& mojo_from_input, const TransformationMatrix& mojo_from_viewer) { // Return space_from_input = space_from_mojo * mojo_from_input auto space_from_input = SpaceFromMojo(mojo_from_viewer); if (!space_from_input) return nullptr; space_from_input->Multiply(mojo_from_input); return space_from_input; } std::unique_ptr<TransformationMatrix> XRReferenceSpace::MojoFromSpace() { // XRReferenceSpace doesn't do anything special with the base pose, but // derived reference spaces (bounded, unbounded, stationary, etc.) have their // own custom behavior. // Calculate the offset space's pose (including originOffset) in mojo // space. TransformationMatrix identity; std::unique_ptr<TransformationMatrix> mojo_from_offsetspace = SpaceFromViewer(identity); if (!mojo_from_offsetspace) { // Transform wasn't possible. return nullptr; } // Must account for position and orientation defined by origin offset. // Result is mojo_from_offset = mojo_from_ref * ref_from_offset, // where ref_from_offset is originOffset's transform matrix. // TODO(https://crbug.com/1008466): move originOffset to separate class? mojo_from_offsetspace->Multiply(origin_offset_->TransformMatrix()); return mojo_from_offsetspace; } TransformationMatrix XRReferenceSpace::OriginOffsetMatrix() { return origin_offset_->TransformMatrix(); } TransformationMatrix XRReferenceSpace::InverseOriginOffsetMatrix() { return origin_offset_->InverseTransformMatrix(); } XRReferenceSpace* XRReferenceSpace::getOffsetReferenceSpace( XRRigidTransform* additional_offset) { auto matrix = OriginOffsetMatrix().Multiply(additional_offset->TransformMatrix()); auto* result_transform = MakeGarbageCollected<XRRigidTransform>(matrix); return cloneWithOriginOffset(result_transform); } XRReferenceSpace* XRReferenceSpace::cloneWithOriginOffset( XRRigidTransform* origin_offset) { return MakeGarbageCollected<XRReferenceSpace>(this->session(), origin_offset, type_); } void XRReferenceSpace::Trace(blink::Visitor* visitor) { visitor->Trace(origin_offset_); XRSpace::Trace(visitor); } void XRReferenceSpace::OnReset() { if (type_ != Type::kTypeViewer) { DispatchEvent( *XRReferenceSpaceEvent::Create(event_type_names::kReset, this)); } } } // namespace blink
[ "stanley@moon.lan" ]
stanley@moon.lan
7e3a4d59da8dafbbd52d30263e2637c3349718a4
24cb27c6796bf13606662cf3a448edf0c76bf5b0
/lib/include/graphic/gcaVertex.hpp
1f895b3d914e95bde7c29357cc86e825d95ed078
[]
no_license
Nicolas91B/Grassmann-Calay
1df59dad403533f45aa02ac7ef7680adc3e25bb7
b04818c7add706b5615da6285a2a647fb6ac7228
refs/heads/master
2016-08-02T21:21:25.538116
2014-02-22T19:14:14
2014-02-22T19:14:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,004
hpp
#pragma once #include <grassmannCalay.hpp> #include <vector> #include "graphic/common.hpp" namespace glimac{ class gcaVertex{ void getPoint(const gca::K_blade& blade, const glm::vec3& color); void getDroite(const gca::K_blade& blade, const glm::vec3& color); void getPlan(const gca::K_blade& blade, const glm::vec3& color); // Alloue et construit les données (implantation dans le .cpp) public: // Constructeur: alloue le tableau de données et construit les attributs des vertex gcaVertex(): m_nVertexCount(0) {} void getBlade(const gca::K_blade& blade, const glm::vec3& color); // Renvoit le pointeur vers les données const glimac::ShapeVertex* getDataPointer() const { return &m_Vertices[0]; } // Renvoit le nombre de vertex GLsizei getVertexCount() const { return m_nVertexCount; } private: std::vector<glimac::ShapeVertex> m_Vertices; GLsizei m_nVertexCount; // Nombre de sommets }; }
[ "nicolasj.bertrand@gmail.com" ]
nicolasj.bertrand@gmail.com
5b8136cfc86ed2847461505ad1b1719edffc6a9c
2d9938a76e7dcca11149b7a988aa29744575932f
/Day2/day2_q1.cpp
99f37fcc20d0d31bf8263ef79b2f628f7308cbff
[]
no_license
Jacobinski/Advent-of-Code-2019
6bcb94ed3bd33a1bbcbb72dbdbffc7a66d28ad63
a617fea6f47b362f1179386e94a0d7b23e8f02b5
refs/heads/master
2020-09-22T14:29:41.330910
2019-12-16T05:16:24
2019-12-16T05:22:24
225,240,000
1
1
null
null
null
null
UTF-8
C++
false
false
3,992
cpp
/* On the way to your gravity assist around the Moon, your ship computer beeps angrily about a "1202 program alarm". On the radio, an Elf is already explaining how to handle the situation: "Don't worry, that's perfectly norma--" The ship computer bursts into flames. You notify the Elves that the computer's magic smoke seems to have escaped. "That computer ran Intcode programs like the gravity assist program it was working on; surely there are enough spare parts up there to build a new Intcode computer!" An Intcode program is a list of integers separated by commas (like 1,0,0,3,99). To run one, start by looking at the first integer (called position 0). Here, you will find an opcode - either 1, 2, or 99. The opcode indicates what to do; for example, 99 means that the program is finished and should immediately halt. Encountering an unknown opcode means something went wrong. Opcode 1 adds together numbers read from two positions and stores the result in a third position. The three integers immediately after the opcode tell you these three positions - the first two indicate the positions from which you should read the input values, and the third indicates the position at which the output should be stored. For example, if your Intcode computer encounters 1,10,20,30, it should read the values at positions 10 and 20, add those values, and then overwrite the value at position 30 with their sum. Opcode 2 works exactly like opcode 1, except it multiplies the two inputs instead of adding them. Again, the three integers after the opcode indicate where the inputs and outputs are, not their values. Once you're done processing an opcode, move to the next one by stepping forward 4 positions. For example, suppose you have the following program: 1,9,10,3,2,3,11,0,99,30,40,50 For the purposes of illustration, here is the same program split into multiple lines: 1,9,10,3, 2,3,11,0, 99, 30,40,50 The first four integers, 1,9,10,3, are at positions 0, 1, 2, and 3. Together, they represent the first opcode (1, addition), the positions of the two inputs (9 and 10), and the position of the output (3). To handle this opcode, you first need to get the values at the input positions: position 9 contains 30, and position 10 contains 40. Add these numbers together to get 70. Then, store this value at the output position; here, the output position (3) is at position 3, so it overwrites itself. Afterward, the program looks like this: 1,9,10,70, 2,3,11,0, 99, 30,40,50 Step forward 4 positions to reach the next opcode, 2. This opcode works just like the previous, but it multiplies instead of adding. The inputs are at positions 3 and 11; these positions contain 70 and 50 respectively. Multiplying these produces 3500; this is stored at position 0: 3500,9,10,70, 2,3,11,0, 99, 30,40,50 Stepping forward 4 more positions arrives at opcode 99, halting the program. Here are the initial and final states of a few more small programs: - 1,0,0,0,99 becomes 2,0,0,0,99 (1 + 1 = 2). - 2,3,0,3,99 becomes 2,3,0,6,99 (3 * 2 = 6). - 2,4,4,5,99,0 becomes 2,4,4,5,99,9801 (99 * 99 = 9801). - 1,1,1,4,99,5,6,0,99 becomes 30,1,1,4,2,5,6,0,99. Once you have a working computer, the first step is to restore the gravity assist program (your puzzle input) to the "1202 program alarm" state it had just before the last computer caught fire. To do this, before running the program, replace position 1 with the value 12 and replace position 2 with the value 2. What value is left at position 0 after the program halts? */ #include <iostream> #include <vector> using namespace std; int main() { vector<int> codes; string str; while (getline(cin, str, ',')) { codes.push_back(stoi(str)); } for (int i=0; codes[i] != 99; i += 4) { if (codes[i] == 1) codes[codes[i+3]] = codes[codes[i+1]] + codes[codes[i+2]]; else // if (codes[i] == 2) codes[codes[i+3]] = codes[codes[i+1]] * codes[codes[i+2]]; } cout << codes[0] << "\n"; return 0; }
[ "jrbudzis@gmail.com" ]
jrbudzis@gmail.com
54e81a799dacd27e02dba111ee7ccc6363482763
6aeccfb60568a360d2d143e0271f0def40747d73
/sandbox/variadic_templates/sandbox/slim/test/tuple.test.cpp
840f73b18888876978554c371d36207ec68588e1
[]
no_license
ttyang/sandbox
1066b324a13813cb1113beca75cdaf518e952276
e1d6fde18ced644bb63e231829b2fe0664e51fac
refs/heads/trunk
2021-01-19T17:17:47.452557
2013-06-07T14:19:55
2013-06-07T14:19:55
13,488,698
1
3
null
2023-03-20T11:52:19
2013-10-11T03:08:51
C++
UTF-8
C++
false
false
3,070
cpp
//Acknowlegements: // The following code was adapted from part of the code in // https://github.com/ericniebler/home/blob/master/src/tuple/unrolled_tuple.hpp //ChangeLog: // 2012-10-26 LJ Evans // 1) Copied the code after the line: // #ifdef TEST // in the above mentioned unrolled_tuple.hpp file. // 2) Added the boostpp #includes. // 3) Used the boostpp stringize to #include the tuple implementation code // named by a macro. // /////////////////////////////////////////////////////////////////////////////// // Copyright 2012 Eric Niebler. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #include <boost/preprocessor/stringize.hpp> #ifndef TUPLE_IMPL #define TUPLE_IMPL tuple_impl_bcon12_vertical.hpp #endif #include BOOST_PP_STRINGIZE(TUPLE_IMPL) #include <cstdio> ////////////////////////////////////////////////////// //{copied from unrolled_tuple.hpp: struct S { S() { std::printf("not constexpr!\n"); } }; // What is a literal type? constexpr tuple_bench<> t0{}; static_assert(std::is_trivial<tuple_bench<>>::value, "not trivial"); constexpr tuple_bench<int> t1{42}; static_assert(std::is_trivial<tuple_bench<int>>::value, "not trivial"); constexpr tuple_bench<int, float> t2{1, 3.14f}; static_assert(std::is_trivial<tuple_bench<int, float>>::value, "not trivial"); constexpr tuple_bench<int, tuple_bench<int, float>> t3{1, tuple_bench<int, float>{2, 3.14f}}; static_assert(std::is_trivial<tuple_bench<int, tuple_bench<int, float>>>::value, "not trivial"); constexpr int i = get<0>(t1); static_assert(i == 42, "not a compile-time constant"); constexpr float f = get<1>(t2); static_assert(f == 3.14f, "not a compile-time constant"); //static_assert(std::is_same<int, tuple_bench_element<0, tuple_bench<int>>::type>::value, "wrong element"); //static_assert(std::is_same<float &, tuple_bench_element<1, tuple_bench<int, float &>>::type>::value, "wrong element"); // Make sure I understand how decltype, rvalues and lvalues work. struct T { S s; }; static_assert(!std::is_reference<decltype((T().s))>::value, "not is rvalue ref"); static_assert(std::is_reference<decltype((static_cast<T &&>(T()).s))>::value, "is rvalue ref"); static_assert(!std::is_lvalue_reference<decltype((static_cast<T &&>(T()).s))>::value, "is lvalue ref"); void test() { tuple_bench<S> s,t; t = s; S &ss = get<0>(s); get<0>(s) = get<0>(t); S && sss = get<0>(::make_tuple(S())); static_assert(std::is_reference<decltype(get<0>(::make_tuple(S())))>::value, ""); static_assert(!std::is_lvalue_reference<decltype(get<0>(::make_tuple(S())))>::value, ""); int i = 0; tuple_bench<int &> ti{i}; tuple_bench<int &> ti2(ti); static_assert(std::is_lvalue_reference<decltype(get<0>(ti2))>::value, ""); static_assert(sizeof(tuple_bench<char,char,char>)==3, "wrong size"); std::printf("%f\n", (double)f);; } //}copied from unrolled_tuple.hpp: int main() { test(); return 0; }
[ "cppljevans@suddenlink.net" ]
cppljevans@suddenlink.net
8ae700369c11a098913cb812bcc89747c3bac704
05c2da67408e83bdffedd8d640ebbf537087a8cb
/Imp2/includes/gameIO.h
66dabd067ff2b1e2084fb895cb27552a5a17e4bd
[]
no_license
fjsaezm/Final_Practise_C-
35d02827d3338608b5f7aa79c0deb08c9257f28a
d35a2aac26907349383548c8c2052f7103d8db8a
refs/heads/master
2021-01-17T08:05:00.556875
2016-06-06T16:10:33
2016-06-06T16:10:33
59,999,277
0
0
null
null
null
null
UTF-8
C++
false
false
1,128
h
#ifndef GAMEIO_H #define GAMEIO_H #include "board.h" #include "player.h" class GameIO { public: void setBoard(Board& board); void setPlayers(Player& player1, Player& player2); void printPlayerName(const Player& player,std::ostream& os = std::cout); void printBoard( Board board,std::ostream& os = std::cout); void insertToken(Board& board,const Player& player1, const Player& player2,std::ostream& os = std::cout); void askToAlign(Board& board,std::ostream& os = std::cout); void askToInsert(Board& board, std::ostream&os = std::cout); void smallTable(std:: ostream& os = std::cout); int AIcolumn(const Board& board); void results( Board& board, Player& player1, Player& player2,std::ostream& os = std::cout); bool keepPlaying(std::ostream& os = std::cout); bool saveGame(const char* filename,const Board& board, const Player& player1, const Player& player2); bool loadGame(const char* filename,Board& board, Player& player1, Player& player2); void dialogSaveGame(Board& board,const Player& player1, const Player& player2,std::ostream& os = std::cout); }; #endif
[ "fjaviersaezm@gmail.com" ]
fjaviersaezm@gmail.com
75f4874843944c37f226da58da2cbad54d8dac46
498b11a3cf9763afcc9e8a7a3b924f30e5c2c5eb
/aws-cpp-sdk-connect/include/aws/connect/model/CreateUserResult.h
bae787261c7f0217e198b86e45a0544d6117244d
[ "MIT", "Apache-2.0", "JSON" ]
permissive
DaddyCal/aws-sdk-cpp
39272e345c50d48360b638587db6bc868fa92b6f
010aeaeb679b056dfe3a1b143c681eb4a3b5108b
refs/heads/master
2023-04-06T18:14:00.178692
2019-10-10T19:22:14
2019-10-10T19:22:14
214,284,026
1
0
Apache-2.0
2023-04-04T01:37:43
2019-10-10T20:55:55
null
UTF-8
C++
false
false
3,815
h
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/connect/Connect_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace Connect { namespace Model { class AWS_CONNECT_API CreateUserResult { public: CreateUserResult(); CreateUserResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); CreateUserResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>The unique identifier for the user account in Amazon Connect</p> */ inline const Aws::String& GetUserId() const{ return m_userId; } /** * <p>The unique identifier for the user account in Amazon Connect</p> */ inline void SetUserId(const Aws::String& value) { m_userId = value; } /** * <p>The unique identifier for the user account in Amazon Connect</p> */ inline void SetUserId(Aws::String&& value) { m_userId = std::move(value); } /** * <p>The unique identifier for the user account in Amazon Connect</p> */ inline void SetUserId(const char* value) { m_userId.assign(value); } /** * <p>The unique identifier for the user account in Amazon Connect</p> */ inline CreateUserResult& WithUserId(const Aws::String& value) { SetUserId(value); return *this;} /** * <p>The unique identifier for the user account in Amazon Connect</p> */ inline CreateUserResult& WithUserId(Aws::String&& value) { SetUserId(std::move(value)); return *this;} /** * <p>The unique identifier for the user account in Amazon Connect</p> */ inline CreateUserResult& WithUserId(const char* value) { SetUserId(value); return *this;} /** * <p>The Amazon Resource Name (ARN) of the user account created.</p> */ inline const Aws::String& GetUserArn() const{ return m_userArn; } /** * <p>The Amazon Resource Name (ARN) of the user account created.</p> */ inline void SetUserArn(const Aws::String& value) { m_userArn = value; } /** * <p>The Amazon Resource Name (ARN) of the user account created.</p> */ inline void SetUserArn(Aws::String&& value) { m_userArn = std::move(value); } /** * <p>The Amazon Resource Name (ARN) of the user account created.</p> */ inline void SetUserArn(const char* value) { m_userArn.assign(value); } /** * <p>The Amazon Resource Name (ARN) of the user account created.</p> */ inline CreateUserResult& WithUserArn(const Aws::String& value) { SetUserArn(value); return *this;} /** * <p>The Amazon Resource Name (ARN) of the user account created.</p> */ inline CreateUserResult& WithUserArn(Aws::String&& value) { SetUserArn(std::move(value)); return *this;} /** * <p>The Amazon Resource Name (ARN) of the user account created.</p> */ inline CreateUserResult& WithUserArn(const char* value) { SetUserArn(value); return *this;} private: Aws::String m_userId; Aws::String m_userArn; }; } // namespace Model } // namespace Connect } // namespace Aws
[ "magmarco@amazon.com" ]
magmarco@amazon.com
f2fcab9f25c169da6ac9519c1da8b93866d310a3
50be3849ca43a772bf061cd165739188b9b33962
/real-time-process-scheduling.cpp
bcff68a643f64d3708c413ed6fee2af930dc3bc8
[]
no_license
tomhsu2000/thread-practicing
427c25897e4019de03035739b895642294aca690
811d97f52765290014ad3e087e5a0052ef397703
refs/heads/main
2022-12-23T16:26:00.720400
2020-10-11T05:29:30
2020-10-11T05:29:30
302,897,020
0
0
null
null
null
null
UTF-8
C++
false
false
4,323
cpp
/* 模擬RMS或EDF排程演算法 在本作業中,利用模擬的方式來熟悉 Real-time Process Scheduling 的觀念 編譯: gcc -o s1071533_prog4 s1071533_prog4.cpp -lstdc++ 執行: ./s1071533_prog4 p 1082-prog4-data.txt */ #include <stdio.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <fstream> #include <queue> using namespace std; struct Task { int tid, R, C, D, T; int remaining_C;// the remaining CUP brust bool working;// distinguish whether is the current working task Task() : tid(0), R(0), C(0), D(0), T(0), remaining_C(0), working(false){}; Task(int tid, int R, int C, int D, int T) : tid(tid), R(R), C(C), D(D), T(T), remaining_C(C), working(false){}; }; // compartor of the arrival time struct compareR { bool operator()(Task const &t1, Task const &t2) { return t1.R > t2.R; } }; // compartor of the period struct compareT { bool operator()(Task const &t1, Task const &t2) { return t1.T > t2.T; } }; // compartor of the deadline which is the arrival time add the deadline preiod struct compareD { bool operator()(Task const &t1, Task const &t2) { int t1_deadline = t1.R + t1.D, t2_deadline = t2.R + t2.D; if (t1_deadline == t2_deadline) { if (t1.working == t2.working) return t1.tid > t2.tid; else return t1.working < t2.working; } return t1_deadline > t2_deadline; } }; int simu_time; priority_queue<Task, vector<Task>, compareR> arrival_que; void error_and_die(const char *msg); void readFile(char file_name[]); template <class T> void simulate(T &task_que); int main(int argc, char *argv[]) { int mode = (int)atoi(argv[1]); priority_queue<Task, vector<Task>, compareT> RMS; priority_queue<Task, vector<Task>, compareD> EDF; readFile(argv[2]); if (mode == 0) simulate(RMS); else simulate(EDF); } void error_and_die(const char *msg) { perror(msg); exit(EXIT_FAILURE); } void readFile(char file_name[]) { char temp[50]; fstream readFile(file_name, ios::in); if (!readFile) error_and_die("File"); while (readFile.getline(temp, 50)) { if (temp[0] != '#') { simu_time = (int)atoi(temp); break; } } while (readFile.getline(temp, 50)) { if (temp[0] != '#') { Task task; task.tid = (int)atoi(temp); task.R = (int)atoi(temp + 2); task.C = (int)atoi(temp + 4); task.D = (int)atoi(temp + 6); task.T = (int)atoi(temp + 8); task.remaining_C = task.C; arrival_que.push(task); } } } template <class T> void simulate(T &task_que) { int curt_time = 0; bool deadline_miss = false, task_table[6]{}; Task prev_task; while (curt_time <= simu_time) { while (curt_time == arrival_que.top().R) { Task curt_arri = arrival_que.top(); arrival_que.pop(); cout << setw(3) << curt_time << " t" << curt_arri.tid << ": arrive" << endl; // the arrival task do not finish the previous task if (task_table[curt_arri.tid] == 1) { cout << setw(3) << curt_time << " t" << curt_arri.tid << ": deadline miss" << endl; deadline_miss = true; break; } // add new task task_table[curt_arri.tid] = 1; task_que.push(curt_arri); // the next arrival time curt_arri.R += curt_arri.T; arrival_que.push(curt_arri); } if (deadline_miss) break; // the previous task is preempted by current task if (!task_que.empty() && prev_task.tid && prev_task.tid != task_que.top().tid) cout << setw(3) << curt_time << " t" << prev_task.tid << ": pause (remaining CPU burst: " << prev_task.remaining_C << ")" << endl; while (!task_que.empty()) { Task curt_task; curt_task = task_que.top(); task_que.pop(); if (prev_task.tid != curt_task.tid) cout << setw(3) << curt_time << " t" << curt_task.tid << ": start" << endl; curt_task.working = true; prev_task = curt_task; // task finish the remaining curt_time += curt_task.remaining_C; // task arrive stop to handle it first if (curt_time > arrival_que.top().R) { prev_task.remaining_C = curt_task.remaining_C = curt_time - arrival_que.top().R; task_que.push(curt_task); curt_time = arrival_que.top().R; break; } prev_task = Task(); task_table[curt_task.tid] = 0; cout << setw(3) << curt_time << " t" << curt_task.tid << ": end" << endl; } // finish all task before the new task arrive curt_time = arrival_que.top().R; } }
[ "noreply@github.com" ]
noreply@github.com
4850ae2bdfd57249a1a866c36bcd25c59498329f
d4648c15a5745c175c347b428403ecc66853c091
/Swirls/Game.h
5cd9d9b8fa5a0ce4cbf8db28d52b9104ec954002
[]
no_license
SecondReality/Swirls
c1c15daab5f7596280289886ceb63545f659036d
b829beb6ff4d033187aaac770c3af23c922a4d1f
refs/heads/master
2021-01-23T08:04:30.144874
2013-02-16T03:38:57
2013-02-16T03:38:57
8,230,892
1
0
null
null
null
null
UTF-8
C++
false
false
485
h
#pragma once #include "Timer.h" #include "Curl.h" #include "tree.hh" #include <vector> #include "Vector.h" #include <random> #include <functional> class Game { public: Game(void); ~Game(void); void update(); private: typedef tree<PositionedCurl> CurlTree; void recursiveDraw(CurlTree::sibling_iterator& it); smr::WorldTimer timer_; std::vector<Curl> curls_; std::vector<smr::Vector3f> curlPositions_; CurlTree tree_; void recursivePopulate(CurlTree::iterator & i); };
[ "smr@secondreality.co.uk" ]
smr@secondreality.co.uk
283a953eced39a78bed912572259b8fd0a9a29d4
5ecf33af7e92b611b68611c41b5857626af93a2c
/src/TensorList.cpp
30574aca3176188a53402230d8febef1cd84e32a
[]
no_license
mlverse/lantern
c9b697effeadb95705967379ae70d4a61c2ec3db
f5779da4510a9a116f8855b32f7ac10f2f02faf3
refs/heads/master
2021-08-10T17:07:12.461255
2021-01-05T21:22:08
2021-01-05T21:22:08
238,034,486
7
2
null
2021-01-05T21:22:13
2020-02-03T18:36:25
C++
UTF-8
C++
false
false
822
cpp
#include <iostream> #define LANTERN_BUILD #include "lantern/lantern.h" #include <torch/torch.h> #include "utils.hpp" void *lantern_TensorList() { return (void *)new LanternObject<std::vector<torch::Tensor>>(); } void lantern_TensorList_push_back(void *self, void *x) { torch::Tensor ten = reinterpret_cast<LanternObject<torch::Tensor> *>(x)->get(); reinterpret_cast<LanternObject<std::vector<torch::Tensor>> *>(self)->get().push_back(ten); } void *lantern_TensorList_at(void *self, int64_t i) { torch::Tensor out = reinterpret_cast<LanternObject<std::vector<torch::Tensor>> *>(self)->get().at(i); return (void *)new LanternObject<torch::Tensor>(out); } int64_t lantern_TensorList_size(void *self) { return reinterpret_cast<LanternObject<std::vector<torch::Tensor>> *>(self)->get().size(); }
[ "dfalbel@gmail.com" ]
dfalbel@gmail.com
643abf0a7917a62a6570d7cdea221a2843be3326
85e0f2f6b25a223d9eadd85a92550b6af3c6750e
/FireCube/Rendering/privateFont.h
da436d9f902b4e5918b72351e46a0bb27760bde8
[ "MIT" ]
permissive
ashleygwinnell/firecube
69cba6679615253d2bf895187e69bb202f605e05
ea6bec6bab98d922dce76610a739beb5f7f88b61
refs/heads/master
2020-05-04T23:07:43.773207
2019-03-23T10:32:00
2019-03-23T10:32:00
179,533,589
2
0
NOASSERTION
2019-04-04T16:15:05
2019-04-04T16:15:05
null
UTF-8
C++
false
false
78
h
namespace FireCube { class FontImpl { public: FT_Face face; }; };
[ "ibachar@e260023c-5348-0410-a714-2bcf037eb5bf" ]
ibachar@e260023c-5348-0410-a714-2bcf037eb5bf
bb1fc805d0d24fe4d0ea0fa68d60261271c2ccc3
b9051dbf39b1d90dc9e5041b22273497e013a244
/struck/libAnalyzer/TDT724RawData.cxx
00bca55e1fbdc98e4fd14f1a995b15c57d5cb2dc
[]
no_license
padsley/k600analyser
518093be041674e5ca5d595b45ed4ea3f74b362b
99ec1611f4540b7bc679b530d561b3b4a3a71d56
refs/heads/master
2023-04-28T05:24:31.176014
2023-04-17T07:53:51
2023-04-17T07:53:51
23,102,240
2
8
null
2022-04-12T08:05:44
2014-08-19T08:13:41
C
UTF-8
C++
false
false
1,497
cxx
#include "TDT724RawData.hxx" #include <iostream> TDT724RawData::TDT724RawData(int bklen, int bktype, const char* name, void *pdata): TGenericData(bklen, bktype, name, pdata) { fGlobalHeader.push_back(GetData32()[0]); fGlobalHeader.push_back(GetData32()[1]); fGlobalHeader.push_back(GetData32()[2]); fGlobalHeader.push_back(GetData32()[3]); // Do some sanity checking. // Make sure first word has right identifier if( (GetData32()[0] & 0xf0000000) != 0xa0000000) std::cerr << "First word has wrong identifier; first word = 0x" << std::hex << GetData32()[0] << std::dec << std::endl; int counter = 4; int number_available_channels = 0; for(int ch = 0; ch < 16; ch++){ if((1<<ch) & GetChMask()){ number_available_channels++; } } int nwords_per_channel = (GetEventSize() - 4)/number_available_channels; // Loop over channel data (only two channels). for(int ch = 0; ch < 2; ch++){ if((1<<ch) & GetChMask()){ std::vector<uint32_t> Samples; for(int i = 0; i < nwords_per_channel; i++){ uint32_t sample = (GetData32()[counter] & 0x3fff); Samples.push_back(sample); sample = (GetData32()[counter] & 0x3fff0000) >> 16; Samples.push_back(sample); counter++; } RawChannelMeasurement meas = RawChannelMeasurement(ch); meas.AddSamples(Samples); fMeasurements.push_back(meas); } } } void TDT724RawData::Print(){ std::cout << "DT724 decoder for bank " << GetName().c_str() << std::endl; }
[ "padsley@gmail.com" ]
padsley@gmail.com
8c70327683c0bcf26c79e5c706d9082c096d224e
71eb0196100d7bece14326afe216999fa2bb25a3
/test/DebugInfo/Inputs/llvm-symbolizer-dwo-test.cc
ea0967a263a8c7ade2c7e30e0d42d2427afeefe9
[ "NCSA", "LLVM-exception", "Apache-2.0" ]
permissive
etclabscore/evm_llvm
aae986955cfbea32bc1c01ec382daa7a7d75611f
700d4b7795d76a37110f8acfb6f05ee4894ab651
refs/heads/EVM
2022-03-11T06:21:35.460136
2020-09-02T21:11:20
2020-09-02T21:11:20
170,783,306
88
25
Apache-2.0
2020-07-29T14:07:28
2019-02-15T01:31:15
LLVM
UTF-8
C++
false
false
290
cc
int f(int a, int b) { return a + b; } int g(int a) { return a + 1; } int main() { return f(2, g(2)); } // Built with Clang 3.5.0: // $ mkdir -p /tmp/dbginfo // $ cp llvm-symbolizer-dwo-test.cc /tmp/dbginfo // $ cd /tmp/dbginfo // $ clang -gsplit-dwarf llvm-symbolizer-dwo-test.cc
[ "samsonov@google.com" ]
samsonov@google.com
2b7ecbf30bdd466b993a7ab85981c6e3e5b27b28
da1500e0d3040497614d5327d2461a22e934b4d8
/third_party/llvm-project/compiler-rt/test/asan/TestCases/use-after-poison.cpp
b32bb8cd23fcf9cdff17ce6e8b5f0966c4486ceb
[ "NCSA", "MIT", "LLVM-exception", "Apache-2.0", "BSD-3-Clause", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
youtube/cobalt
34085fc93972ebe05b988b15410e99845efd1968
acefdaaadd3ef46f10f63d1acae2259e4024d383
refs/heads/main
2023-09-01T13:09:47.225174
2023-09-01T08:54:54
2023-09-01T08:54:54
50,049,789
169
80
BSD-3-Clause
2023-09-14T21:50:50
2016-01-20T18:11:34
null
UTF-8
C++
false
false
579
cpp
// Check that __asan_poison_memory_region works. // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s // // Check that we can disable it // RUN: %env_asan_opts=allow_user_poisoning=0 %run %t #include <stdlib.h> extern "C" void __asan_poison_memory_region(void *, size_t); int main(int argc, char **argv) { char *x = new char[16]; x[10] = 0; __asan_poison_memory_region(x, 16); int res = x[argc * 10]; // BOOOM // CHECK: ERROR: AddressSanitizer: use-after-poison // CHECK: main{{.*}}use-after-poison.cpp:[[@LINE-2]] delete [] x; return res; }
[ "brianting@google.com" ]
brianting@google.com
5cdd0eb68c78d9c61c0d0e3eb62a061de3711894
569d64661f9e6557022cc45428b89eefad9a6984
/code/gameholder/guild_task_config.cpp
54c4d304153b94c8dc06df3d0287aad849d32ee7
[]
no_license
dgkang/ROG
a2a3c8233c903fa416df81a8261aab2d8d9ac449
115d8d952a32cca7fb7ff01b63939769b7bfb984
refs/heads/master
2020-05-25T02:44:44.555599
2019-05-20T08:33:51
2019-05-20T08:33:51
187,584,950
0
1
null
2019-05-20T06:59:06
2019-05-20T06:59:05
null
UTF-8
C++
false
false
5,147
cpp
#include "gameholder_pch.h" #include "guild_task_config.h" #include "game_util.h" IMPLEMENT_SINGLETON(GuildTaskConfig) GuildTaskConfig::GuildTaskConfig() { m_max_task_num = 0; m_use_token_num = 0; m_token_id = 0; m_can_task_num = 0; //m_qualityProList.clear(); m_boxRewardList.clear(); } GuildTaskConfig::~GuildTaskConfig() { } bool GuildTaskConfig::LoadConfig(const char* path) { TiXmlDocument xmlDoc; if(!xmlDoc.LoadFile(path)) { CnError("Load guild task file: %s failed\n", path); return false; } TiXmlElement* xmlRoot = xmlDoc.RootElement(); if(!xmlRoot) return false; for(TiXmlElement* guildTaskEle = xmlRoot->FirstChildElement(); guildTaskEle; guildTaskEle = guildTaskEle->NextSiblingElement()) { if(Crown::SDStrcmp(guildTaskEle->Value(), "base_info") == 0) { guildTaskEle->QueryUnsignedAttribute("max_task_num", &m_max_task_num); guildTaskEle->QueryUnsignedAttribute("can_task_num", &m_can_task_num); guildTaskEle->QueryUnsignedAttribute("use_token_num", &m_use_token_num); guildTaskEle->QueryUnsignedAttribute("token_id", &m_token_id); } //else if(Crown::SDStrcmp(guildTaskEle->Value(), "qualitypro") == 0) //{ //ItemProbability qualitypro; //for (TiXmlElement* dailyEle = guildTaskEle->FirstChildElement(); dailyEle; dailyEle = dailyEle->NextSiblingElement()) //{ // qualitypro.clear(); // dailyEle->QueryUnsignedAttribute("probability",&qualitypro.m_probability); // dailyEle->QueryIntAttribute("item",&qualitypro.m_item); // dailyEle->QueryUnsignedAttribute("multiple",&qualitypro.m_multiple); // m_qualityProList[qualitypro.m_item] = qualitypro; //} //// 检验总几率是否大于100% //uint32 totalPro = 0; //for (ItemProList::iterator proIt = m_qualityProList.begin(); proIt != m_qualityProList.end(); proIt++) //{ // totalPro += proIt->second.m_probability; //} //if (totalPro < BASE_RATE_NUM) //{ // CnFatal("probability total less then 100%\n"); //} //} else if(Crown::SDStrcmp(guildTaskEle->Value(), "reward_addtion") == 0) { RewardAddtionItem addtionItem; for(TiXmlElement* addtionEle = guildTaskEle->FirstChildElement(); addtionEle; addtionEle = addtionEle->NextSiblingElement()) { addtionItem.Clear(); addtionEle->QueryIntAttribute("guild_level", &addtionItem.guild_level); addtionEle->QueryIntAttribute("guild_point", &addtionItem.guild_point); addtionEle->QueryIntAttribute("score", &addtionItem.score); addtionEle->QueryIntAttribute("gamepoint", &addtionItem.gamepoint); addtionEle->QueryIntAttribute("exp", &addtionItem.exp); m_rewardAddtionList[addtionItem.guild_level] = addtionItem; } } else if(Crown::SDStrcmp(guildTaskEle->Value(), "score_boxs") == 0) { int32 score = 0; REWARD_TABLE boxRewardTable; for(TiXmlElement* boxEle = guildTaskEle->FirstChildElement(); boxEle; boxEle = boxEle->NextSiblingElement()) { if(Crown::SDStrcmp(boxEle->Value(), "box") == 0) { boxRewardTable.Clear(); score = 0; boxEle->QueryIntAttribute("score", &score); if(!LoadRewardTable(boxEle, boxRewardTable)) return false; m_boxRewardList[score] = boxRewardTable; } } } } return true; } REWARD_TABLE GuildTaskConfig::GetRewardAddtion(int32 guildLevel) { REWARD_TABLE rewardTable; std::map<int32, RewardAddtionItem>::iterator it = m_rewardAddtionList.find(guildLevel); if(it == m_rewardAddtionList.end()) { CnAssert(false); // 没有对应公会等级的奖励 return rewardTable; } REWARD_ITEM rewardItem; // rewardItem.Clear(); // rewardItem.type = PROP_GUILDPOINT; // rewardItem.num = it->second.guild_point; // rewardTable.items.push_back(rewardItem); rewardItem.Clear(); rewardItem.id = PROP_GUILD_SCORE; rewardItem.num = it->second.score; rewardTable.items.push_back(rewardItem); rewardItem.Clear(); rewardItem.id = PROP_GAMEPOINT; rewardItem.num = it->second.gamepoint; rewardTable.items.push_back(rewardItem); rewardItem.Clear(); rewardItem.id = PROP_EXP; rewardItem.num = it->second.exp; rewardTable.items.push_back(rewardItem); return rewardTable; } const REWARD_TABLE* GuildTaskConfig::GetBoxReward(int score) { std::map<int32, REWARD_TABLE>::iterator boxRewardIt = m_boxRewardList.find(score); if(boxRewardIt == m_boxRewardList.end()) { return NULL; } return &boxRewardIt->second; }
[ "judge23253@sina.com" ]
judge23253@sina.com
dbd763dfce35b8f4f07b4e31e1f9adc04d199ad7
c8218f4f11cae9c7b2c0e9df79102e9aee0556c0
/Raspberry/2021-target/LinesExample.h
fcb38bce016b9cb68d112e699399e1f436a49335
[]
no_license
TeamKoalafied/Robot_2020
a5db13b84e08eb14ac677bc94ad11cfed1134755
0a7ea36843407f7056901a70c41d2fd5cfd758c2
refs/heads/master
2021-06-29T06:04:22.299940
2021-06-04T04:19:03
2021-06-04T04:19:03
239,232,062
2
0
null
2021-06-04T04:19:04
2020-02-09T01:56:41
C++
UTF-8
C++
false
false
1,935
h
#pragma once #include "vision/VisionPipeline.h" #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include <opencv2/features2d.hpp> #include <iostream> #include <stdio.h> #include <stdlib.h> #include <map> #include <vector> #include <string> #include <math.h> namespace grip { /** * Contains details of a line. * */ class Line { public: double x1, y1, x2, y2; /** * Creates a line with given (x, y) points 1 and 2. * * @param x1 x coordinate of one point of the line. * @param y1 y coordinate of the same point of line as above. * @param x2 x coordinate of other point of the line. * @param y2 y coordinate of other point of line. */ Line(double x1, double y1, double x2, double y2) { this->x1 = x1; this->y1 = y1; this->x2 = x2; this->y2 = y2; } /** * Calculates the length of the line. * * @return The point to point length of the line. */ double length() { return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); } /** * Calculates the angle between the two points. * * @return the angle (in degrees between -180 and 180) between the two points. */ double angle() { return (180*atan2(y2 - y1, x2 - x1)/CV_PI); } }; /** * LinesExample class. * * An OpenCV pipeline generated by GRIP. */ class LinesExample : public frc::VisionPipeline { private: cv::Mat hslThresholdOutput; std::vector<Line> findLinesOutput; std::vector<Line> filterLinesOutput; void hslThreshold(cv::Mat &, double [], double [], double [], cv::Mat &); void findLines(cv::Mat &, std::vector<Line> &); void filterLines(std::vector<Line> &, double , double [], std::vector<Line> &); public: LinesExample(); void Process(cv::Mat& source0) override; cv::Mat* GetHslThresholdOutput(); std::vector<Line>* GetFindLinesOutput(); std::vector<Line>* GetFilterLinesOutput(); }; } // end namespace grip
[ "33440834+mjn345@users.noreply.github.com" ]
33440834+mjn345@users.noreply.github.com
0f103673635d64b897c7611334569f1804d89016
eb175fc1ce65bc157d1ccf150bb331e895d6a6ad
/engine_SDL_opengl/main.cpp
b4cccbcf21da0c6567ead701ea737d663706d30c
[]
no_license
zeplaz/razerz
e49f912838447e7032abfad0e2c6dcc8e23fa16b
5198443f0dbbd1bf7676a579c17cd6ab830ab87a
refs/heads/master
2021-09-15T15:41:09.700114
2021-08-25T18:41:42
2021-08-25T18:41:42
247,567,023
2
0
null
null
null
null
UTF-8
C++
false
false
419
cpp
#include "engine_MCP.hpp" //import test_mod; //#include "static_interface.hpp" #include <thread> int main(int argc, char* argv[]) { //std::jthread threadj; std::jthread j1; std::cout << "hardwarethread::" << std::jthread::hardware_concurrency() <<'\n'; Engine engine; engine.configure(argc,argv); engine.ignition(); engine.shutdown(); std::cout <<"\n #####compleate\n \n \a"; return 0; }
[ "life.in.the.vivid.dream@gmail.com" ]
life.in.the.vivid.dream@gmail.com
6a5ff3e77ec16f386d3868039c72cbea1564335e
5a03be7d3ff56b1c6434399bd09970cc3f67594f
/GraphicsProgramming/Scene.cpp
23d45e4060be30f2d3bcd1969ed0543df8a1d835
[]
no_license
Jirds/CMP203Repos
a18fc2db197a83628a9b332b64e7f78880b0ef97
e989ed1ce4a84035795e262408f37a89045c5329
refs/heads/master
2022-04-07T19:40:21.503982
2020-03-06T22:10:54
2020-03-06T22:10:54
227,685,766
0
0
null
null
null
null
UTF-8
C++
false
false
6,303
cpp
#include "Scene.h" // Scene constructor, initilises OpenGL // You should add further variables to need initilised. Scene::Scene(Input* in) { // Store pointer for input class input = in; //OpenGL settings glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.39f, 0.58f, 93.0f, 1.0f); // Cornflour Blue Background glClearDepth(1.0f); // Depth Buffer Setup glClearStencil(0); // Clear stencil buffer glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); gluPerspective(120.0f, (GLfloat)16.0 / (GLfloat)9.0, 1, 150.0f); //glutSetCursor(GLUT_CURSOR_NONE); // Other OpenGL / render setting should be applied here. //glEnable(GL_LIGHTING); sphere.load("Models/largeSphere.obj", "Models/brick.jpg"); /*glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, verts); glNormalPointer(GL_FLOAT, 0, norms); glTexCoordPointer(2, GL_FLOAT, 0, texCoords); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); // Initialise scene variables */ } void Scene::handleInput(float dt) { glGetIntegerv(GL_POLYGON_MODE, polygonMode); if (input->isKeyDown('r')) { if (polygonMode[0] == GL_LINE) { glPolygonMode(GL_FRONT, GL_FILL); input->SetKeyUp('r'); } else if (polygonMode[0] == GL_FILL) { glPolygonMode(GL_FRONT, GL_LINE); input->SetKeyUp('r'); } } if (input->isKeyDown('w')) { camera1.moveForward(dt); input->SetKeyUp('w'); } if (input->isKeyDown('s')) { camera1.moveBackward(dt); input->SetKeyUp('s'); } if (input->isKeyDown('q')) { camera1.moveUp(dt); input->SetKeyUp('q'); } if (input->isKeyDown('e')) { camera1.moveDown(dt); input->SetKeyUp('e'); } float xCurr, yCurr = 0; float yaw = 0, pitch = 0, roll = 0; //Get the change in mouse position since last frame yaw = input->getMouseX() - xLast; pitch = input->getMouseY() - yLast; yaw = 0 - yaw; yaw *= 7 * dt; pitch *= 10 * dt; camera1.viewRotate(yaw, pitch, roll); //Save mouse position as last mouse position xLast = input->getMouseX(); yLast = input->getMouseY(); // Handle user input void setKeyDown(unsigned char key); void setKeyup(unsigned char key); bool isKeyDown(int); } void Scene::update(float dt) { // update scene related variables. camera1.update(); // Calculate FPS for output calculateFPS(); } void Scene::render() { // Clear Color and Depth Buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Reset transformations glLoadIdentity(); // Set the camera (Translate, Coords of intrest, Which way is up) // x y z x(?) y(?) z(?) //gluLookAt(camera1.getPos().x, camera1.getPos().y, camera1.getPos().z, camera1.getLook().x, camera1.getLook().y, camera1.getLook().z, camera1.getUp().x, camera1.getUp().y, camera1.getUp().z); gluLookAt(0.0, 0.0, 6.0, 0.0, 0.0, 5.0, 0.0, 1.0, 0.0); GLfloat Light_Ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f }; GLfloat Light_Diffuse[] = { 0.3f, 0.3f, 0.3f, 1.0f }; GLfloat Light_Specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat Light_Position[] = { 0.0f, 0.0f, 5.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_AMBIENT, Light_Ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, Light_Diffuse); glLightfv(GL_LIGHT0, GL_POSITION, Light_Position); glLightfv(GL_LIGHT0, GL_SPECULAR, Light_Specular); //glEnable(GL_LIGHT0); sphere.render(); glBegin(GL_TRIANGLE_FAN); glEnd(); glBegin(GL_QUADS); glColor3f(1.0f, 0.0f, 0.0f); glNormal3f(0.0f, 1.0f, 0.0f); glVertex3f(-50.0f, 0.0f, 1.0f); glVertex3f(-50.0f, 0.0f, -50.0f); glVertex3f(50.0f, 0.0f, -50.0f); glVertex3f(50.0f, 0.0f, 50.0f); glEnd(); // Render text, should be last object rendered. renderTextOutput(); // Swap buffers, after all objects are rendered. glutSwapBuffers(); } // Handles the resize of the window. If the window changes size the perspective matrix requires re-calculation to match new window size. void Scene::resize(int w, int h) { width = w; height = h; // Prevent a divide by zero, when window is too short // (you cant make a window of zero width). if (h == 0) h = 1; float ratio = (float)w / (float)h; fov = 45.0f; nearPlane = 0.1f; farPlane = 100.0f; // Use the Projection Matrix glMatrixMode(GL_PROJECTION); // Reset Matrix glLoadIdentity(); // Set the viewport to be the entire window glViewport(0, 0, w, h); // Set the correct perspective. gluPerspective(fov, ratio, nearPlane, farPlane); // Get Back to the Modelview glMatrixMode(GL_MODELVIEW); } // Calculates FPS void Scene::calculateFPS() { frame++; time = glutGet(GLUT_ELAPSED_TIME); if (time - timebase > 1000) { sprintf_s(fps, "FPS: %4.2f", frame * 1000.0 / (time - timebase)); timebase = time; frame = 0; } } // Compiles standard output text including FPS and current mouse position. void Scene::renderTextOutput() { // Render current mouse position and frames per second. sprintf_s(mouseText, "Mouse: %i, %i", input->getMouseX(), input->getMouseY()); displayText(-1.f, 0.96f, 1.f, 0.f, 0.f, mouseText); displayText(-1.f, 0.90f, 1.f, 0.f, 0.f, fps); } // Renders text to screen. Must be called last in render function (before swap buffers) void Scene::displayText(float x, float y, float r, float g, float b, char* string) { // Get Lenth of string int j = strlen(string); // Swap to 2D rendering glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, 5, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Orthographic lookAt (along the z-axis). gluLookAt(0.0f, 0.0f, 10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); // Set text colour and position. glColor3f(r, g, b); glRasterPos2f(x, y); // Render text. for (int i = 0; i < j; i++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, string[i]); } // Reset colour to white. glColor3f(1.f, 1.f, 1.f); // Swap back to 3D rendering. glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fov, ((float)width / (float)height), nearPlane, farPlane); glMatrixMode(GL_MODELVIEW); }
[ "jordanmiller120699@gmail.com" ]
jordanmiller120699@gmail.com
25ab313d18613cec71e7c9105ec90047f4508e5a
f89bbef5e7cf7b268d7615e673622cd3d4e74052
/scipy/special/faddeeva_w.cxx
152efbb61ec9d6c71bf46b34715d741f6654a7ce
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
JT5D/scipy
7b977a12221dafe48771f19d004253355e3c2069
217067dfad3e3e04f390113d769210874f28bb8b
refs/heads/master
2020-04-01T18:44:28.396478
2012-09-21T18:38:26
2012-10-10T19:04:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
25,111
cxx
/* Copyright (c) 2012 Massachusetts Institute of Technology * * [Also included are functions derived from derfc in SLATEC * (netlib.org/slatec), which "is in the public domain" * and hence may be redistributed under these or any terms.] * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // include this declaration in your code or header file to call: #include <complex> extern std::complex<double> Faddeeva_w(std::complex<double> z, double relerr); /* Compute the Faddeyeva function w(z) = exp(-z^2) * erfc(-i*z), to a desired relative accuracy relerr, for arbitrary complex arguments z, using the algorithm described in the paper: Mofreh R. Zaghloul and Ahmed N. Ali, "Algorithm 916: Computing the Faddeyeva and Voigt Functions," ACM Trans. Math. Soft. 38(2), 15 (2011). Note that this is an INDEPENDENT RE-IMPLEMENTATION of this algorithm, based on the description in the paper ONLY. In particular, I did not refer to (or even download) the author's Matlab implementation (which is under restrictive ACM copyright terms and therefore unusable in free/open-source software). Steven G. Johnson, Massachusetts Institute of Technology http://math.mit.edu/~stevenj October 2012. -- Note that the algorithm assumes that the erfc(x) function, or rather the scaled function erfcx(x) = exp(x*x)*erfc(x), is supplied for REAL arguments x. I include an erfcx routine derived from the derfc function in SLATEC (modified to compute erfcx instead of erfc). A small test program is included the end, which checks the w(z) results against several known values. To compile the test function, compile with -DFADDEEVA_W_TEST (that is, #define FADDEEVA_W_TEST). REVISION HISTORY: 4 October 2012: initial public release (SGJ) 5 October 2012: revised (SGJ) to fix spelling error, start summation for large x at round(x/a) (> 1) rather than ceil(x/a) as in the original paper, which should slightly improve performance (and, apparently, slightly improves accuracy) */ #include <cfloat> #include <cmath> using namespace std; static double derfcx(double x); #define erfcx(x) derfcx(x) // return sinc(x) = sin(x)/x, given both x and sin(x) // [since we only use this in cases where sin(x) has already been computed] static inline double sinc(double x, double sinx) { return fabs(x) < 1e-4 ? 1 - (0.1666666666666666666667)*x*x : sinx / x; } // sinh(x) via Taylor series, accurate to machine precision for |x| < 1e-2 static inline double sinh_taylor(double x) { return x * (1 + (x*x) * (0.1666666666666666666667 + 0.00833333333333333333333 * (x*x))); } static inline double sqr(double x) { return x*x; } complex<double> Faddeeva_w(complex<double> z, double relerr) { double a, a2, c; if (relerr < DBL_EPSILON) { relerr = DBL_EPSILON; a = 0.518321480430085929872; // pi / sqrt(-log(eps*0.5)) c = 0.329973702884629072537; // (2/pi) * a; a2 = 0.268657157075235951582; // a^2 } else { const double pi = 3.14159265358979323846264338327950288419716939937510582; a = pi / sqrt(-log(relerr*0.5)); c = (2/pi)*a; a2 = a*a; } const double x = fabs(real(z)); const double y = imag(z); complex<double> ret(0.,0.); // return value double sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0, sum5 = 0; if (x == 0.0) return erfcx(y); else if (x < 26.61571750925126020252554553) { // (x < sqrt(-log(DBL_MIN))) const double expx2 = exp(-x*x); const double exp2ax = exp((2*a)*x), expm2ax = 1 / exp2ax; double prod2ax = 1, prodm2ax = 1; if (x < 5e-4) { // compute sum4 and sum5 together as sum5-sum4 for (int n = 1; 1; ++n) { const double coef = exp(-a2*(n*n)) * expx2 / (a2*(n*n) + y*y); prod2ax *= exp2ax; prodm2ax *= expm2ax; sum1 += coef; sum2 += coef * prodm2ax; sum3 += coef * prod2ax; // really = sum5 - sum4 sum5 += coef * (2*a) * n * sinh_taylor((2*a)*n*x); // test convergence via sum3 if (coef * prod2ax < relerr * sum3) break; } } else { // x > 5e-4, compute sum4 and sum5 separately for (int n = 1; 1; ++n) { const double coef = exp(-a2*(n*n)) * expx2 / (a2*(n*n) + y*y); prod2ax *= exp2ax; prodm2ax *= expm2ax; sum1 += coef; sum2 += coef * prodm2ax; sum4 += (coef * prodm2ax) * (a*n); sum3 += coef * prod2ax; sum5 += (coef * prod2ax) * (a*n); // test convergence via sum5, since this sum has the slowest decay if ((coef * prod2ax) * (a*n) < relerr * sum5) break; } } if (y > 5) { // imaginary terms cancel const double sinxy = sin(x*y); ret = (expx2*erfcx(y) - c*y*sum1) * cos(2*x*y) + (c*x*expx2) * sinxy * sinc(x*y, sinxy); } else { double xs = real(z); const double sinxy = sin(xs*y); const double sin2xy = sin(2*xs*y), cos2xy = cos(2*xs*y); const double coef1 = expx2*erfcx(y) - c*y*sum1; const double coef2 = c*xs*expx2; ret = complex<double>(coef1 * cos2xy + coef2 * sinxy * sinc(xs*y, sinxy), coef2 * sinc(2*xs*y, sin2xy) - coef1 * sin2xy); } } else { // x > sqrt(log(-DBL_MIN)): exp(-x^2)=0 & only sum3 & sum5 contribute // (round instead of ceil as in original paper; note that x/a > 1 here) int n0 = int(x/a + 0.5); // sum in both directions, starting at n0 sum3 = exp(-sqr(a*n0-x)) / (a2*(n0*n0) + y*y); sum5 = a*n0 * sum3; double exp1 = exp(4*(a2*n0 - a*x)), exp1dn = 1; int dn; for (dn = 1; n0 - dn > 0; ++dn) { // loop over n0-dn and n0+dn terms int np = n0 + dn, nm = n0 - dn; double tp = exp(-sqr(a*np-x)); double tm = tp * (exp1dn *= exp1); // trick to get tm from tp tp /= (a2*(np*np) + y*y); tm /= (a2*(nm*nm) + y*y); sum3 += tp + tm; sum5 += a * (np * tp + nm * tm); if (a * (np * tp + nm * tm) < relerr * sum5) goto finish; } while (1) { // loop over n0+dn terms only (since n0-dn <= 0) int np = n0 + dn++; double tp = exp(-sqr(a*np-x)) / (a2*(np*np) + y*y); sum3 += tp; sum5 += a * np * tp; if (a * np * tp < relerr * sum5) goto finish; } } finish: return ret + complex<double>((0.5*c)*y*(sum2+sum3), (0.5*c)*copysign(sum5-sum4, real(z))); } ///////////////////////////////////////////////////////////////////////// /* erfcx function derived from derfc function in SLATEC, converted to C by Steven G. Johnson (with help from f2c) and modified to compute erfcx instead of erfc, October 2012. According to http://www.netlib.org/slatec/guide: The Library is in the public domain and distributed by the Energy Science and Technology Software Center. Energy Science and Technology Software Center P.O. Box 1020 Oak Ridge, TN 37831 Telephone 615-576-2606 E-mail estsc%a1.adonis.mrouter@zeus.osti.gov */ #if 0 /* comment out for hard-coded IEEE values in derfc */ /* BEGIN PROLOGUE INITDS */ /* PURPOSE Determine the number of terms needed in an orthogonal */ /* polynomial series so that it meets a specified accuracy. */ /* LIBRARY SLATEC (FNLIB) */ /* CATEGORY C3A2 */ /* TYPE DOUBLE PRECISION (INITS-S, INITDS-D) */ /* KEYWORDS CHEBYSHEV, FNLIB, INITIALIZE, ORTHOGONAL POLYNOMIAL, */ /* ORTHOGONAL SERIES, SPECIAL FUNCTIONS */ /* AUTHOR Fullerton, W., (LANL) */ static int initds(const double *os, int nos, double eta) { /* System generated locals */ int i__1; /* Local variables */ int i__, ii; double err; /* DESCRIPTION */ /* Initialize the orthogonal series, represented by the array OS, so */ /* that INITDS is the number of terms needed to insure the error is no */ /* larger than ETA. Ordinarily, ETA will be chosen to be one-tenth */ /* machine precision. */ /* Input Arguments -- */ /* OS double precision array of NOS coefficients in an orthogonal */ /* series. */ /* NOS number of coefficients in OS. */ /* ETA single precision scalar containing requested accuracy of */ /* series. */ /* REVISION HISTORY (YYMMDD) */ /* 770601 DATE WRITTEN */ /* 890531 Changed all specific intrinsics to generic. (WRB) */ /* 890831 Modified array declarations. (WRB) */ /* 891115 Modified error message. (WRB) */ /* 891115 REVISION DATE from Version 3.2 */ /* 891214 Prologue converted to Version 4.0 format. (BAB) */ /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */ /* 121094 f2c cleanup, eta changed to double(SGJ) */ /* END PROLOGUE INITDS */ /* FIRST EXECUTABLE STATEMENT INITDS */ /* Parameter adjustments */ --os; /* Function Body */ err = 0.; i__1 = nos; for (ii = 1; ii <= i__1; ++ii) { i__ = nos + 1 - ii; err += fabs(os[i__]); if (err > eta) { goto L20; } /* L10: */ } L20: return i__; } /* initds */ #endif /* BEGIN PROLOGUE DCSEVL */ /* PURPOSE Evaluate a Chebyshev series. */ /* LIBRARY SLATEC (FNLIB) */ /* CATEGORY C3A2 */ /* TYPE DOUBLE PRECISION (CSEVL-S, DCSEVL-D) */ /* KEYWORDS CHEBYSHEV SERIES, FNLIB, SPECIAL FUNCTIONS */ /* AUTHOR Fullerton, W., (LANL) */ static double dcsevl_(double x, const double *cs, int n) { /* System generated locals */ int i__1; /* Local variables */ int i__; double b0, b1, b2; int ni; double twox; /* DESCRIPTION */ /* Evaluate the N-term Chebyshev series CS at X. Adapted from */ /* a method presented in the paper by Broucke referenced below. */ /* Input Arguments -- */ /* X value at which the series is to be evaluated. */ /* CS array of N terms of a Chebyshev series. In evaluating */ /* CS, only half the first coefficient is summed. */ /* N number of terms in array CS. */ /* REFERENCES R. Broucke, Ten subroutines for the manipulation of */ /* Chebyshev series, Algorithm 446, Communications of */ /* the A.C.M. 16, (1973) pp. 254-256. */ /* L. Fox and I. B. Parker, Chebyshev Polynomials in */ /* Numerical Analysis, Oxford University Press, 1968, */ /* page 56. */ /* ROUTINES CALLED D1MACH, XERMSG */ /* REVISION HISTORY (YYMMDD) */ /* 770401 DATE WRITTEN */ /* 890831 Modified array declarations. (WRB) */ /* 890831 REVISION DATE from Version 3.2 */ /* 891214 Prologue converted to Version 4.0 format. (BAB) */ /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */ /* 900329 Prologued revised extensively and code rewritten to allow */ /* X to be slightly outside interval (-1,+1). (WRB) */ /* 920501 Reformatted the REFERENCES section. (WRB) */ /* 121094 f2c cleanup, made thread-safe (SGJ) */ /* END PROLOGUE DCSEVL */ /* Parameter adjustments */ --cs; /* Function Body */ /* FIRST EXECUTABLE STATEMENT DCSEVL */ b1 = 0.; b0 = 0.; twox = x * 2.; i__1 = n; for (i__ = 1; i__ <= i__1; ++i__) { b2 = b1; b1 = b0; ni = n + 1 - i__; b0 = twox * b1 - b2 + cs[ni]; /* L10: */ } return (b0 - b2) * .5; } /* dcsevl_ */ /* BEGIN PROLOGUE DERFCX (originally DERFC) */ /* PURPOSE Compute the scaled complementary error function. */ /* LIBRARY SLATEC (FNLIB) */ /* CATEGORY C8A, L5A1E */ /* TYPE DOUBLE PRECISION (ERFC-S, DERFC-D) */ /* KEYWORDS COMPLEMENTARY ERROR FUNCTION, ERFC, FNLIB, */ /* SPECIAL FUNCTIONS */ /* AUTHOR Fullerton, W., (LANL) */ static double derfcx(double x) { /* Initialized data */ const double erfcs[21] = { -.049046121234691808039984544033376, -.14226120510371364237824741899631, .010035582187599795575754676712933, -5.7687646997674847650827025509167e-4, 2.7419931252196061034422160791471e-5, -1.1043175507344507604135381295905e-6, 3.8488755420345036949961311498174e-8, -1.1808582533875466969631751801581e-9, 3.2334215826050909646402930953354e-11, -7.9910159470045487581607374708595e-13, 1.7990725113961455611967245486634e-14, -3.7186354878186926382316828209493e-16, 7.1035990037142529711689908394666e-18, -1.2612455119155225832495424853333e-19, 2.0916406941769294369170500266666e-21, -3.253973102931407298236416e-23, 4.7668672097976748332373333333333e-25, -6.5980120782851343155199999999999e-27, 8.6550114699637626197333333333333e-29, -1.0788925177498064213333333333333e-30, 1.2811883993017002666666666666666e-32 }; const double erc2cs[49] = { -.06960134660230950112739150826197, -.04110133936262089348982212084666, .003914495866689626881561143705244, -4.906395650548979161280935450774e-4, 7.157479001377036380760894141825e-5, -1.153071634131232833808232847912e-5, 1.994670590201997635052314867709e-6, -3.642666471599222873936118430711e-7, 6.944372610005012589931277214633e-8, -1.37122090210436601953460514121e-8, 2.788389661007137131963860348087e-9, -5.814164724331161551864791050316e-10, 1.23892049175275318118016881795e-10, -2.690639145306743432390424937889e-11, 5.94261435084791098244470968384e-12, -1.33238673575811957928775442057e-12, 3.028046806177132017173697243304e-13, -6.966648814941032588795867588954e-14, 1.620854541053922969812893227628e-14, -3.809934465250491999876913057729e-15, 9.040487815978831149368971012975e-16, -2.164006195089607347809812047003e-16, 5.222102233995854984607980244172e-17, -1.26972960236455533637241552778e-17, 3.109145504276197583836227412951e-18, -7.663762920320385524009566714811e-19, 1.90081925136274520253692973329e-19, -4.742207279069039545225655999965e-20, 1.189649200076528382880683078451e-20, -3.000035590325780256845271313066e-21, 7.602993453043246173019385277098e-22, -1.93590944760687288156981104913e-22, 4.951399124773337881000042386773e-23, -1.271807481336371879608621989888e-23, 3.280049600469513043315841652053e-24, -8.492320176822896568924792422399e-25, 2.206917892807560223519879987199e-25, -5.755617245696528498312819507199e-26, 1.506191533639234250354144051199e-26, -3.954502959018796953104285695999e-27, 1.041529704151500979984645051733e-27, -2.751487795278765079450178901333e-28, 7.29005820549755740899770368e-29, -1.936939645915947804077501098666e-29, 5.160357112051487298370054826666e-30, -1.3784193221930940993896448e-30, 3.691326793107069042251093333333e-31, -9.909389590624365420653226666666e-32, 2.666491705195388413323946666666e-32 }; const double erfccs[59] = { .0715179310202924774503697709496, -.0265324343376067157558893386681, .00171115397792085588332699194606, -1.63751663458517884163746404749e-4, 1.98712935005520364995974806758e-5, -2.84371241276655508750175183152e-6, 4.60616130896313036969379968464e-7, -8.22775302587920842057766536366e-8, 1.59214187277090112989358340826e-8, -3.29507136225284321486631665072e-9, 7.2234397604005554658126115389e-10, -1.66485581339872959344695966886e-10, 4.01039258823766482077671768814e-11, -1.00481621442573113272170176283e-11, 2.60827591330033380859341009439e-12, -6.99111056040402486557697812476e-13, 1.92949233326170708624205749803e-13, -5.47013118875433106490125085271e-14, 1.58966330976269744839084032762e-14, -4.7268939801975548392036958429e-15, 1.4358733767849847867287399784e-15, -4.44951056181735839417250062829e-16, 1.40481088476823343737305537466e-16, -4.51381838776421089625963281623e-17, 1.47452154104513307787018713262e-17, -4.89262140694577615436841552532e-18, 1.64761214141064673895301522827e-18, -5.62681717632940809299928521323e-19, 1.94744338223207851429197867821e-19, -6.82630564294842072956664144723e-20, 2.42198888729864924018301125438e-20, -8.69341413350307042563800861857e-21, 3.15518034622808557122363401262e-21, -1.15737232404960874261239486742e-21, 4.28894716160565394623737097442e-22, -1.60503074205761685005737770964e-22, 6.06329875745380264495069923027e-23, -2.31140425169795849098840801367e-23, 8.88877854066188552554702955697e-24, -3.44726057665137652230718495566e-24, 1.34786546020696506827582774181e-24, -5.31179407112502173645873201807e-25, 2.10934105861978316828954734537e-25, -8.43836558792378911598133256738e-26, 3.39998252494520890627359576337e-26, -1.3794523880732420900223837711e-26, 5.63449031183325261513392634811e-27, -2.316490434477065448234277527e-27, 9.58446284460181015263158381226e-28, -3.99072288033010972624224850193e-28, 1.67212922594447736017228709669e-28, -7.04599152276601385638803782587e-29, 2.97976840286420635412357989444e-29, -1.26252246646061929722422632994e-29, 5.39543870454248793985299653154e-30, -2.38099288253145918675346190062e-30, 1.0990528301027615735972668375e-30, -4.86771374164496572732518677435e-31, 1.52587726411035756763200828211e-31 }; const double sqrtpi = 1.77245385090551602729816748334115; /* System generated locals */ double d__1; /* Local variables */ double y; /* DERFCX(X) calculates the double precision scaled complementary * error function [DERFCX(X) = EXP(X^2) DERFC(X)] for double precision * argument X. Original SLATEC function DERFC modified by SGJ in 2012 * to compute DERFCX. */ /* Series for ERF on the interval 0. to 1.00000E+00 */ /* with weighted Error 1.28E-32 */ /* log weighted Error 31.89 */ /* significant figures required 31.05 */ /* decimal places required 32.55 */ /* Series for ERC2 on the interval 2.50000E-01 to 1.00000E+00 */ /* with weighted Error 2.67E-32 */ /* log weighted Error 31.57 */ /* significant figures required 30.31 */ /* decimal places required 32.42 */ /* Series for ERFC on the interval 0. to 2.50000E-01 */ /* with weighted error 1.53E-31 */ /* log weighted error 30.82 */ /* significant figures required 29.47 */ /* decimal places required 31.70 */ /* REFERENCES (NONE) */ /* ROUTINES CALLED D1MACH, DCSEVL, INITDS, XERMSG */ /* REVISION HISTORY (YYMMDD) */ /* 770701 DATE WRITTEN */ /* 890531 Changed all specific intrinsics to generic. (WRB) */ /* 890531 REVISION DATE from Version 3.2 */ /* 891214 Prologue converted to Version 4.0 format. (BAB) */ /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */ /* 920618 Removed space from variable names. (RWC, WRB) */ /* 121094 f2c cleanup, made thread-safe, converted erfc -> erfcx (SGJ) */ /* END PROLOGUE DERFCX */ /* FIRST EXECUTABLE STATEMENT DERFCX */ #if 0 /* Compute limits on the fly, which is somewhat wasteful since they will be the same for every call, but the alternative (as in the original Fortran code) of using static variables is not thread-safe. (We could use thread-local static variables, but that is nonstandard.) In practice, all machines nowadays use IEEE-754 arithmetic, so we should be able to just hard-code these. */ double xsml; int nterf; double sqeps; int nterc2; int nterfc; { double d1mach3 = DBL_EPSILON/FLT_RADIX; double eta = d1mach3 * .1; nterf = initds(erfcs, 21, eta); nterfc = initds(erfccs, 59, eta); nterc2 = initds(erc2cs, 49, eta); xsml = -sqrt(-log(sqrtpi * DBL_EPSILON/FLT_RADIX)); sqeps = sqrt(DBL_EPSILON/FLT_RADIX * 2.); } #else /* hard-code IEEE values, so as to be re-entrant */ const int nterf = 12; const int nterfc = 25; const int nterc2 = 24; const double xsml = -6.01368735691775061802858; const double sqeps = 1.490116119384765625e-08; #endif if (x > xsml) { goto L20; } /* ERFC(X) = 1.0 - ERF(X) FOR X .LT. XSML */ return 2. /* SGJ: */ * exp(x*x); L20: /* SGJ: removed x > xmax test, in which case derfc returned 0 (at L40). This was to account for underflow, which no longer occurs for erfcx. { double txmax; txmax = sqrt(-log(sqrtpi * DBL_MIN)); xmax = txmax - log(txmax) * .5 / txmax - .01; if (x > xmax) { goto L40; } } */ y = fabs(x); if (y > 1.) { goto L30; } /* ERFC(X) = 1.0 - ERF(X) FOR ABS(X) .LE. 1.0 */ if (y < sqeps) { return 1. - x * 2. / sqrtpi; /* note: exp(x*x) = 1 to mach. prec. */ } else { d__1 = x * 2. * x - 1.; return (1. - x * (dcsevl_(d__1, erfcs, nterf) + 1.)) /* SGJ: */ * exp(x*x); /* TODO: should be more efficient to use a Chebyshev approximation for erfcx directly, to avoid computation of exp(x*x) */ } /* ERFC(X) = 1.0 - ERF(X) FOR 1.0 .LT. ABS(X) .LE. XMAX */ L30: y *= y; { double ret; if (y <= 4.) { d__1 = (8. / y - 5.) / 3.; ret = (dcsevl_(d__1, erc2cs, nterc2) + .5) / fabs(x); /* SGJ: removed exp(-y) factor from erfc */ } else { d__1 = 8. / y - 1.; ret = (dcsevl_(d__1, erfccs, nterfc) + .5) / fabs(x); /* SGJ: removed exp(-y) factor from erfc */ } if (x < 0.) { ret = 2. * exp(y) - ret; /* SGJ: added exp(y) factor */ } return ret; } } /* derfcx */ ///////////////////////////////////////////////////////////////////////// // Compile with -DFADDEEVA_W_TEST to compile a little test program #ifdef FADDEEVA_W_TEST #include <cstdio> int main(void) { complex<double> z[10] = { complex<double>(624.2,-0.26123), complex<double>(-0.4,3.), complex<double>(0.6,2.), complex<double>(-1.,1.), complex<double>(-1.,-9.), complex<double>(-1.,9.), complex<double>(-0.0000000234545,1.1234), complex<double>(-3.,5.1), complex<double>(-53,30.1), complex<double>(0.0,0.12345) }; complex<double> w[10] = { // w(z), computed with WolframAlpha complex<double>(-3.78270245518980507452677445620103199303131110e-7, 0.000903861276433172057331093754199933411710053155), complex<double>(0.1764906227004816847297495349730234591778719532788, -0.02146550539468457616788719893991501311573031095617), complex<double>(0.2410250715772692146133539023007113781272362309451, 0.06087579663428089745895459735240964093522265589350), complex<double>(0.30474420525691259245713884106959496013413834051768, -0.20821893820283162728743734725471561394145872072738), complex<double>(7.317131068972378096865595229600561710140617977e34, 8.321873499714402777186848353320412813066170427e34), complex<double>(0.0615698507236323685519612934241429530190806818395, -0.00676005783716575013073036218018565206070072304635), complex<double>(0.3960793007699874918961319170187598400134746631, -5.593152259116644920546186222529802777409274656e-9), complex<double>(0.08217199226739447943295069917990417630675021771804, -0.04701291087643609891018366143118110965272615832184), complex<double>(0.00457246000350281640952328010227885008541748668738, -0.00804900791411691821818731763401840373998654987934), complex<double>(0.8746342859608052666092782112565360755791467973338452, 0.), }; for (int i = 0; i < 10; ++i) { complex<double> fw = Faddeeva_w(z[i],0.); double err = abs((fw - w[i]) / w[i]); printf("w(%g%+gi) = %g%+gi (vs. %g%+gi), rel. err. = %0.2g\n", real(z[i]),imag(z[i]), real(fw),imag(fw), real(w[i]),imag(w[i]), err); if (err > 1e-13) { printf("FAILURE -- relative error %g too large!\n", err); return 1; } } printf("SUCCESS\n"); return 0; } #endif
[ "pav@iki.fi" ]
pav@iki.fi
32b138170b13b83fcae8291dcfdae51a66c2303c
d2fc7fb55ce6acc1f274efc51789dc1dc06c3eb2
/tst/win32/com/timer.hpp
f11f27ee2a3a237e070e42ef6078512648e454a1
[]
no_license
Strongc/isu
31dc6b7049e009bc753d000307936141787942d1
d40f16c3841552b00329b16a61f5c9893ea6c4eb
refs/heads/master
2021-01-15T18:14:32.458687
2014-11-03T14:22:02
2014-11-03T14:22:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
203
hpp
#pragma once #include <Unknwn.h> class timer_interface :public IUnknown { public: typedef void(*timer_callback)(time_t); virtual HRESULT __stdcall set_timer(timer_callback, long millisecond) = 0; };
[ "sismvg@hotmail.com" ]
sismvg@hotmail.com
a562f764143155e8ab2405a32d2ded1d56f47183
a21d0a568f9ef3948b70e47a13325c29404f71d6
/Actions/MultipleSelection.cpp
ba724ab58be59c7a249172fa0c1f0a5e912cf815
[]
no_license
AFarid95/OOP-Project-Spring-2015
a5270fdf7fd4a9a4b9a45f260852c4d2bff1b71a
620051f68c3b4a6548a25e14327c74f8b4af792c
refs/heads/master
2022-12-18T07:25:14.018949
2020-09-26T00:01:30
2020-09-26T00:01:30
298,693,238
0
0
null
null
null
null
UTF-8
C++
false
false
1,095
cpp
#include "MultipleSelection.h" #include "..\ApplicationManager.h" #include "..\GUI\input.h" #include "..\GUI\Output.h" #include <sstream> //constructor: set the ApplicationManager pointer inside this action MultipleSelection::MultipleSelection(ApplicationManager *pAppManager):Action(pAppManager) { } void MultipleSelection::ReadActionParameters() { Input *pIn = pManager->GetInput(); Output *pOut = pManager->GetOutput(); pOut->PrintMessage("Select the statements you want"); pIn->GetPointClicked(Position); pOut->ClearStatusBar(); } void MultipleSelection::Execute() { while (1) { ReadActionParameters(); for (int i=0;i<pManager->GetStatCount();i++) { if (pManager->GetStatList()[i]==pManager->GetStatement(Position)) { for (int j=0;j<200;j++) { if (pManager->GetSelectedStat()[j]==NULL) { pManager->GetSelectedStat()[j]=pManager->GetStatList()[i]; pManager->GetSelectedStat()[j]->SetSelected(true); break; } } pManager->UpdateInterface(); } } if (pManager->GetStatement(Position)==NULL) break; } }
[ "ahmed.farid.95@live.com" ]
ahmed.farid.95@live.com
8a061445726e5bcf9011f7529b53a33ffe87cf0f
b8499de1a793500b47f36e85828f997e3954e570
/v2_3/build/Android/Preview/app/src/main/include/_root.MainView.Template4.h
b0f1123aca6f863536b157dc0a936c01e49b5fc0
[]
no_license
shrivaibhav/boysinbits
37ccb707340a14f31bd57ea92b7b7ddc4859e989
04bb707691587b253abaac064317715adb9a9fe5
refs/heads/master
2020-03-24T05:22:21.998732
2018-07-26T20:06:00
2018-07-26T20:06:00
142,485,250
0
0
null
2018-07-26T20:03:22
2018-07-26T19:30:12
C++
UTF-8
C++
false
false
1,263
h
// This file was generated based on build/Android/Preview/cache/ux15/MainView.g.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.UX.Template.h> namespace g{namespace Uno{namespace UX{struct Selector;}}} namespace g{struct MainView;} namespace g{struct MainView__Template4;} namespace g{ // public partial sealed class MainView.Template4 :97 // { ::g::Uno::UX::Template_type* MainView__Template4_typeof(); void MainView__Template4__ctor_1_fn(MainView__Template4* __this, ::g::MainView* parent, ::g::MainView* parentInstance); void MainView__Template4__New1_fn(MainView__Template4* __this, uObject** __retval); void MainView__Template4__New2_fn(::g::MainView* parent, ::g::MainView* parentInstance, MainView__Template4** __retval); struct MainView__Template4 : ::g::Uno::UX::Template { uWeak< ::g::MainView*> __parent1; uWeak< ::g::MainView*> __parentInstance1; static ::g::Uno::UX::Selector __selector0_; static ::g::Uno::UX::Selector& __selector0() { return MainView__Template4_typeof()->Init(), __selector0_; } void ctor_1(::g::MainView* parent, ::g::MainView* parentInstance); static MainView__Template4* New2(::g::MainView* parent, ::g::MainView* parentInstance); }; // } } // ::g
[ "shubhamanandoist@gmail.com" ]
shubhamanandoist@gmail.com
5354c52f2521f9e3012c3a9ff562f78205c6308f
9f9660f318732124b8a5154e6670e1cfc372acc4
/Case_save/Case20/case6/600/k
a836d6d7521be235245d267ae81d06c5e5c7ea60
[]
no_license
mamitsu2/aircond5
9a6857f4190caec15823cb3f975cdddb7cfec80b
20a6408fb10c3ba7081923b61e44454a8f09e2be
refs/heads/master
2020-04-10T22:41:47.782141
2019-09-02T03:42:37
2019-09-02T03:42:37
161,329,638
0
0
null
null
null
null
UTF-8
C++
false
false
8,757
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "600"; object k; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 459 ( 0.00272231 0.00330873 0.00351692 0.00389145 0.0042631 0.00464507 0.00505326 0.00536884 0.00553505 0.00550719 0.0052649 0.00480523 0.00411122 0.00296865 0.00192208 0.00034162 0.000458355 0.00057739 0.000654229 0.000624222 0.000523859 0.000372657 0.000261672 0.000203233 0.000174755 0.000157532 0.000145825 0.000138067 0.000133396 0.000135363 0.000155538 0.000268111 0.000509724 0.000353318 0.00472078 0.00870662 0.00554554 0.00598304 0.00663011 0.00740003 0.00822976 0.00902359 0.00959361 0.00980714 0.00961064 0.00902061 0.00808496 0.00673605 0.00518488 0.00317982 0.00168154 0.000395432 0.000701741 0.00121794 0.00148743 0.00158375 0.00150606 0.00121123 0.000954299 0.000772777 0.000654866 0.00058156 0.000534602 0.000498875 0.000467145 0.000441447 0.000402176 0.000622453 0.000963853 0.000482596 0.00676492 0.0151274 0.00665957 0.006602 0.00720781 0.00807603 0.00908351 0.0100084 0.010653 0.0109517 0.0108696 0.0104133 0.00959515 0.00855236 0.00736355 0.00591941 0.00331225 0.000656196 0.00107103 0.00137519 0.00163613 0.00177394 0.00173271 0.001267 0.00093805 0.000718487 0.000570305 0.000468582 0.000396995 0.000344875 0.000305618 0.000278818 0.000306072 0.000385233 0.00109282 0.000764391 0.00904193 0.0238397 0.00811961 0.00680589 0.00729625 0.00833834 0.00958783 0.0105372 0.0111301 0.0114358 0.0114117 0.0110059 0.0102905 0.00938075 0.00839225 0.00730025 0.00545379 0.00424387 0.00329949 0.00285697 0.00266014 0.00255749 0.00246249 0.00231491 0.00193232 0.00165392 0.00145036 0.00129402 0.00116685 0.00105434 0.000951136 0.000850703 0.000745825 0.000582016 0.000506714 0.00105095 0.000861104 0.0117142 0.0354279 0.0116179 0.00749162 0.00779336 0.00939221 0.0107684 0.0114979 0.0119107 0.0121267 0.0120574 0.0116012 0.0107633 0.00967755 0.00853737 0.00746386 0.00639592 0.00563517 0.00500055 0.00451005 0.00413356 0.00381289 0.00351317 0.00322813 0.00296368 0.00272349 0.00251298 0.00232554 0.00215128 0.00197499 0.00177158 0.00153926 0.00128942 0.00103497 0.00084127 0.000913273 0.00109489 0.00101568 0.0010523 0.00113641 0.0149686 0.047909 0.0200658 0.0107652 0.0105635 0.0125437 0.0130681 0.0131559 0.0132433 0.0133147 0.0131446 0.0125261 0.0114289 0.0100271 0.00861018 0.00741876 0.00656631 0.00605434 0.00569896 0.00536666 0.00501018 0.00462951 0.00424267 0.00387786 0.00355925 0.00328945 0.00305969 0.00286181 0.00268872 0.0025288 0.00236398 0.00215957 0.00192386 0.00167804 0.00147063 0.00137669 0.00140711 0.00151213 0.0025127 0.00189312 0.0182125 0.0556859 0.0335958 0.021553 0.0194181 0.0176937 0.0162776 0.0154577 0.0151725 0.0150869 0.0147588 0.0138758 0.0124053 0.010596 0.00886789 0.0075472 0.0067574 0.00636628 0.00608766 0.00576051 0.00535785 0.00491066 0.00446211 0.0040526 0.00370865 0.00343651 0.00322906 0.00308093 0.00298725 0.00295378 0.00297987 0.00304909 0.00307691 0.00303723 0.00303004 0.0031398 0.00327859 0.00320068 0.00406702 0.00267515 0.0188515 0.0528536 0.0386911 0.0308936 0.0252426 0.0211405 0.018755 0.0177637 0.0175931 0.0175443 0.0169831 0.0156115 0.0135185 0.0111006 0.00900776 0.0075476 0.0067699 0.00637673 0.00603812 0.00563315 0.00516708 0.00468348 0.00422465 0.00382239 0.00349519 0.00325123 0.00309754 0.00304885 0.00312057 0.00331452 0.00363292 0.00406831 0.00462282 0.00527688 0.00598359 0.00683068 0.00739673 0.00721222 0.0101604 0.00306172 0.0178876 0.0249032 0.0231423 0.0205715 0.0188205 0.018458 0.0191238 0.020256 0.0211606 0.0211093 0.019662 0.0170324 0.0137303 0.0102895 0.00818288 0.00701769 0.00638215 0.00596619 0.0055736 0.00514066 0.00467743 0.00421542 0.00378332 0.0034016 0.00308419 0.00284458 0.00270244 0.0026807 0.00278686 0.00299729 0.00326747 0.00356147 0.0038567 0.00413965 0.0044011 0.00460826 0.00468483 0.00469646 0.00470781 0.00288229 0.00610772 0.0122685 0.0206393 0.0251679 0.0274032 0.0277506 0.0261941 0.0225869 0.0175827 0.0133694 0.0102485 0.0081561 0.00691832 0.00620067 0.00574639 0.00538549 0.00502741 0.00464887 0.0042603 0.0038799 0.00352294 0.00320132 0.00292714 0.00271676 0.00259096 0.00256866 0.00265757 0.00285061 0.00313211 0.00348399 0.00388504 0.00430985 0.00472343 0.0050705 0.00525251 0.00510405 0.00433713 0.002464 0.00689696 0.0234171 0.0284004 0.0273909 0.0252101 0.0221121 0.0184307 0.0147816 0.011527 0.00906037 0.00739023 0.00635407 0.00574061 0.00537217 0.00513141 0.00494392 0.00476849 0.00458943 0.00440457 0.00421674 0.00403072 0.00385402 0.00369852 0.00358095 0.00352106 0.0035367 0.00363642 0.00381288 0.00404117 0.00428326 0.00449918 0.00466263 0.00476193 0.00478569 0.00464158 0.00420665 0.00325453 0.00266653 0.00612887 0.00695146 0.00756601 0.00928014 0.00879019 0.00834756 0.00783572 0.00704229 0.00608346 0.00511964 0.00426431 0.00360138 0.00314658 0.00284922 0.00265128 0.00251073 0.00239979 0.00230139 0.00220819 0.00211963 0.00203796 0.00196574 0.00190503 0.00185749 0.00182473 0.00180843 0.00181028 0.00183159 0.00187292 0.00193405 0.00201439 0.00211322 0.00222823 0.00235683 0.00248137 0.00251456 0.00234607 0.00192086 0.00176907 0.00263824 ) ; boundaryField { floor { type kqRWallFunction; value nonuniform List<scalar> 29 ( 0.00192208 0.00034162 0.000458355 0.00057739 0.000654229 0.000624222 0.000523859 0.000372657 0.000261672 0.000203233 0.000174755 0.000157532 0.000145825 0.000138067 0.000133396 0.000135363 0.000155538 0.000268111 0.000509724 0.000353318 0.000353318 0.000482596 0.000764391 0.000861104 0.00192208 0.00034162 0.000395432 0.000656196 0.00424387 ) ; } ceiling { type kqRWallFunction; value nonuniform List<scalar> 43 ( 0.00612887 0.00695146 0.00756601 0.00928014 0.00879019 0.00834756 0.00783572 0.00704229 0.00608346 0.00511964 0.00426431 0.00360138 0.00314658 0.00284922 0.00265128 0.00251073 0.00239979 0.00230139 0.00220819 0.00211963 0.00203796 0.00196574 0.00190503 0.00185749 0.00182473 0.00180843 0.00181028 0.00183159 0.00187292 0.00193405 0.00201439 0.00211322 0.00222823 0.00235683 0.00248137 0.00251456 0.00234607 0.00192086 0.00176907 0.00263824 0.0178876 0.0249032 0.00689696 ) ; } sWall { type kqRWallFunction; value uniform 0.00612887; } nWall { type kqRWallFunction; value nonuniform List<scalar> 6(0.00113641 0.00189312 0.00267515 0.002464 0.00266653 0.00263824); } sideWalls { type empty; } glass1 { type kqRWallFunction; value nonuniform List<scalar> 9(0.00272231 0.00472078 0.00676492 0.00904193 0.0117142 0.0149686 0.0182125 0.0188515 0.0178876); } glass2 { type kqRWallFunction; value nonuniform List<scalar> 2(0.00306172 0.00288229); } sun { type kqRWallFunction; value nonuniform List<scalar> 14 ( 0.00272231 0.00330873 0.00351692 0.00389145 0.0042631 0.00464507 0.00505326 0.00536884 0.00553505 0.00550719 0.0052649 0.00480523 0.00411122 0.00296865 ) ; } heatsource1 { type kqRWallFunction; value nonuniform List<scalar> 3(0.00101568 0.0010523 0.00113641); } heatsource2 { type kqRWallFunction; value nonuniform List<scalar> 4(0.00317982 0.00168154 0.00168154 0.00331225); } Table_master { type kqRWallFunction; value nonuniform List<scalar> 9(0.001267 0.00093805 0.000718487 0.000570305 0.000468582 0.000396995 0.000344875 0.000305618 0.000278818); } Table_slave { type kqRWallFunction; value nonuniform List<scalar> 9(0.00193232 0.00165392 0.00145036 0.00129402 0.00116685 0.00105434 0.000951136 0.000850703 0.000745825); } inlet { type turbulentIntensityKineticEnergyInlet; intensity 0.05; value uniform 0.0003375; } outlet { type zeroGradient; } } // ************************************************************************* //
[ "mitsuaki.makino@tryeting.jp" ]
mitsuaki.makino@tryeting.jp
239a09a881f3bfe0a0b6a0cfae0f02b29ce96d64
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/squid/gumtree/squid_old_log_36.cpp
646110c4affb2ec08d73f0d65dd23d5e9bfa1896
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
29
cpp
buf.Printf("Allow: 204\r\n");
[ "993273596@qq.com" ]
993273596@qq.com
ba9f23b7d52039f7a5eeb6d5cb0a869b21260eb5
2a8a290eb1d0703a7c7b21429b07870c5ffa868e
/Include/NiTriBasedGeom.h
03c345f60431fe5552b2a25a1f98120d2acdfb05
[]
no_license
sigmaco/gamebryo-v32
b935d737b773497bf9e663887e326db4eca81885
0709c2570e21f6bb06a9382f9e1aa524070f3751
refs/heads/master
2023-03-31T13:56:37.844472
2021-04-17T02:30:46
2021-04-17T02:30:46
198,067,949
4
4
null
2021-04-17T02:30:47
2019-07-21T14:39:54
C++
UTF-8
C++
false
false
2,145
h
// EMERGENT GAME TECHNOLOGIES PROPRIETARY INFORMATION // // This software is supplied under the terms of a license agreement or // nondisclosure agreement with Emergent Game Technologies and may not // be copied or disclosed except in accordance with the terms of that // agreement. // // Copyright (c) 1996-2009 Emergent Game Technologies. // All Rights Reserved. // // Emergent Game Technologies, Calabasas, CA 91302 // http://www.emergent.net #pragma once #ifndef EE_REMOVE_BACK_COMPAT_STREAMING #ifndef NITRIBASEDGEOM_H #define NITRIBASEDGEOM_H #include "NiGeometry.h" #include "NiTriBasedGeomData.h" /** This class is deprecated. It only exists to support loading old NIF files. */ class NIMAIN_ENTRY NiTriBasedGeom : public NiGeometry { public: NiDeclareRTTI; NiDeclareAbstractClone(NiTriBasedGeom); NiDeclareAbstractStream; public: virtual ~NiTriBasedGeom(); // shared data acess virtual void SetModelData(NiGeometryData* pkModelData); // triangles inline unsigned short GetTriangleCount() const; virtual void GetModelTriangle(unsigned short usTriangle, NiPoint3*& pkP0, NiPoint3*& pkP1, NiPoint3*& pkP2) = 0; inline void SetActiveTriangleCount(unsigned short usActive); inline unsigned short GetActiveTriangleCount() const; // *** begin Emergent internal use only *** inline void GetTriangleIndices(unsigned short i, unsigned short& i0, unsigned short& i1, unsigned short& i2) const; // *** end Emergent internal use only *** protected: // The constructed object shares the input data. NiTriBasedGeom(NiTriBasedGeomData* pkModelData); // streaming support NiTriBasedGeom(); }; typedef efd::SmartPointer<NiTriBasedGeom> NiTriBasedGeomPtr; //------------------------------------------------------------------------------------------------ // Inline include #include "NiTriBasedGeom.inl" //------------------------------------------------------------------------------------------------ #endif #endif // #ifndef EE_REMOVE_BACK_COMPAT_STREAMING
[ "veryzon@outlook.com.br" ]
veryzon@outlook.com.br
c4fac832644a1848125e3a07422588cbaa55cf24
537c53e5df9b388662f7cc7ff1caca3dae70267b
/light.h
c2dc62543fab1be327593b29573026d66998d32b
[]
no_license
fwzhuangCg/VirtualStudio_2017_02_07
851297b700318d6dbe670e4ac8c9cc0634966ad2
a7f46787f8bffbbf94e10aaf8dd25d041c708856
refs/heads/master
2021-09-15T07:03:07.944954
2018-05-28T08:18:14
2018-05-28T08:18:14
null
0
0
null
null
null
null
GB18030
C++
false
false
1,419
h
#ifndef LIGHT_H #define LIGHT_H #include <QColor> #include <QVector3D> #include "scene_node.h" enum LightType { LIGHTTYPE_AMBIENT, LIGHTTYPE_DIRECTIONAL, LIGHTTYPE_POINT, LIGHTTYPE_SPOT }; /************************************************************************/ /* 光源 */ /************************************************************************/ class Light : public SceneNode { public: QColor color_; // 颜色 QVector3D spot_direction_; // 方向 float spot_cutoff_; // cutoff angle of spot light float spot_exponent_; // falloff exponent of spot light float constant_attenuation_; // constant attenuation factor for point and spot light float lineaer_attenuation_; // linear attenuation factor for point and spot light float quadratic_attenuation_; // quadratic attenuation factor for point and spot light Light() : SceneNode(), color_(0.5f, 0.5f, 0.5f, 1.0f), spot_direction_(0.0f, 0.0f, -1.0f), spot_cutoff_(180.0f), spot_exponent_(0.0f), constant_attenuation_(1.0f), lineaer_attenuation_(0.0f), quadratic_attenuation_(0.0f), light_type_(LIGHTTYPE_POINT) {} ~Light() { destroy(); } protected: LightType light_type_; public: LightType getLightType() { return light_type_; } void setLightType(LightType type) { light_type_ = type; } private: void destroy(); }; #endif // LIGHT_H
[ "coaspire@COASPIRE-PC" ]
coaspire@COASPIRE-PC
ee28ee7760d12993fd672e3acfada8cf5b84df6a
740fdf1cca74bdb8f930a7907a48f9bdd9b5fbd3
/chrome/browser/chromeos/display/display_preferences_unittest.cc
6255d155af46bea6fb787cebeebb850db5ea2be8
[ "BSD-3-Clause" ]
permissive
hefen1/chromium
a1384249e2bb7669df189235a1ff49ac11fc5790
52f0b6830e000ca7c5e9aa19488af85be792cc88
refs/heads/master
2016-09-05T18:20:24.971432
2015-03-23T14:53:29
2015-03-23T14:53:29
32,579,801
0
2
null
null
null
null
UTF-8
C++
false
false
35,430
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/chromeos/display/display_preferences.h" #include <string> #include <vector> #include "ash/content/display/screen_orientation_controller_chromeos.h" #include "ash/display/display_controller.h" #include "ash/display/display_layout_store.h" #include "ash/display/display_manager.h" #include "ash/display/resolution_notification_controller.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/display_manager_test_api.h" #include "ash/wm/maximize_mode/maximize_mode_controller.h" #include "base/prefs/scoped_user_pref_update.h" #include "base/prefs/testing_pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "chrome/browser/chromeos/display/display_configuration_observer.h" #include "chrome/browser/chromeos/login/users/mock_user_manager.h" #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_browser_process.h" #include "ui/display/chromeos/display_configurator.h" #include "ui/gfx/geometry/vector3d_f.h" #include "ui/message_center/message_center.h" using ash::ResolutionNotificationController; namespace chromeos { namespace { const char kPrimaryIdKey[] = "primary-id"; const char kMirroredKey[] = "mirrored"; const char kPositionKey[] = "position"; const char kOffsetKey[] = "offset"; // The mean acceleration due to gravity on Earth in m/s^2. const float kMeanGravity = 9.80665f; bool IsRotationLocked() { return ash::Shell::GetInstance() ->screen_orientation_controller() ->rotation_locked(); } class DisplayPreferencesTest : public ash::test::AshTestBase { protected: DisplayPreferencesTest() : mock_user_manager_(new MockUserManager), user_manager_enabler_(mock_user_manager_) { } ~DisplayPreferencesTest() override {} void SetUp() override { EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) .WillRepeatedly(testing::Return(false)); EXPECT_CALL(*mock_user_manager_, Shutdown()); ash::test::AshTestBase::SetUp(); RegisterDisplayLocalStatePrefs(local_state_.registry()); TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); observer_.reset(new DisplayConfigurationObserver()); } void TearDown() override { observer_.reset(); TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); ash::test::AshTestBase::TearDown(); } void LoggedInAsUser() { EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) .WillRepeatedly(testing::Return(true)); EXPECT_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) .WillRepeatedly(testing::Return(true)); } void LoggedInAsGuest() { EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) .WillRepeatedly(testing::Return(true)); EXPECT_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) .WillRepeatedly(testing::Return(false)); EXPECT_CALL(*mock_user_manager_, IsLoggedInAsSupervisedUser()) .WillRepeatedly(testing::Return(false)); } // Do not use the implementation of display_preferences.cc directly to avoid // notifying the update to the system. void StoreDisplayLayoutPrefForName(const std::string& name, ash::DisplayLayout::Position layout, int offset, int64 primary_id) { DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); ash::DisplayLayout display_layout(layout, offset); display_layout.primary_id = primary_id; DCHECK(!name.empty()); base::DictionaryValue* pref_data = update.Get(); scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); if (pref_data->HasKey(name)) { base::Value* value = NULL; if (pref_data->Get(name, &value) && value != NULL) layout_value.reset(value->DeepCopy()); } if (ash::DisplayLayout::ConvertToValue(display_layout, layout_value.get())) pref_data->Set(name, layout_value.release()); } void StoreDisplayLayoutPrefForPair(int64 id1, int64 id2, ash::DisplayLayout::Position layout, int offset) { StoreDisplayLayoutPrefForName( base::Int64ToString(id1) + "," + base::Int64ToString(id2), layout, offset, id1); } void StoreDisplayLayoutPrefForSecondary(int64 id, ash::DisplayLayout::Position layout, int offset, int64 primary_id) { StoreDisplayLayoutPrefForName( base::Int64ToString(id), layout, offset, primary_id); } void StoreDisplayOverscan(int64 id, const gfx::Insets& insets) { DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); const std::string name = base::Int64ToString(id); base::DictionaryValue* pref_data = update.Get(); base::DictionaryValue* insets_value = new base::DictionaryValue(); insets_value->SetInteger("insets_top", insets.top()); insets_value->SetInteger("insets_left", insets.left()); insets_value->SetInteger("insets_bottom", insets.bottom()); insets_value->SetInteger("insets_right", insets.right()); pref_data->Set(name, insets_value); } void StoreColorProfile(int64 id, const std::string& profile) { DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); const std::string name = base::Int64ToString(id); base::DictionaryValue* pref_data = update.Get(); base::DictionaryValue* property = new base::DictionaryValue(); property->SetString("color_profile_name", profile); pref_data->Set(name, property); } void StoreDisplayRotationPrefsForTest(bool rotation_lock, gfx::Display::Rotation rotation) { DictionaryPrefUpdate update(local_state(), prefs::kDisplayRotationLock); base::DictionaryValue* pref_data = update.Get(); pref_data->SetBoolean("lock", rotation_lock); pref_data->SetInteger("orientation", static_cast<int>(rotation)); } std::string GetRegisteredDisplayLayoutStr(int64 id1, int64 id2) { ash::DisplayIdPair pair; pair.first = id1; pair.second = id2; return ash::Shell::GetInstance()->display_manager()->layout_store()-> GetRegisteredDisplayLayout(pair).ToString(); } PrefService* local_state() { return &local_state_; } private: MockUserManager* mock_user_manager_; // Not owned. ScopedUserManagerEnabler user_manager_enabler_; TestingPrefServiceSimple local_state_; scoped_ptr<DisplayConfigurationObserver> observer_; DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); }; } // namespace TEST_F(DisplayPreferencesTest, PairedLayoutOverrides) { UpdateDisplay("100x100,200x200"); int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); int64 dummy_id = id2 + 1; ASSERT_NE(id1, dummy_id); StoreDisplayLayoutPrefForPair(id1, id2, ash::DisplayLayout::TOP, 20); StoreDisplayLayoutPrefForPair(id1, dummy_id, ash::DisplayLayout::LEFT, 30); StoreDisplayPowerStateForTest( chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); ash::Shell* shell = ash::Shell::GetInstance(); LoadDisplayPreferences(true); // DisplayPowerState should be ignored at boot. EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, shell->display_configurator()->requested_power_state()); shell->display_manager()->UpdateDisplays(); // Check if the layout settings are notified to the system properly. // The paired layout overrides old layout. // Inverted one of for specified pair (id1, id2). Not used for the pair // (id1, dummy_id) since dummy_id is not connected right now. EXPECT_EQ("top, 20", shell->display_manager()->GetCurrentDisplayLayout().ToString()); EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(id1, id2)); EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(id1, dummy_id)); } TEST_F(DisplayPreferencesTest, BasicStores) { ash::DisplayController* display_controller = ash::Shell::GetInstance()->display_controller(); ash::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); ash::test::DisplayManagerTestApi test_api(display_manager); test_api.SetInternalDisplayId(id1); int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); int64 dummy_id = id2 + 1; ASSERT_NE(id1, dummy_id); std::vector<ui::ColorCalibrationProfile> profiles; profiles.push_back(ui::COLOR_PROFILE_STANDARD); profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); profiles.push_back(ui::COLOR_PROFILE_MOVIE); profiles.push_back(ui::COLOR_PROFILE_READING); // Allows only |id1|. test_api.SetAvailableColorProfiles(id1, profiles); display_manager->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); display_manager->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); LoggedInAsUser(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); SetCurrentDisplayLayout(layout); StoreDisplayLayoutPrefForTest( id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); // Can't switch to a display that does not exist. display_controller->SetPrimaryDisplayId(dummy_id); EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90); EXPECT_TRUE(display_manager->SetDisplayUIScale(id1, 1.25f)); EXPECT_FALSE(display_manager->SetDisplayUIScale(id2, 1.25f)); const base::DictionaryValue* displays = local_state()->GetDictionary(prefs::kSecondaryDisplays); const base::DictionaryValue* layout_value = NULL; std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); ash::DisplayLayout stored_layout; EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*layout_value, &stored_layout)); EXPECT_EQ(layout.position, stored_layout.position); EXPECT_EQ(layout.offset, stored_layout.offset); bool mirrored = true; EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); EXPECT_FALSE(mirrored); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayProperties); const base::DictionaryValue* property = NULL; EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); int ui_scale = 0; int rotation = 0; EXPECT_TRUE(property->GetInteger("rotation", &rotation)); EXPECT_TRUE(property->GetInteger("ui-scale", &ui_scale)); EXPECT_EQ(1, rotation); EXPECT_EQ(1250, ui_scale); // Internal display never registered the resolution. int width = 0, height = 0; EXPECT_FALSE(property->GetInteger("width", &width)); EXPECT_FALSE(property->GetInteger("height", &height)); int top = 0, left = 0, bottom = 0, right = 0; EXPECT_TRUE(property->GetInteger("insets_top", &top)); EXPECT_TRUE(property->GetInteger("insets_left", &left)); EXPECT_TRUE(property->GetInteger("insets_bottom", &bottom)); EXPECT_TRUE(property->GetInteger("insets_right", &right)); EXPECT_EQ(10, top); EXPECT_EQ(11, left); EXPECT_EQ(12, bottom); EXPECT_EQ(13, right); std::string color_profile; EXPECT_TRUE(property->GetString("color_profile_name", &color_profile)); EXPECT_EQ("dynamic", color_profile); EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); EXPECT_TRUE(property->GetInteger("rotation", &rotation)); EXPECT_TRUE(property->GetInteger("ui-scale", &ui_scale)); EXPECT_EQ(0, rotation); // ui_scale works only on 2x scale factor/1st display. EXPECT_EQ(1000, ui_scale); EXPECT_FALSE(property->GetInteger("insets_top", &top)); EXPECT_FALSE(property->GetInteger("insets_left", &left)); EXPECT_FALSE(property->GetInteger("insets_bottom", &bottom)); EXPECT_FALSE(property->GetInteger("insets_right", &right)); // |id2| doesn't have the color_profile because it doesn't have 'dynamic' in // its available list. EXPECT_FALSE(property->GetString("color_profile_name", &color_profile)); // Resolution is saved only when the resolution is set // by DisplayManager::SetDisplayMode width = 0; height = 0; EXPECT_FALSE(property->GetInteger("width", &width)); EXPECT_FALSE(property->GetInteger("height", &height)); ash::DisplayMode mode(gfx::Size(300, 200), 60.0f, false, true); mode.device_scale_factor = 1.25f; display_manager->SetDisplayMode(id2, mode); display_controller->SetPrimaryDisplayId(id2); EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); width = 0; height = 0; // Internal display shouldn't store its resolution. EXPECT_FALSE(property->GetInteger("width", &width)); EXPECT_FALSE(property->GetInteger("height", &height)); // External display's resolution must be stored this time because // it's not best. int device_scale_factor = 0; EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); EXPECT_TRUE(property->GetInteger("width", &width)); EXPECT_TRUE(property->GetInteger("height", &height)); EXPECT_TRUE(property->GetInteger( "device-scale-factor", &device_scale_factor)); EXPECT_EQ(300, width); EXPECT_EQ(200, height); EXPECT_EQ(1250, device_scale_factor); // The layout remains the same. EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*layout_value, &stored_layout)); EXPECT_EQ(layout.position, stored_layout.position); EXPECT_EQ(layout.offset, stored_layout.offset); EXPECT_EQ(id2, stored_layout.primary_id); mirrored = true; EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); EXPECT_FALSE(mirrored); std::string primary_id_str; EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); EXPECT_EQ(base::Int64ToString(id2), primary_id_str); SetCurrentDisplayLayout( ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 20)); UpdateDisplay("1+0-200x200*2,1+0-200x200"); // Mirrored. int offset = 0; std::string position; EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); EXPECT_EQ("top", position); EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); EXPECT_EQ(-20, offset); mirrored = false; EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); EXPECT_TRUE(mirrored); EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); EXPECT_EQ(base::Int64ToString(id2), primary_id_str); EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); EXPECT_FALSE(property->GetInteger("width", &width)); EXPECT_FALSE(property->GetInteger("height", &height)); // External display's selected resolution must not change // by mirroring. EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); EXPECT_TRUE(property->GetInteger("width", &width)); EXPECT_TRUE(property->GetInteger("height", &height)); EXPECT_EQ(300, width); EXPECT_EQ(200, height); // Set new display's selected resolution. display_manager->RegisterDisplayProperty( id2 + 1, gfx::Display::ROTATE_0, 1.0f, NULL, gfx::Size(500, 400), 1.0f, ui::COLOR_PROFILE_STANDARD); UpdateDisplay("200x200*2, 600x500#600x500|500x400"); // Update key as the 2nd display gets new id. id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); EXPECT_EQ("right", position); EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); EXPECT_EQ(0, offset); mirrored = true; EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); EXPECT_FALSE(mirrored); EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); EXPECT_EQ(base::Int64ToString(id1), primary_id_str); // Best resolution should not be saved. EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); EXPECT_FALSE(property->GetInteger("width", &width)); EXPECT_FALSE(property->GetInteger("height", &height)); // Set yet another new display's selected resolution. display_manager->RegisterDisplayProperty( id2 + 1, gfx::Display::ROTATE_0, 1.0f, NULL, gfx::Size(500, 400), 1.0f, ui::COLOR_PROFILE_STANDARD); // Disconnect 2nd display first to generate new id for external display. UpdateDisplay("200x200*2"); UpdateDisplay("200x200*2, 500x400#600x500|500x400%60.0f"); // Update key as the 2nd display gets new id. id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); EXPECT_EQ("right", position); EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); EXPECT_EQ(0, offset); mirrored = true; EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); EXPECT_FALSE(mirrored); EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); EXPECT_EQ(base::Int64ToString(id1), primary_id_str); // External display's selected resolution must be updated. EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); EXPECT_TRUE(property->GetInteger("width", &width)); EXPECT_TRUE(property->GetInteger("height", &height)); EXPECT_EQ(500, width); EXPECT_EQ(400, height); } TEST_F(DisplayPreferencesTest, PreventStore) { ResolutionNotificationController::SuppressTimerForTest(); LoggedInAsUser(); UpdateDisplay("400x300#500x400|400x300|300x200"); int64 id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); // Set display's resolution in single display. It creates the notification and // display preferences should not stored meanwhile. ash::Shell* shell = ash::Shell::GetInstance(); ash::DisplayMode old_mode; ash::DisplayMode new_mode; old_mode.size = gfx::Size(400, 300); new_mode.size = gfx::Size(500, 400); if (shell->display_manager()->SetDisplayMode(id, new_mode)) { shell->resolution_notification_controller()->PrepareNotification( id, old_mode, new_mode, base::Closure()); } UpdateDisplay("500x400#500x400|400x300|300x200"); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayProperties); const base::DictionaryValue* property = NULL; EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); int width = 0, height = 0; EXPECT_FALSE(property->GetInteger("width", &width)); EXPECT_FALSE(property->GetInteger("height", &height)); // Revert the change. When timeout, 2nd button is revert. message_center::MessageCenter::Get()->ClickOnNotificationButton( ResolutionNotificationController::kNotificationId, 1); RunAllPendingInMessageLoop(); EXPECT_FALSE( message_center::MessageCenter::Get()->FindVisibleNotificationById( ResolutionNotificationController::kNotificationId)); // Once the notification is removed, the specified resolution will be stored // by SetDisplayMode. ash::Shell::GetInstance()->display_manager()->SetDisplayMode( id, ash::DisplayMode(gfx::Size(300, 200), 60.0f, false, true)); UpdateDisplay("300x200#500x400|400x300|300x200"); property = NULL; EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); EXPECT_TRUE(property->GetInteger("width", &width)); EXPECT_TRUE(property->GetInteger("height", &height)); EXPECT_EQ(300, width); EXPECT_EQ(200, height); } TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { UpdateDisplay("100x100,200x200"); int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::DisplayController* display_controller = ash::Shell::GetInstance()->display_controller(); display_controller->SwapPrimaryDisplay(); ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); LoggedInAsUser(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); SetCurrentDisplayLayout(layout); layout = layout.Invert(); const base::DictionaryValue* displays = local_state()->GetDictionary(prefs::kSecondaryDisplays); const base::DictionaryValue* new_value = NULL; std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); EXPECT_TRUE(displays->GetDictionary(key, &new_value)); ash::DisplayLayout stored_layout; EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); EXPECT_EQ(layout.position, stored_layout.position); EXPECT_EQ(layout.offset, stored_layout.offset); EXPECT_EQ(id2, stored_layout.primary_id); display_controller->SwapPrimaryDisplay(); EXPECT_TRUE(displays->GetDictionary(key, &new_value)); EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); EXPECT_EQ(layout.position, stored_layout.position); EXPECT_EQ(layout.offset, stored_layout.offset); EXPECT_EQ(id1, stored_layout.primary_id); } TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { ash::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); StoreColorProfile(id1, "dynamic"); LoggedInAsUser(); LoadDisplayPreferences(false); // id1's available color profiles list is empty, means somehow the color // profile suport is temporary in trouble. EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, display_manager->GetDisplayInfo(id1).color_profile()); // Once the profile is supported, the color profile should be restored. std::vector<ui::ColorCalibrationProfile> profiles; profiles.push_back(ui::COLOR_PROFILE_STANDARD); profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); profiles.push_back(ui::COLOR_PROFILE_MOVIE); profiles.push_back(ui::COLOR_PROFILE_READING); ash::test::DisplayManagerTestApi test_api(display_manager); test_api.SetAvailableColorProfiles(id1, profiles); LoadDisplayPreferences(false); EXPECT_EQ(ui::COLOR_PROFILE_DYNAMIC, display_manager->GetDisplayInfo(id1).color_profile()); } TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { ash::DisplayController* display_controller = ash::Shell::GetInstance()->display_controller(); ash::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); UpdateDisplay("200x200*2,200x200"); LoggedInAsGuest(); int64 id1 = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); ash::test::DisplayManagerTestApi(display_manager) .SetInternalDisplayId(id1); int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); SetCurrentDisplayLayout(layout); display_manager->SetDisplayUIScale(id1, 1.25f); display_controller->SetPrimaryDisplayId(id2); int64 new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); display_controller->SetOverscanInsets( new_primary, gfx::Insets(10, 11, 12, 13)); display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90); // Does not store the preferences locally. EXPECT_FALSE(local_state()->FindPreference( prefs::kSecondaryDisplays)->HasUserSetting()); EXPECT_FALSE(local_state()->FindPreference( prefs::kDisplayProperties)->HasUserSetting()); // Settings are still notified to the system. gfx::Screen* screen = gfx::Screen::GetNativeScreen(); EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); EXPECT_EQ(ash::DisplayLayout::BOTTOM, display_manager->GetCurrentDisplayLayout().position); EXPECT_EQ(-10, display_manager->GetCurrentDisplayLayout().offset); const gfx::Display& primary_display = screen->GetPrimaryDisplay(); EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); EXPECT_EQ(1.25f, info1.configured_ui_scale()); const ash::DisplayInfo& info_primary = display_manager->GetDisplayInfo(new_primary); EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.rotation()); EXPECT_EQ(1.0f, info_primary.configured_ui_scale()); } TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) { EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); // Stores display prefs without login, which still stores the power state. StoreDisplayPrefs(); EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); } TEST_F(DisplayPreferencesTest, StorePowerStateGuest) { EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); LoggedInAsGuest(); StoreDisplayPrefs(); EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); } TEST_F(DisplayPreferencesTest, StorePowerStateNormalUser) { EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); LoggedInAsUser(); StoreDisplayPrefs(); EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); } TEST_F(DisplayPreferencesTest, DisplayPowerStateAfterRestart) { StoreDisplayPowerStateForTest( chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); LoadDisplayPreferences(false); EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, ash::Shell::GetInstance()->display_configurator()-> requested_power_state()); } TEST_F(DisplayPreferencesTest, DontSaveAndRestoreAllOff) { ash::Shell* shell = ash::Shell::GetInstance(); StoreDisplayPowerStateForTest( chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); LoadDisplayPreferences(false); // DisplayPowerState should be ignored at boot. EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, shell->display_configurator()->requested_power_state()); StoreDisplayPowerStateForTest( chromeos::DISPLAY_POWER_ALL_OFF); EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, shell->display_configurator()->requested_power_state()); EXPECT_EQ("internal_off_external_on", local_state()->GetString(prefs::kDisplayPowerState)); // Don't try to load local_state()->SetString(prefs::kDisplayPowerState, "all_off"); LoadDisplayPreferences(false); EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, shell->display_configurator()->requested_power_state()); } // Tests that display configuration changes caused by MaximizeModeController // are not saved. TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { ash::Shell* shell = ash::Shell::GetInstance(); gfx::Display::SetInternalDisplayId( gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); ash::DisplayManager* display_manager = shell->display_manager(); LoggedInAsUser(); // Populate the properties. display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), gfx::Display::ROTATE_180); // Reset property to avoid rotation lock display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), gfx::Display::ROTATE_0); // Open up 270 degrees to trigger maximize mode chromeos::AccelerometerUpdate update; update.Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f, kMeanGravity); update.Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f); ash::MaximizeModeController* controller = shell->maximize_mode_controller(); controller->OnAccelerometerUpdated(update); EXPECT_TRUE(controller->IsMaximizeModeWindowManagerEnabled()); // Trigger 90 degree rotation update.Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, -kMeanGravity, 0.0f, 0.0f); update.Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, -kMeanGravity, 0.0f, 0.0f); controller->OnAccelerometerUpdated(update); shell->screen_orientation_controller()->OnAccelerometerUpdated(update); EXPECT_EQ(gfx::Display::ROTATE_90, display_manager-> GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation()); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayProperties); const base::DictionaryValue* property = NULL; EXPECT_TRUE(properties->GetDictionary( base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); int rotation = -1; EXPECT_TRUE(property->GetInteger("rotation", &rotation)); EXPECT_EQ(gfx::Display::ROTATE_0, rotation); } // Tests that the rotation state is saved without a user being logged in. TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { gfx::Display::SetInternalDisplayId( gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); bool current_rotation_lock = IsRotationLocked(); StoreDisplayRotationPrefs(current_rotation_lock); EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayRotationLock); bool rotation_lock; EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); EXPECT_EQ(current_rotation_lock, rotation_lock); int orientation; gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()-> display_manager()-> GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); EXPECT_EQ(current_rotation, orientation); } // Tests that the rotation state is saved when a guest is logged in. TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { gfx::Display::SetInternalDisplayId( gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); LoggedInAsGuest(); bool current_rotation_lock = IsRotationLocked(); StoreDisplayRotationPrefs(current_rotation_lock); EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayRotationLock); bool rotation_lock; EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); EXPECT_EQ(current_rotation_lock, rotation_lock); int orientation; gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()-> display_manager()-> GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); EXPECT_EQ(current_rotation, orientation); } // Tests that the rotation state is saved when a normal user is logged in. TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { gfx::Display::SetInternalDisplayId( gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); LoggedInAsGuest(); bool current_rotation_lock = IsRotationLocked(); StoreDisplayRotationPrefs(current_rotation_lock); EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayRotationLock); bool rotation_lock; EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); EXPECT_EQ(current_rotation_lock, rotation_lock); int orientation; gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()-> display_manager()-> GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); EXPECT_EQ(current_rotation, orientation); } // Tests that rotation state is loaded without a user being logged in, and that // entering maximize mode applies the state. TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { gfx::Display::SetInternalDisplayId( gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); ash::Shell* shell = ash::Shell::GetInstance(); bool initial_rotation_lock = IsRotationLocked(); ASSERT_FALSE(initial_rotation_lock); ash::DisplayManager* display_manager = shell->display_manager(); gfx::Display::Rotation initial_rotation = display_manager-> GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation); StoreDisplayRotationPrefs(initial_rotation_lock); ASSERT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); StoreDisplayRotationPrefsForTest(true, gfx::Display::ROTATE_90); LoadDisplayPreferences(false); bool display_rotation_lock = display_manager->registered_internal_display_rotation_lock(); bool display_rotation = display_manager->registered_internal_display_rotation(); EXPECT_TRUE(display_rotation_lock); EXPECT_EQ(gfx::Display::ROTATE_90, display_rotation); bool rotation_lock = IsRotationLocked(); gfx::Display::Rotation before_maximize_mode_rotation = display_manager-> GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); // Settings should not be applied until maximize mode activates EXPECT_FALSE(rotation_lock); EXPECT_EQ(gfx::Display::ROTATE_0, before_maximize_mode_rotation); // Open up 270 degrees to trigger maximize mode chromeos::AccelerometerUpdate update; update.Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f, kMeanGravity); update.Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f); ash::MaximizeModeController* maximize_mode_controller = shell->maximize_mode_controller(); maximize_mode_controller->OnAccelerometerUpdated(update); EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled()); bool screen_orientation_rotation_lock = IsRotationLocked(); gfx::Display::Rotation maximize_mode_rotation = display_manager-> GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(screen_orientation_rotation_lock); EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation); } // Tests that rotation lock being set causes the rotation state to be saved. TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) { gfx::Display::SetInternalDisplayId( gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( true); EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayRotationLock); bool rotation_lock; EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); } } // namespace chromeos
[ "hefen2007303257@gmail.com" ]
hefen2007303257@gmail.com
4298ccbac41d0fc518af349a1e966910585f90bc
034280389ac7d17c6bfed7324d9dfd3680af2e71
/Financial/Transaction.cpp
217d838981cbf9bc0f7ab36841f6b58444ffb4da
[]
no_license
ireb15/financial-management-system
401b638ebc3a03e71b9144e485b6b0467c895164
24cc78d9931436a2d8f3aa2507a5f46dcbb74937
refs/heads/master
2020-09-08T11:34:07.253336
2019-11-12T03:30:28
2019-11-12T03:30:28
221,121,161
0
0
null
null
null
null
UTF-8
C++
false
false
2,244
cpp
#include "Transaction.hpp" #include <string> // Incrementing this variable in the Transaction constructor ensures that each transaction has a unique transaction ID. int Transaction::incrementTransactionID = 0; Transaction::Transaction(Account* fromAccount, Account* toAccount, Money amount) { transactionID = incrementTransactionID++; this->fromAccount = fromAccount; this->toAccount = toAccount; if (amount.asCents() > 0) { this->amount = amount; } // The following variable is used in the implementation of performTransaction() in the Tranasction class. state = PENDING; } bool Transaction::performTransaction(){ Account* FromAccount = this->fromAccount; Account* ToAccount = this->toAccount; // Withdraw amount from the fromAccount and deposit it into the toAccount. // If withdrawMoney fails, depositMoney is not called and performTransaction() fails. // If withdrawMoney passes but depositMoney fails, determine which type of account FromAccount is and call // revertWithdrawal on it. // revertWithdrawal is a helper method from the Account class and has a different implementation for each // type of account. For more information on how revertWithdrawal works, refer to each type of account to // see it's implementation. // If withdrawMoney passes but depositMoney fails, performTransaction() fails. if (FromAccount->withdrawMoney(amount) == true) { if (ToAccount->depositMoney(amount) == true) { state = COMPLETED; return true; } else if (FromAccount->accountType == SAVINGS) { FromAccount->revertWithdrawal(amount); state = FAILED; return false; } else if (FromAccount->accountType == CHEQUE){ FromAccount->revertWithdrawal(amount); state = FAILED; return false; }else { FromAccount->revertWithdrawal(amount); state = FAILED; return false; } } else { state = FAILED; return false; } } TransactionState Transaction::getState() const { return state; } Money Transaction::getAmount() const { return this->amount; } Account* Transaction::getToAccount() const { return this->toAccount; } Account* Transaction::getFromAccount() const { return this->fromAccount; } int Transaction::getID() const { return transactionID; } Transaction::~Transaction() { }
[ "noreply@github.com" ]
noreply@github.com
81c466754a55e415545b92a6bb2cbc835e8199bc
9d15d17a72d16b79faa75526a78b084ee3deaa78
/c++/50_questions/vitual2.cpp
5a0f1287564732f188c8c90435aea60799527f61
[]
no_license
pankajjindal/DailyCoding
3b2931803b5786ae97e4c837438ab41956472a49
5fdb294515e7861e720d89391164d552a977c333
refs/heads/master
2021-06-12T07:44:40.534953
2021-04-12T20:28:29
2021-04-12T20:28:29
152,621,198
0
0
null
null
null
null
UTF-8
C++
false
false
705
cpp
#include <iostream> using namespace std; class A { public: int a; A() // constructor { a = 10; } void show(){ cout << "10" ; } }; class B : public virtual A { public: void show(){ cout << "11" ; } }; class C : public virtual A { public: void show(){ cout << "12" ; } }; class D : public B, public C { public: void show(){ cout << "13" ; } }; int main() { D object; // object creation of class d cout << "a = " << object.a << endl; object.show(); B objectB; // object creation of class d cout << "a = " << objectB.a << endl; objectB.show(); return 0; }
[ "jindal25@gmail.com" ]
jindal25@gmail.com
4dd41ed62d487cda6c64b00771f2b253612ac5b4
6295837ba91a52200ce924ad00298f81320731a3
/PracticePractic/TaskManager/TaskManager/GeneratedFiles/Debug/moc_TaskManager.cpp
a9cf673c11f4f135462a63e53b492034d7e6ca81
[]
no_license
alexovidiupopa/Object-Oriented-Programming
440aac0a771b2c6f39c8f91072f828346837fd84
93bcfcac464815db832f22c02a4bbfb4d9d30024
refs/heads/master
2022-01-09T13:12:25.330141
2019-06-18T12:25:38
2019-06-18T12:40:40
172,544,796
0
2
null
null
null
null
UTF-8
C++
false
false
4,063
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'TaskManager.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.3) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../TaskManager.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'TaskManager.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.12.3. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_TaskManager_t { QByteArrayData data[7]; char stringdata0[44]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_TaskManager_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_TaskManager_t qt_meta_stringdata_TaskManager = { { QT_MOC_LITERAL(0, 0, 11), // "TaskManager" QT_MOC_LITERAL(1, 12, 3), // "add" QT_MOC_LITERAL(2, 16, 0), // "" QT_MOC_LITERAL(3, 17, 6), // "remove" QT_MOC_LITERAL(4, 24, 7), // "changed" QT_MOC_LITERAL(5, 32, 5), // "close" QT_MOC_LITERAL(6, 38, 5) // "start" }, "TaskManager\0add\0\0remove\0changed\0close\0" "start" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_TaskManager[] = { // content: 8, // revision 0, // classname 0, 0, // classinfo 5, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 39, 2, 0x08 /* Private */, 3, 0, 40, 2, 0x08 /* Private */, 4, 0, 41, 2, 0x08 /* Private */, 5, 0, 42, 2, 0x08 /* Private */, 6, 0, 43, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, 0 // eod }; void TaskManager::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { auto *_t = static_cast<TaskManager *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->add(); break; case 1: _t->remove(); break; case 2: _t->changed(); break; case 3: _t->close(); break; case 4: _t->start(); break; default: ; } } Q_UNUSED(_a); } QT_INIT_METAOBJECT const QMetaObject TaskManager::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_TaskManager.data, qt_meta_data_TaskManager, qt_static_metacall, nullptr, nullptr } }; const QMetaObject *TaskManager::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *TaskManager::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_TaskManager.stringdata0)) return static_cast<void*>(this); if (!strcmp(_clname, "Observer")) return static_cast< Observer*>(this); return QWidget::qt_metacast(_clname); } int TaskManager::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 5) qt_static_metacall(this, _c, _id, _a); _id -= 5; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 5) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 5; } return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
[ "popaalexovidiu@gmail.com" ]
popaalexovidiu@gmail.com
c9b5e972274f31a97ae5046fbb50c4de05dde7c7
f28b1fe7f028426c91354f3bc3ca87399ca7dce8
/PCIe/test_source/pcie2screen_openGL/opengl_yuv.cpp
0cca5eead0b61d2c2bb22075be2aaf59100206f6
[]
no_license
lion1986/AX7015
872cd6df34e83e0faa4b4e335f501c160180a178
a6e5bf8f676ec6f36816cff8d8d7e6c0a1916362
refs/heads/master
2022-01-14T20:21:21.901451
2018-05-30T03:22:51
2018-05-30T03:22:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,004
cpp
#include "opengl_yuv.h" #include <sys/time.h> uOpenglYuv::uOpenglYuv(QWidget *parent) : QOpenGLWidget(parent), m_program(0) { vW = 1920; vH = 1080; pRGB = (unsigned char *)malloc(vW*vH*3); pthread_mutex_init(&optnotice, NULL); } uOpenglYuv::~uOpenglYuv() { makeCurrent(); delete m_program; doneCurrent(); if(pRGB) { free(pRGB); } } void uOpenglYuv::initializeGL() { initializeOpenGLFunctions(); if (!m_program) { m_program = new QOpenGLShaderProgram(); QString vertexStr = "attribute highp vec4 vertexIn;" "attribute highp vec2 textureIn;" "varying vec2 textureOut;" "void main(void) " "{" "gl_Position = vertexIn;" "textureOut = textureIn;" "}"; QString fragmentStr = "varying vec2 textureOut;" "uniform sampler2D tex_rgb;" "void main(void)" "{" "vec3 rgb;" "rgb.x = texture2D(tex_rgb, textureOut).b;" "rgb.y = texture2D(tex_rgb, textureOut).g;" "rgb.z = texture2D(tex_rgb, textureOut).r;" "gl_FragColor = vec4(rgb, 1);" "}"; m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexStr); if(!m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentStr)) { fragmentStr.insert(0, "precision mediump float;"); m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentStr); } m_program->bindAttributeLocation("vertexIn", ATTRIB_VERTEX); m_program->bindAttributeLocation("textureIn", ATTRIB_TEXTURE); m_program->link(); } m_program->bind(); static const GLfloat vertexVertices[] = { -1.0f, -1.0f, +1.0f, -1.0f, -1.0f, +1.0f, +1.0f, +1.0f, }; static const GLfloat textureVertices[] = { 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, }; m_program->setAttributeArray(ATTRIB_VERTEX, GL_FLOAT, vertexVertices, 2); m_program->enableAttributeArray(ATTRIB_VERTEX); m_program->setAttributeArray(ATTRIB_TEXTURE, GL_FLOAT, textureVertices, 2); m_program->enableAttributeArray(ATTRIB_TEXTURE); TextureID0 = m_program->uniformLocation("tex_rgb"); glGenTextures(1, &textureRGB); glBindTexture(GL_TEXTURE_2D, textureRGB); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gettimeofday(&last_time, NULL); } void uOpenglYuv::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureRGB); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, vW, vH, 0, GL_RGB, GL_UNSIGNED_BYTE, pRGB); m_program->setUniformValue(TextureID0, 0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); pthread_mutex_unlock(&optnotice); frameCot++; gettimeofday(&curr_time, NULL); a = curr_time.tv_sec*1000000+curr_time.tv_usec; a -= last_time.tv_sec*1000000; a -= last_time.tv_usec; if(a >= 500000) { a = 100000000*frameCot/a; last_time.tv_sec = curr_time.tv_sec; last_time.tv_usec = curr_time.tv_usec; frameCot = 0; emit flushFps(a); } } void uOpenglYuv::mousePressEvent(QMouseEvent *) { emit mouseDoubleClickNotice(0); } void uOpenglYuv::mouseReleaseEvent(QMouseEvent *) { emit mouseDoubleClickNotice(1); } void uOpenglYuv::mouseDoubleClickEvent(QMouseEvent *) { emit mouseDoubleClickNotice(2); } void uOpenglYuv::mouseMoveEvent(QMouseEvent *) { emit mouseDoubleClickNotice(3); }
[ "avic@alinx.com.cn" ]
avic@alinx.com.cn
fbc1362272a449d22bb06f4886e76aaaa67a6d86
b6a1951dc87fa054e61a89a749990a6f64eca79f
/seek.cpp
0239d6bd412520e556051489a5b5e75be60789b6
[]
no_license
Negi47/USP
61e17c31412306a0c7bf63a08d2c042dff6b1ae8
b943e8d5b53a7bf111c724c654a45d97b4a7a046
refs/heads/master
2020-05-03T08:13:35.062820
2019-05-05T14:02:47
2019-05-05T14:02:47
178,519,967
0
0
null
null
null
null
UTF-8
C++
false
false
485
cpp
#include<iostream> #include<sys/types.h> #include<unistd.h> #include<limits.h> #include<fcntl.h> #include<stdio.h> #include<string.h> using namespace std; int main(int args, char* argv[]) { int fd_1; char buf[] = "Hello"; char buf_2[] = "World"; char ch; fd_1 = open(argv[1], O_RDWR|O_CREAT,0777); write(fd_1,buf,strlen(buf)); lseek(fd_1,10,SEEK_CUR); write(fd_1,buf_2,strlen(buf_2)); while(!(EOF(fd_1))) { read(fd_1, &ch, 1); printf("%c",ch); } return 0; }
[ "narendra.negi47@gmail.com" ]
narendra.negi47@gmail.com
3499c1686fcb134817cb732d1d6f2f88a2e23a5a
852023a16bc839edcc79436f673917943057ba7f
/erpc_c/infra/simple_server.h
0ea74120457b6901f4ab3b5720fa82ff0ea29b43
[ "BSD-3-Clause" ]
permissive
ErichStyger/erpc
798d15fc830e4cdfc9ab11df48c7b3f56a870693
445320f8050a0b778e552e696b8c218e79f90ce0
refs/heads/master
2021-01-17T22:23:38.471639
2016-08-27T20:35:53
2016-08-27T20:35:53
66,768,784
3
2
null
2016-08-28T13:09:48
2016-08-28T13:09:47
null
UTF-8
C++
false
false
3,967
h
/* * Copyright (c) 2014, Freescale Semiconductor, Inc. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * o 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. * * o Neither the name of Freescale Semiconductor, Inc. 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 _EMBEDDED_RPC__SIMPLE_SERVER_H_ #define _EMBEDDED_RPC__SIMPLE_SERVER_H_ #include "server.h" /*! * @addtogroup infra_server * @{ * @file */ //////////////////////////////////////////////////////////////////////////////// // Classes //////////////////////////////////////////////////////////////////////////////// namespace erpc { /*! * @brief Based server implementation. * * @ingroup infra_server */ class SimpleServer : public Server { public: /*! * @brief Constructor. * * This function initializes object attributes. */ SimpleServer() : m_transport() , m_isServerOn(true) { } /*! * @brief SimpleServer destructor */ virtual ~SimpleServer(); /*! * @brief This function sets transport layer to use. * * @param[in] transport Transport layer to use. */ void setTransport(Transport *transport) { m_transport = transport; } /*! * @brief Run server in infinite loop. * * Will never jump out from this function. */ virtual status_t run(); /*! * @brief Run server implementation only if exist message to process. * * If is message to process, server process it and jumps out from this function, * useful for bare-metal because doesn't block main loop, when are not messages * to process. * * @return Return true when server is ON, else false. */ virtual status_t poll(); /*! * @brief This function sets server from ON to OFF */ virtual void stop(); protected: /*! * @brief Run server implementation. * * This function call functions for receiving data, process this data and * if reply exist, send it back. */ status_t runInternal(); /*! * @brief Disposing message buffers and codecs. * * @param[in] codec Pointer to codec to dispose. It contains also message buffer to dispose. */ void disposeBufferAndCodec(Codec *codec); /*! * @brief Create message buffers and codecs. * * @return Pointer to created codec with message buffer. */ Codec *createBufferAndCodec(); Transport *m_transport; /*!< Transport layer used to send and receive data. */ bool m_isServerOn; /*!< Information if server is ON or OFF. */ }; } // namespace erpc /*! @} */ #endif // _EMBEDDED_RPC__SIMPLE_SERVER_H_
[ "chris.reed@nxp.com" ]
chris.reed@nxp.com
fa70c445c03870d5bfad5875e77c8bd267f06f6d
bc358413fb2ce2008ab0647c257b1a71e68e7d66
/CS202classSep17/CS202classSep17.cpp
96e4d8134ebb6e371ac8dd80ad085f035e304175
[]
no_license
CSWMAndrews/CS202
b0308a21aeef1c47d5b5d358d1cee07466ca53b3
771fbcd62b6ed4df77265df5bd5c147d07872c6d
refs/heads/master
2020-07-27T14:54:14.572528
2019-09-24T20:16:10
2019-09-24T20:16:10
209,131,675
0
0
null
null
null
null
UTF-8
C++
false
false
1,744
cpp
// CS202classSep17.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include <string> #include <sstream> #include <fstream> using std::cout; using std::cin; using std::string; using std::getline; using std::istringstream; using std::ofstream; using std::ifstream; int main() { std::cout << "HI Like Pie!\n"; int total = 0; bool boingBoing = true; while (boingBoing) { int x; cout << "NUMBERS!: (drop that sucker negative to quit)"; string userInput; getline(cin, userInput); istringstream uin(userInput); while (true) { uin >> x; if (!uin) { if (uin.eof()) { break; } cout << "Bad User, No Cookie! \n"; uin.clear(); uin.ignore(999, '\n'); continue; } if (x < 0) { boingBoing = false; break; } total += x; } cout << "Your total was " << total << "\n"; } ofstream ofile("Repository of Pie.txt", std::ios::app); ofile << total << "<- number of pies.\n"; ifstream f("Repository of Pie.txt"); if (f.is_open()) std::cout << f.rdbuf(); return 0; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
[ "wmandrews@alaska.edu" ]
wmandrews@alaska.edu
87967c07d0ff75433dabef964ce4f05d0dd5abf4
345d2a61209c3021efd4c16fb39ac47ed792c840
/retired/win32/ChatDlg.cpp
a5dd0645df9e9e825a2209f9c95d37b2074c622a
[]
no_license
c99koder/DCSquares
e46fae81117702bcddafb47ff2a5ce1e3a8a5abb
2bd7050fcdc82be14cc7f930a6fd0c758a209120
refs/heads/master
2021-01-21T21:55:01.338213
2016-03-31T00:57:33
2016-03-31T00:57:33
25,490,062
3
0
null
null
null
null
UTF-8
C++
false
false
2,171
cpp
// ChatDlg.cpp : implementation file // #include "stdafx.h" #include "DCSquares-MFC.h" #include "ChatDlg.h" #include ".\chatdlg.h" #include "squarenet.h" #include "net.h" // CChatDlg dialog IMPLEMENT_DYNAMIC(CChatDlg, CDialog) CChatDlg::CChatDlg(CWnd* pParent /*=NULL*/) : CDialog(CChatDlg::IDD, pParent) { } CChatDlg::~CChatDlg() { } void CChatDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_USERLIST, lstUserList); DDX_Control(pDX, IDC_CHATTEXT, txtChatText); DDX_Control(pDX, IDC_CHATINPUT, txtChatInput); } BEGIN_MESSAGE_MAP(CChatDlg, CDialog) ON_WM_CREATE() ON_WM_TIMER() ON_WM_CLOSE() ON_BN_CLICKED(IDC_BTNSEND, OnBtnSend) END_MESSAGE_MAP() // CChatDlg message handlers CListBox *os_user_list; CEdit *os_chat_text; void os_chat_reload_users() { USES_CONVERSION; struct userlist_node *current=get_userlist(); os_user_list->ResetContent(); while(current!=NULL) { os_user_list->AddString(current->username); current=current->next; } } void os_chat_insert_text(char *text) { CString s; os_chat_text->GetWindowText(s); s += text; s += "\r\n"; os_chat_text->SetWindowText(s); os_chat_text->LineScroll(os_chat_text->GetLineCount()); } int CChatDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here os_user_list = &lstUserList; os_chat_text = &txtChatText; lobby_connect("192.168.11.100","DJ Shibby","jay123"); SetTimer(1000,1000 / 10,NULL); return 0; } void CChatDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default lobby_update(); CDialog::OnTimer(nIDEvent); } void CChatDlg::OnClose() { // TODO: Add your message handler code here and/or call default lobby_disconnect(); CDialog::OnClose(); } void CChatDlg::OnBtnSend() { snChatMsg m; CString s; txtChatInput.GetWindowText(s); strcpy(m.msg,(char *)(LPCTSTR)s); lobby_send(CHAN_CHAT,CHAT_MSG,sizeof(m),&m); txtChatInput.SetWindowText(""); txtChatInput.SetFocus(); }
[ "sam.steele@gmail.com" ]
sam.steele@gmail.com
f2b9461c206091e0538870afbd095f9cba993bf3
9ae5a09f12623ffb53054a0a9c32d2c1951dd1c2
/FinalTank/Cpp坦克大战/BASE.h
0174f7335e71bd74680b298e5b4c90a6b1579e1a
[]
no_license
Katana-O/TankWar
a8a1195774f35452401817fd9692b23f649b1b88
1ef28c30cc989153416bfcc4de923dc288b968ad
refs/heads/main
2023-08-17T05:14:59.576596
2021-09-27T19:06:02
2021-09-27T19:06:02
411,009,450
0
0
null
null
null
null
GB18030
C++
false
false
932
h
#pragma once #include "HEADER.h" #include "PUBLIC.h" #include "BULLET.h" #include "TANK.h" class BASE:public BULLET,public TANK { public: vector<TANK> V_Tank; vector<BULLET> V_Bullet; //关卡菜单 int StageMenu(); //***主菜单 /*int MainMenu();*/ //判断敌人死光 bool EnemyDead(); //判断友方死光 bool AllyDead(); //读取所有元素,地图,坦克,子弹 bool ReadInfo(char level); //保存所有元素,地图,坦克,子弹 bool SaveInfo(char level); //自定义地图 void MessageLoop(); //***存档*** void SaveMap(char level); //***读档*** void ReadMap(char level); //游戏主引擎 void GameStart(); //获取玩家1键盘输入 int GetUserInput(int Dir); //获取玩家2键盘输入 int Get2UserInput(int Dir); //初始化坦克信息 void InitTank(); //初始化子弹信息 void InitBullet(); //记分板上的信息 void ScoreInfo(); BASE(); ~BASE(); };
[ "StaringTheWorldAtMyRearView123@protonmail.com" ]
StaringTheWorldAtMyRearView123@protonmail.com
1613a06c8d50643eb8dd74023d89976c2c40989f
136bf9da5fe164f82cfa680c6e2a17c40afe686f
/Core/TriangulatedMeshes3.h
913b4709cbbb694d9545d2796c6fa58cffce2686
[]
no_license
lorinczszabolcs/CAD
b150bc98d73a9ee7845605e5e29b37a61262e2de
16a0c6649c92306a5b27400ccef8c57e9543fdd5
refs/heads/master
2020-03-19T03:19:26.391163
2018-07-08T19:34:00
2018-07-08T19:34:00
135,684,164
0
0
null
null
null
null
UTF-8
C++
false
false
3,295
h
#pragma once #include "DCoordinates3.h" #include <GL/glew.h> #include <iostream> #include <string> #include "TriangularFaces.h" #include "TCoordinates4.h" #include <vector> namespace cagd { class TriangulatedMesh3 { friend class ParametricSurface3; friend class TensorProductSurface3; // homework: output to stream: // vertex count, face count // list of vertices // list of unit normal vectors // list of texture coordinates // list of faces friend std::ostream& operator <<(std::ostream& lhs, const TriangulatedMesh3& rhs); // homework: input from stream: inverse of the ostream operator friend std::istream& operator >>(std::istream& lhs, TriangulatedMesh3& rhs); protected: // vertex buffer object identifiers GLenum _usage_flag; GLuint _vbo_vertices; GLuint _vbo_normals; GLuint _vbo_tex_coordinates; GLuint _vbo_indices; // corners of bounding box DCoordinate3 _leftmost_vertex; DCoordinate3 _rightmost_vertex; // geometry std::vector<DCoordinate3> _vertex; std::vector<DCoordinate3> _normal; std::vector<TCoordinate4> _tex; std::vector<TriangularFace> _face; public: // special and default constructor TriangulatedMesh3(GLuint vertex_count = 0, GLuint face_count = 0, GLenum usage_flag = GL_STATIC_DRAW); // copy constructor TriangulatedMesh3(const TriangulatedMesh3& mesh); // assignment operator TriangulatedMesh3& operator =(const TriangulatedMesh3& rhs); // deletes all vertex buffer objects GLvoid DeleteVertexBufferObjects(); // renders the geometry GLboolean Render(GLenum render_mode = GL_TRIANGLES) const; GLboolean RenderNormalVectors(GLenum render_mode = GL_LINES) const; // updates all vertex buffer objects GLboolean UpdateVertexBufferObjects(GLenum usage_flag = GL_STATIC_DRAW); // loads the geometry (i.e. the array of vertices and faces) stored in an OFF file // at the same time calculates the unit normal vectors associated with vertices GLboolean LoadFromOFF(const std::string& file_name, GLboolean translate_and_scale_to_unit_cube = GL_FALSE); // homework: saves the geometry into an OFF file GLboolean SaveToOFF(const std::string& file_name) const; // mapping vertex buffer objects GLfloat* MapVertexBuffer(GLenum access_flag = GL_READ_ONLY) const; GLfloat* MapNormalBuffer(GLenum access_flag = GL_READ_ONLY) const; // homework GLfloat* MapTextureBuffer(GLenum access_flag = GL_READ_ONLY) const; // homework // unmapping vertex buffer objects GLvoid UnmapVertexBuffer() const; GLvoid UnmapNormalBuffer() const; // homework GLvoid UnmapTextureBuffer() const; // homework // get properties of geometry GLuint VertexCount() const; // homework GLuint FaceCount() const; // homework // destructor virtual ~TriangulatedMesh3(); }; }
[ "lorincz_szabolcs@yahoo.com" ]
lorincz_szabolcs@yahoo.com
021ae7f668b349e808828629c7c78bd7d3e3d387
5f9b26a41102c38da28b8f757a5586f9bc7cf71a
/crates/zig_build_bin_windows_x86_64/zig-windows-x86_64-0.5.0+80ff549e2/lib/zig/libc/include/any-windows-any/mmdeviceapi.h
b8364c52d0b6c8cc883ba00470285789b1c994ba
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain" ]
permissive
jeremyBanks/zig_with_cargo
f8e65f14adf17ed8d477f0856257422c2158c63f
f8ee46b891bbcdca7ff20f5cad64aa94c5a1d2d1
refs/heads/master
2021-02-06T10:26:17.614138
2020-03-09T04:46:26
2020-03-09T04:46:26
243,905,553
4
1
null
null
null
null
UTF-8
C++
false
false
29,147
h
/*** Autogenerated by WIDL 4.19 from include/mmdeviceapi.idl - Do not edit ***/ #ifdef _WIN32 #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif #include <rpc.h> #include <rpcndr.h> #endif #ifndef COM_NO_WINDOWS_H #include <windows.h> #include <ole2.h> #endif #ifndef __mmdeviceapi_h__ #define __mmdeviceapi_h__ /* Forward declarations */ #ifndef __IMMNotificationClient_FWD_DEFINED__ #define __IMMNotificationClient_FWD_DEFINED__ typedef interface IMMNotificationClient IMMNotificationClient; #ifdef __cplusplus interface IMMNotificationClient; #endif /* __cplusplus */ #endif #ifndef __IMMDevice_FWD_DEFINED__ #define __IMMDevice_FWD_DEFINED__ typedef interface IMMDevice IMMDevice; #ifdef __cplusplus interface IMMDevice; #endif /* __cplusplus */ #endif #ifndef __IMMDeviceCollection_FWD_DEFINED__ #define __IMMDeviceCollection_FWD_DEFINED__ typedef interface IMMDeviceCollection IMMDeviceCollection; #ifdef __cplusplus interface IMMDeviceCollection; #endif /* __cplusplus */ #endif #ifndef __IMMEndpoint_FWD_DEFINED__ #define __IMMEndpoint_FWD_DEFINED__ typedef interface IMMEndpoint IMMEndpoint; #ifdef __cplusplus interface IMMEndpoint; #endif /* __cplusplus */ #endif #ifndef __IMMDeviceEnumerator_FWD_DEFINED__ #define __IMMDeviceEnumerator_FWD_DEFINED__ typedef interface IMMDeviceEnumerator IMMDeviceEnumerator; #ifdef __cplusplus interface IMMDeviceEnumerator; #endif /* __cplusplus */ #endif #ifndef __IMMDeviceActivator_FWD_DEFINED__ #define __IMMDeviceActivator_FWD_DEFINED__ typedef interface IMMDeviceActivator IMMDeviceActivator; #ifdef __cplusplus interface IMMDeviceActivator; #endif /* __cplusplus */ #endif #ifndef __MMDeviceEnumerator_FWD_DEFINED__ #define __MMDeviceEnumerator_FWD_DEFINED__ #ifdef __cplusplus typedef class MMDeviceEnumerator MMDeviceEnumerator; #else typedef struct MMDeviceEnumerator MMDeviceEnumerator; #endif /* defined __cplusplus */ #endif /* defined __MMDeviceEnumerator_FWD_DEFINED__ */ /* Headers for imported files */ #include <unknwn.h> #include <propsys.h> #ifdef __cplusplus extern "C" { #endif #ifndef E_NOTFOUND #define E_NOTFOUND HRESULT_FROM_WIN32(ERROR_NOT_FOUND) #endif #ifndef E_UNSUPPORTED_TYPE #define E_UNSUPPORTED_TYPE HRESULT_FROM_WIN32(ERROR_UNSUPPORTED_TYPE) #endif #define DEVICE_STATE_ACTIVE 0x1 #define DEVICE_STATE_DISABLED 0x2 #define DEVICE_STATE_NOTPRESENT 0x4 #define DEVICE_STATE_UNPLUGGED 0x8 #define DEVICE_STATEMASK_ALL 0xf DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_FormFactor,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,0); DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_ControlPanelPageProvider,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,1); DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_Association,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,2); DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_PhysicalSpeakers,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,3); DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_GUID,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,4); DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_Disable_SysFx,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,5); #define ENDPOINT_SYSFX_ENABLED 0 #define ENDPOINT_SYSFX_DISABLED 1 DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_FullRangeSpeakers,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,6); DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_Supports_EventDriven_Mode,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,7); DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_JackSubType,0x1da5d803,0xd492,0x4edd,0x8c,0x23,0xe0,0xc0,0xff,0xee,0x7f,0x0e,8); DEFINE_PROPERTYKEY(PKEY_AudioEngine_DeviceFormat,0xf19f064d,0x082c,0x4e27,0xbc,0x73,0x68,0x82,0xa1,0xbb,0x8e,0x4c,0); DEFINE_PROPERTYKEY(PKEY_AudioEngine_OEMFormat,0xe4870e26,0x3cc5,0x4cd2,0xba,0x46,0xca,0x0a,0x9a,0x70,0xed,0x04,3); typedef struct tagDIRECTX_AUDIO_ACTIVATION_PARAMS { DWORD cbDirectXAudioActivationParams; GUID guidAudioSession; DWORD dwAudioStreamFlags; } DIRECTX_AUDIO_ACTIVATION_PARAMS; typedef struct tagDIRECTX_AUDIO_ACTIVATION_PARAMS *PDIRECTX_AUDIO_ACTIVATION_PARAMS; typedef enum _EDataFlow { eRender = 0, eCapture = 1, eAll = 2, EDataFlow_enum_count = 3 } EDataFlow; typedef enum _ERole { eConsole = 0, eMultimedia = 1, eCommunications = 2, ERole_enum_count = 3 } ERole; typedef enum _EndpointFormFactor { RemoteNetworkDevice = 0, Speakers = 1, LineLevel = 2, Headphones = 3, Microphone = 4, Headset = 5, Handset = 6, UnknownDigitalPassthrough = 7, SPDIF = 8, DigitalAudioDisplayDevice = 9, UnknownFormFactor = 10, EndpointFormFactor_enum_count = 11 } EndpointFormFactor; #define HDMI DigitalAudioDisplayDevice /***************************************************************************** * IMMNotificationClient interface */ #ifndef __IMMNotificationClient_INTERFACE_DEFINED__ #define __IMMNotificationClient_INTERFACE_DEFINED__ DEFINE_GUID(IID_IMMNotificationClient, 0x7991eec9, 0x7e89, 0x4d85, 0x83,0x90, 0x6c,0x70,0x3c,0xec,0x60,0xc0); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("7991eec9-7e89-4d85-8390-6c703cec60c0") IMMNotificationClient : public IUnknown { virtual HRESULT STDMETHODCALLTYPE OnDeviceStateChanged( LPCWSTR pwstrDeviceId, DWORD dwNewState) = 0; virtual HRESULT STDMETHODCALLTYPE OnDeviceAdded( LPCWSTR pwstrDeviceId) = 0; virtual HRESULT STDMETHODCALLTYPE OnDeviceRemoved( LPCWSTR pwstrDeviceId) = 0; virtual HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged( EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) = 0; virtual HRESULT STDMETHODCALLTYPE OnPropertyValueChanged( LPCWSTR pwstrDeviceId, const PROPERTYKEY key) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IMMNotificationClient, 0x7991eec9, 0x7e89, 0x4d85, 0x83,0x90, 0x6c,0x70,0x3c,0xec,0x60,0xc0) #endif #else typedef struct IMMNotificationClientVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IMMNotificationClient *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IMMNotificationClient *This); ULONG (STDMETHODCALLTYPE *Release)( IMMNotificationClient *This); /*** IMMNotificationClient methods ***/ HRESULT (STDMETHODCALLTYPE *OnDeviceStateChanged)( IMMNotificationClient *This, LPCWSTR pwstrDeviceId, DWORD dwNewState); HRESULT (STDMETHODCALLTYPE *OnDeviceAdded)( IMMNotificationClient *This, LPCWSTR pwstrDeviceId); HRESULT (STDMETHODCALLTYPE *OnDeviceRemoved)( IMMNotificationClient *This, LPCWSTR pwstrDeviceId); HRESULT (STDMETHODCALLTYPE *OnDefaultDeviceChanged)( IMMNotificationClient *This, EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId); HRESULT (STDMETHODCALLTYPE *OnPropertyValueChanged)( IMMNotificationClient *This, LPCWSTR pwstrDeviceId, const PROPERTYKEY key); END_INTERFACE } IMMNotificationClientVtbl; interface IMMNotificationClient { CONST_VTBL IMMNotificationClientVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IMMNotificationClient_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IMMNotificationClient_AddRef(This) (This)->lpVtbl->AddRef(This) #define IMMNotificationClient_Release(This) (This)->lpVtbl->Release(This) /*** IMMNotificationClient methods ***/ #define IMMNotificationClient_OnDeviceStateChanged(This,pwstrDeviceId,dwNewState) (This)->lpVtbl->OnDeviceStateChanged(This,pwstrDeviceId,dwNewState) #define IMMNotificationClient_OnDeviceAdded(This,pwstrDeviceId) (This)->lpVtbl->OnDeviceAdded(This,pwstrDeviceId) #define IMMNotificationClient_OnDeviceRemoved(This,pwstrDeviceId) (This)->lpVtbl->OnDeviceRemoved(This,pwstrDeviceId) #define IMMNotificationClient_OnDefaultDeviceChanged(This,flow,role,pwstrDeviceId) (This)->lpVtbl->OnDefaultDeviceChanged(This,flow,role,pwstrDeviceId) #define IMMNotificationClient_OnPropertyValueChanged(This,pwstrDeviceId,key) (This)->lpVtbl->OnPropertyValueChanged(This,pwstrDeviceId,key) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IMMNotificationClient_QueryInterface(IMMNotificationClient* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IMMNotificationClient_AddRef(IMMNotificationClient* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IMMNotificationClient_Release(IMMNotificationClient* This) { return This->lpVtbl->Release(This); } /*** IMMNotificationClient methods ***/ static FORCEINLINE HRESULT IMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient* This,LPCWSTR pwstrDeviceId,DWORD dwNewState) { return This->lpVtbl->OnDeviceStateChanged(This,pwstrDeviceId,dwNewState); } static FORCEINLINE HRESULT IMMNotificationClient_OnDeviceAdded(IMMNotificationClient* This,LPCWSTR pwstrDeviceId) { return This->lpVtbl->OnDeviceAdded(This,pwstrDeviceId); } static FORCEINLINE HRESULT IMMNotificationClient_OnDeviceRemoved(IMMNotificationClient* This,LPCWSTR pwstrDeviceId) { return This->lpVtbl->OnDeviceRemoved(This,pwstrDeviceId); } static FORCEINLINE HRESULT IMMNotificationClient_OnDefaultDeviceChanged(IMMNotificationClient* This,EDataFlow flow,ERole role,LPCWSTR pwstrDeviceId) { return This->lpVtbl->OnDefaultDeviceChanged(This,flow,role,pwstrDeviceId); } static FORCEINLINE HRESULT IMMNotificationClient_OnPropertyValueChanged(IMMNotificationClient* This,LPCWSTR pwstrDeviceId,const PROPERTYKEY key) { return This->lpVtbl->OnPropertyValueChanged(This,pwstrDeviceId,key); } #endif #endif #endif #endif /* __IMMNotificationClient_INTERFACE_DEFINED__ */ /***************************************************************************** * IMMDevice interface */ #ifndef __IMMDevice_INTERFACE_DEFINED__ #define __IMMDevice_INTERFACE_DEFINED__ DEFINE_GUID(IID_IMMDevice, 0xd666063f, 0x1587, 0x4e43, 0x81,0xf1, 0xb9,0x48,0xe8,0x07,0x36,0x3f); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("d666063f-1587-4e43-81f1-b948e807363f") IMMDevice : public IUnknown { virtual HRESULT STDMETHODCALLTYPE Activate( REFIID iid, DWORD dwClsCtx, PROPVARIANT *pActivationParams, void **ppv) = 0; virtual HRESULT STDMETHODCALLTYPE OpenPropertyStore( DWORD stgmAccess, IPropertyStore **ppProperties) = 0; virtual HRESULT STDMETHODCALLTYPE GetId( LPWSTR *ppstrId) = 0; virtual HRESULT STDMETHODCALLTYPE GetState( DWORD *pdwState) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IMMDevice, 0xd666063f, 0x1587, 0x4e43, 0x81,0xf1, 0xb9,0x48,0xe8,0x07,0x36,0x3f) #endif #else typedef struct IMMDeviceVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IMMDevice *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IMMDevice *This); ULONG (STDMETHODCALLTYPE *Release)( IMMDevice *This); /*** IMMDevice methods ***/ HRESULT (STDMETHODCALLTYPE *Activate)( IMMDevice *This, REFIID iid, DWORD dwClsCtx, PROPVARIANT *pActivationParams, void **ppv); HRESULT (STDMETHODCALLTYPE *OpenPropertyStore)( IMMDevice *This, DWORD stgmAccess, IPropertyStore **ppProperties); HRESULT (STDMETHODCALLTYPE *GetId)( IMMDevice *This, LPWSTR *ppstrId); HRESULT (STDMETHODCALLTYPE *GetState)( IMMDevice *This, DWORD *pdwState); END_INTERFACE } IMMDeviceVtbl; interface IMMDevice { CONST_VTBL IMMDeviceVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IMMDevice_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IMMDevice_AddRef(This) (This)->lpVtbl->AddRef(This) #define IMMDevice_Release(This) (This)->lpVtbl->Release(This) /*** IMMDevice methods ***/ #define IMMDevice_Activate(This,iid,dwClsCtx,pActivationParams,ppv) (This)->lpVtbl->Activate(This,iid,dwClsCtx,pActivationParams,ppv) #define IMMDevice_OpenPropertyStore(This,stgmAccess,ppProperties) (This)->lpVtbl->OpenPropertyStore(This,stgmAccess,ppProperties) #define IMMDevice_GetId(This,ppstrId) (This)->lpVtbl->GetId(This,ppstrId) #define IMMDevice_GetState(This,pdwState) (This)->lpVtbl->GetState(This,pdwState) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IMMDevice_QueryInterface(IMMDevice* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IMMDevice_AddRef(IMMDevice* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IMMDevice_Release(IMMDevice* This) { return This->lpVtbl->Release(This); } /*** IMMDevice methods ***/ static FORCEINLINE HRESULT IMMDevice_Activate(IMMDevice* This,REFIID iid,DWORD dwClsCtx,PROPVARIANT *pActivationParams,void **ppv) { return This->lpVtbl->Activate(This,iid,dwClsCtx,pActivationParams,ppv); } static FORCEINLINE HRESULT IMMDevice_OpenPropertyStore(IMMDevice* This,DWORD stgmAccess,IPropertyStore **ppProperties) { return This->lpVtbl->OpenPropertyStore(This,stgmAccess,ppProperties); } static FORCEINLINE HRESULT IMMDevice_GetId(IMMDevice* This,LPWSTR *ppstrId) { return This->lpVtbl->GetId(This,ppstrId); } static FORCEINLINE HRESULT IMMDevice_GetState(IMMDevice* This,DWORD *pdwState) { return This->lpVtbl->GetState(This,pdwState); } #endif #endif #endif #endif /* __IMMDevice_INTERFACE_DEFINED__ */ /***************************************************************************** * IMMDeviceCollection interface */ #ifndef __IMMDeviceCollection_INTERFACE_DEFINED__ #define __IMMDeviceCollection_INTERFACE_DEFINED__ DEFINE_GUID(IID_IMMDeviceCollection, 0x0bd7a1be, 0x7a1a, 0x44db, 0x83,0x97, 0xcc,0x53,0x92,0x38,0x7b,0x5e); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("0bd7a1be-7a1a-44db-8397-cc5392387b5e") IMMDeviceCollection : public IUnknown { virtual HRESULT STDMETHODCALLTYPE GetCount( UINT *pcDevices) = 0; virtual HRESULT STDMETHODCALLTYPE Item( UINT nDevice, IMMDevice **ppdevice) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IMMDeviceCollection, 0x0bd7a1be, 0x7a1a, 0x44db, 0x83,0x97, 0xcc,0x53,0x92,0x38,0x7b,0x5e) #endif #else typedef struct IMMDeviceCollectionVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IMMDeviceCollection *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IMMDeviceCollection *This); ULONG (STDMETHODCALLTYPE *Release)( IMMDeviceCollection *This); /*** IMMDeviceCollection methods ***/ HRESULT (STDMETHODCALLTYPE *GetCount)( IMMDeviceCollection *This, UINT *pcDevices); HRESULT (STDMETHODCALLTYPE *Item)( IMMDeviceCollection *This, UINT nDevice, IMMDevice **ppdevice); END_INTERFACE } IMMDeviceCollectionVtbl; interface IMMDeviceCollection { CONST_VTBL IMMDeviceCollectionVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IMMDeviceCollection_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IMMDeviceCollection_AddRef(This) (This)->lpVtbl->AddRef(This) #define IMMDeviceCollection_Release(This) (This)->lpVtbl->Release(This) /*** IMMDeviceCollection methods ***/ #define IMMDeviceCollection_GetCount(This,pcDevices) (This)->lpVtbl->GetCount(This,pcDevices) #define IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->lpVtbl->Item(This,nDevice,ppdevice) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IMMDeviceCollection_QueryInterface(IMMDeviceCollection* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IMMDeviceCollection_AddRef(IMMDeviceCollection* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IMMDeviceCollection_Release(IMMDeviceCollection* This) { return This->lpVtbl->Release(This); } /*** IMMDeviceCollection methods ***/ static FORCEINLINE HRESULT IMMDeviceCollection_GetCount(IMMDeviceCollection* This,UINT *pcDevices) { return This->lpVtbl->GetCount(This,pcDevices); } static FORCEINLINE HRESULT IMMDeviceCollection_Item(IMMDeviceCollection* This,UINT nDevice,IMMDevice **ppdevice) { return This->lpVtbl->Item(This,nDevice,ppdevice); } #endif #endif #endif #endif /* __IMMDeviceCollection_INTERFACE_DEFINED__ */ /***************************************************************************** * IMMEndpoint interface */ #ifndef __IMMEndpoint_INTERFACE_DEFINED__ #define __IMMEndpoint_INTERFACE_DEFINED__ DEFINE_GUID(IID_IMMEndpoint, 0x1be09788, 0x6894, 0x4089, 0x85,0x86, 0x9a,0x2a,0x6c,0x26,0x5a,0xc5); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("1be09788-6894-4089-8586-9a2a6c265ac5") IMMEndpoint : public IUnknown { virtual HRESULT STDMETHODCALLTYPE GetDataFlow( EDataFlow *pDataFlow) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IMMEndpoint, 0x1be09788, 0x6894, 0x4089, 0x85,0x86, 0x9a,0x2a,0x6c,0x26,0x5a,0xc5) #endif #else typedef struct IMMEndpointVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IMMEndpoint *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IMMEndpoint *This); ULONG (STDMETHODCALLTYPE *Release)( IMMEndpoint *This); /*** IMMEndpoint methods ***/ HRESULT (STDMETHODCALLTYPE *GetDataFlow)( IMMEndpoint *This, EDataFlow *pDataFlow); END_INTERFACE } IMMEndpointVtbl; interface IMMEndpoint { CONST_VTBL IMMEndpointVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IMMEndpoint_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IMMEndpoint_AddRef(This) (This)->lpVtbl->AddRef(This) #define IMMEndpoint_Release(This) (This)->lpVtbl->Release(This) /*** IMMEndpoint methods ***/ #define IMMEndpoint_GetDataFlow(This,pDataFlow) (This)->lpVtbl->GetDataFlow(This,pDataFlow) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IMMEndpoint_QueryInterface(IMMEndpoint* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IMMEndpoint_AddRef(IMMEndpoint* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IMMEndpoint_Release(IMMEndpoint* This) { return This->lpVtbl->Release(This); } /*** IMMEndpoint methods ***/ static FORCEINLINE HRESULT IMMEndpoint_GetDataFlow(IMMEndpoint* This,EDataFlow *pDataFlow) { return This->lpVtbl->GetDataFlow(This,pDataFlow); } #endif #endif #endif #endif /* __IMMEndpoint_INTERFACE_DEFINED__ */ /***************************************************************************** * IMMDeviceEnumerator interface */ #ifndef __IMMDeviceEnumerator_INTERFACE_DEFINED__ #define __IMMDeviceEnumerator_INTERFACE_DEFINED__ DEFINE_GUID(IID_IMMDeviceEnumerator, 0xa95664d2, 0x9614, 0x4f35, 0xa7,0x46, 0xde,0x8d,0xb6,0x36,0x17,0xe6); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("a95664d2-9614-4f35-a746-de8db63617e6") IMMDeviceEnumerator : public IUnknown { virtual HRESULT STDMETHODCALLTYPE EnumAudioEndpoints( EDataFlow dataFlow, DWORD dwStateMask, IMMDeviceCollection **ppDevices) = 0; virtual HRESULT STDMETHODCALLTYPE GetDefaultAudioEndpoint( EDataFlow dataFlow, ERole role, IMMDevice **ppEndpoint) = 0; virtual HRESULT STDMETHODCALLTYPE GetDevice( LPCWSTR pwstrId, IMMDevice **ppDevice) = 0; virtual HRESULT STDMETHODCALLTYPE RegisterEndpointNotificationCallback( IMMNotificationClient *pClient) = 0; virtual HRESULT STDMETHODCALLTYPE UnregisterEndpointNotificationCallback( IMMNotificationClient *pClient) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IMMDeviceEnumerator, 0xa95664d2, 0x9614, 0x4f35, 0xa7,0x46, 0xde,0x8d,0xb6,0x36,0x17,0xe6) #endif #else typedef struct IMMDeviceEnumeratorVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IMMDeviceEnumerator *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IMMDeviceEnumerator *This); ULONG (STDMETHODCALLTYPE *Release)( IMMDeviceEnumerator *This); /*** IMMDeviceEnumerator methods ***/ HRESULT (STDMETHODCALLTYPE *EnumAudioEndpoints)( IMMDeviceEnumerator *This, EDataFlow dataFlow, DWORD dwStateMask, IMMDeviceCollection **ppDevices); HRESULT (STDMETHODCALLTYPE *GetDefaultAudioEndpoint)( IMMDeviceEnumerator *This, EDataFlow dataFlow, ERole role, IMMDevice **ppEndpoint); HRESULT (STDMETHODCALLTYPE *GetDevice)( IMMDeviceEnumerator *This, LPCWSTR pwstrId, IMMDevice **ppDevice); HRESULT (STDMETHODCALLTYPE *RegisterEndpointNotificationCallback)( IMMDeviceEnumerator *This, IMMNotificationClient *pClient); HRESULT (STDMETHODCALLTYPE *UnregisterEndpointNotificationCallback)( IMMDeviceEnumerator *This, IMMNotificationClient *pClient); END_INTERFACE } IMMDeviceEnumeratorVtbl; interface IMMDeviceEnumerator { CONST_VTBL IMMDeviceEnumeratorVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IMMDeviceEnumerator_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IMMDeviceEnumerator_AddRef(This) (This)->lpVtbl->AddRef(This) #define IMMDeviceEnumerator_Release(This) (This)->lpVtbl->Release(This) /*** IMMDeviceEnumerator methods ***/ #define IMMDeviceEnumerator_EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) (This)->lpVtbl->EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) #define IMMDeviceEnumerator_GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) (This)->lpVtbl->GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) #define IMMDeviceEnumerator_GetDevice(This,pwstrId,ppDevice) (This)->lpVtbl->GetDevice(This,pwstrId,ppDevice) #define IMMDeviceEnumerator_RegisterEndpointNotificationCallback(This,pClient) (This)->lpVtbl->RegisterEndpointNotificationCallback(This,pClient) #define IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(This,pClient) (This)->lpVtbl->UnregisterEndpointNotificationCallback(This,pClient) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IMMDeviceEnumerator_QueryInterface(IMMDeviceEnumerator* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IMMDeviceEnumerator_AddRef(IMMDeviceEnumerator* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IMMDeviceEnumerator_Release(IMMDeviceEnumerator* This) { return This->lpVtbl->Release(This); } /*** IMMDeviceEnumerator methods ***/ static FORCEINLINE HRESULT IMMDeviceEnumerator_EnumAudioEndpoints(IMMDeviceEnumerator* This,EDataFlow dataFlow,DWORD dwStateMask,IMMDeviceCollection **ppDevices) { return This->lpVtbl->EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices); } static FORCEINLINE HRESULT IMMDeviceEnumerator_GetDefaultAudioEndpoint(IMMDeviceEnumerator* This,EDataFlow dataFlow,ERole role,IMMDevice **ppEndpoint) { return This->lpVtbl->GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint); } static FORCEINLINE HRESULT IMMDeviceEnumerator_GetDevice(IMMDeviceEnumerator* This,LPCWSTR pwstrId,IMMDevice **ppDevice) { return This->lpVtbl->GetDevice(This,pwstrId,ppDevice); } static FORCEINLINE HRESULT IMMDeviceEnumerator_RegisterEndpointNotificationCallback(IMMDeviceEnumerator* This,IMMNotificationClient *pClient) { return This->lpVtbl->RegisterEndpointNotificationCallback(This,pClient); } static FORCEINLINE HRESULT IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(IMMDeviceEnumerator* This,IMMNotificationClient *pClient) { return This->lpVtbl->UnregisterEndpointNotificationCallback(This,pClient); } #endif #endif #endif #endif /* __IMMDeviceEnumerator_INTERFACE_DEFINED__ */ /***************************************************************************** * IMMDeviceActivator interface */ #ifndef __IMMDeviceActivator_INTERFACE_DEFINED__ #define __IMMDeviceActivator_INTERFACE_DEFINED__ DEFINE_GUID(IID_IMMDeviceActivator, 0x3b0d0ea4, 0xd0a9, 0x4b0e, 0x93,0x5b, 0x09,0x51,0x67,0x46,0xfa,0xc0); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("3b0d0ea4-d0a9-4b0e-935b-09516746fac0") IMMDeviceActivator : public IUnknown { virtual HRESULT STDMETHODCALLTYPE Activate( REFIID iid, IMMDevice *pDevice, PROPVARIANT *pActivationParams, void **ppv) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IMMDeviceActivator, 0x3b0d0ea4, 0xd0a9, 0x4b0e, 0x93,0x5b, 0x09,0x51,0x67,0x46,0xfa,0xc0) #endif #else typedef struct IMMDeviceActivatorVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IMMDeviceActivator *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IMMDeviceActivator *This); ULONG (STDMETHODCALLTYPE *Release)( IMMDeviceActivator *This); /*** IMMDeviceActivator methods ***/ HRESULT (STDMETHODCALLTYPE *Activate)( IMMDeviceActivator *This, REFIID iid, IMMDevice *pDevice, PROPVARIANT *pActivationParams, void **ppv); END_INTERFACE } IMMDeviceActivatorVtbl; interface IMMDeviceActivator { CONST_VTBL IMMDeviceActivatorVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IMMDeviceActivator_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IMMDeviceActivator_AddRef(This) (This)->lpVtbl->AddRef(This) #define IMMDeviceActivator_Release(This) (This)->lpVtbl->Release(This) /*** IMMDeviceActivator methods ***/ #define IMMDeviceActivator_Activate(This,iid,pDevice,pActivationParams,ppv) (This)->lpVtbl->Activate(This,iid,pDevice,pActivationParams,ppv) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IMMDeviceActivator_QueryInterface(IMMDeviceActivator* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IMMDeviceActivator_AddRef(IMMDeviceActivator* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IMMDeviceActivator_Release(IMMDeviceActivator* This) { return This->lpVtbl->Release(This); } /*** IMMDeviceActivator methods ***/ static FORCEINLINE HRESULT IMMDeviceActivator_Activate(IMMDeviceActivator* This,REFIID iid,IMMDevice *pDevice,PROPVARIANT *pActivationParams,void **ppv) { return This->lpVtbl->Activate(This,iid,pDevice,pActivationParams,ppv); } #endif #endif #endif #endif /* __IMMDeviceActivator_INTERFACE_DEFINED__ */ typedef struct _AudioExtensionParams { LPARAM AddPageParam; IMMDevice *pEndPoint; IMMDevice *pPnpInterface; IMMDevice *pPnpDevnode; } AudioExtensionParams; DEFINE_GUID(LIBID_MMDeviceAPILib, 0x2fdaafa3, 0x7523, 0x4f66, 0x99,0x57, 0x9d,0x5e,0x7f,0xe6,0x98,0xf6); /***************************************************************************** * MMDeviceEnumerator coclass */ DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xbcde0395, 0xe52f, 0x467c, 0x8e,0x3d, 0xc4,0x57,0x92,0x91,0x69,0x2e); #ifdef __cplusplus class DECLSPEC_UUID("bcde0395-e52f-467c-8e3d-c4579291692e") MMDeviceEnumerator; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(MMDeviceEnumerator, 0xbcde0395, 0xe52f, 0x467c, 0x8e,0x3d, 0xc4,0x57,0x92,0x91,0x69,0x2e) #endif #endif /* Begin additional prototypes for all interfaces */ /* End additional prototypes */ #ifdef __cplusplus } #endif #endif /* __mmdeviceapi_h__ */
[ "_@jeremy.ca" ]
_@jeremy.ca
fb131c058357a627a6913624d756d9a4e2de711f
c51919425871367c55f100d91b8d5335171bb37b
/src/sysdicts/main.cpp
04827a6090013f17d2110845d9bafa6cdb51605b
[ "Apache-2.0" ]
permissive
hugh67/clause
ecf8408cb43b358fed78a7b44b7a1f1c4c80144a
27247532a8644f9f1fd826b535951891232b686d
refs/heads/master
2020-08-16T20:20:22.029690
2019-09-30T15:29:41
2019-09-30T15:29:41
215,547,745
2
0
NOASSERTION
2019-10-16T12:53:32
2019-10-16T12:53:28
null
UTF-8
C++
false
false
2,293
cpp
// This autogenerated skeleton file illustrates how to build a server. // You should copy it to another filename to avoid overwriting it. #include <gflags/gflags.h> #include <glog/logging.h> #include "thrift/concurrency/ThreadManager.h" #include "thrift/concurrency/PlatformThreadFactory.h" #include "thrift/concurrency/Thread.h" #include "thrift/protocol/TBinaryProtocol.h" #include "thrift/server/TNonblockingServer.h" #include "thrift/transport/TNonblockingServerSocket.h" #include "thrift/transport/TNonblockingServerTransport.h" #include "thrift/transport/TBufferTransports.h" #include "basictypes.h" #include "serving/Serving.h" #include "src/handler.h" DEFINE_int32(server_port, 6600, "Server's port to process requests."); DEFINE_int32(server_threads, 24, "serving threads"); DEFINE_string(lac_conf_dir, "../../../../var/data/lac/conf", "Baidu LAC Config dir"); using namespace std; using namespace ::chatopera::bot::sysdicts; using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::server; int main(int argc, char *argv[]) { // 解析命令行参数 gflags::ParseCommandLineFlags(&argc, &argv, true); // 初始化日志库 google::InitGoogleLogging(argv[0]); versionPrint("Chatopera Bot Sysdicts Service"); stdcxx::shared_ptr<ServingHandler> handler(new ServingHandler()); CHECK(handler->init()) << "[Fatal Error] Serving Handler fails to init."; stdcxx::shared_ptr<TProcessor> processor(new ServingProcessor(handler)); stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); stdcxx::shared_ptr<TNonblockingServerTransport> serverTransport(new TNonblockingServerSocket(FLAGS_server_port)); stdcxx::shared_ptr<PlatformThreadFactory> threadFactory = std::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()); stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(FLAGS_server_threads); threadManager->threadFactory(threadFactory); threadManager->start(); stdcxx::shared_ptr<TNonblockingServer> server(new TNonblockingServer(processor, protocolFactory, serverTransport, threadManager)); VLOG(2) << "serving on port " << FLAGS_server_port; server->serve(); return 0; }
[ "hain@chatopera.com" ]
hain@chatopera.com
c1b248afc76bcd760eb4e2ca96947f2a2b3de828
52200577bb7a56d108765e4fcb70c9bde27a4ece
/Continuous Subarray Sum/main.cpp
20ece8e2857bd821ad6aaf611f49dcd37ba3ed5d
[]
no_license
zjsxzy/Leetcode
59e7da0319b567b5349a97de401a9990ea7a4df8
d540f0e921cae3b17da7c9f4932d4a3e3419c245
refs/heads/master
2023-08-19T08:50:48.874076
2023-08-06T05:22:37
2023-08-06T05:22:37
13,141,035
2
0
null
null
null
null
UTF-8
C++
false
false
1,046
cpp
#include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <bitset> #include <vector> #include <cstdio> #include <string> #include <cassert> #include <climits> #include <sstream> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define PB push_back #define MP make_pair #define SZ(v) ((int)(v).size()) #define abs(x) ((x) > 0 ? (x) : -(x)) #define FOREACH(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e) typedef long long LL; class Solution { public: bool checkSubarraySum(vector<int>& nums, int k) { map<int, int> mp; int sum = 0; mp[0] = -1; for (int i = 0; i < nums.size(); i++) { sum += nums[i]; if (k != 0) sum %= k; if (mp.find(sum) != mp.end()) { if (i - mp[sum] > 1) { return true; } } else { mp[sum] = i; } } return false; } }; int main() { }
[ "zjsxzy@gmail.com" ]
zjsxzy@gmail.com
2bd56e3df6412ba5a2dedb25133bcc390139beed
5cb5e527ac6de040ab0c8930f9d6b5db597b9cf9
/OOPS1/p130(file handling copy contents on console).cpp
4eeeaef40a91404f449fc5eb7991cbed510f45f4
[]
no_license
Ayushi1999/OOPS-Concepts
8edc5d6c9a5058be90a606d944881e8b69ce7298
3be1e287c544f02cd47881dfe471702290681a6d
refs/heads/master
2020-04-25T17:51:56.441106
2019-03-19T21:46:44
2019-03-19T21:46:44
172,963,910
0
0
null
null
null
null
UTF-8
C++
false
false
243
cpp
#include<iostream> using namespace std; #include<fstream> int main() { ifstream ifile; ofstream ofile("c.txt"); string str; ifile.open("ff.txt"); if(!ifile) { cout<<"error"; } while(!ifile.eof()) { getline(ifile,str); cout<<str; } return 0; }
[ "ayushigupta062@gmail.com" ]
ayushigupta062@gmail.com
fdbaa99c8b124983d0469acda11dc6feb597ffbf
600e235fc93f0dc7d7fcfc2fd20f29c7b787fef3
/Botnia/Botnia_2012/wireless/.svn/text-base/commandsender.cpp.svn-base
287314ea3e998d0f5ea2ec44375377857ca16b0f
[]
no_license
barry963/Robot_project
81c98f4a14ac44034664636005b7e77f7103dbc9
5b9ea404cceed1d9b8a5f85a84ce5dc29448ea3a
refs/heads/master
2021-01-19T15:28:32.962030
2014-03-31T17:45:31
2014-03-31T17:45:31
13,648,517
1
0
null
null
null
null
UTF-8
C++
false
false
2,928
#include "commandsender.h" /*static const unsigned char ComDesAddr[][6]= { {0x98,0xa5,0xc0,0x2e,0x30,0x00}, //Robot0 {0x40,0xa5,0xc0,0x2e,0x30,0x00}, //Robot1 {0x90,0xa5,0xc0,0x2e,0x30,0x00}, //Robot2 {0x20,0xa5,0xc0,0x2e,0x30,0x00}, //Robot3 {0x10,0xa5,0xc0,0x2e,0x30,0x00}, //Robot4 {0xff,0xff,0xff,0xff,0xff,0xff} //broadcast Addr };*/ //static const unsigned char ComScrAddr[6]={0x60,0xa5,0xc0,0x2e,0x30,0x00}; void BytesList::Reset(unsigned char RobotID,RobotAction action) { count=0; //头部 // memcpy(comheadpart.DesAddr,ComDesAddr[RobotID],6); /*memcpy(comheadpart.DesAddr,ComDesAddr[5],6); memcpy(buffer,&comheadpart,sizeof(comheadpart)); count+=sizeof(comheadpart);*/ //数据部分 buffer[count++]=CHARSYN; buffer[count++]=RobotID | action; //buffer[count++]=action; //buffer[count++]=0; } /*static unsigned short CalculateCRC( // copyed from HW86012_FM_210 datasheet unsigned char *Block, //array of bytes unsigned int BlockLen //length of Block in bytes ) { unsigned short crc = 0; //CRC initialised with zero unsigned char BitPos; //counter for bit level loop while (BlockLen != 0) //main loop over all bytes { crc ^= ( (unsigned short) *Block++ << 8); //modulo-2 add a byte for (BitPos=0; BitPos<8; BitPos++) //loop over all bits of byte { if (crc & 0x8000) crc = (crc << 1) ^ 0x1021; else crc <<= 1; //apply generator polynomial } BlockLen--; //decrement loop counter } return crc; } void BytesList::AddEndPart(void) { //计算校验和 // unsigned short checksum=CalculateCRC((unsigned char*)(&comheadpart),3); unsigned short checksum=CalculateCRC((unsigned char*)(buffer)+1,count-1); comendpart.CrcLow=checksum; comendpart.CrcHigh=checksum>>8; // comendpart.CrcLow=0x47; // comendpart.CrcHigh=0xbb; // memcpy(buffer+count,&comendpart,sizeof(comendpart)); count+=sizeof(comendpart); //comheadpart.DataLenLow=count-20; comheadpart.DataLenLow=count-4; buffer[15]=comheadpart.DataLenLow; }*/ void BytesList::Send(void) { serialport.Write(buffer,count); //char *str="good\r\n"; //static unsigned char data=0x00; //serialport.Write(&data,1); //data++; } CommandSender::CommandSender() { } CommandSender::~CommandSender() { } void CommandSender::SendToRobot(Robot& p,unsigned char RobotID) { SetData(p); GetChecksum(); buffer.Reset(RobotID,action); // buffer.Display(); buffer.AddByte(vxh); buffer.AddByte(vxl); buffer.AddByte(vyh); buffer.AddByte(vyl); buffer.AddByte(vth); buffer.AddByte(vtl); buffer.AddByte(CheckSum); buffer.AddByte(0xff-CheckSum); // buffer.Display(); // buffer.AddEndPart(); // buffer.Display(); buffer.Send(); }
[ "barry963@gmail.com" ]
barry963@gmail.com
e1cc452bdaf60a37e54d755b1019a177b591a639
cfbecc77801ad53b6ff21580039fecd95066481b
/src/vendor/stb_image/stb_image.cpp
0b9470fe9a0fbdc756dab5c208d6c43def87d294
[]
no_license
Abhishrut/OpenGL
1fa125265f9b28d999d7afd929f5ce50789fcf1b
7c043ca4bf1f7788ebb7f0b31df1ae7e2382dbf4
refs/heads/master
2022-12-05T08:44:25.687807
2020-08-29T11:04:15
2020-08-29T11:04:15
289,100,419
0
0
null
null
null
null
UTF-8
C++
false
false
57
cpp
#define STB_IMAGE_IMPLEMENTATION #include"stb_image.h"
[ "abhishrutk37@gmail.com" ]
abhishrutk37@gmail.com
f8c2153e302e555d8aab70c9204c092dc098115f
69141e6f8b512a01260b07c0e04d45b4fee1a1dc
/black_label/libraries/rendering/source/rendering/initialize.cpp
5b3520596c0591913d5ceec9f7ee289f435c656d
[]
no_license
swordow/sfj
e10617536cf104f2b90ce2c6ff0d33d7f48173de
68698f1dc150ee220144d1dbe66432354f324509
refs/heads/master
2021-06-08T14:49:13.051726
2016-12-05T10:13:07
2016-12-05T10:13:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,120
cpp
#define BLACK_LABEL_SHARED_LIBRARY_EXPORT #include <black_label/rendering/initialize.hpp> #include <stdexcept> #include <GL/glew.h> namespace black_label { namespace rendering { using namespace std; void initialize() { glewExperimental = GL_TRUE; GLenum glew_error = glewInit(); if (GLEW_OK != glew_error) throw runtime_error{"Glew failed to initialize."}; if (!GLEW_VERSION_3_3) throw runtime_error{"Requires OpenGL version 3.3 or above."}; GLint max_draw_buffers; glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers); if (3 > max_draw_buffers) throw runtime_error{"Requires at least 3 draw buffers."}; if (!GLEW_ARB_shader_storage_buffer_object) throw runtime_error{"Requires GLEW_ARB_shader_storage_buffer_object."}; if (!GLEW_ARB_shader_image_load_store) throw runtime_error{"Requires GLEW_ARB_shader_image_load_store."}; if (GLEW_ARB_texture_storage) glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); glEnable(GL_FRAMEBUFFER_SRGB); } void set_clear_color( glm::vec4 color ) { glClearColor(color.r, color.g, color.b, color.a); } } // namespace rendering } // namespace black_label
[ "frederikaalund@gmail.com" ]
frederikaalund@gmail.com
31695f38f673ecb2f4ade9e231ec96cdaa68950a
24a8c6d6bdd388ce274d4dde4697bc6b5df9f74d
/build-22-Desktop-Debug/moc_mythread.cpp
28c81da7c6745f9be607a07d033f0ad8665726e2
[]
no_license
evanxu123/LTE_Qt_creater
1e4294fc9f25a5f9628ad340cf5e490ec9fb1816
0222554c323a85da5ec14fc5d565db0722bac24d
refs/heads/master
2021-01-22T05:47:08.532527
2017-02-12T04:36:20
2017-02-12T04:36:20
81,702,977
0
0
null
null
null
null
UTF-8
C++
false
false
2,528
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'mythread.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.2.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../22/mythread.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'mythread.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.2.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_MyThread_t { QByteArrayData data[1]; char stringdata[10]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ offsetof(qt_meta_stringdata_MyThread_t, stringdata) + ofs \ - idx * sizeof(QByteArrayData) \ ) static const qt_meta_stringdata_MyThread_t qt_meta_stringdata_MyThread = { { QT_MOC_LITERAL(0, 0, 8) }, "MyThread\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_MyThread[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; void MyThread::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } const QMetaObject MyThread::staticMetaObject = { { &QThread::staticMetaObject, qt_meta_stringdata_MyThread.data, qt_meta_data_MyThread, qt_static_metacall, 0, 0} }; const QMetaObject *MyThread::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *MyThread::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_MyThread.stringdata)) return static_cast<void*>(const_cast< MyThread*>(this)); return QThread::qt_metacast(_clname); } int MyThread::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QThread::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_END_MOC_NAMESPACE
[ "evan_xu123@163.com" ]
evan_xu123@163.com
6ecc3f6a2cb714515c9908a383f7f3991c968105
66f5dce4d7af02da8ee209792d9fb024d526c21c
/3rdParty/V8/v5.7.0.0/src/compiler/access-info.cc
866b06086a2042df0f6a811e25c7fa8a1f36ce62
[ "BSD-3-Clause", "bzip2-1.0.6", "SunPro", "Apache-2.0", "Zlib", "ICU", "LicenseRef-scancode-autoconf-simple-exception", "GPL-1.0-or-later", "LicenseRef-scancode-pcre", "ISC", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "WTFPL", "MIT", "LicenseRef-scancode-pr...
permissive
dolfly/arangodb
9582bd894b79d421c4916133760fb8c637061a44
b3ee17672e19e48db97c5dafce5978ba0a272fb5
refs/heads/devel
2021-07-08T04:41:49.701017
2017-08-07T15:06:02
2017-08-07T15:06:02
99,658,017
0
0
Apache-2.0
2020-06-16T05:55:53
2017-08-08T06:26:58
C++
UTF-8
C++
false
false
21,854
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 <ostream> #include "src/accessors.h" #include "src/compilation-dependencies.h" #include "src/compiler/access-info.h" #include "src/compiler/type-cache.h" #include "src/field-index-inl.h" #include "src/field-type.h" #include "src/ic/call-optimization.h" #include "src/objects-inl.h" namespace v8 { namespace internal { namespace compiler { namespace { bool CanInlineElementAccess(Handle<Map> map) { if (!map->IsJSObjectMap()) return false; if (map->is_access_check_needed()) return false; if (map->has_indexed_interceptor()) return false; ElementsKind const elements_kind = map->elements_kind(); if (IsFastElementsKind(elements_kind)) return true; if (IsFixedTypedArrayElementsKind(elements_kind)) return true; return false; } bool CanInlinePropertyAccess(Handle<Map> map) { // We can inline property access to prototypes of all primitives, except // the special Oddball ones that have no wrapper counterparts (i.e. Null, // Undefined and TheHole). STATIC_ASSERT(ODDBALL_TYPE == LAST_PRIMITIVE_TYPE); if (map->IsBooleanMap()) return true; if (map->instance_type() < LAST_PRIMITIVE_TYPE) return true; return map->IsJSObjectMap() && !map->is_dictionary_map() && !map->has_named_interceptor() && // TODO(verwaest): Whitelist contexts to which we have access. !map->is_access_check_needed(); } } // namespace std::ostream& operator<<(std::ostream& os, AccessMode access_mode) { switch (access_mode) { case AccessMode::kLoad: return os << "Load"; case AccessMode::kStore: return os << "Store"; } UNREACHABLE(); return os; } ElementAccessInfo::ElementAccessInfo() {} ElementAccessInfo::ElementAccessInfo(MapList const& receiver_maps, ElementsKind elements_kind) : elements_kind_(elements_kind), receiver_maps_(receiver_maps) {} // static PropertyAccessInfo PropertyAccessInfo::NotFound(MapList const& receiver_maps, MaybeHandle<JSObject> holder) { return PropertyAccessInfo(holder, receiver_maps); } // static PropertyAccessInfo PropertyAccessInfo::DataConstant( MapList const& receiver_maps, Handle<Object> constant, MaybeHandle<JSObject> holder) { return PropertyAccessInfo(kDataConstant, holder, constant, receiver_maps); } // static PropertyAccessInfo PropertyAccessInfo::DataField( MapList const& receiver_maps, FieldIndex field_index, MachineRepresentation field_representation, Type* field_type, MaybeHandle<Map> field_map, MaybeHandle<JSObject> holder, MaybeHandle<Map> transition_map) { return PropertyAccessInfo(holder, transition_map, field_index, field_representation, field_type, field_map, receiver_maps); } // static PropertyAccessInfo PropertyAccessInfo::AccessorConstant( MapList const& receiver_maps, Handle<Object> constant, MaybeHandle<JSObject> holder) { return PropertyAccessInfo(kAccessorConstant, holder, constant, receiver_maps); } // static PropertyAccessInfo PropertyAccessInfo::Generic(MapList const& receiver_maps) { return PropertyAccessInfo(kGeneric, MaybeHandle<JSObject>(), Handle<Object>(), receiver_maps); } PropertyAccessInfo::PropertyAccessInfo() : kind_(kInvalid), field_representation_(MachineRepresentation::kNone), field_type_(Type::None()) {} PropertyAccessInfo::PropertyAccessInfo(MaybeHandle<JSObject> holder, MapList const& receiver_maps) : kind_(kNotFound), receiver_maps_(receiver_maps), holder_(holder), field_representation_(MachineRepresentation::kNone), field_type_(Type::None()) {} PropertyAccessInfo::PropertyAccessInfo(Kind kind, MaybeHandle<JSObject> holder, Handle<Object> constant, MapList const& receiver_maps) : kind_(kind), receiver_maps_(receiver_maps), constant_(constant), holder_(holder), field_representation_(MachineRepresentation::kNone), field_type_(Type::Any()) {} PropertyAccessInfo::PropertyAccessInfo( MaybeHandle<JSObject> holder, MaybeHandle<Map> transition_map, FieldIndex field_index, MachineRepresentation field_representation, Type* field_type, MaybeHandle<Map> field_map, MapList const& receiver_maps) : kind_(kDataField), receiver_maps_(receiver_maps), transition_map_(transition_map), holder_(holder), field_index_(field_index), field_representation_(field_representation), field_type_(field_type), field_map_(field_map) {} bool PropertyAccessInfo::Merge(PropertyAccessInfo const* that) { if (this->kind_ != that->kind_) return false; if (this->holder_.address() != that->holder_.address()) return false; switch (this->kind_) { case kInvalid: break; case kNotFound: return true; case kDataField: { // Check if we actually access the same field. if (this->transition_map_.address() == that->transition_map_.address() && this->field_index_ == that->field_index_ && this->field_type_->Is(that->field_type_) && that->field_type_->Is(this->field_type_) && this->field_representation_ == that->field_representation_) { this->receiver_maps_.insert(this->receiver_maps_.end(), that->receiver_maps_.begin(), that->receiver_maps_.end()); return true; } return false; } case kDataConstant: case kAccessorConstant: { // Check if we actually access the same constant. if (this->constant_.address() == that->constant_.address()) { this->receiver_maps_.insert(this->receiver_maps_.end(), that->receiver_maps_.begin(), that->receiver_maps_.end()); return true; } return false; } case kGeneric: { this->receiver_maps_.insert(this->receiver_maps_.end(), that->receiver_maps_.begin(), that->receiver_maps_.end()); return true; } } UNREACHABLE(); return false; } AccessInfoFactory::AccessInfoFactory(CompilationDependencies* dependencies, Handle<Context> native_context, Zone* zone) : dependencies_(dependencies), native_context_(native_context), isolate_(native_context->GetIsolate()), type_cache_(TypeCache::Get()), zone_(zone) { DCHECK(native_context->IsNativeContext()); } bool AccessInfoFactory::ComputeElementAccessInfo( Handle<Map> map, AccessMode access_mode, ElementAccessInfo* access_info) { // Check if it is safe to inline element access for the {map}. if (!CanInlineElementAccess(map)) return false; ElementsKind const elements_kind = map->elements_kind(); *access_info = ElementAccessInfo(MapList{map}, elements_kind); return true; } bool AccessInfoFactory::ComputeElementAccessInfos( MapHandleList const& maps, AccessMode access_mode, ZoneVector<ElementAccessInfo>* access_infos) { // Collect possible transition targets. MapHandleList possible_transition_targets(maps.length()); for (Handle<Map> map : maps) { if (Map::TryUpdate(map).ToHandle(&map)) { if (CanInlineElementAccess(map) && IsFastElementsKind(map->elements_kind()) && GetInitialFastElementsKind() != map->elements_kind()) { possible_transition_targets.Add(map); } } } // Separate the actual receiver maps and the possible transition sources. MapHandleList receiver_maps(maps.length()); MapTransitionList transitions(maps.length()); for (Handle<Map> map : maps) { if (Map::TryUpdate(map).ToHandle(&map)) { Map* transition_target = map->FindElementsKindTransitionedMap(&possible_transition_targets); if (transition_target == nullptr) { receiver_maps.Add(map); } else { transitions.push_back(std::make_pair(map, handle(transition_target))); } } } for (Handle<Map> receiver_map : receiver_maps) { // Compute the element access information. ElementAccessInfo access_info; if (!ComputeElementAccessInfo(receiver_map, access_mode, &access_info)) { return false; } // Collect the possible transitions for the {receiver_map}. for (auto transition : transitions) { if (transition.second.is_identical_to(receiver_map)) { access_info.transitions().push_back(transition); } } // Schedule the access information. access_infos->push_back(access_info); } return true; } bool AccessInfoFactory::ComputePropertyAccessInfo( Handle<Map> map, Handle<Name> name, AccessMode access_mode, PropertyAccessInfo* access_info) { // Check if it is safe to inline property access for the {map}. if (!CanInlinePropertyAccess(map)) return false; // Compute the receiver type. Handle<Map> receiver_map = map; // Property lookups require the name to be internalized. name = isolate()->factory()->InternalizeName(name); // We support fast inline cases for certain JSObject getters. if (access_mode == AccessMode::kLoad && LookupSpecialFieldAccessor(map, name, access_info)) { return true; } MaybeHandle<JSObject> holder; do { // Lookup the named property on the {map}. Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate()); int const number = descriptors->SearchWithCache(isolate(), *name, *map); if (number != DescriptorArray::kNotFound) { PropertyDetails const details = descriptors->GetDetails(number); if (access_mode == AccessMode::kStore) { // Don't bother optimizing stores to read-only properties. if (details.IsReadOnly()) { return false; } // Check for store to data property on a prototype. if (details.kind() == kData && !holder.is_null()) { // Store to property not found on the receiver but on a prototype, we // need to transition to a new data property. // Implemented according to ES6 section 9.1.9 [[Set]] (P, V, Receiver) return LookupTransition(receiver_map, name, holder, access_info); } } switch (details.type()) { case DATA_CONSTANT: { *access_info = PropertyAccessInfo::DataConstant( MapList{receiver_map}, handle(descriptors->GetValue(number), isolate()), holder); return true; } case DATA: { int index = descriptors->GetFieldIndex(number); Representation details_representation = details.representation(); FieldIndex field_index = FieldIndex::ForPropertyIndex( *map, index, details_representation.IsDouble()); Type* field_type = Type::NonInternal(); MachineRepresentation field_representation = MachineRepresentation::kTagged; MaybeHandle<Map> field_map; if (details_representation.IsSmi()) { field_type = Type::SignedSmall(); field_representation = MachineRepresentation::kTaggedSigned; } else if (details_representation.IsDouble()) { field_type = type_cache_.kFloat64; field_representation = MachineRepresentation::kFloat64; } else if (details_representation.IsHeapObject()) { // Extract the field type from the property details (make sure its // representation is TaggedPointer to reflect the heap object case). field_representation = MachineRepresentation::kTaggedPointer; Handle<FieldType> descriptors_field_type( descriptors->GetFieldType(number), isolate()); if (descriptors_field_type->IsNone()) { // Store is not safe if the field type was cleared. if (access_mode == AccessMode::kStore) return false; // The field type was cleared by the GC, so we don't know anything // about the contents now. } else if (descriptors_field_type->IsClass()) { // Add proper code dependencies in case of stable field map(s). Handle<Map> field_owner_map(map->FindFieldOwner(number), isolate()); dependencies()->AssumeFieldOwner(field_owner_map); // Remember the field map, and try to infer a useful type. field_type = Type::For(descriptors_field_type->AsClass()); field_map = descriptors_field_type->AsClass(); } } *access_info = PropertyAccessInfo::DataField( MapList{receiver_map}, field_index, field_representation, field_type, field_map, holder); return true; } case ACCESSOR_CONSTANT: { Handle<Object> accessors(descriptors->GetValue(number), isolate()); if (!accessors->IsAccessorPair()) return false; Handle<Object> accessor( access_mode == AccessMode::kLoad ? Handle<AccessorPair>::cast(accessors)->getter() : Handle<AccessorPair>::cast(accessors)->setter(), isolate()); if (!accessor->IsJSFunction()) { CallOptimization optimization(accessor); if (!optimization.is_simple_api_call()) { return false; } if (optimization.api_call_info()->fast_handler()->IsCode()) { return false; } } *access_info = PropertyAccessInfo::AccessorConstant( MapList{receiver_map}, accessor, holder); return true; } case ACCESSOR: { // TODO(turbofan): Add support for general accessors? return false; } } UNREACHABLE(); return false; } // Don't search on the prototype chain for special indices in case of // integer indexed exotic objects (see ES6 section 9.4.5). if (map->IsJSTypedArrayMap() && name->IsString() && IsSpecialIndex(isolate()->unicode_cache(), String::cast(*name))) { return false; } // Don't lookup private symbols on the prototype chain. if (name->IsPrivate()) return false; // Walk up the prototype chain. if (!map->prototype()->IsJSObject()) { // Perform the implicit ToObject for primitives here. // Implemented according to ES6 section 7.3.2 GetV (V, P). Handle<JSFunction> constructor; if (Map::GetConstructorFunction(map, native_context()) .ToHandle(&constructor)) { map = handle(constructor->initial_map(), isolate()); DCHECK(map->prototype()->IsJSObject()); } else if (map->prototype()->IsNull(isolate())) { // Store to property not found on the receiver or any prototype, we need // to transition to a new data property. // Implemented according to ES6 section 9.1.9 [[Set]] (P, V, Receiver) if (access_mode == AccessMode::kStore) { return LookupTransition(receiver_map, name, holder, access_info); } // The property was not found, return undefined or throw depending // on the language mode of the load operation. // Implemented according to ES6 section 9.1.8 [[Get]] (P, Receiver) *access_info = PropertyAccessInfo::NotFound(MapList{receiver_map}, holder); return true; } else { return false; } } Handle<JSObject> map_prototype(JSObject::cast(map->prototype()), isolate()); if (map_prototype->map()->is_deprecated()) { // Try to migrate the prototype object so we don't embed the deprecated // map into the optimized code. JSObject::TryMigrateInstance(map_prototype); } map = handle(map_prototype->map(), isolate()); holder = map_prototype; } while (CanInlinePropertyAccess(map)); return false; } bool AccessInfoFactory::ComputePropertyAccessInfos( MapHandleList const& maps, Handle<Name> name, AccessMode access_mode, ZoneVector<PropertyAccessInfo>* access_infos) { for (Handle<Map> map : maps) { if (Map::TryUpdate(map).ToHandle(&map)) { PropertyAccessInfo access_info; if (!ComputePropertyAccessInfo(map, name, access_mode, &access_info)) { return false; } // Try to merge the {access_info} with an existing one. bool merged = false; for (PropertyAccessInfo& other_info : *access_infos) { if (other_info.Merge(&access_info)) { merged = true; break; } } if (!merged) access_infos->push_back(access_info); } } return true; } bool AccessInfoFactory::LookupSpecialFieldAccessor( Handle<Map> map, Handle<Name> name, PropertyAccessInfo* access_info) { // Check for special JSObject field accessors. int offset; if (Accessors::IsJSObjectFieldAccessor(map, name, &offset)) { FieldIndex field_index = FieldIndex::ForInObjectOffset(offset); Type* field_type = Type::NonInternal(); MachineRepresentation field_representation = MachineRepresentation::kTagged; if (map->IsStringMap()) { DCHECK(Name::Equals(factory()->length_string(), name)); // The String::length property is always a smi in the range // [0, String::kMaxLength]. field_type = type_cache_.kStringLengthType; field_representation = MachineRepresentation::kTaggedSigned; } else if (map->IsJSArrayMap()) { DCHECK(Name::Equals(factory()->length_string(), name)); // The JSArray::length property is a smi in the range // [0, FixedDoubleArray::kMaxLength] in case of fast double // elements, a smi in the range [0, FixedArray::kMaxLength] // in case of other fast elements, and [0, kMaxUInt32] in // case of other arrays. if (IsFastDoubleElementsKind(map->elements_kind())) { field_type = type_cache_.kFixedDoubleArrayLengthType; field_representation = MachineRepresentation::kTaggedSigned; } else if (IsFastElementsKind(map->elements_kind())) { field_type = type_cache_.kFixedArrayLengthType; field_representation = MachineRepresentation::kTaggedSigned; } else { field_type = type_cache_.kJSArrayLengthType; } } *access_info = PropertyAccessInfo::DataField( MapList{map}, field_index, field_representation, field_type); return true; } return false; } bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name, MaybeHandle<JSObject> holder, PropertyAccessInfo* access_info) { // Check if the {map} has a data transition with the given {name}. if (map->unused_property_fields() == 0) { *access_info = PropertyAccessInfo::Generic(MapList{map}); return true; } Handle<Map> transition_map; if (TransitionArray::SearchTransition(map, kData, name, NONE) .ToHandle(&transition_map)) { int const number = transition_map->LastAdded(); PropertyDetails const details = transition_map->instance_descriptors()->GetDetails(number); // Don't bother optimizing stores to read-only properties. if (details.IsReadOnly()) return false; // TODO(bmeurer): Handle transition to data constant? if (details.type() != DATA) return false; int const index = details.field_index(); Representation details_representation = details.representation(); FieldIndex field_index = FieldIndex::ForPropertyIndex( *transition_map, index, details_representation.IsDouble()); Type* field_type = Type::NonInternal(); MaybeHandle<Map> field_map; MachineRepresentation field_representation = MachineRepresentation::kTagged; if (details_representation.IsSmi()) { field_type = Type::SignedSmall(); field_representation = MachineRepresentation::kTaggedSigned; } else if (details_representation.IsDouble()) { field_type = type_cache_.kFloat64; field_representation = MachineRepresentation::kFloat64; } else if (details_representation.IsHeapObject()) { // Extract the field type from the property details (make sure its // representation is TaggedPointer to reflect the heap object case). field_representation = MachineRepresentation::kTaggedPointer; Handle<FieldType> descriptors_field_type( transition_map->instance_descriptors()->GetFieldType(number), isolate()); if (descriptors_field_type->IsNone()) { // Store is not safe if the field type was cleared. return false; } else if (descriptors_field_type->IsClass()) { // Add proper code dependencies in case of stable field map(s). Handle<Map> field_owner_map(transition_map->FindFieldOwner(number), isolate()); dependencies()->AssumeFieldOwner(field_owner_map); // Remember the field map, and try to infer a useful type. field_type = Type::For(descriptors_field_type->AsClass()); field_map = descriptors_field_type->AsClass(); } } dependencies()->AssumeMapNotDeprecated(transition_map); *access_info = PropertyAccessInfo::DataField( MapList{map}, field_index, field_representation, field_type, field_map, holder, transition_map); return true; } return false; } Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } } // namespace compiler } // namespace internal } // namespace v8
[ "willi@arangodb.com" ]
willi@arangodb.com