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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8bca3d20d8c884932ac321a6db71cda1e865d88c
|
2d586903bdd0f183d804779455729ab4bf982631
|
/src/DP/DPTestClient.Cpp/NStackBooks.h
|
b6bfe68d376986ed44ae7eb8564840d3d1e7f776
|
[] |
no_license
|
srivelicheti/gfg
|
e0ed91fe265badf98b257bf49ddd8deed3641f3e
|
37b63a765b5e505569b7913338a15ed257036090
|
refs/heads/master
| 2021-01-13T12:56:10.319945
| 2018-01-15T18:04:29
| 2018-01-15T18:04:29
| 72,796,262
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 119
|
h
|
NStackBooks.h
|
#pragma once
class NStackBooks
{
public:
NStackBooks();
~NStackBooks();
int GetMaxBooks(int a[], int n, int k);
};
|
65db516dd3f292257fadaa0acae61e3cc2573cf4
|
0e17d3f47b50b6995093b71cd039acb8368d97e8
|
/main.cpp
|
38ebbc65e61bfcd6340193e78c5636a87d01f254
|
[] |
no_license
|
Krupnikas/christmasDefence
|
e22441471bd6bf1ef5596e65485558d0af2c8d70
|
04fd4e4401d92b37248de96a700d61239a1b620a
|
refs/heads/master
| 2021-01-19T00:19:57.196304
| 2019-12-11T21:33:36
| 2019-12-11T21:33:36
| 72,995,889
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 484
|
cpp
|
main.cpp
|
#include <mainview.h>
#include <QApplication>
#include <QSplashScreen>
#include <QTimer>
#include <Resource.h>
#include <Metrics/MetricsDef.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPixmap pixmap("://res/christmas/splash.png");
QSplashScreen splash(pixmap);
//splash.show();
MainView w(&a);
w.show();
//QTimer::singleShot(1000, &splash, SLOT(close()));
//QTimer::singleShot(1000, &w, SLOT(show()));
return a.exec();
}
|
482bbf256ec59231f2514490194963411b93f360
|
93e41c4f2892a7c8381ac9f13e88e403591e6065
|
/Source/FPSGame/Private/FPSObjective.cpp
|
89a9b78d9ed03d9fed5e3dfdfcd6dcffde1150f9
|
[] |
no_license
|
ShantanuJamble/AWS_Multiplayer
|
6445e099825a3a921bb9b993315fc1381d4c7ce1
|
a807f0389cd2aeacaf673e2f4651e74539519a70
|
refs/heads/master
| 2020-07-26T00:51:06.269687
| 2020-04-16T17:07:31
| 2020-04-16T17:07:31
| 208,476,663
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,554
|
cpp
|
FPSObjective.cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "FPSObjective.h"
#include "Components/StaticMeshComponent.h"
#include "Components/SphereComponent.h"
#include "Kismet/GameplayStatics.h"
#include "FPSCharacter.h"
// Sets default values
AFPSObjective::AFPSObjective()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
MeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
SetRootComponent(MeshComp);
CollisionSphere = CreateDefaultSubobject<USphereComponent>(TEXT("CollisionSpehere"));
CollisionSphere->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
CollisionSphere->SetCollisionResponseToAllChannels(ECR_Ignore);
CollisionSphere->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
CollisionSphere->SetupAttachment(MeshComp);
//Networking
SetReplicates(true);
}
// Called when the game starts or when spawned
void AFPSObjective::BeginPlay()
{
Super::BeginPlay();
}
void AFPSObjective::PlayEffects()
{
UGameplayStatics::SpawnEmitterAtLocation(this, PickupFX, GetActorLocation());
}
void AFPSObjective::NotifyActorBeginOverlap(AActor* OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
PlayEffects();
if (Role == ROLE_Authority)
{
AFPSCharacter* actor = Cast<AFPSCharacter>(OtherActor);
if (actor)
{
actor->bIsCarryingObjective = true;
Destroy();
}
}
}
|
c9d7133ecdb116abd5b4e075f7dc18f8e88e0c3d
|
c395c382f29aa0c2ddc667f3a101f4b6a6791138
|
/src/device_buffer.h
|
d18169636871c3297b02284d068fc414debdb9bf
|
[
"Apache-2.0"
] |
permissive
|
ogsdave/cuda-bundle-adjustment
|
640a766f70204a4b97163193b87e48b61389b8e8
|
92ebd17f421677f228c5cb11cb5e5a88b9a34805
|
refs/heads/master
| 2023-08-02T18:11:28.234209
| 2021-09-17T18:26:24
| 2021-09-17T18:26:24
| 340,121,053
| 0
| 0
|
Apache-2.0
| 2021-09-17T18:26:25
| 2021-02-18T17:09:20
| null |
UTF-8
|
C++
| false
| false
| 2,349
|
h
|
device_buffer.h
|
/*
Copyright 2020 Fixstars Corporation
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 __DEVICE_BUFFER_H__
#define __DEVICE_BUFFER_H__
#include <cuda_runtime.h>
#include "macro.h"
namespace cuba
{
template <typename T>
class DeviceBuffer
{
public:
DeviceBuffer() : data_(nullptr), size_(0), capacity_(0), allocated_(false) {}
DeviceBuffer(size_t size) : data_(nullptr), size_(0), capacity_(0), allocated_(false) { resize(size); }
~DeviceBuffer() { destroy(); }
void allocate(size_t count)
{
if (data_ && capacity_ >= count)
return;
destroy();
CUDA_CHECK(cudaMalloc(&data_, sizeof(T) * count));
capacity_ = count;
allocated_ = true;
}
void destroy()
{
if (allocated_ && data_)
CUDA_CHECK(cudaFree(data_));
data_ = nullptr;
size_ = 0;
allocated_ = false;
}
void resize(size_t size)
{
allocate(size);
size_ = size;
}
void map(size_t size, void* data)
{
data_ = (T*)data;
size_ = size;
allocated_ = false;
}
void assign(size_t size, const void* h_data)
{
resize(size);
upload((T*)h_data);
}
void upload(const T* h_data)
{
CUDA_CHECK(cudaMemcpy(data_, h_data, sizeof(T) * size_, cudaMemcpyHostToDevice));
}
void download(T* h_data) const
{
CUDA_CHECK(cudaMemcpy(h_data, data_, sizeof(T) * size_, cudaMemcpyDeviceToHost));
}
void copyTo(T* rhs) const
{
CUDA_CHECK(cudaMemcpy(rhs, data_, sizeof(T) * size_, cudaMemcpyDeviceToDevice));
}
void fillZero()
{
CUDA_CHECK(cudaMemset(data_, 0, sizeof(T) * size_));
}
T* data() { return data_; }
const T* data() const { return data_; }
size_t size() const { return size_; }
int ssize() const { return static_cast<int>(size_); }
operator T* () { return data_; }
operator const T* () const { return data_; }
private:
T* data_;
size_t size_, capacity_;
bool allocated_;
};
} // namespace cuba
#endif // !__DEVICE_BUFFER_H__
|
a60b45e9183fbdd9b0c74601577499d932710fe3
|
f92f7508a3314ffe4b23db5ada78c77c339b2942
|
/Day03/ex04/FragTrap.hpp
|
1b30ddb3398bdad0148c38624a0dc7b97553b89a
|
[] |
no_license
|
ssnow95/CPP
|
b472f1592c2f599e8b3c51b3316c49a288494de1
|
1a7021a933544511785f31e01a0bcc1bae498c8c
|
refs/heads/master
| 2023-03-01T21:37:59.536418
| 2021-02-09T12:32:58
| 2021-02-09T12:32:58
| 329,837,943
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,422
|
hpp
|
FragTrap.hpp
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* FragTrap.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ssnowbir <ssnowbir@student.21.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/20 14:47:40 by ssnowbir #+# #+# */
/* Updated: 2021/01/22 19:53:42 by ssnowbir ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FRAGTRAP_HPP
#define FRAGTRAP_HPP
#include <iostream>
#include <string>
#include <iomanip>
#include "ClapTrap.hpp"
class FragTrap: virtual public ClapTrap
{
private:
public:
FragTrap(void);
FragTrap(std::string name);
FragTrap(FragTrap const & src);
~FragTrap(void);
FragTrap & operator=(FragTrap const &src);
void rangedAttack(std::string const & target);
void meleeAttack(std::string const & target);
void vaulthunter_dot_exe(std::string const & target);
};
#endif
|
164ede8c35c32e07bcdf3273f3e06205345db07d
|
3e7e144c870150e0af466eaf0abd46d6ebb03f81
|
/SpaceImpact/game_object.h
|
dbb7da2c2a03e79de039eeac75abd8e14ac69554
|
[] |
no_license
|
beczipetra89/space-impact
|
948183eedbd39cebee09e353315f1dad709b37d3
|
2c2c5360cd0f43de1fb2038e9fe06c9aed47deb7
|
refs/heads/master
| 2021-03-15T03:43:15.180309
| 2020-03-12T11:47:45
| 2020-03-12T11:47:45
| 246,821,395
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,104
|
h
|
game_object.h
|
#pragma once
// GameObject represents objects which moves are drawn
#include <vector>
enum Message {
HIT,
ALIEN_HIT,
ALIEN2_HIT,
ALIEN_G_HIT, ALIEN_V_HIT,
ALIEN_CHANGE_DIRECTION_AND_MOVE_DOWN, ALIEN_HIT_WALL,
ALIEN_G_LEVEL_CLEAR,
ALL_ALIENS_V_CLEAR,
ALIENS_ALL_CLEAR,
PLAYER_HIT,
BOSS_HIT, BOSS_KILLED, LIFE_PICKED, BULLET_BULLET_HIT, GAME_OVER, LEVEL_WIN, NO_MSG, QUIT };
class Component;
class GameObject
{
protected:
std::vector<GameObject*> receivers;
std::vector<Component*> components;
public:
double horizontalPosition;
double verticalPosition;
int width, height;
bool enabled;
virtual ~GameObject();
virtual void Create(int w, int h);
virtual void AddComponent(Component * component);
template<typename T>
T GetComponent() {
for (Component* c : components) {
T t = dynamic_cast<T>(c); //ugly but it works...
if (t != nullptr) {
return t;
}
}
return nullptr;
}
virtual void Init();
virtual void Update(float dt);
virtual void Destroy();
virtual void AddReceiver(GameObject *go);
virtual void Receive(Message m) {}
void Send(Message m);
};
|
df345058eb7600b20bff80889450d929f5adc62e
|
0e33092ba601191b160be0dad296b18f63e574a4
|
/src/block.cpp
|
d324fc37fe54c2f705fdba563dba741e4b63c921
|
[] |
no_license
|
taliesinb/floatworld
|
d08cc4667ed2f580dffeab1384d9877291bd4c93
|
5bd22ad14d1d01ff4f14bbce8b5754d48a96980d
|
refs/heads/master
| 2021-06-04T04:01:09.492670
| 2019-07-15T13:48:02
| 2019-07-15T13:48:02
| 1,101,407
| 24
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,940
|
cpp
|
block.cpp
|
#include "block.hpp"
#include "shape.hpp"
using namespace std;
RegisterClass(Block, Occupant);
RegisterClass(PushableBlock, Block);
RegisterClass(RewardBlock, PushableBlock);
RegisterVar(RewardBlock, reward);
RegisterBinding(RewardBlock, reward, "reward", -100, 100);
RegisterClass(StaticTrap, Block);
RegisterClass(ActiveTrap, PushableBlock);
RegisterClass(SkinnerBlock, Block);
RegisterVar(SkinnerBlock, touch_count);
RegisterVar(SkinnerBlock, threshold);
RegisterVar(SkinnerBlock, radius);
RegisterVar(SkinnerBlock, reward);
RegisterBinding(SkinnerBlock, touch_count, "count", 0, 100);
RegisterBinding(SkinnerBlock, threshold, "threshold", 0, 20);
RegisterBinding(SkinnerBlock, radius, "radius", 1, 20);
RegisterBinding(SkinnerBlock, reward, "reward", 1, 20);
RegisterClass(PhasedSkinnerBlock, SkinnerBlock);
RegisterVar(PhasedSkinnerBlock, period);
RegisterVar(PhasedSkinnerBlock, phase);
RegisterBinding(PhasedSkinnerBlock, period, "period", 1, 20);
RegisterBinding(PhasedSkinnerBlock, phase, "phase");
RegisterClass(ExplodingBlock, Block);
RegisterVar(ExplodingBlock, radius);
RegisterVar(ExplodingBlock, suicide);
RegisterBinding(ExplodingBlock, radius, "radius", 1, 20);
RegisterBinding(ExplodingBlock, suicide, "suicide");
Block::Block()
{
draw_filled = false;
draw_hue = 0.5;
signature = -2;
}
void Block::Update()
{
world->energy(pos) = 0;
}
void PushableBlock::Interact(Creat& c)
{
Pos p = world->Wrap(pos + Pos(c.orient));
Occupant* occ = world->OccupantAt(p);
if (dynamic_cast<PushableBlock*>(occ)) occ->Interact(c);
if (world->OccupantAt(p) == NULL)
{
Move(p);
WasPushed(c);
}
}
void PushableBlock::WasPushed(Creat &c)
{
}
RewardBlock::RewardBlock()
{
reward = 10;
}
void RewardBlock::WasPushed(Creat &c)
{
c.energy += reward;
}
StaticTrap::StaticTrap()
{
signature = -2.0;
draw_hue = 0.0;
}
void StaticTrap::Interact(Creat &c)
{
c.alive = false;
}
ActiveTrap::ActiveTrap()
{
signature = -2.0;
draw_hue = 0.9;
}
void ActiveTrap::Update()
{
Pos new_pos;
if (world->timestep % 3 != 0) return;
for (int dir = 0; dir < 4; dir++)
{
new_pos = world->Wrap(pos + Pos(dir));
if (Creat* creat = world->CreatAt(new_pos))
{
creat->alive = false;
Move(new_pos);
draw_filled = true;
return;
}
}
draw_filled = false;
new_pos = world->Wrap(pos + Pos(rng.Integer(4)));
if (!world->OccupantAt(new_pos)) Move(new_pos);
}
SkinnerBlock::SkinnerBlock()
{
touch_count = _touch_count = 0;
threshold = 8;
reward = 20;
radius = 5;
draw_hue = 0.1;
}
void SkinnerBlock::Interact(Creat&)
{
if (touch_count++ >= threshold)
{
touch_count = 0;
EnergyDisk spot;
spot.pos = pos;
spot.radius = radius;
spot.energy = reward;
spot.Draw(world->energy);
}
}
void SkinnerBlock::Update()
{
draw_filled = (touch_count < _touch_count);
_touch_count = touch_count;
world->energy(pos) = 0;
}
PhasedSkinnerBlock::PhasedSkinnerBlock()
{
period = 8;
phase = false;
}
void PhasedSkinnerBlock::Update()
{
SkinnerBlock::Update();
phase = ((world->timestep + pos.row + pos.col) / period) % 2;
signature = phase ? -1.0 : -2.0;
draw_hue = phase ? 0.1 : 0.4;
}
void PhasedSkinnerBlock::Interact(Creat& c)
{
if (phase)
SkinnerBlock::Interact(c);
else
c.energy -= 50;
}
ExplodingBlock::ExplodingBlock()
{
radius = 5;
suicide = false;
}
void ExplodingBlock::Interact(Creat &c)
{
int r = radius * radius;
for (int dr = -radius; dr <= radius; dr++)
for (int dc = -radius; dc <= radius; dc++)
if (dr * dr + dc * dc < r)
if (Creat* victim = world->CreatAt(world->Wrap(pos + Pos(dr, dc))))
if (suicide || victim != &c) victim->alive = false;
}
|
fb1eaeff7a99ce77f5a04e2fd9192d8682ed7cc6
|
2934bb306e560e69b742ea726e69eaf07270c0a4
|
/Source/MyProject/MyPlayerController.cpp
|
8f6f5577b4f7a44086f0f925b078be44c98704d7
|
[
"MIT"
] |
permissive
|
dezGusty/SpaceMission2018
|
6b6c81f5cb058c623c6518f894546f7bd853b7df
|
8a422f5ba46f825efdae7c283804f7c7b06b379f
|
refs/heads/master
| 2020-03-26T21:57:09.581812
| 2018-09-24T22:20:43
| 2018-09-24T22:20:43
| 145,420,849
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 521
|
cpp
|
MyPlayerController.cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyPlayerController.h"
#include "Blueprint/UserWidget.h"
AMyPlayerController::AMyPlayerController()
:
APlayerController()
{
}
void AMyPlayerController::BeginPlay()
{
UE_LOG(LogTemp, Warning, TEXT("MyPlayerController BeginPlay"));
Super::BeginPlay();
if (wTwinStickHUD)
{
myWidget = CreateWidget<UUserWidget>(this, wTwinStickHUD);
if (myWidget)
{
myWidget->AddToViewport();
}
bShowMouseCursor = true;
}
}
|
0bcd4d4d1f55af2b0e7c04add0d3374c907d622c
|
636180da3b93d48bab74a926db370913558c08da
|
/QT/nrf/main.cpp
|
0c1bee24fc786a6c14d7712653f49fc8dbcceb83
|
[] |
no_license
|
natashaiwscope/emulator_v0
|
640ab09e3ff77b8ce0150e019bc6f8547c0c0bba
|
4eec16b9264c5b339e14f59b0a8b706adef7d1c0
|
refs/heads/master
| 2021-09-15T08:12:02.057294
| 2018-05-29T02:36:16
| 2018-05-29T02:36:16
| 112,984,320
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,537
|
cpp
|
main.cpp
|
#include <QCoreApplication>
#include <iostream>
#include <stdio.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <QMutex>
#include <QThread>
#include <QStringList>
#include "ext_udp.h"
using namespace std;
int WaitForResult(int result)
{
unsigned short winMsg, wPar, lPar;
float fVal;
char strMsg[1023];
do
{
usPullStrWinQ(winMsg, wPar, lPar, fVal, strMsg);
millisleep(1);
}
while(winMsg!=result);
}
int main(int argc, char **argv)
{
enter_eth_lib();
WaitForResult(WM_CONNECTED);
// Now Ready for Data
// Empty every thing
while(usUDPAvailable());
fun_i2c_scan();
while(!usUDPAvailable());
qDebug() << "Number of Devices=" << i2c_devices_cnt();
printf("addr=0x%02x\r\n", i2c_devices_addr(0));
fflush(stdout);
unsigned char itx_mac[4]={0x12,0x34,0x56,0x78};
unsigned char irx_mac[4]={0x13,0x34,0x56,0x78};
nrf_set_address(itx_mac,irx_mac);
while(!usUDPAvailable());
printf("set adddress\r\n"); fflush(stdout);
nrf_set_chnl_datasize(2,4);
while(!usUDPAvailable());
printf("set chnl datasize\r\n"); fflush(stdout);
nrf_write(irx_mac,4);
while(!usUDPAvailable());
printf("do tx\r\n"); fflush(stdout);
while(1)
{
qDebug() << "Device is connected\r\n";
millisleep(1000);
}
exit_eth_lib();
return 0;
}
|
f4f2055b18a27c8b15c8784ec81875ce315c6212
|
12c82ceba45d5508cff2e4f152563435873f2b8b
|
/tallest_billboard.cpp
|
510c68b415c0e89a8720bd91d4067be706311da9
|
[] |
no_license
|
Web-Dev-Collaborative/leetcode-solutions
|
45d50ff92f4c96cf59d5407a8a2bed7405383430
|
b46d09c665d4a89322a32916ebc76c15565616bf
|
refs/heads/master
| 2023-04-03T17:22:53.180100
| 2021-03-29T21:15:55
| 2021-03-29T21:15:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 480
|
cpp
|
tallest_billboard.cpp
|
class Solution {
public:
int tallestBillboard(vector<int>& rods) {
int sum = accumulate(rods.begin(),rods.end(),0);
vector<int> dp(sum*2+1,-1);
dp[sum] = 0;
for(int& r:rods) {
vector<int> prev = dp;
for(int i=0;i<=2*sum;i++) {
if(prev[i]==-1)continue;
dp[i+r]=max(dp[i+r],prev[i]+r);
dp[i-r]=max(dp[i-r],prev[i]);
}
}
return dp[sum];
}
};
|
2d5873734a5f66b931e0c5c418886ab2c712a935
|
3af68b32aaa9b7522a1718b0fc50ef0cf4a704a9
|
/cpp/E/A/E/B/AEAEB.h
|
2c296a3b7b8bed04707005085833ca6a6dda1242
|
[] |
no_license
|
devsisters/2021-NDC-ICECREAM
|
7cd09fa2794cbab1ab4702362a37f6ab62638d9b
|
ac6548f443a75b86d9e9151ff9c1b17c792b2afd
|
refs/heads/master
| 2023-03-19T06:29:03.216461
| 2021-03-10T02:53:14
| 2021-03-10T02:53:14
| 341,872,233
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 65
|
h
|
AEAEB.h
|
#ifndef AEAEB_H
namespace AEAEB {
std::string run();
}
#endif
|
dab526933caefa22d48b39108a13c012a338a6db
|
9e5dcf4f7da501d0228b33ddb7c2661ca720eb45
|
/FinalProject/A_Star_Class.h
|
fd3ffdc6bbe2d34a4829744535e47260b1084e46
|
[] |
no_license
|
ozu95supein/CS380-AIFinalProject
|
a1faea161e01167618e1695c668e8fbd6469f7b7
|
d001955c4445988098e5341b45c56d4a2cb1dc01
|
refs/heads/master
| 2022-01-21T20:37:44.387721
| 2019-07-17T11:55:00
| 2019-07-17T11:55:00
| 192,378,383
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,869
|
h
|
A_Star_Class.h
|
#pragma once
#include "Cell.h"
#include <stack>
#include <list>
#include <queue>
#include <vector>
//typedef std::list<D3DXVECTOR3> WaypointList;
//custom compare of two cells that will pick the one with the lowest cost
enum heuristic
{
H_CHEBYSHEV = 1,
H_MANHATTAN = 2,
H_EUCLIDEAN = 3,
H_OCTILE = 4
};
class A_Star_Class
{
public:
//constructor
A_Star_Class();
A_Star_Class(Cell start, Cell goal);
//functions to set start and goal nodes
void SetStart(Cell start);
void SetGoal(Cell goal);
void SetStartAndGoal(Cell start, Cell goal);
bool RunAStar(bool single);
void SetHeuristicMethod(heuristic h);
float GetHeuristicWeight();
void SetHeuristicWeight(float h);
float CalculateHeuristic(Cell & currentNode);
Cell GetStart();
Cell GetGoal();
Cell & FinalNode;
Cell * ReturnFinalNode()
{
return & FinalNode;
}
std::list<Cell> get_neighbors(Cell & current);
std::list<Cell> get_full_path();
Cell & POP_cheapest_from_OPEN();
bool Check_If_Goal(Cell & c);
void Compute_And_Set_Costs(float & hcost, float & fcost, Cell & c);
bool FindInList(std::list<Cell> l, Cell CellToFind, Cell & CellToReturn);
void ConstructPath(Cell & goal);
void SetFinalNode(Cell c);
void SetMinMaxCell(int m, int x)
{
min = m;
max = x;
}
int min;
int max;
bool path_found;
bool ispathfound()
{
return path_found;
}
void BeginAstar();
bool Iteration();
Cell & GetCurrentAnalyzed()
{
return mCurrentCellBeingAnalyzed;
}
bool StraightlineCheck(Cell start, Cell goal, bool modify_var);
bool mStraightLineCheck;
int debugcount = 0;
bool StraightLineOptimization(std::list<Cell> list, Cell & return_cell);
void Rubberbanding();
private:
Cell mStartCell;
Cell mGoalCell;
Cell mCurrentCellBeingAnalyzed;
float H_weight;
std::list<Cell> OPEN_LIST;
std::list<Cell> CLOSED_LIST;
std::list<Cell> full_path;
heuristic mCurrent_H_Method;
};
|
8718363524b4966cd86d9f92d2161fbcc487661b
|
08444e3ba3a0960b59995f1b3c9969e936910834
|
/Toast-Module/include/toast/module/statics.hpp
|
23a5b81f4ad8184bb60d4f6649e62139518352ba
|
[
"MIT"
] |
permissive
|
JaciBrunning/ToastCPP
|
14530d1f99bc4399115cce31efef8de875e10f54
|
e4879902aacfcbadff87f1bdce021befee72882a
|
refs/heads/master
| 2021-06-09T01:52:23.195671
| 2016-12-20T15:20:00
| 2016-12-20T15:20:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 197
|
hpp
|
statics.hpp
|
#pragma once
#include "toast/library.hpp"
#include <string>
CAPI void toast_module_shutdown();
CAPI void init_toast_module(std::string module_name, std::string private_mempool_id, int module_id);
|
2466140870c43d87724c6153eb731ff4ee75418c
|
5068316a2591ec17269b0b0fa50700baf323e873
|
/polimorfism_niancu99.cpp
|
2225aa031d5fe59d702a81790c6ac6bb14cca748
|
[] |
no_license
|
niancu99/lab8-11_Gestionare_Calatorii_niancu99
|
e8dc3e8f484646bf3fd4c087e28db54c4f5b700f
|
026625bff7e2e10ceedd48841ddcbf5c655dfec5
|
refs/heads/master
| 2022-09-23T18:36:36.181070
| 2020-05-28T16:35:27
| 2020-05-28T16:35:27
| 267,640,550
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 681
|
cpp
|
polimorfism_niancu99.cpp
|
// polimorfism_niancu99.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include "TestRepoFile.h"
#include "Utilizator.h"
#include "TestCalatorie.h"
#include "TestValidatorCalatorie.h"
#include "TestService.h"
#include "UI.h"
int main()
{
TestValidatorCalatorie testval;
testval.testAll();
TestService testservice;
testservice.testAll();
RepoCustom<Utilizator> RepoUtilizator;
RepoUtilizator.setf_name("Useri.txt");
RepoFile* repofile = new RepoTXT("Calatorii.txt");
Service serv(RepoUtilizator, repofile);
UI ui(serv);
ui.run();
return 0;
}
|
218ef1426712a75d594356ffcf07db31b95e9d6f
|
03eb3f665c8c9830a6c06d359f3a7e998b781db9
|
/src/test/lib/storage/dictionary_segment_test.cpp
|
69dbaf953a65c8c3d1267881cfbafbb876a48295
|
[
"MIT"
] |
permissive
|
hyrise/hyrise
|
25f8f396fcf3be2e4a4f7c3b432e3999ee0d6c60
|
46f13fa510aa7e8b232b3081ee1a25b7f0958e55
|
refs/heads/master
| 2023-09-01T10:35:56.802881
| 2023-08-25T07:18:08
| 2023-08-25T07:18:08
| 87,414,843
| 687
| 156
|
MIT
| 2023-09-14T21:17:51
| 2017-04-06T10:03:31
|
C++
|
UTF-8
|
C++
| false
| false
| 7,624
|
cpp
|
dictionary_segment_test.cpp
|
#include <memory>
#include <string>
#include <utility>
#include "base_test.hpp"
#include "storage/chunk_encoder.hpp"
#include "storage/dictionary_segment.hpp"
#include "storage/segment_encoding_utils.hpp"
#include "storage/value_segment.hpp"
#include "storage/vector_compression/fixed_width_integer/fixed_width_integer_vector.hpp"
#include "storage/vector_compression/vector_compression.hpp"
namespace hyrise {
class StorageDictionarySegmentTest : public BaseTestWithParam<VectorCompressionType> {
protected:
std::shared_ptr<ValueSegment<int>> vs_int = std::make_shared<ValueSegment<int>>();
std::shared_ptr<ValueSegment<pmr_string>> vs_str = std::make_shared<ValueSegment<pmr_string>>();
std::shared_ptr<ValueSegment<double>> vs_double = std::make_shared<ValueSegment<double>>();
};
INSTANTIATE_TEST_SUITE_P(VectorCompressionTypes, StorageDictionarySegmentTest,
::testing::Values(VectorCompressionType::FixedWidthInteger, VectorCompressionType::BitPacking),
enum_formatter<VectorCompressionType>);
TEST_P(StorageDictionarySegmentTest, LowerUpperBound) {
for (auto value = int32_t{0}; value <= 10; value += 2) {
vs_int->append(value);
}
auto segment =
ChunkEncoder::encode_segment(vs_int, DataType::Int, SegmentEncodingSpec{EncodingType::Dictionary, GetParam()});
auto dict_segment = std::dynamic_pointer_cast<DictionarySegment<int>>(segment);
// Test for AllTypeVariant as parameter
EXPECT_EQ(dict_segment->lower_bound(AllTypeVariant(4)), ValueID{2});
EXPECT_EQ(dict_segment->upper_bound(AllTypeVariant(4)), ValueID{3});
EXPECT_EQ(dict_segment->lower_bound(AllTypeVariant(5)), ValueID{3});
EXPECT_EQ(dict_segment->upper_bound(AllTypeVariant(5)), ValueID{3});
EXPECT_EQ(dict_segment->lower_bound(AllTypeVariant(15)), INVALID_VALUE_ID);
EXPECT_EQ(dict_segment->upper_bound(AllTypeVariant(15)), INVALID_VALUE_ID);
}
TEST_P(StorageDictionarySegmentTest, CompressSegmentInt) {
vs_int->append(4);
vs_int->append(4);
vs_int->append(3);
vs_int->append(4);
vs_int->append(5);
vs_int->append(3);
auto segment =
ChunkEncoder::encode_segment(vs_int, DataType::Int, SegmentEncodingSpec{EncodingType::Dictionary, GetParam()});
auto dict_segment = std::dynamic_pointer_cast<DictionarySegment<int>>(segment);
// Test attribute_vector size
EXPECT_EQ(dict_segment->size(), 6u);
// Test dictionary size (uniqueness)
EXPECT_EQ(dict_segment->unique_values_count(), 3u);
// Test sorting
auto dict = dict_segment->dictionary();
EXPECT_EQ((*dict)[0], 3);
EXPECT_EQ((*dict)[1], 4);
EXPECT_EQ((*dict)[2], 5);
}
TEST_P(StorageDictionarySegmentTest, CompressSegmentString) {
vs_str->append("Bill");
vs_str->append("Steve");
vs_str->append("Alexander");
vs_str->append("Steve");
vs_str->append("Hasso");
vs_str->append("Bill");
auto segment =
ChunkEncoder::encode_segment(vs_str, DataType::String, SegmentEncodingSpec{EncodingType::Dictionary, GetParam()});
auto dict_segment = std::dynamic_pointer_cast<DictionarySegment<pmr_string>>(segment);
// Test attribute_vector size
EXPECT_EQ(dict_segment->size(), 6u);
// Test dictionary size (uniqueness)
EXPECT_EQ(dict_segment->unique_values_count(), 4u);
// Test sorting
auto dict = dict_segment->dictionary();
EXPECT_EQ((*dict)[0], "Alexander");
EXPECT_EQ((*dict)[1], "Bill");
EXPECT_EQ((*dict)[2], "Hasso");
EXPECT_EQ((*dict)[3], "Steve");
}
TEST_P(StorageDictionarySegmentTest, CompressSegmentDouble) {
vs_double->append(0.9);
vs_double->append(1.0);
vs_double->append(1.0);
vs_double->append(1.1);
vs_double->append(0.9);
vs_double->append(1.1);
auto segment = ChunkEncoder::encode_segment(vs_double, DataType::Double,
SegmentEncodingSpec{EncodingType::Dictionary, GetParam()});
auto dict_segment = std::dynamic_pointer_cast<DictionarySegment<double>>(segment);
// Test attribute_vector size
EXPECT_EQ(dict_segment->size(), 6u);
// Test dictionary size (uniqueness)
EXPECT_EQ(dict_segment->unique_values_count(), 3u);
// Test sorting
auto dict = dict_segment->dictionary();
EXPECT_EQ((*dict)[0], 0.9);
EXPECT_EQ((*dict)[1], 1.0);
EXPECT_EQ((*dict)[2], 1.1);
}
TEST_P(StorageDictionarySegmentTest, CompressNullableSegmentInt) {
vs_int = std::make_shared<ValueSegment<int>>(true);
vs_int->append(4);
vs_int->append(4);
vs_int->append(3);
vs_int->append(4);
vs_int->append(NULL_VALUE);
vs_int->append(3);
auto segment =
ChunkEncoder::encode_segment(vs_int, DataType::Int, SegmentEncodingSpec{EncodingType::Dictionary, GetParam()});
auto dict_segment = std::dynamic_pointer_cast<DictionarySegment<int>>(segment);
// Test attribute_vector size
EXPECT_EQ(dict_segment->size(), 6u);
// Test dictionary size (uniqueness)
EXPECT_EQ(dict_segment->unique_values_count(), 2u);
// Test sorting
auto dict = dict_segment->dictionary();
EXPECT_EQ((*dict)[0], 3);
EXPECT_EQ((*dict)[1], 4);
// Test retrieval of null value
EXPECT_TRUE(variant_is_null((*dict_segment)[ChunkOffset{4}]));
}
TEST_F(StorageDictionarySegmentTest, FixedWidthIntegerVectorSize) {
vs_int->append(0);
vs_int->append(1);
vs_int->append(2);
auto segment = ChunkEncoder::encode_segment(
vs_int, DataType::Int, SegmentEncodingSpec{EncodingType::Dictionary, VectorCompressionType::FixedWidthInteger});
auto dict_segment = std::dynamic_pointer_cast<DictionarySegment<int>>(segment);
auto attribute_vector_uint8_t =
std::dynamic_pointer_cast<const FixedWidthIntegerVector<uint8_t>>(dict_segment->attribute_vector());
auto attribute_vector_uint16_t =
std::dynamic_pointer_cast<const FixedWidthIntegerVector<uint16_t>>(dict_segment->attribute_vector());
EXPECT_NE(attribute_vector_uint8_t, nullptr);
EXPECT_EQ(attribute_vector_uint16_t, nullptr);
for (int i = 3; i < 257; ++i) {
vs_int->append(i);
}
segment = ChunkEncoder::encode_segment(
vs_int, DataType::Int, SegmentEncodingSpec{EncodingType::Dictionary, VectorCompressionType::FixedWidthInteger});
dict_segment = std::dynamic_pointer_cast<DictionarySegment<int>>(segment);
attribute_vector_uint8_t =
std::dynamic_pointer_cast<const FixedWidthIntegerVector<uint8_t>>(dict_segment->attribute_vector());
attribute_vector_uint16_t =
std::dynamic_pointer_cast<const FixedWidthIntegerVector<uint16_t>>(dict_segment->attribute_vector());
EXPECT_EQ(attribute_vector_uint8_t, nullptr);
EXPECT_NE(attribute_vector_uint16_t, nullptr);
}
TEST_F(StorageDictionarySegmentTest, FixedWidthIntegerMemoryUsageEstimation) {
/**
* WARNING: Since it's hard to assert what constitutes a correct "estimation", this just tests basic sanity of the
* memory usage estimations
*/
const auto empty_memory_usage =
ChunkEncoder::encode_segment(
vs_int, DataType::Int,
SegmentEncodingSpec{EncodingType::Dictionary, VectorCompressionType::FixedWidthInteger})
->memory_usage(MemoryUsageCalculationMode::Sampled);
vs_int->append(0);
vs_int->append(1);
vs_int->append(2);
auto compressed_segment = ChunkEncoder::encode_segment(
vs_int, DataType::Int, SegmentEncodingSpec{EncodingType::Dictionary, VectorCompressionType::FixedWidthInteger});
const auto dictionary_segment = std::dynamic_pointer_cast<DictionarySegment<int>>(compressed_segment);
static constexpr auto size_of_attribute = 1u;
EXPECT_GE(dictionary_segment->memory_usage(MemoryUsageCalculationMode::Sampled),
empty_memory_usage + 3 * size_of_attribute);
}
} // namespace hyrise
|
f54824f69ebcbdbbc8449d9f356b984eeee6ad44
|
0a1ebfe6224a5ea2eb4da77077fd7f47b4a34d73
|
/Classes/XGGameScene.cpp
|
fd916dc3d5cacf4a36e088d5ee66aca7018c9065
|
[] |
no_license
|
ppl3232/XGame
|
4921fa7e1f7e020a1d69c257c1f2f4413bdfbebf
|
5458f78d724110bc2f92575f16b93dbfbfe68af0
|
refs/heads/master
| 2020-05-14T16:10:51.153060
| 2013-09-05T17:46:36
| 2013-09-05T17:46:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 349
|
cpp
|
XGGameScene.cpp
|
#include "XGGameScene.h"
#include "XGGameInfo.h"
USING_NS_CC;
XGGameScene::XGGameScene()
{
}
XGGameScene::~XGGameScene()
{
}
bool XGGameScene::init()
{
do
{
CC_BREAK_IF(!CCScene::init());
CCLayer* pGameLayer = XGGameInfo::create();
CC_BREAK_IF(!pGameLayer);
addChild(pGameLayer);
return true;
}
while (false);
return false;
}
|
2e668dde2e01b89372c87564bf73e0c2cd82246f
|
21c2ac906a6aeac0e854a29c8882feda6744685c
|
/SettingsPanel.cpp
|
6cf24b97da932747c3d0fbe044a31c95fe0ff5f9
|
[] |
no_license
|
Veilkrand/Arduino-Sous-Vide
|
8c1eec44fdcef91d9cab0138afe5073ccfc6a034
|
de0c9666681f5929d3f7a392b18ff262428b241f
|
refs/heads/master
| 2021-01-10T18:49:51.956574
| 2013-08-04T02:16:47
| 2013-08-04T02:16:47
| 11,450,737
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,903
|
cpp
|
SettingsPanel.cpp
|
#include "Arduino.h"
#include "SettingsPanel.h"
SettingsPanel::SettingsPanel(String headText,String subheadText,UTFT *myGLCD,UTouch *myTouch,UTFT_Buttons *myButtons,SettingsType *settings,CallbackFunction eventCallbackFunction):PanelGUI(headText,subheadText,myGLCD,myTouch,myButtons,eventCallbackFunction)
{
_settings=settings;
//float temperature=_settings->temperature;
//Serial.print(temperature);
}
void SettingsPanel::show(){
/*
_myGLCD->clrScr();
_myButtons->deleteAllButtons();
setHeadText(_headText);
setSubheadText(_subheadText);
*/
_sizeX=_myGLCD->getDisplayXSize();
_sizeY=_myGLCD->getDisplayYSize();
clearScreen();
isActive=true;
_myGLCD->setFont(SmallFont);
_myGLCD->print("Sous-Vide Cooker V0.5",5,_sizeY-27);
_myGLCD->print("Alberto Naranjo - July 2013",5, _sizeY-15);
butTop0 = _myButtons->addButton(_sizeX-_buttonHeight-2, 2, _buttonHeight, _buttonHeight, "<");
int startX=40;
//myButtons.setTextFont(SmallFont);
buttonsLine[0]=_myButtons->addButton( 10, startX+0*_buttonHeight+5, _sizeX-10*2, _buttonHeight,"");
if (_settings->fahrenheit){
_myButtons->relabelButton(buttonsLine[0],"Temp. Fahrenheit",true);
}else{
_myButtons->relabelButton(buttonsLine[0],"Temp. Celsious",true);
}
buttonsLine[1]=_myButtons->addButton( 10, startX+1*_buttonHeight+5, _sizeX-10*2, _buttonHeight, "");
if (_settings->preheating){
// str_tmp="Preheating is ON";
_myButtons->relabelButton(buttonsLine[1],"Preheating is ON",true);
}else{
// str_tmp="Preheating is OFF";
_myButtons->relabelButton(buttonsLine[1],"Preheating is OFF",true);
}
_myButtons->drawButtons();
while(isActive){
if (_myTouch->dataAvailable() == true){
int pressed_button = _myButtons->checkButtons();
if (pressed_button==buttonsLine[0]){
if (_settings->fahrenheit){
_settings->fahrenheit=false;
_myButtons->relabelButton(buttonsLine[0], "Temp. Celsious",true);
}else{
_settings->fahrenheit=true;
_myButtons->relabelButton(buttonsLine[0], "Temp. Fahrenheit",true);
}
}
if (pressed_button==buttonsLine[1]){
if (_settings->preheating){
_settings->preheating=false;
_myButtons->relabelButton(buttonsLine[1], "Preheating is OFF",true);
}else{
_settings->preheating=true;
_myButtons->relabelButton(buttonsLine[1], "Preheating is ON",true);
}
}
if(pressed_button==butTop0){
isActive=false;
_eventCallbackFunction(0);
}
if(pressed_button==butTop1){
//drawPresetPanel();
}
}
}
//_eventCallbackFunction(0);
}
|
8d32d05e05d4114f9e62f78e7b899d0898d749d9
|
341dde2b3e8f4853292b9b9c74f64ad21c8e8d68
|
/SessionServer/ClientDemo_Patient/PatientApp.h
|
e363c4931b2127c418451a3363750c0622d95340
|
[] |
no_license
|
crawler99/RemotePharmacist
|
d4758d7cb1c6297c7243c9368e48e8c2b81f0228
|
84335bf2485e7e2f0e0f3ca7cf395af47757992a
|
refs/heads/master
| 2021-09-01T23:47:55.427311
| 2017-12-29T07:25:46
| 2017-12-29T07:25:46
| 115,693,789
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 17,989
|
h
|
PatientApp.h
|
#pragma once
#include "Patient.h"
#include "../ClientAPI/UserCallback.h"
#include "../SessionServer/util/Utils.h"
#include <sstream>
#include <iostream>
#include <fstream>
class PatientApp : public Poco::Runnable, public client::UserCallback
{
public:
// ============================================================================
// Callback function
// ============================================================================
void onLoginAccpted(const UserInfo &info)
{
std::cout << "Login accepted: username=" << info._username
<< ", userId=" << info._userId
<< ", userRole=" << info._userRole
<< ", regTime=" << info._regTime << std::endl;
}
void onLoginRejected(const std::string &username)
{
std::cout << "Login rejected: username=" << username << std::endl;
}
void onPharmacistsDetailOfCurStore(const std::vector<client::UserCallback::PharmacistOfCurrentStore> &detail)
{
std::vector<client::UserCallback::PharmacistOfCurrentStore>::const_iterator it = detail.begin();
while (it != detail.end())
{
std::cout << "RealName=" << it->_realName << std::endl;
std::cout << "CertTypeId=" << it->_certTypeId << std::endl;
if (it->_introductionLen != 0)
{
std::cout << "Has intro: " << std::string(it->_pIntroduction, it->_introductionLen) << std::endl;
}
if (it->_photoLen != 0)
{
std::stringstream ss;
ss << it->_realName << ".jpg";
std::string outFile = ss.str();
std::ofstream ofs(outFile.c_str(), std::ios::out | std::ios::binary);
ofs.write(it->_pPhoto, it->_photoLen);
ofs.close();
}
++it;
}
}
void onPharmacistRequestSucc(unsigned int pharmacistSessionId)
{
std::cout << "Get into conversation: pharmacistSessionId=" << pharmacistSessionId << std::endl;
_patient->startVideoReceiver();
_patient->startAudioReceiver();
// send out the handshake video pac to establish video conversation
client::User::Video v;
v._dataLen = 0;
v._pData = NULL;
_patient->send_Video(v);
// send out the handshake audio pac to establish audio conversation
client::User::Audio a;
a._dataLen = 0;
a._pData = NULL;
_patient->send_Audio(a);
}
void onPharmacistRequestFail()
{
std::cout << "Failed to find a pharmacist for service" << std::endl;
}
void onPrescription(const client::User::Prescription &prescription)
{
std::cout << std::endl;
std::cout << "Prescription from pharmacist received: len=" << prescription._dataLen << std::endl;
std::cout << "Enter command: ";
}
void onVideo(const client::User::Video &video)
{
std::cout << "Receive video from pharmacist: len=" << video._dataLen << std::endl;
}
void onAudio(const client::User::Audio &audio)
{
std::cout << "Receive audio from pharmacist: len=" << audio._dataLen << std::endl;
}
void onDealOfPrescriptionDrugAdded()
{
std::cout << "Successfully add or update a deal of prescription drug" << std::endl;
}
void onDealOfPrescriptionDrugAddFail()
{
std::cout << "Failed to add or update a deal of prescription drug" << std::endl;
}
void onDealsOfPrescriptionDrugDetail(const std::vector<client::UserCallback::DealsOfPrescriptionDrugDetailItem> &info)
{
std::vector<client::UserCallback::DealsOfPrescriptionDrugDetailItem>::const_iterator cit = info.begin();
while (cit != info.end())
{
std::cout << "Deal id: " << (*cit)._dealId << "\n"
<< "Buyer name: " << (*cit)._buyerName << "\n"
<< "Buyer age: " << (*cit)._buyerAge << "\n"
<< "Buyer is male: " << (*cit)._buyerIsMale << "\n"
<< "Time: " << (*cit)._time << "\n"
<< "Drug HuoHao: " << (*cit)._drugHuoHao << "\n"
<< "Drug MingCheng: " << (*cit)._drugMingCheng << "\n"
<< "Drug PiHao: " << (*cit)._drugPiHao << "\n"
<< "Drug GuiGe: " << (*cit)._drugGuiGe << "\n"
<< "Drug JiLiang: " << (*cit)._drugJiLiang << "\n"
<< "Drug ShengChanChangJia: " << (*cit)._drugShengChanChangJia << "\n"
<< "Drug ChuFangLaiYuan: " << (*cit)._drugChuFangLaiYuan << "\n";
++cit;
}
}
void onDealOfSpecialDrugAdded()
{
std::cout << "Successfully add or update a deal of special drug" << std::endl;
}
void onDealOfSpecialDrugAddFail()
{
std::cout << "Failed to add or update a deal of special drug" << std::endl;
}
void onDealsOfSpecialDrugDetail(const std::vector<client::UserCallback::DealsOfSpecialDrugDetailItem> &info)
{
std::vector<client::UserCallback::DealsOfSpecialDrugDetailItem>::const_iterator cit = info.begin();
while (cit != info.end())
{
std::cout << "Deal id: " << (*cit)._dealId << "\n"
<< "Buyer name: " << (*cit)._buyerName << "\n"
<< "Buyer shenfenzheng: " << (*cit)._buyerShenFenZheng << "\n"
<< "Buyer age: " << (*cit)._buyerAge << "\n"
<< "Buyer is male: " << (*cit)._buyerIsMale << "\n"
<< "Time: " << (*cit)._time << "\n"
<< "Drug HuoHao: " << (*cit)._drugHuoHao << "\n"
<< "Drug MingCheng: " << (*cit)._drugMingCheng << "\n"
<< "Drug PiHao: " << (*cit)._drugPiHao << "\n"
<< "Drug GuiGe: " << (*cit)._drugGuiGe << "\n"
<< "Drug JiLiang: " << (*cit)._drugJiLiang << "\n"
<< "Drug GouMaiShuLiang: " << (*cit)._drugGouMaiShuLiang << "\n"
<< "Drug ShengChanChangJia: " << (*cit)._drugShengChanChangJia << "\n"
<< "Drug ChuFangLaiYuan: " << (*cit)._drugChuFangLaiYuan << "\n";
++cit;
}
}
void onConsultingDetails(const std::vector<client::UserCallback::ConsultingDetailItem> &info)
{
std::vector<client::UserCallback::ConsultingDetailItem>::const_iterator cit = info.begin();
while (cit != info.end())
{
std::cout << "Pharmacist id: " << (*cit)._pharmacistId << "\n"
<< "Patient id: " << (*cit)._patientId << "\n"
<< "Start time: " << (*cit)._startTime << "\n"
<< "End time: " << (*cit)._endTime << "\n"
<< "Pharmacist video loc: " << (*cit)._pharmacistVideoLoc << "\n"
<< "Patient video loc: " << (*cit)._patientVideoLoc << "\n"
<< "Pharmacist audio loc: " << (*cit)._pharmacistAudioLoc << "\n"
<< "Patient audio loc: " << (*cit)._patientAudioLoc << "\n"
<< "Prescription locs: ";
std::vector<std::string>::const_iterator ciit = (*cit)._prescriptionLocs.begin();
while (ciit != (*cit)._prescriptionLocs.end())
{
std::cout << *ciit << ",";
++ciit;
}
std::cout << std::endl;
++cit;
}
}
void onPharmacistActivityList(const std::vector<std::string> &info)
{
std::vector<std::string>::const_iterator iter = info.begin();
while (iter != info.end())
{
std::cout << "Pharmacist activity: " << *iter << std::endl;
++iter;
}
}
void onPharmacistQuitService(unsigned int pharmacistSessionId)
{
std::cout << std::endl;
std::cout << "Pharmacist quits conversation: pharmacistSessionId=" << pharmacistSessionId << std::endl;
_patient->stopVideoReceiver();
_patient->stopAudioReceiver();
std::cout << "Enter command: ";
}
// ============================================================================
// ============================================================================
void run()
{
std::string helpStr(
"\n" \
"command: \n" \
" login : 登录到服务器 \n" \
" get_pharmacist_info : 得到当前药店的责任药剂师的信息 \n" \
" fetch_pharmacist : 请求连接当前药店的责任药剂师 \n" \
" fetch_global_pharmacist : 在全局空闲药剂师中寻找一个服务 \n" \
" send_prescription : 发送处方单(内部模拟的字符串) \n" \
" send_video : 发送视频包(内部循环20次,每次间隔1秒,每次发送一个小字符串) \n" \
" send_audio : 发送音频包(内部循环20次,每次间隔1秒,每次发送一个小字符串) \n" \
" add_prescription_drug_deal : 登记一笔处方药销售记录 \n" \
" list_prescription_drug_deals : 查询处方药销售记录 \n" \
" add_special_drug_deal : 登记一笔特殊药销售记录 \n" \
" list_special_drug_deals : 查询特殊药销售记录 \n" \
" list_consulting_details : 查询咨询记录 \n" \
" list_pharmacist_activity : 查询药师活动记录 \n" \
" stop_conversation : 退出当前对话 \n" \
" send_hb : 发送心跳包 \n" \
" logout : 退出登录 \n" \
" quit : 结束程序 \n" \
"\n"
);
std::string command;
do
{
std::cout << "Enter command: ";
getline(std::cin, command);
if (command == "login")
{
std::cout << "username: ";
std::string username;
getline(std::cin, username);
std::cout << "password: ";
std::string password;
getline(std::cin, password);
_patient = new client::Patient(username, password, this);
if (!_patient->connect("127.0.0.1", 31257))
{
std::cout << "Failed to connect to the session server" << std::endl;
continue;
}
_patient->start();
_patient->req_Login_Sync(NULL, 0);
}
else if (command == "get_pharmacist_info")
{
_patient->req_PharmacistsDetailOfCurStore_Sync();
}
else if (command == "fetch_pharmacist")
{
unsigned int certTypeId;
std::string valStr;
do
{
std::cout << "certTypeId: ";
getline(std::cin, valStr);
} while (!sserver::Utils::string2Num<unsigned int>(valStr, certTypeId));
_patient->req_Pharmacist_Sync(certTypeId, false);
}
else if (command == "fetch_global_pharmacist")
{
unsigned int certTypeId;
std::string valStr;
do
{
std::cout << "certTypeId: ";
getline(std::cin, valStr);
} while (!sserver::Utils::string2Num<unsigned int>(valStr, certTypeId));
_patient->req_Pharmacist_Sync(certTypeId, true);
}
else if (command == "send_prescription")
{
std::string prescription_go("This a prescription from patient !!!");
client::User::Prescription p1;
p1._dataLen = prescription_go.length();
p1._pData = prescription_go.c_str();
if (!_patient->send_Prescription(p1))
{
std::cout << "failed to send prescription" << std::endl;
}
}
else if (command == "send_video")
{
std::string videoPac("Here is a video pac from patient");
for (unsigned int i = 0; i < 200; ++i)
{
client::User::Video v;
v._dataLen = videoPac.length();
v._pData = videoPac.c_str();
if (!_patient->send_Video(v))
{
std::cout << "failed to send video to pharmacist" << std::endl;
}
}
}
else if (command == "send_audio")
{
std::string audioPac("Here is a audio pac from patient");
for (unsigned int i = 0; i < 20; ++i)
{
client::User::Audio a;
a._dataLen = audioPac.length();
a._pData = audioPac.c_str();
if (!_patient->send_Audio(a))
{
std::cout << "failed to send audio to pharmacist" << std::endl;
}
Poco::Thread::sleep(1000);
}
}
else if (command == "add_prescription_drug_deal")
{
client::User::DealOfPrescriptionDrug deal;
deal._updateDealId=0;
deal._buyerName="JiangTao";
deal._buyerAge=32;
deal._buyerIsMale=true;
deal._drug_guige="规格";
deal._drug_huohao="12345678";
deal._drug_jiliang="1升";
deal._drug_chufanglaiyuan="科创药业";
deal._drug_mingcheng="999感冒灵";
deal._drug_pihao="88888888";
deal._drug_shengchanchangjia="哈药集团";
_patient->req_AddDealOfPrescriptionDrug_Sync(deal);
Poco::Thread::sleep(1000);
deal._buyerName="LiLing";
deal._updateDealId=1;
_patient->req_AddDealOfPrescriptionDrug_Sync(deal);
}
else if (command == "list_prescription_drug_deals")
{
std::cout << "startTime(YYYY-MM-DD hh:mm:ss): ";
std::string startTime;
getline(std::cin, startTime);
std::cout << "endTime(YYYY-MM-DD hh:mm:ss): ";
std::string endTime;
getline(std::cin, endTime);
_patient->req_ListDealsOfPrescriptionDrug_Sync(1, startTime, endTime);
}
else if (command == "add_special_drug_deal")
{
client::User::DealOfSpecialDrug deal;
deal._updateDealId=0;
deal._buyerName="JiangTao";
deal._buyerShenFenZheng="510108";
deal._buyerAge=32;
deal._buyerIsMale=true;
deal._drug_guige="规格";
deal._drug_huohao="12345678";
deal._drug_jiliang="1升";
deal._drug_goumaishuliang="2份";
deal._drug_chufanglaiyuan="科创药业";
deal._drug_mingcheng="999感冒灵";
deal._drug_pihao="88888888";
deal._drug_shengchanchangjia="哈药集团";
_patient->req_AddDealOfSpecialDrug_Sync(deal);
Poco::Thread::sleep(1000);
deal._buyerName="LiLing";
deal._updateDealId=1;
_patient->req_AddDealOfSpecialDrug_Sync(deal);
}
else if (command == "list_special_drug_deals")
{
std::cout << "startTime(YYYY-MM-DD hh:mm:ss): ";
std::string startTime;
getline(std::cin, startTime);
std::cout << "endTime(YYYY-MM-DD hh:mm:ss): ";
std::string endTime;
getline(std::cin, endTime);
_patient->req_ListDealsOfSpecialDrug_Sync(1, startTime, endTime);
}
else if (command == "list_consulting_details")
{
std::cout << "startTime(YYYY-MM-DD hh:mm:ss): ";
std::string startTime;
getline(std::cin, startTime);
std::cout << "endTime(YYYY-MM-DD hh:mm:ss): ";
std::string endTime;
getline(std::cin, endTime);
_patient->req_ListConsultingDetails_Sync(1, startTime, endTime);
}
else if (command == "list_pharmacist_activity")
{
std::cout << "startTime(YYYY-MM-DD hh:mm:ss): ";
std::string startTime;
getline(std::cin, startTime);
std::cout << "endTime(YYYY-MM-DD hh:mm:ss): ";
std::string endTime;
getline(std::cin, endTime);
_patient->req_ListPharmacistActivity_Sync(4, startTime, endTime);
}
else if (command == "stop_conversation")
{
_patient->stopConverstaion();
}
else if (command == "logout")
{
_patient->logout();
}
else if (command == "send_hb")
{
_patient->send_HB();
}
else if (command == "quit")
{
break;
}
else if (command == "help")
{
std::cout << helpStr << std::endl;
}
else
{
std::cout << "Un-recognized command, pls try again ..." << std::endl;
}
} while (true);
}
void start()
{
_thread.start(*this);
}
void waitForQuit()
{
_thread.join();
}
private:
Poco::Thread _thread;
client::Patient *_patient;
};
|
88026bcb8b7ffd9cf20568abca55bcf3b3b52834
|
dc4a282b7e604cb288375e7e2876ef36b6721aa8
|
/boj/2953/2953.cpp
|
e0d3b3b3cd5b9adeb2e61ac02684b95a2f3f8a33
|
[] |
no_license
|
yjbong/problem-solving
|
89be67ba24ad7495d82dcb0788dd7db1b849996a
|
c775271098daa05fcac269fd15de502e60592d49
|
refs/heads/master
| 2023-04-02T18:47:22.920512
| 2023-03-21T17:28:02
| 2023-03-21T17:28:02
| 70,111,700
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 291
|
cpp
|
2953.cpp
|
#include <cstdio>
int score[5];
int main(void){
for(int i=0; i<5; i++){
score[i]=0;
for(int j=0; j<4; j++){
int num;
scanf("%d",&num);
score[i]+=num;
}
}
int win=0;
for(int i=1; i<5; i++)
if(score[i]>score[win]) win=i;
printf("%d %d\n",win+1,score[win]);
return 0;
}
|
98a59d04c9239cd79022cc8097af1c1065bb469d
|
fc915284fe13a5f27f78583cebdde9dcc2646dbb
|
/L06_E01/main.cpp
|
d6d5ad1ed33921d9b7c0a32ff54596ea575e4ff4
|
[] |
no_license
|
Junhonguk/codility
|
379589da1bf1c0a9250b7683615d26a0d64f3bed
|
6ef333ff85f9524814edfb2850815620afe4b7ac
|
refs/heads/master
| 2020-03-23T23:02:25.855882
| 2016-01-24T21:55:57
| 2016-01-24T21:55:57
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 520
|
cpp
|
main.cpp
|
#include <iostream>
#include <vector>
#include <algorithm>
/* Distinct
* L6 - Ex 1
*/
using namespace std;
int solution(vector<int> &A )
{
if( A.empty() ) return 0;
sort(A.begin(),A.end());
int dist=1;
for( unsigned int i=1; i<A.size(); i++ ) {
if( A[i]!=A[i-1] )
dist++;
}
return dist;
}
int main(int argc, char **argv) {
vector<int> A;
A.push_back(2);
A.push_back(1);
A.push_back(1);
A.push_back(2);
A.push_back(3);
A.push_back(1);
cout << solution(A) << endl;
return 0;
}
|
be09dc445fc65bdad2a0ffc8000a1239a2147212
|
2d9909133b6d2f5b50fd58d8a04f451a7247aba0
|
/Servidor/src/server/model/TerrainObject.h
|
5b86ddfe1708da4c0bfa123d667bce56b3a9e1a0
|
[] |
no_license
|
ldtg/tallerZ
|
e6f82bc45e36414a97ce3bdbc032c2d43d04151f
|
3fa17ec2cec77f2625b8811e9dc00d50fdf30c8b
|
refs/heads/master
| 2021-01-20T13:21:34.969423
| 2017-07-05T23:13:29
| 2017-07-05T23:13:29
| 90,473,475
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,222
|
h
|
TerrainObject.h
|
#ifndef TALLERZ_TERRAINOBJECT_H
#define TALLERZ_TERRAINOBJECT_H
#include "Attackable.h"
#include "common/Types/TerrainObjectType.h"
#include "common/IDs/TerrainObjectID.h"
#include "common/States/TerrainObjectState.h"
#include "TerrainObjectData.h"
class TerrainObject : public Attackable {
private:
TerrainObjectID id;
Position centerPosition;
unsigned short health;
unsigned short size;
std::vector<unsigned short> damagesToReceive;
bool passable;
Player *owner;
public:
TerrainObject(const TerrainObjectData &data,
const Position ¢erPos,
Player *owner);
virtual Player *getOwner() override;
virtual Position getAttackPosition(const Position &attacker) const override;
virtual Position nextMovePosition() const override;
virtual void receiveAttack(const Weapon &weapon) override;
virtual void receiveDamages();
virtual bool isAlive() const override;
virtual bool isMoving() const override;
virtual bool hasDamagesToReceive() const;
virtual TerrainObjectID getID() const;
virtual TerrainObjectState getState() const;
virtual Position getCenterPosition() const override;
virtual ~TerrainObject() override;
};
#endif //TALLERZ_TERRAINOBJECT_H
|
5c9c6e152f8c1349973c3620953a6c5d961f229e
|
3b97b786b99c3e4e72bf8fe211bb710ecb674f2b
|
/TClient/Tools/TQuestEditor/TTermSet.cpp
|
8bc8e82213897e245eb1bd21eb6f7c83b1dfc78a
|
[] |
no_license
|
moooncloud/4s
|
930384e065d5172cd690c3d858fdaaa6c7fdcb34
|
a36a5785cc20da19cd460afa92a3f96e18ecd026
|
refs/heads/master
| 2023-03-17T10:47:28.154021
| 2017-04-20T21:42:01
| 2017-04-20T21:42:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,388
|
cpp
|
TTermSet.cpp
|
// TTermSet.cpp : implementation file
//
#include "stdafx.h"
#include "TQuestEditor.h"
#include "TTermSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTTermSet
IMPLEMENT_DYNAMIC(CTTermSet, CRecordset)
CTTermSet::CTTermSet(CDatabase* pdb)
: CRecordset(pdb)
{
//{{AFX_FIELD_INIT(CTTermSet)
m_bCount = 0;
m_bTermType = 0;
m_dwID = 0;
m_dwQuestID = 0;
m_dwTermID = 0;
m_nFields = 5;
//}}AFX_FIELD_INIT
m_nDefaultType = snapshot;
}
CString CTTermSet::GetDefaultConnect()
{
return _T("ODBC;DSN=TQUEST");
}
CString CTTermSet::GetDefaultSQL()
{
return _T("[dbo].[TQUESTTERMCHART]");
}
void CTTermSet::DoFieldExchange(CFieldExchange* pFX)
{
//{{AFX_FIELD_MAP(CTTermSet)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Byte(pFX, _T("[bCount]"), m_bCount);
RFX_Byte(pFX, _T("[bTermType]"), m_bTermType);
RFX_Long(pFX, _T("[dwID]"), m_dwID);
RFX_Long(pFX, _T("[dwQuestID]"), m_dwQuestID);
RFX_Long(pFX, _T("[dwTermID]"), m_dwTermID);
//}}AFX_FIELD_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CTTermSet diagnostics
#ifdef _DEBUG
void CTTermSet::AssertValid() const
{
CRecordset::AssertValid();
}
void CTTermSet::Dump(CDumpContext& dc) const
{
CRecordset::Dump(dc);
}
#endif //_DEBUG
|
1c91df65c66c8bd6ee382113b6d45b5691ec2211
|
c0078f8c1966bef845c1b4ddd46424290abdaf2e
|
/NaturalSoftware.Kinect/NaturalSoftware.Kinect/Skeleton.h
|
265b12a49e6cd4e684ffec2abb5ab2c61cd99d60
|
[
"MIT"
] |
permissive
|
nagyistge/NaturalSoftware.Kinect.Cpp
|
ca683c24eff7b95e36fc032ba54f1be67aec71ad
|
b4c75f852c4686bd7054dea37e0f459ad04dc49b
|
refs/heads/master
| 2020-06-17T00:57:36.547282
| 2012-11-29T08:37:02
| 2012-11-29T08:37:02
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,702
|
h
|
Skeleton.h
|
#pragma once
#include <Windows.h>
#include <NuiApi.h>
#include <vector>
#include "Joint.h"
namespace NaturalSoftware { namespace Kinect {
enum FrameEdges
{
None = 0x0,
Right = 0x1,
Left = 0x2,
Top = 0x4,
Bottom = 0x8,
};
class Skeleton
{
public:
typedef std::vector<NUI_SKELETON_BONE_ORIENTATION> BoneOrientationCollection;
typedef std::vector<Joint> JointCollection;
explicit Skeleton( NUI_SKELETON_DATA& skeletonData );
~Skeleton();
NUI_SKELETON_TRACKING_STATE TrackingState() const
{
return skeletonData_.eTrackingState;
}
DWORD TrackingId() const
{
return skeletonData_.dwTrackingID;
}
DWORD UserIndex() const
{
return skeletonData_.dwUserIndex;
}
const Vector4& Position() const
{
return skeletonData_.Position;
}
FrameEdges ClippedEdges() const
{
return (FrameEdges)skeletonData_.dwQualityFlags;
}
DWORD EnrollmentIndex() const
{
return skeletonData_.dwEnrollmentIndex;
}
const BoneOrientationCollection& GetBoneOrientations() const
{
return boneOrientations_;
}
const JointCollection& GetJoints() const
{
return joints_;
}
const NUI_SKELETON_DATA* GetSkeletonData() const
{
return &skeletonData_;
}
private:
NUI_SKELETON_DATA skeletonData_;
BoneOrientationCollection boneOrientations_;
JointCollection joints_;
};
}}
|
ca5ec917e7661136a76e1c39fec2260796324767
|
f76d326eff25a5e52ce37f77fbea0ec6fff971a6
|
/Lex_master_1.cpp
|
16a0bd9c88e0e8de1c9dbf7e32ac88590f90d660
|
[] |
no_license
|
Helgust/LEX
|
10f8c95539519557954d5a611d0ad1a873006966
|
c4e3d498a3d542d8acd0c4d6c6b7812a588549df
|
refs/heads/master
| 2020-05-17T10:38:37.785092
| 2020-04-15T13:26:24
| 2020-04-15T13:26:24
| 183,663,163
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,149
|
cpp
|
Lex_master_1.cpp
|
//#include "Lex.hpp"
#include <iostream>
#include <string>
#include <cstdio>
#include <ctype.h>
#include <cstdlib>
#include <vector>
#include <stack>
#include <algorithm>
#include <unordered_map>
using namespace std;
enum type_of_lex {
LEX_NULL, /*0*/
LEX_AND, LEX_BOOL, LEX_DO, LEX_ELSE, LEX_IF, LEX_FALSE, LEX_INT,LEX_STRING, /*8*/
LEX_NOT, LEX_OR, LEX_PROGRAM, LEX_READ, LEX_THEN, LEX_TRUE, LEX_GOTO, LEX_WHILE, LEX_WRITE,LEX_BREAK, /*18*/
LEX_FIN, /*19*/
LEX_SEMICOLON, LEX_COMMA, LEX_COLON, LEX_ASSIGN, LEX_LPAREN, LEX_RPAREN, LEX_EQ, LEX_LSS, /*27*/
LEX_GTR, LEX_PLUS, LEX_MINUS, LEX_TIMES, LEX_SLASH, LEX_LEQ, LEX_NEQ, LEX_GEQ, LEX_FBRC_O, LEX_FBRC_C,LEX_DQUATES, /*38*/
LEX_NUM, /*39*/
LEX_ID, /*40*/
POLIZ_LABEL, /*41*/
POLIZ_ADDRESS, /*42*/
POLIZ_GO, /*43*/
POLIZ_FGO
};
///////////////////////// Класс Lex //////////////////////////
class Lex {
type_of_lex t_lex;
int v_lex;
public:
Lex ( type_of_lex t = LEX_NULL, int v = 0): t_lex (t), v_lex (v) { }
type_of_lex get_type () const {
return t_lex;
}
int get_value () const {
return v_lex;
}
friend ostream & operator<< (ostream &s, Lex l);
};
///////////////////// Класс Ident ////////////////////////////
class Ident {
string name;
bool declare;
type_of_lex type;
bool assign;
int value;
public:
Ident() {
declare = false;
assign = false;
}
bool operator==(const string& s) const {
return name == s;
}
Ident(const string n) {
name = n;
declare = false;
assign = false;
}
string get_name () const {
return name;
}
bool get_declare () const {
return declare;
}
void put_declare () {
declare = true;
}
type_of_lex get_type () const {
return type;
}
void put_type ( type_of_lex t ) {
type = t;
}
bool get_assign () const {
return assign;
}
void put_assign (){
assign = true;
}
int get_value () const {
return value;
}
void put_value (int v){
value = v;
}
};
////////////////////// TID ///////////////////////
vector<Ident> TID;
int put ( const string & buf ){
vector<Ident>::iterator k;
if ( (k = find(TID.begin(), TID.end(), buf)) != TID.end())
return k - TID.begin();
TID.push_back(Ident(buf));
return TID.size() - 1;
}
////////////////////// TOT (Table Of Text) ///////////////////////
vector<string> TOT;
//////////////////////////////////////////////////////////////////
std::unordered_map <type_of_lex,const std::string> TD_map =
{
{LEX_AND,"and"},
{LEX_BOOL,"bool"},
{LEX_DO,"do"},
{LEX_ELSE,"else"},
{LEX_IF,"if"},
{LEX_FALSE,"false"},
{LEX_INT,"int"},
{LEX_STRING,"string"},
{LEX_NOT,"not"},
{LEX_OR,"or"},
{LEX_PROGRAM,"program"},
{LEX_READ,"read"},
{LEX_THEN,"then"},
{LEX_TRUE,"true"},
{LEX_GOTO,"goto"},
{LEX_WHILE,"while"},
{LEX_WRITE,"write"},
{LEX_BREAK,"break"},
{LEX_FIN,"FIN"},
{LEX_SEMICOLON,";"},
{LEX_COMMA,","},
{LEX_COLON,":"},
{LEX_ASSIGN,"="},
{LEX_LPAREN,"("},
{LEX_RPAREN,")"},
{LEX_EQ,"=="},
{LEX_LSS,"<"},
{LEX_GTR,">"},
{LEX_PLUS,"+"},
{LEX_MINUS,"-"},
{LEX_SLASH,"/"},
{LEX_LEQ,"<="},
{LEX_NEQ,"!="},
{LEX_GEQ,">="},
{LEX_FBRC_O,"{"},
{LEX_FBRC_C,"}"},
{LEX_DQUATES,"\""},
{LEX_NUM,"NUM"},
{LEX_ID,"ID"},
{LEX_NULL,""},
};
/////////////////////////////////////////////////////////////////
class Scanner {
FILE * fp;
char c;
//string buf;
//Lex lex;
int look ( const string& buf, const char ** list ) {
int i = 0;
while (list[i]) {
if (buf == list[i])
return i;
++i;
}
return 0;
}
void gc () {
c = fgetc (fp);
}
//void makeLex(type_of_lex type) { lex = Lex(type, buf); };
public:
static const char * TW [], * TD [];
Scanner ( const char * program ) {
fp = fopen ( program, "r" );
}
Lex get_lex ();
};
const char *
Scanner::TW [] = {"", "and", "bool","do", "else", "if", "false", "int","string" , "not", "or", "program",
"read", "then", "true","goto", "while", "write","break", NULL};
const char *
Scanner::TD [] = {"@", ";", ",", ":", "=", "(", ")", "==", "<", ">", "+", "-", "*", "/", "<=", "!=", ">=","{","}","\"", NULL};
Lex Scanner::get_lex () {
enum state { H, IDENT, NUMB, COM,COM1,COM2, ALE, NEQ, FBRACK,DQUATES,STRING};
int d, j;
string buf;
state CS = H;
do {
gc();
if(c==EOF) return Lex(LEX_NULL);
switch(CS) {
case H: //cout<<"Case H"<<'\n';
if ( c==' ' || c == '\n' || c== '\r' || c == '\t' ); //gc();
else if ( isalpha(c) ) {
buf.push_back(c);
//sgc();
CS = IDENT;
}
else if ( isdigit(c) ) {
d = c - '0';
//gc();
CS = NUMB;
}
else if ( c== '{' ) {
//CS=FBRACK;
return Lex(LEX_FBRC_O);
}
else if ( c== '}' ) {
//CS=FBRACK;
return Lex(LEX_FBRC_C);
}
else if ( c== '"' ) {
CS=DQUATES;
return Lex(LEX_DQUATES);
}
else if ( c== '=' || c== '<' || c== '>' ) {
buf.push_back(c);
CS = ALE;
}
/* else if (c == '@')
return Lex(LEX_FIN); */
else if (c == '!') {
buf.push_back(c);
CS = NEQ;
}
else if (c == '!') {
buf.push_back(c);
CS = NEQ;
}
else if (c == '/') {
//buf.push_back(c);
CS = COM;
}
else {
buf.push_back(c);
if ( (j = look ( buf, TD)) ){
return Lex ( (type_of_lex)(j+(int)LEX_FIN), j );
}
else
throw c;
}
break;
case IDENT: //cout<<"Case IDENT"<<" "<<c<<'\n';
if ( isalpha(c) || isdigit(c) ) {
buf.push_back(c);
//gc();
}
else {
ungetc (c, fp);
if ( (j = look (buf, TW)) ){
return Lex ((type_of_lex)j, j);
}
else {
j = put(buf);
return Lex (LEX_ID, j);
}
}
break;
case NUMB: //cout<<"Case NUMB"<<'\n';
if ( isdigit(c) ) {
d = d * 10 + (c - '0');
//gc();
}
else {
ungetc (c, fp);
return Lex ( LEX_NUM, j);
}
break;
case COM: //cout<<"Case COM"<<" "<<c<<'\n';
if ( c == '*' ) {
//gc();
CS = COM1;
}
break;
case COM1: //cout<<"Case COM"<<" "<<c<<'\n';
if ( c == '*' ) {
//gc();
CS = COM2; // не работает коомметнраии
}
else if (c == EOF || c == '/' )
throw c;
break;
case COM2: //cout<<"Case COM"<<" "<<c<<'\n';
if ( c == '/' ) {
gc();
CS = H;
}
else if (c == '*' || c == EOF )
throw c;
break;
case DQUATES: //cout<<"Case COM"<<" "<<c<<'\n';
if ( c == '"' ) {
buf.push_back(c);
CS = STRING;
}
else
{
ungetc (c, fp);
buf.clear();
//return Lex(LEX_DQUATES) ;
}
break;
case STRING: //cout<<"Case COM"<<" "<<c<<'\n';
gc();
while(c!='"')
{
buf.push_back(c);
}
TOT.push_back(buf);
CS=H;
return Lex(LEX_DQUATES);
break;
case ALE: //cout<<"Case ALE"<<'\n';
if ( c== '=') {
buf.push_back(c);
j = look ( buf, TD );
return Lex ( (type_of_lex)(j+(int)LEX_FIN), j);
}
else {
ungetc (c, fp);
j = look ( buf, TD );
return Lex ( (type_of_lex)(j+(int)LEX_FIN), j );
}
break;
case NEQ: // cout<<"Case NEQ"<<'\n';
if (c == '=') {
buf.push_back(c);
j = look ( buf, TD );
return Lex ( LEX_NEQ, j );
}
else
throw '!';
break;
}//end switch
} while (true);
}
ostream & operator<< (ostream &s, Lex l){
string t;
std::unordered_map <type_of_lex,const std::string>::const_iterator got = TD_map.find (l.t_lex);
if (got == TD_map.end())
{
s << '(' << l.t_lex << ',' << "not found "<< ");" << endl;
}
else
{
s << '(' << got->second << ',' << got->first << ',' << l.t_lex << ");" << endl;
}
/* if (l.t_lex <= 18)
t = Scanner::TW[l.t_lex];
else if (l.t_lex >= 19 && l.t_lex <= 38)
t = Scanner::TD[l.t_lex-19];
else if (l.t_lex == 39)
t = "NUMB";
else if (l.t_lex == 40)
t = TID[l.v_lex].get_name();
else if (l.t_lex == 41)
t = "Label";
else if(l.t_lex == 42)
t = "Addr";
else if (l.t_lex == 43)
t = "!";
else if (l.t_lex == 44)
t = "!F";
else
throw l;
s << '(' << t << ',' << << ");" << endl; */
return s;
}
int main(int argc, char* argv[])
{
try {
Scanner c(argv[1]);
Lex l;
l=c.get_lex();
cout<<l<<'\n';
while(true)
{
l=c.get_lex();
cout<<l<<'\n';
if(l.get_type()==0) break;
}
}
catch (char c) {
cout << "unexpected symbol " << c << endl;
return 1;
}
catch (Lex l) {
cout << "unexpected lexeme" << l << endl;
return 1;
}
catch ( const char *source ) {
cout << source << endl;
return 1;
}
}
|
494f01fdf46ecb390e5c6b1e13f95db481cb9320
|
49f88ff91aa582e1a9d5ae5a7014f5c07eab7503
|
/gen/third_party/blink/renderer/modules/webaudio/audio_context_options.h
|
13c440cc681ac6e639ea5ab2309f8884de316ae7
|
[] |
no_license
|
AoEiuV020/kiwibrowser-arm64
|
b6c719b5f35d65906ae08503ec32f6775c9bb048
|
ae7383776e0978b945e85e54242b4e3f7b930284
|
refs/heads/main
| 2023-06-01T21:09:33.928929
| 2021-06-22T15:56:53
| 2021-06-22T15:56:53
| 379,186,747
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,641
|
h
|
audio_context_options.h
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated from the Jinja2 template
// third_party/blink/renderer/bindings/templates/dictionary_impl.h.tmpl
// by the script code_generator_v8.py.
// DO NOT MODIFY!
// clang-format off
#ifndef AudioContextOptions_h
#define AudioContextOptions_h
#include "third_party/blink/renderer/bindings/core/v8/idl_dictionary_base.h"
#include "third_party/blink/renderer/bindings/modules/v8/audio_context_latency_category_or_double.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class MODULES_EXPORT AudioContextOptions : public IDLDictionaryBase {
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
public:
AudioContextOptions();
virtual ~AudioContextOptions();
AudioContextOptions(const AudioContextOptions&);
AudioContextOptions& operator=(const AudioContextOptions&);
bool hasLatencyHint() const { return !latency_hint_.IsNull(); }
const AudioContextLatencyCategoryOrDouble& latencyHint() const {
return latency_hint_;
}
void setLatencyHint(const AudioContextLatencyCategoryOrDouble&);
v8::Local<v8::Value> ToV8Impl(v8::Local<v8::Object>, v8::Isolate*) const override;
void Trace(blink::Visitor*) override;
private:
AudioContextLatencyCategoryOrDouble latency_hint_;
friend class V8AudioContextOptions;
};
} // namespace blink
#endif // AudioContextOptions_h
|
9628aa47ee80999bd72193f36fc2c91a2a5389be
|
fcdea24e6466d4ec8d7798555358a9af8acf9b35
|
/Engine/mrayGameLayer/GameComponentGI.h
|
7cd0802f2ff16a2401a2783ae9fea6d1785b9952
|
[] |
no_license
|
yingzhang536/mrayy-Game-Engine
|
6634afecefcb79c2117cecf3e4e635d3089c9590
|
6b6fcbab8674a6169e26f0f20356d0708620b828
|
refs/heads/master
| 2021-01-17T07:59:30.135446
| 2014-11-30T16:10:54
| 2014-11-30T16:10:54
| 27,630,181
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 879
|
h
|
GameComponentGI.h
|
/********************************************************************
created: 2013/01/22
created: 22:1:2013 15:20
filename: C:\Development\mrayEngine\Engine\mrayGameLayer\GameComponentGI.h
file path: C:\Development\mrayEngine\Engine\mrayGameLayer
file base: GameComponentGI
file ext: h
author: MHD Yamen Saraiji
purpose:
*********************************************************************/
#ifndef __GameComponentGI__
#define __GameComponentGI__
#include "IGhostInterface.h"
namespace mray
{
namespace game
{
class IGameComponent;
class GameComponentGI:public IGhostInterface
{
protected:
IGameComponent* m_owner;
public:
GameComponentGI(IGameComponent* owner);
virtual~GameComponentGI();
IGameComponent* GetOwner(){return m_owner;}
virtual void CreateWrite(OS::StreamWriter* stream);
};
}
}
#endif
|
978bbe8363d68d280047601b814e870e99a5cafc
|
390686385d6c5942dee0a896e6368671292f2d28
|
/main/Info.h
|
c2e2093194f9957cd2162270169ffb8a3f2aa146
|
[] |
no_license
|
sologub-s/aldebaran
|
d98cd1eb352cbf624fdc95f6b36d0893952bb8fb
|
81da69b89d2eb7c8632f922cd28da862ac102f25
|
refs/heads/master
| 2021-06-19T21:12:01.869686
| 2021-06-05T22:21:42
| 2021-06-05T22:21:42
| 219,579,100
| 0
| 0
| null | 2021-06-05T22:21:42
| 2019-11-04T19:23:02
|
C++
|
UTF-8
|
C++
| false
| false
| 1,109
|
h
|
Info.h
|
/**
* Class representing data object of info message
* tgo be sent to serial port
*/
class Info
{
private:
// serialized data, ready to be sent to serial
String serializedData = "";
// name of the info message (a part before the '=')
String name = "";
// value of the info message (a part after the '=')
String value = "";
/**
* Serialize the data like name=value
*/
void serializeData(String name, String value) {
this->serializedData = name;
if (value.length() > 0) {
this->serializedData += "=" + value;
}
}
public:
/**
* Constructor
*/
Info (String name, String value)
{
this->name = name;
this->value = value;
this->serializeData(this->name, this->value);
}
/**
* Constructor
*/
Info (String name)
{
this->name = name;
this->value = "";
this->serializeData(this->name, this->value);
}
/**
* Return serialized message
*/
String getSerializedData()
{
return this->serializedData;
}
};
|
81e42baedbac6079335395768c719a6b69b5377f
|
c1d39d3b0bcafbb48ba2514afbbbd6d94cb7ffe1
|
/source/deps/Metadata/Exif_Types.h
|
dde9cc406fc26493ba403e041a01d193cbdb671d
|
[
"IJG",
"MIT"
] |
permissive
|
P4ll/Pictus
|
c6bb6fbc8014c7de5116380f48f8c1c4016a2c43
|
0e58285b89292d0b221ab4d09911ef439711cc59
|
refs/heads/master
| 2023-03-16T06:42:12.293939
| 2018-09-13T18:19:30
| 2018-09-13T18:19:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,313
|
h
|
Exif_Types.h
|
#ifndef IMAGE_EXIF_TYPES_H
#define IMAGE_EXIF_TYPES_H
#include <map>
#include <vector>
#include <cstdint>
#include "Metadata_Value.h"
namespace Metadata {
namespace Exif {
enum class ByteOrder {
Undefined,
Intel,
Motorola
};
enum class TagName {
// IFD0 tags
ImageDescription = 0x010e,
Make = 0x010f,
Model = 0x0110,
Orientation = 0x0112, // Rotation. The only tag we'll use for a while.
XResolution = 0x011a,
YResolution = 0x011b,
ResolutionUnit = 0x0128,
Software = 0x0131,
DateTime = 0x0132,
WhitePoint = 0x013e,
PrimaryChromaticities = 0x013f,
YCbCrCoefficients = 0x0211,
YCbCrPositioning = 0x0213,
ReferenceBlackWhite = 0x0214,
Copyright = 0x8298,
// Sub IFD
ExposureTime = 0x829a,
FNumber = 0x829d,
ExposureProgram = 0x8822,
IsoSpeedRatings = 0x8827,
ExifVersion = 0x9000,
DateTimeOriginal = 0x9003,
DateTimeDigitized = 0x9004,
ComponentConfiguration = 0x9101, // Unknown use
CompressedBitsPerPixel = 0x9102,
Brightness = 0x9203,
ExposureBias = 0x9204,
MaxAperture = 0x9205,
SubjectDistance = 0x9206,
MeteringMode = 0x9207,
LightSource = 0x9208,
Flash = 0x9209,
FocalLength = 0x920a,
MakerNote = 0x927c, // Maker dependent data, not handled,
UserComment = 0x9286,
FlashPixVersion = 0xa000, // Unknown use
ColorSpace = 0xa001,
ExifImageWidth = 0xa002,
ExifImageHeight = 0xa003,
RelatedSoundFile = 0xa004,
ExifInteroperabilityOffset = 0xa005, // Unknown use
FocalPlaneXResolution = 0xa20e,
FocalPlaneYResolution = 0xa20f,
FocalPlaneResolutionUnit = 0xa210,
SensingMethod = 0xa217,
FileSource = 0xa300,
SceneType = 0xa301,
DigitalZoomRatio = 0xa404,
SubIfd = 0x8769,
GpsIfd = 0x8825,
LatitudeRef = 0x001,
Latitude = 0x0002,
LongitudeRef = 0x0003,
Longitude = 0x0004,
AltitudeRef = 0x0005,
Altitude = 0x0006,
};
enum class TagFormat {
UInt8 = 1,
Ascii = 2,
UInt16 = 3,
UInt32 = 4,
URational = 5,
SInt8 = 6,
Undefined = 7,
SInt16 = 8,
SInt32 = 9,
SRational = 10,
Float = 11,
Double = 12
};
struct ExifDocument {
std::map<TagName, uint16_t> U16;
std::map<TagName, std::vector<Metadata::Rational>> Rational;
std::map<TagName, std::string> Ascii;
};
}
}
#endif
|
8f1c6514be3819b50bb96e5c4069df2fffdeac72
|
650f4ec4f03ade37ce86b965ab9eb4f6ef87b3b5
|
/test/atomicCDBoost/main.cpp
|
94a9e790564932dc820629853befa8c225fc1442
|
[] |
no_license
|
Smurgs/SimulationOS
|
f9e4d16f62813dd46ec14562c328ea739dfd2b3d
|
f4c274a874dc2a664f23ef1b2c27ad55a07e27d0
|
refs/heads/master
| 2021-01-11T10:38:32.283301
| 2017-10-01T13:38:27
| 2017-10-01T13:38:27
| 76,133,431
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,016
|
cpp
|
main.cpp
|
#include <math.h>
#include <assert.h>
#include <memory>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
#include <chrono>
#include <algorithm>
#include <limits>
#include <boost/simulation/pdevs/atomic.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/simulation.hpp>
#include "../../vendor/britime.hpp"
#include "../../vendor/input_event_stream.hpp"
#include "../../data_structures/message.hpp"
// INCLUDE THE HEADERS OF YOUR ATOMICS USING THE RELATIVE DIRECTION TO YOUR ACTUAL FOLDER
/*Example*/
//#include "../../atomics/filterPort.hpp"
using namespace std;
using namespace boost::simulation;
using namespace boost::simulation::pdevs;
using namespace boost::simulation::pdevs::basic_models;
using hclock = chrono::high_resolution_clock;
using Time =BRITime; //IF YOU ARE USING BRITIME AS TIME CLASS DO NOT CHANGE ANYTHING. ELSE, BRITime IS YOUR TIME TYPE
using Message = Message_t; //IF YOU ARE USING MESSAGE_T AS MESSAGE CLASS DO NOT CHANGE ANYTHING. ELSE, Message_t IS YOUR MSG TYPE
int main(int argc, char ** argv) {
if (argc < 2) {
cout << "you are using this program with wrong parameters. Te program should be invoked as follow:";
cout << argv[0] << " path to the input file " << endl;
return 1;
}
string test_file = argv[1];
ifstream file(test_file);
string str;
string file_contents;
while (getline(file, str)){
file_contents += str;
file_contents.push_back('\n');
}
string m_input;
m_input = file_contents;
cout << "model input:" << endl;
cout << m_input << endl;
shared_ptr<istringstream> pointer_iss{ new istringstream{} };
pointer_iss->str(m_input);
auto input_test_generator = make_atomic_ptr<input_event_stream<Time, Message, Time, Message>, shared_ptr<istringstream>, Time>(pointer_iss, Time(0),
[](const string& s, Time& t_next, Message& m_next)->void{ //parsing function
string aux;
m_next.clear();
istringstream ss;
ss.str(s);
//CONVERT THE INPUT FILE TO MESSAGES.
//IMPLEMENT HERE THE PARSING FUNCTION JUST FOR ONE LINE.
//THE INPUT FILE MUST BE A TXT. THE FILE CANNOT HAVE BLANK LINE AT THE END
//TIME IN THE TXT FILE HAVE TO BE GREATER OR EQUAL THAN ONE THE PREVIOUS LINE.
/*Example*/
//ss >> t_next; //takes the two fist numbers in the line. The time is defined as a numerator and denominator
//ss >> m_next.port;
//ss >> m_next.value;
string thrash;
ss >> thrash;
if ( 0 != thrash.size()) throw exception();
});
// DEFINE ALL YOUR ATOMIC MODELS
auto AtomicModelNameInstance = make_atomic_ptr< AtomicName<Time,Message>, parametersType>(parametersValue);
//CHANGE AtomicModelNameInstance TO THE NAME YOU GIVE TO THE INSTANCE OF YOUR ATOMIC MODEL
//CHANGE AtomicName TO THE CLASS NAME OF YOUR ATOMIC MODEL. IT WAS DEFINED IN THE FOLDER atomics IN A .hpp FILE
//CHANGE parametersType TO THE PARAMETERS TYPE OF YOUR ATOMIC MODEL CLASS (SEPARATE THEM BY COMMA). IF THERE ARE NO PARAMETERS IN THE CLASE, DELETE ", parametersType"
//CHANGE parametersValue TO THE VALUE OF PARAMETERS TYPE TAKES. IF NO PARAMETERS, DELETE "parametersValue"
/*Examples*/
// auto Subnet1 = make_atomic_ptr<Subnet<Time,Message>, string, int>(string("net1"), 1);
// auto PersonD = make_atomic_ptr<Person<Time,Message>>();
// auto PersonC = make_atomic_ptr<Person<Time,Message>>();
// DEFINE ALL YOUR COUPLED MODELS. EACH COUPLED MODEL IS LIKE AN ATOMIC WHEN YOU DEFINE A HIHER LEVEL. THE NAME OF THE HIGHEST LEVEL MODEL IS CALL TOP.
shared_ptr<flattened_coupled<Time, Message>> TOP(new flattened_coupled<Time, Message>( //CHANGE TOP TO THE NAME OF YOUR COUPLED MODEL
{}, // NAMES OF THE MODELS IN THE COUPLED MODEL
{}, // LIST OF EIC SEPAREATED BY COMMA (",")
{}, // LIST IC DIFINED AS "{inputmodel, outputmodel}" AND SEPARATED BY COMMAS (",")
{}// LIST OF EOC SEPAREATED BY COMMA (",")
));
/* Example*/
// shared_ptr<flattened_coupled<Time, Message>> NET(new flattened_coupled<Time, Message>(
// {input_test_generator, Subnet1}, // NAMES OF THE MODELS IN THE COUPLED MODEL
// {}, // LIST OF EIC SEPAREATED BY ,
// {{input_test_generator, Subnet1}}, // LIST IC DIFINED AS {inputmodel, outputmodel} AND SEPARATED BY COMMAS
// {Subnet1}// LIST OF EOC
// ));
// shared_ptr<flattened_coupled<Time, Message>> TOP(new flattened_coupled<Time, Message>(
// {NET, PersonD, Person C}, // NAMES OF THE MODELS IN THE COUPLED MODEL
// {}, // LIST OF EIC SEPAREATED BY ,
// {{PersonD, NET}, {NET, PersonC}}, // LIST IC DIFINED AS {inputmodel, outputmodel} AND SEPARATED BY COMMAS
// {PersonD, Person C}// LIST OF EOC
// ));
cout << "Preparing runner" << endl;
Time initial_time = Time(0);
ofstream out_data("atomic_test_output.txt"); // atomic_test_output.txt IS THE NAME OF THE OUTPUT FILE WHERE YOU WANT TO STORE THE OUTPUT
runner<Time, Message> r(TOP, initial_time, out_data, [](ostream& os, Message m){ os << m;});
// IF YOUR TOP MODEL NAME IS NOT "TOP", CHANGE "TOP" BY YOUR TOP MODEL NAME
Time end_time = Time(1000000); //FINISHING TIME OF THE SIMULATION. CHANGE 1000000 TO THE AMOUNT YOU WANT.
cout << "Starting simulation until time: " << end_time << "seconds" << endl;
auto start = hclock::now();
end_time = r.runUntil(end_time);
auto elapsed = chrono::duration_cast<std::chrono::duration<double, std::ratio<1>>> (hclock::now() - start).count();
cout << "Finished simulation with time: " << end_time << "sec" << endl;
cout << "Simulation took: " << elapsed << "sec" << endl;
return 0;
}
|
2fa5162e79c8855177097d39f5ef300026c5cf28
|
accc51aa636d7b22bd3fa6d815235a212691e68d
|
/GEditor1_4/view/workbox.h
|
f5c46ba467989ac4b3f90aa5b2453860ec0001d1
|
[] |
no_license
|
fant12/geditor
|
cabb36d79745f5e4510ca73c81b296e344ce7073
|
ba9de9875a824078cb50cd92ec7cee9d5a58f5fc
|
refs/heads/master
| 2021-01-23T15:51:58.920093
| 2014-05-08T11:37:11
| 2014-05-08T11:37:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,242
|
h
|
workbox.h
|
#ifndef WORKBOX_H
#define WORKBOX_H
#include "../control/manager.h"
#include "elist.h"
#include "oinspector.h"
#include "scripteditor.h"
#include <QTableWidget>
#include <QTabWidget>
class CanvasView;
// class --------------------------------------------------------------------------------
//! WorkBox class.
/*!
* \brief The WorkBox class is the widget with canvas element, script editor,
* attribute list and plain widget.
*/
class WorkBox : public QWidget {
Q_OBJECT
// --------------------------------------------------------------------------------
public:
/*!
* \brief The default constructor.
* \param parent the parent widget
*/
explicit WorkBox(QWidget *parent = 0);
// --------------------------------------------------------------------------------
public slots:
/*!
* \brief Adds new plain entries.
*/
void addObject();
/*!
* \brief Removes a selected plain entry.
*/
void removeObject();
/*!
* \brief Shows the context menu.
* \param pos the mouse pointer that describes the position,
* where user has clicked.
*/
void showContextMenu(const QPoint &pos);
// --------------------------------------------------------------------------------
private:
/*!
* \brief Initializes the main tool widget with script editor
* and graphics scene.
*/
void initMainToolWindow();
/*!
* \brief Initializes the side tool widgets.
*/
void initSideToolWindow();
// --------------------------------------------------------------------------------
private:
/*!< The attribute widget. */
OInspector *_attributeWindow;
/*!< The main tool widget. */
QTabWidget *_mainToolWindow;
/*!< The side tool widget. */
QTabWidget *_sideToolWindow;
/*!< The script editor widget. */
GETSET(ScriptEditor*, editor, Editor)
/*!< The EList. */
GETSET(EList*, objectsTab, ObjectsTab)
/*!< The Canvas view. */
GETSET(CanvasView*, view, View)
};
#endif // WORKBOX_H
|
25b22d1875a718fc4fc96aeb6ab310029d0bf7e8
|
a2759cfbcac2d63bbe14868a6df975f672232701
|
/key.cpp
|
0f39e0bece457e37079d1788a81902eb636644d7
|
[] |
no_license
|
umiyo/zlcross
|
999528c04ce14683e2b65e061f1f5c0df820a9ae
|
f21279d780c1fad114626b1ebdce98e886f2ee39
|
refs/heads/master
| 2020-06-16T21:57:51.791948
| 2015-07-25T00:40:17
| 2015-07-25T00:40:17
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 12,626
|
cpp
|
key.cpp
|
#include "key.h"
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include "3des.h"
#include <iostream>
#include <string>
using namespace std;
BYTE szSystemInfo[1024] = {0}; // 在程序执行完毕后,此处存储取得的系统特征码
UINT uSystemInfoLen = 0; // 在程序执行完毕后,此处存储取得的系统特征码的长度
// 以下是其中用到的某些结构及函数的定义:
#define FILE_DEVICE_SCSI 0x0000001b
#define IOCTL_SCSI_MINIPORT_IDENTIFY ( ( FILE_DEVICE_SCSI << 16 ) + 0x0501 )
#define IOCTL_SCSI_MINIPORT 0x0004D008 // see NTDDSCSI.H for definition
#define IDENTIFY_BUFFER_SIZE 512
#define SENDIDLENGTH ( sizeof( SENDCMDOUTPARAMS ) + IDENTIFY_BUFFER_SIZE )
#define IDE_ATAPI_IDENTIFY 0xA1 // Returns ID sector for ATAPI.
#define IDE_ATA_IDENTIFY 0xEC // Returns ID sector for ATA.
#define DFP_RECEIVE_DRIVE_DATA 0x0007c088
typedef struct _IDSECTOR
{
USHORT wGenConfig;
USHORT wNumCyls;
USHORT wReserved;
USHORT wNumHeads;
USHORT wBytesPerTrack;
USHORT wBytesPerSector;
USHORT wSectorsPerTrack;
USHORT wVendorUnique[3];
CHAR sSerialNumber[20];
USHORT wBufferType;
USHORT wBufferSize;
USHORT wECCSize;
CHAR sFirmwareRev[8];
CHAR sModelNumber[40];
USHORT wMoreVendorUnique;
USHORT wDoubleWordIO;
USHORT wCapabilities;
USHORT wReserved1;
USHORT wPIOTiming;
USHORT wDMATiming;
USHORT wBS;
USHORT wNumCurrentCyls;
USHORT wNumCurrentHeads;
USHORT wNumCurrentSectorsPerTrack;
ULONG ulCurrentSectorCapacity;
USHORT wMultSectorStuff;
ULONG ulTotalAddressableSectors;
USHORT wSingleWordDMA;
USHORT wMultiWordDMA;
BYTE bReserved[128];
} IDSECTOR, *PIDSECTOR;
typedef struct _DRIVERSTATUS
{
BYTE bDriverError; // Error code from driver, or 0 if no error.
BYTE bIDEStatus; // Contents of IDE Error register.
// Only valid when bDriverError is SMART_IDE_ERROR.
BYTE bReserved[2]; // Reserved for future expansion.
DWORD dwReserved[2]; // Reserved for future expansion.
} DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
typedef struct _SENDCMDOUTPARAMS
{
DWORD cBufferSize; // Size of bBuffer in bytes
DRIVERSTATUS DriverStatus; // Driver status structure.
BYTE bBuffer[1]; // Buffer of arbitrary length in which to store the data read from the // drive.
} SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
typedef struct _SRB_IO_CONTROL
{
ULONG HeaderLength;
UCHAR Signature[8];
ULONG Timeout;
ULONG ControlCode;
ULONG ReturnCode;
ULONG Length;
} SRB_IO_CONTROL, *PSRB_IO_CONTROL;
typedef struct _IDEREGS
{
BYTE bFeaturesReg; // Used for specifying SMART "commands".
BYTE bSectorCountReg; // IDE sector count register
BYTE bSectorNumberReg; // IDE sector number register
BYTE bCylLowReg; // IDE low order cylinder value
BYTE bCylHighReg; // IDE high order cylinder value
BYTE bDriveHeadReg; // IDE drive/head register
BYTE bCommandReg; // Actual IDE command.
BYTE bReserved; // reserved for future use. Must be zero.
} IDEREGS, *PIDEREGS, *LPIDEREGS;
typedef struct _SENDCMDINPARAMS
{
DWORD cBufferSize; // Buffer size in bytes
IDEREGS irDriveRegs; // Structure with drive register values.
BYTE bDriveNumber; // Physical drive number to send
// command to (0,1,2,3).
BYTE bReserved[3]; // Reserved for future expansion.
DWORD dwReserved[4]; // For future use.
BYTE bBuffer[1]; // Input buffer.
} SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
typedef struct _GETVERSIONOUTPARAMS
{
BYTE bVersion; // Binary driver version.
BYTE bRevision; // Binary driver revision.
BYTE bReserved; // Not used.
BYTE bIDEDeviceMap; // Bit map of IDE devices.
DWORD fCapabilities; // Bit mask of driver capabilities.
DWORD dwReserved[4]; // For future use.
} GETVERSIONOUTPARAMS, *PGETVERSIONOUTPARAMS, *LPGETVERSIONOUTPARAMS;
//////////////////////////////////////////////////////////////////////
//结构定义
typedef struct _UNICODE_STRING
{
USHORT Length;//长度
USHORT MaximumLength;//最大长度
PWSTR Buffer;//缓存指针
} UNICODE_STRING,*PUNICODE_STRING;
typedef struct _OBJECT_ATTRIBUTES
{
ULONG Length;//长度 18h
HANDLE RootDirectory;// 00000000
PUNICODE_STRING ObjectName;//指向对象名的指针
ULONG Attributes;//对象属性00000040h
PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR,0
PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE,0
} OBJECT_ATTRIBUTES;
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
//函数指针变量类型
typedef DWORD (__stdcall *ZWOS )( PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
typedef DWORD (__stdcall *ZWMV )( HANDLE,HANDLE,PVOID,ULONG,ULONG,PLARGE_INTEGER,PSIZE_T,DWORD,ULONG,ULONG);
typedef DWORD (__stdcall *ZWUMV )( HANDLE,PVOID);
BOOL WinNTHDSerialNumAsScsiRead( BYTE* dwSerial, UINT* puSerialLen, UINT uMaxSerialLen )
{
BOOL bInfoLoaded = FALSE;
for( int iController = 0; iController < 2; ++ iController )
{
HANDLE hScsiDriveIOCTL = 0;
char szDriveName[256];
// Try to get a handle to PhysicalDrive IOCTL, report failure
// and exit if can't.
sprintf( szDriveName, "\\\\.\\Scsi%d:", iController );
// Windows NT, Windows 2000, any rights should do
hScsiDriveIOCTL = CreateFile( szDriveName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);
// if (hScsiDriveIOCTL == INVALID_HANDLE_VALUE)
// printf ("Unable to open SCSI controller %d, error code: 0x%lX\n",
// controller, GetLastError ());
if( hScsiDriveIOCTL != INVALID_HANDLE_VALUE )
{
int iDrive = 0;
for( iDrive = 0; iDrive < 2; ++ iDrive )
{
char szBuffer[sizeof( SRB_IO_CONTROL ) + SENDIDLENGTH] = { 0 };
SRB_IO_CONTROL* p = ( SRB_IO_CONTROL* )szBuffer;
SENDCMDINPARAMS* pin = ( SENDCMDINPARAMS* )( szBuffer + sizeof( SRB_IO_CONTROL ) );
DWORD dwResult;
p->HeaderLength = sizeof( SRB_IO_CONTROL );
p->Timeout = 10000;
p->Length = SENDIDLENGTH;
p->ControlCode = IOCTL_SCSI_MINIPORT_IDENTIFY;
strncpy( ( char* )p->Signature, "SCSIDISK", 8 );
pin->irDriveRegs.bCommandReg = IDE_ATA_IDENTIFY;
pin->bDriveNumber = iDrive;
if( DeviceIoControl( hScsiDriveIOCTL, IOCTL_SCSI_MINIPORT,
szBuffer,
sizeof( SRB_IO_CONTROL ) + sizeof( SENDCMDINPARAMS ) - 1,
szBuffer,
sizeof( SRB_IO_CONTROL ) + SENDIDLENGTH,
&dwResult, NULL ) )
{
SENDCMDOUTPARAMS* pOut = ( SENDCMDOUTPARAMS* )( szBuffer + sizeof( SRB_IO_CONTROL ) );
IDSECTOR* pId = ( IDSECTOR* )( pOut->bBuffer );
if( pId->sModelNumber[0] )
{
if( * puSerialLen + 20U <= uMaxSerialLen )
{
// 序列号
CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )pId ) + 10, 20 );
// Cut off the trailing blanks
for( UINT i = 20; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i )
{}
* puSerialLen += i;
// 型号
CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )pId ) + 27, 40 );
// Cut off the trailing blanks
for( i = 40; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i )
{}
* puSerialLen += i;
bInfoLoaded = TRUE;
}
else
{
::CloseHandle( hScsiDriveIOCTL );
return bInfoLoaded;
}
}
}
}
::CloseHandle( hScsiDriveIOCTL );
}
}
return bInfoLoaded;
}
BOOL DoIdentify( HANDLE hPhysicalDriveIOCTL, PSENDCMDINPARAMS pSCIP,
PSENDCMDOUTPARAMS pSCOP, BYTE bIDCmd, BYTE bDriveNum,
PDWORD lpcbBytesReturned )
{
// Set up data structures for IDENTIFY command.
pSCIP->cBufferSize = IDENTIFY_BUFFER_SIZE;
pSCIP->irDriveRegs.bFeaturesReg = 0;
pSCIP->irDriveRegs.bSectorCountReg = 1;
pSCIP->irDriveRegs.bSectorNumberReg = 1;
pSCIP->irDriveRegs.bCylLowReg = 0;
pSCIP->irDriveRegs.bCylHighReg = 0;
// calc the drive number.
pSCIP->irDriveRegs.bDriveHeadReg = 0xA0 | ( ( bDriveNum & 1 ) << 4 );
// The command can either be IDE identify or ATAPI identify.
pSCIP->irDriveRegs.bCommandReg = bIDCmd;
pSCIP->bDriveNumber = bDriveNum;
pSCIP->cBufferSize = IDENTIFY_BUFFER_SIZE;
return DeviceIoControl( hPhysicalDriveIOCTL, DFP_RECEIVE_DRIVE_DATA,
( LPVOID ) pSCIP,
sizeof( SENDCMDINPARAMS ) - 1,
( LPVOID ) pSCOP,
sizeof( SENDCMDOUTPARAMS ) + IDENTIFY_BUFFER_SIZE - 1,
lpcbBytesReturned, NULL );
}
BOOL WinNTHDSerialNumAsPhysicalRead( BYTE* dwSerial, UINT* puSerialLen, UINT uMaxSerialLen )
{
#define DFP_GET_VERSION 0x00074080
BOOL bInfoLoaded = FALSE;
for( UINT uDrive = 0; uDrive < 4; ++ uDrive )
{
HANDLE hPhysicalDriveIOCTL = 0;
// Try to get a handle to PhysicalDrive IOCTL, report failure
// and exit if can't.
char szDriveName [256];
sprintf( szDriveName, "\\\\.\\PhysicalDrive%d", uDrive );
// Windows NT, Windows 2000, must have admin rights
hPhysicalDriveIOCTL = CreateFile( szDriveName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);
if( hPhysicalDriveIOCTL != INVALID_HANDLE_VALUE )
{
GETVERSIONOUTPARAMS VersionParams = { 0 };
DWORD cbBytesReturned = 0;
// Get the version, etc of PhysicalDrive IOCTL
if( DeviceIoControl( hPhysicalDriveIOCTL, DFP_GET_VERSION,
NULL,
0,
&VersionParams,
sizeof( GETVERSIONOUTPARAMS ),
&cbBytesReturned, NULL ) )
{
// If there is a IDE device at number "i" issue commands
// to the device
if( VersionParams.bIDEDeviceMap != 0 )
{
BYTE bIDCmd = 0; // IDE or ATAPI IDENTIFY cmd
SENDCMDINPARAMS scip = { 0 };
// Now, get the ID sector for all IDE devices in the system.
// If the device is ATAPI use the IDE_ATAPI_IDENTIFY command,
// otherwise use the IDE_ATA_IDENTIFY command
bIDCmd = ( VersionParams.bIDEDeviceMap >> uDrive & 0x10 ) ? IDE_ATAPI_IDENTIFY : IDE_ATA_IDENTIFY;
BYTE IdOutCmd[sizeof( SENDCMDOUTPARAMS ) + IDENTIFY_BUFFER_SIZE - 1] = { 0 };
if( DoIdentify( hPhysicalDriveIOCTL,
&scip,
( PSENDCMDOUTPARAMS )&IdOutCmd,
( BYTE )bIDCmd,
( BYTE )uDrive,
&cbBytesReturned ) )
{
if( * puSerialLen + 20U <= uMaxSerialLen )
{
CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )( ( ( PSENDCMDOUTPARAMS )IdOutCmd )->bBuffer ) ) + 10, 20 ); // 序列号
// Cut off the trailing blanks
for( UINT i = 20; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i ) {}
* puSerialLen += i;
CopyMemory( dwSerial + * puSerialLen, ( ( USHORT* )( ( ( PSENDCMDOUTPARAMS )IdOutCmd )->bBuffer ) ) + 27, 40 ); // 型号
// Cut off the trailing blanks
for( i = 40; i != 0U && ' ' == dwSerial[* puSerialLen + i - 1]; -- i ) {}
* puSerialLen += i;
bInfoLoaded = TRUE;
}
else
{
::CloseHandle( hPhysicalDriveIOCTL );
return bInfoLoaded;
}
}
}
}
CloseHandle( hPhysicalDriveIOCTL );
}
}
return bInfoLoaded;
}
// 硬盘序列号,注意:有的硬盘没有序列号
BOOL GetDriveID()
{
OSVERSIONINFO ovi = { 0 };
ovi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( &ovi ); // 获取当前系统的运行信息
if( ovi.dwPlatformId != VER_PLATFORM_WIN32_NT )
{
// Only Windows 2000, Windows XP, Windows Server 2003...
return FALSE;
}
else
{
if( !WinNTHDSerialNumAsPhysicalRead( szSystemInfo, &uSystemInfoLen, 1024 ) )
{
WinNTHDSerialNumAsScsiRead( szSystemInfo, &uSystemInfoLen, 1024 );
}
return TRUE;
}
}
string regkey;
void GetRegKey()
{
unsigned char *keys = szSystemInfo;
while (*keys)
{
char number[16] = {0};
sprintf(number, "%d", int(*keys));
regkey.append(number);
++keys;
}
}
void ShowRegKey()
{
printf("本软件未经过注册,请与作者联系,并把以下数字提供给作者:\n");
printf("%s\n", regkey.c_str());
printf("\n现在进入试用版模式\n\n");
}
bool IsReg()
{
if (GetDriveID())
{
GetRegKey();
FILE *pFile = NULL;
if ((pFile = fopen("license.dat","r")) != NULL)
{
unsigned char keydata[1024] = {0};
unsigned char regkeydata[1024] = {0};
memcpy(regkeydata, regkey.c_str(), regkey.size());
if (fread(keydata, 1024, 1, pFile) != NULL)
{
UTlDes::Encrypt(regkeydata, 1024);
if (memcmp(keydata, regkeydata, 1024) == 0)
{
return true;
}
}
}
}
ShowRegKey();
return false;
}
|
7bf145078df31c08b5eebaf62ea2a2252cfdca92
|
0ad0e201676e9f884cf0cf3a940833de8a35f6ab
|
/UVa/12485 - Perfect Choir.cpp
|
0057f67136d0b11632ba058c73eed10815a1c59f
|
[] |
no_license
|
MNTahhan/Competitive-Programming
|
e0e7b8a480b916d2c85798727c2a98b3003fd23f
|
dee74dc632b0fc18fb258519333b8cdfd3ca4e8c
|
refs/heads/master
| 2021-10-28T05:16:33.689584
| 2019-04-22T09:41:42
| 2019-04-22T09:41:42
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,293
|
cpp
|
12485 - Perfect Choir.cpp
|
/*
The idea: we add 1 in one index and subtract 1 from another one, so the sum of all numbers does not differ in the final solution.
so the number that all numbers must be equal to is sum/n, if sum%n != 0 then there is no solution.
*/
#include <iostream>
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
#if !ONLINE_JUDGE
#include "inc.h"
#endif
using namespace std;
typedef long long ll;
int n;
int main() {
#if !ONLINE_JUDGE
freopen("a.txt", "r", stdin);
freopen("b.txt", "w", stdout);
decTime;
#endif
while (scanf("%d", &n) > 0) {
vector<int>v(n);
int sum = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &v[i]);
sum += v[i];
}
if (sum%n) {
puts("-1");
continue;
}
sum /= n;
int ans = 1;
for (int i = 0; i < n; ++i)
ans += max(0, v[i] - sum);
printf("%d\n", ans);
}
#if !ONLINE_JUDGE
printTime;
#endif
return 0;
}
|
4594430c4fe920655d4796f66c29384c52bf3e7d
|
569d64661f9e6557022cc45428b89eefad9a6984
|
/code/centerserver/pay_job.h
|
75cbe2abaa2a23b22b9f8a5e82076c8cdc702010
|
[] |
no_license
|
dgkang/ROG
|
a2a3c8233c903fa416df81a8261aab2d8d9ac449
|
115d8d952a32cca7fb7ff01b63939769b7bfb984
|
refs/heads/master
| 2020-05-25T02:44:44.555599
| 2019-05-20T08:33:51
| 2019-05-20T08:33:51
| 187,584,950
| 0
| 1
| null | 2019-05-20T06:59:06
| 2019-05-20T06:59:05
| null |
UTF-8
|
C++
| false
| false
| 1,434
|
h
|
pay_job.h
|
#ifndef pay_job_h__
#define pay_job_h__
class DBExecutor;
class DBRecorder;
class Player;
class PayJob
{
public:
PayJob() { m_dbExecutor = 0; };
~PayJob() {};
DECLARE_SINGLETON(PayJob)
// 设置SQL执行
void SetDBExecutor(DBExecutor* val) {m_dbExecutor = val;}
void InsertPayOrder(PAY_ORDER_INFO& payOrde); // 插入充值订单信息
void GetTotalRechargeByPlayerId(uint64 playerId); // 获取玩家总共的充值数
void GetDailyRechargeByPlayerId(uint64 playerId); // 获取玩家今天的充值数
void ReloadRechargeInfo(uint64 playerID); ///< 重新加载充值信息
private:
PayJob( const PayJob& );
PayJob& operator=( const PayJob& );
PayJob* operator&();
const PayJob* operator&() const;
void UpdatePlayerMoneyPoint(PAY_ORDER_INFO& payOrder); // 更新角色魔石数量
void CBInsertPayOrder(DBRecorder& res, PAY_ORDER_INFO payOrder);
void CBUpdatePlayerMoneyPoint(DBRecorder& res, PAY_ORDER_INFO payOrder);
void CBGetTotalRechargeByPlayerId(DBRecorder& res, uint64 playerId); // 获取玩家总共的充值数回调
void CBGetDailyRechargeByPlayerId(DBRecorder& res, uint64 playerId); // 获取玩家今天的充值数回调
void CBReloadRechargeInfo(DBRecorder& res, uint64 playerID); ///< 获得充值信息
DBExecutor* m_dbExecutor;
};
#endif // pay_job_h__
|
1fc0a52d127c4d2555328af24ce718c3af089367
|
a696549255433a0d499d7c5dda18d3128ab66055
|
/src/unittest/clustering_raft.cc
|
18a08458bc5cef67cc2aaa3c8d8c41786cbaad90
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
dk-dev/rethinkdb
|
90cdfdff672a2693842f779d21d60d87c290a39d
|
bb4f5cc28242dc1e29e9a46a8a931ec54420070c
|
refs/heads/next
| 2022-03-14T15:43:50.758116
| 2021-11-30T02:49:09
| 2022-02-20T22:47:44
| 12,976,019
| 0
| 0
|
Apache-2.0
| 2022-02-21T01:10:42
| 2013-09-20T14:50:36
|
C++
|
UTF-8
|
C++
| false
| false
| 5,698
|
cc
|
clustering_raft.cc
|
// Copyright 2010-2015 RethinkDB, all rights reserved.
#include "unittest/gtest.hpp"
#include "clustering/administration/metadata.hpp"
#include "clustering/generic/raft_core.hpp"
#include "clustering/generic/raft_core.tcc"
#include "clustering/generic/raft_network.hpp"
#include "clustering/generic/raft_network.tcc"
#include "unittest/clustering_utils.hpp"
#include "unittest/clustering_utils_raft.hpp"
#include "unittest/dummy_metadata_controller.hpp"
#include "unittest/unittest_utils.hpp"
namespace unittest {
TPTEST(ClusteringRaft, Basic) {
/* Spin up a Raft cluster and wait for it to elect a leader */
dummy_raft_cluster_t cluster(5, dummy_raft_state_t(), nullptr);
/* Do some writes and check the result */
do_writes_raft(&cluster, 100, 60000);
}
void failover_test(dummy_raft_cluster_t::live_t failure_type) {
std::vector<raft_member_id_t> member_ids;
dummy_raft_cluster_t cluster(5, dummy_raft_state_t(), &member_ids);
dummy_raft_traffic_generator_t traffic_generator(&cluster, 3);
do_writes_raft(&cluster, 100, 60000);
cluster.set_live(member_ids[0], failure_type);
cluster.set_live(member_ids[1], failure_type);
do_writes_raft(&cluster, 100, 60000);
cluster.set_live(member_ids[2], failure_type);
cluster.set_live(member_ids[3], failure_type);
cluster.set_live(member_ids[0], dummy_raft_cluster_t::live_t::alive);
cluster.set_live(member_ids[1], dummy_raft_cluster_t::live_t::alive);
do_writes_raft(&cluster, 100, 60000);
cluster.set_live(member_ids[4], failure_type);
cluster.set_live(member_ids[2], dummy_raft_cluster_t::live_t::alive);
cluster.set_live(member_ids[3], dummy_raft_cluster_t::live_t::alive);
do_writes_raft(&cluster, 100, 60000);
ASSERT_LT(100, traffic_generator.get_num_changes());
traffic_generator.check_changes_present();
}
TPTEST(ClusteringRaft, Failover) {
failover_test(dummy_raft_cluster_t::live_t::dead);
}
TPTEST(ClusteringRaft, FailoverIsolated) {
failover_test(dummy_raft_cluster_t::live_t::isolated);
}
TPTEST(ClusteringRaft, MemberChange) {
std::vector<raft_member_id_t> member_ids;
size_t cluster_size = 5;
dummy_raft_cluster_t cluster(cluster_size, dummy_raft_state_t(), &member_ids);
dummy_raft_traffic_generator_t traffic_generator(&cluster, 3);
for (size_t i = 0; i < 10; ++i) {
/* Do some test writes */
do_writes_raft(&cluster, 10, 60000);
/* Kill one member and do some more test writes */
cluster.set_live(member_ids[i], dummy_raft_cluster_t::live_t::dead);
do_writes_raft(&cluster, 10, 60000);
/* Add a replacement member and do some more test writes */
member_ids.push_back(cluster.join());
do_writes_raft(&cluster, 10, 60000);
/* Update the configuration and do some more test writes */
raft_config_t new_config;
for (size_t n = i+1; n < i+1+cluster_size; ++n) {
new_config.voting_members.insert(member_ids[n]);
}
signal_timer_t timeout;
timeout.start(10000);
raft_member_id_t leader = cluster.find_leader(&timeout);
cluster.try_config_change(leader, new_config, &timeout);
do_writes_raft(&cluster, 10, 60000);
}
ASSERT_LT(100, traffic_generator.get_num_changes());
traffic_generator.check_changes_present();
}
TPTEST(ClusteringRaft, NonVoting) {
dummy_raft_cluster_t cluster(1, dummy_raft_state_t(), nullptr);
dummy_raft_traffic_generator_t traffic_generator(&cluster, 3);
do_writes_raft(&cluster, 10, 60000);
raft_config_t new_config;
new_config.voting_members.insert(cluster.find_leader(1000));
new_config.voting_members.insert(cluster.join());
new_config.voting_members.insert(cluster.join());
new_config.non_voting_members.insert(cluster.join());
new_config.non_voting_members.insert(cluster.join());
new_config.non_voting_members.insert(cluster.join());
signal_timer_t timeout;
timeout.start(10000);
raft_member_id_t leader = cluster.find_leader(&timeout);
cluster.try_config_change(leader, new_config, &timeout);
do_writes_raft(&cluster, 10, 60000);
for (const raft_member_id_t &member : new_config.non_voting_members) {
cluster.set_live(member, dummy_raft_cluster_t::live_t::dead);
}
do_writes_raft(&cluster, 10, 60000);
traffic_generator.check_changes_present();
}
TPTEST(ClusteringRaft, Regression4234) {
cond_t non_interruptor;
std::vector<raft_member_id_t> member_ids;
dummy_raft_cluster_t cluster(2, dummy_raft_state_t(), &member_ids);
dummy_raft_traffic_generator_t traffic_generator(&cluster, 3);
do_writes_raft(&cluster, 10, 60000);
raft_member_id_t leader = cluster.find_leader(1000);
raft_config_t new_config;
for (const raft_member_id_t &member : member_ids) {
if (member != leader) {
new_config.voting_members.insert(member);
}
}
cluster.run_on_member(leader,
[&](dummy_raft_member_t *member, signal_t *) {
guarantee(member != nullptr);
raft_member_t<dummy_raft_state_t>::change_lock_t change_lock(
member, &non_interruptor);
auto tok = member->propose_config_change(&change_lock, new_config);
guarantee(tok.has());
});
/* This test is probabilistic. When the bug was present, the test failed about
20% of the time. */
nap(randint(30), &non_interruptor);
cluster.set_live(leader, dummy_raft_cluster_t::live_t::dead);
cluster.set_live(leader, dummy_raft_cluster_t::live_t::alive);
do_writes_raft(&cluster, 10, 60000);
traffic_generator.check_changes_present();
}
} /* namespace unittest */
|
85c76287ecd2ec3b809b3407407706da48a56161
|
4479ee95d2565839bf4034ec606cda5a2ae6c841
|
/portfolio_object.h
|
c8d7129d984dffccc79efea46e3ce7a5b8a12a1b
|
[] |
no_license
|
sh4y/CppFinance
|
a3e5263bddc507edc58a456ba9b23e56f184712a
|
d1e53ed93355054ae6ddf684de5e0f0f29b5cc0b
|
refs/heads/master
| 2020-08-01T02:30:44.524800
| 2019-10-10T08:44:47
| 2019-10-10T08:44:47
| 210,828,433
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,242
|
h
|
portfolio_object.h
|
#pragma once
#include "stock_object.h"
struct PortfolioObject {
private:
double purchasePrice{};
string purchaseDate;
public:
StockObject stock;
double quantity;
string getPurchaseDate() {
return purchaseDate;
}
double getHoldingValueAtDate(string _date) {
auto data = stock.getDataPointAtDate(_date);
double closingPrice = data[3];
return closingPrice * quantity;
}
double getPurchaseValue() {
return purchasePrice * quantity;
}
double AnnualParkinsonVolatility() {
int numDays = stock.Date.size();
double innerSum = 0;
for (int i = 0; i < numDays; i++) {
innerSum += pow(log(stock.High.data[i] / stock.Low.data[i]),2);
}
return sqrt(252) * (innerSum / (4 * numDays * log(2)));
}
/* Constructors */
PortfolioObject(): purchasePrice(0), quantity(0)
{
}
PortfolioObject(StockObject _stock, double _quantity, string _date) {
purchaseDate = _date;
purchasePrice = _stock.getDataPointAtDate(_date)[3];
stock = _stock;
quantity = _quantity;
}
};
struct Portfolio {
private:
vector<double> getPortfolioWeights(string date) {
//string _date = "2017-06-06";
double pfValue = getPortfolioValueAtDate(date);
vector <double> weights;
for (int i = 0; i < holdings.size(); i++) {
auto holdingValue = holdings[i].getHoldingValueAtDate(date);
auto weight = holdingValue / pfValue;
weights.push_back(weight);
}
return weights;
}
public:
vector<PortfolioObject> holdings{};
void AddHolding(PortfolioObject h) {
holdings.push_back(h);
}
double getPortfolioValueAtDate(string _date) {
if (holdings.empty())
return 0.0;
double result = 0;
for (int i = 0; i < holdings.size(); i++) {
result += holdings[i].getHoldingValueAtDate(_date);
}
return result;
}
double getPortfolioReturnsAtDate(string endDate) {
auto weights = getPortfolioWeights(endDate);
double finalReturn = 0;
double pfoReturn, weightedReturn;
for (int i = 0; i < holdings.size(); i++) {
auto purchaseDate = holdings[i].getPurchaseDate();
pfoReturn = holdings[i].stock.Close.CumulativeReturn(purchaseDate, endDate);
weightedReturn = pfoReturn * weights[i];
finalReturn += weightedReturn;
}
return finalReturn;
}
/* Constructors */
Portfolio() {
}
};
|
48c417b48b0b4f5c43452e93fbe5dcecf5657d81
|
b15e8da364aabd9bf4b2c5dd0a69b47cbc1ecf6d
|
/Semester 3/OOP345/WS06/part 1/Car.cpp
|
555dbfbe22e8505d7579e37bcb93d9c385f0f9b3
|
[] |
no_license
|
JiaHua-Zou/Seneca-College
|
9eb03a6746bc69bd4e289cc29be44e9589fab2b4
|
92a02250ed794b4c66970adb2cb56aee94619f83
|
refs/heads/master
| 2023-02-13T01:47:17.622191
| 2021-01-17T18:32:50
| 2021-01-17T18:32:50
| 327,096,849
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,444
|
cpp
|
Car.cpp
|
#include "Car.h"
namespace sdds {
Car::~Car() {}
Car::Car() {}
Car::Car(std::istream& input) {
auto trim = [](std::string& word) {
size_t start = word.find_first_not_of(" ");
word = (start == std::string::npos) ? "" : word.substr(start);
size_t end = word.find_last_not_of(" ");
word = (end == std::string::npos) ? "" : word.substr(0, end + 1);
};
std::string strCar{ '\0' };
std::getline(input, strCar);
strCar.erase(0, strCar.find(',') + 1);
this->m_maker = strCar.substr(0, strCar.find(','));
strCar.erase(0, strCar.find(',') + 1);
trim(m_maker);
//need to change it to words
this->condi = strCar.substr(0, strCar.find(','));
strCar.erase(0, strCar.find(',') + 1);
trim(condi);
if (condi == "n")
{
condi = "new";
}
else if (condi == "u")
{
condi = "used";
}
else if (condi == "b")
{
condi = "broken";
}
std::string temp = strCar.substr(0, strCar.find(','));
strCar.erase(0, strCar.find(',') + 1);
trim(temp);
this->m_topSpeed = std::stod(temp);
}
std::string Car::condition() const {
return condi;
}
double Car::topSpeed() const {
return m_topSpeed;
}
void Car::display(std::ostream& out) const {
out << std::right << "| " << std::setw(10) << m_maker << " | ";
out << std::left << std::setw(6) << condi << " | ";
out << std::setw(6) << std::fixed << std::setprecision(2) << m_topSpeed << " |" << std::endl;
}
}
|
b3bc902e351f41b3e5f48947daca9d4317f9e43e
|
591c7ae29867d43a28e4671bcd4469ec0c6fe15b
|
/Prog I/Lista de Vetor e Matriz/Vetor/Vetor 10.cpp
|
d8b0e159859d414cbdb72682610bcdcd54bfc54e
|
[] |
no_license
|
jessikareis/Programas_da_faculdade
|
a7fc9a2cd0f343d4ce49da5127d3752484f89edc
|
0cb1a5b500bd8fec212a0fff3dcc71d03f70da4b
|
refs/heads/main
| 2023-03-17T04:21:51.728072
| 2021-03-12T22:19:42
| 2021-03-12T22:19:42
| 347,209,588
| 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 843
|
cpp
|
Vetor 10.cpp
|
/*Vetor
10) Informar 3 nomes. Mostrar quantas letras "A" e "E", possuem
Jéssika Reis de Mello*/
#include<stdio.h>
#include<string.h>
#include<locale.h>
#define quantidade 3
main()
{
int x, y, tam, a=0, w;
char nomes[quantidade][20];
setlocale(LC_ALL, "portuguese");
printf("Digite %i nomes.\n", quantidade);
for(x=1;x<=quantidade;x++)
{
printf("\nDigite %iº nome: ",x);
gets(nomes[x]);
}
printf("\nOs nomes são: ");
for(x=1;x<=quantidade;x++)
{
printf("%s", nomes[x]);
if(x==quantidade) printf(".");
else printf(", ");
}
for(x=0;x<=quantidade;x++)
{
tam=strlen(nomes[x]);
for(y=0;y<tam;y++)
{
if(nomes[x][y]=='a' || nomes[x][y]=='A') a++;
if(nomes[x][y]=='e' || nomes[x][y]=='E') w++;
}
}
printf("\nA quantidade de letras 'a': %i.", a);
printf("\nA quantidade de letras 'e': %i.", w);
}
|
33abd7adce5adf9a4ee3b5e323aa8ca820b33408
|
2848652b1e41e6d752a86df5ddfcfd166eda5034
|
/Game/city.hh
|
4697b0feb4bfa98a803ad7efa6d01d0f6d2588a8
|
[] |
no_license
|
ctrl-elri/nyssemeni
|
852234accc3a5f54b18c0bcd734206ae00791ddd
|
2f3dd27b61e9ba45f7a5a1f35fb63e52f73c5573
|
refs/heads/main
| 2023-02-20T06:41:31.308395
| 2021-01-24T09:33:16
| 2021-01-24T09:33:16
| 332,409,030
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,190
|
hh
|
city.hh
|
#ifndef CITY_HH
#define CITY_HH
#include "interfaces/icity.hh"
#include "mainwindow.hh"
#include "interfaces/istop.hh"
#include "actors/stop.hh"
#include "actors/nysse.hh"
#include "actors/passenger.hh"
#include "gamestatistics.h"
#include <QTime>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <QObject>
#include <QtGlobal>
const int NYSSE_TYPE = 1000;
const int PASSENGER_TYPE = 400;
const int STOP_TYPE = 600;
/**
* @brief The City class Pelin kaupunki, suorittaa pelin tapahtumat.
*/
class City : public QObject, public Interface::ICity
{
Q_OBJECT
public:
City();
~City();
/**
* @brief setMainWindow Asettaa käyttöliittymän pääikkunan.
* @param window pääikkuna, luodaan tiedostossa creategame.cpp.
*/
void setMainWindow(MainWindow* window);
/**
* @brief addPlayer Lisää pelaajahahmon.
*/
void addPlayer();
/**
* @brief setDialog asettaa aloitusdialogin ja käynnistää sen.
* @param aloitusdialogi, joka luodaan tiedostossa creategame.cpp.
*/
void setDialog(Dialog* dialog);
// ICity interface
void setBackground(QImage &basicbackground, QImage &bigbackground);
void setClock(QTime clock);
void addStop(std::shared_ptr<Interface::IStop> stop);
void startGame();
void addActor(std::shared_ptr<Interface::IActor> newactor);
void removeActor(std::shared_ptr<Interface::IActor> actor);
void actorRemoved(std::shared_ptr<Interface::IActor> actor);
bool findActor(std::shared_ptr<Interface::IActor> actor) const;
void actorMoved(std::shared_ptr<Interface::IActor> actor);
std::vector<std::shared_ptr<Interface::IActor> > getNearbyActors(Interface::Location loc) const;
bool isGameOver() const;
public slots:
void setPlayers(int players);
void exitGame();
private:
QTime time_;
MainWindow *mainW_;
bool gameIsOver_ = true; // Onko peli loppunut
int amountOfPlayers_ = 1; // Pelaajien määrä
std::vector<std::shared_ptr<Interface::IActor> > actorsInGame_; // Pelissä olevat Actorit
std::vector<std::shared_ptr<Interface::IActor>> nysses_; // Pelin Nysset
};
#endif // CITY_HH
|
c45ba86ce3043601536fb593948aa06ad54b0d03
|
69ea183c1bb6fcea7e2a0cb4d9d5fff67c9cd143
|
/은경나머지공부/2503_숫자야구/은경.cpp
|
5fa2985997732d9f894d7d5de50c9c36dc04fc0d
|
[] |
no_license
|
moonps/ProblemSolving
|
fa2d0e1da998f8f2be7bd485bb035dacf5aa8ab9
|
b15c8fa0effe9b3d21cf13a90dba77940059c815
|
refs/heads/master
| 2020-06-14T16:32:15.284981
| 2019-10-19T15:18:19
| 2019-10-19T15:18:19
| 195,056,594
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,263
|
cpp
|
은경.cpp
|
#include<cstdio>
#include<cstring>
bool arr[1000];
int main(void) {
int t, cnt=0; scanf("%d", &t);
memset(arr, true, sizeof(arr));
for (int i = 123; i <= 999; i++) {
int x,y,z; int temp=i;
z=temp%10; temp/=10; y=temp%10; x=temp/10;
if (x == y || x == z || y == z || x==0 || y==0 || z==0) arr[i] = false;
}
for(int t1=0; t1<t; t1++) {
int n,s,b,x,y,z; scanf("%d %d %d", &n, &s, &b);
// x:백, y:십, z:일
z=n%10; n/=10; y=n%10; x=n/10;
for (int i = 123; i <= 999; i++) {
int xt,yt,zt; int temp=i,strike=0,ball=0;
zt=temp%10; temp/=10; yt=temp%10; xt=temp/10;
if (arr[i]){
if (z==zt) strike++;
if (y==yt) strike++;
if (x==xt) strike++;
if (z==yt) ball++;
if (z==xt) ball++;
if (y==xt) ball++;
if (y==zt) ball++;
if (x==yt) ball++;
if (x==zt) ball++;
if (strike != s || ball != b)
arr[i] = false;
}
}
}
for (int i = 123; i <= 999; i++) {
if (arr[i])
cnt++;
}
printf("%d", cnt);
return 0;
}
|
376dc9dd160f1e5ea9a55c6a369f3221b19d65e2
|
2e23a93ff9da471e9e61e34ab63ca77236f9186d
|
/RubyChar.cpp
|
06b6fb3f7223911588801c028f074cb31f4c4cb7
|
[] |
no_license
|
b17ee518/f3fcb5de86f31ecb32d3ca856a233670
|
047014f59b987ebacf569a2c1978f102cf8e7e54
|
647dc16beb866a914e3e8401c930c250ace92d47
|
refs/heads/master
| 2021-01-01T16:40:11.907827
| 2015-08-06T05:34:33
| 2015-08-06T05:34:33
| 39,623,054
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 340
|
cpp
|
RubyChar.cpp
|
#include "RubyChar.h"
RubyChar::RubyChar()
{
}
RubyChar::~RubyChar()
{
}
void RubyChar::setRuby(const QString& ruby, qint64 beginMS, qint64 endMS)
{
_ruby = ruby;
_beginMS = beginMS;
_endMS = endMS;
if (_endMS <= _beginMS)
{
_endMS = _beginMS + 1;
}
}
void RubyChar::setRenderSize(const QSizeF& size)
{
_renderSize = size;
}
|
7dd783071557c9221ba78c4ca32624be580639e2
|
e6ab37c80167386920e40ad8cf5231ce9b378c8f
|
/PS_Study/1211_data.cpp
|
0875279d44d1f73e080638af4d6820d3107af2f7
|
[] |
no_license
|
seotosps/ps
|
cc6da2b5ba8821328193b92901d38da01faf5d16
|
55db7f986fc6cff41790ce1f9c0af9cd398915d1
|
refs/heads/master
| 2021-01-10T04:16:41.470743
| 2015-11-10T08:18:03
| 2015-11-10T08:18:03
| 45,894,282
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,048
|
cpp
|
1211_data.cpp
|
#include<stdio.h>
long long a[101][3][101]= {0},n,temp,temp2;
int main() {
char str[10],cou=2;
while(cou<=10) {
sprintf(str,"data%02d.out",cou);
freopen(str,"w",stdout);
scanf("%lld",&n);
a[1][0][1]=1;
for(int i=2; i<=n; i++)
for(int j=1; j<=i; j++) {
temp=a[i-1][0][j-1]+a[i-1][0][j];
temp2=a[i-1][1][j-1]+a[i-1][1][j]+temp/10000000;
a[i][2][j]=a[i-1][2][j-1]+a[i-1][2][j]+temp2/10000000;
a[i][0][j]=temp%10000000;
a[i][1][j]=temp2%10000000;
}
for(int i=1; i<=n; i++) {
for(int j=1; j<=i; j++) {
if(a[i][2][j]!=0) {
printf("%lld%lld%lld ",a[i][2][j],a[i][1][j],a[i][0][j]);
} else if(a[i][1][j]!=0) {
printf("%lld%lld ",a[i][1][j],a[i][0][j]);
} else
printf("%lld ",a[i][0][j]);
}
printf("\n");
}
cou++;
}
return 0;
}
|
d9f803dc11b82ba2ee9c92b639efa0365c7ee84e
|
9ce881d429616c56e4bf682373473384a4fceceb
|
/Chambers_PLC_program_C18de/controlChambers.cpp
|
216e4ad578073b3aa7e8f01239eefe7289f52735
|
[] |
no_license
|
ingrafa23/CamarasPIDValencia
|
4ef624017698c9cfdae08cc3337af268614cf931
|
d55619fc8c8d580375fffd6a89fb7167f58d7cb0
|
refs/heads/master
| 2023-02-01T02:55:08.707629
| 2020-12-08T23:51:26
| 2020-12-08T23:51:26
| 317,021,339
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 27,158
|
cpp
|
controlChambers.cpp
|
#include "controlChambers.h"
#include "HoldingRegisterControl.h"
#include "variablesAlarm.h"
#include "variablestimer.h"
#include "InputOutputAssignments.h"
#include "miscellaneous.h"
#include "consoladebug.h"
unsigned long lastValueInputFan1;
unsigned long lastValueOutputFan1;
unsigned long lastValueInputFan2;
unsigned long lastValueOutputFan2;
bool flagTimerAlarmNoVentilationPointer;
unsigned int lastTimeGases = 0;
unsigned int TimeGases;
struct strHoldingRegisterControlEnable holdingRegisterControlEnable;
//Barrido
void Chamber::barrido(){
bool estadoActualBarridoHolderRegister = _modbusTCPServer->holdingRegisterReadBit(addressOffset + 0, 1);
if (estadoActualBarridoHolderRegister != estadoAnteriosBarridoHolderRegister)
{
if (estadoAnteriosBarridoHolderRegister)
{
ActivadorBarridoHolderRegister = 1;
}
if (estadoActualBarridoHolderRegister)
{
ActivadorBarridoHolderRegister = 0;
}
}
if (ActivadorBarridoHolderRegister)
{
if (_modbusTCPServer->holdingRegisterReadBit(addressOffset + 338, 11))
{
if (_controlChamberEthylene->getValueEthylene() > _modbusTCPServer->holdingRegisterReadFloat(addressOffset + 361))
{
//Activamos los ventiladores
flagActivadoresVentiladores = 1;
}
else
{
flagActivadoresVentiladores = 0;
}
}
}
}
//--------------------------------------
/* falta para implementar
//------controlchamber.cpp --> barrido-------
Variableanterior=Hr(0,1) //---- inicializar en el int y en barrido
If (hr (0,1)!=variableanterior)
{
If (variableanterior=1)
{
Activador=1
}
if(HR(0,1)=0)
{
Activador=0
}
//---------------------------
//---------
If(activador=1) //
{
If (hr(338,11))
{
If( etileno > hr 361) // por una metodo pido el valor de etileno
{
Activar ventilador de entrada y salida y poner al máximo forza
// traduzco en una flag de activacion de ventiladores IN_FAN, OUT_FAN carta analogica a 20000
}
Else
{
If((setpoint < temperatura interior)&&(temperaturaexterior+1<temperaturainterior)&& timer hr363)
{
Activar ventilador de entrada y salida y poner al máximo forzar flag de activacion de ventiladores IN_FAN, OUT_FAN carta analogica a 20000
Desactivar el frío control cooluing request cooling request deshabilitar
}
Else
{
Activar ventilador de entrada y salida y poner al máximo desforzar
Desactivar el frío control cooluing request cooling request habilitar
escribirá el hr 338,11 a 0
activador=0
}
}
}
}
}
}
*/
//------------------------------------------
Chamber::Chamber(int chamber,
ModbusTCPServer *modbusTCPServer,
ModbusTCPClient *modbusTCPClient1,
ModbusTCPClient *modbusTCPAnalogInputClient2,
ModbusTCPClient *modbusTCPAnalogInputClient3,
ModbusTCPClient *modbusTCPAnalogInputClient4,
ModbusTCPClient *modbusTCPAnalogInputClient5,
ModbusTCPClient *modbusTCPClient2,
int &holdingRegisterPerChamber)
{
_chamber = chamber;
_modbusTCPServer = modbusTCPServer;
_modbusTCPClient1 = modbusTCPClient1;
_modbusTCPClient2 = modbusTCPClient2;
//Tarea 12
_modbusTCPAnalogInputClient2 = modbusTCPAnalogInputClient2;
_modbusTCPAnalogInputClient3 = modbusTCPAnalogInputClient3;
_modbusTCPAnalogInputClient4 = modbusTCPAnalogInputClient4;
_modbusTCPAnalogInputClient5 = modbusTCPAnalogInputClient5;
holdingRegisterPerChamber += numHoldingRegistersAddresses;
addressOffset = _chamber * numHoldingRegistersAddresses;
eepromOffset = _chamber * numEepromAddresses;
//---------------------------------------------------
_mapsensorReadOutputFan1 = new mapsensor(_modbusTCPServer,
addressOffset + 285, // Measure
addressOffset + 119, // LowLimit1
addressOffset + 120, // HighLimit1
addressOffset + 121, // zeroSensor1
addressOffset + 121, // spanSensor1
1); // constante de normalización
//----------------------------------------
_mapsensorReadOutputFan2 = new mapsensor(_modbusTCPServer,
addressOffset + 289, // Measure
addressOffset + 123, // LowLimit1
addressOffset + 124, // HighLimit1
addressOffset + 125, // zeroSensor1
addressOffset + 126, // spanSensor1
1); // constante de normalización
//----------------------------------------
//----Tarea 12
_mapsensorReadPresionEtileno = new mapsensor(_modbusTCPServer,
addressOffset + 340, // Measure
addressOffset + 64, // LowLimit1
addressOffset + 65, // HighLimit1
addressOffset + 66, // zeroSensor1
addressOffset + 67, // spanSensor1
1); // constante de normalización
//-------
_mapsensorReadPinzaConsumo1 = new mapsensor(_modbusTCPServer,
addressOffset + 321, // Measure
addressOffset + 179, // LowLimit1
addressOffset + 180, // HighLimit1
addressOffset + 181, // zeroSensor1
addressOffset + 182, // spanSensor1
1); // constante de normalización
//-------
_mapsensorReadPinzaConsumo2 = new mapsensor(_modbusTCPServer,
addressOffset + 323, // Measure
addressOffset + 183, // LowLimit1
addressOffset + 184, // HighLimit1
addressOffset + 185, // zeroSensor1
addressOffset + 186, // spanSensor1
1); // constante de normalización
//-------
_mapsensorReadPinzaConsumo3 = new mapsensor(_modbusTCPServer,
addressOffset + 325, // Measure
addressOffset + 187, // LowLimit1
addressOffset + 188, // HighLimit1
addressOffset + 189, // zeroSensor1
addressOffset + 190, // spanSensor1
1); // constante de normalización
//-------
_mapsensorReadPinzaConsumo4 = new mapsensor(_modbusTCPServer,
addressOffset + 327, // Measure
addressOffset + 191, // LowLimit1
addressOffset + 192, // HighLimit1
addressOffset + 193, // zeroSensor1
addressOffset + 194, // spanSensor1
1); // constante de normalización
//---------------------------------
_mapsensorReadTemperaturaExterio = new mapsensor(_modbusTCPServer,
addressOffset + 353, // Measure
addressOffset + 107, // LowLimit1
addressOffset + 108, // HighLimit1
addressOffset + 109, // zeroSensor1
addressOffset + 110, // spanSensor1
1); // constante de normalización
//------------------------------------------------------------------------
_mapsensorReadHumedadExterior = new mapsensor(_modbusTCPServer,
addressOffset + 349, // Measure
addressOffset + 111, // LowLimit1
addressOffset + 112, // HighLimit1
addressOffset + 113, // zeroSensor1
addressOffset + 114, // spanSensor1
1); // constante de normalización
//----------------------------------------------------------------------------
_mapsensorReadPresionAgua= new mapsensor(_modbusTCPServer,
addressOffset + 278, // Measure
addressOffset + 127, // LowLimit1
addressOffset + 128, // HighLimit1
addressOffset + 129, // zeroSensor1
addressOffset + 130, // spanSensor1
1);
//---------------------------------
_mapsensorReadPresionAire= new mapsensor(_modbusTCPServer,
addressOffset + 276, // Measure
addressOffset + 121, // LowLimit1
addressOffset + 122, // HighLimit1
addressOffset + 123, // zeroSensor1
addressOffset + 124, // spanSensor1
1);
//------------------------------------------------------------------------------
readsensorInput1 = new readsensor(_modbusTCPClient1);
readsensorInput2 = new readsensor(_modbusTCPAnalogInputClient2);
readsensorInput3 = new readsensor(_modbusTCPAnalogInputClient3);
readsensorInput4 = new readsensor(_modbusTCPAnalogInputClient4);
readsensorInput5 = new readsensor(_modbusTCPAnalogInputClient5);
//---------------------------------------------------------------------------------
_controlchamberco2 = new controlchamberco2(_modbusTCPServer,addressOffset);
_controlchambershumidity = new controlchambershumidity(_modbusTCPServer,addressOffset);
_controlChamberEthylene = new controlChamberEthylene(_modbusTCPServer,addressOffset);
_controlChamberEthyleneFlow = new controlChamberEthyleneFlow(_modbusTCPServer,addressOffset);
_controlChamberTemperature = new controlChamberTemperature(_modbusTCPServer,addressOffset);
}
void Chamber::init()
{
//Tarea 14
//------------------------Barrido-------------------------------
estadoAnteriosBarridoHolderRegister = _modbusTCPServer->holdingRegisterReadBit(addressOffset + 0, 1);
//----------------------------------
//inicializo los timer de alamr a de puertas y ventilador
timerAlarmNoVentilation = hour2seg(MAX_TIME_ALARM_NO_VENTILATION);
timerOpenDoorTimeAlarm1 = MAX_TIME_OPEN_DOOR_1;
timerOpenDoorTimeAlarm2 = MAX_TIME_OPEN_DOOR_2;
//Get persisten variables from eeprom
int counter = 0;
for (int i = 0; i < 250; i++)
{
uint16_t value = 0;
uint8_t highByte = EEPROM.read(eepromOffset + counter + 1);
uint8_t lowByte = EEPROM.read(eepromOffset + counter);
value = highByte << 8;
value += lowByte;
_modbusTCPServer->holdingRegisterWrite(addressOffset + i, value);
counter += 2;
}
if (EEPROM.read(0) & (1 << 3))
{
digitalWrite(Q0_0, HIGH);
delay(100);
digitalWrite(Q0_0, LOW);
clearBitEeprom(0, 3);
}
}
//Tarea 12
//Botella etileno
void Chamber::botellaEtileno(){
//lectura de sensore
_mapsensorReadPresionEtileno->mapFloatMeasurementSensorInt(readsensorInput2->getValueSensor(2));
int valorPresionEtileno = (int)_mapsensorReadPresionEtileno->getValueSensor();
if (valorPresionEtileno < 10)
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 338, 8);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 338, 8);
}
}
//----------------------------------
//Pinza de consumo
void Chamber::pinzasConsumo(){
//lectura de sensore
_mapsensorReadPinzaConsumo1->mapFloatMeasurementSensorInt(readsensorInput3->getValueSensor(0));
_mapsensorReadPinzaConsumo2->mapFloatMeasurementSensorInt(readsensorInput3->getValueSensor(1));
_mapsensorReadPinzaConsumo3->mapFloatMeasurementSensorInt(readsensorInput3->getValueSensor(2));
_mapsensorReadPinzaConsumo4->mapFloatMeasurementSensorInt(readsensorInput3->getValueSensor(3));
}
//----------------
void Chamber::temperaturaExterior(){
_mapsensorReadTemperaturaExterio->mapFloatMeasurementSensor(readsensorInput2->getValueSensor(3));
_mapsensorReadTemperaturaExterio->mapFloatLimitador(addressOffset + 272);
valorTemperaturaExterior = _mapsensorReadTemperaturaExterio->getValueSensor();
}
//-------------
void Chamber::humedadExterior(){
_mapsensorReadHumedadExterior->mapFloatMeasurementSensorInt(readsensorInput2->getValueSensor(4));
_mapsensorReadTemperaturaExterio->mapFloatLimitador(addressOffset + 268);
}
//-------------------------
void Chamber::presionAgua(){
_mapsensorReadPresionAgua->mapFloatMeasurementSensor(readsensorInput5->getValueSensor(4));
double valorPresionAgua = _mapsensorReadPresionAgua->getValueSensor();
if (valorPresionAgua < 10)
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 255, 4);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 255, 4);
}
}
//-------------------------
void Chamber::presionAire(){
_mapsensorReadPresionAire->mapFloatMeasurementSensor(readsensorInput5->getValueSensor(5));
double valorPresionAire = _mapsensorReadPresionAire->getValueSensor();
if (valorPresionAire < 10)
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 255, 5);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 255, 5);
}
}
//------------------------------
//este es uno nuevo no borrar
void Chamber::run(){
//Lectura de todos los sensores Analogicos de entrada
readsensorInput1->runReadSesor();
readsensorInput2->runReadSesor();
readsensorInput3->runReadSesor();
readsensorInput4->runReadSesor();
readsensorInput5->runReadSesor();
//Tarea 12
this->botellaEtileno();
this->temperaturaExterior();
this->humedadExterior();
this->presionAgua();
this->presionAire();
this->pinzasConsumo();
//alarmas
this->alarms();
//El sistema de control de complir este orden
//run del control humidity
_controlchambershumidity->run(readsensorInput1->getValueSensor(rawValueInputModule1Hum),autoSelectorValue);
// run del control de ehtylene
_controlChamberEthylene->run(readsensorInput1->getValueSensor(rawValueInputModule1Ethylene));
// run control de ethylene flow
_controlChamberEthyleneFlow->run(analogRead(ETHYLENE_FLOW_IN),_controlchamberco2->getAnalogOutputModule1ValuesCo2(0),
_controlchamberco2->getAnalogOutputModule1ValuesCo2(1),_controlchamberco2->getMinCo2());
//Barrido
this->botellaEtileno();
// run control de temperatura
_controlChamberTemperature->run(readsensorInput1->getValueSensor(rawValueInputModule1Temp),autoSelectorValue,valorTemperaturaExterior,flagActivadoresVentiladores);
//Solicito el flag de activar ventiladores por barrido
flagActivadoresVentiladores = _controlChamberTemperature->getForceVentiladores();
//run del control CO2
_controlchamberco2->run(readsensorInput1->getValueSensor(rawValueInputModule1Co2),flagActivadoresVentiladores);
//habilitadores
this->enable();
//forzados
this->forced();
// escritura de entradas
//this->measurements();
// escrituras de salidas
this->writeAnalogValues();
this->writeIODigital();
//indicadores
this->stateIndicator();
//stateAutoTelSelector
this->stateAutoTelSelector();
}
void Chamber::stateIndicator(){
if (digitalRead(ALARM_SET))
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 339, 4);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 339, 4);
}
//-------------------------
if (digitalRead(EVAPORATOR_FAN_ACTIVATOR))
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 339, 1);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 339, 1);
}
//----------------------------------------------------------------
/*
if (digitalRead(SAFETY_RELAY_RESET))
{
//_modbusTCPServer->holdingRegisterSetBit(addressOffset + 339, xxx);
}
else
{
//_modbusTCPServer->holdingRegisterClearBit(addressOffset + 339, xxx);
}
*/
//-----------
if (autoSelectorValue)
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 339, 3);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 339, 3);
}
//----------------------------------------------
if (digitalRead(DOOR_1_OPEN_DETECT))
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 1, 4);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 1, 4);
}
//-----------------------------
if (digitalRead(DOOR_2_OPEN_DETECT))
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 1, 5);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 1, 5);
}
}
void Chamber::writeAnalogValues()
{
analogOutputModule1Values[analogOutputModule1ValuesCo2_0] = _controlchamberco2->getAnalogOutputModule1ValuesCo2(0);
analogOutputModule1Values[analogOutputModule1ValuesCo2_0] = _controlchamberco2->getAnalogOutputModule1ValuesCo2(1);
if (_controlChamberEthylene->getAnalogOutputModule1FlagEthylene())
{
analogOutputModule1Values[analogOutputModule1ValuesEthylene] = _controlChamberEthylene->getAnalogOutputModule1ValuesEthylene();
}else
{
if (_controlChamberEthyleneFlow->getAnalogOutputModule1FlagEthyleneFlow())
{
analogOutputModule1Values[analogOutputModule1ValuesEthylene] = _controlChamberEthyleneFlow->getAnalogOutputModule1ValuesEthyleneFlow();
}
}
_modbusTCPClient2->beginTransmission(HOLDING_REGISTERS, 40, 4);
for (int i = 0; i < NumberanalogOutputModule1Values; i++)
{
_modbusTCPClient2->write(analogOutputModule1Values[i]);
}
_modbusTCPClient2->endTransmission();
}
void Chamber::writeIODigital(){
digitalWrite(ALARM_SET,controlChambersIO.alarmSet);
digitalWrite(EVAPORATOR_FAN_ACTIVATOR,controlChambersIO.evaporatorFanActivator);
digitalWrite(SAFETY_RELAY_RESET,controlChambersIO.safetyRelayReset);
}
void Chamber::alarms()
{
//Alarma General
if(alarmOn == true || _controlchamberco2->getAlarmOnGeneral() == true || _controlchambershumidity->getAlarmOnGeneral() == true
|| _controlChamberEthylene->getAlarmOnGeneral() == true || _controlChamberTemperature->getAlarmOnGeneral() ==true)
{
controlChambersIO.alarmSet = 1; //----- digitalWrite(ALARM_SET, HIGH);
}
else
{
controlChambersIO.alarmSet = 0; //----- digitalWrite(ALARM_SET, LOW);
}
//EMPIEZAN VERIFICAR ALARMAS NO VENTILAR
if (timerAlarmNoVentilation > 0) {
if( (VALUE_ACTUAL_INPUT_FAN1) || (VALUE_ACTUAL_OUTPUT_FAN1) || (VALUE_ACTUAL_INPUT_FAN2) || (VALUE_ACTUAL_OUTPUT_FAN2) ) {
//unsigned int maxTimeAlarmVentilation = EEPROM.read(142)<<8 + EEPROM.read(143);
timerAlarmNoVentilation = hour2seg(MAX_TIME_ALARM_NO_VENTILATION);
flagTimerAlarmNoVentilationPointer = false;
}
else
{
if(timerAlarmNoVentilation == 0 ){
flagTimerAlarmNoVentilationPointer = true;
_modbusTCPServer->holdingRegisterSetBit(256, 9);
}
}
}
//FINALIZAR VERIFICACION ALARMAS VENTILAR
//EMPIEZAN A VERIFICAR ALARMAS POR TIEMPO DE PUERTA ABIERTA
// PUERTA 1
if (VALUE_DOOR_1)
{
if (timerOpenDoorTimeAlarm1 == 0){
flagTimerOpenDoorTimeAlarm1Pointer = true;
alarmOn = true;
_modbusTCPServer->holdingRegisterSetBit(338, 5);
}
else{
flagTimerOpenDoorTimeAlarm1Pointer = false;
}
}
else
{
timerOpenDoorTimeAlarm1 = MAX_TIME_OPEN_DOOR_1;
}
// PUERTA 2
if (VALUE_DOOR_2)
{
if (timerOpenDoorTimeAlarm2 == 0){
flagTimerOpenDoorTimeAlarm2Pointer = true;
alarmOn = true;
_modbusTCPServer->holdingRegisterSetBit(338, 6);
}
else{
flagTimerOpenDoorTimeAlarm2Pointer = false;
}
}
else
{
timerOpenDoorTimeAlarm2 = MAX_TIME_OPEN_DOOR_2;
}
//FINALIZAN VERIFICACION ALARMA POR TIEMPO DE PUERTA ABIERTA
}
void Chamber::writeToEeprom()
{
int modbusAddress = _modbusTCPServer->holdingRegisterRead(addressOffset + 261);
int dataType = _modbusTCPServer->holdingRegisterRead(addressOffset + 260);
int eepromAddress = _modbusTCPServer->holdingRegisterRead(addressOffset + 261) * 2;
if (dataType == 1)
{
EEPROM.put(eepromOffset + eepromAddress,
_modbusTCPServer->holdingRegisterRead(addressOffset + modbusAddress));
_modbusTCPServer->holdingRegisterWrite(addressOffset + 261, 0);
_modbusTCPServer->holdingRegisterWrite(addressOffset + 260, 0);
Serial.print("value stored: ");
Serial.println(_modbusTCPServer->holdingRegisterRead(addressOffset + modbusAddress));
Serial.println("Register stored in eeprom");
}
if (dataType == 2)
{
float floatValue = _modbusTCPServer->holdingRegisterReadFloat(addressOffset + modbusAddress);
uint16_t words[2];
modbus_set_float_dcba(floatValue, words);
for (int i = 0; i < 2; i++)
{
EEPROM.put((eepromOffset + eepromAddress + 2 * i), words[i]);
}
_modbusTCPServer->holdingRegisterWrite(addressOffset + 261, 0);
_modbusTCPServer->holdingRegisterWrite(addressOffset + 260, 0);
Serial.println("Float stored in eeprom");
}
// if (dataType == 3)
// {
// long longValue = _modbusTCPServer->holdingRegisterReadLong(addressOffset + modbusAddress);
// uint8_t bytes[4];
//
// bytes[0] = (uint8_t) longValue;
// bytes[1] = (uint8_t) longValue >> 8;
// bytes[2] = (uint8_t) longValue >> 16;
// bytes[3] = (uint8_t) longValue >> 24;
//
// for (int i = 0; i < 4; i++)
// {
// EEPROM.put((eepromOffset + eepromAddress + i), bytes[i]);
// }
//
// _modbusTCPServer->holdingRegisterWrite(addressOffset + 261, 0);
// _modbusTCPServer->holdingRegisterWrite(addressOffset + 260, 0);
//
// Serial.println("Long stored in eeprom");
// }
}
void Chamber::readOutputFan1(double medidaSensor){
_mapsensorReadOutputFan1->mapFloatMeasurementSensor(medidaSensor);
calculatedSensorValuesOutputFan1 = _mapsensorReadOutputFan1->getValueSensor(); //------------calculatedSensorValues[SensorOutputFan1ValuePos]
}
void Chamber::readOutputFan2(double medidaSensor){
_mapsensorReadOutputFan2->mapFloatMeasurementSensor(medidaSensor);
calculatedSensorValuesOutputFan2 = _mapsensorReadOutputFan2->getValueSensor(); //------------calculatedSensorValues[SensorOutputFan2ValuePos]
}
void Chamber::measurements()
{
readOutputFan1(analogRead(OUTPUT_FAN_PHASE_1));
readOutputFan2(analogRead(OUT_FAN_PHASE_2));
}
/**
* @brief enableInputOutput verifica los estado del holdregister, para habilitar las entradas y salidas del sistema
*/
//----> Tarea 2
void Chamber::enable(){
if (!ENABLE_SAFETY_RELAY_RESET)
{
controlChambersIO.safetyRelayReset = 0;
}
if(!ENABLE_EVAPORATOR_FAN_ACTIVATOR){
controlChambersIO.evaporatorFanActivator = 0; //-------digitalWrite(EVAPORATOR_FAN_ACTIVATOR, LOW);
}
if(!ENABLE_ALARM_SET){
controlChambersIO.alarmSet = 0; //----- digitalWrite(ALARM_SET, LOW);
}
if (!ENABLE_AUTOTEL_SELECTOR_HR)
{
autoSelectorValue = 0;
}
else
{
autoSelectorValue = 1;
}
}
/**
* @brief forcedControl verifica los estado del holdregister, para forza las salidas de Humedad, Co2 y Ethyleno al maximo
*/
//----> Tarea 3
void Chamber::forced()
{
if (FORCED_SAFETY_RELAY_RESET)
{
controlChambersIO.safetyRelayReset = 1;
}
if(FORCED_EVAPORATOR_FAN_ACTIVATOR)
{
controlChambersIO.evaporatorFanActivator = 1; //-------digitalWrite(EVAPORATOR_FAN_ACTIVATOR, LOW);
}
if(FORCED_ALARM_SET){
controlChambersIO.alarmSet = 1; //----- digitalWrite(ALARM_SET, LOW);
}
if (FORCED_AUTOTEL_SELECTOR_HR)
{
autoSelectorValue = 1;
}
}
//Zeta de emergencia
//-----> Tarea 4
void Chamber::setaEmergency(){
if (digitalRead(EMERGENCY_STOP)){
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 0, 0);
}
else{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 0, 0);
}
}
//micro cortes
//------>Tarea 5
void Chamber::atiendeMicroCutsInterrup(unsigned char *mflagMicroCutsPointer){
if (*mflagMicroCutsPointer)
{
if (digitalRead(MICRO_CUTS_DETECTION))
{
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 0, 3);
}
else
{
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 0, 3);
}
*mflagMicroCutsPointer = 0;
}
}
//-----> Tarea 5
void Chamber::atiendeGeneralSwitchDetect(){
if (_modbusTCPServer->holdingRegisterReadBit(addressOffset + 0, 3)){
if(digitalRead(GENERAL_SWITCH_DETEC)){
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 0, 0);
// se limpia el 0,3
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 0, 3);
}
else{
if (timerMicroCut.flag10 == 0)
{
timerMicroCut.timer10 = 10;
timerMicroCut.flag10 = 1;
}
else
{
if (timerMicroCut.timer10 == 0)
{
if (timerMicroCut.flag03 == 0)
{
timerMicroCut.timer03 = 3;
timerMicroCut.flag03 = 1;
}
else
{
if(timerMicroCut.timer03 > 0){
controlChambersIO.safetyRelayReset = 1; //------digitalWrite(SAFETY_RELAY_RESET,HIGH);
}
else
{
controlChambersIO.safetyRelayReset = 0; //-----digitalWrite(SAFETY_RELAY_RESET,LOW);
timerMicroCut = {0,0,0,0};
// se limpia el 0,3
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 0, 3);
}
}
}
}
}
}
}
//---------> Tarea 5
void Chamber::setupSafetyRelayReset(){
if (_modbusTCPServer->holdingRegisterReadBit(addressOffset + 0, 3)){
_modbusTCPServer->holdingRegisterSetBit(addressOffset + 0, 3);
controlChambersIO.safetyRelayReset = 1; //------digitalWrite(SAFETY_RELAY_RESET,HIGH);
delay(1000);
controlChambersIO.safetyRelayReset = 0; //-----digitalWrite(SAFETY_RELAY_RESET,LOW);
_modbusTCPServer->holdingRegisterClearBit(addressOffset + 0, 3);
}
}
// StateAutoTelSelector ---> Tarea 11
void Chamber::stateAutoTelSelector(){
if (digitalRead(AUTO_TEL_SELECTOR))
{
//Asignamos el HR a 1
SET_AUTOTEL_SELECTOR_HR;
if (AUTO_TEL_SELECTOR_STATE){
// control humedad y temperatura bloqueado
autoSelectorValue = 0;
if (_modbusTCPServer->holdingRegisterReadBit(addressOffset + 0, 0)){
SET_AUTOTEL_SELECTOR_HR; //ENABLE_AUTOTEL_SELECTOR_HR = 1;
}
else
{
CLEAR_AUTOTEL_SELECTOR_HR; //ENABLE_AUTOTEL_SELECTOR_HR = 0;
}
}
else
{
// control humedad y temperatura desbloqueado
autoSelectorValue = 1;
CLEAR_AUTOTEL_SELECTOR_HR;
}
}
else {
CLEAR_AUTOTEL_SELECTOR_HR;
}
}
Chamber::~Chamber(){
}
|
0521a33522c96ab255cf9c0ca753ce18666fc120
|
438ca5d000e0b956df4b2277c5bcf69c057d8f26
|
/cpp-cpr/oktauth.cpp
|
af98417926000636b8704688327a1173ccafa303
|
[] |
no_license
|
julianguaringlobant/okta_rest_auth_sample
|
e8de6c6c689106257976c88e5a6468fdb9f5bd50
|
83116fab291a56ab8201795762060d2d008520e5
|
refs/heads/master
| 2023-07-01T06:16:16.474717
| 2021-07-19T04:07:38
| 2021-07-19T04:07:38
| 385,004,050
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,089
|
cpp
|
oktauth.cpp
|
#include <cpr/cpr.h>
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main(int argc, char ** argv)
{
std::cout << "Basic Authentication test sample with OKTA" << std::endl;
if (argc < 4)
{
std::cout << "Usage: auth domainname username password\n";
return -1;
}
auto data = json{};
data["username"] = argv[2];
data["password"] = argv[3];
std::string datastring = data.dump();
auto urlstring = std::string{"https://"} + std::string{argv[1]} + std::string{".okta.com"} ;
auto authn_api = std::string{"/api/v1/authn"};
cpr::Response r = cpr::Post(
cpr::Url{ urlstring + authn_api},
cpr::Body{datastring},
cpr::Header{
{"Accept", "application/json"},
{"Content-Type", "application/json"}
}
);
std::cout << "STATUS CODE : " << r.status_code << std::endl; // 200
std::cout << "+++++++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << std::endl << "CONTENT TYPE: " << r.header["content-type"] << std::endl; // application/json; charset=utf-8
std::cout << "+++++++++++++++++++++++++++++++++++++++++" << std::endl;
auto jsonresponse = json::parse(r.text);
std::cout << jsonresponse.dump(4) << std::endl;
std::cout << "+++++++++++++++++++++++++++++++++++++++++" << std::endl;
auto statusString = jsonresponse["status"];
std::cout << "Status String is : " << statusString << std::endl;
if ( statusString == "MFA_REQUIRED")
{
std::cout << "Multi Factor Authentication Required, the following factors are available for this user: " << std::endl;
auto factors = jsonresponse["_embedded"]["factors"];
for (auto& factor : factors)
{
std::cout << "ID: " << factor["id"] << std::endl;
std::cout << "TYPE: " << factor["factorType"] << std::endl;
}
std::cout << "+++++++++++++++++++++++++++++++++++++++++" << std::endl;
for (auto i = 0; i < 15; ++i) std::cout << std::endl;
for (auto& factor : factors)
{
if (factor["factorType"] != "push") continue;
std::cout << "Push Factor ID: " << factor["id"] << std::endl;
std::cout << "Profile: " << std::endl;
std::cout << factor["profile"].dump(4) << std::endl;
auto verifydata = json{};
verifydata["stateToken"] = jsonresponse["stateToken"];
std::string verifydatastring = verifydata.dump();
cpr::Response verifyresponse = cpr::Post(
cpr::Url{ factor["_links"]["verify"]["href"]},
cpr::Body{verifydatastring},
cpr::Header{
{"Accept", "application/json"},
{"Content-Type", "application/json"}
}
);
std::cout << "STATUS CODE : " << verifyresponse.status_code << std::endl; // 200
std::cout << "+++++++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << std::endl << "CONTENT TYPE: " << verifyresponse.header["content-type"] << std::endl; // application/json; charset=utf-8
std::cout << "+++++++++++++++++++++++++++++++++++++++++" << std::endl;
auto jsonverifyresponse = json::parse(verifyresponse.text);
std::cout << jsonverifyresponse.dump(4) << std::endl;
std::cout << "Break here!!!! " << std::endl;
verifyresponse = cpr::Post(
cpr::Url{ factor["_links"]["verify"]["href"]},
cpr::Body{verifydatastring},
cpr::Header{
{"Accept", "application/json"},
{"Content-Type", "application/json"}
}
);
jsonverifyresponse = json::parse(verifyresponse.text);
std::cout << jsonverifyresponse.dump(4) << std::endl;
}
}
return 0;
}
|
0ee38182013951b135aa66ed12fd4bc3fe153fc8
|
1e52092d90a135b6a6c2931e84af8a0dd993dadb
|
/VideoLibrary/src/main/cpp/FFmpeg.cpp
|
02747521d00d3ec9d321e4a840b5d583b8a87f1f
|
[] |
no_license
|
gogoDoPeter/MyPushEditVideo
|
1d102981f64225b364ca2cc621720fae956448f0
|
1591ac92bed691f9762c82ea4ba37f60f3060138
|
refs/heads/master
| 2023-08-15T01:04:26.807209
| 2021-09-20T16:45:59
| 2021-09-20T16:45:59
| 408,041,513
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,335
|
cpp
|
FFmpeg.cpp
|
//
// Created by lz6600 on 2021/8/31.
//
#include "FFmpeg.h"
static int getCurrentTime()
{
struct timeval t;
gettimeofday(&t, nullptr);
return static_cast<int>(t.tv_sec * 1000 + t.tv_usec / 1000);
}
FFmpeg::FFmpeg(const char *source, CallJava *callJava_, PlayStatus *playStatus_)
{
this->source = source;
this->callJava = callJava_;
this->playStatus = playStatus_;
exitFfmpeg = false;
memset(errMsg, 0, sizeof(errMsg));
pthread_mutex_init(&init_mutex, nullptr);
pthread_mutex_init(&seek_mutex, nullptr);
}
FFmpeg::~FFmpeg()
{
pthread_mutex_destroy(&init_mutex);
pthread_mutex_destroy((&seek_mutex));
}
//todo 打开文件,做好准备,给上层回调结果
void *decodeFFmpegRun(void *data)
{
LOGE("decodeFFmpegRun +");
FFmpeg *pFfmpeg = static_cast<FFmpeg *>(data);
pFfmpeg->prepareDecodeThread();
LOGE("decodeFFmpegRun -");
// return nullptr;
pthread_exit(&pFfmpeg->decodeThread);//pthread_exit 和 return 0 有什么区别?
}
void FFmpeg::prepared()
{
LOGE("prepared +");
pthread_create(&decodeThread, 0, decodeFFmpegRun, this);
LOGE("prepared -");
}
int avformat_callback(void *ctx)
{
FFmpeg *fFmpeg = (FFmpeg *) ctx;
if (fFmpeg->playStatus->exit)
{
return AVERROR_EOF;
}
return 0;
}
//TODO 完成打开文件,准备好开始做解封装
void FFmpeg::prepareDecodeThread()
{
LOGE("prepareDecodeThread + :%s", source);
av_register_all();//TODO 4.2.0废弃,可以不设置照常用
avformat_network_init();
pFormatCtx = avformat_alloc_context();
pFormatCtx->interrupt_callback.callback = avformat_callback;
pFormatCtx->interrupt_callback.opaque = this;
int now_time = getCurrentTime();
LOGE("prepareDecodeThread 1 avformat_open_input, :%s", source);
int retVal = avformat_open_input(&pFormatCtx, source, NULL, NULL);
if (retVal != 0)
{
if (LOG_DEBUG)
{
LOGE("can not open source :%s, errcode:%d", source, retVal);
}
if (callJava)
{
sprintf(errMsg, "can not open source:%s, errcode:%d", source, retVal);
callJava->onCallErrorMsg(CHILD_THREAD,
ERROR_CODE_AVFORMAT_OPEN_FAIL, errMsg);
}
exitFfmpeg = true;
pthread_mutex_unlock(&init_mutex);
return;
}
LOGE("prepareDecodeThread 2, avformat_find_stream_info");
retVal = avformat_find_stream_info(pFormatCtx, NULL);
if (retVal < 0)
{
if (LOG_DEBUG)
{
LOGE("can not find streams from %s, errcode:%d", source, retVal);
}
if (callJava)
{
sprintf(errMsg, "can not find streams from %s, errcode:%d", source, retVal);
callJava->onCallErrorMsg(CHILD_THREAD,
ERROR_CODE_AVFORMAT_FIND_STREAM_INFO, errMsg);
}
exitFfmpeg = true;
pthread_mutex_unlock(&init_mutex);
return;
}
LOGE("prepareDecodeThread 3, pFormatCtx->nb_streams:%d", pFormatCtx->nb_streams);
for (int i = 0; i < pFormatCtx->nb_streams; i++)
{
if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)//得到音频流
{
if (audio == NULL)
{
audio = new MyAudio(playStatus, pFormatCtx->streams[i]->codecpar->sample_rate,
callJava);
audio->streamIndex = i;
audio->avCodecParameters = pFormatCtx->streams[i]->codecpar;
audio->duration = pFormatCtx->duration / AV_TIME_BASE;
audio->time_base = pFormatCtx->streams[i]->time_base;
duration = audio->duration;
if(callJava){
callJava->onCallPcmSampleRate(CHILD_THREAD,audio->sample_rate,
pFormatCtx->streams[i]->codecpar->channels);
}
}
}
}
LOGE("prepareDecodeThread 4, avcodec_find_decoder");
AVCodec *dec = avcodec_find_decoder(audio->avCodecParameters->codec_id);
if (!dec)
{
if (LOG_DEBUG)
{
LOGE("can not find decoder");
}
if (callJava)
{
sprintf(errMsg, "can not find decoder");
callJava->onCallErrorMsg(CHILD_THREAD,
ERROR_CODE_AVFORMAT_FIND_DECODER, errMsg);
}
exitFfmpeg = true;
pthread_mutex_unlock(&init_mutex);
return;
}
LOGE("prepareDecodeThread 5, avcodec_alloc_context3");
audio->avCodecContext = avcodec_alloc_context3(dec);
if (!audio->avCodecContext)
{
if (LOG_DEBUG)
{
LOGE("can not alloc new decodecctx");
}
if (callJava)
{
sprintf(errMsg, "can not alloc new decodecctx");
callJava->onCallErrorMsg(CHILD_THREAD,
ERROR_CODE_AVCODEC_ALLOC_CONTEXT, errMsg);
}
exitFfmpeg = true;
pthread_mutex_unlock(&init_mutex);
return;
}
LOGE("prepareDecodeThread 6, avcodec_parameters_to_context");
if (avcodec_parameters_to_context(audio->avCodecContext, audio->avCodecParameters) < 0)
{
if (LOG_DEBUG)
{
LOGE("can not fill decodecctx");
}
if (callJava)
{
sprintf(errMsg, "can not fill decodecct");
callJava->onCallErrorMsg(CHILD_THREAD,
ERROR_CODE_AVCODEC_PARAM_TO_CONTEXT, errMsg);
}
exitFfmpeg = true;
pthread_mutex_unlock(&init_mutex);
return;
}
LOGE("prepareDecodeThread 7, avcodec_open2");
retVal = avcodec_open2(audio->avCodecContext, dec, 0);
if (retVal != 0)
{
if (LOG_DEBUG)
{
LOGE("cant not open audio streams, errcode:%d", retVal);
}
if (callJava)
{
sprintf(errMsg, "cant not open audio streams, errcode:%d", retVal);
callJava->onCallErrorMsg(CHILD_THREAD,
ERROR_CODE_AVCODEC_OPEN, errMsg);
}
exitFfmpeg = true;
pthread_mutex_unlock(&init_mutex);
return;
}
LOGD("Open audio streams success, decode ffmpeg costTime:%d", getCurrentTime() - now_time);
if (callJava != nullptr)
{
if (playStatus != nullptr && !playStatus->exit)
{
callJava->onCallPrepared(CHILD_THREAD);
}
else
{
exitFfmpeg = true;//TODO Why? if playstatus->exit is true,then set exit to true
}
}
pthread_mutex_unlock(&init_mutex);
LOGE("prepareDecodeThread -");
}
//TODO 开始解码,把解码好的数据(Avpacket)放到audio->queue中 audio->queue->putAvpacket(avPacket)
void FFmpeg::startDecode()
{
LOGE("FFmpeg start +");
if (audio == NULL)
{
if (LOG_DEBUG)
{
LOGE("audio is null");
return;
}
}
audio->play();//do what?
int count = 0;
while (playStatus != NULL && !playStatus->exit)
{
if (playStatus->seekStatus)
{
av_usleep(1000 * 100);//TODO sleep 100ms for CPU using
continue;
}
//TODO 如果解码太快,让他sleep等一下
if (audio->queue->getQueueSize() > 30)
{ //考虑ape格式文件 wanli set 40
av_usleep(1000 * 100);//TODO sleep 100ms for CPU using
continue;
}
AVPacket *avPacket = av_packet_alloc();
if (av_read_frame(pFormatCtx, avPacket) == 0)
{
if (avPacket->stream_index == audio->streamIndex)//index 0 is Audio, 1 is video
{
count++;
LOGE("ffmpeg decode avpacket, 解码第 %d 帧", count);
audio->queue->putAvpacket(avPacket);
}
else
{
av_packet_free(&avPacket);
av_free(avPacket);
}
}
else
{
av_packet_free(&avPacket);
av_free(avPacket);
while (playStatus != NULL && !playStatus->exit)
{
//TODO 全部解码完成,但是音频还没播完,还有一些剩余帧等着播放
if (audio->queue->getQueueSize() > 0)
{
LOGD("audio->queue->getQueueSize() = %d", audio->queue->getQueueSize());
av_usleep(1000 * 100);//TODO sleep 100ms for CPU using
continue;
}
else
{
// playStatus->exit = true; //TODO save this will crash
break;
}
}
break;
}
}
exitFfmpeg = true;
if (audio != nullptr)
{
audio->isCut = false;
}
if (callJava != nullptr)
{
callJava->onCallComplete(CHILD_THREAD);
}
//模拟出队
/* while (audio->queue->getQueueSize() > 0)
{
AVPacket *packet = av_packet_alloc();
audio->queue->getAvpacket(packet);
av_packet_free(&packet);
av_free(packet);
packet = NULL;
}*/
if (LOG_DEBUG)
{
LOGD("解码完成");
}
LOGE("FFmpeg start -");
}
void FFmpeg::pause()
{
if (audio != nullptr)
{
audio->pause();
}
}
void FFmpeg::resume()
{
if (audio != nullptr)
{
audio->resume();
}
}
void FFmpeg::release()
{
if (LOG_DEBUG)
{
LOGE("开始释放Ffmpeg");
}
if (playStatus->exit)
{
return;
}
if (LOG_DEBUG)
{
LOGE("开始释放Ffmpeg2");
}
playStatus->exit = true;
pthread_mutex_lock(&init_mutex);
int sleepCount = 0;
int now_time = getCurrentTime();
while (!exitFfmpeg)
{
if (sleepCount > 1000)
{
exitFfmpeg = true;
}
if (LOG_DEBUG)
{
LOGE("wait ffmpeg exit, sleepCount:%d", sleepCount);
}
sleepCount++;
av_usleep(1000 * 10);//暂停10毫秒 TODO 用av_usleep()合适?
}
if (LOG_DEBUG)
{
LOGE("释放 Audio, sleep costTime:%d ms", getCurrentTime() - now_time);
}
if (audio != NULL)
{
audio->release();
delete (audio);
audio = NULL;
}
if (LOG_DEBUG)
{
LOGE("释放 封装格式上下文");
}
if (pFormatCtx != NULL)
{
avformat_close_input(&pFormatCtx);
avformat_free_context(pFormatCtx);
pFormatCtx = NULL;
}
if (LOG_DEBUG)
{
LOGE("释放 callJava");
}
if (callJava != NULL)
{
callJava = NULL;
}
if (LOG_DEBUG)
{
LOGE("释放 playStatus");
}
if (playStatus != NULL)
{
playStatus = NULL;
}
pthread_mutex_unlock(&init_mutex);
}
void FFmpeg::seek(int64_t seconds)
{
if (duration <= 0)
{
return;
}
if (seconds >= 0 && seconds <= duration)
{
if (audio != NULL)
{
LOGD("seek startTime:%ld in seconds", seconds);
playStatus->seekStatus = true;
audio->queue->clearAvpacket();
audio->clock = 0;
audio->last_time = 0;
pthread_mutex_lock(&seek_mutex);
int64_t realTime = seconds * AV_TIME_BASE;
LOGD("realTime:%ld in realTime",realTime);
//TODO 由于一个AVPacket里面有多个AVFrame,当seek时,FFmpeg解码器中还残留
// AVFrame,所以会导致seek后,不能立即播放当前音乐,需要做下 avcodec_flush_buffers 来清除FFmpeg解码器中残留的AVFrame
avcodec_flush_buffers(audio->avCodecContext);
avformat_seek_file(pFormatCtx, -1, INT64_MIN, realTime, INT64_MAX, 0);
pthread_mutex_unlock(&seek_mutex);
playStatus->seekStatus = false;
}
}
}
void FFmpeg::setVolume(int percent)
{
if (audio != nullptr)
{
audio->setVolume(percent);
}
}
void FFmpeg::setMute(int muteType)
{
if (audio != nullptr)
{
audio->setMute(muteType);
}
}
void FFmpeg::setSpeed(double speed)
{
if (audio != nullptr)
{
audio->setSpeed(speed);
}
}
void FFmpeg::setPitch(double pitch)
{
if (audio != nullptr)
{
audio->setPitch(pitch);
}
}
int FFmpeg::getAudioSampleRate()
{
if (audio != nullptr)
{
return audio->avCodecContext->sample_rate;
}
return 0;
}
void FFmpeg::startRecord(bool start)
{
if (audio != nullptr)
{
audio->startStopRecord(start);
}
}
bool FFmpeg::cutAudioPlay(double startTime, double endTime, bool isShowPcm)
{
if (startTime >= 0 && endTime <= duration && startTime < endTime)
{
if (audio != nullptr)
{
audio->isCut = true;
audio->endTime = endTime;
audio->isShowPcm = isShowPcm;
int64_t tempTime = (int64_t) startTime;
LOGD("startTime:%lf, tempTime:%ld", startTime, tempTime);
seek(tempTime);//这里数据精度有损失,如果想精准,传double类型下来
return true;
}
}
return false;
}
|
44fa9dfa7e6f4673668055f4ca43d18372715175
|
7d1e7eabb2c580de93ddc7806ccfd9f87cf2ca5b
|
/src/cli/Context.h
|
b82a804a630403cf9dc48963cd84367eaf572a68
|
[] |
no_license
|
ValeriiSudakov/TaskManager
|
3d7b8daaacf204fabf9fcbfc1523fd99df83b1c2
|
2b1ae0e65471cdc93909809dd8a5eb5cf3c86906
|
refs/heads/master
| 2023-05-13T21:15:18.384094
| 2021-06-06T20:55:25
| 2021-06-06T20:55:25
| 279,160,124
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 515
|
h
|
Context.h
|
//
// Created by valeriisudakov on 18.08.20.
//
#ifndef TASKMANAGER_CLI_CONTEXT_H_
#define TASKMANAGER_CLI_CONTEXT_H_
#include "TaskService.h"
struct Context {
Context(TaskService& taskService) : taskService_(taskService){}
~Context() = default;
TaskService& taskService_;
struct Buffer {
std::string name;
std::string label;
Priority priority;
Date date;
TaskID id;
std::string fileName;
} buffer_;
std::vector<TaskServiceDTO> tasks_;
};
#endif //TASKMANAGER_CLI_CONTEXT_H_
|
7430ef6151e72139a3426cde57b4d4d5cd23ec88
|
724ab4b95af7786587d442f206f0c3a895b2e2c1
|
/chinko_bot/units/APIUnit/messages/connection/characterSelection/CharacterInformationsListMessage.cpp
|
05ac6a9ca61ca978f00d6ab58f63225e747391f6
|
[] |
no_license
|
LaCulotte/chinko_bot
|
82ade0e6071de4114cc56b1eb6085270d064ccb1
|
29aeba90638d0f2fe54d1394c1c9a2f63524e50e
|
refs/heads/master
| 2023-02-04T21:15:20.344124
| 2020-12-26T08:55:00
| 2020-12-26T08:55:00
| 270,402,722
| 4
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 647
|
cpp
|
CharacterInformationsListMessage.cpp
|
#include "CharacterInformationsListMessage.h"
bool CharacterInformationsListMessage::serialize(sp<MessageDataBuffer> output) {
output->writeVarInt(characters.size());
for(int i = 0; i < characters.size(); i++)
if(!characters[i].serialize(output))
return false;
return true;
}
bool CharacterInformationsListMessage::deserialize(sp<MessageDataBuffer> input) {
int size = input->readVarInt();
for(int i = 0; i < size; i++) {
CharacterInformations character;
if(!character.deserialize(input))
return false;
characters.push_back(character);
}
return true;
}
|
90d0d79934ac949101cc2537efc711ea30655e4b
|
ea8aa77c861afdbf2c9b3268ba1ae3f9bfd152fe
|
/cf913E/cf913E/ACMTemplete.cpp
|
4298ee36b13c1adcff60f8d7e3a136bf03ed35af
|
[] |
no_license
|
lonelam/SolveSet
|
987a01e72d92f975703f715e6a7588d097f7f2e5
|
66a9a984d7270ff03b9c2dfa229d99b922907d57
|
refs/heads/master
| 2021-04-03T02:02:03.108669
| 2018-07-21T14:25:53
| 2018-07-21T14:25:53
| 62,948,874
| 9
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 772
|
cpp
|
ACMTemplete.cpp
|
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <bitset>
#include <deque>
#include <string>
#include <list>
#include <cstdlib>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 100000 + 100;
typedef long long ll;
typedef long double ld;
map<int, string> table = {
};
int n;
int main()
{
while (~scanf("%d", &n))
{
for (int i = 0; i < n; i++)
{
char line[10];
scanf("%s", line);
int base = 0;
for (int j = 0; j < 8; j++)
{
base <<= 1;
if (line[j] == '1')
{
base |= 1;
}
}
printf("%s\n", table[base].c_str());
}
}
}
|
06d05fb3a0699db732e398e258785ce61b16d976
|
2f10f807d3307b83293a521da600c02623cdda82
|
/deps/boost/win/debug/include/boost/math/distributions/students_t.hpp
|
590fad2afc948159757f7d4d52f02782736520c6
|
[] |
no_license
|
xpierrohk/dpt-rp1-cpp
|
2ca4e377628363c3e9d41f88c8cbccc0fc2f1a1e
|
643d053983fce3e6b099e2d3c9ab8387d0ea5a75
|
refs/heads/master
| 2021-05-23T08:19:48.823198
| 2019-07-26T17:35:28
| 2019-07-26T17:35:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 130
|
hpp
|
students_t.hpp
|
version https://git-lfs.github.com/spec/v1
oid sha256:b24e5ff6ee5dc0a371fa5f2139a604a3ce799431d15ee94cbcc22ac2e1af3d40
size 18072
|
5b0d64c75e20e4cbcd02b1a56ab84ddee717768d
|
e014040a3bd59b9178c4f11a42b0abcfc1fc9abb
|
/Source/MomodoraLibrary/LadderObject.h
|
2ca5dbde5bc5008d3f297ec53aeaa0aeff442f1c
|
[] |
no_license
|
tonnac/D3D11
|
c68ee5d92f08da26f960905baee7d5546da59a61
|
4a8275b057444646fe6bffc076400db02f5c1acc
|
refs/heads/master
| 2021-07-18T14:34:22.956587
| 2019-01-22T16:52:15
| 2019-01-22T16:52:15
| 147,910,342
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 168
|
h
|
LadderObject.h
|
#pragma once
#include "TerrainObject.h"
class LadderObject : public TerrainObject
{
public:
bool Collision(Object*) override;
void ObjectDraw(Object*);
private:
};
|
ce7e45924bb06ccfe42dc3a65506af9161de8109
|
b4962292f39aacd93b73a1289f6518f0702a4524
|
/third_party/uc_sdk/src/components/db/include/DBUpgrade.h
|
2bbcca2c6f518e21769b08de164286fac1425a68
|
[] |
no_license
|
oamates/PC2.0
|
ed047681297f565185cad5406204e716e840b33e
|
ddeff8fd85c6d5ce1db3e4e4fc450f472011be15
|
refs/heads/master
| 2021-07-07T22:57:11.733908
| 2017-09-30T09:51:31
| 2017-09-30T09:51:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,138
|
h
|
DBUpgrade.h
|
#if !defined(DBUPGRADE_H_)
#define DBUPGRADE_H_
#include "CppSQLite3.h"
#include <map>
/////////////////升级说明/////////////////
// 1.将当前数据表名改为临时表
// 2.创建新表
// 3.导入数据,新增字段填空
// 4.删除临时表
//////////////////////////////////////////
namespace uc {
using namespace std;
enum {
DBV1 = 1,
DBV2 = 2,
DBV3 = 3,
};
typedef int (*UpgradePtr)(CppSQLite3DB* commonDb, CppSQLite3DB* userDb);
class DBUpgrade {
public:
static DBUpgrade& GetInstance() {
static DBUpgrade instance;
return instance;
}
int Upgrade(const string& devDBPath, const string& userDBPath);
private:
static int UpgradeV1(CppSQLite3DB* commonDb, CppSQLite3DB* userDb);
static int UpgradeV2(CppSQLite3DB* commonDb, CppSQLite3DB* userDb);
static int UpgradeV3(CppSQLite3DB* commonDb, CppSQLite3DB* userDb);
private:
DBUpgrade();
int GetDBVersion(CppSQLite3DB* userDb);
int SetDBVersion(CppSQLite3DB* userDb, int version);
UpgradePtr GetUpgradeFunc(int version);
private:
map<int, UpgradePtr> _upgradeMap;
};
}
#endif //DBUPGRADE_H_
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.