blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
87d31d55b6c2d4c7fb1954d4dd184c83f67bce4c | 7b722e430370d4f5599b3b25fcf5b3faa658d40f | /mpi.grpc.pb.cc | 6db3337e7ee77a9a2797e807af0d8b5dcda1174b | [] | no_license | seiriosPlus/mpi_enabled | c5a27e27297a815cc17202508bbf7109de5e4e33 | 88696b42227b97b5f5e02d2c91f0caadafe23142 | refs/heads/master | 2020-03-07T21:19:12.188516 | 2018-07-03T11:39:42 | 2018-07-03T11:39:42 | 127,723,167 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 2,821 | cc | mpi.grpc.pb.cc | // Generated by the gRPC C++ plugin.
// If you make any local change, they will be lost.
// source: mpi.proto
#include "mpi.pb.h"
#include "mpi.grpc.pb.h"
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/channel_interface.h>
#include <grpcpp/impl/codegen/client_unary_call.h>
#include <grpcpp/impl/codegen/method_handler_impl.h>
#include <grpcpp/impl/codegen/rpc_service_method.h>
#include <grpcpp/impl/codegen/service_type.h>
#include <grpcpp/impl/codegen/sync_stream.h>
namespace mpis {
static const char* MPIService_method_names[] = {
"/mpis.MPIService/ISendRequest",
};
std::unique_ptr< MPIService::Stub> MPIService::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
(void)options;
std::unique_ptr< MPIService::Stub> stub(new MPIService::Stub(channel));
return stub;
}
MPIService::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
: channel_(channel), rpcmethod_ISendRequest_(MPIService_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
{}
::grpc::Status MPIService::Stub::ISendRequest(::grpc::ClientContext* context, const ::mpis::RequestContext& request, ::mpis::ReplyContext* response) {
return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_ISendRequest_, context, request, response);
}
::grpc::ClientAsyncResponseReader< ::mpis::ReplyContext>* MPIService::Stub::AsyncISendRequestRaw(::grpc::ClientContext* context, const ::mpis::RequestContext& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< ::mpis::ReplyContext>::Create(channel_.get(), cq, rpcmethod_ISendRequest_, context, request, true);
}
::grpc::ClientAsyncResponseReader< ::mpis::ReplyContext>* MPIService::Stub::PrepareAsyncISendRequestRaw(::grpc::ClientContext* context, const ::mpis::RequestContext& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< ::mpis::ReplyContext>::Create(channel_.get(), cq, rpcmethod_ISendRequest_, context, request, false);
}
MPIService::Service::Service() {
AddMethod(new ::grpc::internal::RpcServiceMethod(
MPIService_method_names[0],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< MPIService::Service, ::mpis::RequestContext, ::mpis::ReplyContext>(
std::mem_fn(&MPIService::Service::ISendRequest), this)));
}
MPIService::Service::~Service() {
}
::grpc::Status MPIService::Service::ISendRequest(::grpc::ServerContext* context, const ::mpis::RequestContext* request, ::mpis::ReplyContext* response) {
(void) context;
(void) request;
(void) response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
} // namespace mpis
|
33df94cfd6470b12b36133d05f411c630bc49b29 | bbff22e2ea840209993866bbab9a63a5f49de6ac | /src-gui/fsOutputOnlyTab.h | 02d83419e3c81e8474bd4d47290e4f19fa51348a | [] | no_license | kemerelab/NSpike2 | a4162611f2b44539ea8ea759ef2d1bf885fc6773 | 1471b842d8dd6989caaa31e055df65a34220425a | refs/heads/master | 2021-01-22T17:58:05.239263 | 2014-01-08T21:08:00 | 2014-01-08T21:08:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,019 | h | fsOutputOnlyTab.h | #ifndef __SPIKE_FS_OUTPUT_ONLY_H__
#define __SPIKE_FS_OUTPUT_ONLY_H__
#include <QtGui>
#define DEFAULT_TMP_PULSE_COMMANDS_FILE "/tmp/tmp_pulse_commands"
class StimOutputOnlyTab : public QWidget
{
Q_OBJECT
public:
StimOutputOnlyTab (QWidget *parent);
int trainCounter;
int nTrains;
int aOut1Mode, aOut2Mode;
QSpinBox *trainIntervalSpinBox;
QSpinBox *nTrainsSpinBox;
QPushButton *continuousButton;
QComboBox *stimulatorSelectComboBox;
QComboBox *aOutSelectComboBox;
QPushButton *stimSingleButton;
QPushButton *startStimButton;
QPushButton *abortStimButton;
void startStimulation(int count);
void writeStateToFile(QFile *stateFile);
void readStateFromFile(QFile *stateFile);
public slots:
void toggleContinuousMode(bool isToggled) {nTrainsSpinBox->setEnabled(!isToggled);}
void endStimulation(int flag);
void stepStimulation(int count);
void updateActiveAOut(int aOutIndex, int aOut1Mode, int aOut2Mode);
private:
void updateAOutEnable(void);
protected:
};
#endif
|
bff14d97eb0408078e4b2d714432e88413ac31ad | eb9de48d99732deac0b31a5b2c38853366216316 | /c++/SubstringWithConcatenationOfAllWords/SubstringWithConcatenationOfAllWords/main.cpp | 858b7440393673f3bd0be7f48cf81ca4926e8f11 | [] | no_license | allenwhc/Leetcode | 0a46da2301f426cbb713817e955ecd7ec79670e1 | e9b27b7dd69df1a2e53992badc400e29fb475e54 | refs/heads/master | 2020-04-05T14:36:04.575863 | 2017-04-19T09:28:01 | 2017-04-19T09:28:01 | 41,320,519 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,222 | cpp | main.cpp | /*
* Substring with Concatenation of All Words
* Last Modified: 7/8/2015
*/
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
class Solution{
public:
vector<int> findSubstring(string s, vector<string>& words){
vector<int> res;
int m = words.size();
int n = words[0].length();
if (m == 0) return res;
map<string, int> mp;
for (int i = 0; i < m; i++)
{
mp[words[i]]++;
}
int i = 0;
while (i + m*n <= s.length()){
map<string, int> mp2;
int j = 0;
while (j < m){
string str = s.substr(i + j * n, n);
if (mp.find(str) != mp.end()){
mp2[str]++;
if (mp2[str] > mp[str]) break; //Checks if the same word happens more than once
}
else break;
j++;
}
if (j == m) res.push_back(i);
i++;
}
return res;
}
};
void main(int argc, char* argv[]){
string str = "barfoothefoobarman";
vector<string> words = { "foo", "bar" };
Solution s;
cout << "The starting index of ";
for (int i = 0; i < words.size(); i++) cout << words[i] << " ";
cout << "in '" << str << "' are: ";
for (int i = 0; i < s.findSubstring(str, words).size(); i++) cout << s.findSubstring(str, words)[i] << " ";
cout << endl;
system("pause");
} |
3af6e0bc3932f41fc5e2cb90951abf844f4e72d7 | 0964c9c4bba5ff16bae625d8e6721aa85fe8b46c | /src/ibmras/monitoring/agent/threads/ThreadPool.h | 0acbf6e1fa4e733b0f2c40010e8171869bb9abd9 | [
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] | permissive | keithc-ca/omr-agentcore | dd47ee007f088761f63ae7c56285935b8e950554 | ac6baaaf0bf20234f893faeda06855133ca678e7 | refs/heads/main | 2023-03-08T19:04:15.327549 | 2021-01-26T21:40:37 | 2021-02-22T14:06:59 | 342,633,849 | 0 | 0 | Apache-2.0 | 2021-02-26T16:26:48 | 2021-02-26T16:26:47 | null | UTF-8 | C++ | false | false | 1,718 | h | ThreadPool.h | /*******************************************************************************
* Copyright 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#ifndef ibmras_monitoring_agent__threads_threadpool_h
#define ibmras_monitoring_agent__threads_threadpool_h
#include "ibmras/common/port/ThreadData.h"
#include "ibmras/common/port/Semaphore.h"
#include "ibmras/monitoring/AgentExtensions.h"
#include "ibmras/monitoring/Typesdef.h"
#include "ibmras/monitoring/agent/threads/WorkerThread.h"
namespace ibmras {
namespace monitoring {
namespace agent {
namespace threads {
/* a pool of worker threads */
class ThreadPool {
public:
ThreadPool();
void addPullSource(pullsource* src);
void startAll(); /* start all threads in this pool */
void stopAll(); /* stop all threads in this pool */
void process(bool immediate); /* process queue entries */
~ThreadPool();
private:
std::vector<WorkerThread*> threads; /* worker threads */
bool stopping; /* flag to prevent adding pull sources during stop */
};
}
}
}
} /* end namespace threads */
#endif /* ibmras_monitoring_agent__threads_threadpool_h */
|
0f0494c34ff5be1a1bc1d0cd7a83e5571618284a | bb1c9d8f47789137ce7269fdd056992f7848fed0 | /src/api/dcps/isocpp2/include/dds/sub/TSample.hpp | c12dc5a06a9159a758e07daeaeb18642a155f909 | [
"Apache-2.0"
] | permissive | osrf/opensplice | e37ed7e1a24ece7c0f480b4807cd95d3ee18daad | 7c3466f76d083cae38a6d7fcbba1c29106a43ea5 | refs/heads/osrf-6.9.0 | 2021-01-15T14:20:20.065297 | 2020-05-11T18:05:53 | 2020-05-11T18:05:53 | 16,789,031 | 10 | 13 | Apache-2.0 | 2020-05-11T18:05:54 | 2014-02-13T02:13:20 | C | UTF-8 | C++ | false | false | 3,262 | hpp | TSample.hpp | #ifndef OMG_DDS_SUB_TSAMPLE_HPP_
#define OMG_DDS_SUB_TSAMPLE_HPP_
/* Copyright 2010, Object Management Group, Inc.
* Copyright 2010, PrismTech, Corp.
* Copyright 2010, Real-Time Innovations, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dds/core/Value.hpp>
#include <dds/sub/SampleInfo.hpp>
namespace dds
{
namespace sub
{
template <typename T, template <typename Q> class DELEGATE>
class Sample;
}
}
/**
* @brief
* This class encapsulates the data and info meta-data associated with
* DDS samples.
*
* It is normally used with dds::sub::LoanedSamples:
* @code{.cpp}
* dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
* dds::sub::LoanedSamples<Foo::Bar>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); ++it) {
* const dds::sub::Sample<Foo::Bar>& sample = *it;
* const Foo::Bar& data = sample.data();
* const dds::sub::SampleInfo& info = sample.info();
* // Use sample data and meta information.
* }
* @endcode
* Or more implicitly:
* @code{.cpp}
* dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
* dds::sub::LoanedSamples<Foo::Bar>::const_iterator it;
* for (it = samples.begin(); it != samples.end(); ++it) {
* const Foo::Bar& data = it->data();
* const dds::sub::SampleInfo& info = it->info();
* // Use sample data and meta information.
* }
* @endcode
*
* @see @ref DCPS_Modules_Subscription_DataSample "DataSample" for more information
* @see @ref DCPS_Modules_Subscription_SampleInfo "SampleInfo" for more information
* @see @ref DCPS_Modules_Subscription "Subscription" for more information
*/
template <typename T, template <typename Q> class DELEGATE>
class dds::sub::Sample : public dds::core::Value< DELEGATE<T> >
{
public:
/**
* Convenience typedef for the type of the data sample.
*/
typedef T DataType;
public:
/**
* Create a sample with invalid data.
*/
Sample();
/**
* Creates a Sample instance.
*
* @param data the data
* @param info the sample info
*/
Sample(const T& data, const SampleInfo& info);
/**
* Copies a sample instance.
*
* @param other the sample instance to copy
*/
Sample(const Sample& other);
/**
* Gets the data.
*
* @return the data
*/
const DataType& data() const;
/**
* Sets the data.
*
* @param data the data
*/
void data(const DataType& data);
/**
* Gets the info.
*
* @return the info
*/
const SampleInfo& info() const;
/**
* Sets the info.
*
* @param info the info
*/
void info(const SampleInfo& info);
};
#endif /* OMG_DDS_SUB_TSAMPLE_HPP_ */
|
34f307cc1da78d0891d8103184834c88a8f9adda | 55d71cdbf0d60d89be90e5b7843e496dab23cac9 | /SDK/MachIncludes/VBFrame.h | ca2b24cdd07ae24dbe89d2539dd86ac98f62994e | [
"MIT"
] | permissive | mariusl/step2mach | 13f5838471e41a759b352afd0297c43ff7b17791 | 3ac7ff6c3b29a25f4520e4325e7922f2d34c547a | refs/heads/master | 2020-05-25T02:22:29.182553 | 2019-06-21T11:54:01 | 2019-06-21T11:54:01 | 187,577,085 | 0 | 0 | MIT | 2019-06-21T11:54:02 | 2019-05-20T06:03:55 | C | UTF-8 | C++ | false | false | 1,743 | h | VBFrame.h | #pragma once
#include "MyToolbar.h"
// VBFrame frame
class VBFrame : public CFrameWnd
{
DECLARE_DYNCREATE(VBFrame)
public:
VBFrame(); // protected constructor used by dynamic creation
virtual ~VBFrame();
CView *pView;
CMyToolBar myBar;
CToolTipCtrl m_toolTip;
CStatusBar m_wndStatusBar;
protected:
DECLARE_MESSAGE_MAP()
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnVbfileopen();
afx_msg void OnVbfileclose();
afx_msg void OnVbFind();
afx_msg void OnVbReplace();
afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
virtual void RecalcLayout(BOOL bNotify = TRUE);
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnEditFindnext();
afx_msg void OnVbrun();
afx_msg void OnDebugStepinto();
afx_msg void OnDebugStepover();
afx_msg void OnDebugEnd();
afx_msg void OnBreakpointsSetbreakpoint();
afx_msg void OnBreakpointsClearallbreakpoints();
afx_msg void OnBreakpointsEnumeratebreakpoints();
afx_msg void OnRunRun();
afx_msg void OnRunStop();
afx_msg void OnDebugRun();
afx_msg void OnDebugReset();
afx_msg void OnFileSavefile();
afx_msg void OnFileSaveas();
afx_msg void OnDestroy();
void LoadFile( );
afx_msg void OnDebugContinue();
afx_msg void OnUndo();
afx_msg void OnCut();
afx_msg void OnCopy();
afx_msg void OnPaste();
afx_msg void OnClear();
afx_msg void OnSelall();
afx_msg void OnFileOptions();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
afx_msg void OnClose();
};
|
08864ca2cc93b583413a7c5715dcf8cabefa80eb | 9959410b5d4588f4b0dd90a0474b9be2b1acd913 | /coli/minimum_cost_flow/primal_network_simplex/primal_network_simplex_update_potentials.h | 8f4c27fa1ad50b15842f040bd85fb1843cf84dbe | [
"BSL-1.0"
] | permissive | Krellner/Moli | cc29df6a38a662aa7ab0daf956a3d9dbfc3b314e | e1d54146ab98812152f740489bc88d1b7e14d1cf | refs/heads/master | 2021-07-30T16:22:21.418007 | 2021-07-25T14:17:37 | 2021-07-25T14:17:37 | 241,725,039 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,161 | h | primal_network_simplex_update_potentials.h | // Copyright (C) 2019-2020 Florian Krellner
//
// Permission to use, modify and distribute this software is granted
// provided that this copyright notice appears in all copies. For
// precise terms see the accompanying LICENSE file.
//
// This software is provided "AS IS" with no warranty of any kind,
// express or implied, and with no claim as to its suitability for any
// purpose.
#pragma once
#include <vector>
#include "primal_network_simplex_lib.h"
#include "primal_network_simplex_logger.h"
namespace primal_network_simplex {
using namespace std;
template <typename I, typename F>
inline void for_each( //
const I start, //
const I end, //
const I nElements, //
const vector<I> &thread, //
const vector<I> &reversed_thread, //
F function //
) {
I u = start;
I v = end;
I ctr = 0;
while (ctr < nElements / 2) {
function(u);
function(v);
u = thread[u];
v = reversed_thread[v];
ctr++;
}
if (nElements % 2)
function(v);
}
template <typename I,
typename V>
inline void update_potentials( //
const I last_successor_in_v, //
const I in_v, //
const I in_w, //
const V oriented_costs, //
const I number_successors, //
const vector<I> &thread, //
const vector<I> &reversed_thread, //
vector<V> &potentials //
) {
I nVertices = potentials.size();
V reduced_costs = potentials[in_w] - potentials[in_v] - oriented_costs;
// We update the potentials in the smaller subtree. The subtrees are induced by the entering
// edge. We iterate simultaneously from the first and last vertex in the tree towards each
// other and hope for multitasking in lines 1 and 2 or 3 and 4.
if (2 * number_successors < potentials.size())
for_each(in_v, last_successor_in_v, number_successors, thread, reversed_thread,
[&potentials, reduced_costs](I idx) { potentials[idx] += reduced_costs; });
else
for_each(thread[last_successor_in_v], reversed_thread[in_v], nVertices - number_successors,
thread, reversed_thread,
[&potentials, reduced_costs](I idx) { potentials[idx] -= reduced_costs; });
}
template <typename I, typename V,
typename Logger>
inline void update_potentials( //
const I last_successor_in_v, //
const I in_v, //
const I in_w, //
const V oriented_costs, //
const I number_successors, //
const vector<I> &thread, //
const vector<I> &reversed_thread, //
vector<V> &potentials, //
Logger &logger //
) {
logger.start();
update_potentials<I, V>(last_successor_in_v, in_v, in_w, oriented_costs, number_successors,
thread, reversed_thread, potentials);
logger.end();
logger.increment_update_potentials();
}
} // namespace primal_network_simplex |
e0c980c2673bc4d2f5aff7a2652ff0110ccc5961 | 33c7fb627c2177ff9f14f540d2d5cf32fbf03f38 | /Leetcode/刷过的题需要更新/11_maxarea.h | b93f0eebd9a145b1e3c57434830b039622573c29 | [] | no_license | a2zsy/programming_knowledege | ced2a1f0a0b5e022e3b5e1702ed56d7e9fc45b12 | 940e38e8e035bd7e9b762f53b456f10b53e61016 | refs/heads/master | 2020-11-25T07:54:27.918680 | 2020-02-21T13:09:18 | 2020-02-21T13:09:18 | 228,565,368 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,347 | h | 11_maxarea.h | //算出一个数组中的容器所能盛的最大的水容量,暴力破解或者双指针
/*给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。
说明:你不能倾斜容器,且 n 的值至少为 2。
输入: [1,8,6,2,5,4,8,3,7]
输出: 49 */
//暴力破解,极度容易超时
class Solution1 {
public:
int maxArea(vector<int>& height) {
int res = 0;
for (int i = 0; i < height.size(); i++)
{
for (int j = i + 1; j < height.size(); j++)
{
int temp1 = min(height[i], height[j]);
int temp2 = temp1 * (j - i);
res = max(res, temp2);
}
}
return res;
}
};
//因为数组之间间距的均匀性,所以可采用双指针,慢慢比较
class Solution2{
public:
int maxArea(vector<int>& height) {
int i = 0;
int j = height.size() - 1; //双指针,因为每个垂直线间距相同,所以指针移动起来很舒服
int max = 0, temp = 0;
while (i != j)
{
temp = (j - i) * (height[i] > height[j] ? height[j] : height[i]);
if (height[i] >= height[j]) { j--; }
else { i++; }
max = max > temp ? max : temp;
}
return max;
}
};
|
eb2c2febf5b4042c7542b2c5148f51e7aae2892d | 6733261451f8a5454312afea196bc3337de74870 | /xls/ir/proc.h | 7ce5e21b183717020dd488c1c5a1cec8ad4cb469 | [
"Apache-2.0"
] | permissive | catonblack/xls | e8c92d950828598b7df572afdd125726597d855c | 2ebaec60e59e206df9491f00459f6936d481fb00 | refs/heads/main | 2023-01-04T20:45:44.218064 | 2020-10-21T19:05:35 | 2020-10-21T19:06:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,785 | h | proc.h | // Copyright 2020 The XLS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef XLS_IR_PROC_H_
#define XLS_IR_PROC_H_
#include "absl/strings/string_view.h"
#include "xls/ir/function.h"
#include "xls/ir/package.h"
#include "xls/ir/type.h"
namespace xls {
// Abstraction representing an XLS Proc. Procs (from "processes") are stateful
// blocks which iterate indefinitely over mutable state of a fixed type. Procs
// communicate to other components via channels.
// TODO(meheff): Add link to documentation when we have some.
class Proc : public FunctionBase {
public:
Proc(absl::string_view name, const Value& init_value,
absl::string_view token_param_name, absl::string_view state_param_name,
Package* package)
: FunctionBase(name, package),
init_value_(init_value),
state_type_(package->GetTypeForValue(init_value_)),
return_type_(
package->GetTupleType({package->GetTokenType(), state_type_})),
token_param_(AddNode(absl::make_unique<Param>(
absl::nullopt, token_param_name, package->GetTokenType(), this))),
state_param_(AddNode(absl::make_unique<Param>(
absl::nullopt, state_param_name, state_type_, this))) {}
virtual ~Proc() = default;
absl::Status set_return_value(Node* n) override;
// Returns the initial value of the state variable.
const Value& InitValue() const { return init_value_; }
// Returns the type of the recurrent state variable.
Type* StateType() const { return state_type_; }
// Returns the return type of the Proc. The return type is a 2-tuple
// containing the state type and a token.
Type* ReturnType() const { return return_type_; }
// Returns the state (or token) parameter node. These are the only Params of
// the Proc.
Param* StateParam() const { return state_param_; }
Param* TokenParam() const { return token_param_; }
std::string DumpIr(bool recursive = false) const override;
private:
Value init_value_;
Type* state_type_;
Type* return_type_;
// State and token parameters. Procs have fixed set of parameters (state data
// and an input token) which are added at construction time.
Param* token_param_;
Param* state_param_;
};
} // namespace xls
#endif // XLS_IR_PROC_H_
|
374ccadd47c6805a9ff977373767371046fed51f | e89f5914b230060acc6c561d5908e1f23f9914ec | /src/NeonTrails.h | 68d2a155c96104c60bdce672f1284801c0a29186 | [] | no_license | ovicin/KinectVisualsSuite | 6f04339db90d00234c53600108ce5b683b4b14aa | 1630467766a79fc1d782cce6e0acf0d430bf26c4 | refs/heads/master | 2020-04-10T03:59:47.287935 | 2015-02-19T21:14:34 | 2015-02-19T21:14:34 | 30,936,787 | 0 | 1 | null | 2015-02-17T20:42:56 | 2015-02-17T20:42:55 | null | UTF-8 | C++ | false | false | 1,780 | h | NeonTrails.h | //
// NeonTrails.h
// SDMPVisuals
//
// Created by Chris Hall on 5/18/14.
//
//
#ifndef __SDMPVisuals__NeonTrails__
#define __SDMPVisuals__NeonTrails__
#pragma once
#include "ofMain.h"
#include "ofxOpenCv.h"
#include "ofxKinect.h"
// uncomment this to read from two kinects simultaneously
//#define USE_TWO_KINECTS
class NeonTrails : public ofBaseApp {
public:
NeonTrails();
void setup();
void update();
void draw();
void exit();
void drawPointCloud();
void keyPressed(int key);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
ofxKinect kinect;
#ifdef USE_TWO_KINECTS
ofxKinect kinect2;
#endif
ofxCvColorImage colorImg;
ofxCvGrayscaleImage grayImage; // grayscale depth image
ofxCvGrayscaleImage grayThreshNear; // the near thresholded image
ofxCvGrayscaleImage grayThreshFar; // the far thresholded image
ofxCvContourFinder contourFinder;
bool bThreshWithOpenCV;
bool bDrawPointCloud;
int nearThreshold;
int farThreshold;
int angle;
/******** NEON TRAILS *******/
void setupTrails();
void updateDepthImg();
void updatePrevFrames();
void updateTrailsImg();
int threshold = 50;
int motionThresh = 1;
int updateCounter = 0;
ofxCvGrayscaleImage depthImg;
ofxCvColorImage trailsImg;
ofImage neonImg;
vector< ofxCvGrayscaleImage > prevFrames;
int prevFramesCounter = 0;
int prevFramesMax = 5;
unsigned char trail = 30;
int camW = 640;
int camH = 480;
/****************************/
// used for viewing the point cloud
ofEasyCam easyCam;
};
#endif /* defined(__SDMPVisuals__NeonTrails__) */
|
ebab94c2a158fc3b938cdafce30090b17f61da26 | d3dfd46bde7d1c9f1d4d377c063090c6141aeeb4 | /C++ PrimerPlus console program/书例子/第3章/P46 3.4 +.cpp | 94e503101d7ad45ecb83d40c12ff9a2dc5558072 | [] | no_license | sola1121/CPP_PrimerPlus_and_VisualCPP | c58e346e75662ca4c351fe5adc8ef55f271da09d | cfc2f01769cda1eb371a8932e21658c9d395b8fa | refs/heads/master | 2021-02-12T17:17:03.972749 | 2020-04-03T10:48:49 | 2020-04-03T10:48:49 | 244,610,904 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 415 | cpp | P46 3.4 +.cpp | #include<iostream>
int main(){
using namespace std;
int chest=42,waist=42,inseam=42;
cout<<"Just print chest :"<<chest<<endl;
cout<<hex;
cout<<"Add hex(16) before, chest: "<<chest<<endl;
cout<<oct;
cout<<"Add oct(8) before, waist: "<<inseam<<endl;
cout<<dec;
cout<<"Add dec(10) before, show all of them: "<<chest<<" "<<waist<<" "<<inseam<<endl;
cin.get();
return 0;
}
|
615dd21fd12a671ab1b3bc0275aa704f52aafa98 | f621b75def179fdc2e66180a13cf74757e77ddf4 | /hw6/src/cir/cirGate.cpp | d9161ea99f7c8b3e9348e692577c9237970fab88 | [] | no_license | TuringTW/DSnP | e4fad87794ce6708ee8cbb9c7df475b8efdfd973 | 6fd171bbbe1582837fdf91f70d47158738c20cc2 | refs/heads/master | 2021-01-17T18:13:18.341530 | 2017-01-30T15:55:02 | 2017-01-30T15:55:02 | 71,251,735 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,852 | cpp | cirGate.cpp | /****************************************************************************
FileName [ cirGate.cpp ]
PackageName [ cir ]
Synopsis [ Define class CirAigGate member functions ]
Author [ Chung-Yang (Ric) Huang ]
Copyright [ Copyleft(c) 2008-present LaDs(III), GIEE, NTU, Taiwan ]
****************************************************************************/
#include <iostream>
#include <iomanip>
#include <stdarg.h>
#include <cassert>
#include "cirGate.h"
#include "cirMgr.h"
#include "util.h"
using namespace std;
extern CirMgr *cirMgr;
// TODO: Implement memeber functions for class(es) in cirGate.h
// static variable
int CirGate::_cflag=0;
int CirGate::plineNo=0;
/**************************************/
/* class CirGate member functions */
/**************************************/
void
CirGate::reportGate() const
{
ostringstream oss;
oss << getTypeStr() << "(" << _id << ")";
if (_alias.length()>0) oss <<"\"" << _alias << "\"";
oss << ", line " << _lineNo;
cout << "==================================================" << endl;
cout << "= " << left << setfill(' ')<< setw(47)<< oss.str() << "=" << endl;
cout << "==================================================" << endl;
}
void
CirGate::reportFanin(int level)
{
assert (level >= 0);
_cflag++;
goFanin(level, 0, true, true);
}
void
CirGate::reportFanout(int level)
{
assert (level >= 0);
_cflag++;
goFanout(level, 0, true, true);
}
void CirGate::goFanin(int level, int padding, bool isPosi, bool isPrint) {
if(isPrint){
ostringstream oss;
if (!isPosi) oss <<"!";
oss << getTypeStr() << " " << _id;
cout << setw(2*padding) <<"" <<oss.str();
if(_cflag == _flag&&(getType()!=PI_GATE&&getType()!=CONST_GATE)&&level!=0){ cout << " (*)"; }
cout << endl;
}
if (_cflag != _flag) {
_flag = _cflag;
if (level>0) {
for (size_t i = 0; i < _fanin.size(); i++) {
if(_fanin[i]->_fromGate!=0){_fanin[i]->_fromGate->goFanin(level-1, padding+1, _fanin[i]->_isposi, isPrint);}
}
}
}
}
void CirGate::goFanout(int level, int padding, bool isPosi, bool isPrint) {
if(isPrint){
ostringstream oss;
if (!isPosi) {oss <<"!";}
oss << getTypeStr() << " " << _id;
cout << setw(2*padding) <<"" <<oss.str();
if(getType()!=PO_GATE&&level!=0&&_cflag==_flag){cout << " (*)";}
cout << endl;
}
if (_cflag != _flag) {
_flag = _cflag;
if (level>0) {
for (size_t i = 0; i < _fanout.size(); i++) {
if(_fanout[i]->_toGate!=0){_fanout[i]->_toGate->goFanout(level-1, padding+1, _fanout[i]->_isposi, isPrint);}
}
}
}
}
void CirGate::getDFSlist(bool isPosi,ostream& os){
if (_cflag != _flag) {
_flag = _cflag;
if (getType()==AIG_GATE) {
plineNo++;
}
for (size_t i = 0; i < _fanin.size(); i++) {
_fanin[i]->_fromGate->getDFSlist(_fanin[i]->_isposi, os);
}
int fanin1=0, fanin2=0;
if (getType()==AIG_GATE&&_cflag==_flag) {
fanin1 = (_fanin[0]->_fromGate->getId())*2;
fanin2 = (_fanin[1]->_fromGate->getId())*2;
if(!_fanin[0]->_isposi){ fanin1++; }
if(!_fanin[1]->_isposi){ fanin2++; }
os << getId()*2 << " " << fanin1 << " " << fanin2 << endl;
}
}
}
void CirGate::printDFSlist(bool isPosi){
if (_cflag != _flag) {
_flag = _cflag;
ostringstream oss;
for (size_t i = 0; i < _fanin.size(); i++) {
oss << " ";
if(_fanin[i]->_fromGate->getType()==UNDEF_GATE){
oss << "*";
}else{
_fanin[i]->_fromGate->printDFSlist(_fanin[i]->_isposi);
}
if(!_fanin[i]->_isposi) {oss << "!";}
oss << _fanin[i]->_fromGate->getId();
}
if (_alias.length()>0) oss <<" (" << _alias << ")";
cout << "[" << plineNo << "] " << setw(4) << left<< getTypeStr() << getId() << oss.str() << endl;
plineNo++;
}
}
|
74f479002f57297a5a8095b73a9b31c35f8e5155 | 56120205658d16ab50c859944cf48ca2b1867ccb | /1. BASE/1. basic constructions/choice.cpp | a672fc72b5a8589bce71dab211d6c433ec83b7de | [] | no_license | AndreiSachuk/INCUBATOR | 26a884400110ca29a2efd96a328cd0f009ba9804 | b21b137f3b3f812448387c557c883ede12f9482b | refs/heads/main | 2023-06-19T00:32:47.305816 | 2021-07-09T06:25:34 | 2021-07-09T06:25:34 | 376,855,063 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 304 | cpp | choice.cpp | #include <iostream>
using namespace std;
int main()
{
int number = 0;
while (number <= 1 or number >= 10)
{
cout << "Enter a number from 1 to 10: ";
cin >> number;
if (number <= 1 or number >= 10)
cout << "Incorrect answer! " <<endl;
}
return 0;
} |
4b8605b86a63592360d8157b41eac95b661d23c6 | aa6680ee03a50d7445c184720690df4f32660d70 | /Source/FPSProject/FPSProjectile.h | 02904932143adc431686381646afe13d8f6b1991 | [] | no_license | AlexWanderer/FPS | f28be7d77fcf33511d801c49b0087acec0379cbe | 9fcc19bb4620aa5c856d467638fb9887095df82e | refs/heads/master | 2021-05-27T19:44:23.366673 | 2014-03-25T05:05:28 | 2014-03-25T05:05:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 529 | h | FPSProjectile.h | // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Actor.h"
#include "FPSProjectile.generated.h"
/**
*
*/
UCLASS()
class AFPSProjectile : public AActor
{
GENERATED_UCLASS_BODY()
UPROPERTY(VisibleDefaultsOnly, Category=Projectile) TSubobjectPtr<USphereComponent> CollisionComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Movement) TSubobjectPtr<class UProjectileMovementComponent> ProjectileMovement;
void InitVelocity(const FVector &ShootDirection);
};
|
d8733434275d1f9c7e29ed4623ea2f0ca1be59ca | 90597989440de8d5eaf742d2551ad21f9d6146f0 | /Tree/maxSumRootToLeaf.cpp | e83f0b7841d7e836355f45128822c20d56bdd5f6 | [] | no_license | manishjais25/DSA_learning | 76beb22c1d044a49b1c49e988e1a371f7f78c9c0 | dc011e6aba007240f019e58f8f69f418e72b0b11 | refs/heads/main | 2023-07-29T05:36:35.697155 | 2021-09-11T10:59:58 | 2021-09-11T10:59:58 | 355,428,386 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,042 | cpp | maxSumRootToLeaf.cpp | #include <bits/stdc++.h>
using namespace std;
struct Node
{
int data;
Node *left, *right;
Node(int val)
{
data = val;
left = NULL;
right = NULL;
}
};
void Path_Sum(Node *root, int &mxsum, int &sum)
{
if (root == NULL) return;
sum += root->data;
if (!root->left && !root->right){
mxsum = max(sum, mxsum);
}
Path_Sum(root->left, mxsum, sum);
Path_Sum(root->right, mxsum, sum);
sum -= root->data;
}
int Path(Node *root)
{
int mxsum = -100000;
if (!root) return mxsum;
int sum = 0;
Path_Sum(root, mxsum, sum);
return mxsum;
}
int main()
{
/*
1
/ \
2 3
/ / \
4 5 6
/
7
*/
Node *root = new Node(1);
root->left = new Node(2);
root->right = new Node(3);
root->left->left = new Node(4);
root->right->left = new Node(5);
root->right->right = new Node(6);
root->right->left->left = new Node(7);
cout << Path(root) << endl;
}
|
79b872050c3d02e68e82a8aad695253cfcee3062 | e56cbbd7a86c4b4c492017c1b7c935aeb0cfbf8d | /pong-game.h | 06e0534fb1a6e369240e8df834525949dd7187bb | [] | no_license | ksmai/pong | 713078fb8d62feee592563e396f00edada89df30 | 0fe1db84fbcbfe8d405dea56fa19221fb35f5d51 | refs/heads/master | 2020-03-26T18:39:33.603044 | 2018-08-19T09:31:04 | 2018-08-19T09:31:04 | 145,223,781 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 585 | h | pong-game.h | #ifndef _PONG_GAME_H_
#define _PONG_GAME_H_
#include "game.h"
#include "paddle.h"
#include "ball.h"
#include "computer_ai.h"
class PongGame: public Game {
public:
PongGame();
virtual ~PongGame() override;
protected:
virtual void update(int dt) override;
virtual void render_impl() override;
virtual int handle_event_impl() override;
private:
void check_ball_collision();
void check_score();
Paddle *player;
Paddle *computer;
Ball *ball;
ComputerAI *ai;
int player_score;
int computer_score;
bool player_serving;
bool playing;
bool scored;
};
#endif
|
6403185b45f21d901b7a39d8da0cfcc815caa11f | 9623ec513d9925b6168a0aeb51a5641a365a7ec0 | /Session 1/Code/L8/L8/binarysearch.cpp | 931b022300c96dddfc0a02186046810ea1d0547d | [] | no_license | TdevM/Summer2015 | 95b0a849e87aa33fe9764a46ffd48c4c0fadb417 | 590a82644594de042be5a1a39222b850fd7dfe37 | refs/heads/master | 2020-09-26T13:49:11.200452 | 2016-09-06T14:09:40 | 2016-09-06T14:09:40 | 67,513,717 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 540 | cpp | binarysearch.cpp | #include<iostream>
using namespace std;
int binarysearch(int arr[], int start, int end, int ele) {
cout << start << " " << end << endl;
if (start > end) {
return -1;
}
int mid = (start+end)/2;
if (arr[mid] == ele) {
return mid;
} else if (arr[mid] > ele) {
return binarysearch(arr, start, mid-1, ele);
} else {
return binarysearch(arr, mid+1, end, ele);
}
}
int main() {
int arr[] = {1,2,3,4,5,6,7,8};
int ans = binarysearch(arr, 0, 7, 2);
cout << ans << endl;
}
|
fe5c0440bff7e114af80d2a9f3baee515e090895 | f31b8497718c5c00e233c9fb17160339fa0275e1 | /TheQuestOfTheBurningHeart/ClearDyingMonstersSystem.cpp | 49e76bb944d67e70e52910d9e416c9d790be48b6 | [] | no_license | bliou/TheQuestOfTheBurningHeart | 30a6876e80e7424dba6dd8dfa670a5ddabf4a46a | edbb98644f82fb6fcc2182b9bfc79a7fd9872bc2 | refs/heads/master | 2020-04-17T22:34:01.563921 | 2019-02-16T15:41:50 | 2019-02-16T15:41:50 | 166,999,372 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 266 | cpp | ClearDyingMonstersSystem.cpp | #include "ClearDyingMonstersSystem.h"
ClearDyingMonstersSystem::ClearDyingMonstersSystem()
{
}
void ClearDyingMonstersSystem::update(float elapsedTime)
{
auto entities = getEntities();
for (auto& entity : entities)
{
entity.kill();
entity.activate();
}
} |
e9069e2ee215c90b3d53268b12bb031680f5940d | 2cf838b54b556987cfc49f42935f8aa7563ea1f4 | /aws-cpp-sdk-lexv2-models/include/aws/lexv2-models/LexModelsV2Client.h | 4abaaf027ab1e56b9d11b48d28ccc507a8f90265 | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | QPC-database/aws-sdk-cpp | d11e9f0ff6958c64e793c87a49f1e034813dac32 | 9f83105f7e07fe04380232981ab073c247d6fc85 | refs/heads/main | 2023-06-14T17:41:04.817304 | 2021-07-09T20:28:20 | 2021-07-09T20:28:20 | 384,714,703 | 1 | 0 | Apache-2.0 | 2021-07-10T14:16:41 | 2021-07-10T14:16:41 | null | UTF-8 | C++ | false | false | 146,849 | h | LexModelsV2Client.h | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/lexv2-models/LexModelsV2_EXPORTS.h>
#include <aws/lexv2-models/LexModelsV2Errors.h>
#include <aws/core/client/AWSError.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/core/client/AWSClient.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/lexv2-models/model/BuildBotLocaleResult.h>
#include <aws/lexv2-models/model/CreateBotResult.h>
#include <aws/lexv2-models/model/CreateBotAliasResult.h>
#include <aws/lexv2-models/model/CreateBotLocaleResult.h>
#include <aws/lexv2-models/model/CreateBotVersionResult.h>
#include <aws/lexv2-models/model/CreateExportResult.h>
#include <aws/lexv2-models/model/CreateIntentResult.h>
#include <aws/lexv2-models/model/CreateResourcePolicyResult.h>
#include <aws/lexv2-models/model/CreateResourcePolicyStatementResult.h>
#include <aws/lexv2-models/model/CreateSlotResult.h>
#include <aws/lexv2-models/model/CreateSlotTypeResult.h>
#include <aws/lexv2-models/model/CreateUploadUrlResult.h>
#include <aws/lexv2-models/model/DeleteBotResult.h>
#include <aws/lexv2-models/model/DeleteBotAliasResult.h>
#include <aws/lexv2-models/model/DeleteBotLocaleResult.h>
#include <aws/lexv2-models/model/DeleteBotVersionResult.h>
#include <aws/lexv2-models/model/DeleteExportResult.h>
#include <aws/lexv2-models/model/DeleteImportResult.h>
#include <aws/lexv2-models/model/DeleteResourcePolicyResult.h>
#include <aws/lexv2-models/model/DeleteResourcePolicyStatementResult.h>
#include <aws/lexv2-models/model/DescribeBotResult.h>
#include <aws/lexv2-models/model/DescribeBotAliasResult.h>
#include <aws/lexv2-models/model/DescribeBotLocaleResult.h>
#include <aws/lexv2-models/model/DescribeBotVersionResult.h>
#include <aws/lexv2-models/model/DescribeExportResult.h>
#include <aws/lexv2-models/model/DescribeImportResult.h>
#include <aws/lexv2-models/model/DescribeIntentResult.h>
#include <aws/lexv2-models/model/DescribeResourcePolicyResult.h>
#include <aws/lexv2-models/model/DescribeSlotResult.h>
#include <aws/lexv2-models/model/DescribeSlotTypeResult.h>
#include <aws/lexv2-models/model/ListBotAliasesResult.h>
#include <aws/lexv2-models/model/ListBotLocalesResult.h>
#include <aws/lexv2-models/model/ListBotVersionsResult.h>
#include <aws/lexv2-models/model/ListBotsResult.h>
#include <aws/lexv2-models/model/ListBuiltInIntentsResult.h>
#include <aws/lexv2-models/model/ListBuiltInSlotTypesResult.h>
#include <aws/lexv2-models/model/ListExportsResult.h>
#include <aws/lexv2-models/model/ListImportsResult.h>
#include <aws/lexv2-models/model/ListIntentsResult.h>
#include <aws/lexv2-models/model/ListSlotTypesResult.h>
#include <aws/lexv2-models/model/ListSlotsResult.h>
#include <aws/lexv2-models/model/ListTagsForResourceResult.h>
#include <aws/lexv2-models/model/StartImportResult.h>
#include <aws/lexv2-models/model/TagResourceResult.h>
#include <aws/lexv2-models/model/UntagResourceResult.h>
#include <aws/lexv2-models/model/UpdateBotResult.h>
#include <aws/lexv2-models/model/UpdateBotAliasResult.h>
#include <aws/lexv2-models/model/UpdateBotLocaleResult.h>
#include <aws/lexv2-models/model/UpdateExportResult.h>
#include <aws/lexv2-models/model/UpdateIntentResult.h>
#include <aws/lexv2-models/model/UpdateResourcePolicyResult.h>
#include <aws/lexv2-models/model/UpdateSlotResult.h>
#include <aws/lexv2-models/model/UpdateSlotTypeResult.h>
#include <aws/core/NoResult.h>
#include <aws/core/client/AsyncCallerContext.h>
#include <aws/core/http/HttpTypes.h>
#include <future>
#include <functional>
namespace Aws
{
namespace Http
{
class HttpClient;
class HttpClientFactory;
} // namespace Http
namespace Utils
{
template< typename R, typename E> class Outcome;
namespace Threading
{
class Executor;
} // namespace Threading
} // namespace Utils
namespace Auth
{
class AWSCredentials;
class AWSCredentialsProvider;
} // namespace Auth
namespace Client
{
class RetryStrategy;
} // namespace Client
namespace LexModelsV2
{
namespace Model
{
class BuildBotLocaleRequest;
class CreateBotRequest;
class CreateBotAliasRequest;
class CreateBotLocaleRequest;
class CreateBotVersionRequest;
class CreateExportRequest;
class CreateIntentRequest;
class CreateResourcePolicyRequest;
class CreateResourcePolicyStatementRequest;
class CreateSlotRequest;
class CreateSlotTypeRequest;
class CreateUploadUrlRequest;
class DeleteBotRequest;
class DeleteBotAliasRequest;
class DeleteBotLocaleRequest;
class DeleteBotVersionRequest;
class DeleteExportRequest;
class DeleteImportRequest;
class DeleteIntentRequest;
class DeleteResourcePolicyRequest;
class DeleteResourcePolicyStatementRequest;
class DeleteSlotRequest;
class DeleteSlotTypeRequest;
class DescribeBotRequest;
class DescribeBotAliasRequest;
class DescribeBotLocaleRequest;
class DescribeBotVersionRequest;
class DescribeExportRequest;
class DescribeImportRequest;
class DescribeIntentRequest;
class DescribeResourcePolicyRequest;
class DescribeSlotRequest;
class DescribeSlotTypeRequest;
class ListBotAliasesRequest;
class ListBotLocalesRequest;
class ListBotVersionsRequest;
class ListBotsRequest;
class ListBuiltInIntentsRequest;
class ListBuiltInSlotTypesRequest;
class ListExportsRequest;
class ListImportsRequest;
class ListIntentsRequest;
class ListSlotTypesRequest;
class ListSlotsRequest;
class ListTagsForResourceRequest;
class StartImportRequest;
class TagResourceRequest;
class UntagResourceRequest;
class UpdateBotRequest;
class UpdateBotAliasRequest;
class UpdateBotLocaleRequest;
class UpdateExportRequest;
class UpdateIntentRequest;
class UpdateResourcePolicyRequest;
class UpdateSlotRequest;
class UpdateSlotTypeRequest;
typedef Aws::Utils::Outcome<BuildBotLocaleResult, LexModelsV2Error> BuildBotLocaleOutcome;
typedef Aws::Utils::Outcome<CreateBotResult, LexModelsV2Error> CreateBotOutcome;
typedef Aws::Utils::Outcome<CreateBotAliasResult, LexModelsV2Error> CreateBotAliasOutcome;
typedef Aws::Utils::Outcome<CreateBotLocaleResult, LexModelsV2Error> CreateBotLocaleOutcome;
typedef Aws::Utils::Outcome<CreateBotVersionResult, LexModelsV2Error> CreateBotVersionOutcome;
typedef Aws::Utils::Outcome<CreateExportResult, LexModelsV2Error> CreateExportOutcome;
typedef Aws::Utils::Outcome<CreateIntentResult, LexModelsV2Error> CreateIntentOutcome;
typedef Aws::Utils::Outcome<CreateResourcePolicyResult, LexModelsV2Error> CreateResourcePolicyOutcome;
typedef Aws::Utils::Outcome<CreateResourcePolicyStatementResult, LexModelsV2Error> CreateResourcePolicyStatementOutcome;
typedef Aws::Utils::Outcome<CreateSlotResult, LexModelsV2Error> CreateSlotOutcome;
typedef Aws::Utils::Outcome<CreateSlotTypeResult, LexModelsV2Error> CreateSlotTypeOutcome;
typedef Aws::Utils::Outcome<CreateUploadUrlResult, LexModelsV2Error> CreateUploadUrlOutcome;
typedef Aws::Utils::Outcome<DeleteBotResult, LexModelsV2Error> DeleteBotOutcome;
typedef Aws::Utils::Outcome<DeleteBotAliasResult, LexModelsV2Error> DeleteBotAliasOutcome;
typedef Aws::Utils::Outcome<DeleteBotLocaleResult, LexModelsV2Error> DeleteBotLocaleOutcome;
typedef Aws::Utils::Outcome<DeleteBotVersionResult, LexModelsV2Error> DeleteBotVersionOutcome;
typedef Aws::Utils::Outcome<DeleteExportResult, LexModelsV2Error> DeleteExportOutcome;
typedef Aws::Utils::Outcome<DeleteImportResult, LexModelsV2Error> DeleteImportOutcome;
typedef Aws::Utils::Outcome<Aws::NoResult, LexModelsV2Error> DeleteIntentOutcome;
typedef Aws::Utils::Outcome<DeleteResourcePolicyResult, LexModelsV2Error> DeleteResourcePolicyOutcome;
typedef Aws::Utils::Outcome<DeleteResourcePolicyStatementResult, LexModelsV2Error> DeleteResourcePolicyStatementOutcome;
typedef Aws::Utils::Outcome<Aws::NoResult, LexModelsV2Error> DeleteSlotOutcome;
typedef Aws::Utils::Outcome<Aws::NoResult, LexModelsV2Error> DeleteSlotTypeOutcome;
typedef Aws::Utils::Outcome<DescribeBotResult, LexModelsV2Error> DescribeBotOutcome;
typedef Aws::Utils::Outcome<DescribeBotAliasResult, LexModelsV2Error> DescribeBotAliasOutcome;
typedef Aws::Utils::Outcome<DescribeBotLocaleResult, LexModelsV2Error> DescribeBotLocaleOutcome;
typedef Aws::Utils::Outcome<DescribeBotVersionResult, LexModelsV2Error> DescribeBotVersionOutcome;
typedef Aws::Utils::Outcome<DescribeExportResult, LexModelsV2Error> DescribeExportOutcome;
typedef Aws::Utils::Outcome<DescribeImportResult, LexModelsV2Error> DescribeImportOutcome;
typedef Aws::Utils::Outcome<DescribeIntentResult, LexModelsV2Error> DescribeIntentOutcome;
typedef Aws::Utils::Outcome<DescribeResourcePolicyResult, LexModelsV2Error> DescribeResourcePolicyOutcome;
typedef Aws::Utils::Outcome<DescribeSlotResult, LexModelsV2Error> DescribeSlotOutcome;
typedef Aws::Utils::Outcome<DescribeSlotTypeResult, LexModelsV2Error> DescribeSlotTypeOutcome;
typedef Aws::Utils::Outcome<ListBotAliasesResult, LexModelsV2Error> ListBotAliasesOutcome;
typedef Aws::Utils::Outcome<ListBotLocalesResult, LexModelsV2Error> ListBotLocalesOutcome;
typedef Aws::Utils::Outcome<ListBotVersionsResult, LexModelsV2Error> ListBotVersionsOutcome;
typedef Aws::Utils::Outcome<ListBotsResult, LexModelsV2Error> ListBotsOutcome;
typedef Aws::Utils::Outcome<ListBuiltInIntentsResult, LexModelsV2Error> ListBuiltInIntentsOutcome;
typedef Aws::Utils::Outcome<ListBuiltInSlotTypesResult, LexModelsV2Error> ListBuiltInSlotTypesOutcome;
typedef Aws::Utils::Outcome<ListExportsResult, LexModelsV2Error> ListExportsOutcome;
typedef Aws::Utils::Outcome<ListImportsResult, LexModelsV2Error> ListImportsOutcome;
typedef Aws::Utils::Outcome<ListIntentsResult, LexModelsV2Error> ListIntentsOutcome;
typedef Aws::Utils::Outcome<ListSlotTypesResult, LexModelsV2Error> ListSlotTypesOutcome;
typedef Aws::Utils::Outcome<ListSlotsResult, LexModelsV2Error> ListSlotsOutcome;
typedef Aws::Utils::Outcome<ListTagsForResourceResult, LexModelsV2Error> ListTagsForResourceOutcome;
typedef Aws::Utils::Outcome<StartImportResult, LexModelsV2Error> StartImportOutcome;
typedef Aws::Utils::Outcome<TagResourceResult, LexModelsV2Error> TagResourceOutcome;
typedef Aws::Utils::Outcome<UntagResourceResult, LexModelsV2Error> UntagResourceOutcome;
typedef Aws::Utils::Outcome<UpdateBotResult, LexModelsV2Error> UpdateBotOutcome;
typedef Aws::Utils::Outcome<UpdateBotAliasResult, LexModelsV2Error> UpdateBotAliasOutcome;
typedef Aws::Utils::Outcome<UpdateBotLocaleResult, LexModelsV2Error> UpdateBotLocaleOutcome;
typedef Aws::Utils::Outcome<UpdateExportResult, LexModelsV2Error> UpdateExportOutcome;
typedef Aws::Utils::Outcome<UpdateIntentResult, LexModelsV2Error> UpdateIntentOutcome;
typedef Aws::Utils::Outcome<UpdateResourcePolicyResult, LexModelsV2Error> UpdateResourcePolicyOutcome;
typedef Aws::Utils::Outcome<UpdateSlotResult, LexModelsV2Error> UpdateSlotOutcome;
typedef Aws::Utils::Outcome<UpdateSlotTypeResult, LexModelsV2Error> UpdateSlotTypeOutcome;
typedef std::future<BuildBotLocaleOutcome> BuildBotLocaleOutcomeCallable;
typedef std::future<CreateBotOutcome> CreateBotOutcomeCallable;
typedef std::future<CreateBotAliasOutcome> CreateBotAliasOutcomeCallable;
typedef std::future<CreateBotLocaleOutcome> CreateBotLocaleOutcomeCallable;
typedef std::future<CreateBotVersionOutcome> CreateBotVersionOutcomeCallable;
typedef std::future<CreateExportOutcome> CreateExportOutcomeCallable;
typedef std::future<CreateIntentOutcome> CreateIntentOutcomeCallable;
typedef std::future<CreateResourcePolicyOutcome> CreateResourcePolicyOutcomeCallable;
typedef std::future<CreateResourcePolicyStatementOutcome> CreateResourcePolicyStatementOutcomeCallable;
typedef std::future<CreateSlotOutcome> CreateSlotOutcomeCallable;
typedef std::future<CreateSlotTypeOutcome> CreateSlotTypeOutcomeCallable;
typedef std::future<CreateUploadUrlOutcome> CreateUploadUrlOutcomeCallable;
typedef std::future<DeleteBotOutcome> DeleteBotOutcomeCallable;
typedef std::future<DeleteBotAliasOutcome> DeleteBotAliasOutcomeCallable;
typedef std::future<DeleteBotLocaleOutcome> DeleteBotLocaleOutcomeCallable;
typedef std::future<DeleteBotVersionOutcome> DeleteBotVersionOutcomeCallable;
typedef std::future<DeleteExportOutcome> DeleteExportOutcomeCallable;
typedef std::future<DeleteImportOutcome> DeleteImportOutcomeCallable;
typedef std::future<DeleteIntentOutcome> DeleteIntentOutcomeCallable;
typedef std::future<DeleteResourcePolicyOutcome> DeleteResourcePolicyOutcomeCallable;
typedef std::future<DeleteResourcePolicyStatementOutcome> DeleteResourcePolicyStatementOutcomeCallable;
typedef std::future<DeleteSlotOutcome> DeleteSlotOutcomeCallable;
typedef std::future<DeleteSlotTypeOutcome> DeleteSlotTypeOutcomeCallable;
typedef std::future<DescribeBotOutcome> DescribeBotOutcomeCallable;
typedef std::future<DescribeBotAliasOutcome> DescribeBotAliasOutcomeCallable;
typedef std::future<DescribeBotLocaleOutcome> DescribeBotLocaleOutcomeCallable;
typedef std::future<DescribeBotVersionOutcome> DescribeBotVersionOutcomeCallable;
typedef std::future<DescribeExportOutcome> DescribeExportOutcomeCallable;
typedef std::future<DescribeImportOutcome> DescribeImportOutcomeCallable;
typedef std::future<DescribeIntentOutcome> DescribeIntentOutcomeCallable;
typedef std::future<DescribeResourcePolicyOutcome> DescribeResourcePolicyOutcomeCallable;
typedef std::future<DescribeSlotOutcome> DescribeSlotOutcomeCallable;
typedef std::future<DescribeSlotTypeOutcome> DescribeSlotTypeOutcomeCallable;
typedef std::future<ListBotAliasesOutcome> ListBotAliasesOutcomeCallable;
typedef std::future<ListBotLocalesOutcome> ListBotLocalesOutcomeCallable;
typedef std::future<ListBotVersionsOutcome> ListBotVersionsOutcomeCallable;
typedef std::future<ListBotsOutcome> ListBotsOutcomeCallable;
typedef std::future<ListBuiltInIntentsOutcome> ListBuiltInIntentsOutcomeCallable;
typedef std::future<ListBuiltInSlotTypesOutcome> ListBuiltInSlotTypesOutcomeCallable;
typedef std::future<ListExportsOutcome> ListExportsOutcomeCallable;
typedef std::future<ListImportsOutcome> ListImportsOutcomeCallable;
typedef std::future<ListIntentsOutcome> ListIntentsOutcomeCallable;
typedef std::future<ListSlotTypesOutcome> ListSlotTypesOutcomeCallable;
typedef std::future<ListSlotsOutcome> ListSlotsOutcomeCallable;
typedef std::future<ListTagsForResourceOutcome> ListTagsForResourceOutcomeCallable;
typedef std::future<StartImportOutcome> StartImportOutcomeCallable;
typedef std::future<TagResourceOutcome> TagResourceOutcomeCallable;
typedef std::future<UntagResourceOutcome> UntagResourceOutcomeCallable;
typedef std::future<UpdateBotOutcome> UpdateBotOutcomeCallable;
typedef std::future<UpdateBotAliasOutcome> UpdateBotAliasOutcomeCallable;
typedef std::future<UpdateBotLocaleOutcome> UpdateBotLocaleOutcomeCallable;
typedef std::future<UpdateExportOutcome> UpdateExportOutcomeCallable;
typedef std::future<UpdateIntentOutcome> UpdateIntentOutcomeCallable;
typedef std::future<UpdateResourcePolicyOutcome> UpdateResourcePolicyOutcomeCallable;
typedef std::future<UpdateSlotOutcome> UpdateSlotOutcomeCallable;
typedef std::future<UpdateSlotTypeOutcome> UpdateSlotTypeOutcomeCallable;
} // namespace Model
class LexModelsV2Client;
typedef std::function<void(const LexModelsV2Client*, const Model::BuildBotLocaleRequest&, const Model::BuildBotLocaleOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > BuildBotLocaleResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateBotRequest&, const Model::CreateBotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateBotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateBotAliasRequest&, const Model::CreateBotAliasOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateBotAliasResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateBotLocaleRequest&, const Model::CreateBotLocaleOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateBotLocaleResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateBotVersionRequest&, const Model::CreateBotVersionOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateBotVersionResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateExportRequest&, const Model::CreateExportOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateExportResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateIntentRequest&, const Model::CreateIntentOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateIntentResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateResourcePolicyRequest&, const Model::CreateResourcePolicyOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateResourcePolicyResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateResourcePolicyStatementRequest&, const Model::CreateResourcePolicyStatementOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateResourcePolicyStatementResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateSlotRequest&, const Model::CreateSlotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateSlotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateSlotTypeRequest&, const Model::CreateSlotTypeOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateSlotTypeResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::CreateUploadUrlRequest&, const Model::CreateUploadUrlOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > CreateUploadUrlResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteBotRequest&, const Model::DeleteBotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteBotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteBotAliasRequest&, const Model::DeleteBotAliasOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteBotAliasResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteBotLocaleRequest&, const Model::DeleteBotLocaleOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteBotLocaleResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteBotVersionRequest&, const Model::DeleteBotVersionOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteBotVersionResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteExportRequest&, const Model::DeleteExportOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteExportResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteImportRequest&, const Model::DeleteImportOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteImportResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteIntentRequest&, const Model::DeleteIntentOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteIntentResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteResourcePolicyRequest&, const Model::DeleteResourcePolicyOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteResourcePolicyResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteResourcePolicyStatementRequest&, const Model::DeleteResourcePolicyStatementOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteResourcePolicyStatementResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteSlotRequest&, const Model::DeleteSlotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteSlotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DeleteSlotTypeRequest&, const Model::DeleteSlotTypeOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DeleteSlotTypeResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeBotRequest&, const Model::DescribeBotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeBotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeBotAliasRequest&, const Model::DescribeBotAliasOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeBotAliasResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeBotLocaleRequest&, const Model::DescribeBotLocaleOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeBotLocaleResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeBotVersionRequest&, const Model::DescribeBotVersionOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeBotVersionResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeExportRequest&, const Model::DescribeExportOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeExportResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeImportRequest&, const Model::DescribeImportOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeImportResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeIntentRequest&, const Model::DescribeIntentOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeIntentResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeResourcePolicyRequest&, const Model::DescribeResourcePolicyOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeResourcePolicyResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeSlotRequest&, const Model::DescribeSlotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeSlotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::DescribeSlotTypeRequest&, const Model::DescribeSlotTypeOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > DescribeSlotTypeResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListBotAliasesRequest&, const Model::ListBotAliasesOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListBotAliasesResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListBotLocalesRequest&, const Model::ListBotLocalesOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListBotLocalesResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListBotVersionsRequest&, const Model::ListBotVersionsOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListBotVersionsResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListBotsRequest&, const Model::ListBotsOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListBotsResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListBuiltInIntentsRequest&, const Model::ListBuiltInIntentsOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListBuiltInIntentsResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListBuiltInSlotTypesRequest&, const Model::ListBuiltInSlotTypesOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListBuiltInSlotTypesResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListExportsRequest&, const Model::ListExportsOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListExportsResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListImportsRequest&, const Model::ListImportsOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListImportsResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListIntentsRequest&, const Model::ListIntentsOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListIntentsResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListSlotTypesRequest&, const Model::ListSlotTypesOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListSlotTypesResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListSlotsRequest&, const Model::ListSlotsOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListSlotsResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::ListTagsForResourceRequest&, const Model::ListTagsForResourceOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > ListTagsForResourceResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::StartImportRequest&, const Model::StartImportOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > StartImportResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::TagResourceRequest&, const Model::TagResourceOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > TagResourceResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UntagResourceRequest&, const Model::UntagResourceOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UntagResourceResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateBotRequest&, const Model::UpdateBotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateBotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateBotAliasRequest&, const Model::UpdateBotAliasOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateBotAliasResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateBotLocaleRequest&, const Model::UpdateBotLocaleOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateBotLocaleResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateExportRequest&, const Model::UpdateExportOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateExportResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateIntentRequest&, const Model::UpdateIntentOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateIntentResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateResourcePolicyRequest&, const Model::UpdateResourcePolicyOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateResourcePolicyResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateSlotRequest&, const Model::UpdateSlotOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateSlotResponseReceivedHandler;
typedef std::function<void(const LexModelsV2Client*, const Model::UpdateSlotTypeRequest&, const Model::UpdateSlotTypeOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > UpdateSlotTypeResponseReceivedHandler;
/**
* <p/>
*/
class AWS_LEXMODELSV2_API LexModelsV2Client : public Aws::Client::AWSJsonClient
{
public:
typedef Aws::Client::AWSJsonClient BASECLASS;
/**
* Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config
* is not specified, it will be initialized to default values.
*/
LexModelsV2Client(const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
/**
* Initializes client to use SimpleAWSCredentialsProvider, with default http client factory, and optional client config. If client config
* is not specified, it will be initialized to default values.
*/
LexModelsV2Client(const Aws::Auth::AWSCredentials& credentials, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
/**
* Initializes client to use specified credentials provider with specified client config. If http client factory is not supplied,
* the default http client factory will be used
*/
LexModelsV2Client(const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider,
const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
virtual ~LexModelsV2Client();
/**
* <p>Builds a bot, its intents, and its slot types into a specific locale. A bot
* can be built into multiple locales. At runtime the locale is used to choose a
* specific build of the bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/BuildBotLocale">AWS
* API Reference</a></p>
*/
virtual Model::BuildBotLocaleOutcome BuildBotLocale(const Model::BuildBotLocaleRequest& request) const;
/**
* <p>Builds a bot, its intents, and its slot types into a specific locale. A bot
* can be built into multiple locales. At runtime the locale is used to choose a
* specific build of the bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/BuildBotLocale">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::BuildBotLocaleOutcomeCallable BuildBotLocaleCallable(const Model::BuildBotLocaleRequest& request) const;
/**
* <p>Builds a bot, its intents, and its slot types into a specific locale. A bot
* can be built into multiple locales. At runtime the locale is used to choose a
* specific build of the bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/BuildBotLocale">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void BuildBotLocaleAsync(const Model::BuildBotLocaleRequest& request, const BuildBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates an Amazon Lex conversational bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBot">AWS
* API Reference</a></p>
*/
virtual Model::CreateBotOutcome CreateBot(const Model::CreateBotRequest& request) const;
/**
* <p>Creates an Amazon Lex conversational bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateBotOutcomeCallable CreateBotCallable(const Model::CreateBotRequest& request) const;
/**
* <p>Creates an Amazon Lex conversational bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateBotAsync(const Model::CreateBotRequest& request, const CreateBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates an alias for the specified version of a bot. Use an alias to enable
* you to change the version of a bot without updating applications that use the
* bot.</p> <p>For example, you can create an alias called "PROD" that your
* applications use to call the Amazon Lex bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotAlias">AWS
* API Reference</a></p>
*/
virtual Model::CreateBotAliasOutcome CreateBotAlias(const Model::CreateBotAliasRequest& request) const;
/**
* <p>Creates an alias for the specified version of a bot. Use an alias to enable
* you to change the version of a bot without updating applications that use the
* bot.</p> <p>For example, you can create an alias called "PROD" that your
* applications use to call the Amazon Lex bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotAlias">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateBotAliasOutcomeCallable CreateBotAliasCallable(const Model::CreateBotAliasRequest& request) const;
/**
* <p>Creates an alias for the specified version of a bot. Use an alias to enable
* you to change the version of a bot without updating applications that use the
* bot.</p> <p>For example, you can create an alias called "PROD" that your
* applications use to call the Amazon Lex bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotAlias">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateBotAliasAsync(const Model::CreateBotAliasRequest& request, const CreateBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates a locale in the bot. The locale contains the intents and slot types
* that the bot uses in conversations with users in the specified language and
* locale. You must add a locale to a bot before you can add intents and slot types
* to the bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotLocale">AWS
* API Reference</a></p>
*/
virtual Model::CreateBotLocaleOutcome CreateBotLocale(const Model::CreateBotLocaleRequest& request) const;
/**
* <p>Creates a locale in the bot. The locale contains the intents and slot types
* that the bot uses in conversations with users in the specified language and
* locale. You must add a locale to a bot before you can add intents and slot types
* to the bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotLocale">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateBotLocaleOutcomeCallable CreateBotLocaleCallable(const Model::CreateBotLocaleRequest& request) const;
/**
* <p>Creates a locale in the bot. The locale contains the intents and slot types
* that the bot uses in conversations with users in the specified language and
* locale. You must add a locale to a bot before you can add intents and slot types
* to the bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotLocale">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateBotLocaleAsync(const Model::CreateBotLocaleRequest& request, const CreateBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates a new version of the bot based on the <code>DRAFT</code> version. If
* the <code>DRAFT</code> version of this resource hasn't changed since you created
* the last version, Amazon Lex doesn't create a new version, it returns the last
* created version.</p> <p>When you create the first version of a bot, Amazon Lex
* sets the version to 1. Subsequent versions increment by 1.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotVersion">AWS
* API Reference</a></p>
*/
virtual Model::CreateBotVersionOutcome CreateBotVersion(const Model::CreateBotVersionRequest& request) const;
/**
* <p>Creates a new version of the bot based on the <code>DRAFT</code> version. If
* the <code>DRAFT</code> version of this resource hasn't changed since you created
* the last version, Amazon Lex doesn't create a new version, it returns the last
* created version.</p> <p>When you create the first version of a bot, Amazon Lex
* sets the version to 1. Subsequent versions increment by 1.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotVersion">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateBotVersionOutcomeCallable CreateBotVersionCallable(const Model::CreateBotVersionRequest& request) const;
/**
* <p>Creates a new version of the bot based on the <code>DRAFT</code> version. If
* the <code>DRAFT</code> version of this resource hasn't changed since you created
* the last version, Amazon Lex doesn't create a new version, it returns the last
* created version.</p> <p>When you create the first version of a bot, Amazon Lex
* sets the version to 1. Subsequent versions increment by 1.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateBotVersion">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateBotVersionAsync(const Model::CreateBotVersionRequest& request, const CreateBotVersionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates a zip archive containing the contents of a bot or a bot locale. The
* archive contains a directory structure that contains JSON files that define the
* bot.</p> <p>You can create an archive that contains the complete definition of a
* bot, or you can specify that the archive contain only the definition of a single
* bot locale.</p> <p>For more information about exporting bots, and about the
* structure of the export archive, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/importing-exporting.html">
* Importing and exporting bots </a> </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateExport">AWS
* API Reference</a></p>
*/
virtual Model::CreateExportOutcome CreateExport(const Model::CreateExportRequest& request) const;
/**
* <p>Creates a zip archive containing the contents of a bot or a bot locale. The
* archive contains a directory structure that contains JSON files that define the
* bot.</p> <p>You can create an archive that contains the complete definition of a
* bot, or you can specify that the archive contain only the definition of a single
* bot locale.</p> <p>For more information about exporting bots, and about the
* structure of the export archive, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/importing-exporting.html">
* Importing and exporting bots </a> </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateExport">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateExportOutcomeCallable CreateExportCallable(const Model::CreateExportRequest& request) const;
/**
* <p>Creates a zip archive containing the contents of a bot or a bot locale. The
* archive contains a directory structure that contains JSON files that define the
* bot.</p> <p>You can create an archive that contains the complete definition of a
* bot, or you can specify that the archive contain only the definition of a single
* bot locale.</p> <p>For more information about exporting bots, and about the
* structure of the export archive, see <a
* href="https://docs.aws.amazon.com/lexv2/latest/dg/importing-exporting.html">
* Importing and exporting bots </a> </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateExport">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateExportAsync(const Model::CreateExportRequest& request, const CreateExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates an intent.</p> <p>To define the interaction between the user and your
* bot, you define one or more intents. For example, for a pizza ordering bot you
* would create an <code>OrderPizza</code> intent.</p> <p>When you create an
* intent, you must provide a name. You can optionally provide the following:</p>
* <ul> <li> <p>Sample utterances. For example, "I want to order a pizza" and "Can
* I order a pizza." You can't provide utterances for built-in intents.</p> </li>
* <li> <p>Information to be gathered. You specify slots for the information that
* you bot requests from the user. You can specify standard slot types, such as
* date and time, or custom slot types for your application.</p> </li> <li> <p>How
* the intent is fulfilled. You can provide a Lambda function or configure the
* intent to return the intent information to your client application. If you use a
* Lambda function, Amazon Lex invokes the function when all of the intent
* information is available.</p> </li> <li> <p>A confirmation prompt to send to the
* user to confirm an intent. For example, "Shall I order your pizza?"</p> </li>
* <li> <p>A conclusion statement to send to the user after the intent is
* fulfilled. For example, "I ordered your pizza."</p> </li> <li> <p>A follow-up
* prompt that asks the user for additional activity. For example, "Do you want a
* drink with your pizza?"</p> </li> </ul><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateIntent">AWS
* API Reference</a></p>
*/
virtual Model::CreateIntentOutcome CreateIntent(const Model::CreateIntentRequest& request) const;
/**
* <p>Creates an intent.</p> <p>To define the interaction between the user and your
* bot, you define one or more intents. For example, for a pizza ordering bot you
* would create an <code>OrderPizza</code> intent.</p> <p>When you create an
* intent, you must provide a name. You can optionally provide the following:</p>
* <ul> <li> <p>Sample utterances. For example, "I want to order a pizza" and "Can
* I order a pizza." You can't provide utterances for built-in intents.</p> </li>
* <li> <p>Information to be gathered. You specify slots for the information that
* you bot requests from the user. You can specify standard slot types, such as
* date and time, or custom slot types for your application.</p> </li> <li> <p>How
* the intent is fulfilled. You can provide a Lambda function or configure the
* intent to return the intent information to your client application. If you use a
* Lambda function, Amazon Lex invokes the function when all of the intent
* information is available.</p> </li> <li> <p>A confirmation prompt to send to the
* user to confirm an intent. For example, "Shall I order your pizza?"</p> </li>
* <li> <p>A conclusion statement to send to the user after the intent is
* fulfilled. For example, "I ordered your pizza."</p> </li> <li> <p>A follow-up
* prompt that asks the user for additional activity. For example, "Do you want a
* drink with your pizza?"</p> </li> </ul><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateIntent">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateIntentOutcomeCallable CreateIntentCallable(const Model::CreateIntentRequest& request) const;
/**
* <p>Creates an intent.</p> <p>To define the interaction between the user and your
* bot, you define one or more intents. For example, for a pizza ordering bot you
* would create an <code>OrderPizza</code> intent.</p> <p>When you create an
* intent, you must provide a name. You can optionally provide the following:</p>
* <ul> <li> <p>Sample utterances. For example, "I want to order a pizza" and "Can
* I order a pizza." You can't provide utterances for built-in intents.</p> </li>
* <li> <p>Information to be gathered. You specify slots for the information that
* you bot requests from the user. You can specify standard slot types, such as
* date and time, or custom slot types for your application.</p> </li> <li> <p>How
* the intent is fulfilled. You can provide a Lambda function or configure the
* intent to return the intent information to your client application. If you use a
* Lambda function, Amazon Lex invokes the function when all of the intent
* information is available.</p> </li> <li> <p>A confirmation prompt to send to the
* user to confirm an intent. For example, "Shall I order your pizza?"</p> </li>
* <li> <p>A conclusion statement to send to the user after the intent is
* fulfilled. For example, "I ordered your pizza."</p> </li> <li> <p>A follow-up
* prompt that asks the user for additional activity. For example, "Do you want a
* drink with your pizza?"</p> </li> </ul><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateIntent">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateIntentAsync(const Model::CreateIntentRequest& request, const CreateIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates a new resource policy with the specified policy
* statements.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateResourcePolicy">AWS
* API Reference</a></p>
*/
virtual Model::CreateResourcePolicyOutcome CreateResourcePolicy(const Model::CreateResourcePolicyRequest& request) const;
/**
* <p>Creates a new resource policy with the specified policy
* statements.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateResourcePolicy">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateResourcePolicyOutcomeCallable CreateResourcePolicyCallable(const Model::CreateResourcePolicyRequest& request) const;
/**
* <p>Creates a new resource policy with the specified policy
* statements.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateResourcePolicy">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateResourcePolicyAsync(const Model::CreateResourcePolicyRequest& request, const CreateResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Adds a new resource policy statement to a bot or bot alias. If a resource
* policy exists, the statement is added to the current resource policy. If a
* policy doesn't exist, a new policy is created.</p> <p>You can't create a
* resource policy statement that allows cross-account access.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateResourcePolicyStatement">AWS
* API Reference</a></p>
*/
virtual Model::CreateResourcePolicyStatementOutcome CreateResourcePolicyStatement(const Model::CreateResourcePolicyStatementRequest& request) const;
/**
* <p>Adds a new resource policy statement to a bot or bot alias. If a resource
* policy exists, the statement is added to the current resource policy. If a
* policy doesn't exist, a new policy is created.</p> <p>You can't create a
* resource policy statement that allows cross-account access.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateResourcePolicyStatement">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateResourcePolicyStatementOutcomeCallable CreateResourcePolicyStatementCallable(const Model::CreateResourcePolicyStatementRequest& request) const;
/**
* <p>Adds a new resource policy statement to a bot or bot alias. If a resource
* policy exists, the statement is added to the current resource policy. If a
* policy doesn't exist, a new policy is created.</p> <p>You can't create a
* resource policy statement that allows cross-account access.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateResourcePolicyStatement">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateResourcePolicyStatementAsync(const Model::CreateResourcePolicyStatementRequest& request, const CreateResourcePolicyStatementResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates a slot in an intent. A slot is a variable needed to fulfill an
* intent. For example, an <code>OrderPizza</code> intent might need slots for
* size, crust, and number of pizzas. For each slot, you define one or more
* utterances that Amazon Lex uses to elicit a response from the user.
* </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateSlot">AWS
* API Reference</a></p>
*/
virtual Model::CreateSlotOutcome CreateSlot(const Model::CreateSlotRequest& request) const;
/**
* <p>Creates a slot in an intent. A slot is a variable needed to fulfill an
* intent. For example, an <code>OrderPizza</code> intent might need slots for
* size, crust, and number of pizzas. For each slot, you define one or more
* utterances that Amazon Lex uses to elicit a response from the user.
* </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateSlot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateSlotOutcomeCallable CreateSlotCallable(const Model::CreateSlotRequest& request) const;
/**
* <p>Creates a slot in an intent. A slot is a variable needed to fulfill an
* intent. For example, an <code>OrderPizza</code> intent might need slots for
* size, crust, and number of pizzas. For each slot, you define one or more
* utterances that Amazon Lex uses to elicit a response from the user.
* </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateSlot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateSlotAsync(const Model::CreateSlotRequest& request, const CreateSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Creates a custom slot type</p> <p> To create a custom slot type, specify a
* name for the slot type and a set of enumeration values, the values that a slot
* of this type can assume. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateSlotType">AWS
* API Reference</a></p>
*/
virtual Model::CreateSlotTypeOutcome CreateSlotType(const Model::CreateSlotTypeRequest& request) const;
/**
* <p>Creates a custom slot type</p> <p> To create a custom slot type, specify a
* name for the slot type and a set of enumeration values, the values that a slot
* of this type can assume. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateSlotType">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateSlotTypeOutcomeCallable CreateSlotTypeCallable(const Model::CreateSlotTypeRequest& request) const;
/**
* <p>Creates a custom slot type</p> <p> To create a custom slot type, specify a
* name for the slot type and a set of enumeration values, the values that a slot
* of this type can assume. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateSlotType">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateSlotTypeAsync(const Model::CreateSlotTypeRequest& request, const CreateSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a pre-signed S3 write URL that you use to upload the zip archive when
* importing a bot or a bot locale. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateUploadUrl">AWS
* API Reference</a></p>
*/
virtual Model::CreateUploadUrlOutcome CreateUploadUrl(const Model::CreateUploadUrlRequest& request) const;
/**
* <p>Gets a pre-signed S3 write URL that you use to upload the zip archive when
* importing a bot or a bot locale. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateUploadUrl">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::CreateUploadUrlOutcomeCallable CreateUploadUrlCallable(const Model::CreateUploadUrlRequest& request) const;
/**
* <p>Gets a pre-signed S3 write URL that you use to upload the zip archive when
* importing a bot or a bot locale. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/CreateUploadUrl">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void CreateUploadUrlAsync(const Model::CreateUploadUrlRequest& request, const CreateUploadUrlResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Deletes all versions of a bot, including the <code>Draft</code> version. To
* delete a specific version, use the <code>DeleteBotVersion</code> operation.</p>
* <p>When you delete a bot, all of the resources contained in the bot are also
* deleted. Deleting a bot removes all locales, intents, slot, and slot types
* defined for the bot.</p> <p>If a bot has an alias, the <code>DeleteBot</code>
* operation returns a <code>ResourceInUseException</code> exception. If you want
* to delete the bot and the alias, set the <code>skipResourceInUseCheck</code>
* parameter to <code>true</code>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBot">AWS
* API Reference</a></p>
*/
virtual Model::DeleteBotOutcome DeleteBot(const Model::DeleteBotRequest& request) const;
/**
* <p>Deletes all versions of a bot, including the <code>Draft</code> version. To
* delete a specific version, use the <code>DeleteBotVersion</code> operation.</p>
* <p>When you delete a bot, all of the resources contained in the bot are also
* deleted. Deleting a bot removes all locales, intents, slot, and slot types
* defined for the bot.</p> <p>If a bot has an alias, the <code>DeleteBot</code>
* operation returns a <code>ResourceInUseException</code> exception. If you want
* to delete the bot and the alias, set the <code>skipResourceInUseCheck</code>
* parameter to <code>true</code>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteBotOutcomeCallable DeleteBotCallable(const Model::DeleteBotRequest& request) const;
/**
* <p>Deletes all versions of a bot, including the <code>Draft</code> version. To
* delete a specific version, use the <code>DeleteBotVersion</code> operation.</p>
* <p>When you delete a bot, all of the resources contained in the bot are also
* deleted. Deleting a bot removes all locales, intents, slot, and slot types
* defined for the bot.</p> <p>If a bot has an alias, the <code>DeleteBot</code>
* operation returns a <code>ResourceInUseException</code> exception. If you want
* to delete the bot and the alias, set the <code>skipResourceInUseCheck</code>
* parameter to <code>true</code>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteBotAsync(const Model::DeleteBotRequest& request, const DeleteBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Deletes the specified bot alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotAlias">AWS
* API Reference</a></p>
*/
virtual Model::DeleteBotAliasOutcome DeleteBotAlias(const Model::DeleteBotAliasRequest& request) const;
/**
* <p>Deletes the specified bot alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotAlias">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteBotAliasOutcomeCallable DeleteBotAliasCallable(const Model::DeleteBotAliasRequest& request) const;
/**
* <p>Deletes the specified bot alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotAlias">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteBotAliasAsync(const Model::DeleteBotAliasRequest& request, const DeleteBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Removes a locale from a bot.</p> <p>When you delete a locale, all intents,
* slots, and slot types defined for the locale are also deleted.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotLocale">AWS
* API Reference</a></p>
*/
virtual Model::DeleteBotLocaleOutcome DeleteBotLocale(const Model::DeleteBotLocaleRequest& request) const;
/**
* <p>Removes a locale from a bot.</p> <p>When you delete a locale, all intents,
* slots, and slot types defined for the locale are also deleted.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotLocale">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteBotLocaleOutcomeCallable DeleteBotLocaleCallable(const Model::DeleteBotLocaleRequest& request) const;
/**
* <p>Removes a locale from a bot.</p> <p>When you delete a locale, all intents,
* slots, and slot types defined for the locale are also deleted.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotLocale">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteBotLocaleAsync(const Model::DeleteBotLocaleRequest& request, const DeleteBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Deletes a specific version of a bot. To delete all version of a bot, use the
* <a>DeleteBot</a> operation.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotVersion">AWS
* API Reference</a></p>
*/
virtual Model::DeleteBotVersionOutcome DeleteBotVersion(const Model::DeleteBotVersionRequest& request) const;
/**
* <p>Deletes a specific version of a bot. To delete all version of a bot, use the
* <a>DeleteBot</a> operation.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotVersion">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteBotVersionOutcomeCallable DeleteBotVersionCallable(const Model::DeleteBotVersionRequest& request) const;
/**
* <p>Deletes a specific version of a bot. To delete all version of a bot, use the
* <a>DeleteBot</a> operation.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteBotVersion">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteBotVersionAsync(const Model::DeleteBotVersionRequest& request, const DeleteBotVersionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Removes a previous export and the associated files stored in an S3
* bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteExport">AWS
* API Reference</a></p>
*/
virtual Model::DeleteExportOutcome DeleteExport(const Model::DeleteExportRequest& request) const;
/**
* <p>Removes a previous export and the associated files stored in an S3
* bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteExport">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteExportOutcomeCallable DeleteExportCallable(const Model::DeleteExportRequest& request) const;
/**
* <p>Removes a previous export and the associated files stored in an S3
* bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteExport">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteExportAsync(const Model::DeleteExportRequest& request, const DeleteExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Removes a previous import and the associated file stored in an S3
* bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteImport">AWS
* API Reference</a></p>
*/
virtual Model::DeleteImportOutcome DeleteImport(const Model::DeleteImportRequest& request) const;
/**
* <p>Removes a previous import and the associated file stored in an S3
* bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteImport">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteImportOutcomeCallable DeleteImportCallable(const Model::DeleteImportRequest& request) const;
/**
* <p>Removes a previous import and the associated file stored in an S3
* bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteImport">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteImportAsync(const Model::DeleteImportRequest& request, const DeleteImportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Removes the specified intent.</p> <p>Deleting an intent also deletes the
* slots associated with the intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteIntent">AWS
* API Reference</a></p>
*/
virtual Model::DeleteIntentOutcome DeleteIntent(const Model::DeleteIntentRequest& request) const;
/**
* <p>Removes the specified intent.</p> <p>Deleting an intent also deletes the
* slots associated with the intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteIntent">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteIntentOutcomeCallable DeleteIntentCallable(const Model::DeleteIntentRequest& request) const;
/**
* <p>Removes the specified intent.</p> <p>Deleting an intent also deletes the
* slots associated with the intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteIntent">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteIntentAsync(const Model::DeleteIntentRequest& request, const DeleteIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Removes an existing policy from a bot or bot alias. If the resource doesn't
* have a policy attached, Amazon Lex returns an exception.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteResourcePolicy">AWS
* API Reference</a></p>
*/
virtual Model::DeleteResourcePolicyOutcome DeleteResourcePolicy(const Model::DeleteResourcePolicyRequest& request) const;
/**
* <p>Removes an existing policy from a bot or bot alias. If the resource doesn't
* have a policy attached, Amazon Lex returns an exception.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteResourcePolicy">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteResourcePolicyOutcomeCallable DeleteResourcePolicyCallable(const Model::DeleteResourcePolicyRequest& request) const;
/**
* <p>Removes an existing policy from a bot or bot alias. If the resource doesn't
* have a policy attached, Amazon Lex returns an exception.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteResourcePolicy">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteResourcePolicyAsync(const Model::DeleteResourcePolicyRequest& request, const DeleteResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Deletes a policy statement from a resource policy. If you delete the last
* statement from a policy, the policy is deleted. If you specify a statement ID
* that doesn't exist in the policy, or if the bot or bot alias doesn't have a
* policy attached, Amazon Lex returns an exception.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteResourcePolicyStatement">AWS
* API Reference</a></p>
*/
virtual Model::DeleteResourcePolicyStatementOutcome DeleteResourcePolicyStatement(const Model::DeleteResourcePolicyStatementRequest& request) const;
/**
* <p>Deletes a policy statement from a resource policy. If you delete the last
* statement from a policy, the policy is deleted. If you specify a statement ID
* that doesn't exist in the policy, or if the bot or bot alias doesn't have a
* policy attached, Amazon Lex returns an exception.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteResourcePolicyStatement">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteResourcePolicyStatementOutcomeCallable DeleteResourcePolicyStatementCallable(const Model::DeleteResourcePolicyStatementRequest& request) const;
/**
* <p>Deletes a policy statement from a resource policy. If you delete the last
* statement from a policy, the policy is deleted. If you specify a statement ID
* that doesn't exist in the policy, or if the bot or bot alias doesn't have a
* policy attached, Amazon Lex returns an exception.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteResourcePolicyStatement">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteResourcePolicyStatementAsync(const Model::DeleteResourcePolicyStatementRequest& request, const DeleteResourcePolicyStatementResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Deletes the specified slot from an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteSlot">AWS
* API Reference</a></p>
*/
virtual Model::DeleteSlotOutcome DeleteSlot(const Model::DeleteSlotRequest& request) const;
/**
* <p>Deletes the specified slot from an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteSlot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteSlotOutcomeCallable DeleteSlotCallable(const Model::DeleteSlotRequest& request) const;
/**
* <p>Deletes the specified slot from an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteSlot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteSlotAsync(const Model::DeleteSlotRequest& request, const DeleteSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Deletes a slot type from a bot locale.</p> <p>If a slot is using the slot
* type, Amazon Lex throws a <code>ResourceInUseException</code> exception. To
* avoid the exception, set the <code>skipResourceInUseCheck</code> parameter to
* <code>true</code>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteSlotType">AWS
* API Reference</a></p>
*/
virtual Model::DeleteSlotTypeOutcome DeleteSlotType(const Model::DeleteSlotTypeRequest& request) const;
/**
* <p>Deletes a slot type from a bot locale.</p> <p>If a slot is using the slot
* type, Amazon Lex throws a <code>ResourceInUseException</code> exception. To
* avoid the exception, set the <code>skipResourceInUseCheck</code> parameter to
* <code>true</code>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteSlotType">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DeleteSlotTypeOutcomeCallable DeleteSlotTypeCallable(const Model::DeleteSlotTypeRequest& request) const;
/**
* <p>Deletes a slot type from a bot locale.</p> <p>If a slot is using the slot
* type, Amazon Lex throws a <code>ResourceInUseException</code> exception. To
* avoid the exception, set the <code>skipResourceInUseCheck</code> parameter to
* <code>true</code>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DeleteSlotType">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DeleteSlotTypeAsync(const Model::DeleteSlotTypeRequest& request, const DeleteSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Provides metadata information about a bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBot">AWS
* API Reference</a></p>
*/
virtual Model::DescribeBotOutcome DescribeBot(const Model::DescribeBotRequest& request) const;
/**
* <p>Provides metadata information about a bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeBotOutcomeCallable DescribeBotCallable(const Model::DescribeBotRequest& request) const;
/**
* <p>Provides metadata information about a bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeBotAsync(const Model::DescribeBotRequest& request, const DescribeBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Get information about a specific bot alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotAlias">AWS
* API Reference</a></p>
*/
virtual Model::DescribeBotAliasOutcome DescribeBotAlias(const Model::DescribeBotAliasRequest& request) const;
/**
* <p>Get information about a specific bot alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotAlias">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeBotAliasOutcomeCallable DescribeBotAliasCallable(const Model::DescribeBotAliasRequest& request) const;
/**
* <p>Get information about a specific bot alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotAlias">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeBotAliasAsync(const Model::DescribeBotAliasRequest& request, const DescribeBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Describes the settings that a bot has for a specific locale. </p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotLocale">AWS
* API Reference</a></p>
*/
virtual Model::DescribeBotLocaleOutcome DescribeBotLocale(const Model::DescribeBotLocaleRequest& request) const;
/**
* <p>Describes the settings that a bot has for a specific locale. </p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotLocale">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeBotLocaleOutcomeCallable DescribeBotLocaleCallable(const Model::DescribeBotLocaleRequest& request) const;
/**
* <p>Describes the settings that a bot has for a specific locale. </p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotLocale">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeBotLocaleAsync(const Model::DescribeBotLocaleRequest& request, const DescribeBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Provides metadata about a version of a bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotVersion">AWS
* API Reference</a></p>
*/
virtual Model::DescribeBotVersionOutcome DescribeBotVersion(const Model::DescribeBotVersionRequest& request) const;
/**
* <p>Provides metadata about a version of a bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotVersion">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeBotVersionOutcomeCallable DescribeBotVersionCallable(const Model::DescribeBotVersionRequest& request) const;
/**
* <p>Provides metadata about a version of a bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeBotVersion">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeBotVersionAsync(const Model::DescribeBotVersionRequest& request, const DescribeBotVersionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets information about a specific export.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeExport">AWS
* API Reference</a></p>
*/
virtual Model::DescribeExportOutcome DescribeExport(const Model::DescribeExportRequest& request) const;
/**
* <p>Gets information about a specific export.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeExport">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeExportOutcomeCallable DescribeExportCallable(const Model::DescribeExportRequest& request) const;
/**
* <p>Gets information about a specific export.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeExport">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeExportAsync(const Model::DescribeExportRequest& request, const DescribeExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets information about a specific import.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeImport">AWS
* API Reference</a></p>
*/
virtual Model::DescribeImportOutcome DescribeImport(const Model::DescribeImportRequest& request) const;
/**
* <p>Gets information about a specific import.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeImport">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeImportOutcomeCallable DescribeImportCallable(const Model::DescribeImportRequest& request) const;
/**
* <p>Gets information about a specific import.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeImport">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeImportAsync(const Model::DescribeImportRequest& request, const DescribeImportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Returns metadata about an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeIntent">AWS
* API Reference</a></p>
*/
virtual Model::DescribeIntentOutcome DescribeIntent(const Model::DescribeIntentRequest& request) const;
/**
* <p>Returns metadata about an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeIntent">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeIntentOutcomeCallable DescribeIntentCallable(const Model::DescribeIntentRequest& request) const;
/**
* <p>Returns metadata about an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeIntent">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeIntentAsync(const Model::DescribeIntentRequest& request, const DescribeIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets the resource policy and policy revision for a bot or bot
* alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeResourcePolicy">AWS
* API Reference</a></p>
*/
virtual Model::DescribeResourcePolicyOutcome DescribeResourcePolicy(const Model::DescribeResourcePolicyRequest& request) const;
/**
* <p>Gets the resource policy and policy revision for a bot or bot
* alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeResourcePolicy">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeResourcePolicyOutcomeCallable DescribeResourcePolicyCallable(const Model::DescribeResourcePolicyRequest& request) const;
/**
* <p>Gets the resource policy and policy revision for a bot or bot
* alias.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeResourcePolicy">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeResourcePolicyAsync(const Model::DescribeResourcePolicyRequest& request, const DescribeResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets metadata information about a slot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeSlot">AWS
* API Reference</a></p>
*/
virtual Model::DescribeSlotOutcome DescribeSlot(const Model::DescribeSlotRequest& request) const;
/**
* <p>Gets metadata information about a slot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeSlot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeSlotOutcomeCallable DescribeSlotCallable(const Model::DescribeSlotRequest& request) const;
/**
* <p>Gets metadata information about a slot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeSlot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeSlotAsync(const Model::DescribeSlotRequest& request, const DescribeSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets metadata information about a slot type.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeSlotType">AWS
* API Reference</a></p>
*/
virtual Model::DescribeSlotTypeOutcome DescribeSlotType(const Model::DescribeSlotTypeRequest& request) const;
/**
* <p>Gets metadata information about a slot type.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeSlotType">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::DescribeSlotTypeOutcomeCallable DescribeSlotTypeCallable(const Model::DescribeSlotTypeRequest& request) const;
/**
* <p>Gets metadata information about a slot type.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/DescribeSlotType">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void DescribeSlotTypeAsync(const Model::DescribeSlotTypeRequest& request, const DescribeSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of aliases for the specified bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotAliases">AWS
* API Reference</a></p>
*/
virtual Model::ListBotAliasesOutcome ListBotAliases(const Model::ListBotAliasesRequest& request) const;
/**
* <p>Gets a list of aliases for the specified bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotAliases">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListBotAliasesOutcomeCallable ListBotAliasesCallable(const Model::ListBotAliasesRequest& request) const;
/**
* <p>Gets a list of aliases for the specified bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotAliases">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListBotAliasesAsync(const Model::ListBotAliasesRequest& request, const ListBotAliasesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of locales for the specified bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotLocales">AWS
* API Reference</a></p>
*/
virtual Model::ListBotLocalesOutcome ListBotLocales(const Model::ListBotLocalesRequest& request) const;
/**
* <p>Gets a list of locales for the specified bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotLocales">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListBotLocalesOutcomeCallable ListBotLocalesCallable(const Model::ListBotLocalesRequest& request) const;
/**
* <p>Gets a list of locales for the specified bot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotLocales">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListBotLocalesAsync(const Model::ListBotLocalesRequest& request, const ListBotLocalesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets information about all of the versions of a bot.</p> <p>The
* <code>ListBotVersions</code> operation returns a summary of each version of a
* bot. For example, if a bot has three numbered versions, the
* <code>ListBotVersions</code> operation returns for summaries, one for each
* numbered version and one for the <code>DRAFT</code> version.</p> <p>The
* <code>ListBotVersions</code> operation always returns at least one version, the
* <code>DRAFT</code> version.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotVersions">AWS
* API Reference</a></p>
*/
virtual Model::ListBotVersionsOutcome ListBotVersions(const Model::ListBotVersionsRequest& request) const;
/**
* <p>Gets information about all of the versions of a bot.</p> <p>The
* <code>ListBotVersions</code> operation returns a summary of each version of a
* bot. For example, if a bot has three numbered versions, the
* <code>ListBotVersions</code> operation returns for summaries, one for each
* numbered version and one for the <code>DRAFT</code> version.</p> <p>The
* <code>ListBotVersions</code> operation always returns at least one version, the
* <code>DRAFT</code> version.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotVersions">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListBotVersionsOutcomeCallable ListBotVersionsCallable(const Model::ListBotVersionsRequest& request) const;
/**
* <p>Gets information about all of the versions of a bot.</p> <p>The
* <code>ListBotVersions</code> operation returns a summary of each version of a
* bot. For example, if a bot has three numbered versions, the
* <code>ListBotVersions</code> operation returns for summaries, one for each
* numbered version and one for the <code>DRAFT</code> version.</p> <p>The
* <code>ListBotVersions</code> operation always returns at least one version, the
* <code>DRAFT</code> version.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBotVersions">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListBotVersionsAsync(const Model::ListBotVersionsRequest& request, const ListBotVersionsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of available bots.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBots">AWS
* API Reference</a></p>
*/
virtual Model::ListBotsOutcome ListBots(const Model::ListBotsRequest& request) const;
/**
* <p>Gets a list of available bots.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBots">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListBotsOutcomeCallable ListBotsCallable(const Model::ListBotsRequest& request) const;
/**
* <p>Gets a list of available bots.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBots">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListBotsAsync(const Model::ListBotsRequest& request, const ListBotsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of built-in intents provided by Amazon Lex that you can use in
* your bot. </p> <p>To use a built-in intent as a the base for your own intent,
* include the built-in intent signature in the <code>parentIntentSignature</code>
* parameter when you call the <code>CreateIntent</code> operation. For more
* information, see <a>CreateIntent</a>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBuiltInIntents">AWS
* API Reference</a></p>
*/
virtual Model::ListBuiltInIntentsOutcome ListBuiltInIntents(const Model::ListBuiltInIntentsRequest& request) const;
/**
* <p>Gets a list of built-in intents provided by Amazon Lex that you can use in
* your bot. </p> <p>To use a built-in intent as a the base for your own intent,
* include the built-in intent signature in the <code>parentIntentSignature</code>
* parameter when you call the <code>CreateIntent</code> operation. For more
* information, see <a>CreateIntent</a>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBuiltInIntents">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListBuiltInIntentsOutcomeCallable ListBuiltInIntentsCallable(const Model::ListBuiltInIntentsRequest& request) const;
/**
* <p>Gets a list of built-in intents provided by Amazon Lex that you can use in
* your bot. </p> <p>To use a built-in intent as a the base for your own intent,
* include the built-in intent signature in the <code>parentIntentSignature</code>
* parameter when you call the <code>CreateIntent</code> operation. For more
* information, see <a>CreateIntent</a>.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBuiltInIntents">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListBuiltInIntentsAsync(const Model::ListBuiltInIntentsRequest& request, const ListBuiltInIntentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of built-in slot types that meet the specified
* criteria.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBuiltInSlotTypes">AWS
* API Reference</a></p>
*/
virtual Model::ListBuiltInSlotTypesOutcome ListBuiltInSlotTypes(const Model::ListBuiltInSlotTypesRequest& request) const;
/**
* <p>Gets a list of built-in slot types that meet the specified
* criteria.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBuiltInSlotTypes">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListBuiltInSlotTypesOutcomeCallable ListBuiltInSlotTypesCallable(const Model::ListBuiltInSlotTypesRequest& request) const;
/**
* <p>Gets a list of built-in slot types that meet the specified
* criteria.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListBuiltInSlotTypes">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListBuiltInSlotTypesAsync(const Model::ListBuiltInSlotTypesRequest& request, const ListBuiltInSlotTypesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Lists the exports for a bot or bot locale. Exports are kept in the list for 7
* days.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListExports">AWS
* API Reference</a></p>
*/
virtual Model::ListExportsOutcome ListExports(const Model::ListExportsRequest& request) const;
/**
* <p>Lists the exports for a bot or bot locale. Exports are kept in the list for 7
* days.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListExports">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListExportsOutcomeCallable ListExportsCallable(const Model::ListExportsRequest& request) const;
/**
* <p>Lists the exports for a bot or bot locale. Exports are kept in the list for 7
* days.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListExports">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListExportsAsync(const Model::ListExportsRequest& request, const ListExportsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Lists the imports for a bot or bot locale. Imports are kept in the list for 7
* days.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListImports">AWS
* API Reference</a></p>
*/
virtual Model::ListImportsOutcome ListImports(const Model::ListImportsRequest& request) const;
/**
* <p>Lists the imports for a bot or bot locale. Imports are kept in the list for 7
* days.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListImports">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListImportsOutcomeCallable ListImportsCallable(const Model::ListImportsRequest& request) const;
/**
* <p>Lists the imports for a bot or bot locale. Imports are kept in the list for 7
* days.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListImports">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListImportsAsync(const Model::ListImportsRequest& request, const ListImportsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Get a list of intents that meet the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListIntents">AWS
* API Reference</a></p>
*/
virtual Model::ListIntentsOutcome ListIntents(const Model::ListIntentsRequest& request) const;
/**
* <p>Get a list of intents that meet the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListIntents">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListIntentsOutcomeCallable ListIntentsCallable(const Model::ListIntentsRequest& request) const;
/**
* <p>Get a list of intents that meet the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListIntents">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListIntentsAsync(const Model::ListIntentsRequest& request, const ListIntentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of slot types that match the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListSlotTypes">AWS
* API Reference</a></p>
*/
virtual Model::ListSlotTypesOutcome ListSlotTypes(const Model::ListSlotTypesRequest& request) const;
/**
* <p>Gets a list of slot types that match the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListSlotTypes">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListSlotTypesOutcomeCallable ListSlotTypesCallable(const Model::ListSlotTypesRequest& request) const;
/**
* <p>Gets a list of slot types that match the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListSlotTypes">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListSlotTypesAsync(const Model::ListSlotTypesRequest& request, const ListSlotTypesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of slots that match the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListSlots">AWS
* API Reference</a></p>
*/
virtual Model::ListSlotsOutcome ListSlots(const Model::ListSlotsRequest& request) const;
/**
* <p>Gets a list of slots that match the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListSlots">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListSlotsOutcomeCallable ListSlotsCallable(const Model::ListSlotsRequest& request) const;
/**
* <p>Gets a list of slots that match the specified criteria.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListSlots">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListSlotsAsync(const Model::ListSlotsRequest& request, const ListSlotsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Gets a list of tags associated with a resource. Only bots, bot aliases, and
* bot channels can have tags associated with them.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListTagsForResource">AWS
* API Reference</a></p>
*/
virtual Model::ListTagsForResourceOutcome ListTagsForResource(const Model::ListTagsForResourceRequest& request) const;
/**
* <p>Gets a list of tags associated with a resource. Only bots, bot aliases, and
* bot channels can have tags associated with them.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListTagsForResource">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::ListTagsForResourceOutcomeCallable ListTagsForResourceCallable(const Model::ListTagsForResourceRequest& request) const;
/**
* <p>Gets a list of tags associated with a resource. Only bots, bot aliases, and
* bot channels can have tags associated with them.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/ListTagsForResource">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void ListTagsForResourceAsync(const Model::ListTagsForResourceRequest& request, const ListTagsForResourceResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Starts importing a bot or bot locale from a zip archive that you uploaded to
* an S3 bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/StartImport">AWS
* API Reference</a></p>
*/
virtual Model::StartImportOutcome StartImport(const Model::StartImportRequest& request) const;
/**
* <p>Starts importing a bot or bot locale from a zip archive that you uploaded to
* an S3 bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/StartImport">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::StartImportOutcomeCallable StartImportCallable(const Model::StartImportRequest& request) const;
/**
* <p>Starts importing a bot or bot locale from a zip archive that you uploaded to
* an S3 bucket.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/StartImport">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void StartImportAsync(const Model::StartImportRequest& request, const StartImportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Adds the specified tags to the specified resource. If a tag key already
* exists, the existing value is replaced with the new value.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/TagResource">AWS
* API Reference</a></p>
*/
virtual Model::TagResourceOutcome TagResource(const Model::TagResourceRequest& request) const;
/**
* <p>Adds the specified tags to the specified resource. If a tag key already
* exists, the existing value is replaced with the new value.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/TagResource">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::TagResourceOutcomeCallable TagResourceCallable(const Model::TagResourceRequest& request) const;
/**
* <p>Adds the specified tags to the specified resource. If a tag key already
* exists, the existing value is replaced with the new value.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/TagResource">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void TagResourceAsync(const Model::TagResourceRequest& request, const TagResourceResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Removes tags from a bot, bot alias, or bot channel.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UntagResource">AWS
* API Reference</a></p>
*/
virtual Model::UntagResourceOutcome UntagResource(const Model::UntagResourceRequest& request) const;
/**
* <p>Removes tags from a bot, bot alias, or bot channel.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UntagResource">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UntagResourceOutcomeCallable UntagResourceCallable(const Model::UntagResourceRequest& request) const;
/**
* <p>Removes tags from a bot, bot alias, or bot channel.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UntagResource">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UntagResourceAsync(const Model::UntagResourceRequest& request, const UntagResourceResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Updates the configuration of an existing bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBot">AWS
* API Reference</a></p>
*/
virtual Model::UpdateBotOutcome UpdateBot(const Model::UpdateBotRequest& request) const;
/**
* <p>Updates the configuration of an existing bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateBotOutcomeCallable UpdateBotCallable(const Model::UpdateBotRequest& request) const;
/**
* <p>Updates the configuration of an existing bot. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateBotAsync(const Model::UpdateBotRequest& request, const UpdateBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Updates the configuration of an existing bot alias.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBotAlias">AWS
* API Reference</a></p>
*/
virtual Model::UpdateBotAliasOutcome UpdateBotAlias(const Model::UpdateBotAliasRequest& request) const;
/**
* <p>Updates the configuration of an existing bot alias.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBotAlias">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateBotAliasOutcomeCallable UpdateBotAliasCallable(const Model::UpdateBotAliasRequest& request) const;
/**
* <p>Updates the configuration of an existing bot alias.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBotAlias">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateBotAliasAsync(const Model::UpdateBotAliasRequest& request, const UpdateBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Updates the settings that a bot has for a specific locale.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBotLocale">AWS
* API Reference</a></p>
*/
virtual Model::UpdateBotLocaleOutcome UpdateBotLocale(const Model::UpdateBotLocaleRequest& request) const;
/**
* <p>Updates the settings that a bot has for a specific locale.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBotLocale">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateBotLocaleOutcomeCallable UpdateBotLocaleCallable(const Model::UpdateBotLocaleRequest& request) const;
/**
* <p>Updates the settings that a bot has for a specific locale.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateBotLocale">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateBotLocaleAsync(const Model::UpdateBotLocaleRequest& request, const UpdateBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Updates the password used to protect an export zip archive.</p> <p>The
* password is not required. If you don't supply a password, Amazon Lex generates a
* zip file that is not protected by a password. This is the archive that is
* available at the pre-signed S3 URL provided by the operation.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateExport">AWS
* API Reference</a></p>
*/
virtual Model::UpdateExportOutcome UpdateExport(const Model::UpdateExportRequest& request) const;
/**
* <p>Updates the password used to protect an export zip archive.</p> <p>The
* password is not required. If you don't supply a password, Amazon Lex generates a
* zip file that is not protected by a password. This is the archive that is
* available at the pre-signed S3 URL provided by the operation.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateExport">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateExportOutcomeCallable UpdateExportCallable(const Model::UpdateExportRequest& request) const;
/**
* <p>Updates the password used to protect an export zip archive.</p> <p>The
* password is not required. If you don't supply a password, Amazon Lex generates a
* zip file that is not protected by a password. This is the archive that is
* available at the pre-signed S3 URL provided by the operation.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateExport">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateExportAsync(const Model::UpdateExportRequest& request, const UpdateExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Updates the settings for an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateIntent">AWS
* API Reference</a></p>
*/
virtual Model::UpdateIntentOutcome UpdateIntent(const Model::UpdateIntentRequest& request) const;
/**
* <p>Updates the settings for an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateIntent">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateIntentOutcomeCallable UpdateIntentCallable(const Model::UpdateIntentRequest& request) const;
/**
* <p>Updates the settings for an intent.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateIntent">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateIntentAsync(const Model::UpdateIntentRequest& request, const UpdateIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Replaces the existing resource policy for a bot or bot alias with a new one.
* If the policy doesn't exist, Amazon Lex returns an exception.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateResourcePolicy">AWS
* API Reference</a></p>
*/
virtual Model::UpdateResourcePolicyOutcome UpdateResourcePolicy(const Model::UpdateResourcePolicyRequest& request) const;
/**
* <p>Replaces the existing resource policy for a bot or bot alias with a new one.
* If the policy doesn't exist, Amazon Lex returns an exception.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateResourcePolicy">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateResourcePolicyOutcomeCallable UpdateResourcePolicyCallable(const Model::UpdateResourcePolicyRequest& request) const;
/**
* <p>Replaces the existing resource policy for a bot or bot alias with a new one.
* If the policy doesn't exist, Amazon Lex returns an exception.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateResourcePolicy">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateResourcePolicyAsync(const Model::UpdateResourcePolicyRequest& request, const UpdateResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Updates the settings for a slot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateSlot">AWS
* API Reference</a></p>
*/
virtual Model::UpdateSlotOutcome UpdateSlot(const Model::UpdateSlotRequest& request) const;
/**
* <p>Updates the settings for a slot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateSlot">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateSlotOutcomeCallable UpdateSlotCallable(const Model::UpdateSlotRequest& request) const;
/**
* <p>Updates the settings for a slot.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateSlot">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateSlotAsync(const Model::UpdateSlotRequest& request, const UpdateSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
/**
* <p>Updates the configuration of an existing slot type.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateSlotType">AWS
* API Reference</a></p>
*/
virtual Model::UpdateSlotTypeOutcome UpdateSlotType(const Model::UpdateSlotTypeRequest& request) const;
/**
* <p>Updates the configuration of an existing slot type.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateSlotType">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::UpdateSlotTypeOutcomeCallable UpdateSlotTypeCallable(const Model::UpdateSlotTypeRequest& request) const;
/**
* <p>Updates the configuration of an existing slot type.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/models.lex.v2-2020-08-07/UpdateSlotType">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void UpdateSlotTypeAsync(const Model::UpdateSlotTypeRequest& request, const UpdateSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
void OverrideEndpoint(const Aws::String& endpoint);
private:
void init(const Aws::Client::ClientConfiguration& clientConfiguration);
void BuildBotLocaleAsyncHelper(const Model::BuildBotLocaleRequest& request, const BuildBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateBotAsyncHelper(const Model::CreateBotRequest& request, const CreateBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateBotAliasAsyncHelper(const Model::CreateBotAliasRequest& request, const CreateBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateBotLocaleAsyncHelper(const Model::CreateBotLocaleRequest& request, const CreateBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateBotVersionAsyncHelper(const Model::CreateBotVersionRequest& request, const CreateBotVersionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateExportAsyncHelper(const Model::CreateExportRequest& request, const CreateExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateIntentAsyncHelper(const Model::CreateIntentRequest& request, const CreateIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateResourcePolicyAsyncHelper(const Model::CreateResourcePolicyRequest& request, const CreateResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateResourcePolicyStatementAsyncHelper(const Model::CreateResourcePolicyStatementRequest& request, const CreateResourcePolicyStatementResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateSlotAsyncHelper(const Model::CreateSlotRequest& request, const CreateSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateSlotTypeAsyncHelper(const Model::CreateSlotTypeRequest& request, const CreateSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void CreateUploadUrlAsyncHelper(const Model::CreateUploadUrlRequest& request, const CreateUploadUrlResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteBotAsyncHelper(const Model::DeleteBotRequest& request, const DeleteBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteBotAliasAsyncHelper(const Model::DeleteBotAliasRequest& request, const DeleteBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteBotLocaleAsyncHelper(const Model::DeleteBotLocaleRequest& request, const DeleteBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteBotVersionAsyncHelper(const Model::DeleteBotVersionRequest& request, const DeleteBotVersionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteExportAsyncHelper(const Model::DeleteExportRequest& request, const DeleteExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteImportAsyncHelper(const Model::DeleteImportRequest& request, const DeleteImportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteIntentAsyncHelper(const Model::DeleteIntentRequest& request, const DeleteIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteResourcePolicyAsyncHelper(const Model::DeleteResourcePolicyRequest& request, const DeleteResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteResourcePolicyStatementAsyncHelper(const Model::DeleteResourcePolicyStatementRequest& request, const DeleteResourcePolicyStatementResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteSlotAsyncHelper(const Model::DeleteSlotRequest& request, const DeleteSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DeleteSlotTypeAsyncHelper(const Model::DeleteSlotTypeRequest& request, const DeleteSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeBotAsyncHelper(const Model::DescribeBotRequest& request, const DescribeBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeBotAliasAsyncHelper(const Model::DescribeBotAliasRequest& request, const DescribeBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeBotLocaleAsyncHelper(const Model::DescribeBotLocaleRequest& request, const DescribeBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeBotVersionAsyncHelper(const Model::DescribeBotVersionRequest& request, const DescribeBotVersionResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeExportAsyncHelper(const Model::DescribeExportRequest& request, const DescribeExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeImportAsyncHelper(const Model::DescribeImportRequest& request, const DescribeImportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeIntentAsyncHelper(const Model::DescribeIntentRequest& request, const DescribeIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeResourcePolicyAsyncHelper(const Model::DescribeResourcePolicyRequest& request, const DescribeResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeSlotAsyncHelper(const Model::DescribeSlotRequest& request, const DescribeSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void DescribeSlotTypeAsyncHelper(const Model::DescribeSlotTypeRequest& request, const DescribeSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListBotAliasesAsyncHelper(const Model::ListBotAliasesRequest& request, const ListBotAliasesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListBotLocalesAsyncHelper(const Model::ListBotLocalesRequest& request, const ListBotLocalesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListBotVersionsAsyncHelper(const Model::ListBotVersionsRequest& request, const ListBotVersionsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListBotsAsyncHelper(const Model::ListBotsRequest& request, const ListBotsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListBuiltInIntentsAsyncHelper(const Model::ListBuiltInIntentsRequest& request, const ListBuiltInIntentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListBuiltInSlotTypesAsyncHelper(const Model::ListBuiltInSlotTypesRequest& request, const ListBuiltInSlotTypesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListExportsAsyncHelper(const Model::ListExportsRequest& request, const ListExportsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListImportsAsyncHelper(const Model::ListImportsRequest& request, const ListImportsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListIntentsAsyncHelper(const Model::ListIntentsRequest& request, const ListIntentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListSlotTypesAsyncHelper(const Model::ListSlotTypesRequest& request, const ListSlotTypesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListSlotsAsyncHelper(const Model::ListSlotsRequest& request, const ListSlotsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void ListTagsForResourceAsyncHelper(const Model::ListTagsForResourceRequest& request, const ListTagsForResourceResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void StartImportAsyncHelper(const Model::StartImportRequest& request, const StartImportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void TagResourceAsyncHelper(const Model::TagResourceRequest& request, const TagResourceResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UntagResourceAsyncHelper(const Model::UntagResourceRequest& request, const UntagResourceResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateBotAsyncHelper(const Model::UpdateBotRequest& request, const UpdateBotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateBotAliasAsyncHelper(const Model::UpdateBotAliasRequest& request, const UpdateBotAliasResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateBotLocaleAsyncHelper(const Model::UpdateBotLocaleRequest& request, const UpdateBotLocaleResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateExportAsyncHelper(const Model::UpdateExportRequest& request, const UpdateExportResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateIntentAsyncHelper(const Model::UpdateIntentRequest& request, const UpdateIntentResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateResourcePolicyAsyncHelper(const Model::UpdateResourcePolicyRequest& request, const UpdateResourcePolicyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateSlotAsyncHelper(const Model::UpdateSlotRequest& request, const UpdateSlotResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
void UpdateSlotTypeAsyncHelper(const Model::UpdateSlotTypeRequest& request, const UpdateSlotTypeResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
Aws::String m_uri;
Aws::String m_configScheme;
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor;
};
} // namespace LexModelsV2
} // namespace Aws
|
8b0fbab3adadfdd62c8839f6032235f17e40358d | 7776f88bc3bdb0342930dde82fb4edb4f0862818 | /entity/table_entity.cpp | 35c848cbcd9cf1f3d27e1bdf0576e6675e2de949 | [] | no_license | LYuanZhuo/orderSystem | 93858c65d7cf62ee7adb9b9b76e3eb3bda133ad3 | 03c4feac0ee32997d7bae1865d745cd28660c11d | refs/heads/master | 2021-08-07T11:01:21.218987 | 2020-05-11T09:34:02 | 2020-05-11T09:34:02 | 174,059,369 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 831 | cpp | table_entity.cpp | #include "table_entity.h"
Table_entity::Table_entity()
{
}
QString Table_entity::getName(){
return this->name;
}
void Table_entity::setName(QString name){
this->name = name;
}
QString Table_entity::getDescribe(){
return this->describe;
}
void Table_entity::setDescribe(QString describe){
this->describe = describe;
}
int Table_entity::getId(){
return this->id;
}
void Table_entity::setId(int id){
this->id = id;
}
int Table_entity::getSize(){
return this->size;
}
void Table_entity::setSize(int size){
this->size = size;
}
int Table_entity::getShopId(){
return this->shopId;
}
void Table_entity::setShopId(int shopId){
this->shopId = shopId;
}
bool Table_entity::getIsFree(){
return this->isFree;
}
void Table_entity::setIsFree(bool isFree){
this->isFree = isFree;
}
|
fd241ce5f9d2a3d4f084713b8bcf27ac63b42218 | 108a5affdb8c4da4a60324e788d1f86f99cbdcdf | /contest/ct 222/B.cpp | b98538b3e195f9e6a38bf7462cb8bd766861c962 | [] | no_license | beingdisni/topcoder | 558c5f6c65ef48d4f96a7c0e09d4e827ff6e4a7e | d51b0c2d13adda9cdd293783226ca28daa72490a | refs/heads/master | 2021-01-18T17:23:01.342598 | 2014-02-03T15:27:29 | 2014-02-03T15:27:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 545 | cpp | B.cpp | #ifdef no_compile
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
using namespace std;
#define rep(i,f,t) for(int i = (f),end_##i = (t); i < end_##i; ++i)
#define _MAX 1000
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef long long ll;
int n, m, s;
int main() {
cin >> n >> m >> s;
vi a(n), b(m), c(n);
rep(i, 0, m) cin >> b[i];
rep(i, 0, n) cin >> a[i];
return 0;
}
#endif |
67d1c9d2eb6ab51ed7c4f7ab0ebe6a75c06cc986 | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/tar/hunk_10.cpp | f2ef422596a3b6a9515e956df44c3f12f2501a4f | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,197 | cpp | hunk_10.cpp | +/* Per-directory exclusion files for tar.
+
+ Copyright 2014 Free Software Foundation, Inc.
+
+ This file is part of GNU tar.
+
+ GNU tar is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ GNU tar is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include <system.h>
+#include <quotearg.h>
+#include <fnmatch.h>
+#include <wordsplit.h>
+#include "common.h"
+
+typedef void (*add_fn) (struct exclude *, char const *, int, void *);
+
+struct vcs_ignore_file
+{
+ char const *filename;
+ int flags;
+ add_fn addfn;
+ void *(*initfn) (void *);
+ void *data;
+};
+
+static struct vcs_ignore_file *get_vcs_ignore_file (const char *name);
+
+struct excfile
+{
+ struct excfile *next;
+ int flags;
+ char name[1];
+};
+
+struct excfile *excfile_head, *excfile_tail;
+
+void
+excfile_add (const char *name, int flags)
+{
+ struct excfile *p = xmalloc (sizeof (*p) + strlen (name));
+ p->next = NULL;
+ p->flags = flags;
+ strcpy (p->name, name);
+ if (excfile_tail)
+ excfile_tail->next = p;
+ else
+ excfile_head = p;
+ excfile_tail = p;
+}
+
+struct exclist
+{
+ struct exclist *next, *prev;
+ int flags;
+ struct exclude *excluded;
+};
+
+void
+info_attach_exclist (struct tar_stat_info *dir)
+{
+ struct excfile *file;
+ struct exclist *head = NULL, *tail = NULL, *ent;
+ struct vcs_ignore_file *vcsfile;
+
+ if (dir->exclude_list)
+ return;
+ for (file = excfile_head; file; file = file->next)
+ {
+ if (faccessat (dir ? dir->fd : chdir_fd, file->name, F_OK, 0) == 0)
+ {
+ FILE *fp;
+ struct exclude *ex = NULL;
+ int fd = subfile_open (dir, file->name, O_RDONLY);
+ if (fd == -1)
+ {
+ open_error (file->name);
+ continue;
+ }
+ fp = fdopen (fd, "r");
+ if (!fp)
+ {
+ ERROR ((0, errno, _("%s: fdopen failed"), file->name));
+ close (fd);
+ continue;
+ }
+
+ if (!ex)
+ ex = new_exclude ();
+
+ vcsfile = get_vcs_ignore_file (file->name);
+
+ if (vcsfile->initfn)
+ vcsfile->data = vcsfile->initfn (vcsfile->data);
+
+ if (add_exclude_fp (vcsfile->addfn, ex, fp,
+ EXCLUDE_WILDCARDS|EXCLUDE_ANCHORED, '\n',
+ vcsfile->data))
+ {
+ int e = errno;
+ FATAL_ERROR ((0, e, "%s", quotearg_colon (file->name)));
+ }
+ fclose (fp);
+
+ ent = xmalloc (sizeof (*ent));
+ ent->excluded = ex;
+ ent->flags = file->flags == EXCL_DEFAULT
+ ? file->flags : vcsfile->flags;
+ ent->prev = tail;
+ ent->next = NULL;
+
+ if (tail)
+ tail->next = ent;
+ else
+ head = ent;
+ tail = ent;
+ }
+ }
+ dir->exclude_list = head;
+}
+
+void
+info_cleanup_exclist (struct tar_stat_info *dir)
+{
+ struct exclist *ep = dir->exclude_list;
+
+ while (ep)
+ {
+ struct exclist *next = ep->next;
+
+ if (ep->flags & EXCL_NON_RECURSIVE)
+ {
+
+ /* Remove the entry */
+ if (ep->prev)
+ ep->prev->next = ep->next;
+ else
+ dir->exclude_list = ep->next;
+
+ if (ep->next)
+ ep->next->prev = ep->prev;
+
+ free_exclude (ep->excluded);
+ free (ep);
+ }
+ ep = next;
+ }
+}
+
+void
+info_free_exclist (struct tar_stat_info *dir)
+{
+ struct exclist *ep = dir->exclude_list;
+
+ while (ep)
+ {
+ struct exclist *next = ep->next;
+ free_exclude (ep->excluded);
+ free (ep);
+ ep = next;
+ }
+
+ dir->exclude_list = NULL;
+}
+
+
+/* Return nonzero if file NAME is excluded. */
+bool
+excluded_name (char const *name, struct tar_stat_info *st)
+{
+ struct exclist *ep;
+ const char *rname = NULL;
+ char *bname = NULL;
+ bool result;
+ int nr = 0;
+
+ name += FILE_SYSTEM_PREFIX_LEN (name);
+
+ /* Try global exclusion list first */
+ if (excluded_file_name (excluded, name))
+ return true;
+
+ if (!st)
+ return false;
+
+ for (result = false; st && !result; st = st->parent, nr = EXCL_NON_RECURSIVE)
+ {
+ for (ep = st->exclude_list; ep; ep = ep->next)
+ {
+ if (ep->flags & nr)
+ continue;
+ if ((result = excluded_file_name (ep->excluded, name)))
+ break;
+
+ if (!rname)
+ {
+ rname = name;
+ /* Skip leading ./ */
+ while (*rname == '.' && ISSLASH (rname[1]))
+ rname += 2;
+ }
+ if ((result = excluded_file_name (ep->excluded, rname)))
+ break;
+
+ if (!bname)
+ bname = base_name (name);
+ if ((result = excluded_file_name (ep->excluded, bname)))
+ break;
+ }
+ }
+
+ free (bname);
+
+ return result;
+}
+
+static void
+cvs_addfn (struct exclude *ex, char const *pattern, int options, void *data)
+{
+ struct wordsplit ws;
+ size_t i;
+
+ if (wordsplit (pattern, &ws,
+ WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_SQUEEZE_DELIMS))
+ return;
+ for (i = 0; i < ws.ws_wordc; i++)
+ add_exclude (ex, ws.ws_wordv[i], options);
+ wordsplit_free (&ws);
+}
+
+static void
+git_addfn (struct exclude *ex, char const *pattern, int options, void *data)
+{
+ while (isspace (*pattern))
+ ++pattern;
+ if (*pattern == 0 || *pattern == '#')
+ return;
+ if (*pattern == '\\' && pattern[1] == '#')
+ ++pattern;
+ add_exclude (ex, pattern, options);
+}
+
+static void
+bzr_addfn (struct exclude *ex, char const *pattern, int options, void *data)
+{
+ while (isspace (*pattern))
+ ++pattern;
+ if (*pattern == 0 || *pattern == '#')
+ return;
+ if (*pattern == '!')
+ {
+ if (*++pattern == '!')
+ ++pattern;
+ else
+ options |= EXCLUDE_INCLUDE;
+ }
+ /* FIXME: According to the docs, globbing patterns are rsync-style,
+ and regexps are perl-style. */
+ if (strncmp (pattern, "RE:", 3) == 0)
+ {
+ pattern += 3;
+ options &= ~EXCLUDE_WILDCARDS;
+ options |= EXCLUDE_REGEX;
+ }
+ add_exclude (ex, pattern, options);
+}
+
+static void *
+hg_initfn (void *data)
+{
+ int *hgopt;
+ static int hg_options;
+
+ if (!data)
+ hgopt = &hg_options;
+
+ *hgopt = EXCLUDE_REGEX;
+ return hgopt;
+}
+
+static void
+hg_addfn (struct exclude *ex, char const *pattern, int options, void *data)
+{
+ int *hgopt = data;
+ size_t len;
+
+ while (isspace (*pattern))
+ ++pattern;
+ if (*pattern == 0 || *pattern == '#')
+ return;
+ if (strncmp (pattern, "syntax:", 7) == 0)
+ {
+ for (pattern += 7; isspace (*pattern); ++pattern)
+ ;
+ if (strcmp (pattern, "regexp") == 0)
+ /* FIXME: Regexps must be perl-style */
+ *hgopt = EXCLUDE_REGEX;
+ else if (strcmp (pattern, "glob") == 0)
+ *hgopt = EXCLUDE_WILDCARDS;
+ /* Ignore unknown syntax */
+ return;
+ }
+
+ len = strlen(pattern);
+ if (pattern[len-1] == '/')
+ {
+ char *p;
+
+ --len;
+ p = xmalloc (len+1);
+ memcpy (p, pattern, len);
+ p[len] = 0;
+ pattern = p;
+ exclude_add_pattern_buffer (ex, p);
+ options |= FNM_LEADING_DIR|EXCLUDE_ALLOC;
+ }
+
+ add_exclude (ex, pattern,
+ ((*hgopt == EXCLUDE_REGEX)
+ ? (options & ~EXCLUDE_WILDCARDS)
+ : (options & ~EXCLUDE_REGEX)) | *hgopt);
+}
+
+struct vcs_ignore_file vcs_ignore_files[] = {
+ { ".cvsignore", EXCL_NON_RECURSIVE, cvs_addfn, NULL, NULL },
+ { ".gitignore", 0, git_addfn, NULL, NULL },
+ { ".bzrignore", 0, bzr_addfn, NULL, NULL },
+ { ".hgignore", 0, hg_addfn, hg_initfn , NULL },
+ { NULL, 0, git_addfn, NULL, NULL }
+};
+
+static struct vcs_ignore_file *
+get_vcs_ignore_file (const char *name)
+{
+ struct vcs_ignore_file *p;
+
+ for (p = vcs_ignore_files; p->filename; p++)
+ if (strcmp (p->filename, name) == 0)
+ break;
+
+ return p;
+}
+
+void
+exclude_vcs_ignores (void)
+{
+ struct vcs_ignore_file *p;
+
+ for (p = vcs_ignore_files; p->filename; p++)
+ excfile_add (p->filename, EXCL_DEFAULT);
+}
|
6e0e7c621596c43bb61acfd2f178a6998300fff3 | f8eec84300aea6cf26d7114f14e10ef180f6f3cd | /savage/include/Savage/Color.hpp | b12f5fd7ce6a98d061fa02000bfa62dee0e5a8ab | [] | no_license | ashimjyoti/POCs | 5867ff79d0f4dcd601bcddbaee06af404f1cb428 | 4aef8fad1a32b2e66954b94813ebfd836147301a | refs/heads/master | 2016-09-06T04:26:29.420799 | 2015-08-11T16:14:51 | 2015-08-11T16:14:51 | 38,917,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,215 | hpp | Color.hpp | #ifndef SAVAGE_COLOR_HPP
#define SAVAGE_COLOR_HPP
#include <stdint.h>
namespace Savage
{
class Color
{
uint8_t r;
uint8_t g;
uint8_t b;
public:
inline Color()
: r(0)
, g(0)
, b(0)
{
}
inline Color(uint8_t _r, uint8_t _g, uint8_t _b)
: r(_r)
, g(_g)
, b(_b)
{
}
inline const uint8_t getR() const
{
return r;
}
inline void setR(uint8_t _r)
{
r = _r;
}
inline const uint8_t getG() const
{
return g;
}
inline void setG(uint8_t _g)
{
g = _g;
}
inline const uint8_t getB() const
{
return b;
}
inline void setB(uint8_t _b)
{
b = _b;
}
inline void set(uint8_t _r, uint8_t _g, uint8_t _b)
{
r = _r;
g = _g;
b = _b;
}
};
namespace __Private
{
template <typename StreamT>
StreamT& __toHex(StreamT& stream, const uint8_t u)
{
if(0 == (u & 0xF0))
{
stream << "0";
}
stream << std::hex << (int) u << std::dec;
return stream;
}
} // namespace __Private
template <typename StreamT>
StreamT& operator << (StreamT& stream, const Color& _c)
{
stream << "#";
__Private::__toHex(stream, _c.getR());
__Private::__toHex(stream, _c.getG());
__Private::__toHex(stream, _c.getB());
return stream;
}
} // namespace Savage
#endif // SAVAGE_COLOR_HPP |
aac7ce99bd3a6a40ee0ed6fa26c53d9d47ef2a59 | 957c320013b6d0e64727d5bafed0c23f5bddae12 | /DrawGerPic/drawgerimage.cpp | cbc906ae13589abb3e34e3c1129ac2d544a58473 | [] | no_license | qisizhang/GithubProject | 879b240f473b8c9414f2a7801c719d0589115af1 | 168c2962c49702960b3ec9e78bd0be86d18d46f2 | refs/heads/master | 2021-05-10T08:31:04.557627 | 2018-01-25T09:33:03 | 2018-01-25T09:33:03 | 118,892,493 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 133 | cpp | drawgerimage.cpp | #include "drawgerimage.h"
drawGerImage::drawGerImage(QWidget *parent)
: QWidget(parent)
{
}
drawGerImage::~drawGerImage()
{
}
|
77c48a59a529676d9737aee9f741ed665df139f0 | c008097bbc7666bd1c84ae43f8644706012d53c0 | /UnrealChao4/Source/RandomUE4Stuff/AnimNotify_OnEndAnimation.cpp | 73ce6d8dd9cca954414ed180b81d32f8597949c2 | [] | no_license | Sage-of-Mirrors/UnrealChao4 | 6e4eff2aa235f271f161620e77b230f3041e1d92 | dfec6fc89e97e7fff656dad6e094ed40b67ffc84 | refs/heads/master | 2021-01-06T23:04:42.588204 | 2020-03-05T05:17:32 | 2020-03-05T05:17:32 | 241,503,567 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 231 | cpp | AnimNotify_OnEndAnimation.cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "AnimNotify_OnEndAnimation.h"
FString UAnimNotify_OnEndAnimation::GetNotifyName_Implementation() const
{
return TEXT("On Animation End");
} |
08fc6524f572ac1eca1c3784775aca9501bfcfa7 | 2c82aa0033c5a4ff1a3d0bef841411007ca632c8 | /Sabertooth/Face.h | 0d481321f224f2656b133ab4e573ebc7592e6359 | [
"MIT"
] | permissive | PabloSKlein/PG-TGA-OpenGl-3D | 296e825e66ee9b0ecccb132b3990a0c4b588968f | 283b965156dbdadeadde9969ba0673690e0e6ede | refs/heads/master | 2021-09-23T13:56:51.168333 | 2018-09-23T15:31:43 | 2018-09-23T15:31:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 590 | h | Face.h | #pragma once
#include <GL/glew.h> /* include GLEW and new version of GL on Windows */
#include <GLFW/glfw3.h> /* GLFW helper library */
#include <stdio.h>
#include <math.h>
// GLM Includes
#include <glm\glm.hpp>
#include <glm\gtc\matrix_transform.hpp>
#include <glm\gtc\type_ptr.hpp>
#include <vector>
using namespace std;
class Face
{
public:
Face();
Face(std::vector<int> vertsArr, std::vector<int> normsArr, std::vector<int> textsArr) {
verts = vertsArr;
norms = normsArr;
texts = textsArr;
}
~Face();
vector<int> verts;
vector<int> norms;
vector<int> texts;
};
|
d81e3c2a5798cb53357350b1213631c5a2beb753 | 07ea30cb26e14b37e612b7da36a263d6e3569120 | /src/Mini/Power.h | 6f58460fb6aa411afcdfd0f8d5d2ff0811b2b365 | [
"MIT"
] | permissive | joaroyen/arcade-kitchen-timer | f569705a60b474caf7edd525c1c00b26a6fbd4a0 | 63217ce0346be406713f0087f1c928057385b050 | refs/heads/master | 2021-09-02T05:44:08.133762 | 2017-12-30T20:04:47 | 2017-12-30T20:04:47 | 109,736,436 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 366 | h | Power.h | #ifndef __Power_h
#define __Power_h
#include "Timer.h"
class Power {
public:
Power(Timer* timer);
void thinkAboutGoingToSleep();
void sleep();
private:
Timer* _timer;
void powerDown();
void wakeUp();
void setupInterrupt();
void clearInterrupt();
void reenableInterrupt();
void resetPins();
void reset();
};
#endif
|
372e7764875021781c6b8c07f84df65ade562652 | fe0587a2624a19e81dad9d4cd9878cf5a08ba2fa | /7.函数--主函数形参/2.3【salesitem类的建立和使用(头文件)】/salesitem类的建立和使用(头文件)/sales_item.h | ed8a5896db3c4edb00960151ab9f254953dff2ab | [] | no_license | tiandongpo/C-BasicSkill | 7d94cb6826e219fb01a2ce46afca8f510b45f914 | 3e11f10f4d1e9082bcefdbf810a9dac39baa27be | refs/heads/master | 2021-01-17T05:21:38.594068 | 2015-10-18T02:56:13 | 2015-10-18T02:56:13 | 42,811,361 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 561 | h | sales_item.h | #ifndef SALESITEM_H
#define SALESITEM_H
#include<iostream>
#include<string>
class Sales_item
{
public:
//sales_item类对象的操作
std::istream& input(std::istream& in);
std::ostream& output(std::ostream& out)const;
Sales_item add(Sales_item& other);
double avg_price() const;
bool same_isbn(const Sales_item &rhs)const
{
return isbn == rhs.isbn;
}
//默认构造函数需要初始化内置类型的数据成员
Sales_item::Sales_item():units_sold(),revenue(0.0){}
private:
std::string isbn;
unsigned units_sold;
double revenue;
};
#endif;
|
44288c2c81ca2a6d55f3fd04f809164bc7e5f5e2 | c09f5c2a71020144372c098167a92043871f5852 | /Lab/savitch_9thed_ch1_problem3/main.cpp | d66d70d12acecf1e334cc41623e7dda9f8930a03 | [] | no_license | Yassefa24/AssefaYared2377569 | 4f3816ca77e32f031fd7f258eb93bd2fa4bcb899 | ff8f22745ed43a17ee2674b72b6b39efd5abf9d7 | refs/heads/master | 2020-04-15T16:12:55.145182 | 2016-12-14T03:12:54 | 2016-12-14T03:12:54 | 68,023,331 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,209 | cpp | main.cpp | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.cpp
* Author: Yared PC
*
* Created on September 19, 2016, 9:07 PM
*
*/
//Include system libraries
#include<iostream>
using namespace std;
int main( )
{
//values
int numQuarters, numDimes, numNickles, totalChange, totQuarters, totDimes, totNickles;
//introducing the problem
cout << "Enter the number of quarters you have then press the enter button. \n";
cin >> numQuarters;
cout << "Now enter the number of dimes you have then press enter. \n";
cin >> numDimes;
cout << "Now enter the amount of nickles you have and press enter. \n";
cin >> numNickles;
//equation
totQuarters = numQuarters * 25;
totDimes = numDimes * 10;
totNickles = numNickles * 5;
totalChange = totQuarters + totDimes + totNickles;
//answer
cout << "You have ";
cout << totalChange;
cout << " cents \n";
cout << "Thats all you got?\n";
//Thats it
return 0;
}
|
71670215ef6ca75cfbbdd36970f5dba5581e4ff7 | bf798d5af7effdb06f373ac653e98cb4dd145a5c | /src/qif191/QIFDocument/type_t.CUserDefinedAttributeCharacteristicActualType.h | 4438e6b9d6b63bf3b175a8e74819f34a75922365 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | QualityInformationFramework/QIFResourcesEditor | 73387fca4f4280cc1145fae32438c5d2fdc63cd5 | 4ff1de9d1dd20d9c43eaa9cc320caeff1c57760e | refs/heads/master | 2022-07-29T15:57:04.341916 | 2021-08-04T16:36:42 | 2021-08-04T16:36:42 | 298,856,948 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,062 | h | type_t.CUserDefinedAttributeCharacteristicActualType.h | #pragma once
#include "type_t.CCharacteristicActualBaseType.h"
namespace qif191
{
namespace t
{
class CUserDefinedAttributeCharacteristicActualType : public ::qif191::t::CCharacteristicActualBaseType
{
public:
QIF191_EXPORT CUserDefinedAttributeCharacteristicActualType(xercesc::DOMNode* const& init);
QIF191_EXPORT CUserDefinedAttributeCharacteristicActualType(CUserDefinedAttributeCharacteristicActualType const& init);
void operator=(CUserDefinedAttributeCharacteristicActualType const& other) { m_node = other.m_node; }
static altova::meta::ComplexType StaticInfo() { return altova::meta::ComplexType(types + _altova_ti_t_altova_CUserDefinedAttributeCharacteristicActualType); }
MemberElement<xs::CstringType, _altova_mi_t_altova_CUserDefinedAttributeCharacteristicActualType_altova_Value2> Value2;
struct Value2 { typedef Iterator<xs::CstringType> iterator; };
QIF191_EXPORT void SetXsiType();
};
} // namespace t
} // namespace qif191
//#endif // _ALTOVA_INCLUDED_QIFDocument_ALTOVA_t_ALTOVA_CUserDefinedAttributeCharacteristicActualType
|
d31b890de2bcc8bbb754457e079329639fece4b7 | 8c0e508d2e9f03be0a02e48168f5455c51f242e7 | /Compettitive programming/BUU camp #14/camp#6/Rush#4/RT_buy2.cpp | 92d58c5566ef3bdea59025a94710cb74adfb202c | [] | no_license | ithsarasak/Programming | 4109ca7123cb4646b7352f5efea6d1c82bd08049 | 722ef1a9d99310dabb4f46321127bdf86b9e9ac0 | refs/heads/master | 2022-10-28T05:29:55.009295 | 2020-06-13T07:42:23 | 2020-06-13T07:42:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 388 | cpp | RT_buy2.cpp | #include<bits/stdc++.h>
using namespace std;
int n;
int num[100100];
long long sum;
int main()
{
scanf("%d",&n);
for( int i = 0 ; i < n ; i++ ){
scanf("%d",&num[i]);
sum += ( long long )num[i];
}
sort( num, num + n, greater<int>() );
for( int i = 2 ; i < n ; i += 3 ){
sum -= ( long long )num[i];
}
printf("%lld",sum);
return 0;
}
|
814e2d18ea10463f0024401eeb8b1d17752f1b9a | d886bbef4caafefc1796e77d41d7c7fdddbb4794 | /mb/static_resources/src/indent.cpp | f6e624f0a9a990ba790fe62bc4cad080a5c2e1ac | [] | no_license | coryshain/pyModelBlocks | 4864a23e4e8452340797fdbc60338ad5e579d14f | ba25bf5d5279962675763f3c30b6452dbae15d25 | refs/heads/master | 2020-08-26T21:30:55.126202 | 2019-11-11T21:12:38 | 2019-11-11T21:12:38 | 217,154,233 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,011 | cpp | indent.cpp | ///////////////////////////////////////////////////////////////////////////////
// //
// This file is part of ModelBlocks. Copyright 2009, ModelBlocks developers. //
// //
// ModelBlocks is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. //
// //
// ModelBlocks is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with ModelBlocks. If not, see <http://www.gnu.org/licenses/>. //
// //
///////////////////////////////////////////////////////////////////////////////
#define SHORT
#include<stdio.h>
#include"nl-iomacros.h"
#include"nl-list.h"
static const char LEFT1 = '(' ;
static const char RIGHT1 = ')' ;
static const char LEFT2 = '<' ;
static const char RIGHT2 = '>' ;
//static const char LEFT2 = '{' ;
//static const char RIGHT2 = '}' ;
static const char LEFT3 = '<' ;
static const char RIGHT3 = '>' ;
static const char LEFT4 = '[' ;
static const char RIGHT4 = ']' ;
class Int
{
public:
int i ;
} ;
int main ( void )
{
int c = getc(stdin) ;
int j = 0 ;
List<Int> liTabs ;
//Listed(Int)* pi ;
liTabs.push().i = 0 ;
// Read in everything else...
for ( ; c!=EOF && c!='\n' && c!=LEFT1 && c!=LEFT2 && c!=LEFT3 && c!=LEFT4 && /*c!=',' &&*/ c!=RIGHT1 && c!=RIGHT2 && c!=RIGHT3 && c!=RIGHT4; j++, c=getc(stdin) )
putc ( c, stdout ) ;
while ( c!=EOF )
{
// Newlines...
if ( c=='\n' )
{
putc(c,stdout); j++; c=getc(stdin);
j = 0 ;
}
// Open bracket...
else if ( c==LEFT1 || c==LEFT2 || c==LEFT3 || c==LEFT4 )
{
putc(c,stdout); j++; c=getc(stdin);
while ( c!=LEFT1 && c!=LEFT2 && c!=LEFT3 && c!=LEFT4 && c!=RIGHT1 && c!=RIGHT2 && c!=RIGHT3 && c!=RIGHT4 /*&& c!=','*/ && c!='\n' ) { putc(c,stdout); j++; c=getc(stdin); }
liTabs.push().i = j ;
}
// Comma...
else if ( c==',' )
{
#ifdef SHORT ////////////////////////////////
//
putc(c,stdout); j++; c=getc(stdin); //
//
#else ///////////////////////////////////////
putc(c,stdout); j++; c=getc(stdin);
putc ( '\n', stdout ) ;
j = 0 ;
for ( ; j < liTabs.getFirst()->i; j++ )
putc ( ' ', stdout ) ;
for ( ; c==' '; c=getc(stdin) ) ;
#endif //////////////////////////////////////
}
// Close bracket...
else if ( c==RIGHT1 || c==RIGHT2 || c==RIGHT3 || c==RIGHT4 )
{
#ifdef SHORT ////////////////////////////////
while ( c==RIGHT1 || c==RIGHT2 || c==RIGHT3 || c==RIGHT4 )
{ //
putc(c,stdout); j++; c=getc(stdin); //
liTabs.pop() ; //
while ( c==' ' ) c=getc(stdin); //
} //
if ( c==',' ) //
{ //
putc(c,stdout); j++; c=getc(stdin); //
} //
putc ( '\n', stdout ) ; //
//
j = 0 ; //
for ( ; j < liTabs.getFirst()->i; j++ ) //
putc ( ' ', stdout ) ; //
//
for ( ; c==' '; c=getc(stdin) ) ; //
if ( c=='\n' ) c=getc(stdin) ; //
//
#else ///////////////////////////////////////
putc(c,stdout); j++; c=getc(stdin);
liTabs.pop() ;
#endif //////////////////////////////////////
}
// Read in everything else...
for ( ; c!='\n' && c!=LEFT1 && c!=LEFT2 && c!=LEFT3 && c!=LEFT4 && /*c!=',' &&*/ c!=RIGHT1 && c!=RIGHT2 && c!=RIGHT3 && c!=RIGHT4 && c!=EOF; j++, c=getc(stdin) )
putc ( c, stdout ) ;
}
}
|
1e12dae57dd889842e44f63fe727ba30c74a0d3a | 901571e54db419ccd0aa4d7a3dbfcd8dd5b37207 | /BOJ/2000/2172.cpp | ff3ea5fa688efacfa39f62991d40118f13177749 | [] | no_license | fbdp1202/AlgorithmParty | 3b7ae486b4a27f49d2d40efd48ed9a45a98c77e8 | 9fe654aa49392cb261e1b53c995dbb33216c6a20 | refs/heads/master | 2021-08-03T22:52:30.182103 | 2021-07-22T06:15:45 | 2021-07-22T06:15:45 | 156,948,821 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,834 | cpp | 2172.cpp | // baekjoon 2172 yechan
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
const int MAX_N=20;
const int MAX_L=11;
const int MAX_S=MAX_N*MAX_N;
const int dir[8][2] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
int N, L;
int board[MAX_N][MAX_N];
int dp[MAX_L][MAX_S][MAX_S];
inline int encode(int x, int y) { return (x*N)+y; }
inline P decode(int code) { return P(code/N, code%N); }
inline bool inRange(int x, int y) { return !(x < 0 || x >= N || y < 0 || y >= N); }
inline bool inRange(P p) { return inRange(p.first, p.second); }
inline bool inRange(int code) { return inRange(decode(code)); }
inline int getPos(P p) { return board[p.first][p.second]; }
inline int isSame(int l, int r) { return getPos(decode(l))==getPos(decode(r));}
int getNextCode(int code, int d) {
P p = decode(code);
if (!inRange(p.first+dir[d][0], p.second+dir[d][1])) return -1;
return encode(p.first+dir[d][0], p.second+dir[d][1]);
}
int dfs(int num, int l, int r) {
if (!isSame(l, r)) return 0;
if (num == L/2) return 1;
int &ret = dp[num][l][r];
if (ret != -1) return ret;
ret = 0;
for (int i=0; i<8; i++) {
int ci = getNextCode(l,i);
if (ci == -1) continue;
for (int j=0; j<8; j++) {
int cj = getNextCode(r, j);
if (cj == -1) continue;
ret += dfs(num+1, ci, cj);
}
}
return ret;
}
int main() {
memset(dp, -1, sizeof(dp));
scanf("%d%d", &N, &L);
for (int i=0; i<N; i++)
for (int j=0; j<N; j++)
scanf("%d", &board[i][j]);
int ret = 0;
for (int i=0; i<N; i++)
for (int j=0; j<N; j++)
if (L % 2) {
ret += dfs(0, encode(i, j), encode(i, j));
} else {
for (int d=0; d<8; d++) {
int nx = i + dir[d][0];
int ny = j + dir[d][1];
if (!inRange(nx, ny)) continue;
ret += dfs(1, encode(i,j), encode(nx,ny));
}
}
printf("%d\n", ret);
return 0;
} |
939269c481a688596801d65a9d929a7496420d2c | 3dfab3e3badcc535b2113483b50d62e6cea4078f | /src/PoolDrep.cpp | c8be47db7a27a9a335e926acb0d41ede5b5051d3 | [] | no_license | stjordanis/simulationPopulationGenetics | aed266109ee5b5b733670f096fd5ee2e8be261df | 0585254f8f42e737178d67d86addcea4dd8f368a | refs/heads/master | 2020-05-27T18:41:30.982049 | 2017-04-06T03:14:39 | 2017-04-06T03:14:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,409 | cpp | PoolDrep.cpp | #include <random>
#include <string>
#include <cassert>
#include "PoolDrep.h"
/*!
* @file PoolDrep.cpp
* @author Yann Dubois et David CLeres
* @date 10 Novembre 2015
* @version 1.0
* @brief description pool
c
*/
using namespace std;
//CONSTRUCTEUR AVEC MUTATIONS ou par defaut sans mutation
PoolDrep::PoolDrep (vector<double> const& tabFreq,
unsigned int const& nIndividu,
double const& probaMalarya,
string const& nomPays)
: Pool (tabFreq, nIndividu)
, m_probaMalarya (probaMalarya)
, m_nomPays (nomPays)
{
m_ptrWorld = nullptr;
}
//METHODS
void PoolDrep::nextGenerationGeneral()
{
//ici on calcule les probabilités d'avoir un allèle normal et
//un allèle anémique et on les stockes dans le tableau => on change
//notre tableau.
//NOTE: tabFreq[0] = normal et tabFreq[1] = anémique
double p (m_tabFreq[0]);
double q (m_tabFreq[1]);
m_tabFreq[0] = (1 - m_probaMalarya) * (p * p) + p * q;
m_tabFreq[1] = 0.3 * (q * q) + p * q;
//Itérateur sur le tableaux (ATTENTION: begin() et end() ne sont pas
//les indice de début et fin du tableau
discrete_distribution<int> alleleGenerator (m_tabFreq.begin(), m_tabFreq.end());
random_device rd;
mt19937 rng = mt19937 (rd());
int allele (0);
vector<double> newTabFreq (m_nAllele);
if (m_nIndividu == 0)
{
throw 0;
}
for (size_t i (0); i < m_nIndividu * 2; ++i)
{
allele = alleleGenerator (rng);
newTabFreq[allele] += (1.0 / (m_nIndividu * 2));
}
m_tabFreq = newTabFreq;
assert (m_ptrWorld != nullptr);
vector<unsigned int> imigrant (m_ptrWorld->emigration (m_nomPays, m_caseMetaPool));
for (size_t j (0); j < m_tabFreq.size(); ++j)
{
m_tabFreq[j] += (imigrant[j] / (m_nIndividu*2));
}
}
vector<unsigned int> PoolDrep::emigration (unsigned int const& nMigrant)
{
discrete_distribution<int> alleleGenerator (m_tabFreq.begin(), m_tabFreq.end());
random_device rd;
mt19937 rng = mt19937 (rd());
int allele (0);
vector<unsigned int> newTabFreq (m_nAllele, 0);
if (m_nIndividu == 0)
{
throw 0;
}
for (size_t i (0); i < nMigrant * 2; ++i)
{
allele = alleleGenerator (rng);
m_tabFreq[allele] -= (1.0 / (m_nIndividu * 2));
newTabFreq[allele] += (1.0);
}
return newTabFreq;
}
void PoolDrep::setWorld (World* ptr)
{
m_ptrWorld = ptr;
}
void PoolDrep::setCaseMetapool (int const& caseMeta)
{
m_caseMetaPool = caseMeta;
}
PoolDrep::~PoolDrep()
{}
|
92cf47976908bf50eae1d9ec8bd00666a6718bf8 | 1502300055d98b1a675d4c41b08864b7987df535 | /algorithms/sort.cpp | 38b56a60da413bb5614b6bab101e4166cfc0454f | [] | no_license | manideep1821/STL-Algorithms | 97dda2cf0ddd1aeb3667843a45723e2745fb5cb7 | 00b691d34b63c6f9d4c9c718a9a2109592f9a4bb | refs/heads/main | 2023-04-20T12:41:02.774363 | 2021-05-28T11:36:48 | 2021-05-28T11:36:48 | 368,946,793 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 412 | cpp | sort.cpp | // if you are using ubuntu run this file with g++-10 -std='c++2a' filename
#include<bits/stdc++.h>
#include<execution>
using namespace std;
int main()
{
int n;
cin>>n;
std::vector<int>Vector(n);
for(auto & it:Vector)
cin>>it;
std::sort(std::execution::par,begin(Vector), end(Vector));
for(auto & it:Vector)
cout<<it<<" ";
cout<<endl;
return 0;
}
|
bda9a83579150534867dcd175e07773cc55fed79 | 519bb8b67b7ecb6d1a98c244ce5b534671ca7b28 | /ctl/room_mgt.h | 4bcdebcdad2c3576c9ba16c02a58593433cf1da8 | [] | no_license | xuepomh/roomserver | 89ec4b9476a48b73d02512de856179c5ba66c1b8 | 788731fe2fab27f09a0bfc058a7102541d415082 | refs/heads/master | 2021-01-18T09:04:05.551292 | 2014-08-21T15:41:04 | 2014-08-21T15:41:04 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,499 | h | room_mgt.h | /*
* room_mgt.h
*
* Created on: 2011-12-16
* Author: jimm
*/
#ifndef ROOM_MGT_H_
#define ROOM_MGT_H_
#include "common/common_object.h"
#include "common/common_pool.h"
#include "common/common_hashlist.h"
#include "def/server_namespace.h"
#include "def/dal_def.h"
#include "dal/dal_room.h"
#include "public_typedef.h"
FRAME_ROOMSERVER_NAMESPACE_BEGIN
//定义舞台对象池和索引类型
typedef CPool<CRoom, MaxChannelCountPerServer> RoomPool;
typedef CHashList<RoomIndex, MaxRoomCountPerServer, MaxRoomCountPerServer * 256> RoomList;
class CRoomMgt : public CObject
{
protected:
enum
{
enmAdditionalIndex_HashListIndex = 0,
};
public:
CRoomMgt();
virtual ~CRoomMgt();
public:
//初始化舞台管理器
virtual int32_t Initialize();
//恢复舞台管理器
virtual int32_t Resume();
//注销舞台管理器
virtual int32_t Uninitialize();
public:
//创建舞台对象
int32_t CreateRoom(const RoomID nRoomID, RoomPool::CIndex*& pIndex);
//创建舞台对象
int32_t CreateRoom(const RoomID nRoomID, CRoom*& pRoom, RoomIndex& roomIndex);
//获取舞台对象
int32_t GetRoom(const RoomID nRoomID, RoomPool::CIndex*& pIndex);
//获取舞台对象
int32_t GetRoom(const RoomID nRoomID, CRoom*& pRoom, RoomIndex& roomIndex);
//获取舞台对象
int32_t GetRoomByIndex(const RoomIndex roomIndex, RoomPool::CIndex*& pIndex);
//获取舞台对象
int32_t GetRoomByIndex(const RoomIndex roomIndex, CRoom*& pRoom);
//销毁舞台对象
int32_t DestroyRoomByIndex(const RoomIndex roomIndex);
//销毁舞台对象
int32_t DestroyRoom(RoomPool::CIndex* pIndex);
//销毁舞台对象
int32_t DestroyRoom(const RoomID nRoomID);
//销毁舞台对象
int32_t RealDestroyRoom(const RoomID nRoomID);
int32_t GetAllRoom(CRoom *arrRoomObject[], const int32_t arrSize, int32_t &nRoomCount);
//清空舞台管理器
void Clear();
//获取第一个房间
RoomPool::CIndex* GetFirstRoom();
public:
//获取对象池容量
uint32_t GetCapacity() const;
//获取对象池中对象数量
uint32_t GetRoomCount() const;
//对象池是否为空
bool IsEmpty() const;
//对象池是否已满
bool IsFull() const;
protected:
//根据roomID结算Key
RoomList::Key MakeKey(const RoomID nRoomID) const;
protected:
RoomPool m_roomPool; //舞台对象池
RoomList m_roomList;
};
FRAME_ROOMSERVER_NAMESPACE_END
#endif /* ROOM_MGT_H_ */
|
50074e3c8739d5a437c8589a8f11ca6cbfb7bb74 | 4c85488929c0b58afb513d6fddd804e3e2be3a2c | /source/microbit/microbitdisplay.cpp | d3735b40e63c0d48d791ac761d1461f9aa27fac4 | [
"MIT"
] | permissive | tdicola/sinobit-micropython | 3b532a6940c70f0c9aa1023ecdb88d6322f2cb79 | 07c007a62e6923ca898617d678f4bfee16dd5f4f | refs/heads/master | 2021-05-02T14:29:40.537142 | 2018-03-12T22:13:04 | 2018-03-12T22:13:04 | 120,720,229 | 9 | 4 | NOASSERTION | 2020-02-13T13:31:10 | 2018-02-08T06:23:30 | C | UTF-8 | C++ | false | false | 17,167 | cpp | microbitdisplay.cpp | /*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Damien P. George
*
* 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 <string.h>
#include "microbitobj.h"
#include "nrf_gpio.h"
extern "C" {
#include "py/runtime.h"
#include "py/gc.h"
#include "modmicrobit.h"
#include "microbitimage.h"
#include "microbitdisplay.h"
#include "microbitpin.h"
#include "lib/iters.h"
#include "lib/ticker.h"
#include "sinobitdisplay.h"
#define min(a,b) (((a)<(b))?(a):(b))
// New implementation of image buffer pixel drawing that maps the 5x5 pixels
// of the micro:bit to the 12x12 display of the sino:bit. This conversion is
// done by upsampling to 2x2 pixel blocks on the sino:bit display, framed by
// a 1 pixel wide unused frame around the pixels. Any brightness values are
// ignored since the sinobit display can't set individual pixel brightness.
static void mock_image_buffer_set_pixel(uint8_t x, uint8_t y, uint8_t c) {
// Calculate location within the 12x12 of the sinobit display.
// Note that we need to swap the axes to orient the display correctly
// (although A and B buttons are swapped physically on the board).
uint8_t sinobit_y = 1+2*x;
uint8_t sinobit_x = 1+2*y;
// Turn any non-zero brightness to an on pixel.
bool sinobit_c = c > 0 ? true : false;
// Set the four pixels of this 2x2 chunk.
framebuffer_set(sinobit_x, sinobit_y, sinobit_c);
framebuffer_set(sinobit_x+1, sinobit_y, sinobit_c);
framebuffer_set(sinobit_x, sinobit_y+1, sinobit_c);
framebuffer_set(sinobit_x+1, sinobit_y+1, sinobit_c);
// Immediately write to the display. This would normally happen in the
// tick callback a short while later, but writing now should work.
framebuffer_write();
}
static uint8_t mock_image_buffer_get_pixel(uint8_t x, uint8_t y) {
// Calculate location within the 12x12 of the sinobit display.
// Note that we need to swap the axes to orient the display correctly
// (although A and B buttons are swapped physically on the board).
uint8_t sinobit_y = 1+2*x;
uint8_t sinobit_x = 1+2*y;
// Check if all 4 pixels of this 2x2 are set. This isn't perfect since
// the user might use the sinobit module to manipulate individual pixels.
// Perhaps consider keeping track of display buffer state separately.
if (framebuffer_get(sinobit_x, sinobit_y) &&
framebuffer_get(sinobit_x+1, sinobit_y) &&
framebuffer_get(sinobit_x, sinobit_y+1) &&
framebuffer_get(sinobit_x+1, sinobit_y+1)) {
// Pixel is set, return max brightness. Note this will lose brightness
// information which might break certain code that depends on it!
// Again perhaps store this separately for compatibility.
return 9; // Max brightness (9)
}
else {
return 0; // Off
}
}
void microbit_display_show(microbit_display_obj_t *display, microbit_image_obj_t *image) {
mp_int_t w = min(image->width(), 5);
mp_int_t h = min(image->height(), 5);
mp_int_t x = 0;
mp_int_t brightnesses = 0;
for (; x < w; ++x) {
mp_int_t y = 0;
for (; y < h; ++y) {
uint8_t pix = image->getPixelValue(x, y);
mock_image_buffer_set_pixel(x, y, pix);
brightnesses |= (1 << pix);
}
for (; y < 5; ++y) {
mock_image_buffer_set_pixel(x, y, 0);
}
}
for (; x < 5; ++x) {
for (mp_int_t y = 0; y < 5; ++y) {
mock_image_buffer_set_pixel(x, y, 0);
}
}
}
#define DEFAULT_PRINT_SPEED 400
mp_obj_t microbit_display_show_func(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
// Cancel any animations.
MP_STATE_PORT(async_data)[0] = NULL;
MP_STATE_PORT(async_data)[1] = NULL;
static const mp_arg_t show_allowed_args[] = {
{ MP_QSTR_image, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_delay, MP_ARG_INT, {.u_int = DEFAULT_PRINT_SPEED} },
{ MP_QSTR_clear, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_wait, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
{ MP_QSTR_loop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
};
// Parse the args.
microbit_display_obj_t *self = (microbit_display_obj_t*)pos_args[0];
mp_arg_val_t args[MP_ARRAY_SIZE(show_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(show_allowed_args), show_allowed_args, args);
mp_obj_t image = args[0].u_obj;
mp_int_t delay = args[1].u_int;
bool clear = args[2].u_bool;
bool wait = args[3].u_bool;
bool loop = args[4].u_bool;
if (MP_OBJ_IS_STR(image)) {
// arg is a string object
mp_uint_t len;
const char *str = mp_obj_str_get_data(image, &len);
if (len == 0) {
// There are no chars; do nothing.
return mp_const_none;
} else if (len == 1) {
if (!clear && !loop) {
// A single char; convert to an image and print that.
image = microbit_image_for_char(str[0]);
goto single_image_immediate;
}
}
image = microbit_string_facade(image);
} else if (mp_obj_get_type(image) == µbit_image_type) {
if (!clear && !loop) {
goto single_image_immediate;
}
image = mp_obj_new_tuple(1, &image);
}
// iterable:
if (args[4].u_bool) { /*loop*/
image = microbit_repeat_iterator(image);
}
microbit_display_animate(self, image, delay, clear, wait);
return mp_const_none;
single_image_immediate:
microbit_display_show(self, (microbit_image_obj_t *)image);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(microbit_display_show_obj, 1, microbit_display_show_func);
static uint8_t async_mode;
static mp_obj_t async_iterator = NULL;
// Record if an error occurs in async animation. Unfortunately there is no way to report this.
static volatile bool wakeup_event = false;
static mp_uint_t async_delay = 1000;
static mp_uint_t async_tick = 0;
static bool async_clear = false;
bool microbit_display_active_animation(void) {
return async_mode == ASYNC_MODE_ANIMATION;
}
STATIC void async_stop(void) {
async_iterator = NULL;
async_mode = ASYNC_MODE_STOPPED;
async_tick = 0;
async_delay = 1000;
async_clear = false;
MP_STATE_PORT(async_data)[0] = NULL;
MP_STATE_PORT(async_data)[1] = NULL;
wakeup_event = true;
}
STATIC void wait_for_event() {
while (!wakeup_event) {
// allow CTRL-C to stop the animation
if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) {
async_stop();
return;
}
__WFI();
}
wakeup_event = false;
}
static void draw_object(mp_obj_t obj) {
microbit_display_obj_t *display = (microbit_display_obj_t*)MP_STATE_PORT(async_data)[0];
if (obj == MP_OBJ_STOP_ITERATION) {
if (async_clear) {
microbit_display_show(µbit_display_obj, BLANK_IMAGE);
async_clear = false;
} else {
async_stop();
}
} else if (mp_obj_get_type(obj) == µbit_image_type) {
microbit_display_show(display, (microbit_image_obj_t *)obj);
} else if (MP_OBJ_IS_STR(obj)) {
mp_uint_t len;
const char *str = mp_obj_str_get_data(obj, &len);
if (len == 1) {
microbit_display_show(display, microbit_image_for_char(str[0]));
} else {
async_stop();
}
} else {
MP_STATE_VM(mp_pending_exception) = mp_obj_new_exception_msg(&mp_type_TypeError, "not an image.");
async_stop();
}
}
static void microbit_display_update(void) {
async_tick += MILLISECONDS_PER_MACRO_TICK;
if (async_tick < async_delay) {
return;
}
async_tick = 0;
switch (async_mode) {
case ASYNC_MODE_ANIMATION:
{
if (MP_STATE_PORT(async_data)[0] == NULL || MP_STATE_PORT(async_data)[1] == NULL) {
async_stop();
break;
}
/* WARNING: We are executing in an interrupt handler.
* If an exception is raised here then we must hand it to the VM. */
mp_obj_t obj;
nlr_buf_t nlr;
gc_lock();
if (nlr_push(&nlr) == 0) {
obj = mp_iternext_allow_raise(async_iterator);
nlr_pop();
gc_unlock();
} else {
gc_unlock();
if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type),
MP_OBJ_FROM_PTR(&mp_type_StopIteration))) {
// An exception other than StopIteration, so set it for the VM to raise later
// If memory error, write an appropriate message.
if (mp_obj_get_type(nlr.ret_val) == &mp_type_MemoryError) {
mp_printf(&mp_plat_print, "Allocation in interrupt handler");
}
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(nlr.ret_val);
}
obj = MP_OBJ_STOP_ITERATION;
}
draw_object(obj);
break;
}
case ASYNC_MODE_CLEAR:
microbit_display_show(µbit_display_obj, BLANK_IMAGE);
async_stop();
break;
}
}
/* This is the top-level animation/display callback. It is not a registered
* callback. */
void microbit_display_tick(void) {
// The tick callback now only needs to drive animation updates.
microbit_display_update();
}
void microbit_display_animate(microbit_display_obj_t *self, mp_obj_t iterable, mp_int_t delay, bool clear, bool wait) {
// Reset the repeat state.
MP_STATE_PORT(async_data)[0] = NULL;
MP_STATE_PORT(async_data)[1] = NULL;
async_iterator = mp_getiter(iterable);
async_delay = delay;
async_clear = clear;
MP_STATE_PORT(async_data)[0] = self; // so it doesn't get GC'd
MP_STATE_PORT(async_data)[1] = async_iterator;
wakeup_event = false;
mp_obj_t obj = mp_iternext_allow_raise(async_iterator);
draw_object(obj);
async_tick = 0;
async_mode = ASYNC_MODE_ANIMATION;
if (wait) {
wait_for_event();
}
}
// Delay in ms in between moving display one column to the left.
#define DEFAULT_SCROLL_SPEED 150
void microbit_display_scroll(microbit_display_obj_t *self, const char* str, bool wait) {
mp_obj_t iterable = scrolling_string_image_iterable(str, strlen(str), NULL, false, false);
microbit_display_animate(self, iterable, DEFAULT_SCROLL_SPEED, false, wait);
}
mp_obj_t microbit_display_scroll_func(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static const mp_arg_t scroll_allowed_args[] = {
{ MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_delay, MP_ARG_INT, {.u_int = DEFAULT_SCROLL_SPEED} },
{ MP_QSTR_wait, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
{ MP_QSTR_monospace, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_loop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
};
// Parse the args.
microbit_display_obj_t *self = (microbit_display_obj_t*)pos_args[0];
mp_arg_val_t args[MP_ARRAY_SIZE(scroll_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(scroll_allowed_args), scroll_allowed_args, args);
mp_uint_t len;
const char* str = mp_obj_str_get_data(args[0].u_obj, &len);
mp_obj_t iterable = scrolling_string_image_iterable(str, len, args[0].u_obj, args[3].u_bool /*monospace?*/, args[4].u_bool /*loop*/);
microbit_display_animate(self, iterable, args[1].u_int /*delay*/, false/*clear*/, args[2].u_bool/*wait?*/);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(microbit_display_scroll_obj, 1, microbit_display_scroll_func);
mp_obj_t microbit_display_on_func(mp_obj_t obj) {
// No-op, the sinobit display has no concept of turning on/off.
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_on_obj, microbit_display_on_func);
mp_obj_t microbit_display_off_func(mp_obj_t obj) {
// No-op, the sinobit display has no concept of turning on/off.
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_off_obj, microbit_display_off_func);
mp_obj_t microbit_display_is_on_func(mp_obj_t obj) {
// No-op, display is always on.
return mp_const_true;
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_is_on_obj, microbit_display_is_on_func);
void microbit_display_clear(void) {
// Reset repeat state, cancel animation and clear screen.
wakeup_event = false;
async_mode = ASYNC_MODE_CLEAR;
async_tick = async_delay - MILLISECONDS_PER_MACRO_TICK;
wait_for_event();
}
mp_obj_t microbit_display_clear_func(void) {
microbit_display_clear();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_clear_obj, microbit_display_clear_func);
void microbit_display_set_pixel(microbit_display_obj_t *display, mp_int_t x, mp_int_t y, mp_int_t bright) {
if (x < 0 || y < 0 || x > 4 || y > 4) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "index out of bounds."));
}
if (bright < 0 || bright > MAX_BRIGHTNESS) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "brightness out of bounds."));
}
mock_image_buffer_set_pixel(x, y, bright);
}
STATIC mp_obj_t microbit_display_set_pixel_func(mp_uint_t n_args, const mp_obj_t *args) {
(void)n_args;
microbit_display_obj_t *self = (microbit_display_obj_t*)args[0];
microbit_display_set_pixel(self, mp_obj_get_int(args[1]), mp_obj_get_int(args[2]), mp_obj_get_int(args[3]));
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(microbit_display_set_pixel_obj, 4, 4, microbit_display_set_pixel_func);
mp_int_t microbit_display_get_pixel(microbit_display_obj_t *display, mp_int_t x, mp_int_t y) {
if (x < 0 || y < 0 || x > 4 || y > 4) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "index out of bounds."));
}
return mock_image_buffer_get_pixel(x,y);
}
STATIC mp_obj_t microbit_display_get_pixel_func(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) {
microbit_display_obj_t *self = (microbit_display_obj_t*)self_in;
return MP_OBJ_NEW_SMALL_INT(microbit_display_get_pixel(self, mp_obj_get_int(x_in), mp_obj_get_int(y_in)));
}
MP_DEFINE_CONST_FUN_OBJ_3(microbit_display_get_pixel_obj, microbit_display_get_pixel_func);
STATIC const mp_map_elem_t microbit_display_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_get_pixel), (mp_obj_t)µbit_display_get_pixel_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_pixel), (mp_obj_t)µbit_display_set_pixel_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_show), (mp_obj_t)µbit_display_show_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_scroll), (mp_obj_t)µbit_display_scroll_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_clear), (mp_obj_t)µbit_display_clear_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_on), (mp_obj_t)µbit_display_on_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_off), (mp_obj_t)µbit_display_off_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_is_on), (mp_obj_t)µbit_display_is_on_obj },
};
STATIC MP_DEFINE_CONST_DICT(microbit_display_locals_dict, microbit_display_locals_dict_table);
STATIC const mp_obj_type_t microbit_display_type = {
{ &mp_type_type },
.name = MP_QSTR_MicroBitDisplay,
.print = NULL,
.make_new = NULL,
.call = NULL,
.unary_op = NULL,
.binary_op = NULL,
.attr = NULL,
.subscr = NULL,
.getiter = NULL,
.iternext = NULL,
.buffer_p = {NULL},
.stream_p = NULL,
.bases_tuple = NULL,
.locals_dict = (mp_obj_dict_t*)µbit_display_locals_dict,
};
microbit_display_obj_t microbit_display_obj = {
{µbit_display_type},
// For some reason the compass depends on display active state.
// Need to further investigate this dependency.
.active = 1,
};
}
|
287ab2e9eb7c571c044671fa5e8b15f1dca551ca | ef3cf7426e0c1602b8e9104b3ef188412e32ffe0 | /C++/Expression.cpp | 33f76b2a69565f896e9f34bdbb335b969babfd64 | [] | no_license | talhaibnmahmud/Codeforces | 5c56d6a6573d6d62b207686b7407145c4935efa7 | e9e1afd19cf3488790cbb66e7192efa24371e9d1 | refs/heads/main | 2023-08-22T04:40:13.483370 | 2021-10-15T10:13:51 | 2021-10-15T10:13:51 | 394,391,678 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 689 | cpp | Expression.cpp | #include <iostream>
using namespace std;
int main()
{
int a, b, c;
cin >> a >> b >> c;
int e1 = a + (b * c);
int e2 = a * (b + c);
int e3 = (a * b * c);
int e4 = (a + b) * c;
int e5 = (a * b) + c;
int e6 = (a + b + c);
if(e1 >= e2 && e1 >= e3 && e1 >= e4 && e1 >= e5 && e1 >= e6)
cout << e1;
else if(e2 >= e1 && e2 >= e3 && e2 >= e4 && e2 >= e5 && e2 >= e6)
cout << e2;
else if(e3 >= e1 && e3 >= e2 && e3 >= e4 && e3 >= e5 && e3 >= e6)
cout << e3;
else if(e4 >= e1 && e4 >= e2 && e4 >= e3 && e4 >= e5 && e4 >= e6)
cout << e4;
else if(e5 >= e1 && e5 >= e2 && e5 >= e3 && e5 >= e4 && e5 >= e6)
cout << e5;
else
cout << e6;
return 0;
}
|
88d11b734444ad8769b006fb811e353718725a4b | 50cc654b7b289d888511060af8364ac8a4a87e24 | /src/storage/storage-main.cpp | e9929ecde18b232a59c5268cb36136d061fa8c02 | [
"Apache-2.0"
] | permissive | EvilMcJerkface/centiman | b3febc32607ba3b8eaf81bc8d0c8de0fba06db19 | 213eab0bd391822cbc9a01644979f8409440c376 | refs/heads/master | 2021-01-17T17:21:49.160580 | 2015-10-21T22:31:17 | 2015-10-21T22:31:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 857 | cpp | storage-main.cpp | /* storage/storage-main.cpp */
#include <storage/storage.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <util/code-handler.h>
#include <util/const.h>
#include <util/logger.h>
#include "util/config.h"
int main(int argc, char ** argv)
{
/*
* id
* config
* port
*/
Config config(argv[2]);
config.load();
Storage * storage = new Storage(argv[3], atoi(argv[1]), NULL, &config);
Logger::out(0, "StorageMain[%s]: Run!\n", argv[3]);
storage->run();
int sec = 1;
for (int i = 0; i < Const::SERVER_RUNTIME; i += sec) {
sleep(sec);
storage->publishCounter();
}
Logger::out(1, "StorageMain[%s]: Shut down!\n", argv[3]);
storage->publish();
storage->cancel();
delete storage;
Logger::out(0, "StorageMain[%s]: Exit!\n", argv[3]);
return 0;
}
|
1810bc05eb5a973db080316aef8aa0e83133ac67 | 8adafe96914bf039cb0455f3f84c04d5e782bd60 | /practise/src/leetcode/perfect-squares.h | a8180a8ca3adbea5b9d0b25bb11098ec2884f799 | [] | no_license | sryanyuan/cpp11_practise | 1e7d78341349b91773fa8d667bd9ac83e51ea5d0 | 0ead6d5d2f16bd344fee92668fd5b364439a86ac | refs/heads/master | 2021-06-25T13:51:29.957869 | 2019-04-10T04:08:47 | 2019-04-10T04:08:47 | 133,794,224 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 951 | h | perfect-squares.h | #ifndef _INC_PERFECT_SQUARES_
#define _INC_PERFECT_SQUARES_
#include "_common_all.h"
#include "_common_list.h"
#include "_common_binary_tree.h"
/* Generated by leetgen (github.com/sryanyuan/leetgen)
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.
Example 1:
Input: n = 12
Output: 3
Explanation: 12 = 4 + 4 + 4.
Example 2:
Input: n = 13
Output: 2
Explanation: 13 = 4 + 9.
*/
class PerfectSquares {
public:
static void test() {
}
static int numSquares(int n) {
while (n % 4 == 0) {
n /= 4;
}
if (n % 8 == 7) {
return 4;
}
for (int l = 0; l * l <= n; l++) {
int r = sqrt(n - l * l);
if (l * l + r * r == n) {
if (l == 0 || r == 0) {
return 1;
}
return 2;
}
}
return 3;
}
};
#endif
|
7e924dc6f70433da857f20845f0e6735836288db | bdcb73ed6acb3f65f498a413eadbfad8992b7b68 | /source/projectme/editor/temp/ModuleWidgetFactory.cpp | 2d2283b9b9f1539db5ed16eee89f05f115216adf | [] | no_license | shermnonic/wmute | 791f4e364e043084b115cdfed3ae18636a991f7f | e543f8460225b2a0329d223e8c0eb1203ed71345 | refs/heads/master | 2022-12-22T13:07:17.592731 | 2020-09-25T19:30:33 | 2020-09-25T19:30:33 | 298,661,701 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 783 | cpp | ModuleWidgetFactory.cpp | #include "ModuleWidgetFactory.h"
using namespace std;
ModuleWidget* ModuleWidgetFactory::createInstance( string moduleType )
{
CallbackMap::const_iterator it = m_callbacks.find( moduleType );
if( it == m_callbacks.end() )
{
// not found
return NULL;
}
// invoke creation function
return (it->second)();
}
bool ModuleWidgetFactory::registerClass( string moduleType, CreateInstanceCallback cb )
{
return m_callbacks.insert( CallbackMap::value_type( moduleType, cb ) ).second;
}
vector<string> ModuleWidgetFactory::getAvailableModuleWidgets() const
{
static vector<string> list;
list.clear();
CallbackMap::const_iterator it = m_callbacks.begin();
for( ; it != m_callbacks.end(); ++it )
list.push_back( it->first );
return list;
}
|
d6d9e53291ae122ac370817cd20516b5a34cbb60 | c475cd8531a94ffae69cc92371d41531dbbddb6c | /Projects/bullet3-2.89/examples/OpenGLWindow/SimpleOpenGL2Renderer.cpp | 7e1a54e831fc7dca3db26b9323c1aefbb267d972 | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown",
"Zlib"
] | permissive | WolfireGames/overgrowth | 72d3dd29cbd7254337265c29f8de3e5c32400114 | 594a2a4f9da0855304ee8cd5335d042f8e954ce1 | refs/heads/main | 2023-08-15T19:36:56.156578 | 2023-05-17T08:17:53 | 2023-05-17T08:20:36 | 467,448,492 | 2,264 | 245 | Apache-2.0 | 2023-05-09T07:29:58 | 2022-03-08T09:38:54 | C++ | UTF-8 | C++ | false | false | 19,397 | cpp | SimpleOpenGL2Renderer.cpp |
#include "SimpleOpenGL2Renderer.h"
#include "OpenGL2Include.h"
#include "Bullet3Common/b3Vector3.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "GLInstanceGraphicsShape.h"
#include "Bullet3Common/b3Quaternion.h"
#include "Bullet3Common/b3Transform.h"
#include "Bullet3Common/b3ResizablePool.h"
B3_ATTRIBUTE_ALIGNED16(struct)
SimpleGL2Shape
{
B3_DECLARE_ALIGNED_ALLOCATOR();
int m_textureIndex;
int m_primitiveType;
b3AlignedObjectArray<int> m_indices;
b3AlignedObjectArray<GLInstanceVertex> m_vertices;
b3Vector3 m_scaling;
};
B3_ATTRIBUTE_ALIGNED16(struct)
SimpleGL2Instance
{
B3_DECLARE_ALIGNED_ALLOCATOR();
int m_shapeIndex;
b3Vector3 m_position;
b3Quaternion orn;
b3Vector4 m_rgbColor;
b3Vector3 m_scaling;
void clear()
{
}
};
struct InternalTextureHandle2
{
GLuint m_glTexture;
int m_width;
int m_height;
};
typedef b3PoolBodyHandle<SimpleGL2Instance> SimpleGL2InstanceHandle;
struct SimpleOpenGL2RendererInternalData
{
int m_width;
int m_height;
SimpleCamera m_camera;
b3AlignedObjectArray<SimpleGL2Shape*> m_shapes;
//b3AlignedObjectArray<SimpleGL2Instance> m_graphicsInstances1;
b3ResizablePool<SimpleGL2InstanceHandle> m_graphicsInstancesPool;
b3AlignedObjectArray<InternalTextureHandle2> m_textureHandles;
};
SimpleOpenGL2Renderer::SimpleOpenGL2Renderer(int width, int height)
{
m_data = new SimpleOpenGL2RendererInternalData;
m_data->m_width = width;
m_data->m_height = height;
}
SimpleOpenGL2Renderer::~SimpleOpenGL2Renderer()
{
delete m_data;
}
void SimpleOpenGL2Renderer::init()
{
}
const CommonCameraInterface* SimpleOpenGL2Renderer::getActiveCamera() const
{
return &m_data->m_camera;
}
CommonCameraInterface* SimpleOpenGL2Renderer::getActiveCamera()
{
return &m_data->m_camera;
}
void SimpleOpenGL2Renderer::setActiveCamera(CommonCameraInterface* cam)
{
b3Assert(0); //not supported yet
}
void SimpleOpenGL2Renderer::setLightPosition(const float lightPos[3])
{
}
void SimpleOpenGL2Renderer::setLightPosition(const double lightPos[3])
{
}
void SimpleOpenGL2Renderer::updateCamera(int upAxis)
{
float projection[16];
float view[16];
getActiveCamera()->setAspectRatio((float)m_data->m_width / (float)m_data->m_height);
getActiveCamera()->setCameraUpAxis(upAxis);
m_data->m_camera.update(); //??
getActiveCamera()->getCameraProjectionMatrix(projection);
getActiveCamera()->getCameraViewMatrix(view);
GLfloat projMat[16];
GLfloat viewMat[16];
for (int i = 0; i < 16; i++)
{
viewMat[i] = view[i];
projMat[i] = projection[i];
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMultMatrixf(projMat);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixf(viewMat);
}
void SimpleOpenGL2Renderer::removeAllInstances()
{
for (int i = 0; i < m_data->m_shapes.size(); i++)
{
delete m_data->m_shapes[i];
}
m_data->m_shapes.clear();
m_data->m_graphicsInstancesPool.exitHandles();
m_data->m_graphicsInstancesPool.initHandles();
//also destroy textures?
m_data->m_textureHandles.clear();
}
void SimpleOpenGL2Renderer::removeGraphicsInstance(int instanceUid)
{
m_data->m_graphicsInstancesPool.freeHandle(instanceUid);
}
bool SimpleOpenGL2Renderer::readSingleInstanceTransformToCPU(float* position, float* orientation, int srcIndex)
{
return false;
}
void SimpleOpenGL2Renderer::writeSingleInstanceColorToCPU(const float* color, int srcIndex)
{
}
void SimpleOpenGL2Renderer::writeSingleInstanceColorToCPU(const double* color, int srcIndex)
{
}
void SimpleOpenGL2Renderer::writeSingleInstanceScaleToCPU(const float* scale, int srcIndex)
{
}
void SimpleOpenGL2Renderer::writeSingleInstanceScaleToCPU(const double* scale, int srcIndex)
{
}
int SimpleOpenGL2Renderer::getTotalNumInstances() const
{
return m_data->m_graphicsInstancesPool.getNumHandles();
}
void SimpleOpenGL2Renderer::getCameraViewMatrix(float viewMat[16]) const
{
b3Assert(0);
}
void SimpleOpenGL2Renderer::getCameraProjectionMatrix(float projMat[16]) const
{
b3Assert(0);
}
void SimpleOpenGL2Renderer::drawOpenGL(int instanceIndex)
{
const SimpleGL2Instance* instPtr = m_data->m_graphicsInstancesPool.getHandle(instanceIndex);
if (0 == instPtr)
{
b3Assert(0);
return;
}
const SimpleGL2Instance& inst = *instPtr;
const SimpleGL2Shape* shape = m_data->m_shapes[inst.m_shapeIndex];
if (inst.m_rgbColor[3] == 0)
{
return;
}
glPushMatrix();
b3Transform tr;
tr.setOrigin(b3MakeVector3(inst.m_position[0], inst.m_position[1], inst.m_position[2]));
tr.setRotation(b3Quaternion(inst.orn[0], inst.orn[1], inst.orn[2], inst.orn[3]));
b3Scalar m[16];
tr.getOpenGLMatrix(m);
#ifdef B3_USE_DOUBLE_PRECISION
glMultMatrixd(m);
#else
glMultMatrixf(m);
#endif
#if 0
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(0.025f,0.025f,0.025f);
glMatrixMode(GL_MODELVIEW);
static const GLfloat planex[]={1,0,0,0};
// static const GLfloat planey[]={0,1,0,0};
static const GLfloat planez[]={0,0,1,0};
glTexGenfv(GL_S,GL_OBJECT_PLANE,planex);
glTexGenfv(GL_T,GL_OBJECT_PLANE,planez);
glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
m_textureinitialized=true;
#endif
//drawCoordSystem();
//glPushMatrix();
// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
// glMatrixMode(GL_TEXTURE);
// glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glEnable(GL_COLOR_MATERIAL);
if (shape->m_textureIndex >= 0)
{
glEnable(GL_TEXTURE_2D);
activateTexture(shape->m_textureIndex);
}
else
{
glDisable(GL_TEXTURE_2D);
}
glColor3f(inst.m_rgbColor[0], inst.m_rgbColor[1], inst.m_rgbColor[2]);
glScalef(inst.m_scaling[0], inst.m_scaling[1], inst.m_scaling[2]);
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
for (int i = 0; i < shape->m_indices.size(); i += 3)
{
for (int v = 0; v < 3; v++)
{
const GLInstanceVertex& vtx0 = shape->m_vertices[shape->m_indices[i + v]];
glNormal3f(vtx0.normal[0], vtx0.normal[1], vtx0.normal[2]);
glTexCoord2f(vtx0.uv[0], vtx0.uv[1]);
glVertex3f(vtx0.xyzw[0], vtx0.xyzw[1], vtx0.xyzw[2]);
}
}
glEnd();
glPopMatrix();
}
void SimpleOpenGL2Renderer::drawSceneInternal(int pass, int cameraUpAxis)
{
b3AlignedObjectArray<int> usedHandles;
m_data->m_graphicsInstancesPool.getUsedHandles(usedHandles);
for (int i = 0; i < usedHandles.size(); i++)
{
drawOpenGL(usedHandles[i]);
}
#if 0
b3Scalar m[16];
b3Matrix3x3 rot;rot.setIdentity();
const int numObjects=dynamicsWorld->getNumCollisionObjects();
btVector3 wireColor(1,0,0);
//glDisable(GL_CULL_FACE);
for(int i=0;i<numObjects;i++)
{
const btCollisionObject* colObj=dynamicsWorld->getCollisionObjectArray()[i];
const btRigidBody* body=btRigidBody::upcast(colObj);
if(body&&body->getMotionState())
{
btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
rot=myMotionState->m_graphicsWorldTrans.getBasis();
}
else
{
colObj->getWorldTransform().getOpenGLMatrix(m);
rot=colObj->getWorldTransform().getBasis();
}
btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation
if(i&1) wireColor=btVector3(0.f,0.0f,1.f);
///color differently for active, sleeping, wantsdeactivation states
if (colObj->getActivationState() == 1) //active
{
if (i & 1)
{
wireColor += btVector3 (1.f,0.f,0.f);
}
else
{
wireColor += btVector3 (.5f,0.f,0.f);
}
}
if(colObj->getActivationState()==2) //ISLAND_SLEEPING
{
if(i&1)
{
wireColor += btVector3 (0.f,1.f, 0.f);
}
else
{
wireColor += btVector3 (0.f,0.5f,0.f);
}
}
btVector3 aabbMin(0,0,0),aabbMax(0,0,0);
//m_dynamicsWorld->getBroadphase()->getBroadphaseAabb(aabbMin,aabbMax);
aabbMin-=btVector3(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
aabbMax+=btVector3(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
// printf("aabbMin=(%f,%f,%f)\n",aabbMin.getX(),aabbMin.getY(),aabbMin.getZ());
// printf("aabbMax=(%f,%f,%f)\n",aabbMax.getX(),aabbMax.getY(),aabbMax.getZ());
// m_dynamicsWorld->getDebugDrawer()->drawAabb(aabbMin,aabbMax,btVector3(1,1,1));
//switch(pass)
//if (!(getDebugMode()& btIDebugDraw::DBG_DrawWireframe))
int debugMode = 0;//getDebugMode()
//btVector3 m_sundirection(-1,-1,-1);
btVector3 m_sundirection(btVector3(1,-2,1)*1000);
if (cameraUpAxis==2)
{
m_sundirection = btVector3(1,1,-2)*1000;
}
switch(pass)
{
case 0: drawOpenGL(m,colObj->getCollisionShape(),wireColor,debugMode,aabbMin,aabbMax);break;
case 1: drawShadow(m,m_sundirection*rot,colObj->getCollisionShape(),aabbMin,aabbMax);break;
case 2: drawOpenGL(m,colObj->getCollisionShape(),wireColor*b3Scalar(0.3),0,aabbMin,aabbMax);break;
}
}
#endif
}
void SimpleOpenGL2Renderer::renderScene()
{
GLfloat light_ambient[] = {b3Scalar(0.2), b3Scalar(0.2), b3Scalar(0.2), b3Scalar(1.0)};
GLfloat light_diffuse[] = {b3Scalar(1.0), b3Scalar(1.0), b3Scalar(1.0), b3Scalar(1.0)};
GLfloat light_specular[] = {b3Scalar(1.0), b3Scalar(1.0), b3Scalar(1.0), b3Scalar(1.0)};
/* light_position is NOT default value */
GLfloat light_position0[] = {b3Scalar(1.0), b3Scalar(10.0), b3Scalar(1.0), b3Scalar(0.0)};
GLfloat light_position1[] = {b3Scalar(-1.0), b3Scalar(-10.0), b3Scalar(-1.0), b3Scalar(0.0)};
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
drawSceneInternal(0, 0);
}
int SimpleOpenGL2Renderer::registerTexture(const unsigned char* texels, int width, int height, bool flipTexelsY)
{
b3Assert(glGetError() == GL_NO_ERROR);
glActiveTexture(GL_TEXTURE0);
int textureIndex = m_data->m_textureHandles.size();
// const GLubyte* image= (const GLubyte*)texels;
GLuint textureHandle;
glGenTextures(1, (GLuint*)&textureHandle);
glBindTexture(GL_TEXTURE_2D, textureHandle);
b3Assert(glGetError() == GL_NO_ERROR);
InternalTextureHandle2 h;
h.m_glTexture = textureHandle;
h.m_width = width;
h.m_height = height;
m_data->m_textureHandles.push_back(h);
updateTexture(textureIndex, texels, flipTexelsY);
return textureIndex;
}
void SimpleOpenGL2Renderer::updateTexture(int textureIndex, const unsigned char* texels, bool flipTexelsY)
{
if (textureIndex >= 0)
{
glActiveTexture(GL_TEXTURE0);
b3Assert(glGetError() == GL_NO_ERROR);
InternalTextureHandle2& h = m_data->m_textureHandles[textureIndex];
glBindTexture(GL_TEXTURE_2D, h.m_glTexture);
b3Assert(glGetError() == GL_NO_ERROR);
if (flipTexelsY)
{
//textures need to be flipped for OpenGL...
b3AlignedObjectArray<unsigned char> flippedTexels;
flippedTexels.resize(h.m_width * h.m_height * 3);
for (int i = 0; i < h.m_width; i++)
{
for (int j = 0; j < h.m_height; j++)
{
flippedTexels[(i + j * h.m_width) * 3] = texels[(i + (h.m_height - 1 - j) * h.m_width) * 3];
flippedTexels[(i + j * h.m_width) * 3 + 1] = texels[(i + (h.m_height - 1 - j) * h.m_width) * 3 + 1];
flippedTexels[(i + j * h.m_width) * 3 + 2] = texels[(i + (h.m_height - 1 - j) * h.m_width) * 3 + 2];
}
}
// const GLubyte* image= (const GLubyte*)texels;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, h.m_width, h.m_height, 0, GL_RGB, GL_UNSIGNED_BYTE, &flippedTexels[0]);
}
else
{
// const GLubyte* image= (const GLubyte*)texels;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, h.m_width, h.m_height, 0, GL_RGB, GL_UNSIGNED_BYTE, &texels[0]);
}
b3Assert(glGetError() == GL_NO_ERROR);
//glGenerateMipmap(GL_TEXTURE_2D);
b3Assert(glGetError() == GL_NO_ERROR);
}
}
void SimpleOpenGL2Renderer::removeTexture(int textureIndex)
{
if ((textureIndex >= 0) && (textureIndex < m_data->m_textureHandles.size()))
{
glDeleteTextures(1, &m_data->m_textureHandles[textureIndex].m_glTexture);
}
}
void SimpleOpenGL2Renderer::activateTexture(int textureIndex)
{
glActiveTexture(GL_TEXTURE0);
if (textureIndex >= 0)
{
glBindTexture(GL_TEXTURE_2D, m_data->m_textureHandles[textureIndex].m_glTexture);
}
else
{
glBindTexture(GL_TEXTURE_2D, 0);
}
}
int SimpleOpenGL2Renderer::registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* scaling)
{
int newHandle = m_data->m_graphicsInstancesPool.allocHandle();
// int sz = m_data->m_graphicsInstances.size();
SimpleGL2Instance& instance = *m_data->m_graphicsInstancesPool.getHandle(newHandle);
instance.m_shapeIndex = shapeIndex;
instance.m_position[0] = position[0];
instance.m_position[1] = position[1];
instance.m_position[2] = position[2];
instance.orn[0] = quaternion[0];
instance.orn[1] = quaternion[1];
instance.orn[2] = quaternion[2];
instance.orn[3] = quaternion[3];
instance.m_rgbColor[0] = color[0];
instance.m_rgbColor[1] = color[1];
instance.m_rgbColor[2] = color[2];
instance.m_rgbColor[3] = color[3];
instance.m_scaling[0] = scaling[0];
instance.m_scaling[1] = scaling[1];
instance.m_scaling[2] = scaling[2];
return newHandle;
}
int SimpleOpenGL2Renderer::registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)
{
int newHandle = m_data->m_graphicsInstancesPool.allocHandle();
SimpleGL2Instance& instance = *m_data->m_graphicsInstancesPool.getHandle(newHandle);
instance.m_shapeIndex = shapeIndex;
instance.m_position[0] = position[0];
instance.m_position[1] = position[1];
instance.m_position[2] = position[2];
instance.orn[0] = quaternion[0];
instance.orn[1] = quaternion[1];
instance.orn[2] = quaternion[2];
instance.orn[3] = quaternion[3];
instance.m_rgbColor[0] = color[0];
instance.m_rgbColor[1] = color[1];
instance.m_rgbColor[2] = color[2];
instance.m_rgbColor[3] = color[3];
instance.m_scaling[0] = scaling[0];
instance.m_scaling[1] = scaling[1];
instance.m_scaling[2] = scaling[2];
return newHandle;
}
void SimpleOpenGL2Renderer::drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float pointDrawSize)
{
int pointStrideInFloats = pointStrideInBytes / 4;
glLineWidth(pointDrawSize);
for (int i = 0; i < numIndices; i += 2)
{
int index0 = indices[i];
int index1 = indices[i + 1];
b3Vector3 fromColor = b3MakeVector3(color[0], color[1], color[2]);
b3Vector3 toColor = b3MakeVector3(color[0], color[1], color[2]);
b3Vector3 from = b3MakeVector3(positions[index0 * pointStrideInFloats], positions[index0 * pointStrideInFloats + 1], positions[index0 * pointStrideInFloats + 2]);
b3Vector3 to = b3MakeVector3(positions[index1 * pointStrideInFloats], positions[index1 * pointStrideInFloats + 1], positions[index1 * pointStrideInFloats + 2]);
glBegin(GL_LINES);
glColor3f(fromColor.getX(), fromColor.getY(), fromColor.getZ());
glVertex3d(from.getX(), from.getY(), from.getZ());
glColor3f(toColor.getX(), toColor.getY(), toColor.getZ());
glVertex3d(to.getX(), to.getY(), to.getZ());
glEnd();
}
}
void SimpleOpenGL2Renderer::drawLine(const float from[4], const float to[4], const float color[4], float lineWidth)
{
glLineWidth(lineWidth);
glBegin(GL_LINES);
glColor3f(color[0], color[1], color[2]);
glVertex3d(from[0], from[1], from[2]);
glVertex3d(to[0], to[1], to[2]);
glEnd();
}
int SimpleOpenGL2Renderer::registerShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureIndex)
{
SimpleGL2Shape* shape = new SimpleGL2Shape();
shape->m_textureIndex = textureIndex;
shape->m_indices.resize(numIndices);
for (int i = 0; i < numIndices; i++)
{
shape->m_indices[i] = indices[i];
}
shape->m_vertices.resize(numvertices);
for (int v = 0; v < numvertices; v++)
{
GLInstanceVertex& vtx = shape->m_vertices[v];
vtx.xyzw[0] = vertices[9 * v + 0];
vtx.xyzw[1] = vertices[9 * v + 1];
vtx.xyzw[2] = vertices[9 * v + 2];
vtx.xyzw[3] = vertices[9 * v + 3];
vtx.normal[0] = vertices[9 * v + 4];
vtx.normal[1] = vertices[9 * v + 5];
vtx.normal[2] = vertices[9 * v + 6];
vtx.uv[0] = vertices[9 * v + 7];
vtx.uv[1] = vertices[9 * v + 8];
}
int sz = m_data->m_shapes.size();
m_data->m_shapes.push_back(shape);
return sz;
}
void SimpleOpenGL2Renderer::writeSingleInstanceTransformToCPU(const float* position, const float* orientation, int srcIndex)
{
SimpleGL2Instance& graphicsInstance = *m_data->m_graphicsInstancesPool.getHandle(srcIndex);
graphicsInstance.m_position[0] = position[0];
graphicsInstance.m_position[1] = position[1];
graphicsInstance.m_position[2] = position[2];
graphicsInstance.orn[0] = orientation[0];
graphicsInstance.orn[1] = orientation[1];
graphicsInstance.orn[2] = orientation[2];
graphicsInstance.orn[3] = orientation[3];
}
void SimpleOpenGL2Renderer::writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)
{
SimpleGL2Instance& graphicsInstance = *m_data->m_graphicsInstancesPool.getHandle(srcIndex);
graphicsInstance.m_position[0] = position[0];
graphicsInstance.m_position[1] = position[1];
graphicsInstance.m_position[2] = position[2];
graphicsInstance.orn[0] = orientation[0];
graphicsInstance.orn[1] = orientation[1];
graphicsInstance.orn[2] = orientation[2];
graphicsInstance.orn[3] = orientation[3];
}
void SimpleOpenGL2Renderer::writeTransforms()
{
}
void SimpleOpenGL2Renderer::resize(int width, int height)
{
m_data->m_width = width;
m_data->m_height = height;
}
int SimpleOpenGL2Renderer::getScreenWidth()
{
return m_data->m_width;
}
int SimpleOpenGL2Renderer::getScreenHeight()
{
return m_data->m_height;
}
void SimpleOpenGL2Renderer::drawLine(const double from[4], const double to[4], const double color[4], double lineWidth)
{
glLineWidth(lineWidth);
glBegin(GL_LINES);
glColor3f(color[0], color[1], color[2]);
glVertex3d(from[0], from[1], from[2]);
glVertex3d(to[0], to[1], to[2]);
glEnd();
}
void SimpleOpenGL2Renderer::drawPoint(const float* position, const float color[4], float pointDrawSize)
{
}
void SimpleOpenGL2Renderer::drawPoint(const double* position, const double color[4], double pointDrawSize)
{
}
void SimpleOpenGL2Renderer::updateShape(int shapeIndex, const float* vertices)
{
SimpleGL2Shape* shape = m_data->m_shapes[shapeIndex];
int numvertices = shape->m_vertices.size();
for (int i = 0; i < numvertices; i++)
{
shape->m_vertices[i].xyzw[0] = vertices[9 * i + 0];
shape->m_vertices[i].xyzw[1] = vertices[9 * i + 1];
shape->m_vertices[i].xyzw[2] = vertices[9 * i + 2];
shape->m_vertices[i].xyzw[3] = vertices[9 * i + 3];
shape->m_vertices[i].normal[0] = vertices[9 * i + 4];
shape->m_vertices[i].normal[1] = vertices[9 * i + 5];
shape->m_vertices[i].normal[2] = vertices[9 * i + 6];
shape->m_vertices[i].uv[0] = vertices[9 * i + 7];
shape->m_vertices[i].uv[1] = vertices[9 * i + 8];
}
}
void SimpleOpenGL2Renderer::clearZBuffer()
{
glClear(GL_DEPTH_BUFFER_BIT);
} |
06af72bf45163df4367524c0ebb866b5380f1489 | 27721e886795df3e467756b8e0480f7afd6e66c4 | /xtt/lib/xtt/qt/xtt_evala_qt.h | e4bbcfe652fe1a2946c72a4b3a973eb845f44193 | [] | no_license | brunad-coder/proview | 88722029f3614d0febc4a8e9e6dea4859cc87363 | 4d75b942c649b1da8797323fa40f7f20cff634f8 | refs/heads/master | 2020-07-15T14:52:59.275163 | 2020-03-02T23:40:11 | 2020-03-02T23:40:11 | 205,586,528 | 0 | 0 | null | 2019-08-31T19:15:34 | 2019-08-31T19:15:34 | null | UTF-8 | C++ | false | false | 3,260 | h | xtt_evala_qt.h | /*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2018 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef xtt_evala_qt_h
#define xtt_evala_qt_h
/* xtt_evala_qt.h -- Alarm window in xtt */
#include "xtt_evala.h"
#include <QVBoxLayout>
#include <QWidget>
class EvAlaQtWidget;
class EvAlaQt : public EvAla {
public:
EvAlaQt(void* ev_parent_ctx, QWidget* ev_parent_wid, char* ala_name,
pwr_tObjid ev_user, int ev_eventname_seg, int ev_width, int ev_height,
int ev_x, int ev_y, pwr_tObjid ev_view, unsigned int ev_options,
void* widget, pwr_tStatus* status);
~EvAlaQt();
EvAlaQtWidget* toplevel;
QWidget* parent_wid_ala;
QWidget* ala_widget;
QVBoxLayout* ala_vbox;
pwr_tObjid alarm_views[25];
void map_ala();
void unmap_ala();
void set_title_ala(char* title);
QWidget* get_widget()
{
return parent_wid_ala;
}
};
class EvAlaQtWidget : public QWidget {
Q_OBJECT
public:
EvAlaQtWidget(EvAlaQt* parent_ctx, QWidget* parent)
: QWidget(), ala(parent_ctx)
{
}
protected:
void focusInEvent(QFocusEvent* event);
void closeEvent(QCloseEvent* event);
public slots:
void ala_activate_print();
void ala_activate_ack_last();
void ala_activate_ack_all();
void ala_activate_zoom_in();
void ala_activate_zoom_out();
void ala_activate_zoom_reset();
void ala_activate_open_plc();
void ala_activate_display_in_xnav();
void ala_activate_disp_hundredth(bool set);
void ala_activate_hide_object(bool set);
void ala_activate_hide_text(bool set);
void ala_activate_help();
void ala_activate_helpevent();
void ala_activate_shift_view();
void ala_activate_select_flat();
void ala_activate_select_view();
private:
EvAlaQt* ala;
};
#endif |
727306581fd1a91efe715caa3582fe7305e01613 | c75e7dacc70bb6cbc7ea9eadc0ba4837b2679bee | /beatiful_matrix.cpp | cecede790e8aed7e6d02b9aacf6ef35c79e3fc8a | [] | no_license | akashc1612/Codeforces_ras | 0f602b8b88eeea87687548cfdb082541f64a412b | 0c17831e5ea4ec6ce835848a56c3f04ecadd7155 | refs/heads/main | 2023-04-17T08:20:16.646366 | 2021-04-27T04:03:18 | 2021-04-27T04:03:18 | 361,467,630 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | cpp | beatiful_matrix.cpp | #include <bits/stdc++.h>
using namespace std;
void solve(){
int a[5][5],x,y;
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
cin>>a[i][j];
if(a[i][j]==1){
x=i;
y=j;
}
}}
int z=abs(x-2)+abs(y-2);
cout<<z;
}
int main(){
cin.tie(0);
int t=1;
while(t--)
solve();
return 0;
} |
c8235837ee4cd65d47777e66e7e2ee6c4341ce7c | e58375bdc94b48f828b7f8ded6cd0d4174216918 | /cpp/codejam/y2015/ProblemD/main.cpp | acb0a697be2770ebd64d4bbfdfb205528026426e | [] | no_license | tedkim81/algorithm-study | eb43ffaf9b072c98910fee6e34ed528397d989f7 | 541115544dea589c9c5226eccd96e1f39bef1dfb | refs/heads/master | 2021-06-05T10:45:39.240524 | 2021-05-01T16:09:20 | 2021-05-01T16:09:20 | 133,684,139 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,296 | cpp | main.cpp | #include <stdio.h>
#include <vector>
#include <iterator>
#include <algorithm>
#include <set>
#include <string>
#include <iostream>
#include <list>
#include <map>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
int main() {
freopen("/Users/teuskim/Documents/workspace/cpp-src/GCJ2015/ProblemD/ProblemD/in", "r", stdin);
freopen("/Users/teuskim/Documents/workspace/cpp-src/GCJ2015/ProblemD/ProblemD/out", "w", stdout);
int T;
scanf("%d", &T);
for (int tt=1; tt<=T; tt++) {
printf("case #%d: ", tt);
int X, R, C;
scanf("%d %d %d", &X, &R, &C);
bool winRichard = false;
// if (X < 7) {
if (X > max(R, C)) {
winRichard = true;
} else {
int x1 = X / 2;
int x2 = X - x1;
if (min(x1, x2)+1 > min(R, C)) {
winRichard = true;
}
}
// } else {
// winRichard = true;
// }
if (winRichard) {
printf("RICHARD\n");
} else {
printf("GABRIEL\n");
}
}
return 0;
}
|
367ddcb1293dd0585f06f8bf0028a7c4b439cd2c | c74371b5118c1ad25b11cc0ee4f928a55de67160 | /algospot/darpa.cpp | 810eebccafa78248a476a6a161603d90d5e7e54d | [] | no_license | didw/coding | 8eaf7dee9d8476d042db6ec3141e6e57861916b2 | 5b0d026234b25a04c8a6ce6d6abd959e22bbd643 | refs/heads/master | 2021-07-10T03:20:19.509875 | 2021-06-17T13:19:15 | 2021-06-17T13:19:15 | 47,166,357 | 2 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 986 | cpp | darpa.cpp | #include <iostream>
#include <vector>
using namespace std;
bool decision(const vector<double>& location, int camera, double gap) {
double limit = -1;
int installed = 0;
for (int i = 0; i < location.size(); ++i) {
if (location[i] >= limit) {
limit = location[i] + gap;
installed++;
}
}
return camera <= installed;
}
double optimize(const vector<double>& location, int cameras) {
double lo = 0, hi = 241;
for (int it = 0; it < 100; ++it) {
double mid = (lo + hi) / 2;
if (decision(location, cameras, mid))
lo = mid;
else
hi = mid;
}
return lo;
}
int main() {
int c;
cin >> c;
while (c--) {
int n, m;
cin >> n >> m;
vector<double> location;
for (int i = 0; i < m; ++i) {
double a;
cin >> a;
location.push_back(a);
}
printf("%.2f\n", optimize(location, n));
}
}
|
aae87efefd79a7f1a55e2ab99a8d6d53a450a6e7 | 29accac928201357008780958a42ae54ca8299ba | /letnie piwo/194.cpp | fe3026db3e60684d27f97b17bd9473be56ceb87b | [] | no_license | xorver/Liceum | 4df3cc7716810f06f569abd2a8ed05d9b6fb1854 | 829fa3765d96d95a0d4fbb65e7c1fab498063509 | refs/heads/master | 2021-01-10T20:38:40.734041 | 2014-03-08T16:36:34 | 2014-03-08T16:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | cpp | 194.cpp | #include<iostream>
using namespace std;
string a;
int ile;
void wypisz(int x)
{
for(int i=x;i<a.size();i++)
if(a[i]=='b')
{
cout << "PASUJE" <<endl;
return;
}
cout << "NIE PASUJE" << endl;
}
main()
{
cin >> a;
ile=a.size();
for(int i=0;i<a.size();i++)
if(a[i]=='a')
{
ile=i+1;
break;
}
wypisz(ile);
return 0;
}
|
67401234c8fc47f2bd58c98228b438b916c99ad6 | adf73acdc7c442d420ce7b3b56c07f7e348cd9eb | /src/log.cpp | a6a0f303461315fe631391f1e4d93523f41ca400 | [] | no_license | xydinesh/DLB4VC | 2166f26a431c6533765d9476334d7fe44d2113b9 | 3b5355880758caf0f3294b110299869fb8f4f406 | refs/heads/master | 2016-09-10T10:50:48.378189 | 2012-04-05T05:14:24 | 2012-04-05T05:14:24 | 3,393,342 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,345 | cpp | log.cpp | #include "log.h"
/*
* This log implementation writes log messages to log
* file. This implementation is not thread safe.
*
* Different log level defined using an integer.
*
* Debug : 1
* Info : 2
* Warning : 3
* Error : 4
* Critical : 5
*
*
* Off : 0
*
*/
// global variables defined for log
double __log_stime__;
FILE *__log_file__;
FILE *__error_file__;
int __log_level__;
#ifndef __PARALLEL__
struct timeval tval;
struct timezone tzval;
#endif // __PARALLEL__
void log_init (const char *filename, const char *errorfile, int loglevel)
{
#ifndef __PARALLEL__
gettimeofday(&tval, &tzval);
#endif
__log_stime__ = STIME;
__log_level__ = 0;
if (!(loglevel < 0))
__log_level__ = loglevel;
/* #ifdef __LOG_ENABLE__ */
__log_file__ = fopen (filename, "w");
if (!__log_file__)
{
fprintf (stderr, "Unable to open __log_file__ for writing\n");
}
if (!errorfile)
{
errorfile = filename;
}
__error_file__ = fopen (errorfile, "w");
if (!__error_file__)
{
fprintf (stderr, "Unable to open __error_file__ for writing\n");
}
/* #endif */ /* __LOG_ENABLE__ */
}
void log_close ()
{
/* #ifdef __LOG_ENABLE__ */
fclose (__log_file__);
fclose (__error_file__);
/* #endif */ /* __LOG_ENABLE__ */
}
|
4b268439395bb0e431a418a5d47744b210ad50ab | d900eaef32972ada6e49a7ff3e58c98f2d55c9fb | /Project/RRMProjectR/RRMProject/SushiMon.cpp | da6c1f29b502f70f1897e38a0f2739435771d22c | [] | no_license | hanakita114514/RRMProject | 97a1973aa2f1cb305cf602e3bf93952a24e72acd | bcc366c6479752417858fd6be5fe02aa920bd15d | refs/heads/master | 2021-01-21T19:13:16.861695 | 2017-10-06T04:28:14 | 2017-10-06T04:28:14 | 92,117,623 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 4,241 | cpp | SushiMon.cpp | #include "SushiMon.h"
#include <RRMLib.h>
#include "GameTime.h"
#include "EffectManager.h"
#include "SushiHitBox.h"
static const int MAX_HP = 100;
static const int IMG_MAX = 2;
SushiMon::SushiMon(int handle , const Position& pos)
{
_friction = 0.05f;
_handle = handle;
_rc.pos = pos;
_hp.SetMaxHp(MAX_HP);
_hp.FullRecovery();
_rc.w = 64;
_rc.h = 32;
_dir = Vector2(-1, 0);
_uv = Vector2(0, 0);
_vel.x = _dir.x * 2;
_update[UpdateState::fall] = &SushiMon::FallUpdate;
_update[UpdateState::alive] = &SushiMon::AliveUpdate;
_update[UpdateState::attack] = &SushiMon::AttackUpdate;
_update[UpdateState::damage] = &SushiMon::DamageUpdate;
_update[UpdateState::dying] = &SushiMon::DyingUpdate;
_update[UpdateState::search] = &SushiMon::SearchUpdate;
_update[UpdateState::worry] = &SushiMon::WorryUpdate;
_update[UpdateState::charge] = &SushiMon::ChargeUpdate;
_state = UpdateState::fall;
_animFrame = 0;
_hitBox = new SushiHitBox();
_footCheck = true;
_warryTime = 0.0f;
_chargeTime = 0.0f;
_searchTime = 0.0f;
}
SushiMon::~SushiMon()
{
delete _hitBox;
}
void
SushiMon::Initialize()
{
}
void
SushiMon::AliveUpdate()
{
Gravity();
_vel.x = _dir.x * 2 * GameTime::Instance().GetTimeScale(this);
_rc.pos += _vel;
_hitBox->Foot(0, _rc, _dir);
_hitBox->Search(0, _rc, _dir);
_hpbar.CommitPeriod();
if (!_footCheck)
{
_state = UpdateState::worry;
_warryTime = 5;
}
if (_isSearch)
{
_state = UpdateState::search;
_searchTime = 20.f;
_hitBox->SearchClear();
//‰EŒü‚«
if (_targetPos.x > _rc.pos.x)
{
_dir.x = 1;
}
else
{
_dir.x = -1;
}
}
if (_isDamage)
{
_state = UpdateState::damage;
}
if (_hp.IsDead())
{
_state = UpdateState::dying;
EffectManager::Instance().Create(EffectType::erasure, _rc.Center(), Vector2(1.5f, 1.5f), 1.3f);
_isAlive = false;
}
}
void
SushiMon::DyingUpdate()
{
}
void
SushiMon::ChargeUpdate()
{
--_chargeTime;
static int quake = 1;
_rc.pos.x = _rc.pos.x + (3 * quake);
quake *= -1;
if (_chargeTime < 0)
{
_state = UpdateState::attack;
_vel.x = _dir.x * 4.f;
_vel.y = -13;
}
}
void
SushiMon::SearchUpdate()
{
Gravity();
_vel.x = _dir.x * 4.f * GameTime::Instance().GetTimeScale(this);
_rc.pos += _vel;
--_searchTime;
if (_searchTime < 0 && _hitGround)
{
_state = UpdateState::charge;
_chargeTime = 30.0f;
_hitBox->Foot(0, _rc, _dir);
_hitBox->Search(0, _rc, _dir);
}
}
void
SushiMon::AttackUpdate()
{
Gravity();
_rc.pos += _vel;
_hitBox->Attack(0, _rc, _dir);
if (_hitGround)
{
_state = UpdateState::alive;
_isSearch = false;
_hitBox->Clear();
_mhp.Clear();
}
}
void
SushiMon::WorryUpdate()
{
--_warryTime;
if (_warryTime <= 0)
{
_state = UpdateState::fall;
_dir.x *= -1;
_vel.x = _dir.x * 2;
_hitBox->Foot(0, _rc, _dir);
_hitBox->Search(0, _rc, _dir);
}
}
void
SushiMon::FallUpdate()
{
Gravity();
_rc.pos += _vel;
if (_hitGround)
{
_state = UpdateState::alive;
}
}
void
SushiMon::DamageUpdate()
{
Gravity();
_rc.pos += _vel;
DistanceAttenuation();
if (_vel.x == 0)
{
_isDamage = false;
_state = UpdateState::alive;
_vel.x = _dir.x * 2;
_hpbar.Commit();
_armor.Recovery();
}
}
void
SushiMon::Update()
{
if (!_hitStop.IsHitStop())
{
Anim();
(this->*_update[_state])();
}
if (_armor.IsBroken())
{
}
_hpbar.Update();
_hitStop.Update();
}
void
SushiMon::Draw(const Vector2& offset)
{
Vector2 drawPos;
drawPos.x = _rc.pos.x - offset.x;
drawPos.y = _rc.pos.y - offset.y;
RRMLib::DrawRectGraph(drawPos.x, drawPos.y, _uv.x, _uv.y, _rc.w, _rc.h, _handle, true, _dir.x > 0);
_hpbar.Draw(Vector2(drawPos.x + _rc.w / 4, drawPos.y - _rc.h / 4), _hp);
//ColDraw();
}
void
SushiMon::Anim()
{
static const Vector2 uv[]
{
Vector2(0,0),
Vector2(_rc.w, 0)
};
_animFrame += GameTime::Instance().GetTimeScale(this);
int idx = (int)(_animFrame * 0.1f) % IMG_MAX;
_uv = uv[idx];
}
EnemyType
SushiMon::GetEnemyType()
{
return EnemyType::sushi;
} |
aabd39b696c4c4ece0fea7f5b4773188faec14de | 7c8c742e5e3a285a7fb98381de235bc05e705ae7 | /Viona/qrc_qml.cpp | 327caf9ce776c474a5bd8a0a88d097fdffedb24a | [] | no_license | grahamcrowell/MovieMaker | c2e94e63cd29e189522f4a1d1d21e231e4f38c16 | f98b27a61f78a57c90ca1e62b66ae574f124c67b | refs/heads/master | 2021-01-01T05:40:03.670568 | 2016-12-08T07:44:20 | 2016-12-08T07:44:20 | 32,563,181 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,385 | cpp | qrc_qml.cpp | /****************************************************************************
** Resource object code
**
** Created by: The Resource Compiler for Qt version 5.4.1
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
static const unsigned char qt_resource_data[] = {
// /Users/grahamcrowell/Dropbox/github_local/Viona/main.qml
0x0,0x0,0x2,0x59,
0x0,
0x0,0x8,0xef,0x78,0x9c,0xdd,0x55,0x3b,0x6f,0xdb,0x30,0x10,0xde,0xf5,0x2b,0x8,
0x4f,0xce,0x22,0xc8,0x6,0xb2,0xa8,0xf0,0xd0,0x18,0x9,0x1a,0xb4,0x1,0x62,0xd7,
0x40,0x46,0x83,0x96,0x4e,0xd2,0xc1,0x14,0x29,0x93,0x94,0x93,0xb4,0xf0,0x7f,0x2f,
0xa9,0x87,0xad,0x97,0x63,0xb8,0xcd,0x54,0x4e,0xbc,0xbb,0x8f,0x1f,0xef,0xc5,0x23,
0xa6,0x99,0x90,0x9a,0x2c,0xf4,0x22,0xc7,0x60,0x4b,0xa6,0xee,0xd4,0xc1,0x96,0xca,
0x9d,0xb,0xae,0xa5,0x60,0x8a,0x4c,0xdc,0x49,0x6d,0xcb,0x58,0x9e,0x6e,0x90,0xc7,
0xc4,0x33,0x3a,0xe7,0x6b,0x96,0x31,0xc,0xa8,0x46,0xc1,0x5f,0x90,0x87,0xe2,0x95,
0xfc,0x76,0x88,0x59,0x18,0xfa,0x84,0x76,0x6d,0x93,0xc2,0xb4,0x47,0x85,0x1b,0x6,
0x3e,0xd1,0x32,0x87,0x42,0xf3,0x8a,0xa1,0x4e,0x7c,0x32,0xf5,0xbc,0x42,0x4c,0x0,
0xe3,0x44,0xfb,0x64,0x52,0xc9,0x1a,0xb5,0x85,0xef,0xd4,0x4a,0x8e,0x47,0xdf,0x80,
0x31,0x41,0x5e,0x84,0x64,0xe1,0xe8,0xc6,0x29,0xec,0x29,0xf0,0xfc,0x8e,0x4a,0x9f,
0x3c,0x95,0x9b,0xca,0x5,0xbb,0xac,0xa6,0x21,0xf6,0xd8,0x1e,0x90,0x81,0xa1,0x69,
0xda,0xed,0x91,0x47,0xd,0x69,0xe7,0x58,0x71,0x14,0xde,0x74,0x7d,0xf2,0xfe,0xd,
0x75,0xe7,0xa4,0x5d,0x82,0xaf,0x24,0xc6,0x31,0x48,0x30,0x9,0x58,0x68,0x77,0x97,
0xa3,0x1e,0xdf,0x7c,0x69,0xe1,0xe,0x4e,0x7b,0x77,0x28,0xc3,0xe8,0x5c,0x6a,0x33,
0x28,0xf6,0x20,0x99,0x90,0xe1,0x51,0x49,0x79,0x90,0x8,0xa9,0xdc,0x8,0x19,0xf3,
0x49,0x46,0x25,0x70,0x7d,0x34,0x46,0x22,0xc8,0x55,0x95,0xd6,0xa3,0xf2,0x2e,0xd7,
0x5a,0xf0,0x4e,0x30,0x96,0x7b,0x53,0x18,0x26,0xed,0xdc,0x34,0x2,0x9c,0x4b,0xa0,
0x1a,0xc8,0x63,0x4a,0x63,0x50,0x9d,0x48,0x83,0x4,0x82,0xad,0x8d,0x30,0xa2,0x4c,
0x41,0xcb,0x54,0x7b,0xa8,0x45,0x56,0x3b,0x68,0xf7,0xe7,0x30,0x4f,0x54,0xc6,0xc8,
0x7d,0x72,0xeb,0xd,0x22,0x64,0xd9,0x9,0x15,0x4f,0x21,0x9d,0xc7,0xd5,0x5c,0xc3,
0x54,0x1b,0x61,0xe2,0x4d,0x8f,0x5c,0xa5,0x38,0x88,0x64,0x10,0x9d,0xee,0xb4,0x42,
0x7,0xa5,0x91,0x32,0xa4,0xca,0xbc,0x81,0x46,0xf,0xb7,0x52,0x43,0x8b,0xfe,0xee,
0x27,0x47,0xf0,0xb9,0x79,0x11,0x45,0xe6,0xfa,0xdd,0xc5,0x72,0x8c,0xd1,0x4d,0x28,
0xf,0x19,0x94,0x55,0xbb,0xd4,0x38,0x76,0x3d,0xd7,0xcf,0xb1,0x5f,0xe1,0x82,0xb0,
0xa5,0xdd,0xa5,0x6c,0x6d,0x3,0x5a,0xef,0xed,0x73,0xb1,0xd5,0x7e,0x40,0x60,0xe1,
0xf,0xa3,0x72,0xad,0xd4,0x3,0x17,0x79,0xed,0xa0,0x97,0x56,0xd7,0x86,0x9f,0xdc,
0x59,0xd5,0xa8,0x1,0x7f,0x5a,0xf7,0xb5,0xac,0xcd,0xce,0xbd,0x22,0xd7,0x65,0xbb,
0x8e,0x6e,0x3d,0x6f,0xd4,0xd2,0x67,0x8c,0x6,0x90,0x8,0x16,0x82,0x5c,0x95,0x90,
0x48,0xd2,0xd4,0x74,0x71,0xe7,0x52,0x53,0xde,0x4c,0x20,0xd7,0x3f,0xf1,0x17,0xd8,
0xf1,0xf3,0x19,0x8d,0xfc,0x71,0xf3,0x55,0x8f,0xee,0x2c,0x51,0x89,0xfb,0x98,0xeb,
0xaf,0xde,0x44,0x3d,0x4b,0xbb,0xa0,0x4b,0xbd,0x7e,0x42,0x9d,0x9c,0x6a,0x94,0xfd,
0xba,0xba,0x2f,0x7,0x7c,0xfd,0xa4,0x2,0x17,0x5f,0xc8,0xff,0x51,0xdf,0xeb,0x4b,
0x72,0xae,0xb8,0xff,0x38,0x3d,0x1b,0xe5,0xfd,0xe,0xef,0xca,0x15,0xfc,0x59,0x82,
0x52,0xfd,0xe9,0x85,0x11,0x19,0xc3,0xde,0xde,0xb1,0x85,0x77,0x32,0x9b,0xcd,0xec,
0xcf,0x67,0x8e,0xac,0x97,0xa0,0x73,0xc9,0xfb,0xbf,0xe4,0xe5,0x51,0x7,0x66,0x74,
0x1a,0xde,0x61,0xda,0x7b,0x15,0xd0,0xc,0xfa,0xb4,0xc7,0xff,0xb6,0xd9,0xa2,0x55,
0x24,0x7,0xe7,0xf,0xd2,0xb1,0x67,0x3b,
};
static const unsigned char qt_resource_name[] = {
// main.qml
0x0,0x8,
0x8,0x1,0x5a,0x5c,
0x0,0x6d,
0x0,0x61,0x0,0x69,0x0,0x6e,0x0,0x2e,0x0,0x71,0x0,0x6d,0x0,0x6c,
};
static const unsigned char qt_resource_struct[] = {
// :
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
// :/main.qml
0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
};
#ifdef QT_NAMESPACE
# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
# define QT_RCC_MANGLE_NAMESPACE0(x) x
# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
#else
# define QT_RCC_PREPEND_NAMESPACE(name) name
# define QT_RCC_MANGLE_NAMESPACE(name) name
#endif
#ifdef QT_NAMESPACE
namespace QT_NAMESPACE {
#endif
bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
#ifdef QT_NAMESPACE
}
#endif
int QT_RCC_MANGLE_NAMESPACE(qInitResources_qml)();
int QT_RCC_MANGLE_NAMESPACE(qInitResources_qml)()
{
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_qml)();
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_qml)()
{
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
namespace {
struct initializer {
initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_qml)(); }
~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_qml)(); }
} dummy;
}
|
d42f93d934368f4e3abad2acdcf5f51933896999 | f862ae64559a336b5876a788dae4bb3bad56b7a7 | /Tutorial05/Include/NsGui/Path.h | 7863cc2e6b067d2f47bc1bcc86a691743f673cd4 | [] | no_license | nitianxiaoshuai/NoesisDemo | ef9485f4f015707cae15e017fcd8593ebc4fd216 | dc949eb8058361fbba0d6be58503bef824216453 | refs/heads/master | 2020-06-17T06:14:36.282909 | 2016-12-01T00:09:25 | 2016-12-01T00:09:25 | 75,034,645 | 1 | 8 | null | 2016-12-07T01:13:31 | 2016-11-29T02:28:47 | C++ | UTF-8 | C++ | false | false | 3,088 | h | Path.h | ////////////////////////////////////////////////////////////////////////////////////////////////////
// Noesis Engine - http://www.noesisengine.com
// Copyright (c) 2009-2010 Noesis Technologies S.L. All Rights Reserved.
////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __GUI_PATH_H__
#define __GUI_PATH_H__
#include <Noesis.h>
#include <NsGui/Shape.h>
namespace Noesis
{
namespace Gui
{
/// Forward declarations
//@{
class Geometry;
class MatrixTransform;
//@}
#ifdef NS_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable: 4251 4275)
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Draws a series of connected lines and curves.
///
/// .. code-block:: c++
///
/// // Geometry
/// Ptr<StreamGeometry> geometry = *new StreamGeometry();
/// {
/// StreamGeometryContext context = geometry->Open();
/// context.BeginFigure(Point(260.0f, 200.0f), true);
/// context.ArcTo(Point(140.0f, 200.0f), Drawing::Size(60.0f, 60.0f), 0, false, true);
/// context.ArcTo(Point(260.0f, 200.0f), Drawing::Size(60.0f, 60.0f), 0, false, true);
/// }
///
/// // Path
/// Ptr<Gui::Path> path = *new Gui::Path();
/// Ptr<Brush> red = *new SolidColorBrush(Color::Red);
/// path->SetFill(red.GetPtr());
/// path->SetData(geometry.GetPtr());
///
/// // Root canvas
/// Ptr<Canvas> root = *new Canvas();
/// Ptr<Brush> gray = *new SolidColorBrush(Color::LightGray);
/// root->SetBackground(gray.GetPtr());
/// root->GetChildren()->Add(path.GetPtr());
///
/// http://msdn.microsoft.com/en-us/library/system.windows.shapes.path.aspx
////////////////////////////////////////////////////////////////////////////////////////////////////
class NS_GUI_CORE_API Path: public Shape
{
public:
/// Constructor
Path();
/// Destructor
~Path();
/// Gets or sets the geometry that specifies the shape to be drawn
//@{
Geometry* GetData() const;
void SetData(Geometry* data);
//@}
public:
/// Dependency properties
//@{
static const DependencyProperty* DataProperty;
//@}
protected:
/// From DependencyObject
//@{
NsBool OnPropertyChanged(const DependencyPropertyChangedEventArgs& args);
//@}
/// From UIElement
//@{
void OnRender(DrawingContext* context);
//@}
/// From FrameworkElement
//@{
Drawing::Size MeasureOverride(const Drawing::Size& availableSize);
Drawing::Size ArrangeOverride(const Drawing::Size& finalSize);
//@}
private:
Drawing::Size GetMinimumSize() const;
void OnGeometryChanged(Freezable* freezable, FreezableEventReason reason);
private:
Ptr<Geometry> mRenderGeometry;
Ptr<MatrixTransform> mRenderMatrix;
Ptr<MatrixTransform> mStretchMatrix;
NS_DECLARE_REFLECTION(Path, Shape)
};
#ifdef NS_COMPILER_MSVC
#pragma warning(pop)
#endif
}
}
#endif
|
6b772b25355bb38a8959e94c5913882832fb4bf5 | 511d7cd374cf8ecdc6a9d72223bed16a32d83c78 | /msdk/mscom/managedb/managedb/otl/otlfieldhandlers.h | 799d7737aa2a5fbf48ed8603a58a8a0cd702a822 | [] | no_license | mynick777/msdk | 1818c718a181de772b9a3e2dd6d7b9a66296dc86 | 4ee669c60148ad72e1d8af9bea05e05019af79e6 | refs/heads/master | 2020-05-18T00:56:37.308774 | 2019-05-01T16:19:13 | 2019-05-01T16:19:13 | 184,075,465 | 0 | 0 | null | 2019-04-29T13:22:32 | 2019-04-29T13:22:32 | null | UTF-8 | C++ | false | false | 9,603 | h | otlfieldhandlers.h | /********************************************************************
created: 2009/12/19
created: 19:12:2009 15:02
filename: d:\C++Work\approduct2010\utm\src\unitive\managedb\otlfieldhandlers.h
file path: d:\C++Work\approduct2010\utm\src\unitive\managedb
file base: otlfieldhandlers
file ext: h
author: zhangming1
purpose:
*********************************************************************/
#pragma once
#include "otlinc.h"
#include <rscom/prophelpers.h>
#include <iostream>
#include <vector>
using namespace std;
enum otl_handler_type
{
otl_handler_numeric,
otl_handler_blob,
otl_handler_char,
otl_handler_binary,
otl_handler_varchar_long,
otl_handler_datetime
};
class IOtlFieldHandler
{
public:
IOtlFieldHandler( otl_stream* pStream )
:m_pStream(pStream)
{
}
virtual ~IOtlFieldHandler()
{
}
virtual BOOL PrepareColumn( otl_column_desc* pColumn )
{
return TRUE;
}
virtual BOOL PrepareIO( BOOL bStreamMode )
{
return TRUE;
}
virtual VOID GetField( CPropVar* prop, int otlType ) = 0;
protected:
otl_stream* m_pStream;
};
template <DWORD hander_type>
class concrete_handler : public IOtlFieldHandler
{
public:
concrete_handler( otl_stream* pStream )
: IOtlFieldHandler(pStream) {}
virtual BOOL PrepareColumn( otl_column_desc* pColumn, BOOL& bStreamMode )
{
bStreamMode = FALSE;
return FALSE;
}
virtual BOOL PrepareIO( BOOL bStreamMode )
{
return FALSE;
}
virtual VOID GetField( CPropVar* prop, int otlType )
{
*prop = CPropVar::GetNull();
}
};
#define OTL_NUM_CASE( otlType, dataType )\
case otlType:\
{\
dataType num;\
(*m_pStream) >> num;\
*prop = m_pStream->is_null() ? CPropVar::GetNull() : num;\
}\
break;
#define OTL_VT_CASE( vt, dataType )\
case vt:\
{\
dataType num = *prop;\
stream << num;\
}\
break;
template <>
class concrete_handler<otl_handler_numeric> : public IOtlFieldHandler
{
public:
concrete_handler( otl_stream* pStream )
:IOtlFieldHandler(pStream)
{}
public:
virtual VOID GetField( CPropVar* prop, int otlType )
{
switch( otlType )
{
OTL_NUM_CASE( otl_var_bigint, OTL_BIGINT )
OTL_NUM_CASE( otl_var_float, float )
OTL_NUM_CASE( otl_var_int, int )
OTL_NUM_CASE( otl_var_long_int, long int )
OTL_NUM_CASE( otl_var_short, short )
OTL_NUM_CASE( otl_var_unsigned_int, unsigned int )
}
}
static VOID PutVar( otl_stream& stream, CPropVar* prop )
{
switch( prop->vt )
{
OTL_VT_CASE( VT_INT, int )
OTL_VT_CASE( VT_UINT, unsigned int )
OTL_VT_CASE( VT_I4, long )
OTL_VT_CASE( VT_UI4, long )
OTL_VT_CASE( VT_I8, OTL_BIGINT )
}
}
};
template <>
class concrete_handler<otl_handler_blob>: public IOtlFieldHandler
{
public:
concrete_handler( otl_stream* pStream )
:IOtlFieldHandler(pStream)
{
m_pLongStr = NULL;
}
virtual ~concrete_handler()
{
delete m_pLongStr;
}
virtual BOOL PrepareIO( BOOL bStreamMode )
{
m_bStreamMode = bStreamMode;
m_pLongStr = new otl_long_string(LOB_CHUNK_SIZE);
return TRUE;
}
virtual VOID GetField( CPropVar* prop, int otlType )
{
if( m_bStreamMode )
{
m_lobBuff.clear();
(*m_pStream) >> m_lobStream;
if( m_pStream->is_null() )
{
*prop = CPropVar::GetNull();
return;
}
while( m_lobStream.eof() )
{
m_lobStream >> (*m_pLongStr);
unsigned char* pStart = &(*m_pLongStr)[0];
m_lobBuff.insert( m_lobBuff.end(), pStart, pStart+m_pLongStr->len() );
}
m_lobStream.close();
prop->vt = VT_BUFFER;
prop->SetVector( &m_lobBuff.front(), (int)m_lobBuff.size() );
}
else
{
(*m_pStream) >> (*m_pLongStr);
if( m_pStream->is_null() )
{
*prop = CPropVar::GetNull();
return;
}
prop->SetVector( (LPVOID)&( (*m_pLongStr)[0] ), m_pLongStr->len() );
}
}
static VOID PutVar( otl_stream& stream, CPropVar* prop )
{
LPBYTE pBuffer;
INT dwLen;
prop->GetVector( (VOID**)&pBuffer, (INT)dwLen );
otl_lob_stream lobStream;
stream << lobStream;
DWORD dwIndex = 0;
while( dwIndex < (DWORD)dwLen )
{
DWORD dwRest = dwLen - dwIndex;
DWORD dwChunkSize = (dwRest > LOB_CHUNK_SIZE) ? LOB_CHUNK_SIZE : dwRest;
// No copy here
otl_long_string longStr( pBuffer+dwIndex, dwChunkSize, dwChunkSize );
lobStream << longStr;
dwIndex += dwChunkSize;
}
lobStream.close();
}
private:
BOOL m_bStreamMode;
otl_lob_stream m_lobStream;
otl_long_string* m_pLongStr;
std::vector<unsigned char> m_lobBuff;
};
template <>
class concrete_handler<otl_handler_varchar_long>: public IOtlFieldHandler
{
public:
concrete_handler( otl_stream* pStream )
:IOtlFieldHandler(pStream)
{
m_pLongStr = NULL;
}
virtual ~concrete_handler()
{
delete m_pLongStr;
}
virtual BOOL PrepareIO( BOOL bStreamMode )
{
#ifdef _UNICODE
m_pLongStr = new otl_long_unicode_string(LOB_CHUNK_SIZE/sizeof(TCHAR));
#else
m_pLongStr = new otl_long_string(LOB_CHUNK_SIZE/sizeof(TCHAR));
#endif
m_bStreamMode = bStreamMode;
return TRUE;
}
virtual VOID GetField( CPropVar* prop, int otlType )
{
m_lobBuff.clear();
if(m_bStreamMode)
{
(*m_pStream) >> m_lobStream;
if( m_pStream->is_null() )
*prop = CPropVar::GetNull();
while( !m_lobStream.eof() )
{
m_lobStream >> (*m_pLongStr);
OTL_CHAR* pStart = &(*m_pLongStr)[0];
m_lobBuff.insert( m_lobBuff.end(), pStart, pStart+m_pLongStr->len() );
}
m_lobBuff.push_back( 0 );
m_lobStream.close();
*prop = (LPTSTR)&m_lobBuff.front();
}
else
{
(*m_pStream) >> (*m_pLongStr);
if( m_pStream->is_null() )
{
*prop = CPropVar::GetNull();
return;
}
*prop = (LPTSTR)&(*m_pLongStr)[0];
}
}
static VOID PutVar( otl_stream& stream, CPropVar* prop )
{
LPCTSTR szValue = *prop;
DWORD dwLen = (DWORD)_tcslen( szValue );
otl_lob_stream lobStream;
stream << lobStream; // Initialize lob stream by writing it into otl_stream
lobStream.set_len( dwLen );
DWORD lobLen = (dwLen > LOB_CHAR_COUNT) ? LOB_CHAR_COUNT : dwLen;
#ifdef _UNICODE
otl_long_unicode_string longStr( lobLen+100 );
#else
otl_long_string longStr( lobLen+100 );
#endif
DWORD dwIndex = 0;
while( dwIndex < dwLen )
{
DWORD dwRest = dwLen - dwIndex;
DWORD dwChunkSize = (dwRest > LOB_CHAR_COUNT) ? LOB_CHAR_COUNT : dwRest;
for( DWORD i=0; i<dwChunkSize; i++ )
{
longStr[i] = (unsigned short)szValue[dwIndex+i];
}
longStr.set_len( dwChunkSize );
lobStream << longStr;
dwIndex += dwChunkSize;
}
lobStream.close();
}
private:
BOOL m_bStreamMode;
otl_lob_stream m_lobStream;
#ifdef _UNICODE
otl_long_unicode_string* m_pLongStr;
#else
otl_long_string* m_pLongStr;
#endif
std::vector<OTL_CHAR> m_lobBuff;
};
template <>
class concrete_handler<otl_handler_char> : public IOtlFieldHandler
{
public:
concrete_handler( otl_stream* pStream )
:IOtlFieldHandler(pStream)
{
m_dwSize = 0;
m_szValue = NULL;
}
virtual ~concrete_handler()
{
delete[] m_szValue;
}
virtual BOOL PrepareColumn( otl_column_desc* pColumn )
{
if( (DWORD)pColumn->dbsize > m_dwSize )
m_dwSize = pColumn->dbsize;
return TRUE;
}
virtual BOOL PrepareIO( BOOL bStreamMode )
{
m_szValue = new TCHAR[m_dwSize/sizeof(TCHAR)+1];
return TRUE;
}
virtual VOID GetField( CPropVar* prop, int otlType )
{
(*m_pStream) >> (unsigned char*)m_szValue;
if( m_pStream->is_null() )
*prop = CPropVar::GetNull();
else
*prop = m_szValue;
}
static VOID PutVar( otl_stream& stream, CPropVar* prop )
{
LPCTSTR szValue = *prop;
stream << szValue;
}
private:
DWORD m_dwSize;
LPTSTR m_szValue;
};
template <>
class concrete_handler<otl_handler_binary> : public IOtlFieldHandler
{
public:
concrete_handler( otl_stream* pStream )
:IOtlFieldHandler(pStream)
{
m_dwSize = 0;
m_pBuffer = NULL;
}
virtual ~concrete_handler()
{
delete m_pBuffer;
}
virtual BOOL PrepareColumn( otl_column_desc* pColumn )
{
if( (DWORD)pColumn->dbsize > m_dwSize )
m_dwSize = pColumn->dbsize;
return TRUE;
}
virtual BOOL PrepareIO( BOOL bStreamMode )
{
m_pBuffer = new otl_long_string( m_dwSize );
return TRUE;
}
virtual VOID GetField( CPropVar* prop, int otlType )
{
(*m_pStream) >> (*m_pBuffer);
if( m_pStream->is_null() )
{
*prop = CPropVar::GetNull();
return;
}
prop->SetVector( (LPVOID)&( (*m_pBuffer)[0] ), m_pBuffer->len() );
}
static VOID PutVar( otl_stream& stream, CPropVar* prop )
{
LPBYTE pBuffer;
INT dwSize;
prop->GetVector( &pBuffer, dwSize );
if( pBuffer && dwSize )
{
otl_long_string longStr( pBuffer, dwSize, dwSize );
stream << longStr;
}
}
private:
DWORD m_dwSize;
otl_long_string* m_pBuffer;
};
template <>
class concrete_handler<otl_handler_datetime> : public IOtlFieldHandler
{
public:
concrete_handler( otl_stream* pStream )
:IOtlFieldHandler(pStream)
{
memset( m_szTime, 0, sizeof(m_szTime) );
}
virtual VOID GetField( CPropVar* prop, int otlType )
{
otl_datetime otlTime;
(*m_pStream) >> otlTime;
if( m_pStream->is_null() )
{
*prop = CPropVar::GetNull();
return;
}
_stprintf_s( m_szTime, _countof(m_szTime), _T("%d-%d-%d %d:%d:%d"),
otlTime.year, otlTime.month, otlTime.day,
otlTime.hour, otlTime.minute, otlTime.second );
*prop = (LPTSTR)m_szTime;
}
static VOID PutVar( otl_stream& stream, CPropVar* prop )
{
SYSTEMTIME sysTime = *prop;
otl_datetime otlTime;
otlTime.year = sysTime.wYear;
otlTime.month = sysTime.wMonth;
otlTime.day = sysTime.wDay;
otlTime.hour = sysTime.wHour;
otlTime.minute = sysTime.wMinute;
otlTime.second = sysTime.wSecond;
stream << otlTime;
}
private:
TCHAR m_szTime[128];
}; |
7fc54059488ce4bedcc4ca329656ecd607053da6 | 6f100f69232c6597c3f9564acde9c303b2adf47d | /Kattis/Integer Lists/main.cpp | 8f2297f860a7b797215cec58d48316c7efb04295 | [] | no_license | douglasbravimbraga/programming-contests | 43e1b6aaa5a3ef51f5815fed8cb9a607f4f334cc | 75e444977cc3ff701b7390b8de70c88f6b40c52f | refs/heads/master | 2023-07-20T07:58:53.145049 | 2021-08-01T12:48:23 | 2021-08-01T12:48:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 970 | cpp | main.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
int test_cases;
cin >> test_cases;
while (test_cases--) {
string operation;
cin >> operation;
bool rev = false;
int size;
cin >> size;
list<int> l;
int num;
char trash;
cin >> trash;
for (int i = 0; i < size; i++) {
if (i) {
cin >> trash;
}
cin >> num;
l.push_back(num);
}
cin >> trash;
bool err = false;
for (int i = 0; i < operation.length(); i++) {
if (operation[i] == 'R') {
rev = !rev;
} else {
if (l.empty()) {
err = true;
break;
} else {
size--;
if (rev) {
l.pop_back();
} else {
l.pop_front();
}
}
}
}
if (err) {
cout << "error" << endl;
} else {
if (rev) l.reverse();
int cc = 0;
cout << '[';
for (auto i : l) {
cout << i;
if (cc++ != size - 1) cout << ',';
}
cout << ']' << endl;
}
}
return 0;
} |
babb9454020d4968933a9b254e187f26a56cb8e1 | a1fbf16243026331187b6df903ed4f69e5e8c110 | /cs/engine/xrGame/smart_cover_object_script.cpp | 1774fc5ee33769e38bd7f9b59d8f260805b1b3d8 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | OpenXRay/xray-15 | ca0031cf1893616e0c9795c670d5d9f57ca9beff | 1390dfb08ed20997d7e8c95147ea8e8cb71f5e86 | refs/heads/xd_dev | 2023-07-17T23:42:14.693841 | 2021-09-01T23:25:34 | 2021-09-01T23:25:34 | 23,224,089 | 64 | 23 | NOASSERTION | 2019-04-03T17:50:18 | 2014-08-22T12:09:41 | C++ | UTF-8 | C++ | false | false | 585 | cpp | smart_cover_object_script.cpp | ////////////////////////////////////////////////////////////////////////////
// Module : smart_cover_script.cpp
// Created : 21.12.2007
// Modified : 21.12.2007
// Author : Dmitriy Iassenev
// Description : smart cover script export
////////////////////////////////////////////////////////////////////////////
#include "pch_script.h"
#include "smart_cover.h"
using namespace luabind;
#pragma optimize("s",on)
void smart_cover::object::script_register (lua_State *L)
{
module(L) [
class_<smart_cover::object,CGameObject>("smart_cover_object")
.def(constructor<>())
];
}
|
78dedce193dbed419ed64b920e3c6e325111fb4d | f7297d121add98402f68a52c50dfcc121a5f11cd | /emu/applications/pron/window.h | ba31011fb60433dd3b43e912a4fd25dcd913e241 | [] | no_license | TacOS-team/tacos-gui | 152590afc03f396a61f5297cd2c9923aa69277b3 | 31ed320218b4c04211830a6da952c90cceedc81e | refs/heads/master | 2021-01-15T20:29:18.882340 | 2012-06-07T11:33:23 | 2012-06-07T11:33:23 | 37,925,020 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,239 | h | window.h | #ifndef _WINDOW_H_
#define _WINDOW_H_
#include <pronlib_enums.h>
#include <pronlib_structs.h>
#include <pronlib_events.h>
#include <vector>
using namespace std;
class Screen;
class Client;
struct OtherClient {
OtherClient(Client *client, unsigned int mask) {
this->client = client;
this->mask = mask;
}
Client *client;
unsigned int mask;
};
class Window {
public: //XXX: bourrin
Screen *screen;
int id;
Client *creator;
// Window attributes
int x, y;
int width, height;
int eventMask;
int dontPropagateMask;
vector<OtherClient> otherClients;
Window *parent;
Window *prevSibling, *nextSibling;
Window *firstChild, *lastChild;
Window(Screen *screen, int id, Client *creator, Window *parent, int x, int y, int width, int height);
//short getCreator();
Client* getCreator();
void drawPoint(int x, int y);
void drawLine(int x1, int y1, int x2, int y2);
void drawRect(int x1, int y1, int width, int height) ;
void fillRectangle(int x, int y, int width, int height);
void drawCircle(int x, int y, int radius);
void fillCircle(int x, int y, int radius);
void clear();
void clear(int x, int y, int width, int height);
PronWindowAttributes getAttributes();
void setAttributes(PronWindowAttributes *newAttributes, unsigned int mask);
void selectInput(Client *client, unsigned int mask);
void raise();
void exposeArea(int x, int y, int width, int height);
/**
* Delivers an event to this window.
*
* @param e The event to deliver
* @param size The size of the event
*/
void deliverEvent(PronEvent *e, unsigned int size);
/**
* Delivers an event to this window and its immediate parent.
* Suitable for window events ().
*
* @param e The event to deliver
* @param size The size of the event
*/
void deliverWindowEvent(PronEvent *e, unsigned int size);
/**
* Delivers a event that needs to propagate up the window tree.
* Suitable for device events ().
* @param e The event to deliver
* @param size The size of the event
*/
void deliverDeviceEvent(PronEvent *e, unsigned int size);
private:
void reduce(int &x, int &y, int &width, int &height);
bool overlaps(Window *w);
};
#endif
|
0167bf84b15b096facac44c327454eb2274c42ab | d9a988cf5cbf84eb18cde9e8f087b19fe33b00ac | /Arduino/libraries/CAN_Serializer/Constants.cpp | b987bbf9f7513664df49ce3656404f3ceb9aa683 | [] | no_license | wilsonPhiggsbury/NanyangVenture | fa354f1fabddd47b7fed135eba235997826bd41e | 05a3446d9523683595bc658eeb11fce93683bdc8 | refs/heads/master | 2020-03-20T21:55:19.577911 | 2018-12-28T10:48:47 | 2018-12-28T10:48:47 | 137,768,250 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 67 | cpp | Constants.cpp | #include <Constants.h>
uint8_t peripheralStates[NUMSTATES] = { 0 }; |
e83153af123b7f0a0ba9a8857c297745dee66022 | de21f9075f55640514c29ef0f1fe3f0690845764 | /src/big-int/bigint-func.cc | 6ee5210a5c6ea3aceba34257cc0c580901995842 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-4-Clause"
] | permissive | diffblue/cbmc | 975a074ac445febb3b5715f8792beb545522dc18 | decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16 | refs/heads/develop | 2023-08-31T05:52:05.342195 | 2023-08-30T13:31:51 | 2023-08-30T13:31:51 | 51,877,056 | 589 | 309 | NOASSERTION | 2023-09-14T18:49:17 | 2016-02-16T23:03:52 | C++ | UTF-8 | C++ | false | false | 1,703 | cc | bigint-func.cc | // $Id: bigint-func.cc,v 1.1.1.1 2002-06-13 22:00:30 kroening Exp $
// Author: Dirk Zoller
// References:
//
// [1] Hüttenhofer/Lesch/Peyerimhoff, Mathematik in Anwendung mit C++
// Heidelberg, Wiesbaden 1994
#include "bigint.hh"
BigInt
pow (BigInt const &x, unsigned y)
{
BigInt a = x;
BigInt r = 1;
for (;;)
{
if (y & 1)
r *= a;
y >>= 1;
if (y == 0)
return r;
a *= a;
}
}
// Modular exponentiation, see [1] p. 74.
BigInt
pow (BigInt const &x, BigInt const &y, BigInt const &m)
{
BigInt a = x;
BigInt b = y;
BigInt r = 1;
for (;;)
{
a %= m;
if (b.is_odd())
{
r *= a;
r %= m;
}
b /= 2;
if (b.is_zero())
return r;
a *= a;
}
}
// Integer square root. see [1] p.23, slightly changed for better performance.
BigInt
sqrt (BigInt const &n)
{
BigInt x0 = n;
BigInt x1 = n;
x1 += 1;
x1 /= 2;
while (x1 < x0)
{
x0 = x1;
x1 += n / x0;
x1 /= 2;
}
return x0;
}
BigInt
gcd (const BigInt &X, const BigInt &Y)
{
BigInt x (X);
BigInt y (Y);
for (;;)
{
if (y.is_zero())
return x;
x %= y;
if (x.is_zero())
return y;
y %= x;
}
}
// Modular inverse, see [1] p.35
// Returns i in range 1..m-1 such that i*a = 1 mod m.
// a must be in range 1..m-1.
BigInt
modinv (const BigInt &a, const BigInt &m)
{
BigInt j (1), i (0);
BigInt b (m), c (a);
BigInt x, y;
while (!c.is_zero())
{
BigInt::div (b, c, x, y);
b = c;
c = y;
y = j;
// j = i - j * x; trading clarity for efficiency.
j *= x;
j -= i;
j.negate();
i = y;
}
if (i.is_negative())
i += m;
return i;
}
|
b2073de98078c8764ffc9d2e57f05b0125cfca1d | a3effde3c27c072090f0021bdae3306961eb2d92 | /Codeforces/433/B.cpp | 97f1c0ae0ee9c68874b88926b72e9e4f8b2e356a | [] | no_license | anmolgup/Competitive-programming-code | f4837522bf648c90847d971481f830a47722da29 | 329101c4e45be68192715c9a0718f148e541b58b | refs/heads/master | 2022-12-03T19:00:40.261727 | 2020-08-08T09:21:58 | 2020-08-08T09:21:58 | 286,011,774 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,669 | cpp | B.cpp | /*
Author:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% ANMOL GUPTA %%%%%%%%
%%%%%%%% NIT HAMIRPUR %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define pb push_back
#define debug(x) cout<<'>'<<#x<<" : "<<x<<endl;
#define mp make_pair
#define ff first
#define ss second
#define allunique(v) v.erase(unique(v.begin(),v.end()),v.end());
#define MOD 1000000007
#define MOD9 1000000009
#define th(n) cout<<n<<endl
#define gc getchar_unlocked
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define bolt ios::sync_with_stdio(0)
#define forr(i,n) for(ll i=0;i<n;i++)
#define eof (scanf("%d" ,&n))!=EOF
#define PI acos(-1.0)
#define all(v) v.begin(),v.end()
#define endl "\n"
typedef long long ll;
typedef double db;
typedef long long ll;
typedef pair< ll, ll > pll;
typedef vector< ll > vll;
typedef map< ll, ll > mll;
typedef set< ll > sll;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//printf("%I64d", n)
ll n,m,l,r,type;
cin>>n;
ll arr[n + 1];
ll brr[n + 1];
ll query1[n+4];
ll query2[n+4];
query1[0] = query2[0] = 0;
for(int i = 0;i<n;i++)
{
cin>>arr[i];
brr[i] = arr[i];
}
sort(brr,brr+n);
for(int i = 1;i<=n;i++)
{
query1[i] = query1[i-1] + arr[i-1];
query2[i] = query2[i-1] + brr[i-1];
}
// query2[n] = query2[n-1] + brr[n-1];
// cout<<brr[n-1];
// for(int i = 0;i<=n;i++)
// cout<<query2[i]<<endl;
cin>>m;
while(m--)
{
cin>>type>>l>>r;
if(type == 1)
cout<<query1[r] - query1[l-1]<<endl;
else
cout<<query2[r] - query2[l-1]<<endl;
}
} |
2886fa83b0952e3ede1b686a34b7d73035862e24 | 3a629a12e5db0c959d0eaf360c9bac6ec7340f08 | /src/ofApp.cpp | d9f35a3033f352db80757a258afa089c837e35ef | [] | no_license | rhodso/2DTileEngine | 89b2843124c6c15aefef200d0d62756bd3c688c2 | 6be88f7e6c52fef3cb10fe6d9ef89b026ae218d9 | refs/heads/main | 2023-01-05T20:20:56.006305 | 2020-11-04T11:05:41 | 2020-11-04T11:05:41 | 309,955,563 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,258 | cpp | ofApp.cpp | #include "ofApp.h"
void ofApp::setup(){
//Setup variables
srand (time(NULL));
grid::setDoUpdate(true);
debugger::setDebug(debug);
//Log that app has started
debugger::log("App started");
//Setup game vars
frameCount = 0;
//Setup grid vars
g.setGH(10);
g.setGW(10);
g.autoSize();
g.setLineColour(ofColor::fromHex(0xCCCCCC));
g.createGrid();
//Setup completed, log
debugger::log("Setup complete");
}
void ofApp::update(){}
void ofApp::draw(){
g.drawGrid();
}
void ofApp::handleKeypresses(){}
void ofApp::keyPressed(int key){
//Log key press
std::string msg = "Key "; msg += key; msg += "("; msg += std::to_string(key); msg += ")"; msg += " pressed on frame "; msg += std::to_string(frameCount);
debugger::log(msg);
//Show specified key as being pressed
keys[key] = true;
}
//Not used
void ofApp::keyReleased(int key){}
void ofApp::mouseMoved(int x, int y ){}
void ofApp::mouseDragged(int x, int y, int button){}
void ofApp::mousePressed(int x, int y, int button){}
void ofApp::mouseReleased(int x, int y, int button){}
void ofApp::mouseEntered(int x, int y){}
void ofApp::mouseExited(int x, int y){}
void ofApp::windowResized(int w, int h){}
void ofApp::gotMessage(ofMessage msg){}
void ofApp::dragEvent(ofDragInfo dragInfo){}
|
909fddd2fe8ea08fe6bf537e2587e2ca6ff26ecd | 7b653eac7ec1c789b7c5ca4e00499fcb9b0e5fed | /include/PlayState.cpp | 657047f4523f5e6dc83be718a6a467247f105dcc | [] | no_license | pk400/lets-play-outside | 0bc7af9c9e4b351070665ae4f93328d33b8e5fc2 | 619daa3293fcd320b17146e9a81a3ca2bf8dcd48 | refs/heads/master | 2020-04-14T08:45:46.636888 | 2015-09-12T02:55:00 | 2015-09-12T02:55:00 | 41,830,338 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 621 | cpp | PlayState.cpp |
#include "states/PlayState.hpp"
PlayState::PlayState() {
world = new World(0);
// TODO: change this to player position
camera = new Camera(sf::Vector2f(400.f, 120.f), sf::Vector2f(800 / 1.5, 480 / 1.5f));
player = new Player();
player->setGameObject("assets/sprites/spritesheet.png");
}
int PlayState::handleInput() {
return player->handleInput();
}
void PlayState::update(float deltatime) {
player->update(deltatime);
}
void PlayState::render(sf::RenderWindow& gamewindow) {
world->render(gamewindow);
player->render(gamewindow);
//gamewindow.setView(camera->getView());
}
|
c2069f4277c0615d5be52d3ded1f3617c0ede2f9 | a6c31b3a566c19fdac30a571899448ae9199adb8 | /simplification.h | cf491c6e976d032b6ddfbbef1eca6e5cdd4a7d60 | [] | no_license | pratikhada/differentiator | 8e538f595a2bc12e2c6a04ae5a0a68cd4fa84973 | 1ae1009d1d0284a437f49f1d41ab74e6b5f926fe | refs/heads/master | 2021-06-11T10:44:22.919675 | 2017-03-01T04:17:34 | 2017-03-01T04:17:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 974 | h | simplification.h | #ifndef SIMPLIFICATION_H_
#define SIMPLIFICATION_H_
class mani_string
{
private:
bool next_simp;
int intdata[1000];
bool invert_sign;
float floatdata[1000];
char argu_ment[500];
char input[1000],operate[1000];
public:
class error1 {};
class error2 {};
int remove_outermost_brace(char ch[]);
void insert(char [],int ,int );
void calc_pow();
void mult_signs();
int pos_pre_float(int c_pos);
int pos_post_char(int c_pos);
void num_to_char(char [],int ,int &);
void make_string();
void separate_int_char();
void separate_float_char();
void div_mult();
void simplify_floats();
void simplifying(char []);
void simplification(char []);
int term_in_braces(char [],char [],int &, int &);
bool remove_braces();
int read_expression();
void simplify();
void show_result();
void rep_x(char [], float);
};
#endif
|
f94f50ac068a38af4678403bed0588883319cab6 | 3200032af3ad5d95817028a52d296d632867355e | /src/Display.h | 60450ae2e2b0e1947c950e2cb03ce75313f913e1 | [] | no_license | florianbrede-ayet/oldcars-combined-ecu | 84627eb5a650d63b104c2252923a6559d768296a | 7f6864fee7113048a1dec6497b1db50323fb1c22 | refs/heads/master | 2022-11-18T16:34:36.303695 | 2020-07-09T09:41:36 | 2020-07-09T09:41:36 | 272,831,666 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,470 | h | Display.h | /*
Display.h - Library to control a ST7565 based 12864 LCD.
Thomas Baum, th.baum@online.de, 10.05.2014
*/
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class Display {
public:
static const byte WIDTH = 128;
static const byte HEIGHT = 64;
Display() {}
void init(byte contrast);
void initI2C(byte contrast);
void writeCommand(byte command);
void writeData(byte data);
void resetRamAddress(void);
void setPageAddress(byte pageAddress);
void setColumnAddress(byte columnAddress);
void clearDisplayRAM(void);
void clearVideoBuffer(void);
void drawPixel(byte x, byte y);
void drawLine(byte x1, byte y1, byte x2, byte y2);
void drawRect(byte x1, byte y1, byte x2, byte y2);
void clearRect(byte x1, byte y1, byte x2, byte y2);
void drawString(byte x, byte y, const char string[]);
void drawBitmapOffset(byte x, byte y, byte renderWidth, byte renderHeight, byte offX, byte offY, byte width, byte height, const byte *bitmap);
void drawBitmap(byte x, byte y, byte width, byte height, const byte bitmap[]);
void drawEllipse(byte x, byte y, byte a, byte b);
void show();
void fillRoundRect(int16_t x, int16_t y, int16_t w,
int16_t h, int16_t r, uint16_t color);
void drawStringAdvanced(byte x, byte y, byte size, boolean inverted, const char *c);
private:
boolean isSoftSPI;
};
#endif
|
4537aa27544c64d135fbeece88dd96fa95d30d18 | b2af0aab412c7492166327d4043c6fc2cdde2ccd | /llvm/lib/Target/RV16K/TargetInfo/RV16KTargetInfo.cpp | fe24a705d482811dfe4328e4867ea66aabc9a4e9 | [
"Apache-2.0",
"NCSA"
] | permissive | virtualsecureplatform/llvm-rv16k | afc14550cbbbd0a18c4254a36d07f156767451c4 | 0ebfe53bee6936e673dadb86e4dcc451ab828022 | refs/heads/rv16k | 2020-08-06T14:26:50.916085 | 2019-10-05T09:52:56 | 2019-10-05T09:52:56 | 212,962,679 | 1 | 0 | null | 2019-10-05T07:54:48 | 2019-10-05T07:44:54 | null | UTF-8 | C++ | false | false | 593 | cpp | RV16KTargetInfo.cpp | // This file is copied and modified from The LLVM Compiler Infrastructure, which
// is distributed under the University of Illinois Open Source License (see
// LICENSE.TXT for details). This file is licensed under the same license.
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
namespace llvm {
Target &getTheRV16KTarget() {
static Target TheRV16KTarget;
return TheRV16KTarget;
}
} // namespace llvm
extern "C" void LLVMInitializeRV16KTargetInfo() {
RegisterTarget<Triple::rv16k> X(getTheRV16KTarget(), "rv16k", "RV16K",
"RV16K");
}
|
95cf54315c066a48a83616bb0e13079290644c59 | 11336b8a10d91307e99f6a8bd70674a04ce92c82 | /PTPCore.hpp | c1934c52152e480ae07b5d6219d094f3157202d4 | [] | no_license | herryoo95/ptp | 93770fba9081dd8fa0f7fa808bf02dd129ddc040 | 41f78aa13b96b92c57275fc5a8c397545d9152a3 | refs/heads/master | 2020-04-02T07:55:29.406218 | 2016-07-16T08:23:14 | 2016-07-16T08:23:14 | 63,412,327 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,713 | hpp | PTPCore.hpp | /*
* Copyright 2015, DFKI GmbH Robotics Innovation Center
*
* This file is part of the PTP(Plastic Terramechanics Particle).
*
* Author: Dr. -Ing. Yong-Ho Yoo
*
*/
#ifndef __PTPCORE_H__
#define __PTPCORE_H__
#include <stdio.h>
#include "PTPUtil.hpp"
#include <math.h>
#include <stdlib.h>
#define MM2M 0.001
#define M2MM 1000
#define SPHERE 0
//#define CYLINDER 1
//#define CUBE 2
#define NOT 0
//#define GOLINE 1024
//#define FEATURE_POINT 512
#define ERR -1
#define FINE 1
#define FAST 2
#define START 1
#define END 2
#define PTP_START 4
#define PTP_END 8
//#define MOST_UPPER 0
//#define MOST_CONTAIN 1
///SPHARE
#define IS_ON 1
#define IS_IN 256
///COLLISION
#define NOT_COLLISION 0
#define COLLISION -1
namespace mars {
namespace sim {
typedef struct FOOT{
vecD loc; ///[mm*MAG]
// vecD acc; ///[mm*MAG/s^2]
vecD vel; ///[mm*MAG/s]
// vecD avel; ///[rad/s]
int type; ///SPHERE
double r; ///[mm*MAG]
// double l; ///[mm*MAG]
// double d; ///[mm*MAG]
// double mass;
bool contact;
} FOOT;
typedef struct PTP{
vecD start; ///[mm*MAG]
vecD end; ///[mm*MAG]
vecN n; ///[]
vecD cellScale;
vecD test;
vecD start_loc; /// to calculate dip. of lateral
int lateral;
double plane_a,plane_b,plane_c,plane_d;
} PTP;
typedef struct CELL {
vecD start; ///[mm*MAG]
vecD end; ///[mm*MAG]
vecD center;
vecD averageLoc; /** average location of particles collided with object */
unsigned int CollisionParticleNum;
unsigned int particleNum;
} CELL;
typedef struct PARTICLE {
vecD loc; ///[mm*MAG]
vecN cloc; ///[]
int isCollision;
} PARTICLE;
class PTPCore{
public:
PTPCore(int x, int y, int z);
~PTPCore();
bool AABBCollision(CELL* pAABB1, CELL* pAABB2);
bool calcForce(FOOT* foot, const int type, vecD* forceR);
bool initializePTP(const vecN *n,const vecD *s,const vecD *e);
int particleWorks(const vecN* particleN,const FOOT* foot, const FOOT* lastFootLoc, const int pLocData);
int ptpWorks(const FOOT* foot,const FOOT* lastFoot);
vecD particleMovement(const vecD* point,const FOOT* foot);
vecN getComputeNeededCellNum(const FOOT* foot, const int type);
int getSumOfParticlesNum();
int particleCollisionDetect(const FOOT* foot, const PARTICLE* particle);
bool PTPCollisionDetectOne(const FOOT* foot);
int cellCollisionDetectVertex(const FOOT* foot, const vecN* cellN);
int cellCollisionDetectLine(const FOOT* foot, const vecN* cellN);
double lookupTable(const CELL* cell);
double shearStress(const double disp, const double pressure);
double getArea(const CELL* cell,const int direction);
vecD getCellSize();
double determinePlanePointLoc(const vecD n, const double d, const vecD p);
vecD getFeaturePoint(const FOOT* foot, const vecD cellcenter);
int isInASphere(const FOOT* foot, const vecD* point);
vecD getOriginalParticlePosition(const vecN n);
int getIntersectionNumLineSphere(const vecD* LineStart, const vecD* LineEnd, const vecD* SphereCenter, const double* SphereRadius);
int cellCollisionFeaturePoint(const FOOT* foot, const vecN* cellN);
vecD getFootAABBBound(const FOOT* foot, const int type);
vecN judgeWhichCell(const vecD* loc);
double getVolume(const CELL* cell);
double getLength(const CELL* cell, const int type);
PTP ptp;
PTPUtil* ptputil;
PARTICLE*** particle;
CELL*** cell;
char filenameCALC[150];
vecN LOOPSTART;
vecN LOOPEND;
FILE *outCALC;
vecN ptpsize;
private:
};
} // end of namespace sim
} // end of namespace mars
#endif // __PTPCORE_H__
|
e2f97485771d91c983c59d428433a8e3895b74ce | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5769900270288896_0/C++/Kumarajiva/b.cpp | 4fcf866e691bd3b6d504939e34a04e8dda23a562 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,061 | cpp | b.cpp | #include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a[20][20];
int n,m,k,ca,cas,x,i,j,ans,t,xx;
int Check(int x){
int c;
c=0;
while (x){
if (x % 2) c++;
x>>=1;
}
return c;
}
int main(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d",&cas);
for (ca=1;ca<=cas;ca++){
scanf("%d%d%d",&n,&m,&k);
ans=999999;
for (x=0;x<(1<<(n*m));x++)
if (Check(x)==k){
// printf("!");
memset(a,0,sizeof(a));
xx=x;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++){
if (xx % 2) a[i][j]=1;
xx>>=1;
}
t=0;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
if (a[i][j]){
if (a[i-1][j]) t++;
if (a[i+1][j]) t++;
if (a[i][j-1]) t++;
if (a[i][j+1]) t++;
}
ans=min(ans,t);
}
printf("Case #%d: %d\n",ca,ans/2);
}
return 0;
}
|
8b643195faa54bbfd840a43f43511c2ccd1a2c65 | 75c8829a839e11579c5efc549fcfa488ba473a44 | /exercise 6.cpp | 0a76648b6f214e0537eaf0626bf785f4a0ede54a | [] | no_license | JackMeagher01/AP-Module-C-Monday-Exercises | 81765b207f0178fe10231c741e8a94549e401ec8 | 3319cdbf2af4452130247571f985ce5a67b00d1f | refs/heads/main | 2023-02-16T12:19:18.210791 | 2021-01-11T23:22:48 | 2021-01-11T23:22:48 | 328,655,086 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,738 | cpp | exercise 6.cpp | //
// Public Link - https://repl.it/@Meagher01/Karvonen-Heart-Rate-Calculator#main.cpp
// Invite Link - https://repl.it/join/ahwsehgq-meagher01
//
#include <iostream>
using namespace std;
int getAge() {
int age;
cout << "Please enter your age: ";
cin >> age;
return age;
}
int getRestingHeartRate() {
int pulse;
cout << "Please enter your resting pulse: ";
cin >> pulse;
return pulse;
}
bool isValidInput() {
if (cin.fail()) {
cout << "Please enter a valid age.\n" << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return false;
}
return true;
}
void displayInputs(int age, int pulse) {
cout << "Resting Pulse: " << pulse << "\tAge: " << age << endl;
cout << "\nIntensity\tRate\n--------------------"<< endl;
}
int calculateHeartRate(int age, int pulse, float intensity) {
return (((220-age) - pulse) * intensity) + pulse;
}
int * getTargetHeartRates(int age, int pulse) {
static int heartRates[12];
int size = sizeof(heartRates) / sizeof(*heartRates);
for (int i = 0; i < size; i++) {
float intensity = 0.4 + (0.05 * i);
heartRates[i] = calculateHeartRate(age, pulse, intensity);
}
return heartRates;
}
void displayTargetRates(int * pTargetHeartRates) {
int *targetHeartRates = pTargetHeartRates;
int size = sizeof(*pTargetHeartRates) + sizeof(pTargetHeartRates);
for (int i = 0; i < 12; i++) {
cout << (0.4 + (0.05 * i)) * 100 << "\t\t\t" << targetHeartRates[i] << endl;
}
}
int main() {
int age;
do {
age = getAge();
} while (!isValidInput());
int pulse;
do {
pulse = getRestingHeartRate();
} while (!isValidInput());
displayInputs(age, pulse);
displayTargetRates(getTargetHeartRates(age, pulse));
}
|
d30b64265c6a7afcc5b31d03c2a1ce8d6e10d0c9 | c1b03b59b3974058e3dc4e3aa7a46a7ab9cc3b29 | /src/module-wx/Class_wx_TaskBarIcon.h | 2eda741e550ea288ad96cda204652bdf79b676fd | [] | no_license | gura-lang/gura | 972725895c93c22e0ec87c17166df4d15bdbe338 | 03aff5e2b7fe4f761a16400ae7cc6fa7fec73a47 | refs/heads/master | 2021-01-25T08:04:38.269289 | 2020-05-09T12:42:23 | 2020-05-09T12:42:23 | 7,141,465 | 25 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,748 | h | Class_wx_TaskBarIcon.h | //----------------------------------------------------------------------------
// wxTaskBarIcon
// extracted from taskbar.tex
//----------------------------------------------------------------------------
#ifndef __CLASS_WX_TASKBARICON_H__
#define __CLASS_WX_TASKBARICON_H__
Gura_BeginModuleScope(wx)
//----------------------------------------------------------------------------
// Class declaration for wxTaskBarIcon
//----------------------------------------------------------------------------
Gura_DeclareUserClass(wx_TaskBarIcon);
//----------------------------------------------------------------------------
// Object declaration for wxTaskBarIcon
//----------------------------------------------------------------------------
class Object_wx_TaskBarIcon : public Object_wx_EvtHandler {
public:
Gura_DeclareObjectAccessor(wx_TaskBarIcon)
public:
inline Object_wx_TaskBarIcon(wxTaskBarIcon *pEntity, GuraObjectObserver *pObserver, bool ownerFlag) :
Object_wx_EvtHandler(Gura_UserClass(wx_TaskBarIcon), pEntity, pObserver, ownerFlag) {}
inline Object_wx_TaskBarIcon(Class *pClass, wxTaskBarIcon *pEntity, GuraObjectObserver *pObserver, bool ownerFlag) :
Object_wx_EvtHandler(pClass, pEntity, pObserver, ownerFlag) {}
virtual ~Object_wx_TaskBarIcon();
virtual Object *Clone() const;
virtual String ToString(bool exprFlag);
inline wxTaskBarIcon *GetEntity() {
return dynamic_cast<wxTaskBarIcon *>(_pEntity);
}
inline wxTaskBarIcon *ReleaseEntity() {
wxTaskBarIcon *pEntity = GetEntity();
InvalidateEntity();
return pEntity;
}
inline bool IsInvalid(Signal &sig) const {
if (_pEntity != nullptr) return false;
SetError_InvalidWxObject(sig, "wxTaskBarIcon");
return true;
}
};
Gura_EndModuleScope(wx)
#endif
|
e768cffe527d2f5d0037645f0da98b51f7a974a4 | 24e6244e4268c5a93781c85d6a2d29d2b195a5ba | /Logic_Gate/Logic_Gate.cpp | e73a4792ef6e048ed438705aca3071838c76a279 | [] | no_license | a121529392/Compiler | f96add0aa3a3613fa831ee9c61e1cafdf7c6bf7d | cc7d546e65baf7987fa253bf12b7d43fa3790799 | refs/heads/master | 2020-03-07T19:32:32.911297 | 2018-04-01T21:51:37 | 2018-04-01T21:51:37 | 127,673,655 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,170 | cpp | Logic_Gate.cpp | #include<iostream>
#include<vector>
#include<string>
using namespace std;
struct ans{
string num;
int value;
string buff;
string in[2];
};
void del(vector<string> &a,int n){
for (int i = 0; i < a[n].size(); i++){
if (a[n][i] == '='){
return;
}
if (a[n][i] == '(' || a[n][i] == ')' ){
a[n].erase(a[n].begin()+i);
i--;
}
if (a[n][i] == '#'){
a[n].clear();
}
}
}
void assignin(vector<string> &a, int n, vector<string> &ip){
string in = "INPUT";
for (int i = 0; i < in.size(); i++){
if (a[n][i] != in[i]){
return;
}
}
a[n].erase(a[n].begin(), a[n].begin() + in.size());
ip.push_back(a[n]);
}
void assignout(vector<string> &a, int n, vector<string> &op){
string in = "OUTPUT";
for (int i = 0; i < in.size(); i++){
if (a[n][i] != in[i]){
return;
}
}
a[n].erase(a[n].begin(), a[n].begin() + in.size());
op.push_back(a[n]);
}
void Buffer(vector<string> a, int n, ans *&result,int &num){
//cout << num<<endl;
if (a[n] == ""){
return;
}
int i = 0;
int count = 0;
for (int j = 0; j < a[n].size(); j++){
if (a[n][j] != '='){
count++;
}
if (count == a[n].size()){
return;
}
}
for (; a[n][i]!='='; i++){
result[num].num.push_back(a[n][i]);
}
result[num].num.erase(result[num].num.end()-1);
i++;
for (int j=0; a[n][i] != '(';j++, i++){
result[num].buff.push_back(a[n][i]);
}
i++;
for (int b = 0; b < a[n].size(); b++){
if (a[n][b] == ','){
for (int j = 0; a[n][i] != ','; j++, i++){
result[num].in[0].push_back(a[n][i]);
}
break;
}
if (a[n][b] == ')'){
for (int j = 0; a[n][i] != ')'; j++, i++){
result[num].in[0].push_back(a[n][i]);
}
break;
}
}
if (a[n][i] == ','){
i++;
for (int j = 0; a[n][i] != ')'; j++, i++){
result[num].in[1].push_back(a[n][i]);
}
result[num].in[1].erase(result[num].in[1].begin());
}
num++;
}
void cal(ans *&result, int num,int in){
if (result[num].buff == " NOT"){
result[num].value = !in;
}
if (result[num].buff == " BUFF"){
result[num].value = in;
}
}
void cal2(ans *&result, int num, int in,int in2){
if (result[num].buff == " AND"){
result[num].value = in & in2;
}
if (result[num].buff == " NAND"){
result[num].value = !(in & in2);
}
if (result[num].buff == " OR"){
result[num].value = in | in2;
}
if (result[num].buff == " NOR"){
result[num].value = !(in | in2);
}
if (result[num].buff == " XOR"){
result[num].value = in ^ in2;
}
if (result[num].buff == " NXOR"){
result[num].value = !(in ^ in2);
}
}
int main(){
int get=0;
string in;
vector<string> input;
while (getline(cin,in)){
input.push_back(in);
}
//cout << get << endl;
vector<string> ip;
vector<string> op;
ans *result;
result = new ans[input.size()];
int num = 0;
//cout << input.size();
for (int i = 0; i < input.size(); i++){
del(input, i);
assignin(input, i, ip);
assignout(input, i, op);
Buffer(input, i, result, num);
//cout << result[num].num << endl;
}
ans *inp;
inp = new ans[ip.size()];
ans *outp;
outp = new ans[op.size()];
for (int i = 0; i < op.size(); i++){
outp[i].num = op[i];
}
for (int i = 0; i < ip.size(); i++){
inp[i].num = ip[i];
}
for (; get < 2; get++){
for (int i = 0; i < num; i++){
result[i].value = -1;
}
for (int i = 0; i < ip.size(); i++){
inp[i].value = get;
}
for (int i = num, j = 0; i < num + ip.size(), j < ip.size(); i++, j++){
result[i] = inp[j];
}
vector<string> check;
for (int i = 0; i < num; i++){
check.push_back(result[i].num);
}
while (!check.empty()){
int cc = 0;
for (int i = 0; i < num + ip.size(); i++){
if (check[check.size() - 1] == result[i].num){
if (result[i].value != -1){
check.pop_back();
cc++;
}
if (cc != 0){
break;
}
if (result[i].in[1] == ""){
for (int x = 0; x < num + ip.size(); x++){
if (result[i].in[0] == result[x].num){
if (result[x].value != -1){
cal(result, i, result[x].value);
check.pop_back();
cc++;
break;
}
else{
check.push_back(result[x].num);
cc++;
break;
}
}
}
}
if (result[i].in[1] != ""){
for (int x = 0; x < num + ip.size(); x++){
if (result[i].in[0] == result[x].num){
if (result[x].value != -1){
for (int b = 0; b < num + ip.size(); b++){
if (result[i].in[1] == result[b].num){
if (result[b].value != -1){
cal2(result, i, result[x].value, result[b].value);
check.pop_back();
cc++;
break;
}
else{
check.push_back(result[b].num);
cc++;
break;
}
}
}
}
else{
check.push_back(result[x].num);
cc++;
break;
}
}
if (cc != 0){
break;
}
}
}
}
if (cc != 0){
break;
}
}
}
for (int j = 0; j < op.size(); j++){
for (int i = 0; i < num + ip.size(); i++){
if (op[j] == result[i].num){
cout << result[i].value;
}
}
}
cout << endl;
}
} |
0c7e88cfeaa6c03460e5364ee9e9d10fa17d7380 | 8167ad02f92660d8307f95d664d385e123230fbd | /Week 1: April 1st–April 7th/Maximum Subarray/Solution.cpp | fc7dab00032aa62c9d9e2ac09ebf1be39cd94bb9 | [] | no_license | Turing551/30-Day-LeetCoding-Challenge | 22d024538520af6c066bb31d63527fa6b5c552b1 | 3c174b586506bc115b2198ad9e98b897d361b129 | refs/heads/master | 2022-04-17T07:05:40.587596 | 2020-04-12T07:46:54 | 2020-04-12T07:46:54 | 254,844,992 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 396 | cpp | Solution.cpp | class Solution {
public:
int maxSubArray(vector<int>& nums){
int x=0,y=0;
bool check=true;
for(const int& num : nums){
y+=num;
if(y<0){
y=0;
}if(y>x){
x=y;
check=false;
}
}
return (check) ? *max_element(nums.begin(), nums.end()) : x;
}
};
|
f29dbcd921d3e7458ab50e56cd807fa70a5c8ea2 | 47a765a596da856d749b98cc671562484f98ac06 | /aud-rnd/test/TestPlayer.cpp | 2d46c5d0fee958b19373494449df0167572ac558 | [] | no_license | dlxqlig/xmbc_audio_engine | 34807acb016afe0d2bffdac614d60d091ac16263 | c4bcae9a52fd56afa5e0bed0989a9f0fae16f5b7 | refs/heads/master | 2021-01-20T00:56:38.175305 | 2014-01-28T12:28:58 | 2014-01-28T12:28:58 | 16,304,718 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 12,664 | cpp | TestPlayer.cpp | /*
* Copyright (C) 2010-2013 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
* You can also contact with mail(dlxqlig@gmail.com)
*/
extern "C" {
#ifndef INT64_C
#define INT64_C
#define UINT64_C
#endif
#define INT64_C(val) val##64
#define _64BITARG_ "I64"
#define PRId64 _64BITARG_"d"
#define PRIu64 -64BITARG_"u"
#include <math.h>
#include <libavutil/opt.h>
#include <libavcodec/avcodec.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/imgutils.h>
#include <libavutil/mathematics.h>
#include <libavutil/samplefmt.h>
#include <libavutil/imgutils.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
}
#include "AudRender.h"
#include "AudStream.h"
#include "AudFormat.h"
#include "AudChInfo.h"
using namespace AudRender;
static AVFormatContext *fmt_ctx = NULL;
static AVCodecContext *audio_dec_ctx;
static AVStream *audio_stream = NULL;
static const char *src_filename = NULL;
static int audio_stream_idx = -1;
static AVFrame *frame = NULL;
static AVPacket pkt;
static int audio_frame_count = 0;
static CAudRender* render = NULL;
static CAudStream* stream = NULL;
static bool start_stream = false;
pthread_t thread_h;
struct SwrContext* sw_convert = NULL;
unsigned char* convert_buffer = NULL;
const size_t convert_buffer_size = 288000 * 2 + FF_INPUT_BUFFER_PADDING_SIZE;
static void* write_audio_frames_render(void* pcontext)
{
printf("@@@@@@write_audio_frames_render start\n");
convert_buffer = (unsigned char*)malloc_aligned(convert_buffer_size, 16);
memset(convert_buffer, 0, convert_buffer_size);
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
unsigned int space = stream->GetSpace();
while(1) {
if (av_read_frame(fmt_ctx, &pkt) >= 0) {
AVPacket orig_pkt = pkt;
if (pkt.stream_index != audio_stream_idx) {
av_free_packet(&orig_pkt);
continue;
}
do {
int got_frame;
int ret = avcodec_decode_audio4(audio_dec_ctx, frame, &got_frame, &pkt);
if (ret < 0) {
fprintf(stderr, "Error decoding audio frame\n");
break;
}
printf("Decode(%p,%d) planar[%d] len=%d format=%d(%d) samples=%d linesize=%d,%d,%d,%d,%d,%d,%d,%d date=%p,%p,%p,%p,%p,%p,%p,%p edata=%p,%p,%p,%p,%p,%p,%p,%p\n",
pkt.data, pkt.size, av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt), ret,
0, (int)frame->format,
(int)frame->nb_samples,
frame->linesize[0],
frame->linesize[1],
frame->linesize[2],
frame->linesize[3],
frame->linesize[4],
frame->linesize[5],
frame->linesize[6],
frame->linesize[7],
frame->data[0],
frame->data[1],
frame->data[2],
frame->data[3],
frame->data[4],
frame->data[5],
frame->data[6],
frame->data[7],
frame->extended_data[0],
frame->extended_data[1],
frame->extended_data[2],
frame->extended_data[3],
frame->extended_data[4],
frame->extended_data[5],
frame->extended_data[6],
frame->extended_data[7]);
if (got_frame) {
int linesize1, linesize2;
size_t data_size1 = av_samples_get_buffer_size(&linesize1, audio_dec_ctx->channels, frame->nb_samples, audio_dec_ctx->sample_fmt, 1);
size_t data_size2 = av_samples_get_buffer_size(&linesize2, audio_dec_ctx->channels, frame->nb_samples, AV_SAMPLE_FMT_FLT, 1);
bool is_planar = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt);
size_t unpadded_linesize = frame->nb_samples * (av_get_bytes_per_sample((AVSampleFormat)frame->format))*audio_dec_ctx->channels;
printf("audio_frame n:%d data_size1 %d nb_samples:%d pts:%s planar:%d\n",
audio_frame_count++, data_size1, frame->nb_samples,
av_ts2timestr(frame->pts, &audio_dec_ctx->time_base), is_planar);
printf("ch[%d] format:%d data_size1:%d data_size2:%d linesize1:%d linesize2:%d nb_samples %d ret %d unpadded_linesize[%d]\n",
audio_dec_ctx->channels, audio_dec_ctx->sample_fmt, data_size1, data_size2,
linesize1, linesize2, frame->nb_samples, ret, unpadded_linesize);
int size_tmp;
if (is_planar) {
size_tmp = data_size2;
}
else {
size_tmp = unpadded_linesize;
}
unsigned int added = 0;
while (size_tmp > 0) {
space = stream->GetSpace();
unsigned int samples = std::min((unsigned int)size_tmp, space);
if (!samples) {
//printf("####there is no space \n");
sleep(0.1);
continue;
}
printf("####unpadded_linesize[%d] data_size1[%d] space[%d], samples[%d] \n",
unpadded_linesize, data_size1, space, samples);
if (is_planar) {
if (!sw_convert) {
//printf("#### channels[%d] sample_fmt[%d] sample_rate[%d] \n", audio_dec_ctx->channels, audio_dec_ctx->sample_fmt, audio_dec_ctx->sample_rate);
sw_convert = swr_alloc_set_opts(NULL,
av_get_default_channel_layout(audio_dec_ctx->channels),
AV_SAMPLE_FMT_FLT,
audio_dec_ctx->sample_rate,
av_get_default_channel_layout(audio_dec_ctx->channels),
audio_dec_ctx->sample_fmt,
audio_dec_ctx->sample_rate,
0, NULL);
}
if (!sw_convert || swr_init(sw_convert) < 0) {
printf("####failed to swr_init.\n");
break;
}
unsigned char *out_planes[]={convert_buffer + 0 * linesize2,convert_buffer + 1 * linesize2, convert_buffer + 2 * linesize2,
convert_buffer + 3 * linesize2, convert_buffer + 4 * linesize2, convert_buffer + 5 * linesize2, convert_buffer + 6 * linesize2,
convert_buffer + 7 * linesize2,
};
if (swr_convert(sw_convert, out_planes, frame->nb_samples, (const uint8_t**)frame->data, frame->nb_samples) < 0) {
printf("####failed to sw_convert.\n");
break;
}
added = stream->AddData(convert_buffer, data_size2);
//printf("####AddData [%d].\n", added);
}
else
{
added = stream->AddData(frame->extended_data[0], samples);
}
size_tmp -= added;
}
}
pkt.data += ret;
pkt.size -= ret;
} while (pkt.size > 0);
av_free_packet(&orig_pkt);
}else{
break;
}
}
return (void*)0;
}
static int open_codec_context(int *stream_idx,
AVFormatContext *fmt_ctx, enum AVMediaType type)
{
int ret;
AVStream *st;
AVCodecContext *dec_ctx = NULL;
AVCodec *dec = NULL;
ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
if (ret < 0) {
printf("failed to find %s stream in input file '%s'\n",
av_get_media_type_string(type), src_filename);
return ret;
} else {
*stream_idx = ret;
st = fmt_ctx->streams[*stream_idx];
dec_ctx = st->codec;
dec = avcodec_find_decoder(dec_ctx->codec_id);
if (!dec) {
printf("failed to find %s codec\n", av_get_media_type_string(type));
return ret;
}
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
printf("failed to open %s codec\n", av_get_media_type_string(type));
return ret;
}
}
return 0;
}
int main (int argc, char **argv)
{
int ret = 0;
AudDataFormat format = AUD_FMT_S16LE;
int sample_rate = 8000;
int encoded_sample_rate = 0;
CAudChInfo ch_info(CH_LAYOUT_2_0);
CAudChInfo ch_info_6(CH_LAYOUT_5_1);
CAudChInfo ch_info_8(CH_LAYOUT_7_1);
if (argc != 2) {
printf("pls input media file.\n");
exit(1);
}
src_filename = argv[1];
render = new CAudRender();
if (!render) {
printf("failed to create AudRender.\n");
goto end;;
}
render->Initialize();
av_register_all();
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
fprintf(stderr, "failed to avformat_open_input %s\n", src_filename);
exit(1);
}
if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
fprintf(stderr, "faied to avformat_find_stream_info\n");
exit(1);
}
if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
audio_stream = fmt_ctx->streams[audio_stream_idx];
audio_dec_ctx = audio_stream->codec;
}
av_dump_format(fmt_ctx, 0, src_filename, 0);
if (!audio_stream ) {
printf("failed to av_dump_format.\n");
ret = 1;
goto end;
}
switch (audio_dec_ctx->sample_fmt) {
case AV_SAMPLE_FMT_S16:
format = AUD_FMT_S16LE;
break;
case AV_SAMPLE_FMT_S16P:
format = AUD_FMT_S16LE;
break;
case AV_SAMPLE_FMT_S32:
format = AUD_FMT_S32LE;
break;
case AV_SAMPLE_FMT_FLT:
format = AUD_FMT_FLOAT;
break;
case AV_SAMPLE_FMT_FLTP:
format = AUD_FMT_FLOAT;
break;
default:
printf("wrong sample format[%d].\n", audio_dec_ctx->sample_fmt);
ret = 1;
goto end;
}
if (audio_dec_ctx->channels == 6) {
ch_info = ch_info_6;
}
else if (audio_dec_ctx->channels == 8) {
ch_info = ch_info_8;
}
sample_rate = audio_dec_ctx->sample_rate;
stream = render->MakeStream(format, sample_rate, encoded_sample_rate, ch_info, AUDSTREAM_PAUSED);
if (!stream){
printf("failed to create stream.\n");
goto end;
}
frame = avcodec_alloc_frame();
if (!frame) {
fprintf(stderr, "failed to avcodec_alloc_frame\n");
ret = AVERROR(ENOMEM);
goto end;
}
if (!start_stream) {
stream->Resume();
}
pthread_create(&thread_h, NULL, &write_audio_frames_render, NULL);
pthread_join(thread_h, NULL);
printf("work is over!\n");
end:
if (render) {
delete render;
render = NULL;
}
if (audio_dec_ctx)
avcodec_close(audio_dec_ctx);
avformat_close_input(&fmt_ctx);
av_free(frame);
return ret < 0;
}
|
cf0430d9a0abe38c2fddb46b602fd419186b20cb | ef766d12490830d9f74e655132ef1b469032e699 | /Code/Src/Internal/Systems/Resource/Resource.cpp | caa121268a35e827295354272c89982236dfa059 | [] | no_license | google-code/avion | 6e1fd1fcbb4e5a0b4c0461bb64be04493784115f | f6bf33c18d44932e71dfd380d6b3b5e016b62275 | refs/heads/master | 2016-08-07T06:12:20.904675 | 2015-03-15T17:16:25 | 2015-03-15T17:16:25 | 32,273,316 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,245 | cpp | Resource.cpp | /*!
\file
\brief
Manages assets, such as models, textures, and sounds.
© 2011 Mark W. Gabby II
This file is part of the Avion engine.
The Avion engine is free software: you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
The Avion engine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the Avion Engine.
If not, see <http://www.gnu.org/licenses/>.
*/
#include "Systems/Resource/Resource.hpp"
#include <sstream>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glext.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include <fiff.hpp> // Flexible Interchange File Format library
#include "Avion FIFF IDs.hpp"
#include "Systems/Resource/AvionModel.hpp"
#include "Systems/Resource/AvionTexture.hpp"
#include "Systems/Platform/glCP.hpp"
#include "Systems/Platform/Platform.hpp"
#include "Systems/Graphics/Graphics.hpp"
#include "Systems/ErrorManager/ErrorManager.hpp"
#include "Util/ConstantsFile.hpp"
#include "Util/IOutils.hpp"
#include "Util/MemMappedFile.hpp"
Resource RESOURCES;
ModelData * Resource::GetModelData( const uint32_t Handle )
{
return models[Handle];
}
Font * Resource::GetFont( const uint32_t Handle )
{
return fonts[Handle];
}
void FiffErrorCallback( const char * const Message )
{
Error( Message );
}
void FiffWarningCallback( const char * const Message )
{
Warning( Message );
}
void Resource::LoadIndividualFiles()
{
// Load the texture data.
texturesPath = "Textures";
CONSTANTS.Get( texturesPath, "TexturesFolder" );
LoadIndividualTextures( texturesPath );
// Now load the models.
modelsPath = "Models";
CONSTANTS.Get( modelsPath, "ModelsFolder" );
LoadIndividualModels( modelsPath );
// TODO: load the sounds.
soundsPath = "Sounds";
CONSTANTS.Get( soundsPath, "SoundsFolder" );
// TODO: load the animations.
animationsPath = "Animations";
CONSTANTS.Get( animationsPath, "AnimationsFolder" );
}
void Resource::LoadAvnArchiveFiles()
{
// Load the texture data.
texturesArchivePath = "Textures.avnArchive";
CONSTANTS.Get( texturesArchivePath, "TexturesArchiveFilePath" );
LoadTexturesFromAvnArchive( texturesArchivePath );
// Now load the models.
modelsArchivePath = "Models.avnArchive";
CONSTANTS.Get( modelsArchivePath, "ModelsArchiveFilePath" );
LoadModelsFromAvnArchive( modelsArchivePath );
soundsArchivePath = "Sounds.avnArchive";
CONSTANTS.Get( soundsArchivePath, "SoundsArchiveFilePath" );
animationsArchivePath = "Animations.avnArchive";
CONSTANTS.Get( animationsArchivePath, "AnimationsArchiveFilePath" );
}
/*!
\brief
This function sets up the resource manager.
*/
bool Resource::Initialize()
{
// Setup the FIFF library
fiff::set_allocator( fiff::allocator_new );
fiff::set_error_callback( FiffErrorCallback );
fiff::set_warning_callback( FiffWarningCallback );
LoadFonts();
LoadIndividualFiles();
LoadAvnArchiveFiles();
return true;
}
/*!
\brief
This function loads the textures from a data file.
\param TextureDataFilePath
The path to the textures data file.
*/
bool Resource::LoadTexturesFromAvnArchive( const std::string & TextureDataFilePath )
{
// Open the file for reading
if ( fiff::file_begin( TextureDataFilePath.c_str(), fiff::kExisting ) == false )
{
// If we fail, return false
return false;
}
// Get the first group
fiff::read_group_begin();
// If it's not a "Textures" or "Mixed" group, it's not a supported group to load from.
const fiff::uChunkID64 TypeID = fiff::get_chunk_type_ID();
if ( TypeID != AVION_ARCHIVE_BITMAPS_TYPE_ID &&
TypeID != AVION_ARCHIVE_MIXED_TYPE_ID )
{
fiff::file_end();
return false;
}
// For each texture...
std::list<AvionTexture *> Textures;
while ( fiff::read_object_begin( AVION_TEXTURE_MAP_TYPE_ID ) )
{
AvionTexture * CurTexture = new AvionTexture();
CurTexture->LoadFromFIFFObject();
Textures.push_back( CurTexture );
fiff::read_object_end( AVION_TEXTURE_MAP_TYPE_ID );
}
// Create the texture object names for OpenGL.
const uint32_t TextureCount = Textures.size();
if ( TextureCount > 0 )
{
textureObjectNames = new uint32_t[TextureCount];
glGenTextures( TextureCount, textureObjectNames );
int TextureObjectNameIndex = 0;
while ( Textures.empty() == false )
{
const AvionTexture * const CurTexture = Textures.back();
Textures.pop_back();
// Set the texture to this texture object
BindTexture( *CurTexture, textureObjectNames[TextureObjectNameIndex] );
// Now, assign the texture object index to the map for this texture's name.
// If there's already a texture of this name... well... it's overwriting it.
textureHandles[CurTexture->GetName()] = TextureObjectNameIndex;
++TextureObjectNameIndex;
// Deallocate this texture - we don't need it anymore
delete CurTexture;
}
}
return true;
}
void Resource::BindTexture( const AvionTexture & Texture, const uint32_t TextureObjectName )
{
// Bind the texture object to the following operations.
glBindTexture( GL_TEXTURE_2D, TextureObjectName );
uint32_t MipCount = Texture.GetMIPcount();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
float requestedAnisotropyLevel = GFX.GetAnisotropyLevel();
float supportedAnisotropyLevel = CrossPlatformOpenGL::GetMaxAnisotropy();
if ( supportedAnisotropyLevel )
{
// If we have enough supported levels, set to the requested level.
if ( requestedAnisotropyLevel <= supportedAnisotropyLevel &&
requestedAnisotropyLevel )
{
CrossPlatformOpenGL::SetAnisotropy( requestedAnisotropyLevel );
}
// Otherwise, set to the max level available.
else
{
CrossPlatformOpenGL::SetAnisotropy( supportedAnisotropyLevel );
}
}
// Go through all the mip map levels and load them for the current texture object.
for ( uint32_t i = 0; i < MipCount; ++i )
{
CoordPair<uint32_t> dimensions = Texture.GetMIPdimensions( i );
// Here's where the actual copying takes place.
glTexImage2D( GL_TEXTURE_2D, i, GL_RGBA,
dimensions[kWidth], dimensions[kHeight],
0, GL_RGBA, GL_UNSIGNED_BYTE,
Texture.GetPixels( i ) );
}
}
bool Resource::LoadIndividualTextures( const std::string & Folder )
{
return false;
}
/*!
\brief
This function parses the Fonts List and loads each font in the list.
\param FontsListFilePath
Path and filename for the fonts list file.
\return
True on success, false on failure.
*/
bool Resource::LoadFonts()
{
// Get the location of the fonts directory
std::string FontsListFilePath = CONSTANTS.GetPath( "FontsFolder", NULL );
// Attempt to load the FreeType library in order to load all the fonts.
FT_Library FreeTypeLibrary;
FT_Error LastErrorFT = FT_Init_FreeType( &FreeTypeLibrary );
if ( LastErrorFT )
{
Error( "Failed to initialize freetype. Error code %i.", LastErrorFT );
return false;
}
std::list<std::string> FontFilepaths = pf::GetDirectoryFilePaths( FontsListFilePath.c_str(), "avionFnt" );
for ( std::list<std::string>::iterator it = FontFilepaths.begin(); it != FontFilepaths.end(); ++it )
{
Font * NewFont = new Font();
std::string FontName;
if ( NewFont->Load( FontName, *it, FreeTypeLibrary ) )
{
uint32_t CurFontCount = fonts.size();
fontHandles[FontName] = CurFontCount;
fonts.push_back( NewFont );
}
else
{
Warning( "Font %s failed to load.", it->c_str() );
}
}
return true;
}
/*!
\brief
This function loads models from an .avnArchive file.
\param ModelDataFilePath
This is the path of the model .avnArchive file.
*/
bool Resource::LoadModelsFromAvnArchive( const std::string & ModelDataFilePath )
{
// Open the file for reading
if ( fiff::file_begin( ModelDataFilePath.c_str(), fiff::kExisting ) == false )
{
// If we fail, return false
return false;
}
// Get the first group
fiff::read_group_begin();
// If it's not a "Models" or "Mixed" group, it's not a supported group to load from.
const fiff::uChunkID64 TypeID = fiff::get_chunk_type_ID();
if ( TypeID != AVION_ARCHIVE_MODELS_TYPE_ID &&
TypeID != AVION_ARCHIVE_MIXED_TYPE_ID )
{
fiff::file_end();
return false;
}
// For each object:
int CurModelIndex = 0;
while ( fiff::read_object_begin( AVION_MODEL_TYPE_ID ) )
{
AvionModel Model;
Model.LoadFromFIFFObject();
fiff::read_object_end( AVION_MODEL_TYPE_ID );
// Load the model's data into OpenGL
ModelData * Data = new ModelData;
Data->bufferIndices = new uint32_t[Model.GetBufferCount()];
Data->bufferCount = Model.GetBufferCount();
const char * const ModelTextureName = Model.GetTextureMapName();
Data->textureIndex = kNull32;
if ( ModelTextureName[0] != '\0' )
{
Data->textureIndex = GetTextureObjectName( ModelTextureName );
}
const char * const ModelNormalMapName = Model.GetNormalMapName();
if ( ModelNormalMapName[0] != '\0' )
{
Data->normalMapIndex = GetTextureObjectName( ModelNormalMapName );
}
Data->triangleCount = Model.GetTriangleCount();
Data->boundingBox = Model.GetBoundingBox();
// Generate buffers for the new Model.
CrossPlatformOpenGL::glGenBuffers( Model.GetBufferCount(),
Data->bufferIndices );
// Load the vertices into a buffer.
CrossPlatformOpenGL::glBindBuffer( GL_ARRAY_BUFFER, Data->bufferIndices[kVertices] );
CrossPlatformOpenGL::glBufferData( GL_ARRAY_BUFFER, Model.GetVertexSizeBytes(),
Model.GetVertexData(), GL_STATIC_DRAW );
// Load the normals into a buffer.
CrossPlatformOpenGL::glBindBuffer( GL_ARRAY_BUFFER, Data->bufferIndices[kNormals] );
CrossPlatformOpenGL::glBufferData( GL_ARRAY_BUFFER, Model.GetNormalSizeBytes(),
Model.GetNormalData(), GL_STATIC_DRAW );
// Load the vertex colors into a buffer.
CrossPlatformOpenGL::glBindBuffer( GL_ARRAY_BUFFER, Data->bufferIndices[kColors] );
CrossPlatformOpenGL::glBufferData( GL_ARRAY_BUFFER, Model.GetVcolorSizeBytes(),
Model.GetVcolorData(), GL_STATIC_DRAW );
// // Load the specular colors into a buffer.
// CrossPlatformOpenGL::glBindBuffer( GL_ARRAY_BUFFER, Data->bufferIndices[kSpecColors] );
// CrossPlatformOpenGL::glBufferData( GL_ARRAY_BUFFER, Model.GetSpecColorSizeBytes(),
// Model.GetSpecClrData(), GL_STATIC_DRAW );
// Load the texture coordinates
CrossPlatformOpenGL::glBindBuffer( GL_ARRAY_BUFFER, Data->bufferIndices[kTextureCoords] );
CrossPlatformOpenGL::glBufferData( GL_ARRAY_BUFFER, Model.GetTextureCoordsSizeBytes(),
Model.GetTextureCoords(), GL_STATIC_DRAW );
// // Load the vertex specular coefficients
// CrossPlatformOpenGL::glBindBuffer( GL_ARRAY_BUFFER, Data->bufferIndices[kCoefficients] );
// CrossPlatformOpenGL::glBufferData( GL_ARRAY_BUFFER, Model.GetSpecPowerSizeBytes(),
// Model.GetspecPowers(), GL_STATIC_DRAW );
Data->specular = Model.GetSpecPowers()[0];
Data->triangleIndices = new uint32_t[Model.GetTriangleCount() * 3];
memcpy( Data->triangleIndices, Model.GetTriangleIndices(), Model.GetTriangleIndicesSizeBytes() );
const std::string & Name = Model.GetName();
modelHandles[Name] = CurModelIndex;
models.push_back( Data );
++CurModelIndex;
}
fiff::read_group_end();
fiff::file_end();
return true;
}
bool Resource::LoadIndividualModels( const std::string & /*ModelsDirectory*/ )
{
return true;
}
bool Resource::LoadModelsMemMapped( const std::string & /*ModelDataFilePath*/ )
{
return true;
}
bool Resource::LoadAnimationsMemMapped( const std::string & /*AnimationDataFilePath*/ )
{
return true;
}
bool Resource::LoadSoundsMemMapped( const std::string & /*SoundDataFilePath*/ )
{
return true;
}
/*!
\brief
Returns an OpenGL texture object name. If the texture isn't loaded, it returns
kNull32.
\note
The texture object name is NOT a string, it's a number that's used by OpenGL
to uniquely identify a texture.
*/
uint32_t Resource::GetTextureObjectName( const char * const TextureName )
{
std::map<std::string, uint32_t>::iterator handleIt = textureHandles.find( TextureName );
if ( handleIt == textureHandles.end() )
{
if ( textureHandles.empty() )
{
Error( "Trying to get texture object name for texture %s when no textures have been "
"loaded! Make sure your textures archive is valid.", TextureName );
}
else
{
Error( "No texture named %s found!", TextureName );
}
return kNull32;
}
uint32_t TexName = textureObjectNames[ handleIt->second ];
if ( glIsTexture( TexName ) )
{
return TexName;
}
return kNull32;
}
/*!
\brief
Returns an index which can be used to index a model
object. If the model isn't loaded, it returns
kNull32.
*/
uint32_t Resource::GetModelHandle( const char * const ModelName )
{
std::map<std::string, uint32_t>::iterator it = modelHandles.find( ModelName );
if ( it == modelHandles.end() )
{
if ( modelHandles.empty() )
{
Error( "Trying to get handle to model %s when no models have been loaded! Make sure your "
"models archive is valid.", ModelName );
}
else
{
Error( "No model named %s found!", ModelName );
}
return kNull32;
}
return it->second;
}
/*!
\brief
Returns an handle which can be used to get a font.
If the font isn't loaded, it returns kNull32.
*/
uint32_t Resource::GetFontHandle( const char * const FontName )
{
std::map<std::string, uint32_t>::iterator it = fontHandles.find( FontName );
if ( it == fontHandles.end() )
{
if ( fontHandles.empty() )
{
Error( "Trying to get handle to font %s when no fonts have been loaded! Make sure your "
"fonts folder is valid.", FontName );
}
else
{
Error( "No font named %s found!", FontName );
}
return kNull32;
}
return it->second;
}
void Resource::FreeAllTextures()
{
if ( textureCount )
{
glDeleteTextures( textureCount, textureObjectNames );
delete[] textureObjectNames;
textureObjectNames = 0;
textureCount = 0;
}
}
void Resource::FreeAllSounds()
{
}
void Resource::FreeAllModels()
{
uint32_t ModelCount = uint32_t( models.size() );
for ( uint32_t i = 0; i < ModelCount; ++i )
{
if ( models[i]->triangleIndices )
{
delete[] models[i]->triangleIndices;
}
CrossPlatformOpenGL::glDeleteBuffers( models[i]->bufferCount,
models[i]->bufferIndices );
}
models.clear();
}
Resource::Resource()
{
textureCount = 0;
textureObjectNames = 0;
}
Resource::~Resource()
{
Close();
}
void Resource::Close()
{
FreeAllTextures();
FreeAllSounds();
FreeAllModels();
}
|
e7237ec21dcb8cd3eb48226520d5d679813c21a9 | 7e72e19d9d10cc610e2dad2aea25ed22b4a67739 | /Labo 09/AllesTegelijk/AllesTegelijk.ino | bb86f419042ef47c93a216846c0eb623422b816a | [] | no_license | mcoens/alle-labo-s | f8fa7df57f691554c7dfc02cc19154be7cf7436f | a9e9d1e7cf043b8814d72b5f2922046f39c2ad8b | refs/heads/master | 2020-12-12T11:41:12.086814 | 2020-01-15T16:06:52 | 2020-01-15T16:06:52 | 234,119,058 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,202 | ino | AllesTegelijk.ino | #include <Ethernet.h>
//#include <Ethernet2.h>
byte LED[] = {5, 6, 7};
int nrLED;
bool statusLED;
String inlezen;
//Ethernet declarations
byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0xA8, 0x11 };
EthernetServer server(80);
void setup() {
Serial.begin(9600);
for (int i = 0; i < sizeof(LED); i++) {
pinMode(LED[i], OUTPUT);
}
if(Ethernet.begin(mac)) {
Serial.print("Server has started on ");
Serial.println(Ethernet.localIP());
delay(1000);
server.begin();
}
}
void loop() {
//Ethernet server
EthernetClient client = server.available();
if (client) {
Serial.println("New Client");
//initPage(client);
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (inlezen.length() < 100) {
inlezen += c;
}
if (c == '\n') {
//Serial.println(inlezen);
if(inlezen.substring(6,10) == "LED=") {
nrLED = inlezen.charAt(10) - 48;
//Serial.print(inlezen.substring(14,15));
statusLED = inlezen.charAt(14) - 0x30;
if (nrLED == 0) {
Serial.print("LED : ");
Serial.println(nrLED);
Serial.print("STATUS : ");
Serial.println(statusLED);
for (int i = 0; i < sizeof(LED); i++) {
digitalWrite(LED[i], statusLED);
}
} else {
Serial.print("LED : ");
Serial.println(nrLED);
Serial.print("STATUS : ");
Serial.println(statusLED);
digitalWrite(LED[nrLED - 1], statusLED);
}
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE> Arduino LedWeb </TITLE>");
//client.println("<meta http-equiv=\"refresh\" content=\"1\">");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1 style=\"color:blue; font-family:courier new;\"> Labo 09 : Helderheid </H1>");
for (int i = 0; i < sizeof(LED); i++) {
if (digitalRead(LED[i])) {
client.print("<input checked type=checkbox onclick=location.href=\"/?LED=");
} else {
client.print("<input type=checkbox onclick=location.href=\"/?LED=");
}
client.print(i+1);
client.print("&S=");
client.print(!digitalRead(LED[i]));
client.print("\" /> LED");
client.print(i);
client.println("<br></input>");
}
client.println("<input type=\"button\" onclick=location.href=\"/?LED=0&S=0\" /> OFF</input>");
client.print("<input type=\"button\" onclick=location.href=\"/?LED=0&S=1\" /> ON</input>");
client.println("</div>");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
client.stop();
inlezen="";
Serial.println("Client disconnected");
}
}
}
}
}
|
98b50142944342f387b26b867b0094f8c8bfd7a9 | 1fef8be32473f3477e015ac8c90e1cc7e85d47e8 | /main.cpp | c07c794e08545acb9e42c1196c3c80d7e8724f69 | [] | no_license | usamayousuf13/facebookFunctionalitiesAlgorithmC- | dd3c2621a204396c08d6174c0bfafe16a6259fcf | dd9bd1e2a36d5e5e3fc77e9f36c703bf5fdbab35 | refs/heads/master | 2020-03-23T14:31:51.346948 | 2018-07-20T08:03:44 | 2018-07-20T08:03:44 | 141,682,268 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 147 | cpp | main.cpp | #include "Graph.h"
#include "Interface.h"
#include <iostream>
using namespace std;
int main () {
Interface inter;
inter.menu();
return 0;
}
|
7b1cc30e739b5ae3ee30efd2595c9e7c8b0e9d16 | 1ddb8539e4839e5ce4cb1407f5a8608b3185d271 | /Source/NexusBattle/Public/NBBasePlayerCharacter.h | 2eda9d5b2dc1e0e533f57684ebb4765adeae578a | [] | no_license | chocoberu/Unreal_NexusBattle | ba649150209022c35ec89bba21bbf213ced22833 | 6dd94cda75a4ec1d5582a098ddfe9df2c0fabfc3 | refs/heads/master | 2023-02-12T15:56:02.812136 | 2021-01-09T12:04:48 | 2021-01-09T12:04:48 | 289,920,024 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,025 | h | NBBasePlayerCharacter.h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "NexusBattle.h"
#include "NBBaseCharacter.h"
#include "NBBasePlayerCharacter.generated.h"
UCLASS()
class NEXUSBATTLE_API ANBBasePlayerCharacter : public ANBBaseCharacter
{
GENERATED_BODY()
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
ANBBasePlayerCharacter();
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
virtual void PostInitializeComponents() override;
virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser) override;
ETeam GetMyTeam() { return MyTeam; }
// 공격, 스킬 관련 함수
// 경험치 추가
UFUNCTION() void AddExp(float NewExp);
virtual void OnDead();
protected:
// 이동 관련 벡터 변수
FVector DirectionToMove = FVector::ZeroVector;
// 스프링 암 관련 변수
float ArmLengthTo = 0.0f;
FRotator ArmRotationTo = FRotator::ZeroRotator;
float ArmLengthSpeed = 0.0f;
float ArmRotationSpeed = 0.0f;
UPROPERTY(VisibleAnywhere, Category = Camera) USpringArmComponent* SpringArm;
UPROPERTY(VisibleAnywhere, Category = Camera) UCameraComponent* Camera;
UPROPERTY() class ANBPlayerController* NBController; // 플레이어 컨트롤러
// 이동 관련 함수
void UpDown(float NewAxisValue);
void LeftRight(float NewAxisValue);
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category = Attack, Meta = (AllowPrivateAccess = true)) float AttackRange;
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category = Attack, Meta = (AllowPrivateAccess = true)) float AttackRadius;
UPROPERTY(VisibleAnywhere, Category = Stat) class UNBCharacterStatComponent* CharacterStat;
UPROPERTY(VisibleAnywhere, Category = UI) class UWidgetComponent* HPBarWidget;
};
|
b1a9d067f5c564ab10c6045c4f5e142575d12075 | 7182b78c0ecf8b99d9e5db315b34b7c7577b779b | /old_complete/dynamol/trunk/Main_Build/dynacomp/file.cpp | 5176124c009fb0640568d634d312f4f511545f96 | [] | no_license | gnulnx/dynamol | cbc85abf3d23c9af508576731d06f8ba372449db | 88a1000563f1d49793df8a404eff0fe8768b46b4 | refs/heads/master | 2016-09-06T11:20:54.279297 | 2015-04-09T14:02:42 | 2015-04-09T14:02:42 | 32,398,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,871 | cpp | file.cpp | /***************************************
* Copyright (C) 2004 by Dynamol Inc.*
* john.furr@dynamol.com *
***************************************/
#include "file.h"
//Dynamol Computational Libary includes
#include "molecule.h"
#include "atom.h"
#include "bond.h"
//Dynamol Base Library Includes
#include "../dynabase/utility.h"
//Standard Library Includes
#include <iostream>
#include <iomanip>
#include <fstream>
using std::cout;
using std::endl;
using std::setw;
using std::ofstream;
#include <boost/weak_ptr.hpp>
namespace dynacomp {
file::file()
{
}
file::~file()
{
}
bool file::writeSDF(const char *file, molecule *mol, int append) {
////////////cout <<"n::writeSDF"<<endl;
//THis first section renumbers the atoms && bonds to make sure that everything writes correctly
for (int i=0; i < mol->atoms.size(); i++) {
mol->atoms[i]->setNum(i+1);
}
for (int i=0; i<mol->atoms.size(); i++) {
atom *atm = mol->atoms[i];
atm->atoms.clear();
atm->angles.clear();
atm->bonds.clear();
}
for (int i=0; i<mol->bonds.size(); i++) {
bond *bd = mol->bonds[i];
bd->fromAtom()->addAtom(bd->toAtom());
bd->toAtom()->addAtom(bd->fromAtom());
}
//this->AN2SYM(1);
for (int i=0; i<mol->atoms.size(); i++) {
atom *atm = mol->atoms[i];
string sym = AN2SYM(atm->getAN());
atm->setSymbol( sym );
}
//Now lets make sure that all the atom->syms match the atomicNumbers
ofstream outFile;
if (append == 1) outFile.open(file, ios::app);
else outFile.open(file, ios::out);
if (!outFile) {
cout <<"Could not open " << file <<" for writing"<<endl;
return false;
}
outFile << mol->getName() << endl;
outFile <<"Dynamol 3D sdf file"<<endl;
outFile <<endl;
outFile << setw(3) << mol->atoms.size() << setw(3) << mol->bonds.size();
outFile <<" 0 0 1 0 0 0 0 0999 V2000"<<endl;
//outFile <<" 0 0 1 0 0 0 0 0999 V2000" << endl;
//for (int i=0; i<8; i++) {
// outFile << setw(3) << "0";
//}
//outFile << endl;
for (int i=0; i<mol->atoms.size(); i++) {
atom *atm = mol->atoms[i];
float *cd = atm->fCoords;
string scd0 = dynabase::setNum(cd[0]);
string scd1 = dynabase::setNum(cd[1]);
string scd2 = dynabase::setNum(cd[2]);
string tmp = "";
for (int i=0; i<scd0.size(); i++) {
if (i < 7)
tmp = tmp + scd0[i];
}
scd0 = tmp;
tmp = "";
for (int i=0; i<scd1.size(); i++) {
if (i < 7)
tmp = tmp + scd1[i];
}
scd1 = tmp;
tmp = "";
for (int i=0; i<scd2.size(); i++) {
if (i < 7)
tmp = tmp + scd2[i];
}
scd2 = tmp;
//outFile << setiosflags(ios::fixed) << setprecision(2) << setw(10) << scd0 << setw(10) << scd1 << setw(10) << scd2;
outFile << setiosflags(ios::fixed) << setprecision(4) <<setw(10)<< cd[0] << setw(10) << cd[1] << setw(10) << cd[2];
outFile <<" "<< left << setw(2) << atm->getSymbol().c_str()<<" 0 0 " << atm->parity << right;
for (int i=0; i<9; i++) outFile << setw(3) << "0";
outFile << endl;
}
for (int i=0; i<mol->bonds.size(); i++) {
bond *bd = mol->bonds[i];
outFile << setw(3) << bd->fromAtom()->getNum() << setw(3) << bd->toAtom()->getNum();
outFile << setw(3) << bd->order;
for (int i=0; i<4; i++) outFile << setw(3) << "0";
outFile << endl;
}
outFile <<"M END"<<endl;
map<string, string>::iterator propIt = mol->propMap.begin();
for (propIt; propIt != mol->propMap.end(); propIt++) {
//for (int i=0; i<mol->propertyData.size(); i++) {
string name = propIt->first;
string value = propIt->second;
outFile << "> <" << name << ">" << endl;
outFile << value << endl;
outFile << endl;
}
outFile << "$$$$" << endl;
return true;
}
string file::AN2SYM(int an) {
if (an == 1) return "H";
else if (an == 2) return "He";
else if (an == 3) return "li";
else if (an == 4) return "Be";
else if (an == 5) return "B";
else if (an == 6) return "C";
else if (an == 7) return "N";
else if (an == 8) return "O";
else if (an == 9) return "F";
else if (an == 10) return "Ne";
else if (an == 11) return "Na";
else if (an == 12) return "Mg";
else if (an == 13) return "Al";
else if (an == 14) return "Si";
else if (an == 15) return "P";
else if (an == 16) return "S";
else if (an == 17) return "Cl";
else if (an == 18) return "Ar";
else if (an == 19) return "K";
else if (an == 20) return "Ca";
else if (an == 21) return "Sc";
else if (an == 22) return "Ti";
else if (an == 23) return "V";
else if (an == 24) return "Cr";
else if (an == 25) return "Mn";
else if (an == 26) return "Fe";
else if (an == 27) return "Co";
else if (an == 28) return "Ni";
else if (an == 29) return "Cu";
else if (an == 30) return "Zn";
else if (an == 31) return "Ga";
else if (an == 32) return "Ge";
else if (an == 33) return "As";
else if (an == 34) return "Se";
else if (an == 35) return "Br";
else if (an == 36) return "Kr";
else if (an == 37) return "Rb";
else if (an == 38) return "Sr";
else if (an == 39) return "Y";
else if (an == 40) return "Zr";
else if (an == 42) return "Mo";
else if (an == 43) return "Tc";
else if (an == 44) return "Ru";
else if (an == 45) return "Rh";
else if (an == 46) return "Pd";
else if (an == 47) return "Ag";
else if (an == 48) return "Cd";
else if (an == 49) return "In";
else if (an == 50) return "Sn";
else if (an == 51) return "Sb";
else if (an == 52) return "Te";
else if (an == 53) return "I";
else if (an == 54) return "Xe";
else if (an == 55) return "Cs";
else if (an == 56) return "Ba";
else if (an == 57) return "La";
else if (an == 58) return "Hf";
else if (an == 59) return "Pr";
else if (an == 60) return "Nd";
else if (an == 61) return "Pm";
else if (an == 62) return "Sm";
else if (an == 63) return "Eu";
else if (an == 64) return "Gd";
else if (an == 65) return "Tb";
else if (an == 66) return "Dy";
else if (an == 67) return "Ho";
else if (an == 68) return "Er";
else if (an == 69) return "Tm";
else if (an == 70) return "Yb";
else if (an == 71) return "Lu";
else if (an == 72) return "Hf";
else if (an == 73) return "Ta";
else if (an == 74) return "W";
else if (an == 75) return "Re";
else if (an == 76) return "Os";
else if (an == 77) return "Ir";
else if (an == 78) return "Pt";
else if (an == 79) return "Au";
else if (an == 80) return "Hg";
else if (an == 81) return "Ti";
else if (an == 82) return "Pb";
else if (an == 83) return "Bi";
else if (an == 84) return "Po";
else if (an == 85) return "At";
else if (an == 86) return "Rn";
else if (an == 87) return "Fr";
else if (an == 88) return "Ra";
else if (an == 89) return "Ac";
else if (an == 90) return "Th";
else if (an == 91) return "Pa";
else if (an == 92) return "U";
else if (an == 93) return "Np";
else if (an == 94) return "Pu";
else if (an == 95) return "Am";
else if (an == 96) return "Cm";
else if (an == 97) return "Bk";
else if (an == 98) return "Cf";
else if (an == 99) return "Es";
else if (an == 100) return "Fm";
else if (an == 101) return "Md";
else if (an == 102) return "No";
else if (an == 103) return "Lr";
else if (an == 104) return "Unq";
else if (an == 105) return "Unp";
else if (an == 106) return "Unh";
else if (an == 107) return "Uns";
else if (an == 108) return "Uno";
else if (an == 109) return "Une";
else if (an == 110) return "Unn";
else {
//////////cout <<"Could not convert atomic number: " << an << " to symbol...please fix me!"<<endl;
}
}
}
|
b032990e6a9669a96c789d87dcc9370c9cde2c02 | 9de18ef120a8ae68483b866c1d4c7b9c2fbef46e | /third_party/concurrentqueue/tests/relacy/relacy/test/main.cpp | 9da8eed809193e22b48fbf1f86ad15e408f0a23d | [
"BSD-2-Clause",
"LicenseRef-scancode-free-unknown",
"Zlib"
] | permissive | google/orbit | 02a5b4556cd2f979f377b87c24dd2b0a90dff1e2 | 68c4ae85a6fe7b91047d020259234f7e4961361c | refs/heads/main | 2023-09-03T13:14:49.830576 | 2023-08-25T06:28:36 | 2023-08-25T06:28:36 | 104,358,587 | 2,680 | 325 | BSD-2-Clause | 2023-08-25T06:28:37 | 2017-09-21T14:28:35 | C++ | UTF-8 | C++ | false | false | 15,574 | cpp | main.cpp | #include "stdafx.h"
//#define RL_MSVC_OUTPUT
#include "../relacy/relacy_std.hpp"
#include "memory_order.hpp"
#include "fence.hpp"
#include "data_race.hpp"
#include "mutex.hpp"
#include "condvar.hpp"
#include "semaphore.hpp"
#include "event.hpp"
#include "scheduler.hpp"
#include "compare_swap.hpp"
#include "wfmo.hpp"
#include "thread_local.hpp"
#include "dyn_thread.hpp"
#include "memory.hpp"
#include "pthread.hpp"
#include "windows.hpp"
#include "addr_hash.hpp"
#include "futex.hpp"
#include "../relacy/windows.h"
#include "../relacy/pthread.h"
#include <cstdio>
#include <climits>
class queue_t
{
public:
queue_t()
{
VAR(head) = 0;
VAR(tail) = 0;
pthread_mutex_init(&mtx, 0);
pthread_cond_init(&cv, 0);
}
~queue_t()
{
pthread_mutex_destroy(&mtx);
pthread_cond_destroy(&cv);
}
void enqueue(void* data)
{
node_t* n = new node_t;
n->VAR(next) = 0;
n->VAR(data) = data;
bool was_empty = false;
pthread_mutex_lock(&mtx);
if (VAR(head) == 0)
{
was_empty = true;
VAR(head) = n;
VAR(tail) = n;
}
else
{
VAR(tail)->VAR(next) = n;
VAR(tail) = n;
}
pthread_mutex_unlock(&mtx);
if (was_empty)
pthread_cond_broadcast(&cv);
}
void* dequeue()
{
node_t* n = 0;
pthread_mutex_lock(&mtx);
while (VAR(head) == 0)
pthread_cond_wait(&cv, &mtx);
n = VAR(head);
if (n->VAR(next) == 0)
VAR(tail) = 0;
VAR(head) = n->VAR(next);
pthread_mutex_unlock(&mtx);
void* data = n->VAR(data);
delete n;
return data;
}
private:
struct node_t
{
VAR_T(node_t*) next;
VAR_T(void*) data;
};
VAR_T(node_t*) head;
VAR_T(node_t*) tail;
pthread_mutex_t mtx;
pthread_cond_t cv;
};
void* enqueue_thread(void* ctx)
{
queue_t* q = static_cast<queue_t*>(ctx);
for (size_t i = 0; i != 4; i += 1)
q->enqueue((void*)(i + 1));
return 0;
}
void* dequeue_thread(void* ctx)
{
queue_t* q = static_cast<queue_t*>(ctx);
for (size_t i = 0; i != 4; i += 1)
{
void* data = q->dequeue();
assert((int)(uintptr_t)data >= 1 && (int)(uintptr_t)data <= 4);
}
return 0;
}
void queue_test()
{
queue_t q;
pthread_t th [4];
for (size_t i = 0; i != 2; i += 1)
pthread_create(&th[i], 0, enqueue_thread, &q);
for (size_t i = 2; i != 4; i += 1)
pthread_create(&th[i], 0, dequeue_thread, &q);
void* res = 0;
for (size_t i = 0; i != 4; i += 1)
pthread_join(th[i], &res);
}
/*
class recursive_timed_mutex
{
public:
recursive_timed_mutex()
{
sema.init(false, 1, 1, $);
owner = -1;
recursion_count = 0;
}
~recursive_timed_mutex()
{
assert(owner == -1 && recursion_count == 0);
sema.deinit($);
}
void lock(rl::debug_info_param info)
{
rl::context& c = rl::ctx();
if (owner == c.current_thread())
{
RL_HIST(rl::user_msg_event) {"recursive mutex lock"} RL_HIST_END();
assert(recursion_count > 0);
recursion_count += 1;
}
else
{
sema.wait(false, false, info);
assert(owner == -1 && recursion_count == 0);
owner = c.current_thread();
recursion_count = 1;
}
}
bool try_lock(rl::debug_info_param info)
{
rl::context& c = rl::ctx();
if (owner == c.current_thread())
{
RL_HIST(rl::user_msg_event) {"recursive mutex try lock"} RL_HIST_END();
assert(recursion_count > 0);
recursion_count += 1;
return true;
}
else
{
rl::sema_wakeup_reason r = sema.wait(true, false, info);
if (r == rl::sema_wakeup_reason_success)
{
assert(owner == -1 && recursion_count == 0);
owner = c.current_thread();
recursion_count = 1;
return true;
}
else
{
return false;
}
}
}
void unlock(rl::debug_info_param info)
{
rl::context& c = rl::ctx();
assert(owner == c.current_thread() && recursion_count > 0);
RL_HIST(rl::user_msg_event) {"recursive mutex unlock"} RL_HIST_END();
recursion_count -= 1;
if (recursion_count == 0)
{
owner = -1;
unsigned prev;
sema.post(1, prev, info);
}
}
bool timed_lock(rl::debug_info_param info, ... )
{
rl::context& c = rl::ctx();
if (owner == c.current_thread())
{
RL_HIST(rl::user_msg_event) {"recursive mutex timed lock"} RL_HIST_END();
assert(recursion_count > 0);
recursion_count += 1;
return true;
}
else
{
rl::sema_wakeup_reason r = sema.wait(false, true, info);
if (r == rl::sema_wakeup_reason_success)
{
assert(owner == -1 && recursion_count == 0);
owner = c.current_thread();
recursion_count = 1;
return true;
}
else
{
return false;
}
}
}
private:
struct tag_t;
rl::semaphore<tag_t> sema;
rl::thread_id_t owner;
int recursion_count;
recursive_timed_mutex(recursive_timed_mutex const&);
recursive_timed_mutex& operator = (recursive_timed_mutex const&);
};
*/
class recursive_timed_mutex
{
public:
recursive_timed_mutex()
{
mtx = CreateMutex(0, 0, 0);
}
~recursive_timed_mutex()
{
CloseHandle(mtx);
}
void lock(rl::debug_info_param info)
{
rl::rl_WaitForSingleObject(mtx, INFINITE, info);
}
bool try_lock(rl::debug_info_param info)
{
return WAIT_OBJECT_0 == rl::rl_WaitForSingleObject(mtx, 0, info);
}
void unlock(rl::debug_info_param info)
{
rl::rl_ReleaseMutex(mtx, info);
}
bool timed_lock(rl::debug_info_param info, ... /*abs_time*/)
{
return WAIT_OBJECT_0 == rl::rl_WaitForSingleObject(mtx, 1, info);
}
private:
HANDLE mtx;
recursive_timed_mutex(recursive_timed_mutex const&);
recursive_timed_mutex& operator = (recursive_timed_mutex const&);
};
struct recursive_timed_mutex_test : rl::test_suite<recursive_timed_mutex_test, 3>
{
recursive_timed_mutex mtx;
VAR_T(int) data;
void thread(unsigned idx)
{
if (idx)
{
mtx.lock($);
mtx.lock($);
VAR(data) = 1;
mtx.unlock($);
mtx.unlock($);
}
else
{
if (mtx.timed_lock($))
{
VAR(data) = 2;
mtx.unlock($);
}
}
}
void after()
{
//assert(VAR(data) != 2);
}
};
int main()
{
//rl::test_params p;
//p.search_type = rl::sched_full;
//p.context_bound = 5;
//p.execution_depth_limit = 200;
//rl::simulate<test_pthread_condvar>(p);
//if (rand() <= RAND_MAX) return 0;
//rl::execute<queue_test, 4>();
//if (rand() <= RAND_MAX) return 0;
//rl::test_params p;
//p.initial_state = "1000000";
//p.iteration_count = 2000000;
//p.collect_history = true;
//p.output_history = true;
//p.search_type = rl::sched_bound;
//p.search_type = rl::sched_full;
//p.execution_depth_limit = 500;
//p.context_bound = 1;
//rl::simulate<test_pthread_condvar>(p);
//std::cout << "scheduler state = \"" << p.final_state << "\"" << std::endl;
//std::cout << std::endl;
//if (rand() <= RAND_MAX) return 0;
//rl::test_params p;
//p.iteration_count = 80000000;
//p.initial_state = "50000000";
//p.search_type = rl::fair_context_bound_scheduler_type;
//p.context_bound = 1;
//p.collect_history = true;
//p.output_history = true;
//rl::simulate<test>(p);
//if (rand() <= RAND_MAX) return 0;
//rl::test_params p;
//p.context_bound = 1;
//p.iteration_count = 1000;
//p.search_type = rl::fair_full_search_scheduler_type;
//p.search_type = rl::random_scheduler_type;
//p.collect_history = true;
//p.output_history = true;
//p.execution_depth_limit = 1000;
//p.initial_state = "550 24 3 0 0 3 0 0 3 0 0 3 0 0 2 0 4 2 0 0 2 0 4 2 1 0 2 0 4 3 1 0 3 0 0 2 0 0 1 0 4 2 0 4 3 0 0 3 0 0 2 0 4 3 1 0 3 0 0 2 1 0 2 0 4 2 1 0 2 1 0 2 1 4";
//bool result = rl::simulate<test>(p);
//std::cout << "result=" << result << std::endl;
//simulate<my_test>();
//if (rand() <= RAND_MAX) return 0;
rl::simulate_f tests[] =
{
#if 1
&rl::simulate<test_FlushProcessWriteBuffers>,
&rl::simulate<test_addr_hash>,
&rl::simulate<test_addr_hash2>,
//!!! fails &rl::simulate<sched_load_test>,
&rl::simulate<test_memory_allocation>,
// memory model
&rl::simulate<test_pthread_thread>,
&rl::simulate<test_pthread_mutex>,
&rl::simulate<test_pthread_rwlock>,
&rl::simulate<test_pthread_condvar>,
&rl::simulate<test_pthread_condvar2>,
&rl::simulate<test_pthread_sem>,
&rl::simulate<order_relaxed_test<0> >,
&rl::simulate<order_relaxed_test<1> >,
&rl::simulate<order_relaxed_test<2> >,
&rl::simulate<order_relaxed_test<3> >,
&rl::simulate<order_relaxed_test<4> >,
&rl::simulate<reorder_single_var_test>,
&rl::simulate<acq_rel_test>,
&rl::simulate<seq_cst_test<0> >,
&rl::simulate<seq_cst_test<1> >,
&rl::simulate<reordering_test>,
&rl::simulate<reordering_test2>,
&rl::simulate<test_win_thread>,
&rl::simulate<test_win_mutex>,
&rl::simulate<test_win_cs>,
&rl::simulate<test_win_condvar>,
&rl::simulate<test_win_condvar_srw>,
&rl::simulate<test_win_sem>,
&rl::simulate<test_win_event>,
&rl::simulate<modification_order_test>,
&rl::simulate<transitive_test>,
&rl::simulate<cc_transitive_test>,
&rl::simulate<occasional_test>,
// fences
&rl::simulate<fence_synch_test<0, 0> >,
&rl::simulate<fence_synch_test<1, 0> >,
&rl::simulate<fence_synch_test<2, 0> >,
&rl::simulate<fence_synch_test<0, 1> >,
&rl::simulate<fence_synch_test<1, 1> >,
&rl::simulate<fence_synch_test<2, 1> >,
&rl::simulate<two_fence_synch_test>,
&rl::simulate<seq_cst_fence_test<0> >,
&rl::simulate<seq_cst_fence_test<1> >,
// data races
&rl::simulate<race_ld_ld_test>,
&rl::simulate<race_ld_st_test>,
&rl::simulate<race_st_st_test>,
&rl::simulate<race_seq_ld_ld_test>,
&rl::simulate<race_seq_ld_st_test>,
&rl::simulate<race_seq_st_ld_test>,
&rl::simulate<race_seq_st_st_test>,
&rl::simulate<race_uninit_test>,
&rl::simulate<race_indirect_test>,
// compare_exchange
&rl::simulate<cas_spurious_fail_test<0> >,
&rl::simulate<cas_spurious_fail_test<1> >,
&rl::simulate<cas_spurious_fail_test<2> >,
// mutex
&rl::simulate<test_deadlock>,
&rl::simulate<test_deadlock2>,
&rl::simulate<test_mutex_destuction>,
&rl::simulate<test_mutex_destuction2>,
&rl::simulate<test_mutex_recursion>,
&rl::simulate<test_mutex_recursion_error>,
&rl::simulate<test_mutex_unlock_error>,
&rl::simulate<test_mutex_leak>,
&rl::simulate<test_mutex>,
&rl::simulate<test_mutex_try_lock>,
// futex
&rl::simulate<test_futex>,
&rl::simulate<test_futex_deadlock>,
&rl::simulate<test_futex_sync1>,
&rl::simulate<test_futex_sync2>,
&rl::simulate<test_futex_intr>,
// condition variable
&rl::simulate<test_condvar>,
&rl::simulate<test_condvar2>,
// semaphore
&rl::simulate<test_semaphore>,
&rl::simulate<test_semaphore_atomic>,
// event
&rl::simulate<test_event_auto>,
&rl::simulate<test_event_manual>,
&rl::simulate<test_event_atomic>,
//wfmo
&rl::simulate<test_wfmo_all>,
&rl::simulate<test_wfmo_single>,
&rl::simulate<test_wfmo_timeout>,
&rl::simulate<test_wfmo_try>,
&rl::simulate<test_wfmo_mixed>,
&rl::simulate<test_wfmo_mixed2>,
&rl::simulate<test_wfmo_event_all>,
&rl::simulate<test_wfmo_event_any>,
&rl::simulate<test_wfmo_atomic>,
// thread local storage
&rl::simulate<tls_basic_test>,
&rl::simulate<tls_reset_test>,
&rl::simulate<tls_global_test>,
&rl::simulate<tls_win32_test>,
// dynamic thread
&rl::simulate<dyn_thread_basic_test>,
&rl::simulate<dyn_thread_win32_test>,
&rl::simulate<dyn_thread_visibility_test>,
#endif
};
for (size_t sched = 0; sched != rl::sched_count; ++sched)
{
std::cout << format((rl::scheduler_type_e)sched) << " tests:" << std::endl;
for (size_t i = 0; i != sizeof(tests)/sizeof(*tests); ++i)
{
//!!! make it work under sched_full
if (sched == rl::sched_full
&& (tests[i] == (rl::simulate_f)&rl::simulate<test_pthread_condvar>
|| tests[i] == (rl::simulate_f)&rl::simulate<test_win_condvar>))
continue;
rl::ostringstream stream;
rl::test_params params;
params.search_type = (rl::scheduler_type_e)sched;
params.iteration_count =
(params.test_result == rl::test_result_success ? 100000 : 500);
params.output_stream = &stream;
params.progress_stream = &stream;
params.context_bound = 2;
params.execution_depth_limit = 500;
if (false == tests[i](params))
{
std::cout << std::endl;
std::cout << "FAILED" << std::endl;
std::cout << stream.str();
std::cout << std::endl;
return 1;
}
else
{
std::cout << params.test_name << "...OK" << std::endl;
}
}
std::cout << std::endl;
}
rl::simulate_f scheduler_tests[] =
{
&rl::simulate<livelock_test>,
&rl::simulate<yield_livelock_test>,
};
std::cout << "full search scheduler tests:" << std::endl;
for (size_t i = 0; i != sizeof(scheduler_tests)/sizeof(*scheduler_tests); ++i)
{
rl::ostringstream stream;
rl::test_params params;
params.search_type = rl::sched_full;
params.output_stream = &stream;
params.progress_stream = &stream;
params.context_bound = 2;
params.execution_depth_limit = 500;
if (false == scheduler_tests[i](params))
{
std::cout << std::endl;
std::cout << "FAILED" << std::endl;
std::cout << stream.str();
return 1;
}
else
{
std::cout << params.test_name << "...OK" << std::endl;
}
}
std::cout << std::endl;
std::cout << "SUCCESS" << std::endl;
}
|
0e2027718d2e68f008a0532c3d1bd8843c4102a5 | 99a5e186d346e2ff964d40c974ddb9519ce61f7f | /algo/leetcode_p64.cpp | 5a5e8ed88d651ca8bad63b472e2b79a45f6c279a | [] | no_license | darthsuogles/phissenschaft | db93fdf965421915dfde7b931249459fe47b509d | 444c65e30c10fcf07fe66e86cc783b6a6b313d7d | refs/heads/develop | 2021-10-19T07:23:05.523455 | 2019-02-19T05:23:04 | 2019-02-19T05:23:04 | 84,702,314 | 2 | 0 | null | 2018-11-03T20:08:11 | 2017-03-12T05:28:39 | C++ | UTF-8 | C++ | false | false | 1,167 | cpp | leetcode_p64.cpp | /**
* LeetCode Problem 64
*
* Minimum path sum
*/
#include <vector>
#include <iostream>
using namespace std;
class Solution {
public:
int minPathSum(vector<vector<int> > &grid)
{
int m = grid.size();
if ( 0 == m ) return -1;
int n = grid[0].size();
if ( 0 == n ) return -1;
vector< vector<int> > tbl(m, vector<int>(n, 0));
tbl[m-1][n-1] = grid[m-1][n-1];
if ( m > 1 )
for (int i = m-2; i >= 0; --i) // right boundary
tbl[i][n-1] = tbl[i+1][n-1] + grid[i][n-1];
if ( 1 == n ) return tbl[0][n-1];
for (int j = n-2; j >= 0; --j) // bottom boundary
tbl[m-1][j] = tbl[m-1][j+1] + grid[m-1][j];
if ( 1 == m ) return tbl[m-1][0];
for (int i = m-2; i >= 0; --i)
for (int j = n-2; j >= 0; --j)
{
int dn = tbl[i+1][j];
int rt = tbl[i][j+1];
tbl[i][j] = min(dn, rt) + grid[i][j];
}
return tbl[0][0];
}
};
int main()
{
const int m = 3;
const int n = 4;
int A[m][n] = {{1,2,3,1},
{2,5,4,7},
{3,0,3,5}};
vector< vector<int> > grid;
for (int i = 0; i < m; ++i)
grid.push_back(vector<int>(A[i], A[i] + n));
Solution sol;
cout << sol.minPathSum(grid) << endl;
}
|
ec81b987cd33df9a6a91c42f83996ffca6e728ba | c03fd7482030098d4d4afdaef536b8bad4c1ad5f | /1052.爱生气的书店老板/solution.cpp | 5693689d16973e80210681b4d4183f36f49376bf | [] | no_license | Zhenghao-Liu/LeetCode_problem-and-solution | 79c88766c341c7789b5b01efd997fd6384edd8c3 | 09e9c9be2fc1d8f900e1e07fb5298c7c59596262 | refs/heads/master | 2022-11-02T00:15:21.089949 | 2022-10-07T12:06:41 | 2022-10-07T12:06:41 | 216,760,405 | 54 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 749 | cpp | solution.cpp | class Solution {
public:
int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int X) {
int sz=customers.size();
int all=0;
for (int i=0;i<sz;i++) {
if (grumpy.at(i)==0) {
all+=customers.at(i);
}
}
int ans=all;
int win=0;
for (int i=0;i<X-1;i++) {
if (grumpy.at(i)==1) {
win+=customers.at(i);
}
}
for (int i=X-1;i<sz;i++) {
if (grumpy.at(i)==1) {
win+=customers.at(i);
}
if (i-X>=0 && grumpy.at(i-X)==1) {
win-=customers.at(i-X);
}
ans=max(ans,win+all);
}
return ans;
}
};
|
2c0378435d527a3cc4569b18a3f1b51c967baad6 | 33e78d0ca1615d8ee4f8ade50702cf77dc995e40 | /activity_choice.cpp | ee843ecf718eaf27ef6442e243278c60bb84c236 | [] | no_license | yinyindecongcong/introduction_of_algorithm | fd39e6b2f2dd8c887f99dac581dea4717d4e3488 | de9aac4137b6eece60c0551aa4cf0db186adcda8 | refs/heads/master | 2021-01-01T18:05:59.986501 | 2017-07-29T13:13:23 | 2017-07-29T13:13:23 | 98,249,236 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 928 | cpp | activity_choice.cpp | #include <iostream>
#include <vector>
using namespace std;
//递归实现
void get_set(int s[], int f[], vector<int> &set, int t, int n){
int m = t + 1;
while (m <= n && s[m] < f[t]) m++;
if (m <= n){
set.push_back(m);
get_set(s, f, set, m, n);
}
}
//迭代实现
int get_set_for(int s[], int f[], int t, int n){
int c = 0;
int m = t + 1;
while (m <= n){
while (m <= n && s[m] < f[t]) m++;
if (m <= n) { c++; t = m; }
}
return c;
}
int main (){
//给定条件为十一个事件的开始时间和结束时间,假设已按结束时间排序
int s[] = {0, 1, 3, 0, 5, 3, 5, 6, 8, 8, 2, 12};//11个事件,大小为12
int f[] = {0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
//创建一个数组,存放选择的事件
vector <int> set;
//调用贪心算法的实现
get_set(s, f, set, 0, 11);//ak属于set,当f0 <= sk < fk <= f11
cout << set.size() << endl;
cout << get_set_for(s, f, 0, 11) << endl;
} |
d906f1e82c45cbdec8a8bfa6b21c34c87c2a05d9 | 1ad16fdad3ad63af9c081a72d4d4aa8613db9430 | /source/systemc/systems/TT_TB_sim.cpp | cd3defdfc13b447af59eb366dc12ccc7a0173996 | [] | no_license | camstutz/TT_TB | b27568166c7f986a977db4f898e6e37d4d71845c | 2c92d78192f4e7d82ad99de947f586e3f8b235e5 | refs/heads/master | 2021-01-20T09:00:59.724014 | 2016-08-11T08:37:44 | 2016-08-11T08:37:44 | 15,766,005 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,030 | cpp | TT_TB_sim.cpp | /*!
* @file TT_TB_sim.cpp
* @author Christian Amstutz
* @date August 17, 2015
*
* @brief
*/
/*
* Copyright (c) 2015 by Christian Amstutz
*/
#include "tt_tb.hpp"
#include "../TT_configuration/track_trigger_config.hpp"
//#include "../TT_configuration/baseline_config.hpp"
//#include "../TT_configuration/simple_tower_27_config.hpp"
//#include "../TT_configuration/dsd/dsd_config.hpp"
#include "../TT_configuration/debug_2x2/debug_2x2_config.hpp"
#include "sc_analyzer.hpp"
#include <systemc.h>
#include <iostream>
#include <sstream>
#include <utility>
//size_analyzer simulation_size;
int sc_main(int argc, char *agv[])
{
// Setting up analyzer for SystemC simulation
sc_analyzer analyzer;
analyzer.register_model_setup_start();
// Configure model
//track_trigger_config test_config = simple_tower_27_config();
//track_trigger_config test_config = dsd_config();
track_trigger_config test_config = debug_2x2_config();
test_config.hit_generator.input_file = "source/systemc/TT_configuration/debug_2x2/hits_debug_8track.txt";
tt_tb testbench("TT_TB", test_config);
//testbench.print_system();
// ----- Time unit / resolution setup --------------------------------------
// ----- Set up tracing ----------------------------------------------------
sc_trace_file *trace_file;
trace_file=sc_create_vcd_trace_file("TT_TB");
//trace_file->delta_cycles(true);
sc_trace(trace_file, testbench.LHC_clock, "LHC_clock");
// ----- Start simulation --------------------------------------------------
std::cout << "Model constructed." << std::endl;
std::cout << "Start simulation ..." << std::endl;
analyzer.register_simulation_start();
sc_start(10000, SC_NS);
analyzer.register_simulation_end();
sc_close_vcd_trace_file(trace_file);
#ifdef DEBUG
std::cout << "Simulation ended." << std::endl;
#endif
analyzer.print_report();
std::cout << std::endl;
//simulation_size.print_report();
return (0);
}
|
cb15935eee11bb459020e0870b8c714f2072c8cf | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/squid/new_hunk_6986.cpp | fe108ff816b412ab222631a4fb9edf947e3a8c32 | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,547 | cpp | new_hunk_6986.cpp | }
safe_free(tmp_line);
}
fclose(fp);
defaults_if_none();
configDoConfigure();
return 0;
}
static void
configDoConfigure(void)
{
LOCAL_ARRAY(char, buf, BUFSIZ);
memset(&Config2, '\0', sizeof(SquidConfig2));
/* Sanity checks */
if (Config.cacheSwap.swapDirs == NULL)
fatal("No cache_dir's specified in config file");
if (Config.Swap.maxSize < (Config.Mem.maxSize >> 10))
fatal("cache_swap is lower than cache_mem");
if (Config.Announce.period < 1) {
Config.Announce.period = 86400 * 365; /* one year */
Config.onoff.announce = 0;
}
if (Config.dnsChildren < 1)
fatal("No dnsservers allocated");
if (Config.dnsChildren > DefaultDnsChildrenMax) {
debug(3, 0) ("WARNING: dns_children was set to a bad value: %d\n",
Config.dnsChildren);
debug(3, 0) ("Setting it to the maximum (%d).\n",
DefaultDnsChildrenMax);
Config.dnsChildren = DefaultDnsChildrenMax;
}
if (Config.Program.redirect) {
if (Config.redirectChildren < 1) {
Config.redirectChildren = 0;
safe_free(Config.Program.redirect);
} else if (Config.redirectChildren > DefaultRedirectChildrenMax) {
debug(3, 0) ("WARNING: redirect_children was set to a bad value: %d\n",
Config.redirectChildren);
debug(3, 0) ("Setting it to the maximum (%d).\n", DefaultRedirectChildrenMax);
Config.redirectChildren = DefaultRedirectChildrenMax;
}
}
if (Config.Accel.host) {
snprintf(buf, BUFSIZ, "http://%s:%d", Config.Accel.host, Config.Accel.port);
Config2.Accel.prefix = xstrdup(buf);
|
2e775dd45ca020a574f8d01d5e0a80bd76a47b87 | f3e7a082d261d68467d15346118740c5a3db9fd8 | /nwnx/sinfarx/ai.cpp | 90161f23bc7c923266753f733f9df93e0d86581b | [] | no_license | DanielmGoulart/Sinfar-NWNX | 1dea766e8a1f5bf2c5667725f56ef26b6cc5d841 | ae76cf748c0e3be14d18050c62064de18fad4849 | refs/heads/master | 2021-08-22T10:14:22.792483 | 2017-11-30T00:21:05 | 2017-11-30T00:21:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,200 | cpp | ai.cpp | #include "ai.h"
#include "nwscript.h"
#include <sys/time.h>
#include <unistd.h>
#include "server.h"
using namespace nwnx::core;
using namespace nwnx::nwscript;
namespace nwnx { namespace ai {
std::unordered_set<CNWSArea*> active_areas;
int (*AddEventDeltaTime)(CServerAIMaster*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, void*) = (int (*)(CServerAIMaster*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, void*))0x08096388;
unsigned char d_ret_code_addobjtoai[0x20];
int (*AddObjectToAI_Org)(CServerAIMaster*, CNWSObject*, int) = (int (*)(CServerAIMaster*, CNWSObject*, int))&d_ret_code_addobjtoai;
int AddObjectToAI_HookProc(CServerAIMaster* ai_master, CNWSObject* object, int level)
{
if (module_loaded)
{
return AddObjectToAI_Org(ai_master, object, level);
}
return 1;
}
uint32_t re_use_timer_count = 0;
bool re_use_timer = false;
int64_t last_high_res_time = 0;
inline int64_t gettimeofday_int64()
{
struct timeval tv;
gettimeofday(&tv, NULL);
last_high_res_time = tv.tv_sec;
last_high_res_time *= 1000*1000;
last_high_res_time += tv.tv_usec;
return last_high_res_time;
}
unsigned char d_ret_code_highrestimer[0x20];
int64_t GetHighResolutionTimer_Override(CExoTimers* timer)
{
if (re_use_timer_count < 1000)
{
re_use_timer_count++;
return last_high_res_time;
}
else
{
//fprintf(stderr, "re use timer >= 1000 (%d)\n", re_use_timer_count);
re_use_timer_count = 0;
return gettimeofday_int64();
}
}
int64_t GetHighResolutionTimer_HookProc(CExoTimers* timer)
{
if (re_use_timer)
{
return GetHighResolutionTimer_Override(timer);
}
else
{
re_use_timer_count = 0;
return gettimeofday_int64();
}
}
unsigned char d_ret_code_aiupdateplc[0x20];
void (*AIUpdate_Placeable_Org)(CNWSPlaceable*) = (void (*)(CNWSPlaceable*))&d_ret_code_aiupdateplc;
void AIUpdate_Placeable_HookProc(CNWSPlaceable* placeable)
{
re_use_timer = true;
AIUpdate_Placeable_Org(placeable);
re_use_timer = false;
}
unsigned char d_ret_code_aiupdatedoor[0x20];
void (*AIUpdate_Door_Org)(CNWSDoor*) = (void (*)(CNWSDoor*))&d_ret_code_aiupdatedoor;
void AIUpdate_Door_HookProc(CNWSDoor* placeable)
{
re_use_timer = true;
AIUpdate_Door_Org(placeable);
re_use_timer = false;
}
int64_t main_loop_recover_time = 0;
int64_t last_main_loop_start_time = 0;
#define LOOP_PAUSE_TIME_USEC 10*1000
#define LOOP_MAX_ELAPSED_TIME_USEC 20*LOOP_PAUSE_TIME_USEC
void MainLoop_USleep(uint32_t usec)
{
int64_t current_time_int64 = gettimeofday_int64();
main_loop_recover_time += current_time_int64-last_main_loop_start_time;
if (main_loop_recover_time > LOOP_MAX_ELAPSED_TIME_USEC) main_loop_recover_time = LOOP_MAX_ELAPSED_TIME_USEC;
last_main_loop_start_time = current_time_int64;
if (main_loop_recover_time >= LOOP_PAUSE_TIME_USEC)
{
main_loop_recover_time -= LOOP_PAUSE_TIME_USEC;
}
else
{
int64_t sleep_time_usec = LOOP_PAUSE_TIME_USEC-main_loop_recover_time;
main_loop_recover_time = 0;
usleep(sleep_time_usec);
last_main_loop_start_time += sleep_time_usec;
}
}
std::vector<std::function<void()>> pending_x_events;
void add_pending_x_event(std::function<void()> pending_x_event)
{
pending_x_events.push_back(pending_x_event);
}
int (*GetPendingEvent)(CServerAIMaster*, uint32_t*, uint32_t*, uint32_t*, uint32_t*, uint32_t*, void**) = (int (*)
(CServerAIMaster*, uint32_t*, uint32_t*, uint32_t*, uint32_t*, uint32_t*, void**))0x8098334;
void (*UpdateModule)(CNWSModule*) = (void (*)(CNWSModule*))0x81c05fc;
void (*EventHandler_Module)(CNWSModule*, uint32_t, uint32_t, void*, uint32_t, uint32_t) = (void (*)
(CNWSModule*, uint32_t, uint32_t, void*, uint32_t, uint32_t))0x081b3f0c;
void (*EventHandler_Area)(CNWSArea*, uint32_t, uint32_t, void*, uint32_t, uint32_t) = (void (*)
(CNWSArea*, uint32_t, uint32_t, void*, uint32_t, uint32_t))0x080cc5f0;
void (*GetWorldTime)(CWorldTimer*, uint32_t*, uint32_t*) = (void (*)(CWorldTimer*, uint32_t*, uint32_t*))0x82416a4;
int (*EventPending)(CServerAIMaster*, uint32_t, uint32_t) = (int (*)(CServerAIMaster*, uint32_t, uint32_t))0x080982dc;
int (*UpdateDialog)(CNWSObject*) = (int (*)(CNWSObject*))0x81d0c38;
int (*ModuleAIUpdate)(CNWSModule*) = (int (*)(CNWSModule*))0x81b3dec;
int (*AreaAIUpdate)(CNWSArea*) = (int (*)(CNWSArea*))0x080cc3e0;
int update_counter = 0;
int last_ai_level_index = 0;
uint32_t last_ai_update_object_id = OBJECT_INVALID;
int64_t last_ai_update_start_time = 0;
inline bool update_object_ai_state(uint32_t object_id)
{
if (last_high_res_time-last_ai_update_start_time >= LOOP_PAUSE_TIME_USEC)
{
last_ai_update_object_id = object_id;
return false;
}
CGameObject* o = GetGameObject(object_id);
if (o)
{
o->vtable->AIUpdate(o);
UpdateDialog((CNWSObject*)o);
}
return true;
}
void (*DestroyScriptEvent)(CScriptEvent*, int) = (void (*)(CScriptEvent*, int))0x0806189C;
void (*DeleteScriptSituation)(CVirtualMachine*, CVirtualMachineScript*) = (void (*)(CVirtualMachine*, CVirtualMachineScript*))0x08264550;
void (*DeleteEventData)(CServerAIMaster*, uint32_t, void*) = (void (*)(CServerAIMaster*, uint32_t, void*))0x080976c0;
void UpdateAIState(CServerAIMaster* ai_master)
{
for (auto pending_x_event : pending_x_events)
{
pending_x_event();
}
pending_x_events.clear();
last_ai_update_start_time = last_high_res_time;
uint32_t time_high;
uint32_t time_low;
GetWorldTime(server_internal->srv_time_world, &time_high, &time_low);
while (EventPending(ai_master, time_high, time_low))
{
uint32_t event_params1;
uint32_t event_params2;
uint32_t event_params3;
uint32_t event_object_id;
uint32_t event_type;
void* event_data;
if (GetPendingEvent(ai_master, &event_params1, &event_params2, &event_params3, &event_object_id, &event_type, &event_data))
{
CGameObject* o_event = GetGameObject(event_object_id);
if (o_event)
{
if (o_event->type == OBJECT_TYPE_AREA)
{
CNWSArea* area = o_event->vtable->AsNWSArea(o_event);
EventHandler_Area(area, event_type, event_params3, event_data, event_params1, event_params2);
}
else if (o_event->type == OBJECT_TYPE_MODULE)
{
CNWSModule* module = o_event->vtable->AsNWSModule(o_event);
EventHandler_Module(module, event_type, event_params3, event_data, event_params1, event_params2);
}
else
{
o_event->vtable->EventHandler(o_event, event_type, event_params3, event_data, event_params1, event_params2);
}
}
else if (event_data)
{
DeleteEventData(ai_master, event_type, event_data);
}
}
}
//first complete the last_ai_level_index, if needed
if (last_ai_update_object_id != OBJECT_INVALID)
{
uint32_t* p_object = ai_master->ai_objects[last_ai_level_index].objects.data;
uint32_t* p_last_object = p_object+ai_master->ai_objects[last_ai_level_index].objects.len;
//go to the last updated object
while (p_object < p_last_object && *p_object != last_ai_update_object_id) p_object++;
//last updated object not found: start from the first index
if (p_object == p_last_object) p_object = ai_master->ai_objects[last_ai_level_index].objects.data;
while (p_object < p_last_object && update_object_ai_state(*p_object)) p_object++;
if (p_object < p_last_object) return; //time out
last_ai_level_index++;
}
for (; last_ai_level_index<=4; last_ai_level_index++)
{
if (update_counter % (1+(4-last_ai_level_index)*2) == 0)
{
uint32_t* p_object = ai_master->ai_objects[last_ai_level_index].objects.data;
uint32_t* p_last_object = p_object+ai_master->ai_objects[last_ai_level_index].objects.len;
while (p_object < p_last_object && update_object_ai_state(*p_object)) p_object++;
if (p_object < p_last_object) return; //time out
}
}
last_ai_level_index = 0;
last_ai_update_object_id = OBJECT_INVALID;
if (update_counter % 12 == 0)
{
ModuleAIUpdate(module);
for (auto iter=active_areas.begin(); iter!=active_areas.end(); iter++)
{
AreaAIUpdate(*iter);
}
}
update_counter++;
}
int (*RunScriptSituation)(CVirtualMachine*, CVirtualMachineScript*, uint32_t, int) = (int (*)(CVirtualMachine*, CVirtualMachineScript*, uint32_t, int))0x08262534;
unsigned char d_ret_code_dooreventhandler[0x20];
void (*DoorEventHandler_Org)(CNWSDoor*, uint32_t, uint32_t, void*, uint32_t, uint32_t) = (void (*)(CNWSDoor*, uint32_t, uint32_t, void*, uint32_t, uint32_t))&d_ret_code_dooreventhandler;
void DoorEventHandler_Hook(CNWSDoor* door, uint32_t event_type, uint32_t p3, void* event_data, uint32_t p5, uint32_t p6)
{
if (p3!=OBJECT_INVALID && cgoa.find(p3)==cgoa.end())
{
fprintf(stderr, "crash fix:DoorEventHandler:creature is null\n");
return;
}
return DoorEventHandler_Org(door, event_type, p3, event_data, p5, p6);
}
void (*RemoveEncounterFromArea)(CNWSEncounter*) = (void (*)(CNWSEncounter*))0x0818402c;
void (*DestroyEncounter)(CNWSEncounter*, int) = (void (*)(CNWSEncounter*, int))0x0817fae4;
unsigned char d_ret_code_encountereventhandler[0x20];
void (*EncounterEventHandler_Org)(CNWSEncounter*, uint32_t, uint32_t, void*, uint32_t, uint32_t) = (void (*)(CNWSEncounter*, uint32_t, uint32_t, void*, uint32_t, uint32_t))&d_ret_code_encountereventhandler;
void EncounterEventHandler_Hook(CNWSEncounter* encounter, uint32_t event_type, uint32_t p3, void* event_data, uint32_t p5, uint32_t p6)
{
if (event_type == 1 /* timed event */)
{
if (event_data)
{
RunScriptSituation(virtual_machine, static_cast<CVirtualMachineScript*>(event_data), encounter->obj.obj_id, 1);
}
}
else if (event_type == 11 /* destroy object*/)
{
RemoveEncounterFromArea(encounter);
DestroyEncounter(encounter, 3);
}
else if (event_type == 10 /* signal event */)
{
EncounterEventHandler_Org(encounter, event_type, p3, event_data, p5, p6);
}
else
{
fprintf(stderr, "EncounterEventHandler_Hook: unknonw event:%d\n", event_type);
}
}
unsigned char d_ret_code_wpeventhandler[0x20];
void (*WaypointEventHandler_Org)(CNWSWaypoint*, uint32_t, uint32_t, void*, uint32_t, uint32_t) = (void (*)(CNWSWaypoint*, uint32_t, uint32_t, void*, uint32_t, uint32_t))&d_ret_code_wpeventhandler;
void WaypointEventHandler_Hook(CNWSWaypoint* waypoint, uint32_t event_type, uint32_t p3, void* event_data, uint32_t p5, uint32_t p6)
{
if (event_type == 1 /* timed event */)
{
if (event_data)
{
RunScriptSituation(virtual_machine, static_cast<CVirtualMachineScript*>(event_data), waypoint->obj.obj_id, 1);
}
}
else
{
return WaypointEventHandler_Org(waypoint, event_type, p3, event_data, p5, p6);
}
}
void (*DestroySound)(CNWSSoundObject*, int) = (void (*)(CNWSSoundObject*, int))0x081e9948;
void (*RemoveSoundFromArea)(CNWSSoundObject*) = (void (*)(CNWSSoundObject*))0x081e9a10;
void SoundObjectEventHandler_Hook(CNWSSoundObject* sound, uint32_t event_type, uint32_t p3, void* event_data, uint32_t p5, uint32_t p6)
{
if (event_type == 1 /* timed event */)
{
if (event_data)
{
RunScriptSituation(virtual_machine, static_cast<CVirtualMachineScript*>(event_data), sound->obj.obj_id, 1);
}
}
else if (event_type == 11 /* destroy object*/)
{
RemoveSoundFromArea(sound);
DestroySound(sound, 3);
}
else
{
fprintf(stderr, "SoundObjectEventHandler_Hook: unknonw event:%d\n", event_type);
}
}
bool validate_timed_event_object(uint32_t object_id)
{
CGameObject* go = GetGameObject(object_id);
if (!go) return false;
switch (go->type)
{
case OBJECT_TYPE_STORE:
case OBJECT_TYPE_AREA:
case OBJECT_TYPE_CREATURE:
case OBJECT_TYPE_DOOR:
case OBJECT_TYPE_ITEM:
case OBJECT_TYPE_MODULE:
case OBJECT_TYPE_PLACEABLE:
case OBJECT_TYPE_AREA_OF_EFFECT:
case OBJECT_TYPE_TRIGGER:
case OBJECT_TYPE_WAYPOINT:
case OBJECT_TYPE_ENCOUNTER:
case OBJECT_TYPE_SOUND:
return true;
}
fprintf(stderr, "trying to assign a command to an invalid object(%d|%s)\n", go->type, get_last_script_ran().c_str());
return false;
}
CVirtualMachineScript* last_vm_script = NULL;
unsigned char d_ret_code_popcommand[0x20];
int (*StackPopCommand_Org)(CVirtualMachine*, CVirtualMachineScript**) = (int (*)(CVirtualMachine*, CVirtualMachineScript**))&d_ret_code_popcommand;
int StackPopCommand_Hook(CVirtualMachine* vm, CVirtualMachineScript** p_vm_script)
{
if (last_vm_script)
{
DeleteScriptSituation(virtual_machine, last_vm_script);
last_vm_script = NULL;
}
int ret = StackPopCommand_Org(vm, p_vm_script);
if (!ret) return ret;
last_vm_script = *p_vm_script;
return true;
}
int AddTimedEvent(CServerAIMaster* server_ai, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t event_object_id, uint32_t event_type, void* event_data)
{
if (event_data != last_vm_script)
{
fprintf(stderr, "AddTimedEvent called without the last popped command\n");
}
last_vm_script = NULL;
if (!validate_timed_event_object(event_object_id))
{
CGameObject* go = GetGameObject(event_object_id);
fprintf(stderr, "Assign/DelayComand called with a bad object type (%d|%x|%s)\n", (go?go->type:-1), event_object_id, get_last_script_ran().c_str());
DeleteScriptSituation(virtual_machine, static_cast<CVirtualMachineScript*>(event_data));
return false;
}
int ret = AddEventDeltaTime(server_ai, p1, p2, p3, event_object_id, event_type, event_data);
if (!ret)
{
DeleteScriptSituation(virtual_machine, static_cast<CVirtualMachineScript*>(event_data));
}
return ret;
}
int (*AddCommandAction)(CNWSObject*, CVirtualMachineScript*) = (int (*)(CNWSObject*, CVirtualMachineScript*))0x081C861C;
int ScriptAddCommandAction(CNWSObject* object, CVirtualMachineScript* vm_script)
{
if (vm_script != last_vm_script)
{
fprintf(stderr, "ScriptAddCommandAction called without the last popped command\n");
}
last_vm_script = NULL;
return AddCommandAction(object, vm_script);
}
int (*AddObjectToAI)(CServerAIMaster*, CNWSObject*, int) = (int (*)(CServerAIMaster*, CNWSObject*, int))0x080980e0;
int (*RemoveObjectFromAI)(CServerAIMaster*, CNWSObject*) = (int (*)(CServerAIMaster*, CNWSObject*))0x080962a8;
int OnAddObjectToAI_Bypass(CServerAIMaster* server_ai, CNWSObject* object, int ai_level)
{
return 1;
}
int (*GetItemWeight)(CNWSItem*) = (int (*)(CNWSItem*))0x81a6b90;
int OnEquip_GetWeight(CNWSItem* item)
{
AddObjectToAI(server_internal->srv_ai, &(item->obj), 0);
return GetItemWeight(item);
}
int OnUnequip_GetWeight(CNWSItem* item)
{
RemoveObjectFromAI(server_internal->srv_ai, &(item->obj));
return GetItemWeight(item);
}
CNWSArea* OnUpdateModule_GetAreaById(CServerExoApp* server, uint32_t object_id)
{
CNWSArea* area = GetAreaById(object_id);
if (area && area->num_players > 0) return area;
return NULL;
}
void UpdatePlayerCountInArea_Hook(CNWSArea* area)
{
//handled in different events
}
void init()
{
//sleep longer when the server is not busy, to reduce the CPU usage and not the lag
hook_call(0x0804bbf6, (uint32_t)MainLoop_USleep);
hook_function(0x82cc7a8, (unsigned long)GetHighResolutionTimer_HookProc, d_ret_code_highrestimer, 11);
hook_function(0x081e0614,(unsigned long)AIUpdate_Placeable_HookProc, d_ret_code_aiupdateplc, 9);
hook_function(0x08166d64,(unsigned long)AIUpdate_Door_HookProc, d_ret_code_aiupdatedoor, 9);
//all high res timer request in UpdateState()
hook_call(0x08095dcf, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x08095e47, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x08095e73, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x08095f0b, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x08096053, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x080960fe, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x08096189, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x080961c2, (uint32_t)GetHighResolutionTimer_Override);
hook_call(0x08096243, (uint32_t)GetHighResolutionTimer_Override);
hook_function(0x080980e0, (unsigned long)AddObjectToAI_HookProc, d_ret_code_addobjtoai, 12);
hook_function(0x08095d60, (unsigned long)UpdateAIState, d_ret_code_nouse, 9);
hook_function(0x08166e4c, (unsigned long)DoorEventHandler_Hook, d_ret_code_dooreventhandler, 12);
hook_function(0x0817fef0, (unsigned long)EncounterEventHandler_Hook, d_ret_code_encountereventhandler, 10);
hook_function(0x081f5110, (unsigned long)WaypointEventHandler_Hook, d_ret_code_wpeventhandler, 10);
hook_function(0x081E999C, (unsigned long)SoundObjectEventHandler_Hook, d_ret_code_nouse, 8);
//prevent StackPop without storing the result
hook_function(0x08262ebc, (unsigned long)StackPopCommand_Hook, d_ret_code_popcommand, 12);
hook_call(0x081FDD32, (uint32_t)AddTimedEvent);
hook_call(0x081FDE55, (uint32_t)AddTimedEvent);
hook_call(0x08233256, (uint32_t)ScriptAddCommandAction);
//set the default AI level of AoE
enable_write(0x081e9fea);
*(uint8_t*)0x081e9fea = 1;
//"" for creatures
enable_write(0x08113ff9);
*(uint8_t*)0x08113ff9 = 3;
//add object to ai... bypass for objects that dont need ai
enable_write(0x0819ee8b);
*(uint32_t*)(0x0819ee8b) = ((uint32_t)OnAddObjectToAI_Bypass-(uint32_t)0x0819ee8f);
enable_write(0x08083d16);
*(uint32_t*)(0x08083d16) = ((uint32_t)OnAddObjectToAI_Bypass-(uint32_t)0x08083d1a);
//but then need to add equipped items back in the ai array
enable_write(0x0811b773);
*(uint32_t*)(0x0811b773) = ((uint32_t)OnEquip_GetWeight-(uint32_t)0x0811b777);
enable_write(0x0811b861);
*(uint32_t*)(0x0811b861) = ((uint32_t)OnUnequip_GetWeight-(uint32_t)0x0811b865);
//do not update area with no players
hook_call(0x081c063a, (uint32_t)OnUpdateModule_GetAreaById);
hook_function(0x080d489c, (uint32_t)UpdatePlayerCountInArea_Hook, d_ret_code_nouse, 8);
hook_function(0x080d48cc, (uint32_t)UpdatePlayerCountInArea_Hook, d_ret_code_nouse, 9);
}
REGISTER_INIT(init);
VM_FUNC_NEW(SuspendArea, 285)
{
CNWSArea* area = GetAreaById(vm_pop_object());
if (area)
{
active_areas.erase(area);
if (area->num_players != 0)
{
fprintf(stderr, "area: %s has an invalid number of players: %d instead of 0\n", area->area_tag.text, area->num_players);
}
}
}
VM_FUNC_NEW(WokeUpArea, 286)
{
CNWSArea* area = GetAreaById(vm_pop_object());
if (area)
{
active_areas.insert(area);
}
}
}
}
|
38cce245a52f94aca53d80fceab2fd9e406cadb6 | 3ba97c04ab52817330cae22a4a27792db88818df | /PuzzleView.cpp | 3c159afc1d9d3a7d3ae52a6a8ca23be5d8735e24 | [] | no_license | zkt1061749991/bashumapintu | c4635bb940f87cb4c302e9c2e3b7e6ff143bb2bb | 628d40f330cd2b243cc1ca2cb68b1fc7d5211b27 | refs/heads/main | 2023-06-21T01:39:38.883579 | 2021-07-26T11:15:32 | 2021-07-26T11:15:32 | 389,603,627 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 17,481 | cpp | PuzzleView.cpp | // PuzzleView.cpp : implementation of the CPuzzleView class
//
#include "stdafx.h"
#include "Puzzle.h"
#include "P.h"
#include "PuzzleDoc.h"
#include "PuzzleView.h"
#include "LookPic.h"
#include "FreeLevelDlg.h"
#include "EndDlg.h"
//实现随机初始化必要的头文件
#include "time.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*********************************************************/
//实现音效必要的头文件和库
#include "windows.h"
#include "Mmsystem.h"
#pragma comment(lib,"WINMM.LIB")
/*********************************************************/
/////////////////////////////////////////////////////////////////////////////
// CPuzzleView
IMPLEMENT_DYNCREATE(CPuzzleView, CFormView)
BEGIN_MESSAGE_MAP(CPuzzleView, CFormView)
//{{AFX_MSG_MAP(CPuzzleView)
ON_WM_LBUTTONUP()
ON_COMMAND(ID_MENUITEM32776, OnEasy)
ON_COMMAND(ID_MENUITEM32777, OnMd)
ON_COMMAND(ID_MENUITEM32778, OnHard)
ON_COMMAND(ID_QUICKSTART, OnQuickstart)
ON_COMMAND(ID_MENUITEM32781, OnFreeLevel)
ON_COMMAND(ID_AOTUPLAYER, OnAotuplayer)
ON_COMMAND(ID_PIC_OPEN, OnPicOpen)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTONLOOKPIC, OnButtonlookpic)
ON_BN_CLICKED(IDC_BUTTONRESTART, OnButtonrestart)
ON_WM_KEYUP()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPuzzleView construction/destruction
CPuzzleView::CPuzzleView() : CFormView(CPuzzleView::IDD)
{
//{{AFX_DATA_INIT(CPuzzleView)
m_mstep = _T("0 步");
m_mtime = _T("0 秒 ");
//}}AFX_DATA_INIT
// TODO: add construction code here
/**********************************************************/
//局部刷新矩形赋值
mainrect.left = X;
mainrect.right = X+WIDE;
mainrect.top = Y;
mainrect.bottom = Y+WIDE;
/**********************************************************/
flag = false; //设定完成窗口可弹出
/**********************************************************/
//获取预设图片资源编号
PIC1 = IDB_BITMAP1;
PIC2 = IDB_BITMAP2;
PIC3 = IDB_BITMAP3;
PIC4 = IDB_BITMAP4;
PIC5 = IDB_BITMAP5;
PIC6 = IDB_BITMAP6;
PIC = PIC1; //默认得到PIC1
/*********************************************************/
//获取音效资源编号
WAV = IDR_WAVE1;
WAVEND = IDR_WAVE2;
WAVRESET = IDR_WAVE3;
/************************************************************************/
m_bitmap = new CBitmap();
m_bitmap->LoadBitmap(PIC); //装载图片资源到对象
/************************************************************************/
}
CPuzzleView::~CPuzzleView()
{
}
void CPuzzleView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPuzzleView)
DDX_Control(pDX, IDC_STEP, m_static2);
DDX_Control(pDX, IDC_STATICTIME, m_timecontrol);
DDX_Text(pDX, IDC_STEP, m_mstep);
DDX_Text(pDX, IDC_STATICTIME, m_mtime);
//}}AFX_DATA_MAP
}
//////////////////////////////界面按钮美化///////////////////////////////////
BOOL CPuzzleView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
this->Button1.LoadBitmaps(IDB_BUTTON1);//自绘
this->Button1.SubclassDlgItem(IDC_BUTTONLOOKPIC,this);
this->Button1.SizeToContent();
this->Button2.LoadBitmaps(IDB_BUTTON2);//自绘
this->Button2.SubclassDlgItem(IDC_BUTTONRESTART,this);
this->Button2.SizeToContent();
this->stepstyle();
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CPuzzleView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CPuzzleView printing
BOOL CPuzzleView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CPuzzleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CPuzzleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CPuzzleView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CPuzzleView diagnostics
#ifdef _DEBUG
void CPuzzleView::AssertValid() const
{
CFormView::AssertValid();
}
void CPuzzleView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CPuzzleDoc* CPuzzleView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPuzzleDoc)));
return (CPuzzleDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPuzzleView message handlers
///////////////////////////窗口绘制//////////////////////////////////////////////////////////
//拼图主体的绘制
void CPuzzleView::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
this->GetDocument()->p->draw(pDC, m_bitmap); //绘制拼图主体
if(this->GetDocument()->p->isok())
this->GetDocument()->p->drawlastpart(pDC, m_bitmap);
}
//计步器字体风格
void CPuzzleView::stepstyle()
{
m_static2.SubclassDlgItem(IDC_STEP,this);
LOGFONT log;
GetObject(::GetStockObject(DEFAULT_GUI_FONT),sizeof(log),&log);
log.lfHeight=22; //改
log.lfWidth=10; //改
log.lfCharSet=GB2312_CHARSET;
lstrcpy(log.lfFaceName, _T("华文彩云"));
font.CreateFontIndirect(&log);
m_static2.SetFont(&font);
}
//计时器设定
void CPuzzleView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_timecontrol.SubclassDlgItem(IDC_STATICTIME,this);
LOGFONT log;
GetObject(::GetStockObject(DEFAULT_GUI_FONT),sizeof(log),&log);
log.lfHeight=22;
log.lfWidth=10;
log.lfCharSet=GB2312_CHARSET;
lstrcpy(log.lfFaceName, _T("华文彩云"));
font.CreateFontIndirect(&log);
m_timecontrol.SetFont(&font);
CString strTime;
strTime.Format("%d 秒",++m_time);
this->m_mtime=strTime;
UpdateData(FALSE);
CFormView::OnTimer(nIDEvent);
}
//////////////////////鼠标按键响应及执行//////////////////////////////////////////////////////////
void CPuzzleView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(point.x>=mainrect.left&&point.x<=mainrect.right&&point.y>=mainrect.top&&point.y<=mainrect.bottom&&!flag)
{
if(this->GetDocument()->p->click(point,m_bitmap)) //当拼图对象判断可执行移动时
{
PlaySound(MAKEINTRESOURCE(WAV), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
if(!m_Timer)
{
this->SetTimer(1,1000,NULL);//设置定时器
this->m_Timer=true;
}
stepstyle();
++(this->m_step);
CString strStep;
strStep.Format("%d 步",this->m_step);
this->m_mstep=strStep;
UpdateData(FALSE);
}
this->InvalidateRect(&mainrect);
}
if(this->GetDocument()->p->isok()&&!flag) //每次操作完成判断是否拼完
{
this->KillTimer(1);
PlaySound(MAKEINTRESOURCE(WAVEND), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
EndDlg end;
end.DoModal();
}
CFormView::OnLButtonUp(nFlags, point);
}
//////////////////////自动拼好////////////////////////////////////////////////////////////
//延时器
void CPuzzleView::MySleep(DWORD nMilliseconds)
{
HANDLE hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
LARGE_INTEGER liDuring;
liDuring.QuadPart = - (__int64)nMilliseconds * 10000; //单位是100纳秒
if (hTimer == NULL)
RaiseException(EXCEPTION_INVALID_HANDLE, 0, 0, 0);
SetWaitableTimer(hTimer, &liDuring, 0, 0, 0, 0);
for(;;) {
DWORD dwRet = MsgWaitForMultipleObjects(1, &hTimer, FALSE, INFINITE, QS_ALLEVENTS);
if (dwRet == WAIT_OBJECT_0)
break;
else if (dwRet == WAIT_OBJECT_0 + 1) {
MSG msg;
while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE) != 0) {
if (AfxGetThread()->PumpMessage() == 0) {
AfxPostQuitMessage(0);
break;
}
}
}
}
CloseHandle(hTimer);
}
//自动拼好功能
void CPuzzleView::OnAotuplayer()
{
// TODO: Add your command handler code here
this->timereset();
this->stepreset();
int stepnum = this->GetDocument()->p->autoplayanswer(); //调用算法
if(!m_Timer)
{
this->SetTimer(1,1000,NULL);//设置定时器
this->m_Timer=true;
}
int s=0;
for(s = 0;s<stepnum;s++)
{
switch(this->GetDocument()->p->step[s])
{
case 0 : this->GetDocument()->p->move(0);break;
case 1 : this->GetDocument()->p->move(1);break;
case 2 : this->GetDocument()->p->move(2);break;
case 3 : this->GetDocument()->p->move(3);break;
}
stepstyle();
++(this->m_step);
CString strStep;
strStep.Format("%d 步",this->m_step);
this->m_mstep=strStep;
UpdateData(FALSE);
MySleep(300); //调用延时器模块,单位为毫秒
this->InvalidateRect(&mainrect);
}
if(this->GetDocument()->p->isok())
this->KillTimer(1);
}
///////////////////////////////初始化函数////////////////////////////////////////////////////////////
//拼图对象初始化
void CPuzzleView::reset()
{
PlaySound(MAKEINTRESOURCE(WAVRESET), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
flag = false;
int i;
if(this->GetDocument()->p==this->GetDocument()->p1)
i=1;
if(this->GetDocument()->p==this->GetDocument()->p2)
i=2;
if(this->GetDocument()->p==this->GetDocument()->p3)
i=3;
switch(i)
{
case 1:delete[] this->GetDocument()->p1;this->GetDocument()->p1=new P(3);this->GetDocument()->p=this->GetDocument()->p1;break;
case 2:delete[] this->GetDocument()->p2;this->GetDocument()->p2=new P(4);this->GetDocument()->p=this->GetDocument()->p2;break;
case 3:delete[] this->GetDocument()->p3;this->GetDocument()->p3=new P(5);this->GetDocument()->p=this->GetDocument()->p3;break;
}
}
//计步器初始化
void CPuzzleView::stepreset()
{
this->m_step=0;
CString strStep;
strStep.Format("%d 步",0);
this->m_mstep=strStep;
UpdateData(FALSE);
}
//计时器初始化
void CPuzzleView::timereset()
{
//////////////////////////重新开始时必要的初始化
m_timecontrol.SubclassDlgItem(IDC_STATICTIME,this);
LOGFONT log;
GetObject(::GetStockObject(DEFAULT_GUI_FONT),sizeof(log),&log);
log.lfHeight=22;
log.lfWidth=10;
log.lfCharSet=GB2312_CHARSET;
lstrcpy(log.lfFaceName, _T("华文彩云"));
font.CreateFontIndirect(&log);
m_timecontrol.SetFont(&font);
this->m_Timer=false;
this->KillTimer(1);
this->m_time=0;
CString strTime;
strTime.Format("%d 秒",0);
this->m_mtime=strTime;
UpdateData(FALSE);
}
//随机型初始化
void CPuzzleView::random()
{
PlaySound(MAKEINTRESOURCE(WAVRESET), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
flag = false;
srand(time(NULL));
int rlevel = rand()%3+1;
switch(rlevel)
{
case 1:delete[] this->GetDocument()->p1;this->GetDocument()->p1=new P(3);this->GetDocument()->p=this->GetDocument()->p1;break;
case 2:delete[] this->GetDocument()->p2;this->GetDocument()->p2=new P(4);this->GetDocument()->p=this->GetDocument()->p2;break;
case 3:delete[] this->GetDocument()->p3;this->GetDocument()->p3=new P(5);this->GetDocument()->p=this->GetDocument()->p3;break;
}
int rpic = rand()%6+1;
switch(rpic)
{
case 1:m_bitmap->DeleteObject();m_bitmap->LoadBitmap(IDB_BITMAP1);break;
case 2:m_bitmap->DeleteObject();m_bitmap->LoadBitmap(IDB_BITMAP2);break;
case 3:m_bitmap->DeleteObject();m_bitmap->LoadBitmap(IDB_BITMAP3);break;
case 4:m_bitmap->DeleteObject();m_bitmap->LoadBitmap(IDB_BITMAP4);break;
case 5:m_bitmap->DeleteObject();m_bitmap->LoadBitmap(IDB_BITMAP5);break;
case 6:m_bitmap->DeleteObject();m_bitmap->LoadBitmap(IDB_BITMAP6);break;
}
}
//随机开始
void CPuzzleView::OnQuickstart()
{
// TODO: Add your command handler code here
this->random();
this->timereset();
this->stepreset();
this->Invalidate();
}
//////////////////////////////////////////选择阶数//////////////////////////////////
void CPuzzleView::OnEasy()
{
// TODO: Add your command handler code here
this->reset();
this->GetDocument()->p=this->GetDocument()->p1;
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::OnMd()
{
// TODO: Add your command handler code here
this->reset();
this->GetDocument()->p=this->GetDocument()->p2;
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::OnHard()
{
// TODO: Add your command handler code here
this->reset();
this->GetDocument()->p=this->GetDocument()->p3;
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::OnFreeLevel()
{
// TODO: Add your command handler code here
FreeLevelDlg cin;
cin.DoModal();
}
void CPuzzleView::freelevel(int level)
{
PlaySound(MAKEINTRESOURCE(WAVRESET), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
delete GetDocument()->pfree;
this->GetDocument()->pfree=new P(level);
this->GetDocument()->p=this->GetDocument()->pfree;
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
/////////////////////////键盘响应模块////////////////////////////////////////////////////////////
BOOL CPuzzleView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYUP&&!flag)
{
if(pMsg->wParam>=37&&pMsg->wParam<=40) //限定只有方向键可响应
{
if(this->GetDocument()->p->move(pMsg->wParam-37))
{
PlaySound(MAKEINTRESOURCE(WAV), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
if(!m_Timer)
{
this->SetTimer(1,1000,NULL);//设置定时器
this->m_Timer=true;
}
stepstyle();
++(this->m_step);
CString strStep;
strStep.Format("%d 步",this->m_step);
this->m_mstep=strStep;
UpdateData(FALSE);
}
this->InvalidateRect(&mainrect);
if(this->GetDocument()->p->isok()&&!flag) //每次操作完成判断是否拼完
{
this->KillTimer(1);
PlaySound(MAKEINTRESOURCE(WAVEND), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
EndDlg end;
end.DoModal();
}
}
}
return CFormView::PreTranslateMessage(pMsg);
}
////////////////////////////////////选择图片//////////////////////////////////////////
void CPuzzleView::Onpic1()
{
m_bitmap->DeleteObject();
m_bitmap->LoadBitmap(IDB_BITMAP1);
reset();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::Onpic2()
{
m_bitmap->DeleteObject();
m_bitmap->LoadBitmap(IDB_BITMAP2);
reset();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::Onpic3()
{
m_bitmap->DeleteObject();
m_bitmap->LoadBitmap(IDB_BITMAP3);
reset();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::Onpic4()
{
m_bitmap->DeleteObject();
m_bitmap->LoadBitmap(IDB_BITMAP4);
reset();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::Onpic5()
{
m_bitmap->DeleteObject();
m_bitmap->LoadBitmap(IDB_BITMAP6);
reset();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
void CPuzzleView::Onpic6()
{
m_bitmap->DeleteObject();
m_bitmap->LoadBitmap(IDB_BITMAP5);
reset();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
//自定义图片
void CPuzzleView::OnPicOpen()
{
// TODO: Add your command handler code here
CFileDialog dlg(TRUE,NULL,NULL,NULL,"位图文件(*.bmp)|*.bmp"); //设置对话框
if(dlg.DoModal()==IDOK)
{
HBITMAP hbitmap=(HBITMAP)::LoadImage(NULL,dlg.GetFileName(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
m_bitmap->DeleteObject();
m_bitmap->Attach(hbitmap);
reset();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
}
CScrollBar* CPuzzleView::GetScrollBarCtrl(int nBar) const
{
// TODO: Add your specialized code here and/or call the base class
return CFormView::GetScrollBarCtrl(nBar);
}
//////////////////////////////////////按钮响应////////////////////////////////////////
void CPuzzleView::OnButtonlookpic()
{
// TODO: Add your control notification handler code here
LookPic *pic=new LookPic();
pic->Create(IDD_DIALOG3,this);
pic->ShowWindow(1);
}
void CPuzzleView::OnButtonrestart()
{
// TODO: Add your control notification handler code here
this->reset();
this->stepstyle();
this->timereset();
this-> stepreset();
this->InvalidateRect(&mainrect);
}
|
51c1bcdde6bfbe3c476758c4b6c8ac77151c7d32 | 8e4a3464a9cfb59466f7ce80b276e7ba87044bc7 | /Code Storage/Windows/Add Tray Function/TrayIcon.h | 41006259d0cb22c6d6dc96b06d2c7da805034120 | [] | no_license | lilingshui/code-refrence | 875daf6b69c6a1d0bb908e78cc718ccc967cf8e6 | 5bf07d09f12133a1fa10d8d3fb086f143f9f7c1e | refs/heads/master | 2023-08-16T16:38:43.215233 | 2023-07-23T09:54:00 | 2023-07-23T09:54:00 | 26,759,907 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 687 | h | TrayIcon.h | #pragma once
//call back msg send to the notify window
//to let the notify wnd deal
#define WM_TRAYCALLMSG (WM_USER + 1000)
class CTrayIcon : public CObject
{
public:
CTrayIcon();
virtual ~CTrayIcon();
public:
CWnd* GetNotifyWnd() const;
BOOL SetNotifyWnd(CWnd* pNtfWnd);
BOOL CreateIcon(CWnd* pNtfWnd, UINT uID, HICON hIcon,
LPCTSTR lpszTip);
BOOL DeleteIcon();
virtual LRESULT OnNotify(WPARAM WParam, LPARAM LParam);
BOOL SetTipText(UINT nID);
BOOL SetTipText(LPCTSTR lpszTip);
BOOL ChangeIcon(HICON hIcon);
BOOL ChangeIcon(UINT nID);
BOOL ChangeStandardIcon(LPCTSTR lpszIconName);
public:
NOTIFYICONDATA m_ntfData;
BOOL m_bIconExit;
CWnd* m_pNtfWnd;
};
|
072858151b65795523d1cfd70ef89223c5a3fee8 | e45f197f56ec6d81728e7aa857a536db9220f9e4 | /SkProjects/GNSS_Viewer_V2/NMEA.h | 6c0c96fc4aacc6b334785018d2664a9de4799799 | [] | no_license | asion0/AsionGitCodes | 82bfbaf5bf14eebeb375f3d83ecbcee5c45989ad | 7f493fb2a67e053387026a5652fc28f53e76f73c | refs/heads/master | 2016-09-10T20:12:25.665716 | 2013-12-31T09:11:47 | 2013-12-31T09:11:47 | 15,427,503 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 8,955 | h | NMEA.h | #pragma once
#include "stdafx.h"
#include "float.h"
enum NmeaType
{
MSG_Unknown = 0,
MSG_GGA,
MSG_GPGSA,
MSG_GLGSA,
MSG_BDGSA,
MSG_GNGSA,
MSG_GPGSV,
MSG_GLGSV,
MSG_BDGSV,
MSG_RMC,
MSG_GLL,
MSG_ZDA,
MSG_GNS,
MSG_VTG,
MSG_STI,
MSG_ERROR,
MSG_REBOOT,
};
typedef struct GPGGA
{
U16 Hour;
U16 Min;
F32 Sec;
D64 Latitude;
U08 Latitude_N_S;
D64 Longitude;
U08 Longitude_E_W;
U16 GPSQualityIndicator;
U16 NumsOfSatellites;
F32 HDOP;
F32 Altitude;
U08 Altitude_meters;
F32 GeoidalSeparation;
U08 GeoidalSeparation_meters;
F32 AgeDGPSData;
U16 DiffRefStaID;
}GPGGA, *pGPGGA, &rGPGGA;
typedef struct GPGLL
{
D64 Latitude;
U08 Latitude_N_S;
D64 Longitude;
U08 Longitude_E_W;
U16 Hour;
U16 Min;
F32 Sec;
U08 Status;
U08 ModeIndicator;
}GPGLL, *pGPGLL, &rGPGLL;
typedef struct GPGSA
{
U08 Auto_Manu_Mode;//A=Automatic,M=Manual
U16 Mode; //1=fix not available,2=2D,3=3D
U16 SatelliteID[MAX_SATELLITE];
F32 PDOP;
F32 HDOP;
F32 VDOP;
}GPGSA, *pGPGSA, &rGPGSA;
typedef struct GPVTG
{
F32 TrueCourse;//true course over ground in degrees(000.0 ~ 359.9)
F32 MagneticCourse;//Magnetic course over ground in degrees(000.0 ~ 359.9)
F32 SpeedKnots;
F32 SpeedKmPerHur;
U08 Mode;//N=not valid, A=Auto, D=Diff, E=Estimated, M=Manual, S=Simulator
}GPVTG, *pGPVTG, &rGPVTG;
typedef struct Satellite
{
U16 SatelliteID;
U16 Elevation;
U16 Azimuth;
U16 SNR;
}Satellite, *pSatellite, &rSatellite;
typedef struct GPGSV
{
U16 NumOfMessage;
U16 SequenceNum;
U16 NumOfSate;
U08 have_gps;
U08 have_gnss;
Satellite sates[4];
}GPGSV, *pGPGSV, &rGPGSV;
typedef struct GPRMC
{
U16 Hour;
U16 Min;
F32 Sec;
U08 Status;
D64 Latitude;
U08 Latitude_N_S;
D64 Longitude;
U08 Longitude_E_W;
F32 SpeedKnots;
F32 TrueCourse;
U16 Year;
U16 Month;
U16 Day;
F32 MagVar;
U08 MagVarDir;
U08 ModeIndicator;
}GPRMC, *pGPRMC, &rGPRMC;
typedef struct GPZDA
{
U16 Hour;
U16 Min;
F32 Sec;
U16 Day;
U16 Month;
U16 Year;
U16 LocalZoneHours;
U16 LocaZoneMinutes;
}GPZDA, *pGPZDA, &rGPZDA;
extern Satellite satellites_gps[MAX_SATELLITE];
extern Satellite satellites_gnss[MAX_SATELLITE];
extern Satellite satellites_bd[MAX_SATELLITE];
enum { INVALIDATE_SNR = 999 };
enum { MaxNmeaParam = 30 };
//#define UWM_GNSS_DATA_UPDATE (WM_USER + 0x1379)
class GnssData
{
public:
enum QualityMode {
Uninitial = 0,
Unlocated,
EstimatedMode,
DgpsMode,
PpsMode,
PositionFix2d,
PositionFix3d,
SurveyIn,
StaticMode,
DataNotValid,
AutonomousMode,
DgpsMode2,
};
enum UpdateNotify
{
UpdateData = 1 << 0,
UpdateTime = 1 << 1,
UpdateLatitude = 1 << 2,
UpdateLongitude = 1 << 3,
UpdateAltitude = 1 << 4,
UpdateDirection = 1 << 5,
UpdateSpeed = 1 << 6,
UpdateHdop = 1 << 7,
UpdateGpSate = 1 << 8,
UpdateGlSate = 1 << 9,
UpdateBdSate = 1 << 10,
UpdateFixMode = 1 << 11,
};
GnssData()
{
notifyWnd = NULL;
m_updateEvent = 0;
Init();
}
void Notify(UINT_PTR f)
{
if(notifyWnd && m_updateEvent)
{
::PostMessage(notifyWnd, m_updateEvent, f, 0);
}
}
void SetNotify(HWND h) { notifyWnd = h; }
UINT RegisterEventMessage()
{
m_updateEvent = ::RegisterWindowMessage("GnssDataUpdate-Event");
return m_updateEvent;
}
//Getter
U16 GetYear() const { return year; }
U16 GetMonth() const { return month; }
U16 GetDay() const { return day; }
U16 GetHour() const { return hour; }
U16 GetMinute() const { return minute; }
D64 GetSecond() const { return second; }
D64 GetLatitude() const { return latitude; }
U08 GetLatitudeNS() const { return latitudeNS; }
D64 GetLongitude() const { return longitude; }
U08 GetLongitudeEW() const { return longitudeEW; }
D64 GetAltitude() const { return altitude; }
D64 GetDirection() const { return trueCourse; }
D64 GetSpeed() const { return speedKnots; }
D64 GetHdop() const { return hdop; }
QualityMode GetFixMode() const { return fixMode; }
//Setter
void SetDate(U16 y, U16 m, U16 d)
{
GnssDataCs.Lock();
year = y;
month = m;
day = d;
GnssDataCs.Unlock();
}
void SetTime(U16 h, U16 m, D64 s)
{
GnssDataCs.Lock();
hour = h;
minute = m;
second = s;
GnssDataCs.Unlock();
}
void SetLatitude(D64 lat, U08 latNS)
{
GnssDataCs.Lock();
latitude = lat;
latitudeNS = latNS;
GnssDataCs.Unlock();
}
void SetLongitude(D64 lon, U08 lonEW)
{
GnssDataCs.Lock();
longitude = lon;
longitudeEW = lonEW;
GnssDataCs.Unlock();
}
void SetAltitude(D64 alt)
{
GnssDataCs.Lock();
altitude = alt;
GnssDataCs.Unlock();
}
void SetDirection(D64 d)
{
GnssDataCs.Lock();
trueCourse = d;
GnssDataCs.Unlock();
}
void SetSpeed(D64 s)
{
GnssDataCs.Lock();
speedKnots = s;
GnssDataCs.Unlock();
}
void SetHdop(D64 h)
{
GnssDataCs.Lock();
hdop = h;
GnssDataCs.Unlock();
}
void SetFixMode(U16 ggaQtyInd, U16 gpGsaMode, U16 glGsaMode, U16 bdGsaMode, U08 rmcModeInd);
void ClearData() { Init(); }
protected:
HWND notifyWnd;
//For date
U16 year;
U16 month;
U16 day;
//For time
U16 hour;
U16 minute;
D64 second;
//Latitude
D64 latitude;
U08 latitudeNS;
//Longitude
D64 longitude;
U08 longitudeEW;
//Altitude
D64 altitude;
//Direction
D64 trueCourse;
//Speed
D64 speedKnots;
//Hdop
D64 hdop;
//Fix Mode
QualityMode fixMode;
//Satellite sataus
Satellite gpSate[MAX_SATELLITE];
Satellite glSate[MAX_SATELLITE];
Satellite bdSate[MAX_SATELLITE];
void Init()
{
year = SHRT_MAX;
month = SHRT_MAX;
day = SHRT_MAX;
//For time
hour = SHRT_MAX;
minute = SHRT_MAX;
second = DBL_MAX;
//Latitude
latitude = DBL_MAX;
latitudeNS = ' ';
//Longitude
longitude = DBL_MAX;
longitudeEW = ' ';
//Altitude
altitude = DBL_MAX;
//Direction
trueCourse = DBL_MAX;
//Speed
speedKnots = DBL_MAX;
//Hdop
hdop = DBL_MAX;
//Fix Mode
fixMode = Uninitial;
//Satellite sataus
for(int i=0; i<MAX_SATELLITE; ++i)
{
gpSate[i].Azimuth = 0;
gpSate[i].Elevation = 0;
gpSate[i].SNR = SHRT_MAX;
gpSate[i].SatelliteID = SHRT_MAX;
glSate[i].Azimuth = 0;
glSate[i].Elevation = 0;
glSate[i].SNR = SHRT_MAX;
glSate[i].SatelliteID = SHRT_MAX;
bdSate[i].Azimuth = 0;
bdSate[i].Elevation = 0;
bdSate[i].SNR = SHRT_MAX;
bdSate[i].SatelliteID = SHRT_MAX;
}
}
private:
UINT m_updateEvent;
CCriticalSection GnssDataCs;
};
class NMEA
{
public:
enum GNSS_System
{
GsUnknown,
Gps,
Glonass,
Beidou,
Galileo,
};
enum NMEA_Type
{
NtUnknown,
PureGP,
MixGP,
GN,
};
protected:
static int LSB(char lsb);
static int MSB(char msb);
static int ParamInt(LPCSTR p, int first, int second, int defaultValue);
static char ParamChar(LPCSTR p, int first, int second, char defaultValue);
static float ParamFloat(LPCSTR p, int first, int second, float defaultValue);
static double ParamDouble(LPCSTR p, int first, int second, float defaultValue);
static int ScanDot(LPCSTR pt, int offset, int dot[MaxNmeaParam]);
static bool VarifyNmeaChecksum(LPCSTR pt, int len);
static bool GLLProc(GPGLL& rgll, LPCSTR pt, int len);
static bool GGAProc(GPGGA& rgga, LPCSTR pt, int len);
static bool GNSProc(GPGGA& rgga, LPCSTR pt, int len);
static bool GSVProc(GPGSV& rgsv, LPCSTR pt, int len);
static bool GSAProc(GPGSA& rgsa, LPCSTR pt, int len);
static bool RMCProc(GPRMC& rrmc, LPCSTR pt, int len);
static bool ZDAProc(GPZDA& rzda, LPCSTR pt, int len);
static bool VTGProc(GPVTG& rvtg, LPCSTR pt, int len);
static bool firstGsaIn;
public:
static GnssData gnssData;
static NMEA_Type nmeaType;
static GNSS_System GetGNSSSystem(int prn);
static GNSS_System GetGNSSSystem0(int prn);
static GNSS_System GetGNSSSystem1(int prn);
static NmeaType MessageType(LPCSTR pt, int len);
static bool GetFirstGsaIn() { return firstGsaIn; }
void ShowGPGLLmsg(GPGLL&, const char* ,int);
void ShowGPZDAmsg(GPZDA&, const char* ,int);
void ShowGPGGAmsg(GPGGA&, const char* ,int);
void ShowGNSmsg(GPGGA&, const char* ,int);
void ShowGPRMCmsg(GPRMC&, const char* ,int);
void ShowGPVTGmsg(GPVTG&, const char* ,int);
void ShowGPGSVmsg(GPGSV&, const char* ,int);
void ShowGPGSVmsg2(GPGSV&, GPGSV&, GPGSV&, const char* ,int);
void ShowGLGSVmsg(GPGSV& ,const char* ,int);
void ShowBDGSVmsg(GPGSV& ,const char* ,int);
void ShowGLGSAmsg(GPGSA& msg_glgsa,const char* pt,int offset);
void ShowGPGSAmsg(GPGSA& msg_gpgsa,const char* pt,int offset);
//void ShowGPGSAmsg(GPGSA& msg_gpgsa, GPGSA& msg_glgsa, GPGSA& msg_bdgsa, const char* pt, int offset);
void ShowGNGSAmsg(GPGSA& msg_gpgsa, GPGSA& msg_glgsa, GPGSA& msg_bdgsa, const char* pt, int offset);
void ShowBDGSAmsg(GPGSA& msg_glgsa,const char* pt,int offset);
};
|
a183f52c02e0cb7d46cd845cf0a2311a8b0c216f | 7ffab7f9085e5950944bad4e089fef14cd253772 | /Ref.h | 7b220647d49e8511e32d9f4e22d9bb996df87f5c | [] | no_license | blueeads/API-casual-2D-shooting-game | 357b8cc63fa63cde484de2ce00d7ff91bccd30b4 | 564065ad12a6ef8fb00a48de4d880dd3f17f0aa3 | refs/heads/master | 2020-05-04T00:19:44.843221 | 2019-04-01T14:36:29 | 2019-04-01T14:36:29 | 178,882,132 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 690 | h | Ref.h | #pragma once
#include "Game.h"
class CRef
{
protected:
CRef();
virtual ~CRef() = 0;
protected:
int m_iRef;
bool m_bEnable;
bool m_bLife;
string m_strTag;
public:
void AddRef()
{
++m_iRef;
}
int Release()
{
--m_iRef;
if (m_iRef == 0)
{
delete this;
return 0;
}
return m_iRef;
}
string GetTag() const
{
return m_strTag;
}
void SetTag(const string& strTag)
{
m_strTag = strTag;
}
void SetEnable(bool bEnable)
{
m_bEnable = bEnable;
}
void Die()
{
m_bLife = false;
}
bool GetEnable() const
{
return m_bEnable;
}
bool GetLife() const
{
return m_bLife;
}
};
|
59b6603dd075904fca2e75d403fe08e3ce7af32b | 0dc243cf9828bd1ca3acdefe02acf7febd7817fe | /src/IO_BinaryFileStream/BinaryFileStream_Save.cpp | 020d322398211066194ba6883fc84144f35e3a3b | [
"BSD-3-Clause"
] | permissive | Akranar/daguerreo | c8b38eb43cf4f59497c2d2d13ced92911bd3cc5a | 20999144d2c62e54837cd60462cf0db2cfb2d5c8 | refs/heads/master | 2020-05-22T12:38:22.550303 | 2011-10-05T22:55:26 | 2011-10-05T22:55:26 | 2,337,599 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,954 | cpp | BinaryFileStream_Save.cpp | #include "BinaryFileStream.h"
bool BinaryFileStream::Save(const Serializable * val)
{
endian.WriteIntType(stream, val);
if (ShouldSerialize(val))
{
val->SerializeTypeId(*this);
Save(*val);
}
return true;
}
bool BinaryFileStream::Save(const char * val, int length)
{
//If Null
if (!val)
{
if (!endian.WriteIntType(stream, 0)) return false;
return stream.good();
}
//Else
else
{
unsigned int string_length = strlen(val);
if (!endian.WriteIntType(stream, string_length)) return false;
for (unsigned int i = 0; i < string_length; ++i)
{
stream.put(val[i]);
}
return stream.good();
}
}
bool BinaryFileStream::Save(const unsigned int & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const unsigned char & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const unsigned short & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const unsigned long & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const int & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const float & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const double & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const char & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const bool & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const short & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const long & val)
{
endian.WriteIntType(stream, val);
return true;
}
bool BinaryFileStream::Save(const Serializable & val)
{
val.Serialize(*this);
return true;
}
bool BinaryFileStream::Save(const long double & val)
{
endian.WriteIntType(stream, val);
return true;
} |
ccfa55fbd33e01cf7bff442cf8918a26c7d7cf44 | ce2bd9cbb70270bd3f055c4df1bc4ec7a89c2b93 | /codeforces/750A_NewYearAndHurry.cpp | 2f6d16d3f6684f0972a11d604eb7d3e9d690daff | [] | no_license | harry-dev98/CompetitiveCodingSolutions | 600f1dfeedb125c55225047696f5f4b6d04f70a5 | 4e58101052a0d20f9620ad86126ab0ed331809b0 | refs/heads/master | 2023-03-08T22:11:22.834532 | 2021-02-22T16:04:36 | 2021-02-22T16:04:36 | 293,509,577 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 297 | cpp | 750A_NewYearAndHurry.cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int n, t;
cin>>n>>t;
t = 240-t;
int ans, sum=0;
for(int i=1; i<=n; i++){
sum+=5*i;
ans = i;
if(sum>t){
ans--;
break;
}
}
cout<<ans<<"\n";
return 0;
} |
cc29aea3bb07ba12cc16caa09b3b44f4864494aa | 9ad6fca920841dfd293f2605c2dba069c8fe4afd | /Components/Cpu.cpp | e89c73cfb36083ff0e26970b8c42071249905b9d | [] | no_license | rbenjami/GKrellM | 39a3674777cab228fdc2832f18b988fb7e54dd42 | 87f95c72a314b35739bfb6ccad4f6f47ba6cbb65 | refs/heads/master | 2021-05-28T15:29:25.127305 | 2015-01-18T18:08:07 | 2015-01-18T18:08:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,426 | cpp | Cpu.cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Cpu.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dsousa <dsousa@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/17 19:56:40 by dsousa #+# #+# */
/* Updated: 2015/01/18 19:00:41 by dsousa ### ########.fr */
/* */
/* ************************************************************************** */
# include "Cpu.hpp"
# include <iostream>
# include <sstream>
# include "../Engine/GeometricDrawer.hpp"
# include <sys/sysctl.h>
# include <sys/types.h>
#include <unistd.h>
#include <mach/mach_host.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <mach/mach.h>
#include <mach/processor_info.h>
#include <mach/mach_host.h>
Cpu::Cpu() : ProgramComponent()
{
return ;
}
Cpu::Cpu( Cpu const & cpy ) : ProgramComponent( cpy )
{
*this = cpy;
}
Cpu::~Cpu()
{
}
Cpu & Cpu::operator=( Cpu const & )
{
return (*this);
}
void Cpu::input( float delta )
{
(void)delta;
}
void Cpu::update( float delta )
{
std::stringstream ss;
uint64_t freq = 0;
size_t size = sizeof(freq);
char model[100];
size_t modellen = sizeof(model);
sysctlbyname("hw.cpufrequency_min", &freq, &size, NULL, 0);
sysctlbyname("machdep.cpu.brand_string", &model, &modellen, NULL, 0);
ss << "Cpu Model: " << model;
this->_cpuModel = ss.str();
ss.str("");
ss << "Nb Core: " << sysconf(_SC_NPROCESSORS_CONF);
this->_cpuCore = ss.str();
ss.str("");
ss << "Clock Speed: " << static_cast<float>(((freq / 1024.0) / 1024.0) / 1024.0) << "GHz";
this->_cpuClock = ss.str();
(void)delta;
}
void Cpu::ncursesRender( NcursesRenderEngine & renderEngine )
{
drawRectangleBorder();
drawString( Vector2f(3, 1), "Calculator Procedural Unijambiste:" );
drawString( Vector2f(3, 3), this->_cpuModel );
drawString( Vector2f(3, 4), this->_cpuCore );
drawString( Vector2f(3, 5), this->_cpuClock );
(void)renderEngine;
}
|
1ca6d9c7e7888ea99ada10a62d622d2016b32fac | 132e37d1fe2c04f1cd0656e0ddcf0bf2554be5da | /mainwindow.cpp | 5c58b55982a19a8ed1c9f203851835c6b8d81679 | [] | no_license | JustasBart/3DUnwrapper | 0092cbb63810a23ae7f43e1bc4dffd16c78e9ffd | 3edb7bc2f2f76ce42a2b5e32274da97d6f4183e7 | refs/heads/master | 2020-03-23T00:27:02.906779 | 2018-08-03T13:37:57 | 2018-08-03T13:37:57 | 140,864,017 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,186 | cpp | mainwindow.cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QRect"
using namespace cv;
static VideoCapture camera(0);
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
camera.set(cv::CAP_PROP_FRAME_WIDTH, IMAGE_WIDTH);
camera.set(cv::CAP_PROP_FRAME_HEIGHT, IMAGE_HEIGHT);
connect(&VideoTimer, SIGNAL(timeout()), this, SLOT(slotCompute()));
VideoTimer.start(20);
enableButtons(false);
laplacianMode = false;
guidesToggle = false;
upperFocus = 0;
lowerFocus = 0;
cancelStack = false;
focus_area_size = ui -> areaSpinBox -> value();
UN8NUMBEROFIMAGES = ui -> layersSpinBox -> value();
ROI_GROWTH = ui -> roiGrowthSpinBox -> value();
ENERGY_MULTIPLIER = ui -> energyThresholdSpinBox -> value();
}
MainWindow::~MainWindow()
{
cancelStack = true;
enableButtons(false);
serialOptiScan.disconnect();
serialOmni.disconnect();
delete ui;
}
void MainWindow::slotCompute()
{
camera >> LiveImage; // MAT
#ifdef RULER_GUIDE
drawGuide(LiveImage, (IMAGE_HEIGHT / 12), 5, 50);
#endif
if (laplacianMode)
{
cvtColor(LiveImage, LapGrey, CV_BGRA2GRAY);
Laplacian(LapGrey, LapMat, CV_8U, 1, ENERGY_MULTIPLIER, 0, BORDER_ISOLATED);
convertScaleAbs(LapMat, LapMat);
cv::GaussianBlur( LapMat, LapMat, cv::Point(11, 11), 0 );
// processHeight( LapMat[0] );
focus = cv::sum( LapMat )[0];
ui -> qualityLabel -> setText( "Quality: " + QString::number(focus) );
if (guidesToggle)
{
cv::line(LapMat, cv::Point(0, IMAGE_HEIGHT / 2), cv::Point(IMAGE_WIDTH, IMAGE_HEIGHT / 2), cv::Scalar(255), GUIDES_SIZE);
cv::line(LapMat, cv::Point((IMAGE_WIDTH / 2), 0), cv::Point((IMAGE_WIDTH / 2), IMAGE_HEIGHT), cv::Scalar(128), GUIDES_SIZE);
}
pixLiveImage = MatToQPixmap( LapMat );
}
else
{
ui -> qualityLabel -> setText( "Quality: Unavailable" );
if (guidesToggle)
{
cv::line(LiveImage, cv::Point(0, IMAGE_HEIGHT / 2), cv::Point(IMAGE_WIDTH, IMAGE_HEIGHT / 2), cv::Scalar(255), GUIDES_SIZE);
cv::line(LiveImage, cv::Point((IMAGE_WIDTH / 2), 0), cv::Point((IMAGE_WIDTH / 2), IMAGE_HEIGHT), cv::Scalar(128), GUIDES_SIZE);
}
pixLiveImage = MatToQPixmap( LiveImage );
}
ui -> videoLabel -> setPixmap( pixLiveImage );
if (serialOmni.isOpen())
{
QString message;
message = serialOmni.readLine();
if (message.length() > 0)
{
ui -> serialLabel -> setText( message );
message = "";
}
}
}
void MainWindow::handleSerialCommunications()
{
serialOptiScan.setPortName(OPTI_SCAN_SERIAL); // -> Might change
if(serialOptiScan.open(QIODevice::ReadWrite))
{
if(!serialOptiScan.setBaudRate(QSerialPort::Baud9600))
{
qDebug() << serialOptiScan.errorString();
return;
}
if(!serialOptiScan.setDataBits(QSerialPort::Data8))
{
qDebug() << serialOptiScan.errorString();
return;
}
if(!serialOptiScan.setParity(QSerialPort::NoParity))
{
qDebug() << serialOptiScan.errorString();
return;
}
if(!serialOptiScan.setStopBits(QSerialPort::OneStop))
{
qDebug() << serialOptiScan.errorString();
return;
}
if(!serialOptiScan.setFlowControl(QSerialPort::NoFlowControl))
{
qDebug() << serialOptiScan.errorString();
return;
}
enableButtons(true);
}
else
{
qDebug() << "Serial port could not be opened. Error: " << serialOptiScan.errorString();
enableButtons(false);
}
/////////////////////////////////////////////////////////
serialOmni.setPortName(OMNI_SERIAL); // -> Might change
if(serialOmni.open(QIODevice::ReadWrite))
{
if(!serialOmni.setBaudRate(QSerialPort::Baud115200))
{
qDebug() << serialOmni.errorString();
return;
}
if(!serialOmni.setDataBits(QSerialPort::Data8))
{
qDebug() << serialOmni.errorString();
return;
}
if(!serialOptiScan.setParity(QSerialPort::NoParity))
{
qDebug() << serialOmni.errorString();
return;
}
if(!serialOptiScan.setStopBits(QSerialPort::OneStop))
{
qDebug() << serialOmni.errorString();
return;
}
if(!serialOptiScan.setFlowControl(QSerialPort::NoFlowControl))
{
qDebug() << serialOmni.errorString();
return;
}
enableButtons(true);
}
else
{
qDebug() << "Serial port could not be opened. Error: " << serialOmni.errorString();
enableButtons(false);
}
}
void MainWindow::on_leftButton_pressed()
{
moveGantry( GantryPosition::Left, ui -> moveByDistance -> value() );
}
void MainWindow::on_rightButton_pressed()
{
moveGantry(GantryPosition::Right, ui -> moveByDistance -> value() );
}
void MainWindow::on_upButton_pressed()
{
moveGantry(GantryPosition::Up, ui -> moveByDistance -> value() );
}
void MainWindow::on_downButton_pressed()
{
moveGantry(GantryPosition::Down, ui -> moveByDistance -> value() );
}
void MainWindow::on_zeroButton_pressed()
{
serialOptiScan.write("H\r");
qSleep(100);
}
void MainWindow::on_homeButton_pressed()
{
serialOptiScan.write(("L " + QString::number(findMoveZoomRatio()) + " \r").toStdString().c_str());
}
void MainWindow::on_connectButton_pressed()
{
if (ui -> connectButton -> text() == "Connect" )
{
handleSerialCommunications();
if (serialOptiScan.isOpen())
{
ui -> connectButton -> setText("Connected");
ui -> connectButton -> setEnabled(false);
}
}
}
void MainWindow::enableButtons(bool state)
{
ui -> upButton -> setEnabled(state);
ui -> zeroButton -> setEnabled(state);
ui -> leftButton -> setEnabled(state);
ui -> homeButton -> setEnabled(state);
ui -> rightButton -> setEnabled(state);
ui -> downButton -> setEnabled(state);
ui -> minFocus -> setEnabled(state);
ui -> maxFocus -> setEnabled(state);
ui -> lowerBoundry -> setEnabled(state);
ui -> upperBoundry -> setEnabled(state);
ui -> widthSpinBox -> setEnabled(state);
ui -> heightSpinBox -> setEnabled(state);
ui -> layersSpinBox -> setEnabled(state);
ui -> strengthSpinBox -> setEnabled(state);
ui -> roiGrowthSpinBox -> setEnabled(state);
ui -> energyThresholdSpinBox -> setEnabled(state);
ui -> areaSpinBox -> setEnabled(state);
}
void MainWindow::StackImagesFocusFast(Mat threeDimentional)
{
Mat SavedImage[UN8NUMBEROFIMAGES];
Mat GreyImage[UN8NUMBEROFIMAGES];
Mat LaplacianImage[UN8NUMBEROFIMAGES];
focusBy = lowerFocus < upperFocus ? ((upperFocus - lowerFocus) / UN8NUMBEROFIMAGES) : ((lowerFocus - upperFocus) / UN8NUMBEROFIMAGES);
focusHeight = lowerFocus < upperFocus ? lowerFocus : upperFocus;
for(int i = 0; i < UN8NUMBEROFIMAGES; i++)
{
if (!cancelStack)
{
zoomOutHeight();
camera >> SavedImage[i];
focusHeight += focusBy;
qDebug() << QString::number(focusHeight);
cvtColor( SavedImage[i], GreyImage[i], CV_BGRA2GRAY );
Laplacian( GreyImage[i], LaplacianImage[i], CV_8U, 1, ENERGY_MULTIPLIER, 0, BORDER_ISOLATED );
convertScaleAbs( LaplacianImage[i], LaplacianImage[i] );
cv::GaussianBlur( LaplacianImage[i], LaplacianImage[i], cv::Point(11, 11), 0 );
}
else
return;
}
if (!cancelStack)
{
processHeight( LaplacianImage, threeDimentional );
cv::medianBlur(threeDimentional, threeDimentional, 31);
}
}
void MainWindow::zoomOutHeight(void)
{
QString zoomOutMessage = "F_DIR " + QString::number( focusHeight ) + " \n";
serialOmni.write( zoomOutMessage.toStdString().c_str() );
qSleep(100);
if (findFocusLevel() != focusHeight)
{
pM("The focus level could not be set. Re-sending height level!");
serialOmni.write( zoomOutMessage.toStdString().c_str() );
qSleep(100);
if (findFocusLevel() != focusHeight)
{
pM("The focus level could not be set for the second time!!!");
}
}
}
void MainWindow::processHeight(Mat heigthMat[], Mat finalMat)
{
int heightWeight = 255 / UN8NUMBEROFIMAGES;
for(int i = 0; i < IMAGE_WIDTH; i += focus_area_size)
{
for(int j = 0; j < IMAGE_HEIGHT; j += focus_area_size)
{
bestFocus = 0.0;
bestImage = 0;
roi = cv::Rect(i, j, focus_area_size, focus_area_size);
for(int n = 1; n < ROI_GROWTH; n *= 2)
{
for(int k = 0; k < UN8NUMBEROFIMAGES; k++)
{
if (!cancelStack)
{
Mat focusArea;
try
{
heigthMat[k](roi).copyTo( focusArea );
}
catch (Exception e)
{
qDebug() << "Could not paste in";
break;
}
focus = cv::sum( focusArea )[0];
if (focus > FOCUS_ENERGY) // Pass filter
{
if (focus > bestFocus)
{
bestFocus = focus;
bestImage = k;
break;
}
}
else
increaseROI(i, j, &roi, n);
}
else
return;
}
}
roi = cv::Rect(i, j, focus_area_size, focus_area_size);
finalMat(roi) = Scalar(bestImage * heightWeight);
}
}
}
void MainWindow::increaseROI(int width, int height, cv::Rect *region, int position)
{
if (width - position >= 0 && height - position >= 0)
{
if (width + focus_area_size + position <= IMAGE_WIDTH && height + focus_area_size + position <= IMAGE_HEIGHT)
{
region -> x -= position;
region -> y -= position;
region -> width += position;
region -> height += position;
}
}
}
int MainWindow::findFocusLevel()
{
int replyValues[REPLY_ATTEMPTS];
int goodValue;
QString reply;
for (int i = 0; i < REPLY_ATTEMPTS; i++)
{
serialOmni.write("F_READ \n");
if (serialOmni.waitForReadyRead(2000))
{
reply = serialOmni.readLine();
replyValues[i] = reply.toInt();
qSleep(100);
}
else
ui -> serialLabel -> setText("FAILLED TO GET A REPLY!");
}
for (int i = 0; i < REPLY_ATTEMPTS; i++)
{
if (replyValues[i] == replyValues[i + 1])
{
goodValue = replyValues[i];
}
}
return goodValue;
}
void MainWindow::pN(double num)
{
qDebug() << QString::number(num);
}
void MainWindow::pM(QString mes)
{
qDebug() << mes;
}
void MainWindow::pS(cv::Size s)
{
qDebug() << "Width: " << QString::number(s.width) << "Height: " << QString::number(s.height);
}
void MainWindow::testImage(Mat img)
{
QPixmap myQPixmap;
myQPixmap = MatToQPixmap( img );
qSleep(1000);
ui -> testLabel -> setPixmap( myQPixmap );
}
void MainWindow::qSleep(int ms)
{
QTime dieTime = QTime::currentTime().addMSecs(ms);
while (QTime::currentTime() < dieTime)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
double MainWindow::findMoveZoomRatio(void)
{
double replyValues[REPLY_ATTEMPTS];
double goodValue = 0.0;
QString reply;
for (int i = 0; i < REPLY_ATTEMPTS; i++)
{
serialOmni.write("PIXEL2MM \n");
if (serialOmni.waitForReadyRead(2000))
{
reply = serialOmni.readLine();
replyValues[i] = reply.toDouble();
qSleep(100);
}
else
ui -> serialLabel -> setText("FAILLED TO GET A REPLY!");
}
for (int i = 0; i < REPLY_ATTEMPTS; i++)
{
if (fabs(replyValues[i] - replyValues[i + 1]) <= 0.1 * fabs(replyValues[i]))
{
goodValue = replyValues[i];
}
}
return goodValue;
}
void MainWindow::on_laplacianButton_pressed()
{
if (ui -> laplacianButton -> text() == "Regular")
{
ui -> laplacianButton -> setText("Laplacian");
laplacianMode = true;
}
else
{
ui -> laplacianButton -> setText("Regular");
laplacianMode = false;
}
}
void MainWindow::on_guidesButon_pressed()
{
if (ui -> guidesButon -> text() == "Guides on")
{
ui -> guidesButon -> setText("Guides off");
guidesToggle = false;
}
else
{
ui -> guidesButon -> setText("Guides on");
guidesToggle = true;
}
}
void MainWindow::drawGuide(Mat mat, int guideHeight, int guideThickness, int guideSpacing)
{
cv::line(mat, cv::Point(0, IMAGE_HEIGHT / 2), cv::Point(IMAGE_WIDTH, IMAGE_HEIGHT / 2), cv::Scalar(0, 0, 255), guideThickness);
int h = 0;
bool guide = false;
for(int i = 0; i < IMAGE_WIDTH; i += guideSpacing)
{
if (i == 0)
continue;
if (guide == false)
{
h = guideHeight;
guide = true;
}
else
{
h = guideHeight / 2;
guide = false;
}
if (i == (IMAGE_WIDTH / 2))
cv::line(mat, cv::Point(i, (IMAGE_HEIGHT / 2) + h + 5), cv::Point(i, (IMAGE_HEIGHT / 2) - h - 5), cv::Scalar(255, 255, 255), 3);
else
cv::line(mat, cv::Point(i, (IMAGE_HEIGHT / 2) + h), cv::Point(i, (IMAGE_HEIGHT / 2) - h), cv::Scalar(0, 0, 255), guideThickness);
}
}
void MainWindow::on_lowerBoundry_pressed()
{
lowerFocus = findFocusLevel();
if (lowerFocus == upperFocus)
{
ui -> lBoundLabel -> setText("INVALID");
lowerFocus = 0;
return;
}
ui -> lBoundLabel -> setText( QString::number(lowerFocus) );
stackAllow[0] = true;
checkStackStatus();
}
void MainWindow::on_upperBoundry_pressed()
{
upperFocus = findFocusLevel();
if (upperFocus == lowerFocus)
{
ui -> uBoundLabel -> setText("INVALID");
upperFocus = 1;
return;
}
ui -> uBoundLabel -> setText( QString::number(upperFocus) );
stackAllow[1] = true;
checkStackStatus();
}
void MainWindow::checkStackStatus(void)
{
if (stackAllow[0] && stackAllow[1])
ui -> stackButton -> setEnabled(true);
else
ui -> stackButton -> setEnabled(false);
}
void MainWindow::moveGantry(GantryPosition instruction, double millimeter)
{
QString sendCommand;
switch(instruction)
{
case GantryPosition::Left:
{
sendCommand = "R " + QString::number( static_cast<int>(millimeter * STEP_MM_MULTIPLIER) ) + "\r";
qDebug() << "Going left by " + QString::number(millimeter) + "mm... " + QString::number(static_cast<int>(millimeter * STEP_MM_MULTIPLIER)) + " Steps.";
break;
}
case GantryPosition::Right:
{
sendCommand = "L " + QString::number( static_cast<int>(millimeter * STEP_MM_MULTIPLIER) ) + "\r";
qDebug() << "Going right by " + QString::number(millimeter) + "mm... " + QString::number(static_cast<int>(millimeter * STEP_MM_MULTIPLIER)) + " Steps.";
break;
}
case GantryPosition::Up:
{
sendCommand = "F " + QString::number( static_cast<int>(millimeter * STEP_MM_MULTIPLIER) ) + "\r";
qDebug() << "Going up by " + QString::number(millimeter) + "mm... " + QString::number(static_cast<int>(millimeter * STEP_MM_MULTIPLIER)) + " Steps.";
break;
}
case GantryPosition::Down:
{
sendCommand = "B " + QString::number( static_cast<int>(millimeter * STEP_MM_MULTIPLIER) ) + "\r";
qDebug() << "Going down by " + QString::number(millimeter) + "mm... " + QString::number(static_cast<int>(millimeter * STEP_MM_MULTIPLIER)) + " Steps.";
break;
}
}
serialOptiScan.write(sendCommand.toStdString().c_str());
}
void MainWindow::on_minFocus_pressed()
{
serialOmni.write("F_DIR 4096 \n");
if (findFocusLevel() != 4096)
{
pM("The minimum focus level could not be set. Re-sending the mininmum focus level!");
serialOmni.write("F_DIR 4096 \n");
qSleep(100);
if (findFocusLevel() != 4096)
{
pM("The minimum focus level could not be set for the second time.");
}
}
}
void MainWindow::on_maxFocus_pressed()
{
serialOmni.write("F_DIR 53248 \n");
if (findFocusLevel() != 53248)
{
pM("The maximum focus level could not be set. Re-sending the maximum focus level!");
serialOmni.write("F_DIR 53248 \n");
if (findFocusLevel() != 53248)
{
pM("The maximum focus level could not be set for the second time.");
}
}
}
void MainWindow::on_stackButton_pressed()
{
if (ui -> stackButton -> text() == "StackImages")
{
cancelStack = false;
enableButtons(false);
ui -> stackButton -> setText("Cancel");
int x, y;
int wTimes = ui -> widthSpinBox -> value();
int hTimes = ui -> heightSpinBox -> value();
on_minFocus_pressed();
double zRatio = findMoveZoomRatio();
double xMoveBy = zRatio * IMAGE_WIDTH;
double yMoveBy = zRatio * IMAGE_HEIGHT;
Mat full3DMat(hTimes * IMAGE_HEIGHT, wTimes * IMAGE_WIDTH, CV_8UC1, Scalar(0));
for (y = 0; y < hTimes; y++)
{
for (x = 0; x < wTimes; x++)
{
if(wTimes > 1 && x > 0)
{
moveGantry(GantryPosition::Right, xMoveBy);
qSleep(2000);
}
cv::Rect roi(x * IMAGE_WIDTH, y * IMAGE_HEIGHT, IMAGE_WIDTH, IMAGE_HEIGHT);
Mat partOf3DMat(IMAGE_HEIGHT, IMAGE_WIDTH, CV_8UC1, Scalar(0));
StackImagesFocusFast( partOf3DMat );
partOf3DMat.copyTo( full3DMat(roi) );
testImage(full3DMat);
}
if (hTimes > 1 && (y + 1) != hTimes)
{
if (wTimes > 1)
{
moveGantry(GantryPosition::Left, (wTimes - 1) * xMoveBy );
qSleep(500);
}
moveGantry(GantryPosition::Down, yMoveBy );
qSleep(7000);
}
}
testImage(full3DMat);
QTime currentTime = QTime::currentTime();
QString label = "../../DepthMap_" + QString::number(currentTime.minute()) + "_" + QString::number(currentTime.second()) + ".jpg";
imwrite(label.toStdString().c_str(), full3DMat);
cancelStack = true;
enableButtons(true);
ui -> stackButton -> setText("StackImages");
}
else
{
cancelStack = true;
enableButtons(true);
ui -> stackButton -> setText("StackImages");
}
}
void MainWindow::on_layersSpinBox_valueChanged(int arg1)
{
UN8NUMBEROFIMAGES = arg1;
}
void MainWindow::on_strengthSpinBox_valueChanged(int arg1)
{
ENERGY_MULTIPLIER = arg1;
}
void MainWindow::on_roiGrowthSpinBox_valueChanged(int arg1)
{
ROI_GROWTH = arg1;
}
void MainWindow::on_areaSpinBox_valueChanged(int arg1)
{
focus_area_size = arg1;
}
|
be3f83d5f2abd40341bb73937d6d94f948053d05 | 4e635c90d731f3ae4eeb528d3a9aa1584a0daff5 | /Triangle.h | 89a40ba98e7bbde45e78ac24595b42f8fd739f6f | [] | no_license | Hanel32/Cplusplus_FLTK_Graphical_Code_Dump | 716c1d4bcc42b8c9f9236f7467442727e1e73221 | 4ddde3bac7707515d95599d6ea12a6fad55f9489 | refs/heads/master | 2021-07-13T04:06:07.200187 | 2017-10-15T19:08:47 | 2017-10-15T19:08:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 489 | h | Triangle.h | /*
Triangle class derived from Shape class
*/
#ifndef TRIANGLE_H
#define TRIANGLE_H
#include "Shape.h"
class Triangle : public Shape {
private:
unsigned int width, height;
Point b;
Point c;
public:
Triangle();
Triangle(Point a, Point b, Point c, Color d);
void set_width(unsigned int w);
unsigned int get_width() const;
void set_height(unsigned int h);
unsigned int get_height() const;
void draw();
void print_parameters();
};
#endif
|
f976da2a37599bf85f1684177dd8637bfe1f98c9 | 48692078c003a3afec487aead471129ba4e96355 | /Playfile/playfile.h | d541b21817290c3f04d3973bcd22f52ce723b1a7 | [] | no_license | Quickest-Owl/Gagot-TLV-Samples | fbbeabaedc2b4bdc882a09d3758cf7fc247ee290 | 99e804e93f3a9c47facb1580baa6e5b3b28a0302 | refs/heads/master | 2021-04-30T08:46:01.856481 | 2018-02-25T22:20:32 | 2018-02-25T22:20:32 | 121,382,213 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,437 | h | playfile.h | /**********************************************************************\
Project : TA Roofs / player app
Filename : playfile.h
Purpose : Main file for ZED/Realsense CMD player
Created : 20.2.2018
Author : Sergey Krasnitsky, (c) Quickest-Owl Ltd
\**********************************************************************/
#ifndef _PLAYFILE_H
#define _PLAYFILE_H
#include <opencv2/opencv.hpp> // OpenCV API
#include "str.h"
/*
******************************************************************************
Basic interface class for all Cameras Players.
All functions may throw exceptions.
******************************************************************************
*/
class PlayerB
{
public:
virtual void Construct (int64 jump = -1, cchar* file = nullptr); // Construct the object. If file param is supplied then use it as input stream. Otherwise to work with correspondent Camera HW
virtual int64 GetNextFrame () = 0; // Called from PlayerB::Loop(), returns frame number (IFrame), should fill PlayerB::Frame. Returning -1 means a 1st frame still was not appeared
virtual unsigned GetDepthCoordinate (int x, int y) = 0; // Get Depth value for the X,Y pixel in Frame
void onMouse (int event, int x, int y, int flags); // OpenCV onMouse callback for a specific Player object
void* GetWindowHandle() { return cvGetWindowHandle(PlayerName); } // Gets current player OpenCV window handle
void Loop(); // Endless loop body function to show the video, called from main() while loop
protected:
STRING PlayerName; // Player OpenCV Window name
STRING OverlapText; // Overlapped text formated by PlayerB::onMouse() func
cv::Mat Frame; // Current frame RGB data filled by GetNextFrame()
cv::Size FrameSize; // Frame size
int LastX, LastY; // X,Y coordinates in the Frame after last mouse press
int64 Nframes; // Keeps amount of frames or -1 when it's unknown. Actually it should contain last frame number.
int64 Iframe; // Frame sequence number, initialized in PlayerB::Construct as -1, in order to detect first interations with no data
int64 Ijump; // When != 0, the playing starts from Iframe == Ijump
bool Paused; // When true, the player should be paused on a current frame
};
#endif // _PLAYFILE_H
|
2feea1631cf8487529da106108f788854b23bd43 | 3493e7ff9d76c6a74199d0af2c6a1e4ef2b8221a | /src/point_cloud_manipulation.cpp | 533f1867f054f1c294a619f5840630a5a951bc59 | [] | no_license | GT-RAIL/remote_manipulation_markers | 7c31c7656b9e5a0f8fba9222f0fe1750ccd9da67 | 0c243bfe2ad037563b177856bc03c3dcb268f84e | refs/heads/develop | 2021-01-13T03:59:08.972735 | 2020-05-13T20:41:35 | 2020-05-13T20:41:35 | 78,131,197 | 7 | 1 | null | 2020-05-14T16:58:11 | 2017-01-05T16:53:12 | C++ | UTF-8 | C++ | false | false | 2,781 | cpp | point_cloud_manipulation.cpp | #include <remote_manipulation_markers/point_cloud_manipulation.h>
using std::string;
void PointCloudManipulation::transformPointCloud(const sensor_msgs::PointCloud2 &cloud_in,
sensor_msgs::PointCloud2 &cloud_out, std::string frame, tf::TransformListener &tf_listener)
{
pcl_ros::transformPointCloud(frame, cloud_in, cloud_out, tf_listener);
cloud_out.header.frame_id = frame;
}
void PointCloudManipulation::transformPointCloud(const sensor_msgs::PointCloud2 &cloud_in,
pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud_out, std::string frame, tf::TransformListener &tf_listener)
{
sensor_msgs::PointCloud2 temp_cloud_out;
transformPointCloud(cloud_in, temp_cloud_out, frame, tf_listener);
fromSensorMsgs(temp_cloud_out, cloud_out);
}
void PointCloudManipulation::transformPointCloud(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud_in,
sensor_msgs::PointCloud2 &cloud_out, std::string frame, tf::TransformListener &tf_listener)
{
sensor_msgs::PointCloud2 temp_cloud_in;
toSensorMsgs(cloud_in, temp_cloud_in);
transformPointCloud(temp_cloud_in, cloud_out, frame, tf_listener);
}
void PointCloudManipulation::transformPointCloud(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud_in,
pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud_out, std::string frame, tf::TransformListener &tf_listener)
{
sensor_msgs::PointCloud2 temp_cloud_in, temp_cloud_out;
toSensorMsgs(cloud_in, temp_cloud_in);
transformPointCloud(temp_cloud_in, temp_cloud_out, frame, tf_listener);
fromSensorMsgs(temp_cloud_out, cloud_out);
}
void PointCloudManipulation::fromSensorMsgs(const sensor_msgs::PointCloud2 &cloud_in,
pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud_out)
{
pcl::PCLPointCloud2::Ptr temp_cloud(new pcl::PCLPointCloud2);
pcl_conversions::toPCL(cloud_in, *temp_cloud);
pcl::fromPCLPointCloud2(*temp_cloud, *cloud_out);
}
void PointCloudManipulation::fromSensorMsgs(const sensor_msgs::PointCloud2 &cloud_in,
pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_out)
{
pcl::PCLPointCloud2::Ptr temp_cloud(new pcl::PCLPointCloud2);
pcl_conversions::toPCL(cloud_in, *temp_cloud);
pcl::fromPCLPointCloud2(*temp_cloud, *cloud_out);
}
void PointCloudManipulation::toSensorMsgs(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud_in,
sensor_msgs::PointCloud2 &cloud_out)
{
pcl::PCLPointCloud2::Ptr temp_cloud(new pcl::PCLPointCloud2);
pcl::toPCLPointCloud2(*cloud_in, *temp_cloud);
pcl_conversions::fromPCL(*temp_cloud, cloud_out);
}
void PointCloudManipulation::toSensorMsgs(const pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_in,
sensor_msgs::PointCloud2 &cloud_out)
{
pcl::PCLPointCloud2::Ptr temp_cloud(new pcl::PCLPointCloud2);
pcl::toPCLPointCloud2(*cloud_in, *temp_cloud);
pcl_conversions::fromPCL(*temp_cloud, cloud_out);
}
|
4c1fc42edf96c77da9760cbf5de6401c69ddadfe | 09e0347fa988563a252d9f0b49ba1cf54cca30a1 | /soemetadbsrv/src/metadbsrvdefaultstore.cpp | 7c670689f1f630af2fc03080223edc112fd0f348 | [] | no_license | janlt/SOE | 501b94a94fe8d53a3289db057b34bb2ad907b33e | 883ea8fb5b04393e387a8af819d7eb500269d6fe | refs/heads/master | 2020-09-19T03:10:07.868212 | 2020-03-21T07:19:38 | 2020-03-21T07:19:38 | 224,192,571 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,519 | cpp | metadbsrvdefaultstore.cpp | /**
* @file metadbsrvdefaultstore.cpp
* @author Jan Lisowiec <jlisowiec@gmail.com>
* @version 1.0
* @brief Soe Session API
*
*
* @section Copyright
*
* Copyright Notice:
*
* Copyright 2014-2019 Jan Lisowiec jlisowiec@gmail.com,
*
*
* This product is free software; you can redistribute it and/or,
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This software is distributed in the hope that it will be useful.
*
*
* @section Licence
*
* GPL 2 or later
*
*
* @section Description
*
* soe_soe
*
* @section Source
*
*
*
*
*/
/*
* metadbsrvdefaultstore.cpp
*
* Created on: Nov 25, 2017
* Author: Jan Lisowiec
*/
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <list>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/type_index.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <chrono>
#include <boost/random.hpp>
extern "C" {
#include "soeutil.h"
}
#include "soelogger.hpp"
using namespace SoeLogger;
#include <rocksdb/cache.h>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/slice.h>
#include <rocksdb/table.h>
#include <rocksdb/utilities/options_util.h>
#include <rocksdb/db.h>
#include <rocksdb/utilities/backupable_db.h>
#include <rocksdb/merge_operator.h>
#include <rocksdb/options.h>
#include <rocksdb/utilities/transaction.h>
#include <rocksdb/utilities/stackable_db.h>
#include <rocksdb/utilities/transaction_db.h>
#include <rocksdb/utilities/checkpoint.h>
using namespace rocksdb;
#include "soe_bind_api.hpp"
#include "rcsdbargdefs.hpp"
#include "rcsdbidgener.hpp"
#include "rcsdbfacadeapi.hpp"
#include "rcsdbfacadebase.hpp"
#include "rcsdbconfigbase.hpp"
#include "rcsdbconfig.hpp"
#include "rcsdbfilters.hpp"
#include "metadbsrvrcsdbname.hpp"
#include "metadbsrvrcsdbsnapshot.hpp"
#include "metadbsrvrcsdbstorebackup.hpp"
#include "metadbsrvrcsdbstoreiterator.hpp"
#include "metadbsrvrangecontext.hpp"
#include "metadbsrvrcsdbstore.hpp"
#include "metadbsrvrcsdbspace.hpp"
#include "metadbsrvrcsdbcluster.hpp"
#include "metadbsrvdefaultstore.hpp"
using namespace std;
using namespace RcsdbFacade;
namespace Metadbsrv {
DefaultStore::DefaultStore():
Store()
{}
void DefaultStore::Open(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::Close(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::Repair(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::Put(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::Get(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::Delete(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::GetRange(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::Merge(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::Iterate(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::CreateGroup(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::DestroyGroup(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::WriteGroup(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::StartTransaction(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::CommitTransaction(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::RollbackTransaction(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::CreateSnapshotEngine(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::CreateSnapshot(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::DestroySnapshot(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::ListSnapshots(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::CreateBackupEngine(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::CreateBackup(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::RestoreBackup(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::DestroyBackup(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::DestroyBackupEngine(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::ListBackups(LocalAdmArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::CreateIterator(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
void DefaultStore::DestroyIterator(LocalArgsDescriptor &args) throw(RcsdbFacade::Exception) { throw RcsdbFacade::Exception("No such store", RcsdbFacade::Exception::eNoFunction); }
int GetState() { return 100000; }
uint32_t GetRefCount() { return 100000; }
}
|
535dc8e35e6a174c56696d56d6cb7a05ac24a52a | ac97923bbb7f4703f15a6ae0c7f9f05fd7cc83b8 | /code/ioDevice.cpp | 4bb41d9947a8581926db104c55b0a2fe80d0e528 | [] | no_license | AishwaryaPS/SystemEmulator-DP | 431ce861833e9b9bfdffdf8d0125b6fde794da8e | efc2777882378ea559eb08e0471faac7b68e3760 | refs/heads/master | 2020-09-22T12:47:02.889823 | 2019-12-13T17:27:02 | 2019-12-13T17:27:02 | 225,201,379 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,307 | cpp | ioDevice.cpp | #include "ioDevice.h"
/*
private static instance variables of each device type to be redeclared here
and assigned nullptr
*/
keyboard* keyboard :: _instance = nullptr;
mouse* mouse :: _instance = nullptr;
int ioDevice::count = 0;
/*
ioDevice implementations ---------------------------------------------------------------------------
*/
ioDevice :: ioDevice(){
#ifdef DEBUG
cout << "ioDevice ctor \n";
#endif
}
ioDevice :: ~ioDevice(){
#ifdef DEBUG
cout << "ioDevice dtor \n";
#endif
}
/*
factory method to create io device required
*/
ioDevice* ioDevice :: create(deviceType type){
#ifdef DEBUG
cout << "\nSTEP 1 : create IO Obj for type :"<< type <<"\n";
#endif
switch(type){
case typeKeyboard :
#ifdef DEBUG
cout << "create - > keyboard object \n";
#endif
return keyboard::createInstance();
break;
case typeMouse :
#ifdef DEBUG
cout << "create -> mouse obj \n";
#endif
return mouse::createInstance();
break;
default :
#ifdef DEBUG
cout << "create -> invlaid type \n";
#endif
throw invalid_argument("Device type specified not supported :(");
}
}
/*
keyboard implementations ---------------------------------------------------------------------------
*/
keyboard :: keyboard(){
portNum = ioDevice::count;
++ioDevice::count;
#ifdef DEBUG
cout << "keyboard ctor - portNum: "<<portNum<<"\n" ;
#endif
}
keyboard :: ~keyboard(){
#ifdef DEBUG
cout << "keyboard dtor \n";
#endif
keyboard :: _instance = nullptr;
}
string keyboard :: whoami(){
cout << "ioDevice : keyboard \n";
return "keyboard";
}
void keyboard :: startApplication(string application){
cout << "Event triggered by keyboard\n";
#ifdef DEBUG
cout << "\nSTEP 2 : Io Obj triggers event\n";
#endif
clickEnter(application);
}
keyboard* keyboard:: createInstance(){
if(keyboard :: _instance == nullptr){
#ifdef DEBUG
cout << "creating a new instance of keyboard \n";
#endif
keyboard :: _instance = new keyboard();
}
return keyboard :: _instance;
}
void keyboard :: clickEnter(string application){
#ifdef DEBUG
cout << "click Enter method called\n";
#endif
port* adaptor = new port(portNum);
adaptor->startApplication(application);
delete adaptor;
}
/*
mouse implementations ---------------------------------------------------------------------------
*/
mouse :: mouse(){
portNum = ioDevice::count;
++ioDevice::count;
#ifdef DEBUG
cout << "mouse ctor -- portNum: "<<portNum<<"\n" ;
#endif
}
mouse :: ~mouse(){
#ifdef DEBUG
cout << "mouse dtor \n";
#endif
mouse :: _instance = nullptr;
}
string mouse :: whoami(){
cout << "ioDevice : mouse \n";
return "mouse";
}
void mouse :: startApplication(string application){
cout << "Event triggered by mouse : "<<application<<"\n";
#ifdef DEBUG
cout << "\nSTEP 2 : Io Obj triggers event\n";
#endif
doubleClick(application);
}
mouse* mouse:: createInstance(){
if(mouse :: _instance == nullptr){
#ifdef DEBUG
cout << "creating a new instance of mouse \n";
#endif
mouse :: _instance = new mouse();
}
return mouse :: _instance;
}
void mouse :: doubleClick(string application){
#ifdef DEBUG
cout << "double click method called\n";
#endif
port* adaptor = new port(portNum);
adaptor->startApplication(application);
delete adaptor;
}
/*
port adaptor implementations ---------------------------------------------------------------------------
*/
port :: port(int portNum): bus(portNum, "") {
#ifdef DEBUG
cout << "port adaptor ctor - for port no : "<<portNum<<"\n";
#endif
}
port :: ~port(){
#ifdef DEBUG
cout << "port dtor\n";
#endif
}
void port :: startApplication(string application){
this->application= application;
#ifdef DEBUG
cout <<"\nSTEP 3 : port calls startapplication \n";
cout <<"inturn calling storeToMemory of bus\n";
#endif
storeToMemory(true);
}
string port :: whoami(){
cout <<"port adaptor\n";
return "port-adaptor\n";
} |
b39f4e6b801accc37c42c8d3148a960ef3dfcc19 | e9f3aed4d520b7a2634ae6bd9467a5504dbbdfa2 | /node/Node.hpp | 048084582ad2b997ff6ecc4d3aa3d844385574ef | [] | no_license | tfoerch/LMP | 4b7e50f72796e96f8c40691c3cfab1c5c64f2ca9 | b82e2665778e6d984f166ba2242add0f78cf4857 | refs/heads/master | 2021-01-01T03:48:57.646358 | 2018-12-18T22:01:17 | 2018-12-18T22:01:17 | 58,702,868 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,065 | hpp | Node.hpp | #ifndef LIBS_Node_HPP_
#define LIBS_Node_HPP_
/*
* Node.hpp
*
* Created on: 19.02.2015
* Author: tom
*/
#include "node/NodeApplicationIF.hpp"
#include <map>
#include <set>
namespace lmp
{
namespace node
{
class Node : public NodeApplicationIF
{
public:
explicit Node(
lmp::DWORD nodeId);
virtual ~Node(){}
private:
typedef std::map<lmp::DWORD, // nodeId
neighbor::NeighborApplicationIF*> NeighborNodes;
typedef std::set<lmp::DWORD> SetOfIdentifiers;
// implement NeighborFactoryIF
virtual neighbor::NeighborApplicationIF const* do_getNeighbor(
lmp::DWORD neighborNodeId) const;
virtual neighbor::NeighborApplicationIF* do_accessNeighbor(
lmp::DWORD neighborNodeId);
virtual neighbor::NeighborApplicationIF* do_createNeighbor(
lmp::DWORD neighborNodeId);
virtual bool do_removeNeighbor(
lmp::DWORD neighborNodeId);
// implement NeighbordjacencyObserverIF
virtual void do_neighborAdjacencyAdded(
lmp::DWORD neighborNodeId,
cc::IpccApplicationIF& ipcc);
virtual void do_neighborAdjacencyRemoved(
lmp::DWORD neighborNodeId,
cc::IpccApplicationIF& ipcc);
// implement NodeLocalCCIdPoolIF
virtual lmp::DWORD do_registerFreeLocalCCId();
virtual bool do_checkLocalCCId(
lmp::DWORD localCCId) const;
virtual bool do_registerLocalCCId(
lmp::DWORD localCCId);
virtual bool do_releaseLocalCCId(
lmp::DWORD localCCId);
// implement NodeApplicationIF
virtual void do_enable();
virtual void do_disable();
virtual lmp::DWORD do_getNodeId() const;
lmp::DWORD m_nodeId;
NeighborNodes m_neighborNodes;
SetOfIdentifiers m_assignedLocalCCIds;
};
} // namespace node
} // namespace lmp
#endif /* LIBS_Node_HPP_ */
|
895679422d78b25937e2408bbd4f2448ff8284e8 | 61a358201d270dbad93f13e2a36f6e9271097e4e | /hash/CSha2In512.cpp | c082db733a4c211beca6761e8570e6ccc169887c | [
"MIT"
] | permissive | skdltmxn/Checkmate | 0840ff2c8a52b64a47414d2a42284a10c394f813 | 3cf4330da4e3c60c75b7d9b80bb33b985df9a15a | refs/heads/master | 2020-04-22T21:15:23.969468 | 2014-05-22T07:49:29 | 2014-05-22T07:49:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,426 | cpp | CSha2In512.cpp | /*
* CSha2In512.cpp
*
* Copyright (c) 2013-2014 skdltmxn <supershop@naver.com>
*
* Implements CSha2In512 class
*
*/
#include "stdafx.h"
#include "CSha2.h"
#include "../helper/CEndian.h"
#define CH(x, y, z) (((x) & (y)) ^ ((~x) & (z)))
#define MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
const DWORD CSha2In512::k[] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
CSha2In512::CSha2In512(int length) : CHash(512, length)
{
}
CSha2In512::~CSha2In512()
{
}
void CSha2In512::_hashBlock(const BYTE *pbBlock)
{
// 512 bit block
DWORD w[16];
DWORD a = h[0];
DWORD b = h[1];
DWORD c = h[2];
DWORD d = h[3];
DWORD e = h[4];
DWORD f = h[5];
DWORD g = h[6];
DWORD j = h[7];
// Decode block
CEndian::decodeBig32(w, pbBlock, 64);
for (int i = 0; i < 64; ++i)
{
int s = i & 0x0f;
DWORD s0, s1, t1, t2;
if (i >= 16)
{
s0 = ROR32(w[(s + 1) & 0x0f], 7) ^ ROR32(w[(s + 1) & 0x0f], 18) ^ (w[(s + 1) & 0x0f] >> 3);
s1 = ROR32(w[(s + 14) & 0x0f], 17) ^ ROR32(w[(s + 14) & 0x0f], 19) ^ (w[(s + 14) & 0x0f] >> 10);
w[s] = w[s] + s0 + w[(s + 9) & 0x0f] + s1;
}
s0 = ROR32(a, 2) ^ ROR32(a, 13) ^ ROR32(a, 22);
s1 = ROR32(e, 6) ^ ROR32(e, 11) ^ ROR32(e, 25);
t1 = j + s1 + CH(e, f, g) + k[i] + w[s];
t2 = s0 + MAJ(a, b, c);
j = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
h[0] += a;
h[1] += b;
h[2] += c;
h[3] += d;
h[4] += e;
h[5] += f;
h[6] += g;
h[7] += j;
}
void CSha2In512::_padBlock(const BYTE *pbBlock, const QWORD qwLength)
{
register DWORD dwBlockSize = (getBlockSize() >> 3);
DWORD dwTailLength = (qwLength % dwBlockSize);
DWORD dwPadding = dwBlockSize - dwTailLength;
if (dwPadding <= 8) dwPadding += dwBlockSize;
dwPadding += dwTailLength;
PBYTE pbPaddingBlock = new (std::nothrow) BYTE[dwPadding];
if (!pbPaddingBlock) return;
memset(pbPaddingBlock, NULL, dwPadding);
memcpy(pbPaddingBlock, pbBlock, dwTailLength);
// First byte of padding
pbPaddingBlock[dwTailLength] = 0x80;
// Append length in bits
QWORD qwBitLength = qwLength << 3;
CEndian::encodeBig64(&pbPaddingBlock[dwPadding - 8], &qwBitLength, 8);
_hashBlock(pbPaddingBlock);
// If there is one more padded block
if (dwPadding > dwBlockSize)
_hashBlock(pbPaddingBlock + dwBlockSize);
delete []pbPaddingBlock;
}
void CSha2In512::_finalize(BYTE *pbHash)
{
CEndian::encodeBig32(pbHash, h, getOutputSize() >> 3);
} |
812d63d433fe1ed0dc781c9ea82fa45fd873e2cf | 4cbff5b4445ced1d085350e54a6491f456ad87ee | /src/motor_setup.cpp | 0e0406ddf989e17e7ef45a974dc1a83c2b0f8f1b | [] | no_license | Sajantoor/4549A | 74b85988a579d3525f49220401da541d1b6783c2 | dccdd63948e990ef70608e6a9069b7831f4d1b79 | refs/heads/master | 2022-04-24T12:43:58.441785 | 2020-04-25T18:48:05 | 2020-04-25T18:48:05 | 193,636,524 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,003 | cpp | motor_setup.cpp | #include "main.h"
#include "motor_setup.h"
#include "motor_sensor_init.h"
void drive_set(int speed) {
drive_left.move(speed);
drive_left_b.move(speed);
drive_right.move(speed);
drive_right_b.move(speed);
}
void turn_set(int speed) {
drive_left.move(speed);
drive_left_b.move(speed);
drive_right.move(-speed);
drive_right_b.move(-speed);
}
void strafe(int speed) {
drive_left.move(-speed);
drive_left_b.move(speed);
drive_right.move(speed);
drive_right_b.move(-speed);
}
void left_drive_set(int speed) {
drive_left.move(speed);
drive_left_b.move(speed);
}
void right_drive_set(int speed) {
drive_right.move(speed);
drive_right_b.move(speed);
}
void reset_drive_encoders() {
drive_left.tare_position();
drive_left_b.tare_position();
drive_right.tare_position();
drive_right_b.tare_position();
left_encoder.reset();
right_encoder.reset();
}
void set_drive(int left_speed, int right_speed) {
left_drive_set(left_speed);
right_drive_set(right_speed);
}
|
510ba975b6ffdb29829ab3b691fcfb6aebf56a7f | 6ca08dc2de5fe6a74c481389463548412c576418 | /Core/Util/Ubox/Box1iTool.cpp | 3314fa7d240fadba25c3123100a253d27cf3d12e | [] | no_license | nirch/homage-cv-app | d2e3fbb70d876adc73fe4466f1c39a3fbece21f4 | 60e6a759ac8caf8079af9818e8464c6eda22b0e8 | refs/heads/master | 2021-03-24T10:11:55.488542 | 2016-08-03T10:00:47 | 2016-08-03T10:00:47 | 18,877,919 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,932 | cpp | Box1iTool.cpp | #include <stdio.h>
#include "Uigp/igp.h"
#include "Uigp/GpMemoryLeak.h"
#include "Box1i.h"
box1iA_type *
box1iA_alloc( int n )
{
box1iA_type *avl;
avl = (box1iA_type *)malloc( sizeof( box1iA_type) );
avl->NA = n;
avl->a = ( box1i_type *)malloc( avl->NA*sizeof(box1i_type) );
avl->nA = 0;
GPMEMORY_LEAK_ALLOC( avl );
return( avl );
}
box1iA_type *
box1iA_realloc( box1iA_type *avl, int n )
{
if( avl == NULL ){
avl = box1iA_alloc(n );
return( avl );
}
if( avl->NA < n ){
avl->a = ( box1i_type *)realloc( avl->a, n*sizeof(box1i_type) );
avl->NA = n;
}
return( avl );
}
box1iA_type *
box1iA_copy( box1iA_type *bavl, box1iA_type *avl )
{
avl = box1iA_realloc( avl, bavl->nA );
int i;
for( i = 0 ; i < bavl->nA ; i++ )
avl->a[i] = bavl->a[i];
avl->nA = bavl->nA;
return( avl );
}
void
box1iA_destroy( box1iA_type *avl )
{
GPMEMORY_LEAK_DESTROY( avl );
free( avl->a );
free( avl );
}
box1fA_type *
box1fA_alloc( int n )
{
box1fA_type *avl;
avl = (box1fA_type *)malloc( sizeof( box1fA_type) );
avl->NA = n;
avl->a = ( box1f_type *)malloc( avl->NA*sizeof(box1f_type) );
avl->nA = 0;
GPMEMORY_LEAK_ALLOC( avl );
return( avl );
}
box1fA_type *
box1fA_realloc( box1fA_type *avl, int n )
{
if( avl == NULL ){
avl = box1fA_alloc(n );
return( avl );
}
if( avl->NA < n ){
avl->a = ( box1f_type *)realloc( avl->a, n*sizeof(box1f_type) );
avl->NA = n;
}
return( avl );
}
box1fA_type *
box1iA_copy( box1fA_type *bavl, box1fA_type *avl )
{
avl = box1fA_realloc( avl, bavl->nA );
int i;
for( i = 0 ; i < bavl->nA ; i++ )
avl->a[i] = bavl->a[i];
avl->nA = bavl->nA;
return( avl );
}
void
box1fA_destroy( box1fA_type *avl )
{
GPMEMORY_LEAK_DESTROY( avl );
free( avl->a );
free( avl );
}
void
box1i_print( char *title, box1i_type ab[], int nP, FILE *fp )
{
int i;
fprintf( fp, "%s %d\n", title, nP );
for( i = 0 ; i < nP ; i++ ){
fprintf( fp, "%d %d %d\n", i, ab[i].i0, ab[i].i1 );
}
}
void
box1iA_write( char *title, box1iA_type *ab, FILE *fp )
{
int i;
fprintf( fp, "%s %d\n", title, ab->nA );
for( i = 0 ; i < ab->nA ; i++ ){
fprintf( fp, "%d %d %d\n", i, ab->a[i].i0, ab->a[i].i1 );
}
}
int
box1i_overlap( box1i_type *b, box1i_type *b1, box1i_type *b2 )
{
if( b->i0 < b1->i0 ){
if( b->i1 < b1->i0 )
return( b->i1 - b1->i0 );
if( b->i1 > b1->i1 ){
b2->i0 = b1->i0;
b2->i1 = b1->i1;
return( b2->i1 - b2->i0 );
}
b2->i0 = b1->i0;
b2->i1 = b->i1;
return( b2->i1 - b2->i0 );
}
if( b1->i1 < b->i0 )
return( b1->i1 - b->i0 );
if( b1->i1 > b->i1 ){
b2->i0 = b->i0;
b2->i1 = b->i1;
return( b2->i1 - b2->i0 );
}
b2->i0 = b->i0;
b2->i1 = b1->i1;
return( b2->i1 - b2->i0 );
} |
7b9d3f30f7a256d89fa88bd064b4a4cda018693d | a6445017ba43f4ee5fc3e9535d01d4cda8ed6c25 | /Esercizi/Ricorsione/CercaA/main.cpp | 0b287e22149e0e4a596d4d5c553c52fe126b4e7d | [
"MIT"
] | permissive | gabrielegenovese/Esercizi-Programmazione-2020 | 361c5514b536083aaef5df92607a2c92a5a5fc68 | bb16aec872ece3f7d88fcbfc88b3778efcb4f16b | refs/heads/main | 2023-02-18T00:16:04.483500 | 2021-01-18T10:14:40 | 2021-01-18T10:14:40 | 307,976,771 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 324 | cpp | main.cpp | #include <iostream>
using namespace std;
int serch_a(char s[], int start = 0)
{
if(s[0] == '\0') return start;
if(s[0] == 'a')
return serch_a(++s, ++start);
return serch_a(++s, start);
}
int main()
{
char s[] = { 'a', 'b', 'a', 'C', 'o', 'a'};
cout << serch_a(s) << endl;
return 0;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.