blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b0ff0e28060c4733c01cda35e797e2849cc7b2ee | ec4371c240fac47ec87269672af4949134046eaf | /XiaCaoJun_Teacher/XPlay/app/src/main/cpp/IObserver.h | 9c756b8c4e0204f9bfe1c45f07bfceb649cb1d19 | [] | no_license | jiaquan11/2020AndroidPro | 032f5054058b89bbd060f83b34eb593785cf0683 | 61158a754314ab5e13b1856f4e7a4ae55394ffef | refs/heads/master | 2021-12-03T07:54:33.155573 | 2021-11-27T09:05:47 | 2021-11-27T09:05:47 | 249,470,685 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 568 | h | //
// Created by jiaqu on 2020/4/6.
//
#ifndef XPLAY_IOBSERVER_H
#define XPLAY_IOBSERVER_H
#include "XData.h"
#include "XThread.h"
#include <vector>
#include <mutex>
//观察者和主体
class IObserver : public XThread {
public:
//观察者接收数据函数
virtual void Update(XData data) {}
//主体函数 添加观察者(线程安全)
void AddObs(IObserver *obs);
//通知所有观察者 (线程安全)
void Notify(XData data);
protected:
std::vector<IObserver *> obss;
std::mutex mux;
};
#endif //XPLAY_IOBSERVER_H
| [
"913882743@qq.com"
] | 913882743@qq.com |
dda3b8761487b3e54fad27b2872de1c33b59b8f5 | d4cdc06cdef352add4c6bcd9b300e419d03b7568 | /BGPsource/OpenGL 3.0/chapter_8/multiple_lights/src/example.h | f3f2e9dc315fcc86e5ee166b1c6f699cac743763 | [] | no_license | QtOpenGL/Animation-Retargeter-Qt-2 | f2ce024c6895a9640b92057bb2ae2f7d253f123a | 1619072d0aed8073fa5311a33ac9523aa0d95e20 | refs/heads/master | 2021-04-15T10:59:36.433919 | 2018-01-26T01:06:10 | 2018-01-26T01:06:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 653 | h | #ifndef _EXAMPLE_H
#define _EXAMPLE_H
#ifdef _WIN32
#include <windows.h>
#endif
#include <vector>
#include <string>
#include "terrain.h"
#include "targa.h"
class GLSLProgram;
using std::vector;
using std::string;
class Example
{
public:
Example();
virtual ~Example();
bool init();
void prepare(float dt);
void render();
void shutdown();
void onResize(int width, int height);
private:
vector<float> calculateNormalMatrix(const float* modelviewMatrix);
Terrain m_terrain;
GLSLProgram* m_GLSLProgram;
TargaImage m_grassTexture;
GLuint m_grassTexID;
float m_angle;
float m_lightPosZ;
};
#endif
| [
"alex.handby@gmail.com"
] | alex.handby@gmail.com |
35e6afacaa85fde819f943923aea5bf0d994b0ed | b71b8bd385c207dffda39d96c7bee5f2ccce946c | /testcases/CWE416_Use_After_Free/CWE416_Use_After_Free__new_delete_int_06.cpp | c5e97670ffbd77a5cce670fc3be1e96a43d2b86e | [] | no_license | Sporknugget/Juliet_prep | e9bda84a30bdc7938bafe338b4ab2e361449eda5 | 97d8922244d3d79b62496ede4636199837e8b971 | refs/heads/master | 2023-05-05T14:41:30.243718 | 2021-05-25T16:18:13 | 2021-05-25T16:18:13 | 369,334,230 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,496 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE416_Use_After_Free__new_delete_int_06.cpp
Label Definition File: CWE416_Use_After_Free__new_delete.label.xml
Template File: sources-sinks-06.tmpl.cpp
*/
/*
* @description
* CWE: 416 Use After Free
* BadSource: Allocate data using new, initialize memory block, and Deallocate data using delete
* GoodSource: Allocate data using new and initialize memory block
* Sinks:
* GoodSink: Do nothing
* BadSink : Use data after delete
* Flow Variant: 06 Control flow: if(STATIC_CONST_FIVE==5) and if(STATIC_CONST_FIVE!=5)
*
* */
#include "std_testcase.h"
#include <wchar.h>
/* The variable below is declared "const", so a tool should be able
to identify that reads of this will always give its initialized
value. */
static const int STATIC_CONST_FIVE = 5;
namespace CWE416_Use_After_Free__new_delete_int_06
{
#ifndef OMITBAD
void bad()
{
int * data;
/* Initialize data */
data = NULL;
{
data = new int;
*data = 5;
/* POTENTIAL FLAW: Delete data in the source - the bad sink attempts to use data */
delete data;
}
{
/* POTENTIAL FLAW: Use of data that may have been deleted */
printIntLine(*data);
/* POTENTIAL INCIDENTAL - Possible memory leak here if data was not deleted */
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G1() - use badsource and goodsink by changing the second STATIC_CONST_FIVE==5 to STATIC_CONST_FIVE!=5 */
static void goodB2G1()
{
int * data;
/* Initialize data */
data = NULL;
{
data = new int;
*data = 5;
/* POTENTIAL FLAW: Delete data in the source - the bad sink attempts to use data */
delete data;
}
{
/* FIX: Don't use data that may have been deleted already */
/* POTENTIAL INCIDENTAL - Possible memory leak here if data was not deleted */
/* do nothing */
; /* empty statement needed for some flow variants */
}
}
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the second if */
static void goodB2G2()
{
int * data;
/* Initialize data */
data = NULL;
{
data = new int;
*data = 5;
/* POTENTIAL FLAW: Delete data in the source - the bad sink attempts to use data */
delete data;
}
{
/* FIX: Don't use data that may have been deleted already */
/* POTENTIAL INCIDENTAL - Possible memory leak here if data was not deleted */
/* do nothing */
; /* empty statement needed for some flow variants */
}
}
/* goodG2B1() - use goodsource and badsink by changing the first STATIC_CONST_FIVE==5 to STATIC_CONST_FIVE!=5 */
static void goodG2B1()
{
int * data;
/* Initialize data */
data = NULL;
{
data = new int;
*data = 5;
/* FIX: Do not delete data in the source */
}
{
/* POTENTIAL FLAW: Use of data that may have been deleted */
printIntLine(*data);
/* POTENTIAL INCIDENTAL - Possible memory leak here if data was not deleted */
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the first if */
static void goodG2B2()
{
int * data;
/* Initialize data */
data = NULL;
{
data = new int;
*data = 5;
/* FIX: Do not delete data in the source */
}
{
/* POTENTIAL FLAW: Use of data that may have been deleted */
printIntLine(*data);
/* POTENTIAL INCIDENTAL - Possible memory leak here if data was not deleted */
}
}
void good()
{
goodB2G1();
goodB2G2();
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE416_Use_After_Free__new_delete_int_06; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"jaredzap@rams.colostate.edu"
] | jaredzap@rams.colostate.edu |
f8ba74fa1d6f584d05599feb000dfe5f787e8110 | 9af6b48d14157cf533fb332b43a3b77ec868c8f1 | /Assignment 4/Error.cpp | 928ef6e8e1122d6eff58281da517eaf75cb8a731 | [] | no_license | RickyB01/Object-Oriented-Programming | 570b9fd9ce0776a2045fc170f240e94d62073a4e | 53c73b2cbb1595c983863a9b29f207e6c6d00615 | refs/heads/master | 2020-07-28T09:47:01.001367 | 2019-09-19T14:35:53 | 2019-09-19T14:35:53 | 209,383,851 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,491 | cpp | // Final Project Milestone 3
/***********************************************************
// Name:Ricky Badyal
// Student Number:020028098
// Date:2018-10-15
// Email:jrbadyal@myseneca.ca
// Section:OOP244SAB
***********************************************************/
#include <iostream>
#include <cstring>
#include "Error.h"
using namespace std;
namespace aid {
Error::Error(const char * errorMessage) {
if (errorMessage == nullptr)
Erorrmsge = nullptr;
else if (strcmp(errorMessage, "") == 0)
Erorrmsge = nullptr;
else {
Erorrmsge = new char[strlen(errorMessage) + 1];
strncpy(Erorrmsge, errorMessage, strlen(errorMessage) + 1);
}
}
Error::~Error() {
delete[] Erorrmsge;
Erorrmsge = nullptr;
}
void Error::message(const char * str) {
delete[] Erorrmsge;
Erorrmsge = new char[strlen(str) + 1];
strncpy(Erorrmsge, str, (strlen(str) + 1));
}
void Error::clear() {
delete[] this->Erorrmsge;
Erorrmsge = nullptr;
}
bool Error::isClear() const {
if (Erorrmsge == nullptr)
return true;
else
return false;
}
bool Error::isEmpty() const {
if (Erorrmsge != 0) {
return false;
}
else {
return true;
}
}
const char * Error::message() const {
return Erorrmsge;
}
std::ostream& operator<<(std::ostream& ostr, const Error& tml) {
if (!tml.isClear()) {
ostr << tml.message();
}
return ostr;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
b192cc96139e9704faa45cfdcd7facbb3c9c230b | 64bba64a111e7c17887442435e42b81ec79d2946 | /DynamicFileRectangle/DynamicFileRectangle/Source.cpp | 5100ebe90d1f897bdcc9eabbab390b170fe2b942 | [] | no_license | geekguy100/MYFILES-cpp-developer-course | 2638cd9ed8734331371fc00a67c510710b6b3941 | fa5780c24320fdc355afecfe0ba0c9df5a201c27 | refs/heads/main | 2023-07-15T14:09:11.455565 | 2021-08-30T08:17:59 | 2021-08-30T08:17:59 | 367,965,748 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,954 | cpp | #include <iostream>
#include <vector>
#include <fstream>
#include "Rectangle.h"
using namespace std;
void populateVector(vector<Rectangle*> & v, ifstream & infile) noexcept;
void printRectangleData(const vector<Rectangle*> & rectangles) noexcept;
int main()
{
// Opening file
ifstream infile;
infile.open("rectangles.txt");
if (!infile)
{
cout << "Could not open 'rectangles.txt'. Terminating program..." << endl;
system("pause");
return 1;
}
// Creating and populating vector
cout << "File opened. Populating vector..." << endl;
vector<Rectangle*> rectangles;
populateVector(rectangles, infile);
printRectangleData(rectangles);
// Cleanup
cout << "Performing cleanup..." << endl;
infile.close();
for (Rectangle * r : rectangles)
delete r;
// Clearing the vector so we don't have any dangling pointers.
rectangles.clear();
cout << "Done" << endl;
cout << endl;
system("pause");
return 0;
}
// Populates the vector with dynamically allocated Rectangle objects.
void populateVector(vector<Rectangle*> & v, ifstream & infile) noexcept
{
while (!infile.eof())
{
int width;
int length;
infile >> width;
infile >> length;
Rectangle * rect{ new Rectangle(length, width) };
v.push_back(rect);
}
}
// Prints the perimeters and areas of the rectangles we created.
void printRectangleData(const vector<Rectangle*> & rectangles) noexcept
{
ofstream outfile;
outfile.open("output.txt");
for (int i = 0; i < rectangles.size(); ++i)
{
cout << "Rectangle " << i << ":" << endl;
outfile << "Rectangle " << i << ":" << endl;
cout << "\tPerimeter: " << rectangles[i]->perimeter() << endl;
outfile << "\tPerimeter: " << rectangles[i]->perimeter() << endl;
cout << "\tArea: " << rectangles[i]->area() << endl;
outfile << "\tArea: " << rectangles[i]->area() << endl;
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
outfile << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
}
outfile.close();
} | [
"kyle.grenier11@gmail.com"
] | kyle.grenier11@gmail.com |
74e28025c078a31b180a3baa64e3663509167f25 | ec8b7bf40612fe06874b3b6e308d45fc563e70a1 | /Purchase.cpp | 14fa0732ad1107009169f9c9eb1d95dc47d9126a | [] | no_license | faust4exe/expensesQt | 2e07ec403412be93f4ccd7c5ac7026980efbeae8 | aa436788c2c391d1d666df0d8e2a20feaee3ec83 | refs/heads/master | 2021-01-19T14:06:29.942123 | 2014-01-19T22:33:10 | 2014-01-19T22:33:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 918 | cpp | #include "Purchase.h"
Purchase::Purchase(void)
{
parameters << "productId" << "purchaseDate" << "purchaseCantitaty";
}
Purchase::~Purchase(void)
{
}
const QString Purchase::data(const QString &name) const
{
if (!parameters.contains(name))
return QString();
const int index = paramIndex(name);
switch(index){
case 0:
return QString::number(m_prodId);
break;
case 1:
return m_purchaseDate.toString(st_dateFormat);
break;
case 2:
return QString::number(m_purchaseCantity);
break;
}
return QString();
}
bool Purchase::setData(const QString &name, const QString &value)
{
if (!parameters.contains(name))
return false;
const int index = paramIndex(name);
switch(index){
case 0:
m_prodId = value.toInt();
break;
case 1:
m_purchaseDate = QDate::fromString(value, st_dateFormat);
break;
case 2:
m_purchaseCantity = value.toDouble();
break;
}
return true;
} | [
"gitorious@mail.ru"
] | gitorious@mail.ru |
37a452a02769ab13c00ccaaf8223f11494ddacbc | 6a30e6a0548ee99109da995fe2cee6a4317d39ff | /DCCache.h | 171b61536c023526919c52f2eeb3d155cf9b3f24 | [] | no_license | daniuu/YJS-PIS-2018 | 9f9206bd9a1dcd6af3463ffd54423d00353d94f6 | 1f5c2f1a5d68915bb316e62cafc4630118b80921 | refs/heads/master | 2020-06-02T00:43:57.247679 | 2019-06-09T08:45:47 | 2019-06-09T08:45:47 | 190,982,640 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 639 | h | // DCCache.h: interface for the CDCCache class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DCCACHE_H__310F5F48_8A8A_45A0_BDB2_D71981F7C51C__INCLUDED_)
#define AFX_DCCACHE_H__310F5F48_8A8A_45A0_BDB2_D71981F7C51C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
const int CIMAGE_DC_CACHE_SIZE = 4;
class CDCCache
{
public:
CDCCache() throw();
~CDCCache() throw();
HDC GetDC() const throw();
void ReleaseDC( HDC ) const throw();
private:
HDC m_ahDCs[CIMAGE_DC_CACHE_SIZE];
};
#endif // !defined(AFX_DCCACHE_H__310F5F48_8A8A_45A0_BDB2_D71981F7C51C__INCLUDED_)
| [
"44184349+LiaoHuanjian@users.noreply.github.com"
] | 44184349+LiaoHuanjian@users.noreply.github.com |
5dde47b6010a0be83bd0492c3e87332797cfda0d | a4ace471f3a34bfe7bd9aa57470aaa6e131012a9 | /LeetCode/56_Merge-Intervals/56_Merge-Intervals.cpp | 58caa337d0b5f3defc2e5368ac2bd4c35eee8556 | [] | no_license | luqian2017/Algorithm | 52beca787056e8418f74d383f4ea697f5f8934b7 | 17f281fb1400f165b4c5f8bdd3e0500f6c765b45 | refs/heads/master | 2023-08-17T05:37:14.886220 | 2023-08-08T06:10:28 | 2023-08-08T06:10:28 | 143,100,735 | 1 | 3 | null | 2020-10-19T07:05:21 | 2018-08-01T03:45:48 | C++ | UTF-8 | C++ | false | false | 561 | cpp | class Solution {
public:
vector<vector<int>> merge(vector<vector<int>>& intervals) {
int n = intervals.size();
sort(intervals.begin(), intervals.end()); //按照区间左值排序
vector<vector<int>> ans;
int i = 0;
while (i < n) {
int L = intervals[i][0], R = intervals[i][1];
do {
R = max(R, intervals[i][1]);
i++;
} while (i < n && R >= intervals[i][0]);
ans.push_back({L, R});
}
return ans;
}
}; | [
"luqian.ncsu@gmail.com"
] | luqian.ncsu@gmail.com |
6efe8d5f51e284de207de31d9e60fbaaec186785 | 9c139237cca9ba3040f40f9c996cd610ae22db21 | /practica2.2/replicacion-chat/Chat.cc | 201f9f582b7f63a57ff642cb2c28854adb3eb138 | [] | no_license | DFaouaz/RVR_UCM_2019-20 | 8e32da5912d6d3601fb307cc5234f2246e1e8201 | 54aa3a466b51a38a92e8e7b1d4997e6f69ab2056 | refs/heads/master | 2022-11-04T22:08:08.717078 | 2020-06-21T15:27:06 | 2020-06-21T15:27:06 | 258,138,843 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,579 | cc | #include "Chat.h"
void ChatMessage::to_bin()
{
alloc_data(MESSAGE_SIZE);
memset(_data, 0, MESSAGE_SIZE);
// Serializar los campos type, nick y message en el buffer _data
// Type
memcpy(_data, (void *)&type, sizeof(type));
// Nick
char *pos = _data + sizeof(type);
nick[7] = '\0';
memcpy(pos, nick.c_str(), 8);
// Message
pos = pos + 8;
message[79] = '\0';
memcpy(pos, message.c_str(), 80);
}
int ChatMessage::from_bin(char *bobj)
{
try
{
alloc_data(MESSAGE_SIZE);
memcpy(static_cast<void *>(_data), bobj, MESSAGE_SIZE);
//Reconstruir la clase usando el buffer _data
// Type
memcpy((void *)&type, _data, sizeof(type));
// Nick
char *pos = _data + sizeof(type);
char name[8];
memcpy(name, pos, 8);
name[7] = '\0';
nick = name;
// Message
pos = pos + 8;
char message[80];
memcpy(message, pos, 80);
message[79] = '\0';
this->message = message;
return 0;
}
catch (std::exception exception)
{
}
return -1;
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void ChatServer::do_messages()
{
while (true)
{
//Recibir Mensajes en y en función del tipo de mensaje
// - LOGIN: Añadir al vector clients
// - LOGOUT: Eliminar del vector clients
// - MESSAGE: Reenviar el mensaje a todos los clientes (menos el emisor)
ChatMessage *obj = new ChatMessage();
Socket *client = &socket;
socket.recv(*obj, client);
// LOGIN
if (obj->type == ChatMessage::LOGIN)
{
for (Socket *c : clients)
{
if (*c == *client)
{
std::cout << "LOGGING ERROR: " << *client << "\n";
delete client;
client == nullptr;
}
}
if (client == nullptr)
continue;
clients.push_back(client);
std::cout << "CLIENT LOGGED: " << *client << "\n";
}
// LOGOUT
else if (obj->type == ChatMessage::LOGOUT)
{
Socket *aux = nullptr;
int i = 0;
while (aux == nullptr && i < clients.size())
{
if (*clients[i] == *client)
aux = clients[i];
i++;
}
// No encontrado en clientes
if (aux == nullptr)
{
delete client;
continue;
}
else
{
socket.send(*obj, *aux);
auto it = std::find(clients.begin(), clients.end(), aux);
clients.erase(it);
std::cout << "CLIENT LOGGED OUT: " << *aux << "\n";
delete aux;
delete client;
}
}
// MESSAGE
else if (obj->type == ChatMessage::MESSAGE)
{
for (auto *c : clients)
{
if (*c == *client)
continue;
socket.send(*obj, *c);
}
delete client;
printf("Enviando \"%s\" a todos los usuarios menos al remitente\n", obj->message.c_str());
}
}
}
void ChatClient::login()
{
std::string msg;
ChatMessage em(nick, msg);
em.type = ChatMessage::LOGIN;
socket.send(em, socket);
}
void ChatClient::logout()
{
std::string msg;
ChatMessage em(nick, msg);
em.type = ChatMessage::LOGOUT;
socket.send(em, socket);
}
void ChatClient::input_thread()
{
while (true)
{
// Leer stdin con std::getline
std::string msg;
if (!std::getline(std::cin, msg))
break;
if (!strcmp(msg.c_str(), "logout"))
break;
// Enviar al servidor usando socket
ChatMessage em(nick, msg);
em.type = ChatMessage::MESSAGE;
socket.send(em, socket);
}
}
void ChatClient::net_thread()
{
while (true)
{
// Recibir Mensajes de red
std::string msg;
ChatMessage em;
if (socket.recv(em) < 0)
break;
if (em.type == ChatMessage::LOGOUT)
break;
// Mostrar en pantalla el mensaje de la forma "nick: mensaje"
printf("%s: %s\n", em.nick.c_str(), em.message.c_str());
}
}
| [
"dfaouaz@ucm.es"
] | dfaouaz@ucm.es |
5d82a0a43b090506b6429f2c3d249be1f1df437f | e81c48994d392bd0b23aa4b987ad2a358d84c04a | /backend/addon/SimpleAnomalyDetector.cpp | 5ba26764403a32c8c8821b0776c3d52ace594c62 | [] | no_license | shaigundersen/AnomalyDetectionWebApp | 521b099a619b7ce62d0285903304f7bf901d3825 | f7975298388b9524425e297f2979788ec27b98fa | refs/heads/master | 2023-04-20T11:32:56.222440 | 2021-05-30T18:58:10 | 2021-05-30T18:58:10 | 368,505,492 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,517 | cpp | #include "SimpleAnomalyDetector.h"
#include <vector>
SimpleAnomalyDetector::SimpleAnomalyDetector() {
threshold = 0.9;
}
SimpleAnomalyDetector::~SimpleAnomalyDetector() {
// TODO Auto-generated destructor stub
}
Point** SimpleAnomalyDetector::toPoints(vector<float> x, vector<float> y) {
Point** ps = new Point * [x.size()];
for (size_t i = 0;i < x.size();i++) {
ps[i] = new Point(x[i], y[i]);
}
return ps;
}
float SimpleAnomalyDetector::findThreshold(Point** ps, size_t len, Line rl) {
float max = 0;
for (size_t i = 0;i < len;i++) {
float d = abs(ps[i]->y - rl.f(ps[i]->x));
if (d > max)
max = d;
}
return max;
}
void SimpleAnomalyDetector::learnNormal(const TimeSeries& ts) {
vector<string> atts = ts.gettAttributes();
size_t len = ts.getRowSize();
vector<float> rows(atts.size());
vector<vector<float>> vals(atts.size(), vector<float>(len));
for (size_t i = 0;i < atts.size();i++) {
vector<float> x = ts.getAttributeData(atts[i]);
for (size_t j = 0;j < len;j++) {
vals[i][j] = x[j];
}
}
for (size_t i = 0;i < atts.size();i++) {
string f1 = atts[i];
float max = 0;
size_t jmax = 0;
for (size_t j = i + 1;j < atts.size();j++) {
float p = abs(pearson(&vals[i][0], &vals[j][0], len));
if (p > max) {
max = p;
jmax = j;
}
}
string f2 = atts[jmax];
Point** ps = toPoints(ts.getAttributeData(f1), ts.getAttributeData(f2));
learnHelper(ts, max, f1, f2, ps);
// delete points
for (size_t k = 0;k < len;k++)
delete ps[k];
delete[] ps;
}
}
void SimpleAnomalyDetector::learnHelper(const TimeSeries& ts, float p/*pearson*/, string f1, string f2, Point** ps) {
if (p > threshold) {
size_t len = ts.getRowSize();
correlatedFeatures c;
c.feature1 = f1;
c.feature2 = f2;
c.corrlation = p;
c.lin_reg = linear_reg(ps, len);
c.threshold = findThreshold(ps, len, c.lin_reg) * 1.1; // 10% increase
cf.push_back(c);
}
}
vector<AnomalyReport> SimpleAnomalyDetector::detect(const TimeSeries& ts) {
vector<AnomalyReport> v;
for_each(cf.begin(), cf.end(), [&v, &ts, this](correlatedFeatures c) {
vector<float> x = ts.getAttributeData(c.feature1);
vector<float> y = ts.getAttributeData(c.feature2);
for (size_t i = 0;i < x.size();i++) {
if (isAnomalous(x[i], y[i], c)) {
string d = c.feature1 + "~~" + c.feature2;
v.push_back(AnomalyReport(d, (i + 1)));
}
}
});
return v;
}
bool SimpleAnomalyDetector::isAnomalous(float x, float y, correlatedFeatures c) {
return (abs(y - c.lin_reg.f(x)) > c.threshold);
}
| [
"shai.gundersen@gmail.com"
] | shai.gundersen@gmail.com |
bd3c0a70dbf2d6aa228b633203e3e524c0c2ee27 | 26807b046fbd9c37c7ca49c151f197ee213dda14 | /src/libasr/pass/global_symbols.h | 0f74a5550ffd23f3693a6463495c11198a2ce55f | [
"BSD-3-Clause"
] | permissive | yundantianchang/lfortran | 59bb1a0178401c04c53a5d379e1074f0d5d8cd48 | e9bcc263fbae5e0d7b9881f616c28029343d1749 | refs/heads/master | 2023-07-08T15:30:06.832080 | 2023-06-26T18:40:59 | 2023-06-26T18:40:59 | 195,522,974 | 0 | 0 | NOASSERTION | 2019-07-06T09:42:05 | 2019-07-06T09:42:04 | null | UTF-8 | C++ | false | false | 373 | h | #ifndef LFORTRAN_PASS_GLOBAL_SYMBOLS_H
#define LFORTRAN_PASS_GLOBAL_SYMBOLS_H
#include <libasr/asr.h>
#include <libasr/utils.h>
namespace LCompilers {
void pass_wrap_global_syms_into_module(Allocator &al,
ASR::TranslationUnit_t &unit,
const LCompilers::PassOptions& pass_options);
} // namespace LCompilers
#endif // LFORTRAN_PASS_GLOBAL_SYMBOLS_H
| [
"gdp.1807@gmail.com"
] | gdp.1807@gmail.com |
5f763459250fffa797a63ba80b070da0fbae2f81 | f1d64c5e154bf8b1b65f9032dc5b9ec26b4bc9f1 | /Source/Strings.cpp | b7cc51cfe028c9a756f521eab456fcd2dae799b3 | [
"BSD-3-Clause"
] | permissive | fcccode/Hookshot | 5e74e361923a581a931fce15a7176817a0e1871e | 69410a7da7190152fbded028f78e6cf30b043045 | refs/heads/master | 2022-04-22T13:47:59.992014 | 2020-04-24T04:34:25 | 2020-04-24T04:34:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,583 | cpp | /******************************************************************************
* Hookshot
* General-purpose library for injecting DLLs and hooking function calls.
******************************************************************************
* Authored by Samuel Grossman
* Copyright (c) 2019-2020
**************************************************************************//**
* @file Strings.cpp
* Implementation of functions for manipulating Hookshot-specific strings.
*****************************************************************************/
#include "ApiWindows.h"
#include "DependencyProtect.h"
#include "Globals.h"
#include "TemporaryBuffer.h"
#include <cstdlib>
#include <intrin.h>
#include <psapi.h>
#include <shlobj.h>
#include <sstream>
#include <string>
#include <string_view>
namespace Hookshot
{
namespace Strings
{
// -------- INTERNAL CONSTANTS ------------------------------------- //
/// File extension of the dynamic-link library form of Hookshot.
#ifdef HOOKSHOT64
static constexpr std::wstring_view kStrHookshotDynamicLinkLibraryExtension = L".64.dll";
#else
static constexpr std::wstring_view kStrHookshotDynamicLinkLibraryExtension = L".32.dll";
#endif
/// File extension of the executable form of Hookshot.
#ifdef HOOKSHOT64
static constexpr std::wstring_view kStrHookshotExecutableExtension = L".64.exe";
#else
static constexpr std::wstring_view kStrHookshotExecutableExtension = L".32.exe";
#endif
/// File extension of the executable form of Hookshot but targeting the opposite processor architecture.
#ifdef HOOKSHOT64
static constexpr std::wstring_view kStrHookshotExecutableOtherArchitectureExtension = L".32.exe";
#else
static constexpr std::wstring_view kStrHookshotExecutableOtherArchitectureExtension = L".64.exe";
#endif
/// File extension for a Hookshot configuration file.
static constexpr std::wstring_view kStrHookshotConfigurationFileExtension = L".ini";
/// File extension for a Hookshot log file.
static constexpr std::wstring_view kStrHookshotLogFileExtension = L".log";
/// File extension for all hook modules.
#ifdef HOOKSHOT64
static constexpr std::wstring_view kStrHookModuleExtension = L".HookModule.64.dll";
#else
static constexpr std::wstring_view kStrHookModuleExtension = L".HookModule.32.dll";
#endif
// -------- INTERNAL FUNCTIONS ------------------------------------- //
/// Generates the value for kStrProductName; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetProductName(void)
{
TemporaryBuffer<wchar_t> buf;
LoadString(Globals::GetInstanceHandle(), IDS_HOOKSHOT_PRODUCT_NAME, (wchar_t*)buf, buf.Count());
return (std::wstring(buf));
}
/// Generates the base name of the current running form of Hookshot, minus the extension.
/// For example: "C:\Directory\Program\Hookshot.32.dll" -> "Hookshot"
/// @return Base name without extension.
static std::wstring GetHookshotBaseNameWithoutExtension(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(Globals::GetInstanceHandle(), buf, (DWORD)buf.Count());
wchar_t* hookshotBaseName = wcsrchr(buf, L'\\');
if (nullptr == hookshotBaseName)
hookshotBaseName = buf;
else
hookshotBaseName += 1;
// Hookshot module filenames are expected to end with a double-extension, the first specifying the platform and the second the actual file type.
// Therefore, look for the last two dot characters and truncate them.
wchar_t* const lastDot = wcsrchr(hookshotBaseName, L'.');
if (nullptr == lastDot)
return (std::wstring(hookshotBaseName));
*lastDot = L'\0';
wchar_t* const secondLastDot = wcsrchr(hookshotBaseName, L'.');
if (nullptr == secondLastDot)
return (std::wstring(hookshotBaseName));
*secondLastDot = L'\0';
return (std::wstring(hookshotBaseName));
}
/// Generates the fully-qualified path of the current running form of Hookshot, minus the extension.
/// This is useful for determining the correct path of the next file or module to load.
/// For example: "C:\Directory\Program\Hookshot.32.dll" -> "C:\Directory\Program\Hookshot"
/// @return Fully-qualified base path.
static std::wstring GetHookshotCompleteFilenameWithoutExtension(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(Globals::GetInstanceHandle(), buf, (DWORD)buf.Count());
// Hookshot module filenames are expected to end with a double-extension, the first specifying the platform and the second the actual file type.
// Therefore, look for the last two dot characters and truncate them.
wchar_t* const lastDot = wcsrchr(buf, L'.');
if (nullptr == lastDot)
return (std::wstring(buf));
*lastDot = L'\0';
wchar_t* const secondLastDot = wcsrchr(buf, L'.');
if (nullptr == secondLastDot)
return (std::wstring(buf));
*secondLastDot = L'\0';
return (std::wstring(buf));
}
/// Generates the value for kStrExecutableBaseName; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetExecutableBaseName(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(nullptr, buf, (DWORD)buf.Count());
wchar_t* executableBaseName = wcsrchr(buf, L'\\');
if (nullptr == executableBaseName)
executableBaseName = buf;
else
executableBaseName += 1;
return (std::wstring(executableBaseName));
}
/// Generates the value for kStrExecutableDirectoryName; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetExecutableDirectoryName(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(nullptr, buf, (DWORD)buf.Count());
wchar_t* const lastBackslash = wcsrchr(buf, L'\\');
if (nullptr == lastBackslash)
buf[0] = L'\0';
else
lastBackslash[1] = L'\0';
return (std::wstring(buf));
}
/// Generates the value for kStrExecutableCompleteFilename; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetExecutableCompleteFilename(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(nullptr, buf, (DWORD)buf.Count());
return (std::wstring(buf));
}
/// Generates the value for kStrHookshotBaseName; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetHookshotBaseName(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(Globals::GetInstanceHandle(), buf, (DWORD)buf.Count());
wchar_t* hookshotBaseName = wcsrchr(buf, L'\\');
if (nullptr == hookshotBaseName)
hookshotBaseName = buf;
else
hookshotBaseName += 1;
return (std::wstring(hookshotBaseName));
}
/// Generates the value for kStrHookshotDirectoryName; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetHookshotDirectoryName(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(Globals::GetInstanceHandle(), buf, (DWORD)buf.Count());
wchar_t* const lastBackslash = wcsrchr(buf, L'\\');
if (nullptr == lastBackslash)
buf[0] = L'\0';
else
lastBackslash[1] = L'\0';
return (std::wstring(buf));
}
/// Generates the value for kStrHookshotCompleteFilename; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetHookshotCompleteFilename(void)
{
TemporaryBuffer<wchar_t> buf;
GetModuleFileName(Globals::GetInstanceHandle(), buf, (DWORD)buf.Count());
return (std::wstring(buf));
}
/// Generates the value for kStrHookshotConfigurationFilename; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetHookshotConfigurationFilename(void)
{
return GetExecutableDirectoryName() + GetHookshotBaseNameWithoutExtension() + kStrHookshotConfigurationFileExtension.data();
}
/// Generates the value for kStrHookshotLogFilename; see documentation of this run-time constant for more information.
/// @return Corresponding run-time constant value.
static std::wstring GetHookshotLogFilename(void)
{
std::wstringstream logFilename;
PWSTR knownFolderPath;
const HRESULT result = SHGetKnownFolderPath(FOLDERID_Desktop, 0, nullptr, &knownFolderPath);
if (S_OK == result)
{
logFilename << knownFolderPath << L'\\';
CoTaskMemFree(knownFolderPath);
}
logFilename << GetHookshotBaseNameWithoutExtension() << L'_' << GetExecutableBaseName() << L'_' << Globals::GetCurrentProcessId() << kStrHookshotLogFileExtension;
return logFilename.str();
}
/// Generates the value for kStrHookshotDynamicLinkLibraryFilename; see documentation of this run-time constant for more information.
/// @return coorresponding run-time constant value.
static std::wstring GetHookshotDynamicLinkLibraryFilename(void)
{
return GetHookshotCompleteFilenameWithoutExtension() + kStrHookshotDynamicLinkLibraryExtension.data();
}
/// Generates the value for kStrHookshotExecutableFilename; see documentation of this run-time constant for more information.
/// @return coorresponding run-time constant value.
static std::wstring GetHookshotExecutableFilename(void)
{
return GetHookshotCompleteFilenameWithoutExtension() + kStrHookshotExecutableExtension.data();
}
/// Generates the value for kStrHookshotExecutableOtherArchitectureFilename; see documentation of this run-time constant for more information.
/// @return coorresponding run-time constant value.
static std::wstring GetHookshotExecutableOtherArchitectureFilename(void)
{
return GetHookshotCompleteFilenameWithoutExtension() + kStrHookshotExecutableOtherArchitectureExtension.data();
}
// -------- INTERNAL CONSTANTS ------------------------------------- //
// Used to implement run-time constants; see "Strings.h" for documentation.
static const std::wstring kStrProductNameImpl(GetProductName());
static const std::wstring kStrExecutableBaseNameImpl(GetExecutableBaseName());
static const std::wstring kStrExecutableDirectoryNameImpl(GetExecutableDirectoryName());
static const std::wstring kStrExecutableCompleteFilenameImpl(GetExecutableCompleteFilename());
static const std::wstring kStrHookshotBaseNameImpl(GetHookshotBaseName());
static const std::wstring kStrHookshotDirectoryNameImpl(GetHookshotDirectoryName());
static const std::wstring kStrHookshotCompleteFilenameImpl(GetHookshotCompleteFilename());
static const std::wstring kStrHookshotConfigurationFilenameImpl(GetHookshotConfigurationFilename());
static const std::wstring kStrHookshotLogFilenameImpl(GetHookshotLogFilename());
static const std::wstring kStrHookshotDynamicLinkLibraryFilenameImpl(GetHookshotDynamicLinkLibraryFilename());
static const std::wstring kStrHookshotExecutableFilenameImpl(GetHookshotExecutableFilename());
static const std::wstring kStrHookshotExecutableOtherArchitectureFilenameImpl(GetHookshotExecutableOtherArchitectureFilename());
// -------- RUN-TIME CONSTANTS ------------------------------------- //
// See "Strings.h" for documentation.
extern const std::wstring_view kStrProductName(kStrProductNameImpl);
extern const std::wstring_view kStrExecutableBaseName(kStrExecutableBaseNameImpl);
extern const std::wstring_view kStrExecutableDirectoryName(kStrExecutableDirectoryNameImpl);
extern const std::wstring_view kStrExecutableCompleteFilename(kStrExecutableCompleteFilenameImpl);
extern const std::wstring_view kStrHookshotBaseName(kStrHookshotBaseNameImpl);
extern const std::wstring_view kStrHookshotDirectoryName(kStrHookshotDirectoryNameImpl);
extern const std::wstring_view kStrHookshotCompleteFilename(kStrHookshotCompleteFilenameImpl);
extern const std::wstring_view kStrHookshotConfigurationFilename(kStrHookshotConfigurationFilenameImpl);
extern const std::wstring_view kStrHookshotLogFilename(kStrHookshotLogFilenameImpl);
extern const std::wstring_view kStrHookshotDynamicLinkLibraryFilename(kStrHookshotDynamicLinkLibraryFilenameImpl);
extern const std::wstring_view kStrHookshotExecutableFilename(kStrHookshotExecutableFilenameImpl);
extern const std::wstring_view kStrHookshotExecutableOtherArchitectureFilename(kStrHookshotExecutableOtherArchitectureFilenameImpl);
// -------- FUNCTIONS ---------------------------------------------- //
// See "Strings.h" for documentation.
std::wstring HookModuleFilename(std::wstring_view moduleName)
{
return kStrExecutableDirectoryNameImpl + moduleName.data() + kStrHookModuleExtension.data();
}
// --------
std::wstring SystemErrorCodeString(const unsigned long systemErrorCode)
{
TemporaryBuffer<wchar_t> systemErrorString;
DWORD systemErrorLength = Protected::Windows_FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, systemErrorCode, 0, systemErrorString, systemErrorString.Count(), nullptr);
if (0 == systemErrorLength)
{
swprintf_s(systemErrorString, systemErrorString.Count(), L"System error %u.", (unsigned int)systemErrorCode);
}
else
{
for (; systemErrorLength > 0; --systemErrorLength)
{
if (L'\0' != systemErrorString[systemErrorLength] && !iswspace(systemErrorString[systemErrorLength]))
break;
systemErrorString[systemErrorLength] = L'\0';
}
}
return std::wstring(systemErrorString);
}
}
}
| [
"samuelgr@users.noreply.github.com"
] | samuelgr@users.noreply.github.com |
71d473ab1a603efd629f02f266620633d046e30b | ace4f40598e3a13d2b748351a5c8bb5de0a594fa | /entity.h | 1f25650895ebacd8ce59105da436cd8b2660b479 | [] | no_license | threat0day/Notebook | c8a9facd6b5093f9cdfcdae5e89a94f4be42b535 | 467f971e2825a7d8ae868f44392d67c970ad2a7c | refs/heads/master | 2020-03-22T14:11:19.291610 | 2018-07-08T10:56:02 | 2018-07-08T10:56:02 | 140,159,486 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 843 | h | #include <stdlib.h>
#include <string>
using namespace std;
struct Hobby;
struct User
{
int id;
string name;
string surname;
string birthday;
string adress;
string tel;
string email;
string description;
Hobby *hobby;
int SIZE_ARRAY = 0;
User(string name, string surname, string birthday, string adress, string tel, string email, string description)
{
this->id = 0;
this->name = name;
this->surname = surname;
this->birthday = birthday;
this->adress = adress;
this->tel = tel;
this->email = email;
this->description = description;
}
User()
{
}
};
struct Hobby
{
int id;
string name;
int SIZE_ARRAY = 0;
Hobby(string name)
{
this->id = 0;
this->name = name;
}
Hobby() {}
};
| [
"user@mail.com"
] | user@mail.com |
0d22896544bfe51ed87c11f57d2d127c76e89d3a | da0e478aa133828b46cd9cdce321440806d6f5df | /IbeoSDK6.0.4/sdk/source/sdk/include/ibeo/common/sdk/datablocks/commands/ecucommands/CommandEcuSetFilter2010Importer2010.hpp | 2d5f069f120216cf4e02a7c9eaabce9990353ac0 | [] | no_license | mak6gulati/IBEO_sdk_check | 1a911fe1b5bd92bab2800fa40e4dfa219a10cd5b | 1114cbb88fa1a95e00b912a501582b3a42544379 | refs/heads/master | 2022-12-30T17:27:45.848079 | 2020-10-20T07:59:07 | 2020-10-20T07:59:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,591 | hpp | //==============================================================================
//!\file
//!
//!$$IBEO_LICENSE_BEGIN$$
//!Copyright (c) Ibeo Automotive Systems GmbH 2010-2019
//!All Rights Reserved.
//!
//!For more details, please refer to the accompanying file
//!IbeoLicense.txt.
//!$$IBEO_LICENSE_END$$
//!
//!\date Feb 16, 2018
//------------------------------------------------------------------------------
#pragma once
//==============================================================================
#include <ibeo/common/sdk/misc/WinCompatibility.hpp>
#include <ibeo/common/sdk/datablocks/SpecialRegisteredImporter.hpp>
#include <ibeo/common/sdk/datablocks/commands/ecucommands/CommandEcuSetFilterC.hpp>
//==============================================================================
namespace ibeo {
namespace common {
namespace sdk {
//==============================================================================
template<>
class SpecialImporter<Command2010, DataTypeId::DataType_Command2010, CommandEcuSetFilterC>
: public SpecialRegisteredImporter<Command2010, DataTypeId::DataType_Command2010, CommandEcuSetFilterC>
{
public:
static constexpr uint8_t commandBaseSize{4};
public:
SpecialImporter() : SpecialRegisteredImporter<Command2010, DataTypeId::DataType_Command2010, CommandEcuSetFilterC>()
{}
SpecialImporter(const SpecialImporter&) = delete;
SpecialImporter& operator=(const SpecialImporter&) = delete;
public:
virtual std::streamsize getSerializedSize(const CommandCBase& s) const override;
//========================================
//!\brief convert data from source to target type (deserialization)
//!\param[in, out] is Input data stream
//!\param[out] c Output container.
//!\param[in] header Ibeo DataHeader
//!\return \c true if serialization succeed, else: false
//!\note This method is to be called from outside for deserialization.
//----------------------------------------
virtual bool deserialize(std::istream& is, CommandCBase& s, const IbeoDataHeader& header) const override;
}; // CommandEcuSetFilter2010Importer2010
//==============================================================================
using CommandEcuSetFilter2010Importer2010
= SpecialImporter<Command2010, DataTypeId::DataType_Command2010, CommandEcuSetFilterC>;
//==============================================================================
} // namespace sdk
} // namespace common
} // namespace ibeo
//==============================================================================
| [
"mayank.gulati@automotive-ai.com"
] | mayank.gulati@automotive-ai.com |
6df48583cd27cc7c3682af33847a8385ce692237 | 8e684d3ec711cccdba71144db01da1af1d228412 | /CvGameCoreDLL/CvGlobals.h | 3a6646b23fc96cb2beb0390394ad49a5a133cb18 | [
"MIT"
] | permissive | Imperator-Knoedel/Sunset | 38f40e92ba5007b74e6ba7d7a4e6084d663f4391 | 19c95f4844586b96341f3474b58e0dacaae485b9 | refs/heads/master | 2021-07-09T17:14:42.617543 | 2020-06-23T10:47:31 | 2020-06-23T10:47:31 | 147,971,684 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 44,889 | h | #pragma once
// CvGlobals.h
#ifndef CIV4_GLOBALS_H
#define CIV4_GLOBALS_H
//#include "CvStructs.h"
//
// 'global' vars for Civ IV. singleton class.
// All globals and global types should be contained in this class
//
class FProfiler;
class CvDLLUtilityIFaceBase;
class CvRandom;
class CvGameAI;
class CMessageControl;
class CvDropMgr;
class CMessageQueue;
class CvSetupData;
class CvInitCore;
class CvMessageCodeTranslator;
class CvPortal;
class CvStatsReporter;
class CvDLLInterfaceIFaceBase;
class CvPlayerAI;
class CvDiplomacyScreen;
class CvCivicsScreen;
class CvWBUnitEditScreen;
class CvWBCityEditScreen;
class CMPDiplomacyScreen;
class FMPIManager;
class FAStar;
class CvInterface;
class CMainMenu;
class CvEngine;
class CvArtFileMgr;
class FVariableSystem;
class CvMap;
class CvPlayerAI;
class CvTeamAI;
class CvInterfaceModeInfo;
class CvWorldInfo;
class CvClimateInfo;
class CvSeaLevelInfo;
class CvColorInfo;
class CvPlayerColorInfo;
class CvAdvisorInfo;
class CvRouteModelInfo;
class CvRiverInfo;
class CvRiverModelInfo;
class CvWaterPlaneInfo;
class CvTerrainPlaneInfo;
class CvCameraOverlayInfo;
class CvAnimationPathInfo;
class CvAnimationCategoryInfo;
class CvEntityEventInfo;
class CvEffectInfo;
class CvAttachableInfo;
class CvCameraInfo;
class CvUnitFormationInfo;
class CvGameText;
class CvLandscapeInfo;
class CvTerrainInfo;
class CvBonusClassInfo;
class CvBonusInfo;
class CvFeatureInfo;
class CvCivilizationInfo;
class CvLeaderHeadInfo;
class CvTraitInfo;
class CvCursorInfo;
class CvThroneRoomCamera;
class CvThroneRoomInfo;
class CvThroneRoomStyleInfo;
class CvSlideShowInfo;
class CvSlideShowRandomInfo;
class CvWorldPickerInfo;
class CvSpaceShipInfo;
class CvUnitInfo;
class CvSpecialUnitInfo;
class CvInfoBase;
class CvYieldInfo;
class CvCommerceInfo;
class CvRouteInfo;
class CvImprovementInfo;
class CvGoodyInfo;
class CvBuildInfo;
class CvHandicapInfo;
class CvGameSpeedInfo;
class CvTurnTimerInfo;
class CvProcessInfo;
class CvVoteInfo;
class CvProjectInfo;
class CvBuildingClassInfo;
class CvBuildingInfo;
class CvSpecialBuildingInfo;
class CvUnitClassInfo;
class CvActionInfo;
class CvMissionInfo;
class CvControlInfo;
class CvCommandInfo;
class CvAutomateInfo;
class CvPromotionInfo;
class CvTechInfo;
class CvReligionInfo;
class CvCorporationInfo;
class CvSpecialistInfo;
class CvCivicOptionInfo;
class CvCivicInfo;
class CvDiplomacyInfo;
class CvEraInfo;
class CvHurryInfo;
class CvEmphasizeInfo;
class CvUpkeepInfo;
class CvCultureLevelInfo;
class CvVictoryInfo;
class CvQuestInfo;
class CvGameOptionInfo;
class CvMPOptionInfo;
class CvForceControlInfo;
class CvPlayerOptionInfo;
class CvGraphicOptionInfo;
class CvTutorialInfo;
class CvEventTriggerInfo;
class CvEventInfo;
class CvEspionageMissionInfo;
class CvUnitArtStyleTypeInfo;
class CvVoteSourceInfo;
class CvMainMenuInfo;
class CvGlobals
{
// friend class CvDLLUtilityIFace;
friend class CvXMLLoadUtility;
public:
// singleton accessor
DllExport inline static CvGlobals& getInstance();
DllExport CvGlobals();
DllExport virtual ~CvGlobals();
DllExport void init();
DllExport void uninit();
DllExport void clearTypesMap();
DllExport CvDiplomacyScreen* getDiplomacyScreen();
DllExport CMPDiplomacyScreen* getMPDiplomacyScreen();
DllExport FMPIManager*& getFMPMgrPtr();
DllExport CvPortal& getPortal();
DllExport CvSetupData& getSetupData();
DllExport CvInitCore& getInitCore();
DllExport CvInitCore& getLoadedInitCore();
DllExport CvInitCore& getIniInitCore();
DllExport CvMessageCodeTranslator& getMessageCodes();
DllExport CvStatsReporter& getStatsReporter();
DllExport CvStatsReporter* getStatsReporterPtr();
DllExport CvInterface& getInterface();
DllExport CvInterface* getInterfacePtr();
DllExport int getMaxCivPlayers() const;
#ifdef _USRDLL
CvMap& getMapINLINE() { return *m_map; } // inlined for perf reasons, do not use outside of dll
CvGameAI& getGameINLINE() { return *m_game; } // inlined for perf reasons, do not use outside of dll
#endif
DllExport CvMap& getMap();
DllExport CvGameAI& getGame();
DllExport CvGameAI *getGamePointer();
DllExport CvRandom& getASyncRand();
DllExport CMessageQueue& getMessageQueue();
DllExport CMessageQueue& getHotMessageQueue();
DllExport CMessageControl& getMessageControl();
DllExport CvDropMgr& getDropMgr();
DllExport FAStar& getPathFinder();
DllExport FAStar& getInterfacePathFinder();
DllExport FAStar& getStepFinder();
DllExport FAStar& getRouteFinder();
DllExport FAStar& getBorderFinder();
DllExport FAStar& getAreaFinder();
DllExport FAStar& getPlotGroupFinder();
DllExport NiPoint3& getPt3Origin();
DllExport std::vector<CvInterfaceModeInfo*>& getInterfaceModeInfo();
DllExport CvInterfaceModeInfo& getInterfaceModeInfo(InterfaceModeTypes e);
DllExport NiPoint3& getPt3CameraDir();
DllExport bool& getLogging();
DllExport bool& getRandLogging();
DllExport bool& getSynchLogging();
DllExport bool& overwriteLogs();
DllExport int* getPlotDirectionX();
DllExport int* getPlotDirectionY();
DllExport int* getPlotCardinalDirectionX();
DllExport int* getPlotCardinalDirectionY();
DllExport int* getCityPlotX();
DllExport int* getCityPlotY();
DllExport int* getCityPlotPriority();
DllExport int getXYCityPlot(int i, int j);
DirectionTypes* getTurnLeftDirection();
DirectionTypes getTurnLeftDirection(int i);
DirectionTypes* getTurnRightDirection();
DirectionTypes getTurnRightDirection(int i);
DllExport DirectionTypes getXYDirection(int i, int j);
// Leoreth
DllExport int* getCityPlot3X();
DllExport int* getCityPlot3Y();
// Leoreth: graphics paging
void setGraphicalDetailPagingEnabled(bool bEnabled);
bool getGraphicalDetailPagingEnabled();
int getGraphicalDetailPageInRange();
//
// Global Infos
// All info type strings are upper case and are kept in this hash map for fast lookup
//
DllExport int getInfoTypeForString(const char* szType, bool hideAssert = false) const; // returns the infos index, use this when searching for an info type string
DllExport void setInfoTypeFromString(const char* szType, int idx);
DllExport void infoTypeFromStringReset();
DllExport void addToInfosVectors(void *infoVector);
DllExport void infosReset();
DllExport int getNumWorldInfos();
std::vector<CvWorldInfo*>& getWorldInfo();
DllExport CvWorldInfo& getWorldInfo(WorldSizeTypes e);
DllExport int getNumClimateInfos();
std::vector<CvClimateInfo*>& getClimateInfo();
DllExport CvClimateInfo& getClimateInfo(ClimateTypes e);
DllExport int getNumSeaLevelInfos();
std::vector<CvSeaLevelInfo*>& getSeaLevelInfo();
DllExport CvSeaLevelInfo& getSeaLevelInfo(SeaLevelTypes e);
DllExport int getNumColorInfos();
std::vector<CvColorInfo*>& getColorInfo();
DllExport CvColorInfo& getColorInfo(ColorTypes e);
DllExport int getNumPlayerColorInfos();
std::vector<CvPlayerColorInfo*>& getPlayerColorInfo();
DllExport CvPlayerColorInfo& getPlayerColorInfo(PlayerColorTypes e);
int getNumAdvisorInfos();
std::vector<CvAdvisorInfo*>& getAdvisorInfo();
CvAdvisorInfo& getAdvisorInfo(AdvisorTypes e);
DllExport int getNumHints();
std::vector<CvInfoBase*>& getHints();
DllExport CvInfoBase& getHints(int i);
DllExport int getNumMainMenus();
std::vector<CvMainMenuInfo*>& getMainMenus();
DllExport CvMainMenuInfo& getMainMenus(int i);
DllExport int getNumRouteModelInfos();
std::vector<CvRouteModelInfo*>& getRouteModelInfo();
DllExport CvRouteModelInfo& getRouteModelInfo(int i);
DllExport int getNumRiverInfos();
std::vector<CvRiverInfo*>& getRiverInfo();
DllExport CvRiverInfo& getRiverInfo(RiverTypes e);
DllExport int getNumRiverModelInfos();
std::vector<CvRiverModelInfo*>& getRiverModelInfo();
DllExport CvRiverModelInfo& getRiverModelInfo(int i);
DllExport int getNumWaterPlaneInfos();
std::vector<CvWaterPlaneInfo*>& getWaterPlaneInfo();
DllExport CvWaterPlaneInfo& getWaterPlaneInfo(int i);
DllExport int getNumTerrainPlaneInfos();
std::vector<CvTerrainPlaneInfo*>& getTerrainPlaneInfo();
DllExport CvTerrainPlaneInfo& getTerrainPlaneInfo(int i);
DllExport int getNumCameraOverlayInfos();
std::vector<CvCameraOverlayInfo*>& getCameraOverlayInfo();
DllExport CvCameraOverlayInfo& getCameraOverlayInfo(int i);
DllExport int getNumAnimationPathInfos();
std::vector<CvAnimationPathInfo*>& getAnimationPathInfo();
DllExport CvAnimationPathInfo& getAnimationPathInfo(AnimationPathTypes e);
DllExport int getNumAnimationCategoryInfos();
std::vector<CvAnimationCategoryInfo*>& getAnimationCategoryInfo();
DllExport CvAnimationCategoryInfo& getAnimationCategoryInfo(AnimationCategoryTypes e);
DllExport int getNumEntityEventInfos();
std::vector<CvEntityEventInfo*>& getEntityEventInfo();
DllExport CvEntityEventInfo& getEntityEventInfo(EntityEventTypes e);
DllExport int getNumEffectInfos();
std::vector<CvEffectInfo*>& getEffectInfo();
DllExport CvEffectInfo& getEffectInfo(int i);
DllExport int getNumAttachableInfos();
std::vector<CvAttachableInfo*>& getAttachableInfo();
DllExport CvAttachableInfo& getAttachableInfo(int i);
DllExport int getNumCameraInfos();
std::vector<CvCameraInfo*>& getCameraInfo();
DllExport CvCameraInfo& getCameraInfo(CameraAnimationTypes eCameraAnimationNum);
DllExport int getNumUnitFormationInfos();
std::vector<CvUnitFormationInfo*>& getUnitFormationInfo();
DllExport CvUnitFormationInfo& getUnitFormationInfo(int i);
int getNumGameTextXML();
std::vector<CvGameText*>& getGameTextXML();
DllExport int getNumLandscapeInfos();
std::vector<CvLandscapeInfo*>& getLandscapeInfo();
DllExport CvLandscapeInfo& getLandscapeInfo(int iIndex);
DllExport int getActiveLandscapeID();
DllExport void setActiveLandscapeID(int iLandscapeID);
DllExport int getNumTerrainInfos();
std::vector<CvTerrainInfo*>& getTerrainInfo();
DllExport CvTerrainInfo& getTerrainInfo(TerrainTypes eTerrainNum);
int getNumBonusClassInfos();
std::vector<CvBonusClassInfo*>& getBonusClassInfo();
CvBonusClassInfo& getBonusClassInfo(BonusClassTypes eBonusNum);
DllExport int getNumBonusInfos();
std::vector<CvBonusInfo*>& getBonusInfo();
DllExport CvBonusInfo& getBonusInfo(BonusTypes eBonusNum);
DllExport int getNumFeatureInfos();
std::vector<CvFeatureInfo*>& getFeatureInfo();
DllExport CvFeatureInfo& getFeatureInfo(FeatureTypes eFeatureNum);
DllExport int& getNumPlayableCivilizationInfos();
DllExport int& getNumAIPlayableCivilizationInfos();
DllExport int getNumCivilizationInfos();
std::vector<CvCivilizationInfo*>& getCivilizationInfo();
DllExport CvCivilizationInfo& getCivilizationInfo(CivilizationTypes eCivilizationNum);
DllExport int getNumLeaderHeadInfos();
std::vector<CvLeaderHeadInfo*>& getLeaderHeadInfo();
DllExport CvLeaderHeadInfo& getLeaderHeadInfo(LeaderHeadTypes eLeaderHeadNum);
int getNumTraitInfos();
std::vector<CvTraitInfo*>& getTraitInfo();
CvTraitInfo& getTraitInfo(TraitTypes eTraitNum);
DllExport int getNumCursorInfos();
std::vector<CvCursorInfo*>& getCursorInfo();
DllExport CvCursorInfo& getCursorInfo(CursorTypes eCursorNum);
DllExport int getNumThroneRoomCameras();
std::vector<CvThroneRoomCamera*>& getThroneRoomCamera();
DllExport CvThroneRoomCamera& getThroneRoomCamera(int iIndex);
DllExport int getNumThroneRoomInfos();
std::vector<CvThroneRoomInfo*>& getThroneRoomInfo();
DllExport CvThroneRoomInfo& getThroneRoomInfo(int iIndex);
DllExport int getNumThroneRoomStyleInfos();
std::vector<CvThroneRoomStyleInfo*>& getThroneRoomStyleInfo();
DllExport CvThroneRoomStyleInfo& getThroneRoomStyleInfo(int iIndex);
DllExport int getNumSlideShowInfos();
std::vector<CvSlideShowInfo*>& getSlideShowInfo();
DllExport CvSlideShowInfo& getSlideShowInfo(int iIndex);
DllExport int getNumSlideShowRandomInfos();
std::vector<CvSlideShowRandomInfo*>& getSlideShowRandomInfo();
DllExport CvSlideShowRandomInfo& getSlideShowRandomInfo(int iIndex);
DllExport int getNumWorldPickerInfos();
std::vector<CvWorldPickerInfo*>& getWorldPickerInfo();
DllExport CvWorldPickerInfo& getWorldPickerInfo(int iIndex);
DllExport int getNumSpaceShipInfos();
std::vector<CvSpaceShipInfo*>& getSpaceShipInfo();
DllExport CvSpaceShipInfo& getSpaceShipInfo(int iIndex);
int getNumUnitInfos();
std::vector<CvUnitInfo*>& getUnitInfo();
CvUnitInfo& getUnitInfo(UnitTypes eUnitNum);
int getNumSpecialUnitInfos();
std::vector<CvSpecialUnitInfo*>& getSpecialUnitInfo();
CvSpecialUnitInfo& getSpecialUnitInfo(SpecialUnitTypes eSpecialUnitNum);
int getNumConceptInfos();
std::vector<CvInfoBase*>& getConceptInfo();
CvInfoBase& getConceptInfo(ConceptTypes e);
int getNumNewConceptInfos();
std::vector<CvInfoBase*>& getNewConceptInfo();
CvInfoBase& getNewConceptInfo(NewConceptTypes e);
int getNumCityTabInfos();
std::vector<CvInfoBase*>& getCityTabInfo();
CvInfoBase& getCityTabInfo(CityTabTypes e);
int getNumCalendarInfos();
std::vector<CvInfoBase*>& getCalendarInfo();
CvInfoBase& getCalendarInfo(CalendarTypes e);
int getNumSeasonInfos();
std::vector<CvInfoBase*>& getSeasonInfo();
CvInfoBase& getSeasonInfo(SeasonTypes e);
int getNumMonthInfos();
std::vector<CvInfoBase*>& getMonthInfo();
CvInfoBase& getMonthInfo(MonthTypes e);
int getNumDenialInfos();
std::vector<CvInfoBase*>& getDenialInfo();
CvInfoBase& getDenialInfo(DenialTypes e);
int getNumInvisibleInfos();
std::vector<CvInfoBase*>& getInvisibleInfo();
CvInfoBase& getInvisibleInfo(InvisibleTypes e);
int getNumVoteSourceInfos();
std::vector<CvVoteSourceInfo*>& getVoteSourceInfo();
CvVoteSourceInfo& getVoteSourceInfo(VoteSourceTypes e);
int getNumUnitCombatInfos();
std::vector<CvInfoBase*>& getUnitCombatInfo();
CvInfoBase& getUnitCombatInfo(UnitCombatTypes e);
std::vector<CvInfoBase*>& getDomainInfo();
CvInfoBase& getDomainInfo(DomainTypes e);
std::vector<CvInfoBase*>& getUnitAIInfo();
CvInfoBase& getUnitAIInfo(UnitAITypes eUnitAINum);
std::vector<CvInfoBase*>& getAttitudeInfo();
CvInfoBase& getAttitudeInfo(AttitudeTypes eAttitudeNum);
std::vector<CvInfoBase*>& getMemoryInfo();
CvInfoBase& getMemoryInfo(MemoryTypes eMemoryNum);
DllExport int getNumGameOptionInfos();
std::vector<CvGameOptionInfo*>& getGameOptionInfo();
DllExport CvGameOptionInfo& getGameOptionInfo(GameOptionTypes eGameOptionNum);
DllExport int getNumMPOptionInfos();
std::vector<CvMPOptionInfo*>& getMPOptionInfo();
DllExport CvMPOptionInfo& getMPOptionInfo(MultiplayerOptionTypes eMPOptionNum);
DllExport int getNumForceControlInfos();
std::vector<CvForceControlInfo*>& getForceControlInfo();
DllExport CvForceControlInfo& getForceControlInfo(ForceControlTypes eForceControlNum);
std::vector<CvPlayerOptionInfo*>& getPlayerOptionInfo();
DllExport CvPlayerOptionInfo& getPlayerOptionInfo(PlayerOptionTypes ePlayerOptionNum);
std::vector<CvGraphicOptionInfo*>& getGraphicOptionInfo();
DllExport CvGraphicOptionInfo& getGraphicOptionInfo(GraphicOptionTypes eGraphicOptionNum);
std::vector<CvYieldInfo*>& getYieldInfo();
CvYieldInfo& getYieldInfo(YieldTypes eYieldNum);
std::vector<CvCommerceInfo*>& getCommerceInfo();
CvCommerceInfo& getCommerceInfo(CommerceTypes eCommerceNum);
DllExport int getNumRouteInfos();
std::vector<CvRouteInfo*>& getRouteInfo();
DllExport CvRouteInfo& getRouteInfo(RouteTypes eRouteNum);
DllExport int getNumImprovementInfos();
std::vector<CvImprovementInfo*>& getImprovementInfo();
DllExport CvImprovementInfo& getImprovementInfo(ImprovementTypes eImprovementNum);
DllExport int getNumGoodyInfos();
std::vector<CvGoodyInfo*>& getGoodyInfo();
DllExport CvGoodyInfo& getGoodyInfo(GoodyTypes eGoodyNum);
DllExport int getNumBuildInfos();
std::vector<CvBuildInfo*>& getBuildInfo();
DllExport CvBuildInfo& getBuildInfo(BuildTypes eBuildNum);
DllExport int getNumHandicapInfos();
std::vector<CvHandicapInfo*>& getHandicapInfo();
DllExport CvHandicapInfo& getHandicapInfo(HandicapTypes eHandicapNum);
DllExport int getNumGameSpeedInfos();
std::vector<CvGameSpeedInfo*>& getGameSpeedInfo();
DllExport CvGameSpeedInfo& getGameSpeedInfo(GameSpeedTypes eGameSpeedNum);
DllExport int getNumTurnTimerInfos();
std::vector<CvTurnTimerInfo*>& getTurnTimerInfo();
DllExport CvTurnTimerInfo& getTurnTimerInfo(TurnTimerTypes eTurnTimerNum);
int getNumProcessInfos();
std::vector<CvProcessInfo*>& getProcessInfo();
CvProcessInfo& getProcessInfo(ProcessTypes e);
int getNumVoteInfos();
std::vector<CvVoteInfo*>& getVoteInfo();
CvVoteInfo& getVoteInfo(VoteTypes e);
int getNumProjectInfos();
std::vector<CvProjectInfo*>& getProjectInfo();
CvProjectInfo& getProjectInfo(ProjectTypes e);
int getNumBuildingClassInfos();
std::vector<CvBuildingClassInfo*>& getBuildingClassInfo();
CvBuildingClassInfo& getBuildingClassInfo(BuildingClassTypes eBuildingClassNum);
int getNumBuildingInfos();
std::vector<CvBuildingInfo*>& getBuildingInfo();
CvBuildingInfo& getBuildingInfo(BuildingTypes eBuildingNum);
int getNumSpecialBuildingInfos();
std::vector<CvSpecialBuildingInfo*>& getSpecialBuildingInfo();
CvSpecialBuildingInfo& getSpecialBuildingInfo(SpecialBuildingTypes eSpecialBuildingNum);
int getNumUnitClassInfos();
std::vector<CvUnitClassInfo*>& getUnitClassInfo();
CvUnitClassInfo& getUnitClassInfo(UnitClassTypes eUnitClassNum);
DllExport int getNumActionInfos();
std::vector<CvActionInfo*>& getActionInfo();
DllExport CvActionInfo& getActionInfo(int i);
std::vector<CvMissionInfo*>& getMissionInfo();
DllExport CvMissionInfo& getMissionInfo(MissionTypes eMissionNum);
std::vector<CvControlInfo*>& getControlInfo();
DllExport CvControlInfo& getControlInfo(ControlTypes eControlNum);
std::vector<CvCommandInfo*>& getCommandInfo();
DllExport CvCommandInfo& getCommandInfo(CommandTypes eCommandNum);
DllExport int getNumAutomateInfos();
std::vector<CvAutomateInfo*>& getAutomateInfo();
DllExport CvAutomateInfo& getAutomateInfo(int iAutomateNum);
int getNumPromotionInfos();
std::vector<CvPromotionInfo*>& getPromotionInfo();
CvPromotionInfo& getPromotionInfo(PromotionTypes ePromotionNum);
int getNumTechInfos();
std::vector<CvTechInfo*>& getTechInfo();
CvTechInfo& getTechInfo(TechTypes eTechNum);
int getNumReligionInfos();
std::vector<CvReligionInfo*>& getReligionInfo();
CvReligionInfo& getReligionInfo(ReligionTypes eReligionNum);
int getNumCorporationInfos();
std::vector<CvCorporationInfo*>& getCorporationInfo();
CvCorporationInfo& getCorporationInfo(CorporationTypes eCorporationNum);
int getNumSpecialistInfos();
std::vector<CvSpecialistInfo*>& getSpecialistInfo();
CvSpecialistInfo& getSpecialistInfo(SpecialistTypes eSpecialistNum);
int getNumCivicOptionInfos();
std::vector<CvCivicOptionInfo*>& getCivicOptionInfo();
CvCivicOptionInfo& getCivicOptionInfo(CivicOptionTypes eCivicOptionNum);
int getNumCivicInfos();
std::vector<CvCivicInfo*>& getCivicInfo();
CvCivicInfo& getCivicInfo(CivicTypes eCivicNum);
int getNumDiplomacyInfos();
std::vector<CvDiplomacyInfo*>& getDiplomacyInfo();
CvDiplomacyInfo& getDiplomacyInfo(int iDiplomacyNum);
DllExport int getNumEraInfos();
std::vector<CvEraInfo*>& getEraInfo();
DllExport CvEraInfo& getEraInfo(EraTypes eEraNum);
int getNumHurryInfos();
std::vector<CvHurryInfo*>& getHurryInfo();
CvHurryInfo& getHurryInfo(HurryTypes eHurryNum);
int getNumEmphasizeInfos();
std::vector<CvEmphasizeInfo*>& getEmphasizeInfo();
CvEmphasizeInfo& getEmphasizeInfo(EmphasizeTypes eEmphasizeNum);
int getNumUpkeepInfos();
std::vector<CvUpkeepInfo*>& getUpkeepInfo();
CvUpkeepInfo& getUpkeepInfo(UpkeepTypes eUpkeepNum);
int getNumCultureLevelInfos();
std::vector<CvCultureLevelInfo*>& getCultureLevelInfo();
CvCultureLevelInfo& getCultureLevelInfo(CultureLevelTypes eCultureLevelNum);
DllExport int getNumVictoryInfos();
std::vector<CvVictoryInfo*>& getVictoryInfo();
DllExport CvVictoryInfo& getVictoryInfo(VictoryTypes eVictoryNum);
int getNumQuestInfos();
std::vector<CvQuestInfo*>& getQuestInfo();
CvQuestInfo& getQuestInfo(int iIndex);
int getNumTutorialInfos();
std::vector<CvTutorialInfo*>& getTutorialInfo();
CvTutorialInfo& getTutorialInfo(int i);
int getNumEventTriggerInfos();
std::vector<CvEventTriggerInfo*>& getEventTriggerInfo();
CvEventTriggerInfo& getEventTriggerInfo(EventTriggerTypes eEventTrigger);
int getNumEventInfos();
std::vector<CvEventInfo*>& getEventInfo();
CvEventInfo& getEventInfo(EventTypes eEvent);
int getNumEspionageMissionInfos();
std::vector<CvEspionageMissionInfo*>& getEspionageMissionInfo();
CvEspionageMissionInfo& getEspionageMissionInfo(EspionageMissionTypes eEspionageMissionNum);
int getNumUnitArtStyleTypeInfos();
std::vector<CvUnitArtStyleTypeInfo*>& getUnitArtStyleTypeInfo();
CvUnitArtStyleTypeInfo& getUnitArtStyleTypeInfo(UnitArtStyleTypes eUnitArtStyleTypeNum);
//
// Global Types
// All type strings are upper case and are kept in this hash map for fast lookup
// The other functions are kept for convenience when enumerating, but most are not used
//
DllExport int getTypesEnum(const char* szType) const; // use this when searching for a type
DllExport void setTypesEnum(const char* szType, int iEnum);
DllExport int getNUM_ENGINE_DIRTY_BITS() const;
DllExport int getNUM_INTERFACE_DIRTY_BITS() const;
DllExport int getNUM_YIELD_TYPES() const;
DllExport int getNUM_COMMERCE_TYPES() const;
DllExport int getNUM_FORCECONTROL_TYPES() const;
DllExport int getNUM_INFOBAR_TYPES() const;
DllExport int getNUM_HEALTHBAR_TYPES() const;
DllExport int getNUM_CONTROL_TYPES() const;
DllExport int getNUM_LEADERANIM_TYPES() const;
DllExport int& getNumEntityEventTypes();
CvString*& getEntityEventTypes();
DllExport CvString& getEntityEventTypes(EntityEventTypes e);
DllExport int& getNumAnimationOperatorTypes();
CvString*& getAnimationOperatorTypes();
DllExport CvString& getAnimationOperatorTypes(AnimationOperatorTypes e);
CvString*& getFunctionTypes();
DllExport CvString& getFunctionTypes(FunctionTypes e);
int& getNumFlavorTypes();
CvString*& getFlavorTypes();
CvString& getFlavorTypes(FlavorTypes e);
DllExport int& getNumArtStyleTypes();
CvString*& getArtStyleTypes();
DllExport CvString& getArtStyleTypes(ArtStyleTypes e);
int& getNumCitySizeTypes();
CvString*& getCitySizeTypes();
CvString& getCitySizeTypes(int i);
CvString*& getContactTypes();
CvString& getContactTypes(ContactTypes e);
CvString*& getDiplomacyPowerTypes();
CvString& getDiplomacyPowerTypes(DiplomacyPowerTypes e);
CvString*& getAutomateTypes();
CvString& getAutomateTypes(AutomateTypes e);
CvString*& getDirectionTypes();
DllExport CvString& getDirectionTypes(AutomateTypes e);
DllExport int& getNumFootstepAudioTypes();
CvString*& getFootstepAudioTypes();
DllExport CvString& getFootstepAudioTypes(int i);
DllExport int getFootstepAudioTypeByTag(CvString strTag);
CvString*& getFootstepAudioTags();
DllExport CvString& getFootstepAudioTags(int i);
CvString& getCurrentXMLFile();
void setCurrentXMLFile(const TCHAR* szFileName);
//
///////////////// BEGIN global defines
// THESE ARE READ-ONLY
//
DllExport FVariableSystem* getDefinesVarSystem();
DllExport void cacheGlobals();
// ***** EXPOSED TO PYTHON *****
DllExport int getDefineINT( const char * szName ) const;
DllExport float getDefineFLOAT( const char * szName ) const;
DllExport const char * getDefineSTRING( const char * szName ) const;
DllExport void setDefineINT( const char * szName, int iValue );
DllExport void setDefineFLOAT( const char * szName, float fValue );
DllExport void setDefineSTRING( const char * szName, const char * szValue );
int getMOVE_DENOMINATOR();
int getNUM_UNIT_PREREQ_OR_BONUSES();
int getNUM_BUILDING_PREREQ_OR_BONUSES();
int getFOOD_CONSUMPTION_PER_POPULATION();
int getMAX_HIT_POINTS();
int getPATH_DAMAGE_WEIGHT();
int getHILLS_EXTRA_DEFENSE();
int getRIVER_ATTACK_MODIFIER();
int getAMPHIB_ATTACK_MODIFIER();
int getHILLS_EXTRA_MOVEMENT();
DllExport int getMAX_PLOT_LIST_ROWS();
DllExport int getUNIT_MULTISELECT_MAX();
int getPERCENT_ANGER_DIVISOR();
DllExport int getEVENT_MESSAGE_TIME();
int getROUTE_FEATURE_GROWTH_MODIFIER();
int getFEATURE_GROWTH_MODIFIER();
int getMIN_CITY_RANGE();
int getCITY_MAX_NUM_BUILDINGS();
int getNUM_UNIT_AND_TECH_PREREQS();
int getNUM_AND_TECH_PREREQS();
int getNUM_OR_TECH_PREREQS();
int getLAKE_MAX_AREA_SIZE();
int getNUM_ROUTE_PREREQ_OR_BONUSES();
int getNUM_BUILDING_AND_TECH_PREREQS();
int getMIN_WATER_SIZE_FOR_OCEAN();
int getFORTIFY_MODIFIER_PER_TURN();
int getMAX_CITY_DEFENSE_DAMAGE();
int getNUM_CORPORATION_PREREQ_BONUSES();
int getPEAK_SEE_THROUGH_CHANGE();
int getHILLS_SEE_THROUGH_CHANGE();
int getSEAWATER_SEE_FROM_CHANGE();
int getPEAK_SEE_FROM_CHANGE();
int getHILLS_SEE_FROM_CHANGE();
int getUSE_SPIES_NO_ENTER_BORDERS();
DllExport float getCAMERA_MIN_YAW();
DllExport float getCAMERA_MAX_YAW();
DllExport float getCAMERA_FAR_CLIP_Z_HEIGHT();
DllExport float getCAMERA_MAX_TRAVEL_DISTANCE();
DllExport float getCAMERA_START_DISTANCE();
DllExport float getAIR_BOMB_HEIGHT();
DllExport float getPLOT_SIZE();
DllExport float getCAMERA_SPECIAL_PITCH();
DllExport float getCAMERA_MAX_TURN_OFFSET();
DllExport float getCAMERA_MIN_DISTANCE();
DllExport float getCAMERA_UPPER_PITCH();
DllExport float getCAMERA_LOWER_PITCH();
DllExport float getFIELD_OF_VIEW();
DllExport float getSHADOW_SCALE();
DllExport float getUNIT_MULTISELECT_DISTANCE();
int getUSE_CANNOT_FOUND_CITY_CALLBACK();
int getUSE_CAN_FOUND_CITIES_ON_WATER_CALLBACK();
int getUSE_IS_PLAYER_RESEARCH_CALLBACK();
int getUSE_CAN_RESEARCH_CALLBACK();
int getUSE_CANNOT_DO_CIVIC_CALLBACK();
int getUSE_CAN_DO_CIVIC_CALLBACK();
int getUSE_CANNOT_CONSTRUCT_CALLBACK();
int getUSE_CAN_CONSTRUCT_CALLBACK();
int getUSE_CAN_DECLARE_WAR_CALLBACK();
int getUSE_CANNOT_RESEARCH_CALLBACK();
int getUSE_GET_UNIT_COST_MOD_CALLBACK();
int getUSE_GET_BUILDING_COST_MOD_CALLBACK();
int getUSE_GET_CITY_FOUND_VALUE_CALLBACK();
int getUSE_CANNOT_HANDLE_ACTION_CALLBACK();
int getUSE_CAN_BUILD_CALLBACK();
int getUSE_CANNOT_TRAIN_CALLBACK();
int getUSE_CAN_TRAIN_CALLBACK();
int getUSE_UNIT_CANNOT_MOVE_INTO_CALLBACK();
int getUSE_USE_CANNOT_SPREAD_RELIGION_CALLBACK();
DllExport int getUSE_FINISH_TEXT_CALLBACK();
int getUSE_ON_UNIT_SET_XY_CALLBACK();
int getUSE_ON_UNIT_SELECTED_CALLBACK();
int getUSE_ON_UPDATE_CALLBACK();
int getUSE_ON_UNIT_CREATED_CALLBACK();
int getUSE_ON_UNIT_LOST_CALLBACK();
DllExport int getMAX_CIV_PLAYERS();
DllExport int getMAX_PLAYERS();
DllExport int getMAX_CIV_TEAMS();
DllExport int getMAX_TEAMS();
DllExport int getBARBARIAN_PLAYER();
DllExport int getBARBARIAN_TEAM();
DllExport int getINVALID_PLOT_COORD();
DllExport int getNUM_CITY_PLOTS();
DllExport int getCITY_HOME_PLOT();
// ***** END EXPOSED TO PYTHON *****
////////////// END DEFINES //////////////////
DllExport void setDLLIFace(CvDLLUtilityIFaceBase* pDll);
#ifdef _USRDLL
CvDLLUtilityIFaceBase* getDLLIFace() { return m_pDLL; } // inlined for perf reasons, do not use outside of dll
#endif
DllExport CvDLLUtilityIFaceBase* getDLLIFaceNonInl();
DllExport void setDLLProfiler(FProfiler* prof);
FProfiler* getDLLProfiler();
DllExport void enableDLLProfiler(bool bEnable);
bool isDLLProfilerEnabled() const;
DllExport bool IsGraphicsInitialized() const;
DllExport void SetGraphicsInitialized(bool bVal);
// for caching
DllExport bool readBuildingInfoArray(FDataStreamBase* pStream);
DllExport void writeBuildingInfoArray(FDataStreamBase* pStream);
DllExport bool readTechInfoArray(FDataStreamBase* pStream);
DllExport void writeTechInfoArray(FDataStreamBase* pStream);
DllExport bool readUnitInfoArray(FDataStreamBase* pStream);
DllExport void writeUnitInfoArray(FDataStreamBase* pStream);
DllExport bool readLeaderHeadInfoArray(FDataStreamBase* pStream);
DllExport void writeLeaderHeadInfoArray(FDataStreamBase* pStream);
DllExport bool readCivilizationInfoArray(FDataStreamBase* pStream);
DllExport void writeCivilizationInfoArray(FDataStreamBase* pStream);
DllExport bool readPromotionInfoArray(FDataStreamBase* pStream);
DllExport void writePromotionInfoArray(FDataStreamBase* pStream);
DllExport bool readDiplomacyInfoArray(FDataStreamBase* pStream);
DllExport void writeDiplomacyInfoArray(FDataStreamBase* pStream);
DllExport bool readCivicInfoArray(FDataStreamBase* pStream);
DllExport void writeCivicInfoArray(FDataStreamBase* pStream);
DllExport bool readHandicapInfoArray(FDataStreamBase* pStream);
DllExport void writeHandicapInfoArray(FDataStreamBase* pStream);
DllExport bool readBonusInfoArray(FDataStreamBase* pStream);
DllExport void writeBonusInfoArray(FDataStreamBase* pStream);
DllExport bool readImprovementInfoArray(FDataStreamBase* pStream);
DllExport void writeImprovementInfoArray(FDataStreamBase* pStream);
DllExport bool readEventInfoArray(FDataStreamBase* pStream);
DllExport void writeEventInfoArray(FDataStreamBase* pStream);
DllExport bool readEventTriggerInfoArray(FDataStreamBase* pStream);
DllExport void writeEventTriggerInfoArray(FDataStreamBase* pStream);
//
// additional accessors for initting globals
//
DllExport void setInterface(CvInterface* pVal);
DllExport void setDiplomacyScreen(CvDiplomacyScreen* pVal);
DllExport void setMPDiplomacyScreen(CMPDiplomacyScreen* pVal);
DllExport void setMessageQueue(CMessageQueue* pVal);
DllExport void setHotJoinMessageQueue(CMessageQueue* pVal);
DllExport void setMessageControl(CMessageControl* pVal);
DllExport void setSetupData(CvSetupData* pVal);
DllExport void setMessageCodeTranslator(CvMessageCodeTranslator* pVal);
DllExport void setDropMgr(CvDropMgr* pVal);
DllExport void setPortal(CvPortal* pVal);
DllExport void setStatsReport(CvStatsReporter* pVal);
DllExport void setPathFinder(FAStar* pVal);
DllExport void setInterfacePathFinder(FAStar* pVal);
DllExport void setStepFinder(FAStar* pVal);
DllExport void setRouteFinder(FAStar* pVal);
DllExport void setBorderFinder(FAStar* pVal);
DllExport void setAreaFinder(FAStar* pVal);
DllExport void setPlotGroupFinder(FAStar* pVal);
// So that CvEnums are moddable in the DLL
DllExport int getNumDirections() const;
DllExport int getNumGameOptions() const;
DllExport int getNumMPOptions() const;
DllExport int getNumSpecialOptions() const;
DllExport int getNumGraphicOptions() const;
DllExport int getNumTradeableItems() const;
DllExport int getNumBasicItems() const;
DllExport int getNumTradeableHeadings() const;
DllExport int getNumCommandInfos() const;
DllExport int getNumControlInfos() const;
DllExport int getNumMissionInfos() const;
DllExport int getNumPlayerOptionInfos() const;
DllExport int getMaxNumSymbols() const;
DllExport int getNumGraphicLevels() const;
DllExport int getNumGlobeLayers() const;
// BUG - DLL Info - start
bool isBull() const;
int getBullApiVersion() const;
const wchar* getBullName() const;
const wchar* getBullVersion() const;
// BUG - DLL Info - end
// BUG - BUG Info - start
void setIsBug(bool bIsBug);
// BUG - BUG Info - end
// BUFFY - DLL Info - start
#ifdef _BUFFY
bool isBuffy() const;
int getBuffyApiVersion() const;
const wchar* getBuffyName() const;
const wchar* getBuffyVersion() const;
#endif
// BUFFY - DLL Info - end
void deleteInfoArrays();
protected:
bool m_bGraphicsInitialized;
bool m_bDLLProfiler;
bool m_bLogging;
bool m_bRandLogging;
bool m_bSynchLogging;
bool m_bOverwriteLogs;
NiPoint3 m_pt3CameraDir;
int m_iNewPlayers;
CMainMenu* m_pkMainMenu;
bool m_bZoomOut;
bool m_bZoomIn;
bool m_bLoadGameFromFile;
FMPIManager * m_pFMPMgr;
CvRandom* m_asyncRand;
CvGameAI* m_game;
CMessageQueue* m_messageQueue;
CMessageQueue* m_hotJoinMsgQueue;
CMessageControl* m_messageControl;
CvSetupData* m_setupData;
CvInitCore* m_iniInitCore;
CvInitCore* m_loadedInitCore;
CvInitCore* m_initCore;
CvMessageCodeTranslator * m_messageCodes;
CvDropMgr* m_dropMgr;
CvPortal* m_portal;
CvStatsReporter * m_statsReporter;
CvInterface* m_interface;
CvArtFileMgr* m_pArtFileMgr;
CvMap* m_map;
CvDiplomacyScreen* m_diplomacyScreen;
CMPDiplomacyScreen* m_mpDiplomacyScreen;
FAStar* m_pathFinder;
FAStar* m_interfacePathFinder;
FAStar* m_stepFinder;
FAStar* m_routeFinder;
FAStar* m_borderFinder;
FAStar* m_areaFinder;
FAStar* m_plotGroupFinder;
NiPoint3 m_pt3Origin;
int* m_aiPlotDirectionX; // [NUM_DIRECTION_TYPES];
int* m_aiPlotDirectionY; // [NUM_DIRECTION_TYPES];
int* m_aiPlotCardinalDirectionX; // [NUM_CARDINALDIRECTION_TYPES];
int* m_aiPlotCardinalDirectionY; // [NUM_CARDINALDIRECTION_TYPES];
int* m_aiCityPlotX; // [NUM_CITY_PLOTS];
int* m_aiCityPlotY; // [NUM_CITY_PLOTS];
int* m_aiCityPlotPriority; // [NUM_CITY_PLOTS];
int m_aaiXYCityPlot[CITY_PLOTS_DIAMETER][CITY_PLOTS_DIAMETER];
// Leoreth: index over the third ring as well
int* m_aiCityPlot3X;
int* m_aiCityPlot3Y;
// Leoreth: graphics paging
bool m_bGraphicalDetailPagingEnabled;
DirectionTypes* m_aeTurnLeftDirection; // [NUM_DIRECTION_TYPES];
DirectionTypes* m_aeTurnRightDirection; // [NUM_DIRECTION_TYPES];
DirectionTypes m_aaeXYDirection[DIRECTION_DIAMETER][DIRECTION_DIAMETER];
//InterfaceModeInfo m_aInterfaceModeInfo[NUM_INTERFACEMODE_TYPES] =
std::vector<CvInterfaceModeInfo*> m_paInterfaceModeInfo;
/***********************************************************************************************************************
Globals loaded from XML
************************************************************************************************************************/
// all type strings are upper case and are kept in this hash map for fast lookup, Moose
typedef stdext::hash_map<std::string /* type string */, int /* info index */> InfosMap;
InfosMap m_infosMap;
std::vector<std::vector<CvInfoBase *> *> m_aInfoVectors;
std::vector<CvColorInfo*> m_paColorInfo;
std::vector<CvPlayerColorInfo*> m_paPlayerColorInfo;
std::vector<CvAdvisorInfo*> m_paAdvisorInfo;
std::vector<CvInfoBase*> m_paHints;
std::vector<CvMainMenuInfo*> m_paMainMenus;
std::vector<CvTerrainInfo*> m_paTerrainInfo;
std::vector<CvLandscapeInfo*> m_paLandscapeInfo;
int m_iActiveLandscapeID;
std::vector<CvWorldInfo*> m_paWorldInfo;
std::vector<CvClimateInfo*> m_paClimateInfo;
std::vector<CvSeaLevelInfo*> m_paSeaLevelInfo;
std::vector<CvYieldInfo*> m_paYieldInfo;
std::vector<CvCommerceInfo*> m_paCommerceInfo;
std::vector<CvRouteInfo*> m_paRouteInfo;
std::vector<CvFeatureInfo*> m_paFeatureInfo;
std::vector<CvBonusClassInfo*> m_paBonusClassInfo;
std::vector<CvBonusInfo*> m_paBonusInfo;
std::vector<CvImprovementInfo*> m_paImprovementInfo;
std::vector<CvGoodyInfo*> m_paGoodyInfo;
std::vector<CvBuildInfo*> m_paBuildInfo;
std::vector<CvHandicapInfo*> m_paHandicapInfo;
std::vector<CvGameSpeedInfo*> m_paGameSpeedInfo;
std::vector<CvTurnTimerInfo*> m_paTurnTimerInfo;
std::vector<CvCivilizationInfo*> m_paCivilizationInfo;
int m_iNumPlayableCivilizationInfos;
int m_iNumAIPlayableCivilizationInfos;
std::vector<CvLeaderHeadInfo*> m_paLeaderHeadInfo;
std::vector<CvTraitInfo*> m_paTraitInfo;
std::vector<CvCursorInfo*> m_paCursorInfo;
std::vector<CvThroneRoomCamera*> m_paThroneRoomCamera;
std::vector<CvThroneRoomInfo*> m_paThroneRoomInfo;
std::vector<CvThroneRoomStyleInfo*> m_paThroneRoomStyleInfo;
std::vector<CvSlideShowInfo*> m_paSlideShowInfo;
std::vector<CvSlideShowRandomInfo*> m_paSlideShowRandomInfo;
std::vector<CvWorldPickerInfo*> m_paWorldPickerInfo;
std::vector<CvSpaceShipInfo*> m_paSpaceShipInfo;
std::vector<CvProcessInfo*> m_paProcessInfo;
std::vector<CvVoteInfo*> m_paVoteInfo;
std::vector<CvProjectInfo*> m_paProjectInfo;
std::vector<CvBuildingClassInfo*> m_paBuildingClassInfo;
std::vector<CvBuildingInfo*> m_paBuildingInfo;
std::vector<CvSpecialBuildingInfo*> m_paSpecialBuildingInfo;
std::vector<CvUnitClassInfo*> m_paUnitClassInfo;
std::vector<CvUnitInfo*> m_paUnitInfo;
std::vector<CvSpecialUnitInfo*> m_paSpecialUnitInfo;
std::vector<CvInfoBase*> m_paConceptInfo;
std::vector<CvInfoBase*> m_paNewConceptInfo;
std::vector<CvInfoBase*> m_paCityTabInfo;
std::vector<CvInfoBase*> m_paCalendarInfo;
std::vector<CvInfoBase*> m_paSeasonInfo;
std::vector<CvInfoBase*> m_paMonthInfo;
std::vector<CvInfoBase*> m_paDenialInfo;
std::vector<CvInfoBase*> m_paInvisibleInfo;
std::vector<CvVoteSourceInfo*> m_paVoteSourceInfo;
std::vector<CvInfoBase*> m_paUnitCombatInfo;
std::vector<CvInfoBase*> m_paDomainInfo;
std::vector<CvInfoBase*> m_paUnitAIInfos;
std::vector<CvInfoBase*> m_paAttitudeInfos;
std::vector<CvInfoBase*> m_paMemoryInfos;
std::vector<CvInfoBase*> m_paFeatInfos;
std::vector<CvGameOptionInfo*> m_paGameOptionInfos;
std::vector<CvMPOptionInfo*> m_paMPOptionInfos;
std::vector<CvForceControlInfo*> m_paForceControlInfos;
std::vector<CvPlayerOptionInfo*> m_paPlayerOptionInfos;
std::vector<CvGraphicOptionInfo*> m_paGraphicOptionInfos;
std::vector<CvSpecialistInfo*> m_paSpecialistInfo;
std::vector<CvEmphasizeInfo*> m_paEmphasizeInfo;
std::vector<CvUpkeepInfo*> m_paUpkeepInfo;
std::vector<CvCultureLevelInfo*> m_paCultureLevelInfo;
std::vector<CvReligionInfo*> m_paReligionInfo;
std::vector<CvCorporationInfo*> m_paCorporationInfo;
std::vector<CvActionInfo*> m_paActionInfo;
std::vector<CvMissionInfo*> m_paMissionInfo;
std::vector<CvControlInfo*> m_paControlInfo;
std::vector<CvCommandInfo*> m_paCommandInfo;
std::vector<CvAutomateInfo*> m_paAutomateInfo;
std::vector<CvPromotionInfo*> m_paPromotionInfo;
std::vector<CvTechInfo*> m_paTechInfo;
std::vector<CvCivicOptionInfo*> m_paCivicOptionInfo;
std::vector<CvCivicInfo*> m_paCivicInfo;
std::vector<CvDiplomacyInfo*> m_paDiplomacyInfo;
std::vector<CvEraInfo*> m_aEraInfo; // [NUM_ERA_TYPES];
std::vector<CvHurryInfo*> m_paHurryInfo;
std::vector<CvVictoryInfo*> m_paVictoryInfo;
std::vector<CvRouteModelInfo*> m_paRouteModelInfo;
std::vector<CvRiverInfo*> m_paRiverInfo;
std::vector<CvRiverModelInfo*> m_paRiverModelInfo;
std::vector<CvWaterPlaneInfo*> m_paWaterPlaneInfo;
std::vector<CvTerrainPlaneInfo*> m_paTerrainPlaneInfo;
std::vector<CvCameraOverlayInfo*> m_paCameraOverlayInfo;
std::vector<CvAnimationPathInfo*> m_paAnimationPathInfo;
std::vector<CvAnimationCategoryInfo*> m_paAnimationCategoryInfo;
std::vector<CvEntityEventInfo*> m_paEntityEventInfo;
std::vector<CvUnitFormationInfo*> m_paUnitFormationInfo;
std::vector<CvEffectInfo*> m_paEffectInfo;
std::vector<CvAttachableInfo*> m_paAttachableInfo;
std::vector<CvCameraInfo*> m_paCameraInfo;
std::vector<CvQuestInfo*> m_paQuestInfo;
std::vector<CvTutorialInfo*> m_paTutorialInfo;
std::vector<CvEventTriggerInfo*> m_paEventTriggerInfo;
std::vector<CvEventInfo*> m_paEventInfo;
std::vector<CvEspionageMissionInfo*> m_paEspionageMissionInfo;
std::vector<CvUnitArtStyleTypeInfo*> m_paUnitArtStyleTypeInfo;
// Game Text
std::vector<CvGameText*> m_paGameTextXML;
//////////////////////////////////////////////////////////////////////////
// GLOBAL TYPES
//////////////////////////////////////////////////////////////////////////
// all type strings are upper case and are kept in this hash map for fast lookup, Moose
typedef stdext::hash_map<std::string /* type string */, int /*enum value */> TypesMap;
TypesMap m_typesMap;
// XXX These are duplicates and are kept for enumeration convenience - most could be removed, Moose
CvString *m_paszEntityEventTypes2;
CvString *m_paszEntityEventTypes;
int m_iNumEntityEventTypes;
CvString *m_paszAnimationOperatorTypes;
int m_iNumAnimationOperatorTypes;
CvString* m_paszFunctionTypes;
CvString* m_paszFlavorTypes;
int m_iNumFlavorTypes;
CvString *m_paszArtStyleTypes;
int m_iNumArtStyleTypes;
CvString *m_paszCitySizeTypes;
int m_iNumCitySizeTypes;
CvString *m_paszContactTypes;
CvString *m_paszDiplomacyPowerTypes;
CvString *m_paszAutomateTypes;
CvString *m_paszDirectionTypes;
CvString *m_paszFootstepAudioTypes;
int m_iNumFootstepAudioTypes;
CvString *m_paszFootstepAudioTags;
int m_iNumFootstepAudioTags;
CvString m_szCurrentXMLFile;
//////////////////////////////////////////////////////////////////////////
// Formerly Global Defines
//////////////////////////////////////////////////////////////////////////
FVariableSystem* m_VarSystem;
int m_iMOVE_DENOMINATOR;
int m_iNUM_UNIT_PREREQ_OR_BONUSES;
int m_iNUM_BUILDING_PREREQ_OR_BONUSES;
int m_iFOOD_CONSUMPTION_PER_POPULATION;
int m_iMAX_HIT_POINTS;
int m_iPATH_DAMAGE_WEIGHT;
int m_iHILLS_EXTRA_DEFENSE;
int m_iRIVER_ATTACK_MODIFIER;
int m_iAMPHIB_ATTACK_MODIFIER;
int m_iHILLS_EXTRA_MOVEMENT;
int m_iMAX_PLOT_LIST_ROWS;
int m_iUNIT_MULTISELECT_MAX;
int m_iPERCENT_ANGER_DIVISOR;
int m_iEVENT_MESSAGE_TIME;
int m_iROUTE_FEATURE_GROWTH_MODIFIER;
int m_iFEATURE_GROWTH_MODIFIER;
int m_iMIN_CITY_RANGE;
int m_iCITY_MAX_NUM_BUILDINGS;
int m_iNUM_UNIT_AND_TECH_PREREQS;
int m_iNUM_AND_TECH_PREREQS;
int m_iNUM_OR_TECH_PREREQS;
int m_iLAKE_MAX_AREA_SIZE;
int m_iNUM_ROUTE_PREREQ_OR_BONUSES;
int m_iNUM_BUILDING_AND_TECH_PREREQS;
int m_iMIN_WATER_SIZE_FOR_OCEAN;
int m_iFORTIFY_MODIFIER_PER_TURN;
int m_iMAX_CITY_DEFENSE_DAMAGE;
int m_iNUM_CORPORATION_PREREQ_BONUSES;
int m_iPEAK_SEE_THROUGH_CHANGE;
int m_iHILLS_SEE_THROUGH_CHANGE;
int m_iSEAWATER_SEE_FROM_CHANGE;
int m_iPEAK_SEE_FROM_CHANGE;
int m_iHILLS_SEE_FROM_CHANGE;
int m_iUSE_SPIES_NO_ENTER_BORDERS;
float m_fCAMERA_MIN_YAW;
float m_fCAMERA_MAX_YAW;
float m_fCAMERA_FAR_CLIP_Z_HEIGHT;
float m_fCAMERA_MAX_TRAVEL_DISTANCE;
float m_fCAMERA_START_DISTANCE;
float m_fAIR_BOMB_HEIGHT;
float m_fPLOT_SIZE;
float m_fCAMERA_SPECIAL_PITCH;
float m_fCAMERA_MAX_TURN_OFFSET;
float m_fCAMERA_MIN_DISTANCE;
float m_fCAMERA_UPPER_PITCH;
float m_fCAMERA_LOWER_PITCH;
float m_fFIELD_OF_VIEW;
float m_fSHADOW_SCALE;
float m_fUNIT_MULTISELECT_DISTANCE;
int m_iUSE_CANNOT_FOUND_CITY_CALLBACK;
int m_iUSE_CAN_FOUND_CITIES_ON_WATER_CALLBACK;
int m_iUSE_IS_PLAYER_RESEARCH_CALLBACK;
int m_iUSE_CAN_RESEARCH_CALLBACK;
int m_iUSE_CANNOT_DO_CIVIC_CALLBACK;
int m_iUSE_CAN_DO_CIVIC_CALLBACK;
int m_iUSE_CANNOT_CONSTRUCT_CALLBACK;
int m_iUSE_CAN_CONSTRUCT_CALLBACK;
int m_iUSE_CAN_DECLARE_WAR_CALLBACK;
int m_iUSE_CANNOT_RESEARCH_CALLBACK;
int m_iUSE_GET_UNIT_COST_MOD_CALLBACK;
int m_iUSE_GET_BUILDING_COST_MOD_CALLBACK;
int m_iUSE_GET_CITY_FOUND_VALUE_CALLBACK;
int m_iUSE_CANNOT_HANDLE_ACTION_CALLBACK;
int m_iUSE_CAN_BUILD_CALLBACK;
int m_iUSE_CANNOT_TRAIN_CALLBACK;
int m_iUSE_CAN_TRAIN_CALLBACK;
int m_iUSE_UNIT_CANNOT_MOVE_INTO_CALLBACK;
int m_iUSE_USE_CANNOT_SPREAD_RELIGION_CALLBACK;
int m_iUSE_FINISH_TEXT_CALLBACK;
int m_iUSE_ON_UNIT_SET_XY_CALLBACK;
int m_iUSE_ON_UNIT_SELECTED_CALLBACK;
int m_iUSE_ON_UPDATE_CALLBACK;
int m_iUSE_ON_UNIT_CREATED_CALLBACK;
int m_iUSE_ON_UNIT_LOST_CALLBACK;
// DLL interface
CvDLLUtilityIFaceBase* m_pDLL;
FProfiler* m_Profiler; // profiler
CvString m_szDllProfileText;
/************************************************************************************************/
/* BETTER_BTS_AI_MOD 02/21/10 jdog5000 */
/* */
/* Efficiency, Options */
/************************************************************************************************/
public:
int getDefineINT( const char * szName, const int iDefault ) const;
int getCOMBAT_DIE_SIDES();
int getCOMBAT_DAMAGE();
protected:
int m_iCOMBAT_DIE_SIDES;
int m_iCOMBAT_DAMAGE;
/************************************************************************************************/
/* BETTER_BTS_AI_MOD END */
/************************************************************************************************/
};
extern CvGlobals gGlobals; // for debugging
//
// inlines
//
inline CvGlobals& CvGlobals::getInstance()
{
return gGlobals;
}
//
// helpers
//
#define GC CvGlobals::getInstance()
#ifndef _USRDLL
#define gDLL GC.getDLLIFaceNonInl()
#else
#define gDLL GC.getDLLIFace()
#endif
#ifndef _USRDLL
#define NUM_DIRECTION_TYPES (GC.getNumDirections())
#define NUM_GAMEOPTION_TYPES (GC.getNumGameOptions())
#define NUM_MPOPTION_TYPES (GC.getNumMPOptions())
#define NUM_SPECIALOPTION_TYPES (GC.getNumSpecialOptions())
#define NUM_GRAPHICOPTION_TYPES (GC.getNumGraphicOptions())
#define NUM_TRADEABLE_ITEMS (GC.getNumTradeableItems())
#define NUM_BASIC_ITEMS (GC.getNumBasicItems())
#define NUM_TRADEABLE_HEADINGS (GC.getNumTradeableHeadings())
#define NUM_COMMAND_TYPES (GC.getNumCommandInfos())
#define NUM_CONTROL_TYPES (GC.getNumControlInfos())
#define NUM_MISSION_TYPES (GC.getNumMissionInfos())
#define NUM_PLAYEROPTION_TYPES (GC.getNumPlayerOptionInfos())
#define MAX_NUM_SYMBOLS (GC.getMaxNumSymbols())
#define NUM_GRAPHICLEVELS (GC.getNumGraphicLevels())
#define NUM_GLOBE_LAYER_TYPES (GC.getNumGlobeLayers())
#endif
#endif
| [
"imperatorknoedel@ymail.com"
] | imperatorknoedel@ymail.com |
10018331df29ff949d4b82198a0698c4556149be | 26706a661c23f5c2c1f97847ba09f44b7b425cf6 | /TaskManager/DlgProcessPort.h | 45ed08495970377973d743af3e6d95cdb91e1db2 | [] | no_license | 124327288/nativetaskmanager | 96a54dbe150f855422d7fd813d3631eaac76fadd | e75b3d9d27c902baddbb1bef975c746451b1b8bb | refs/heads/master | 2021-05-29T05:18:26.779900 | 2009-02-10T13:23:28 | 2009-02-10T13:23:28 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,559 | h | #pragma once
#include "afxcmn.h"
#include "SortListCtrl.h"
#include "CriticalSection.h"
#include "EnumPort.h"
using namespace enumPort;
// CDlgProcessPort 对话框
typedef struct tagPortColInfo
{
CString strColName; // Colnum名称
UINT uWidth; // Colnum宽度
}PortColInfo;
class CDlgProcessPort : public CDialog
{
DECLARE_DYNAMIC(CDlgProcessPort)
public:
CDlgProcessPort(CWnd* pParent = NULL); // 标准构造函数
virtual ~CDlgProcessPort();
// 对话框数据
enum { IDD = IDD_FORMVIEW_PROCESS_TAB_PORT };
private:
CSortListCtrl m_wndListPort; // List Ctrl
CFont m_font; // the Font of List
CriticalSection m_cs; // 关键段
int m_nProcessID; // 当前选中进程ID
CWinThread *m_pPortThread; // 获取端口信息线程
vector<PortInfo> m_vecPortInfo; // 端口信息
static const PortColInfo m_PortColInfo[]; // 模块List显示信息
private:
void InitList(); // 初始化ListCtrl
void InsertItem(); // 插入数据
static DWORD WINAPI PortInfoThread(LPVOID pVoid); // 端口工作线程
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
virtual void PreSubclassWindow();
public:
DECLARE_EASYSIZE
DECLARE_MESSAGE_MAP()
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
afx_msg LRESULT OnLoadPortInfo(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnFlushPortInfo(WPARAM wParam,LPARAM lParam);
};
| [
"chenyu2202863@gmail.com@97a26042-f463-11dd-a7be-4b3ef3b0700c"
] | chenyu2202863@gmail.com@97a26042-f463-11dd-a7be-4b3ef3b0700c |
53575ccad2f2d40f2c7b7d0f0422346630cf9831 | 5888c735ac5c17601969ebe215fd8f95d0437080 | /Codeforces round Solution/code_forces(360)a.cpp | b4305c5b78ce1d3a54fbceebe9fa42c8f9d1fa0a | [] | no_license | asad14053/My-Online-Judge-Solution | 8854dc2140ba7196b48eed23e48f0dcdb8aec83f | 20a72ea99fc8237ae90f3cad7624224be8ed4c6c | refs/heads/master | 2021-06-16T10:41:34.247149 | 2019-07-30T14:44:09 | 2019-07-30T14:44:09 | 40,115,430 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 384 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
int n,d;
while(cin>>n>>d)
{int c1=0,c2=0,ans=0,m;
while(d--)
{
cin>>a;
m=a.find('0');
m=m+1;
if(m)
c1++;
else
c1=0;
ans=max(ans,c1);
}
cout<<ans<<endl;
}
return 0;
}
| [
"asad14053@users.noreply.github.com"
] | asad14053@users.noreply.github.com |
d8c57d1127fd961eaa240b3c0463b93353e2cb55 | 4be1d4819a60e2db72b59dd7f0fd4c03436283b3 | /Data Structures/Stack/STL implementation.cpp | fb3ddac2d4861684d23c3818322bafa329827b6b | [] | no_license | barath83/DSA-and-Programming-Concepts | c1797484525fd8e81f1b7deb88e030cb3a46a571 | e568a8cca3b1c4c98c870852783bec2b18b21647 | refs/heads/master | 2023-01-14T04:44:05.093279 | 2020-11-10T02:36:16 | 2020-11-10T02:36:16 | 290,454,101 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 753 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
//declare a stack which can store integer values
stack<int> s;
//pushing values into stack
s.push(1);
s.push(2);
s.push(3);
s.push(4);
s.push(5);
//printing the peak element in stack
cout<<"The topmost element in stack is "<<s.top()<<endl;
//popping off elements in stack
s.pop();
s.pop();
//printing all the remaining elements in stack
//loop till the stack becomes empty
cout<<"Elements in stack currently:"<<endl;
while(!s.empty())
{
//for each iteration print the topmost element
//pop the element from stack
int x = s.top();
s.pop();
cout<<x<<" ";
}
cout<<endl;
} | [
"barathgopi1699@gmail.com"
] | barathgopi1699@gmail.com |
340eec63799cf8f1d367e12c199529a6f224cb28 | 274098aed7550798f9be07ef71664fe1b2fb1fd8 | /src/test/allocator_tests.cpp | b9e11445450af312ba9e801fe079010907c0d853 | [
"MIT"
] | permissive | rog64/masterbit | 7e16a3af2f4a96470ab97bbfc655bc8031dabcb4 | 9d61d18bbb9174014b8a3734e64e1c00ae109f8a | refs/heads/master | 2020-05-01T19:40:32.588269 | 2018-04-26T18:31:28 | 2018-04-26T18:31:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,921 | cpp | // Copyright (c) 2012-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "util.h"
#include "support/allocators/secure.h"
#include "test/test_masterbit.h"
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(allocator_tests, BasicTestingSetup)
// Dummy memory page locker for platform independent tests
static const void *last_lock_addr, *last_unlock_addr;
static size_t last_lock_len, last_unlock_len;
class TestLocker
{
public:
bool Lock(const void *addr, size_t len)
{
last_lock_addr = addr;
last_lock_len = len;
return true;
}
bool Unlock(const void *addr, size_t len)
{
last_unlock_addr = addr;
last_unlock_len = len;
return true;
}
};
BOOST_AUTO_TEST_CASE(test_LockedPageManagerBase)
{
const size_t test_page_size = 4096;
LockedPageManagerBase<TestLocker> lpm(test_page_size);
size_t addr;
last_lock_addr = last_unlock_addr = 0;
last_lock_len = last_unlock_len = 0;
/* Try large number of small objects */
addr = 0;
for(int i=0; i<1000; ++i)
{
lpm.LockRange(reinterpret_cast<void*>(addr), 33);
addr += 33;
}
/* Try small number of page-sized objects, straddling two pages */
addr = test_page_size*100 + 53;
for(int i=0; i<100; ++i)
{
lpm.LockRange(reinterpret_cast<void*>(addr), test_page_size);
addr += test_page_size;
}
/* Try small number of page-sized objects aligned to exactly one page */
addr = test_page_size*300;
for(int i=0; i<100; ++i)
{
lpm.LockRange(reinterpret_cast<void*>(addr), test_page_size);
addr += test_page_size;
}
/* one very large object, straddling pages */
lpm.LockRange(reinterpret_cast<void*>(test_page_size*600+1), test_page_size*500);
BOOST_CHECK(last_lock_addr == reinterpret_cast<void*>(test_page_size*(600+500)));
/* one very large object, page aligned */
lpm.LockRange(reinterpret_cast<void*>(test_page_size*1200), test_page_size*500-1);
BOOST_CHECK(last_lock_addr == reinterpret_cast<void*>(test_page_size*(1200+500-1)));
BOOST_CHECK(lpm.GetLockedPageCount() == (
(1000*33+test_page_size-1)/test_page_size + // small objects
101 + 100 + // page-sized objects
501 + 500)); // large objects
BOOST_CHECK((last_lock_len & (test_page_size-1)) == 0); // always lock entire pages
BOOST_CHECK(last_unlock_len == 0); // nothing unlocked yet
/* And unlock again */
addr = 0;
for(int i=0; i<1000; ++i)
{
lpm.UnlockRange(reinterpret_cast<void*>(addr), 33);
addr += 33;
}
addr = test_page_size*100 + 53;
for(int i=0; i<100; ++i)
{
lpm.UnlockRange(reinterpret_cast<void*>(addr), test_page_size);
addr += test_page_size;
}
addr = test_page_size*300;
for(int i=0; i<100; ++i)
{
lpm.UnlockRange(reinterpret_cast<void*>(addr), test_page_size);
addr += test_page_size;
}
lpm.UnlockRange(reinterpret_cast<void*>(test_page_size*600+1), test_page_size*500);
lpm.UnlockRange(reinterpret_cast<void*>(test_page_size*1200), test_page_size*500-1);
/* Check that everything is released */
BOOST_CHECK(lpm.GetLockedPageCount() == 0);
/* A few and unlocks of size zero (should have no effect) */
addr = 0;
for(int i=0; i<1000; ++i)
{
lpm.LockRange(reinterpret_cast<void*>(addr), 0);
addr += 1;
}
BOOST_CHECK(lpm.GetLockedPageCount() == 0);
addr = 0;
for(int i=0; i<1000; ++i)
{
lpm.UnlockRange(reinterpret_cast<void*>(addr), 0);
addr += 1;
}
BOOST_CHECK(lpm.GetLockedPageCount() == 0);
BOOST_CHECK((last_unlock_len & (test_page_size-1)) == 0); // always unlock entire pages
}
BOOST_AUTO_TEST_SUITE_END()
| [
"masterbit2050@gmail.com"
] | masterbit2050@gmail.com |
8e8dff5ad917d4845c26a4057812997b336dac14 | 8e088e87061a80345461c01fe29c4a3079455ba1 | /Business/VarCalcService/BondPriceSeries.h | a34a445e1ed85d6fb416fc2e56a242279557a976 | [] | no_license | awesometype/SacnTest | 71041b0c09bccb4ad3d8225e3a34778492820b4d | c3b3f9e440322c388d8e5a2912d9cc2f8c06cb25 | refs/heads/master | 2022-11-27T11:49:32.475311 | 2018-04-17T08:44:49 | 2018-04-17T08:44:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,169 | h | #ifndef _bondPriceseries_h_1987192
#define _bondPriceseries_h_1987192
#include "PriceSeriesGenerator.h"
struct _VAR_BondInfo{
long m_lSecuritiesId;
double m_dParRate;
double m_dHoldYear;
int m_iInterestType;
long m_lBeginDate;
long m_lEndDate;
int m_iPayInterestFrequence;
double m_dParValue;
int m_iBondType;
double m_dIssuePrice;
};
typedef struct _VAR_BondInfo VAR_BondInfo;
class CBondPriceSeries : public CPriceSeriesGenerator
{
public:
CBondPriceSeries();
CBondPriceSeries(long lLatestDate, int iSampleCount);
virtual ~CBondPriceSeries();
public:
virtual double GetLatestPrice(long lEntityID);
virtual int GetSeries(long lEntityID, std::vector<double> &arrSeries);
virtual CString ErrorCodeToString(int iError);
protected:
double GetBondTotalPrice(long lEntityID, long lDate);
bool GetBondInfo(long lSecurities, VAR_BondInfo &infoBond);
double CalcBondInterestPerShare(long lSecurities, long lDate);
double GetBondCashFlowYearRate(long lSecurities, long lDate);
double GetBondEndDayNetValue(long lSecurities);
long GetBondNearestInterestPayDate(long lSecurities, long lDate);
};
#endif | [
"2808050775@qq.com"
] | 2808050775@qq.com |
0ad29cb57c28fd2614f9f41048f290787c479d85 | 4ff51d00031103f1210f427e24eee7095a040db9 | /sqf/src/seabed/src/ms.cpp | bbd1a1e1a5c63dc6ec40213829b7ab79a616ee51 | [
"Apache-2.0"
] | permissive | rtvt123/core | e1f2e3d979651599249886dd837cfa83e64c87e2 | 29234db43a2a8ed50d83329ebfd3b920196ee18b | refs/heads/master | 2022-08-28T16:36:44.731024 | 2014-06-12T02:03:27 | 2014-06-12T02:03:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 130,796 | cpp | //------------------------------------------------------------------
//
// @@@ START COPYRIGHT @@@
//
// (C) Copyright 2006-2014 Hewlett-Packard Development Company, L.P.
//
// 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.
//
// @@@ END COPYRIGHT @@@
//
// special defines:
//
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <malloc.h>
#include <linux/unistd.h> // gettid
#include <sys/stat.h>
#include <sys/time.h>
#include "common/evl_sqlog_eventnum.h"
#include "seabed/fserr.h"
#include "seabed/log.h"
#include "seabed/ms.h"
#include "seabed/pctl.h"
#include "seabed/pevents.h"
#include "seabed/trace.h"
#include "apictr.h"
#include "buf.h"
#include "chk.h"
#include "compq.h"
#include "env.h"
#include "mserr.h"
#include "mserrmsg.h"
#include "msflowx.h"
#include "mslabelmapsx.h"
#include "msmon.h"
#include "mstrace.h"
#include "msutil.h"
#include "msvars.h"
#include "msx.h"
#include "pctlx.h"
#include "props.h"
#include "qid.h"
#include "smap.h"
#include "threadtlsx.h"
#include "timerx.h"
#include "util.h"
#include "utracex.h"
#define gettid() static_cast<pid_t>(syscall(__NR_gettid))
extern "C" const char *libsbms_vers2_str();
extern void SB_thread_main();
typedef void (*Prof_Flush)(const char *,int);
typedef union {
Prof_Flush iflush;
void *ipflush;
} Prof_Flush_Type;
typedef void (*Prof_Mark)();
typedef union {
Prof_Mark imark;
void *ipmark;
} Prof_Mark_Type;
typedef void (*Prof_Reset)();
typedef union {
Prof_Reset ireset;
void *ipreset;
} Prof_Reset_Type;
// from NSK: dmsghi
enum { MSG_MAXREPLYCTRLSIZE = 900 };
enum { MSG_MAXREQCTRLSIZE = 1100 };
enum { MSG_MINREPLYCTRLSIZE = 8 };
enum { MSG_MINREQCTRLSIZE = 8 };
static const char *gp_config_file = "ms.env";
static char *gp_config_arg_file = NULL;
// forwards
static void ms_fsdone_key_dtor(void *pp_queue);
static void ms_ldone_key_dtor(void *pp_queue);
static void ms_recv_q_proc_death_md(MS_Md_Type *pp_md,
int pv_nid,
int pv_pid,
bool pv_use_stream,
void *pp_stream);
// globals
SB_Comp_Queue gv_fs_comp_q(QID_FS_COMP, "q-fs-comp-md");
static SB_Comp_Queue gv_ms_abandon_comp_q(QID_ABANDON_COMP, "q-abandon-comp-md");
bool gv_ms_attach = false;
MS_Buf_Mgr_Type gv_ms_buf_mgr = {
{malloc}, {free},
{malloc}, {free}
};
int gv_ms_buf_options = 0;
bool gv_ms_calls_ok = false;
bool gv_ms_client_only = false;
int gv_ms_conn_idle_timeout = 0; // disabled
bool gv_ms_conn_reuse = true;
static int gv_ms_disable_wait = 0;
int gv_ms_disc_sem = 50;
bool gv_ms_disc_sem_rob = false;
bool gv_ms_disc_sem_stats = false;
int gv_ms_enable_messages = 0;
static SB_Props gv_ms_env(true);
static bool gv_ms_env_loaded = false;
SB_Ms_Tl_Event_Mgr gv_ms_event_mgr;
#ifdef USE_EVENT_REG
static bool gv_ms_event_wait_abort = true;
#endif
int gv_ms_fd_stderr = -1;
int gv_ms_fd_stdout = -1;
SB_Ts_Lmap gv_ms_fsdone_map("map-ms-fsdone"); // used by IC
static int gv_ms_fsdone_tls_inx =
SB_create_tls_key(ms_fsdone_key_dtor, "ms-fs-compq");
SB_Ts_D_Queue gv_ms_hold_q(QID_HOLD, "q-hold-md");
bool gv_ms_ic_ibv = false;
bool gv_ms_inited = false;
bool gv_ms_init_phandle = true;
bool gv_ms_init_test = false;
static SB_Comp_Queue gv_ms_ldone_comp_q(QID_LDONE_COMP, "q-ldone-comp-md");
static int gv_ms_ldone_tls_inx =
SB_create_tls_key(ms_ldone_key_dtor, "ms-compq");
MS_Lim_Queue_Cb_Type gv_ms_lim_cb = 0;
SB_Recv_Queue gv_ms_lim_q("lim-q-md");
int gv_ms_max_phandles = 0;
bool gv_ms_mon_calls_ok = false;
bool gv_ms_msg_timestamp = false;
bool gv_ms_pre_inited = false;
bool gv_ms_process_comp = false;
SB_Recv_Queue gv_ms_recv_q("recv-q-md");
bool gv_ms_recv_q_proc_death = false;
bool gv_ms_shutdown_called = false;
bool gv_ms_shutdown_fast = true;
bool gv_ms_trans_sock = false;
double gv_ms_wtime_adj;
enum { MAX_RETRIES = 5 };
static SB_Lmap gv_ms_abandon_map("map-ms-abandon");
bool gv_ms_assert_chk = false;
bool gv_ms_assert_chk_send = false;
SB_Ts_Lmap gv_ms_ldone_map("map-ms-ldone"); // used by IC
static SB_Smap gv_ms_phandle_map("map-ms-phandle");
void __attribute__((constructor)) __msg_init(void);
void __attribute__((destructor)) __msg_fini(void);
//
// forwards
//
static void ms_fifo_fd_restore();
static void ms_fifo_fd_save();
static bool ms_is_mon_number(char *pp_arg);
static void ms_ldone_key_dtor(void *pp_queue);
static void ms_ldone_key_dtor_lock(void *pp_queue, bool pv_lock);
static void msg_init_env_load();
static void msg_init_env_load_exe(const char *pp_exe, SB_Props *pp_env);
static void msg_init_trace_com(const char *pp_where,
int pv_argc,
char **ppp_argv);
//
// Implementation notes:
// Buffers are NOT checked for valid address.
// In linux kernel mode, it's possible to use the macro access_of(),
// but the macro is fairly crude in the checks that it makes.
// However, there is an assumption that the addresses will
// be checked by MPI at some point. The only real downside
// to this approach, is that a failure may be latently reported
// (e.g. in the case of MSG_LINK_ with a bad recv buffer address).
//
//
// Purpose: complete abandon (callback-target)
//
void ms_abandon_cbt(MS_Md_Type *pp_md, bool pv_add) {
const char *WHERE = "ms_abandon_cbt";
if (pv_add) {
gv_ms_abandon_comp_q.add(&pp_md->iv_link);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "setting LCAN, msgid=%d\n",
pp_md->iv_link.iv_id.i);
} else {
// remove from abandon-q
gv_ms_abandon_comp_q.remove_list(&pp_md->iv_link);
}
}
//
// Purpose:
//
void ms_fifo_setup(int pv_orig_fd, char *pp_fifo_name) {
const char *WHERE = "ms_fifo_setup";
int lv_err;
int lv_fifo_fd;
if (gv_ms_trace)
trace_where_printf(WHERE, "opening fifo to monitor, fifo=%s, fd=%d\n",
pp_fifo_name, pv_orig_fd);
// Open the fifo for writing.
lv_fifo_fd = open(pp_fifo_name, O_WRONLY);
if (lv_fifo_fd == -1) {
if (gv_ms_trace)
trace_where_printf("fifo open error, fifo=%s, errno=%d\n",
pp_fifo_name, errno);
} else {
// Remap fifo file descriptor
// Close unneeded fifo file descriptor.
lv_err = close(pv_orig_fd);
if (lv_err == -1) {
if (gv_ms_trace)
trace_where_printf(WHERE, "fifo original close error, fd=%d, errno=%d\n",
pv_orig_fd, errno);
}
lv_err = dup2(lv_fifo_fd, pv_orig_fd);
if (lv_err == -1) {
if (gv_ms_trace)
trace_where_printf(WHERE, "fifo dup2 error, old-fd=%d, new-fd=%d, errno=%d\n",
lv_fifo_fd, pv_orig_fd, errno);
} else {
lv_err = close(lv_fifo_fd);
if (lv_err == -1) {
if (gv_ms_trace)
trace_where_printf(WHERE, "fifo close error, fifo-fd=%d, errno=%d\n",
lv_fifo_fd, errno);
}
}
}
}
//
// Purpose: Restore standard fds
//
void ms_fifo_fd_restore() {
if (gv_ms_fd_stdout != -1)
dup2(gv_ms_fd_stdout, 1);
if (gv_ms_fd_stderr != -1)
dup2(gv_ms_fd_stderr, 1);
}
//
// Purpose: Save standard fds
//
void ms_fifo_fd_save() {
gv_ms_fd_stdout = dup(1);
gv_ms_fd_stderr = dup(2);
}
//
// Purpose: Set requeue in md
//
void ms_msg_set_requeue(const char *pp_where, int pv_msgid, bool pv_requeue) {
MS_Md_Type *lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, pp_where);
lp_md->out.iv_requeue = pv_requeue;
}
void ms_buf_free(void *pp_buf) {
const char *WHERE = "msg_buf_free";
if (gv_ms_trace_alloc)
trace_where_printf(WHERE,
"ENTER buf=%p\n", pp_buf);
gv_ms_buf_mgr.ufi.ifree(pp_buf);
}
void *ms_buf_malloc(size_t pv_size) {
const char *WHERE = "msg_buf_malloc";
void *lp_buf = gv_ms_buf_mgr.uai.ialloc(pv_size);
if (gv_ms_trace_alloc)
trace_where_printf(WHERE,
"EXIT size=" PFSZ ", buf=%p\n",
pv_size,
lp_buf);
return lp_buf;
}
//
// Purpose: set buf manager
// If tracing, call through tracer.
// If no tracing, call directly.
//
void ms_buf_trace_change() {
if (gv_ms_trace_enable && gv_ms_trace_alloc) {
gv_ms_buf_mgr.ua.ialloc = ms_buf_malloc;
gv_ms_buf_mgr.uf.ifree = ms_buf_free;
} else {
gv_ms_buf_mgr.ua.ialloc = gv_ms_buf_mgr.uai.ialloc;
gv_ms_buf_mgr.uf.ifree = gv_ms_buf_mgr.ufi.ifree;
}
}
//
// Purpose: set options
//
SB_Export short msg_buf_options(int pv_options) {
const char *WHERE = "msg_buf_options";
SB_API_CTR (lv_zctr, MSG_BUF_OPTIONS);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER options=0x%x\n", pv_options);
short lv_fserr = XZFIL_ERR_OK;
if (gv_ms_inited)
lv_fserr = XZFIL_ERR_INVALIDSTATE;
else if (pv_options & ~MS_BUF_OPTION_ALL) {
// reserved bits turned on - error
lv_fserr = XZFIL_ERR_BOUNDSERR;
}
if (lv_fserr == XZFIL_ERR_OK)
gv_ms_buf_options = pv_options;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: read-ctrl
//
SB_Export short msg_buf_read_ctrl(int pv_msgid,
short **ppp_reqctrl,
int *pp_bytecount,
int pv_clear) {
const char *WHERE = "msg_buf_read_ctrl";
MS_Md_Type *lp_md;
SB_API_CTR (lv_zctr, MSG_BUF_READ_CTRL);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER msgid=%d, reqC=%p, bytecount=%p, clear=%d\n",
pv_msgid, pfp(ppp_reqctrl),
pfp(pp_bytecount), pv_clear);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, WHERE);
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
int lv_bytecount = lp_md->out.iv_recv_ctrl_size;
if (pp_bytecount != NULL)
*pp_bytecount = lv_bytecount;
*ppp_reqctrl = reinterpret_cast<short *>(lp_md->out.ip_recv_ctrl);
if (pv_clear) {
lp_md->out.ip_recv_ctrl = NULL;
lp_md->out.iv_recv_ctrl_size = 0;
}
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"reqC=%p, bytecount=%d\n",
pfp(*ppp_reqctrl), lv_bytecount);
trace_print_data(*ppp_reqctrl, lv_bytecount, gv_ms_trace_data_max);
}
short lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: read-data
//
SB_Export short msg_buf_read_data(int pv_msgid,
char **ppp_buffer,
int *pp_bytecount,
int pv_clear) {
const char *WHERE = "msg_buf_read_data";
MS_Md_Type *lp_md;
SB_API_CTR (lv_zctr, MSG_BUF_READ_DATA);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER msgid=%d, buffer=%p, bytecount=%p, clear=%d\n",
pv_msgid, pfp(ppp_buffer),
pfp(pp_bytecount), pv_clear);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, WHERE);
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
int lv_bytecount = lp_md->out.iv_recv_data_size;
if (pp_bytecount != NULL)
*pp_bytecount = lv_bytecount;
*ppp_buffer = lp_md->out.ip_recv_data;
if (pv_clear) {
lp_md->out.ip_recv_data = NULL;
lp_md->out.iv_recv_data_size = 0;
}
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"buffer=%p, bytecount=%d\n",
*ppp_buffer, lv_bytecount);
trace_print_data(*ppp_buffer, lv_bytecount, gv_ms_trace_data_max);
}
short lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: read-data
// (similar to BMSG_READDATA_ except no abandon check)
//
short msg_buf_read_data_int(int pv_msgid,
char *pp_reqdata,
int pv_bytecount) {
const char *WHERE = "msg_buf_read_data_int";
MS_Md_Type *lp_md;
int lv_rc;
SB_API_CTR (lv_zctr, BMSG_READDATA_);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER msgid=%d, reqD=%p, bytecount=%d\n",
pv_msgid, pp_reqdata, pv_bytecount);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, WHERE);
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
SB_Trans::Trans_Stream::recv_copy(WHERE,
&lp_md->out.ip_recv_data,
lp_md->out.iv_recv_data_size,
pp_reqdata,
pv_bytecount,
&lv_rc,
false);
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"reqD=%p, bytecount=%d\n",
pp_reqdata, lv_rc);
trace_print_data(pp_reqdata, lv_rc, gv_ms_trace_data_max);
}
short lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: register buffer
//
SB_Export short msg_buf_register(MS_Buf_Alloc_Cb_Type pv_callback_alloc,
MS_Buf_Free_Cb_Type pv_callback_free) {
const char *WHERE = "msg_buf_register";
short lv_fserr;
SB_API_CTR (lv_zctr, MSG_BUF_REGISTER);
if (gv_ms_inited)
lv_fserr = XZFIL_ERR_INVALIDSTATE;
else {
lv_fserr = XZFIL_ERR_OK;
gv_ms_buf_mgr.ua.ialloc = pv_callback_alloc;
gv_ms_buf_mgr.uf.ifree = pv_callback_free;
gv_ms_buf_mgr.uai.ialloc = pv_callback_alloc;
gv_ms_buf_mgr.ufi.ifree = pv_callback_free;
}
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return lv_fserr;
}
//
// Purpose: debug hook
//
SB_Export void msg_debug_hook(const char *pp_who, const char *pp_fname) {
char la_buf[500];
char *lp_p;
int lv_enable;
int lv_err;
struct stat lv_stat;
SB_API_CTR (lv_zctr, MSG_DEBUG_HOOK);
lp_p = getenv(gp_ms_env_hook_enable);
if (lp_p == NULL)
return;
lv_enable = atoi(lp_p);
if (!lv_enable)
return;
lv_err = stat(pp_fname, &lv_stat);
if (lv_err == -1) {
lp_p = getcwd(la_buf, sizeof(la_buf));
printf("%s: create file %s/%s to continue\n",
pp_who, lp_p, pp_fname);
printf("%s: slave pid=%d\n", pp_who, getpid());
for (;;) {
lv_err = stat(pp_fname, &lv_stat);
if (lv_err == 0) {
printf("%s: %s detected - continuing\n", pp_who, pp_fname);
break;
}
sleep(1); // msg_debug_hook
}
}
}
//
// Purpose: set lim-queue
//
SB_Export void msg_enable_lim_queue(MS_Lim_Queue_Cb_Type pv_cb) {
const char *WHERE = "msg_enable_lim_queue";
SB_API_CTR (lv_zctr, MSG_ENABLE_LIM_QUEUE);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER\n");
gv_ms_lim_cb = pv_cb;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT\n");
}
//
// Purpose: set open-cleanup
//
SB_Export int msg_enable_open_cleanup() {
const char *WHERE = "msg_enable_open_cleanup";
int lv_fserr;
SB_API_CTR (lv_zctr, MSG_ENABLE_OPEN_CLEANUP);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER\n");
lv_fserr = ms_od_cleanup_enable();
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return lv_fserr;
}
//
// Purpose: set priority-queue
//
SB_Export void msg_enable_priority_queue() {
const char *WHERE = "msg_enable_priority_queue";
SB_API_CTR (lv_zctr, MSG_ENABLE_PRIORITY_QUEUE);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER\n");
gv_ms_recv_q.set_priority_queue(true);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT\n");
}
//
// Purpose: set proc-death on recv-queue
//
SB_Export void msg_enable_recv_queue_proc_death() {
const char *WHERE = "msg_enable_recv_queue_proc_death";
SB_API_CTR (lv_zctr, MSG_ENABLE_RECV_QUEUE_PROC_DEATH);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER\n");
gv_ms_recv_q_proc_death = true;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT\n");
}
//
// Purpose: Check mpi error - pathdown ok
//
void ms_err_check_mpi_pathdown_ok(const char *pp_where,
const char *pp_msg,
short pv_fserr) {
switch (pv_fserr) {
case XZFIL_ERR_OK:
case XZFIL_ERR_DEVDOWN:
case XZFIL_ERR_PATHDOWN:
break;
default:
if (gv_ms_trace_params)
trace_where_printf(pp_where, "%s, fserr=%d\n", pp_msg, pv_fserr);
SB_util_assert((pv_fserr == XZFIL_ERR_OK) ||
(pv_fserr == XZFIL_ERR_DEVDOWN) ||
(pv_fserr == XZFIL_ERR_PATHDOWN));
break;
}
}
//
// Purpose: return an ms error
//
static short ms_err_mpi_rtn(const char *pp_where, int pv_mpierr) {
return ms_err_rtn(ms_err_mpi_to_fserr(pp_where, pv_mpierr));
}
//
// Purpose: trace msg and return an ms error
//
short ms_err_mpi_rtn_msg(const char *pp_where,
const char *pp_msg,
int pv_mpierr) {
return ms_err_rtn_msg(pp_where, pp_msg,
ms_err_mpi_to_fserr(pp_where, pv_mpierr));
}
//
// Purpose: trace msg and return an ms error
//
short ms_err_mpi_rtn_msg_noassert(const char *pp_where,
const char *pp_msg,
int pv_mpierr) {
return ms_err_rtn_msg_noassert(pp_where, pp_msg,
ms_err_mpi_to_fserr(pp_where, pv_mpierr));
}
//
// Purpose: fatal error
//
short ms_err_mpi_rtn_msg_fatal(const char *pp_where,
const char *pp_msg,
int pv_mpierr) {
short lv_fserr = ms_err_mpi_to_fserr(pp_where, pv_mpierr);
return ms_err_rtn_msg_fatal(pp_where, pp_msg, lv_fserr, true);
}
//
// Purpose: free recv buffers
//
void ms_free_recv_bufs(MS_Md_Type *pp_md) {
if (pp_md->out.ip_recv_ctrl != NULL) {
MS_BUF_MGR_FREE(pp_md->out.ip_recv_ctrl);
pp_md->out.ip_recv_ctrl = NULL;
}
if (pp_md->out.ip_recv_data != NULL) {
MS_BUF_MGR_FREE(pp_md->out.ip_recv_data);
pp_md->out.ip_recv_data = NULL;
}
}
//
// Purpose: get completion queue
//
SB_Comp_Queue *ms_fsdone_get_comp_q(bool pv_ts) {
SB_Comp_Queue *lp_queue;
int lv_status;
if (pv_ts) {
lp_queue =
static_cast<SB_Comp_Queue *>(SB_Thread::Sthr::specific_get(gv_ms_fsdone_tls_inx));
if (lp_queue == NULL) {
lp_queue =
new SB_Comp_Queue(QID_FS_TS_COMP, "q-fsdone-ts-comp-md");
SB_LML_Type *lp_info = new SB_LML_Type;
lp_info->iv_id.l = reinterpret_cast<long>(lp_queue);
gv_ms_fsdone_map.put(lp_info);
lv_status = SB_Thread::Sthr::specific_set(gv_ms_fsdone_tls_inx, lp_queue);
SB_util_assert_ieq(lv_status, 0);
}
} else
lp_queue = &gv_fs_comp_q;
return lp_queue;
}
//
// cleanup TS completion-queue
//
static void ms_fsdone_key_dtor(void *pp_queue) {
SB_Comp_Queue *lp_queue = static_cast<SB_Comp_Queue *>(pp_queue);
if (lp_queue != NULL) {
SB_LML_Type *lp_info =
static_cast<SB_LML_Type *>(gv_ms_fsdone_map.remove_lock(reinterpret_cast<long>(lp_queue), false));
if (lp_info != NULL) {
// only delete if it hasn't already been deleted
delete lp_info;
delete lp_queue;
}
}
}
//
// Purpose: map FS error to results error
//
static void ms_fserr_to_results(short pv_fserr, MS_Result_Type *pp_results) {
// TODO revisit
switch (pv_fserr) {
case XZFIL_ERR_OK:
break;
case XZFIL_ERR_DEVDOWN:
case XZFIL_ERR_PATHDOWN:
pp_results->rr_ctrlsize = 0;
pp_results->rr_datasize = 0;
pp_results->rrerr_updatedestb = 1;
pp_results->rrerr_countitb = 1;
pp_results->rrerr_startedb = 1;
pp_results->rrerr_retryableb = 1;
pp_results->rrerr_errorb = 1;
break;
default:
pp_results->rr_ctrlsize = 0;
pp_results->rr_datasize = 0;
pp_results->rrerr_startedb = 1;
pp_results->rrerr_errorb = 1;
break;
}
}
// Purpose: gather some helpful info
//
void ms_gather_info(const char *pp_where) {
char la_host[HOST_NAME_MAX];
int lv_err;
if (gv_ms_su_nid >= 0)
trace_where_printf(pp_where, "pname=%s, nid=%d, pid=%d\n",
ga_ms_su_pname, gv_ms_su_nid, getpid());
else
trace_where_printf(pp_where, "pname=%s, pid=%d\n", ga_ms_su_pname, getpid());
lv_err = gethostname(la_host, HOST_NAME_MAX);
if (lv_err == -1)
trace_where_printf(pp_where, "gethostname ret=%d\n", lv_err);
else
trace_where_printf(pp_where, "gethostname host=%s\n", la_host);
FILE *lp_file = fopen("/proc/cpuinfo", "r");
if (lp_file != NULL) {
char la_line[100];
const char *lp_core = "core id\t";
const char *lp_cores = "cpu cores\t";
const char *lp_model = "model name\t";
const char *lp_proc = "processor\t";
const char *lp_speed = "cpu MHz\t";
int lv_core_len = static_cast<int>(strlen(lp_core));
int lv_cores_len = static_cast<int>(strlen(lp_cores));
int lv_model_len = static_cast<int>(strlen(lp_model));
int lv_proc_len = static_cast<int>(strlen(lp_proc));
int lv_speed_len = static_cast<int>(strlen(lp_speed));
int lv_max_proc = -1;
for (;;) {
char *lp_s = fgets(la_line, sizeof(la_line), lp_file);
if (lp_s == NULL)
break;
#ifdef DEBUG_PRINT
printf("/proc/cpuinfo=%s", la_line);
fflush(stdout);
#else
if ((memcmp(lp_s, lp_core, lv_core_len) == 0) ||
(memcmp(lp_s, lp_cores, lv_cores_len) == 0) ||
(memcmp(lp_s, lp_proc, lv_proc_len) == 0) ||
(memcmp(lp_s, lp_model, lv_model_len) == 0) ||
(memcmp(lp_s, lp_speed, lv_speed_len) == 0))
trace_where_printf(pp_where, "/proc/cpuinfo=%s", lp_s);
#endif // !DEBUG_PRINT
if (memcmp(lp_s, lp_proc, lv_proc_len) == 0) {
char la_colon[100];
char la_proc[100];
int lv_proc;
sscanf(lp_s, "%s %s %d",
la_proc, la_colon, &lv_proc);
if (lv_proc > lv_max_proc)
lv_max_proc = lv_proc;
}
}
fclose(lp_file);
if (lv_max_proc >= 0)
lv_max_proc++;
trace_where_printf(pp_where, "max processors=%d\n", lv_max_proc);
}
}
//
// Purpose: check if monitor number
//
bool ms_is_mon_number(char *pp_arg) {
int lv_inx;
int lv_len;
lv_len = static_cast<int>(strlen(pp_arg));
if ((lv_len != 5) && (lv_len != 6))
return false;
for (lv_inx = 0; lv_inx < lv_len; lv_inx++)
if (!isdigit(pp_arg[lv_inx]))
return false;
return true;
}
//
// Purpose: complete ldone (callback-target)
//
void ms_ldone_cbt(MS_Md_Type *pp_md) {
SB_Comp_Queue *lp_comp_q;
lp_comp_q = pp_md->ip_comp_q; // in case break called
if (lp_comp_q != NULL)
lp_comp_q->add(&pp_md->iv_link);
if (gv_ms_process_comp) {
#ifdef USE_EVENT_REG
gv_ms_event_mgr.set_event_reg(LDONE);
#else
gv_ms_event_mgr.get_gmgr()->set_event(LDONE, &pp_md->iv_reply_done);
#endif
} else
pp_md->ip_mgr->set_event_atomic(LDONE, &pp_md->iv_reply_done);
}
//
// Purpose: get completion queue
//
SB_Comp_Queue *ms_ldone_get_comp_q() {
int lv_status;
if (gv_ms_process_comp)
return &gv_ms_ldone_comp_q;
SB_Comp_Queue *lp_queue =
static_cast<SB_Comp_Queue *>(SB_Thread::Sthr::specific_get(gv_ms_ldone_tls_inx));
if (lp_queue == NULL) {
lp_queue = new SB_Comp_Queue(QID_LDONE_COMP, "q-ldone-comp-md");
SB_LML_Type *lp_info = new SB_LML_Type;
lp_info->iv_id.l = reinterpret_cast<long>(lp_queue);
gv_ms_ldone_map.put(lp_info);
lv_status = SB_Thread::Sthr::specific_set(gv_ms_ldone_tls_inx, lp_queue);
SB_util_assert_ieq(lv_status, 0);
}
return lp_queue;
}
static void ms_ldone_key_dtor(void *pp_queue) {
ms_ldone_key_dtor_lock(pp_queue, true);
}
static void ms_ldone_key_dtor_lock(void *pp_queue, bool pv_lock) {
SB_Comp_Queue *lp_queue = static_cast<SB_Comp_Queue *>(pp_queue);
if (lp_queue != NULL) {
if (pv_lock)
gv_ms_ldone_map.lock();
SB_LML_Type *lp_info =
static_cast<SB_LML_Type *>(gv_ms_ldone_map.remove_lock(reinterpret_cast<long>(lp_queue), false));
if (lp_info != NULL) {
// only delete if it hasn't already been deleted
delete lp_info;
delete lp_queue;
}
if (pv_lock)
gv_ms_ldone_map.unlock();
}
}
static void ms_ldone_shutdown() {
void *lp_queue;
bool lv_done;
lv_done = false;
do {
gv_ms_ldone_map.lock();
SB_Lmap_Enum *lp_enum = gv_ms_ldone_map.keys();
if (lp_enum->more()) {
SB_LML_Type *lp_info = static_cast<SB_LML_Type *>(lp_enum->next());
lp_queue = reinterpret_cast<void *>(lp_info->iv_id.l);
ms_ldone_key_dtor_lock(lp_queue, false);
} else
lv_done = true;
delete lp_enum;
gv_ms_ldone_map.unlock();
} while (!lv_done);
}
//
// Purpose: getenv (bool)
//
void ms_getenv_bool(const char *pp_key, bool *pp_val) {
const char *lp_p = ms_getenv_str(pp_key);
if (lp_p != NULL)
*pp_val = atoi(lp_p);
}
//
// Purpose: getenv (int)
//
void ms_getenv_int(const char *pp_key, int *pp_val) {
const char *lp_p = ms_getenv_str(pp_key);
if (lp_p != NULL)
*pp_val = atoi(lp_p);
}
//
// Purpose: getenv (long long)
//
void ms_getenv_longlong(const char *pp_key, long long *pp_val) {
const char *lp_p = ms_getenv_str(pp_key);
if (lp_p != NULL)
*pp_val = atoll(lp_p);
}
//
// Purpose: getenv (either regular env or properties file)
//
const char *ms_getenv_str(const char *pp_key) {
if (!gv_ms_env_loaded) {
if (!gv_ms_env.load(gp_config_arg_file)) { // try to load arg config
if (!gv_ms_env.load(gp_config_file)) { // try to load default config
char *lp_root = getenv(gp_ms_env_sq_root);
if (lp_root != NULL) {
SB_Buf_Lline lv_file;
sprintf(&lv_file, "%s/etc/%s", lp_root, gp_config_file);
gv_ms_env.load(&lv_file);
}
}
}
msg_init_env_load();
gv_ms_env_loaded = true;
}
const char *lp_value = gv_ms_env.get(pp_key);
if (lp_value == NULL)
lp_value = getenv(pp_key);
return lp_value;
}
//
// Purpose: mark recv-q items with proc-death
//
void ms_recv_q_proc_death(int pv_nid,
int pv_pid,
bool pv_use_stream,
void *pp_stream) {
const char *WHERE = "ms_recv_q_proc_death";
MS_Md_Type *lp_md;
if (gv_ms_trace)
trace_where_printf(WHERE, "nid=%d, pid=%d\n",
pv_nid, pv_pid);
gv_ms_recv_q.lock();
lp_md = reinterpret_cast<MS_Md_Type *>(gv_ms_recv_q.head());
while (lp_md != NULL) {
ms_recv_q_proc_death_md(lp_md,
pv_nid,
pv_pid,
pv_use_stream,
pp_stream);
lp_md = reinterpret_cast<MS_Md_Type *>(lp_md->iv_link.ip_next);
}
gv_ms_recv_q.unlock();
gv_ms_lim_q.lock();
lp_md = reinterpret_cast<MS_Md_Type *>(gv_ms_lim_q.head());
while (lp_md != NULL) {
ms_recv_q_proc_death_md(lp_md,
pv_nid,
pv_pid,
pv_use_stream,
pp_stream);
lp_md = reinterpret_cast<MS_Md_Type *>(lp_md->iv_link.ip_next);
}
gv_ms_lim_q.unlock();
}
void ms_recv_q_proc_death_md(MS_Md_Type *pp_md,
int pv_nid,
int pv_pid,
bool pv_use_stream,
void *pp_stream) {
const char *WHERE = "ms_recv_q_proc_death_md";
if (!pp_md->out.iv_mon_msg) {
if ((pp_md->out.iv_nid == pv_nid) && (pp_md->out.iv_pid == pv_pid)) {
if (!pv_use_stream ||
(pv_use_stream && (pp_stream == pp_md->ip_stream))) {
pp_md->out.iv_opts |= SB_Trans::MS_OPTS_PROCDEAD;
if (gv_ms_trace)
trace_where_printf(WHERE, "msgid=%d, nid=%d, pid=%d, stream=%p\n",
pp_md->iv_link.iv_id.i,
pv_nid,
pv_pid,
pp_stream);
}
}
}
}
//
// Purpose: shutdown
//
void ms_shutdown() {
ms_ldone_shutdown();
sb_timer_shutdown();
#ifdef SB_THREAD_LOCK_STATS
SB_Buf_Lline lv_cmdline;
char *lp_s = SB_util_get_cmdline(0,
false, // args
&lv_cmdline,
lv_cmdline.size());
if (lp_s == NULL)
lp_s = const_cast<char *>("<unknown>");
SB_Buf_Line la_where;
sprintf(la_where, "pid=%d, cmd=%s", getpid(), lp_s);
gv_sb_lock_stats.print(la_where);
#endif
ms_fifo_fd_restore();
}
void ms_trace_msg_ts(char *pp_str, struct timeval *pp_tv) {
int lv_hr;
int lv_min;
int lv_sec;
lv_sec = static_cast<int>(pp_tv->tv_sec) % 86400;
lv_hr = lv_sec / 3600;
lv_sec %= 3600;
lv_min = lv_sec / 60;
lv_sec = lv_sec % 60;
sprintf(pp_str, "%02d:%02d:%02d.%06ld",
lv_hr, lv_min, lv_sec, pp_tv->tv_usec);
}
SB_Export SB_Phandle_Type *msg_get_phandle(char *pp_pname) {
return msg_get_phandle(pp_pname, NULL);
}
SB_Export SB_Phandle_Type *msg_get_phandle(char *pp_pname, int *pp_fserr) {
const char *WHERE = "msg_get_phandle";
char la_pname[MS_MON_MAX_PROCESS_NAME+1];
SB_Phandle_Type *lp_phandle;
int lv_fserr;
int lv_oid;
SB_Phandle_Type lv_phandle;
SB_API_CTR (lv_zctr, MSG_GET_PHANDLE);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER pname=%s, fserr=%p\n",
pp_pname, pfp(pp_fserr));
SB_util_get_case_insensitive_name(pp_pname, la_pname);
lp_phandle =
static_cast<SB_Phandle_Type *>(gv_ms_phandle_map.getv(la_pname));
if (lp_phandle == NULL) {
lv_fserr = msg_mon_open_process(la_pname, &lv_phandle, &lv_oid);
if (lv_fserr == XZFIL_ERR_OK) {
lv_fserr = msg_set_phandle(la_pname, &lv_phandle);
SB_util_assert_ieq(lv_fserr, XZFIL_ERR_OK);
lp_phandle =
static_cast<SB_Phandle_Type *>(gv_ms_phandle_map.getv(la_pname));
SB_util_assert_pne(lp_phandle, NULL);
} else
lp_phandle = NULL;
} else
lv_fserr = XZFIL_ERR_OK;
if (pp_fserr != NULL)
*pp_fserr = lv_fserr;
if (gv_ms_trace_params) {
char la_phandle[MSG_UTIL_PHANDLE_LEN];
msg_util_format_phandle(la_phandle, lp_phandle);
trace_where_printf(WHERE,
"EXIT phandle=%s, fserr=%d\n",
la_phandle, lv_fserr);
}
return lp_phandle;
}
SB_Export SB_Phandle_Type *msg_get_phandle_no_open(char *pp_pname) {
const char *WHERE = "msg_get_phandle_no_open";
char la_pname[MS_MON_MAX_PROCESS_NAME+1];
SB_Phandle_Type *lp_phandle;
SB_API_CTR (lv_zctr, MSG_GET_PHANDLE_NO_OPEN);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER pname=%s\n", pp_pname);
SB_util_get_case_insensitive_name(pp_pname, la_pname);
lp_phandle =
static_cast<SB_Phandle_Type *>(gv_ms_phandle_map.getv(la_pname));
if (gv_ms_trace)
trace_where_printf(WHERE, "PHANDLES-inuse-count=%d\n",
gv_ms_phandle_map.size());
if (gv_ms_trace_params) {
char la_phandle[MSG_UTIL_PHANDLE_LEN];
msg_util_format_phandle(la_phandle, lp_phandle);
trace_where_printf(WHERE,
"EXIT phandle=%s\n", la_phandle);
}
return lp_phandle;
}
SB_Export void msg_getenv_bool(const char *pp_key, bool *pp_val) {
if (gv_ms_inited)
ms_getenv_bool(pp_key, pp_val);
}
SB_Export void msg_getenv_int(const char *pp_key, int *pp_val) {
if (gv_ms_inited)
ms_getenv_int(pp_key, pp_val);
}
SB_Export const char *msg_getenv_str(const char *pp_key) {
if (gv_ms_inited)
return ms_getenv_str(pp_key);
else
return NULL;
}
//
// Purpose: initialize msg module
//
SB_Export int msg_init(int *pp_argc, char ***pppp_argv)
SB_THROWS_FATAL {
SB_API_CTR (lv_zctr, MSG_INIT);
SB_UTRACE_API_TEST();
SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MSG_INIT, 0);
return msg_init_com(pp_argc,
pppp_argv,
true,
false,
false,
NULL,
true);
}
//
// Purpose: initialize msg module (attach)
//
SB_Export int msg_init_attach(int *pp_argc,
char ***pppp_argv,
int pv_forkexec,
char *pp_name)
SB_THROWS_FATAL {
SB_API_CTR (lv_zctr, MSG_INIT_ATTACH);
SB_UTRACE_API_TEST();
SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MSG_INIT_ATTACH, 0);
return msg_init_com(pp_argc,
pppp_argv,
true,
true,
pv_forkexec,
pp_name,
true);
}
//
// Purpose: initialize msg module (attach)
//
SB_Export int msg_init_attach_no_msg(int *pp_argc,
char ***pppp_argv,
int pv_forkexec,
char *pp_name)
SB_THROWS_FATAL {
SB_API_CTR (lv_zctr, MSG_INIT_ATTACH);
SB_UTRACE_API_TEST();
SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MSG_INIT_ATTACH, 0);
return msg_init_com(pp_argc,
pppp_argv,
true,
true,
pv_forkexec,
pp_name,
false);
}
//
// Purpose: initialize msg module
//
int msg_init_com(int *pp_argc,
char ***pppp_argv,
int pv_mpi_init,
bool pv_attach,
bool pv_forkexec,
char *pp_name,
bool pv_stderr)
SB_THROWS_FATAL {
const char *WHERE = "msg_init";
struct sigaction lv_act;
SB_Buf_Lline lv_cmdline;
int lv_err;
SB_Buf_Lline lv_line;
#ifdef USE_SB_SP_LOG
#if 0 // permanently disabled
int lv_status;
#endif
#endif
SB_UTRACE_MPI_TEST();
// TODO: remove when evlog gone
lv_act.sa_handler = SIG_IGN;
sigemptyset(&lv_act.sa_mask);
lv_act.sa_flags = 0;
lv_err = sigaction(SIGPIPE, &lv_act, NULL);
SB_util_assert_ieq(lv_err, 0);
gv_ms_su_pthread_self = pthread_self();
SB_util_get_cmdline(0,
false, // args
&lv_cmdline,
lv_cmdline.size());
ga_ms_su_prog[SB_MAX_PROG-1] = '\0';
strncpy(ga_ms_su_prog, basename(&lv_cmdline), SB_MAX_PROG-1);
SB_thread_main();
pctl_init();
if (pv_attach)
ms_fifo_fd_save();
pv_forkexec = pv_forkexec; // touch
if (gv_ms_inited && !gv_ms_init_test)
return ms_err_rtn_msg(WHERE, "msg-init: already initialized",
XZFIL_ERR_INVALIDSTATE);
// do this here, so we can trace
msg_init_trace_com(WHERE, *pp_argc, *pppp_argv);
// if we're supposed to attach, but we're started by shell, don't attach
if (pv_attach) {
if (*pp_argc >= 9) {
// "SQMON1.0" <pnid> <nid> <pid> <pname> <port> <ptype> <zid> "SPARE"
// [1] [2] [3] [4] [5] [6] [7] [8] [9]
if ((!strcmp((*pppp_argv)[1], "SQMON1.0")) &&
ms_is_mon_number((*pppp_argv)[2]) && // pnid
ms_is_mon_number((*pppp_argv)[3]) && // nid
ms_is_mon_number((*pppp_argv)[4]) && // pid
ms_is_mon_number((*pppp_argv)[7]) && // ptype
ms_is_mon_number((*pppp_argv)[8]) && // zid
(strlen((*pppp_argv)[5]) >= 2) && // pname
((*pppp_argv)[5][0] == '$')) {
pv_forkexec = false;
pv_attach = false;
}
}
}
if (gv_ms_trace_enable) {
SB_Buf_Line la_line;
sprintf(la_line, "argc=%d. argv=", *pp_argc);
msg_trace_args(la_line, *pppp_argv, *pp_argc, sizeof(la_line));
trace_where_printf(WHERE, "%s\n", la_line);
ms_gather_info(WHERE);
}
if (ms_getenv_str(gp_ms_env_assert_chk) == NULL)
gv_ms_assert_chk = true;
if (gv_ms_trace_enable)
trace_where_printf(WHERE, "TCP set, MS_ASSERT_CHK=%d\n",
gv_ms_assert_chk);
msg_mon_init();
if (pv_mpi_init) {
if (!pv_attach) {
int lv_fserr = msg_mon_init_process_args(WHERE, pp_argc, pppp_argv);
if (lv_fserr != XZFIL_ERR_OK)
return ms_err_rtn_msg_fatal(WHERE, "msg-init: process args failed",
static_cast<short>(lv_fserr), true);
}
#ifdef USE_EVENT_REG
// automatically register for main thread
if (getpid() == gettid()) {
proc_event_register(LREQ);
proc_event_register(LDONE);
// set LREQ.
// This is in case something was received before XWAIT called.
// The application may see spurious LREQ.
gv_ms_event_mgr.get_mgr(NULL)->set_event(LREQ, NULL);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "setting LREQ\n");
}
#else
// set LREQ.
// This is in case something was received before XWAIT called.
// The application may see spurious LREQ.
gv_ms_event_mgr.get_mgr(NULL)->set_event(LREQ, NULL);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "setting LREQ\n");
#endif
if (pv_attach) {
int lv_fserr = msg_mon_init_attach(WHERE, pp_name);
if (lv_fserr != XZFIL_ERR_OK)
return ms_err_rtn_msg_fatal(WHERE, "msg-init: init-attach failed",
static_cast<short>(lv_fserr),
pv_stderr);
}
} else
gv_ms_init_test = true;
// setup for start event (pid/etc set)
SB_util_get_cmdline(0,
true, // args
&lv_cmdline,
lv_cmdline.size());
sprintf(&lv_line, "msg_init - p-id=%d/%d, tid=%ld, pname=%s, cmdline=%s, %s\n",
gv_ms_su_nid,
gv_ms_su_pid,
SB_Thread::Sthr::self_id(),
ga_ms_su_pname,
&lv_cmdline,
ms_seabed_vers());
// setup timer module
sb_timer_init();
gv_ms_inited = true;
gv_ms_calls_ok = true;
gv_ms_attach = pv_attach;
#ifdef USE_SB_SP_LOG
#if 0 // permanently disabled
// issue start event (pid/etc set)
lv_status = SB_log_write_str(SQEVL_SEABED, // USE_SB_SP_LOG
SB_EVENT_ID,
SQ_LOG_SEAQUEST,
SQ_LOG_INFO,
&lv_line);
CHK_STATUSIGNORE(lv_status);
#endif
#endif
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT OK\n");
return ms_err_mpi_rtn(WHERE, MPI_SUCCESS);
}
//
// Purpose: initialize environment for msg module
//
void msg_init_env(int pv_argc, char **ppp_argv) {
char la_host[200];
char la_unique[200];
const char *lp_p;
if (gv_ms_pre_inited)
return;
gv_ms_pre_inited = true;
mallopt(M_ARENA_MAX, 1);
// initialize trace subsystem
int lv_msenv = -1;
for (int lv_arg = 0; lv_arg < pv_argc; lv_arg++) {
char *lp_arg = ppp_argv[lv_arg];
if (strcmp(lp_arg, "-msenv") == 0)
lv_msenv = lv_arg + 1;
else if (lv_arg == lv_msenv) {
gp_config_arg_file = new char[strlen(lp_arg) + 1];
strcpy(gp_config_arg_file, lp_arg);
}
}
ms_getenv_bool(gp_ms_env_assert_chk, &gv_ms_assert_chk);
ms_getenv_bool(gp_ms_env_assert_chk_send, &gv_ms_assert_chk_send);
ms_getenv_bool(gp_ms_env_assert_error, &gv_ms_assert_error);
ms_getenv_bool(gp_ms_env_conn_reuse, &gv_ms_conn_reuse);
ms_getenv_int(gp_ms_env_disc_sem, &gv_ms_disc_sem);
ms_getenv_bool(gp_ms_env_disc_sem_rob, &gv_ms_disc_sem_rob);
ms_getenv_bool(gp_ms_env_disc_sem_stats, &gv_ms_disc_sem_stats);
ms_getenv_int(gp_ms_env_conn_idle_timeout, &gv_ms_conn_idle_timeout);
ms_getenv_bool(gp_ms_env_shutdown_fast, &gv_ms_shutdown_fast);
lp_p = ms_getenv_str(gp_ms_env_sq_ic);
if ((lp_p != NULL) &&
((strcmp(lp_p, "IBV") == 0) ||
(strcmp(lp_p, "-IBV") == 0)))
gv_ms_ic_ibv = true;
gv_ms_trans_sock = true;
ms_getenv_bool(gp_ms_env_msg_timestamp, &gv_ms_msg_timestamp);
// process file vars regardless of enable
lp_p = ms_getenv_str(gp_ms_env_trace_file_dir);
if (lp_p != NULL) {
delete [] gp_ms_trace_file_dir;
gp_ms_trace_file_dir = new char[strlen(lp_p) + 1];
strcpy(gp_ms_trace_file_dir, lp_p);
}
ms_getenv_longlong(gp_ms_env_trace_file_maxsize,
&gv_ms_trace_file_maxsize);
ms_getenv_bool(gp_ms_env_trace_file_nolock, &gv_ms_trace_file_nolock);
ms_getenv_int(gp_ms_env_trace_file_unique, &gv_ms_trace_file_unique);
lp_p = ms_getenv_str(gp_ms_env_trace_file);
if (lp_p != NULL) {
delete [] gp_ms_trace_file;
if (gv_ms_trace_file_unique < 0) {
gethostname(la_host, sizeof(la_host));
sprintf(la_unique, "%s.%s.", lp_p, la_host);
lp_p = la_unique;
}
if (gp_ms_trace_file_dir == NULL) {
gp_ms_trace_file = new char[strlen(lp_p) + 1];
strcpy(gp_ms_trace_file, lp_p);
} else {
gp_ms_trace_file =
new char[strlen(gp_ms_trace_file_dir) + strlen(lp_p) + 2];
sprintf(gp_ms_trace_file, "%s/%s", gp_ms_trace_file_dir, lp_p);
}
}
ms_getenv_bool(gp_ms_env_trace_file_delta, &gv_ms_trace_file_delta);
ms_getenv_int(gp_ms_env_trace_file_fb, &gv_ms_trace_file_fb);
if (gv_ms_trace_file_fb > 0)
gv_ms_trace_file_maxsize = 0; // turn off maxsize!
ms_getenv_int(gp_ms_env_trace_file_inmem, &gv_ms_trace_file_inmem);
ms_getenv_bool(gp_ms_env_trace_file_signal, &gv_ms_trace_file_signal);
if (gv_ms_trace_file_signal)
ms_trace_signal_init();
lp_p = ms_getenv_str(gp_ms_env_trace_prefix);
if (lp_p != NULL) {
delete [] gp_ms_trace_prefix;
gp_ms_trace_prefix = new char[strlen(lp_p) + 1];
strcpy(gp_ms_trace_prefix, lp_p);
}
ms_getenv_bool(gp_ms_env_trace_enable, &gv_ms_trace_enable);
if (gv_ms_trace_enable) {
ms_getenv_bool(gp_ms_env_trace, &gv_ms_trace);
ms_getenv_bool(gp_ms_env_trace_abandon, &gv_ms_trace_abandon);
ms_getenv_bool(gp_ms_env_trace_aggr, &gv_ms_trace_aggr);
ms_getenv_bool(gp_ms_env_trace_alloc, &gv_ms_trace_alloc);
ms_buf_trace_change();
ms_getenv_bool(gp_ms_env_trace_data, &gv_ms_trace_data);
ms_getenv_int(gp_ms_env_trace_data_max, &gv_ms_trace_data_max);
ms_getenv_bool(gp_ms_env_trace_detail, &gv_ms_trace_detail);
ms_getenv_bool(gp_ms_env_trace_dialect, &gv_ms_trace_dialect);
ms_getenv_bool(gp_ms_env_trace_environ, &gv_ms_trace_environ);
ms_getenv_bool(gp_ms_env_trace_errors, &gv_ms_trace_errors);
ms_getenv_bool(gp_ms_env_trace_events, &gv_ms_trace_events);
SB_Ms_Tl_Event_Mgr::set_trace_events(gv_ms_trace_events);
ms_getenv_bool(gp_ms_env_trace_evlog, &gv_ms_trace_evlog);
ms_getenv_bool(gp_ms_env_trace_ic, &gv_ms_trace_ic);
ms_getenv_bool(gp_ms_env_trace_locio, &gv_ms_trace_locio);
ms_getenv_bool(gp_ms_env_trace_md, &gv_ms_trace_md);
ms_getenv_bool(gp_ms_env_trace_mon, &gv_ms_trace_mon);
ms_getenv_bool(gp_ms_env_trace_name, &gv_ms_trace_name);
ms_getenv_bool(gp_ms_env_trace_params, &gv_ms_trace_params);
ms_getenv_bool(gp_ms_env_trace_pthread, &gv_sb_trace_pthread);
ms_getenv_bool(gp_ms_env_trace_qalloc, &gv_ms_trace_qalloc);
ms_getenv_bool(gp_ms_env_trace_ref, &gv_ms_trace_ref);
ms_getenv_bool(gp_ms_env_trace_sm, &gv_ms_trace_sm);
ms_getenv_bool(gp_ms_env_trace_sock, &gv_ms_trace_sock);
ms_getenv_bool(gp_ms_env_trace_stats, &gv_ms_trace_stats);
ms_getenv_bool(gp_ms_env_trace_thread, &gv_sb_trace_thread);
ms_getenv_bool(gp_ms_env_trace_timer, &gv_ms_trace_timer);
ms_getenv_bool(gp_ms_env_trace_timermap, &gv_ms_trace_timermap);
ms_getenv_bool(gp_ms_env_trace_trans, &gv_ms_trace_trans);
ms_getenv_bool(gp_ms_env_trace_verbose, &gv_ms_trace_verbose);
ms_getenv_bool(gp_ms_env_trace_wait, &gv_ms_trace_wait);
ms_getenv_int(gp_ms_env_trace_xx, &gv_ms_trace_xx);
if (gv_ms_trace || gv_ms_trace_params)
gv_ms_trace_errors = true;
}
}
void msg_init_env_load() {
char la_exe[PATH_MAX];
bool lv_exe;
// put the variables into env so others can pick them up
// pass1 - setenv for non-exe-props
lv_exe = false;
SB_Smap_Enum lv_enum1(&gv_ms_env);
while (lv_enum1.more()) {
char *lp_key = lv_enum1.next();
const char *lp_value = gv_ms_env.get(lp_key);
setenv(lp_key, lp_value, 1);
}
// pass2 - setenv for exe-props
SB_Smap_Enum lv_enum2(&gv_ms_env);
SB_Props lv_env(true);
while (lv_enum2.more()) {
char *lp_key = lv_enum2.next();
const char *lp_value = gv_ms_env.get(lp_key);
// if key SQ_PROPS_<exe> matches <exe>, load that prop
if (memcmp(lp_key, "SQ_PROPS_", 9) == 0) {
if (!lv_exe) {
lv_exe = true;
SB_util_get_exe(la_exe, sizeof(la_exe), true);
}
char *lp_key_exe = &lp_key[9];
if (strcasecmp(lp_key_exe, la_exe) == 0)
msg_init_env_load_exe(lp_value, &lv_env);
else if (isdigit(la_exe[0]) ||
((la_exe[0] >= 'a') && (la_exe[0] <= 'f'))) {
// check for clearcase view
// filenames look like: 800004064c0e6923tdm_arkcmp
int lv_len = static_cast<int>(strlen(lp_key_exe));
int lv_off = static_cast<int>(strlen(la_exe)) - lv_len;
if (strcasecmp(lp_key_exe, &la_exe[lv_off]) == 0)
msg_init_env_load_exe(lp_value, &lv_env);
}
}
}
// copy exe-props into gv_ms_env/setenv
SB_Smap_Enum lv_enum3(&lv_env);
while (lv_enum3.more()) {
char *lp_key = lv_enum3.next();
const char *lp_value = lv_env.get(lp_key);
gv_ms_env.put(lp_key, lp_value);
setenv(lp_key, lp_value, 1);
}
}
void msg_init_env_load_exe(const char *pp_exe, SB_Props *pp_env) {
SB_Props lv_exe_env(true);
if (!lv_exe_env.load(pp_exe)) {
char *lp_root = getenv(gp_ms_env_sq_root);
if (lp_root != NULL) {
SB_Buf_Lline lv_file;
sprintf(&lv_file, "%s/etc/%s", lp_root, pp_exe);
lv_exe_env.load(&lv_file);
}
}
SB_Smap_Enum lv_enum(&lv_exe_env);
while (lv_enum.more()) {
char *lp_key = lv_enum.next();
const char *lp_value = lv_exe_env.get(lp_key);
pp_env->put(lp_key, lp_value);
}
}
SB_Export void msg_init_trace() {
SB_API_CTR (lv_zctr, MSG_INIT_TRACE);
msg_init_trace_com("msg_init_trace", 0, NULL);
}
void msg_init_trace_com(const char *pp_where, int pv_argc, char **ppp_argv) {
char **lpp_env;
SB_Buf_Lline lv_line;
msg_init_env(pv_argc, ppp_argv);
trace_set_assert_no_trace(gv_ms_assert_error);
if (gv_ms_trace_enable) {
trace_set_delta(gv_ms_trace_file_delta);
if (gv_ms_trace_file_nolock)
trace_set_lock(!gv_ms_trace_file_nolock);
trace_init2(gp_ms_trace_file,
gv_ms_trace_file_unique,
gp_ms_trace_prefix,
false,
gv_ms_trace_file_maxsize);
}
if (gv_ms_trace_file_fb > 0)
trace_set_mem(gv_ms_trace_file_fb);
if (gv_ms_trace_file_inmem > 0)
trace_set_inmem(gv_ms_trace_file_inmem);
// trace start
sprintf(&lv_line, "SEABED module version %s\n",
ms_seabed_vers());
if (gv_ms_trace_enable) {
SB_Buf_Line la_line;
trace_printf("%s\n", libsbms_vers2_str());
trace_where_printf(pp_where, &lv_line);
SB_util_get_cmdline(0,
true, // args
la_line,
sizeof(la_line));
trace_where_printf(pp_where, "cmdline=%s\n", la_line);
}
if (gv_ms_trace_environ) {
lpp_env = environ;
while (*lpp_env != NULL) {
trace_where_printf(pp_where, "env=%s\n", *lpp_env);
lpp_env++;
}
}
}
SB_Export void msg_test_disable_wait(int pv_disable_wait) {
gv_ms_disable_wait = pv_disable_wait;
gv_ms_disable_wait = gv_ms_disable_wait; // touch
}
SB_Export int msg_test_enable_client_only(void) {
int lv_fserr;
if (gv_ms_inited)
lv_fserr = XZFIL_ERR_INVALIDSTATE;
else {
lv_fserr = XZFIL_ERR_OK;
gv_ms_client_only = true;
}
return lv_fserr;
}
SB_Export void msg_test_set_md_count(int pv_count) {
SB_Trans::Msg_Mgr::test_set_md_count(pv_count);
}
//
// Purpose: emulate MSG_ABANDON_
//
SB_Export short BMSG_ABANDON_(int pv_msgid) {
const char *WHERE = "BMSG_ABANDON_";
short lv_fserr;
MS_Md_Type *lp_md;
SB_API_CTR (lv_zctr, BMSG_ABANDON_);
SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MS_MSG_ABANDON, pv_msgid);
lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER msgid=%d\n", pv_msgid);
else if (gv_ms_trace || gv_ms_trace_abandon)
trace_where_printf(WHERE, "msgid=%d\n", pv_msgid);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, NULL); // don't mess up where (ABANDON)
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
if (gv_ms_trace || gv_ms_trace_abandon)
trace_where_printf(WHERE, "msg=%p\n", pfp(lp_md));
//
// Mark abandon.
// If it's already in completion-queue, simply remove it from queue;
// otherwise, send abandon to remote
//
lp_md->iv_abandoned = true;
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
if ((lp_stream != NULL) && lp_stream->remove_comp_q(lp_md)) {
// found on queue, simply remove it
if (gv_ms_trace || gv_ms_trace_abandon)
trace_where_printf(WHERE, "msgid=%d found on completion queue and removed\n",
pv_msgid);
lp_md->ip_mgr->change_replies_done(-1, LDONE);
SB_Trans::Msg_Mgr::put_md_link(lp_md, "abandon comp-q");
} else if (lp_md->iv_reply_done) {
if (gv_ms_trace || gv_ms_trace_abandon)
trace_where_printf(WHERE, "msgid=%d reply already done\n", pv_msgid);
lp_md->ip_mgr->change_replies_done(-1, LDONE);
if (lp_md->out.iv_opts & (SB_Trans::MS_OPTS_LDONE | SB_Trans::MS_OPTS_FSDONE))
SB_Trans::Trans_Stream::remove_comp_q_static(lp_md);
SB_Trans::Msg_Mgr::put_md_link(lp_md, "abandon no-q");
} else if (lp_stream != NULL) {
// send abandon to remote
MS_Md_Type *lp_can_md;
SB_Trans::Msg_Mgr::get_md(&lp_can_md, // BMSG_ABANDON_
lp_stream,
gv_ms_event_mgr.get_mgr(NULL),
true, // send
NULL, // fserr
"abandon (BMSG_ABANDON_)",
MD_STATE_MSG_LOW_ABANDON);
SB_util_assert_pne(lp_can_md, NULL); // TODO: can't get md
lv_fserr = lp_stream->exec_abandon(lp_can_md,
lp_can_md->iv_link.iv_id.i, // reqid
lp_md->iv_link.iv_id.i); // can_reqid
if (lv_fserr == XZFIL_ERR_OK)
lp_stream->wait_rep_done(lp_can_md);
else
lp_stream->error_sync();
SB_Trans::Msg_Mgr::put_md_link(lp_can_md, "abandon md");
// it is possible that we missed the check above
if (lp_stream->remove_comp_q(lp_md)) {
// found on queue, simply remove it
if (gv_ms_trace || gv_ms_trace_abandon)
trace_where_printf(WHERE, "msgid=%d found on completion queue after abandon and removed\n",
pv_msgid);
lp_md->ip_mgr->change_replies_done(-1, LDONE);
SB_Trans::Msg_Mgr::put_md_link(lp_md, "abandon comp-q");
}
} else {
if (gv_ms_trace || gv_ms_trace_abandon)
trace_where_printf(WHERE, "msgid=%d stream is NULL\n", pv_msgid);
lp_md->ip_mgr->change_replies_done(-1, LDONE);
SB_Trans::Msg_Mgr::put_md_link(lp_md, "abandon no-stream");
}
if (gv_ms_trace_params || gv_ms_trace_abandon)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: emulate MSG_AWAIT_
//
SB_Export short BMSG_AWAIT_(int pv_msgid, int pv_tov) {
SB_API_CTR (lv_zctr, BMSG_AWAIT_);
while (!BMSG_ISDONE_(pv_msgid)) {
if (XWAIT(LDONE, pv_tov) == 0)
return 1;
}
return 0;
}
//
// Purpose: emulate MSG_BREAK_
//
// do receive (if not already done)
// get results
//
SB_Export short BMSG_BREAK_(int pv_msgid,
short *pp_results,
SB_Phandle_Type *pp_phandle) {
SB_API_CTR (lv_zctr, BMSG_BREAK_);
return xmsg_break_com(pv_msgid, pp_results, pp_phandle, NULL, false);
}
//
// Purpose: emulate MSG_BREAK_
//
// do receive (if not already done)
// get results
//
SB_Export void BMSG_BREAK2_(int pv_msgid,
short *pp_results,
SB_Phandle_Type *pp_phandle) {
SB_API_CTR (lv_zctr, BMSG_BREAK_);
xmsg_break_com(pv_msgid, pp_results, pp_phandle, NULL, true);
}
//
// Purpose: common MSG_BREAK_
//
// if ppp_md is NOT NULL, then md is returned (not put)
//
short xmsg_break_com(int pv_msgid,
short *pp_results,
SB_Phandle_Type *pp_phandle,
MS_Md_Type **ppp_md,
bool pv_reply_ctrl) {
const char *WHERE = "BMSG_BREAK_";
MS_Md_Type *lp_md;
MS_Result_Type *lp_results;
MS_Result_Raw_Type *lp_results_raw;
long long lv_delta;
short lv_fserr;
bool lv_trace_delta;
SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MS_MSG_BREAK, pv_msgid);
if (gv_ms_trace_params) {
char la_phandle[MSG_UTIL_PHANDLE_LEN];
msg_util_format_phandle(la_phandle, pp_phandle);
trace_where_printf(WHERE,
"ENTER from=%s, msgid=%d, results=%p, phandle=%s\n",
ms_od_map_phandle_to_name(pp_phandle), pv_msgid,
pfp(pp_results), la_phandle);
}
if (ppp_md != NULL)
*ppp_md = NULL;
// don't mess up where (yet) (BREAK)
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, NULL);
if (lp_md == NULL) {
if (pv_reply_ctrl)
ms_err_break_err(WHERE, XZFIL_ERR_NOTFOUND, lp_md, pp_results);
return ms_err_rtn_msg(WHERE, " EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
}
if (lp_md->iv_break_done) {
if (pv_reply_ctrl)
ms_err_break_err(WHERE, XZFIL_ERR_TOOMANY, lp_md, pp_results);
return ms_err_rtn_msg(WHERE, " EXIT [break already done]", XZFIL_ERR_TOOMANY);
}
lp_md->iv_break_done = true;
lp_results = reinterpret_cast<MS_Result_Type *>(pp_results);
lp_results_raw = reinterpret_cast<MS_Result_Raw_Type *>(pp_results);
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
lv_trace_delta = false;
if (lp_stream == NULL) {
SB_Trans::Trans_Stream::wait_req_done_static(lp_md);
if (lp_md->out.iv_opts & (SB_Trans::MS_OPTS_LDONE | SB_Trans::MS_OPTS_FSDONE))
SB_Trans::Trans_Stream::remove_comp_q_static(lp_md);
else if (gv_ms_trace_params)
lv_trace_delta = true;
} else {
lp_stream->wait_req_done(lp_md);
if (lp_md->out.iv_opts & (SB_Trans::MS_OPTS_LDONE | SB_Trans::MS_OPTS_FSDONE))
lp_stream->remove_comp_q(lp_md);
else if (gv_ms_trace_params)
lv_trace_delta = true;
}
if (gv_ms_msg_timestamp)
gettimeofday(&lp_md->iv_ts_msg_cli_break, NULL);
if (lv_trace_delta) {
gettimeofday(&lp_md->out.iv_comp_q_off_tod, NULL);
lv_delta = (lp_md->out.iv_comp_q_off_tod.tv_sec * SB_US_PER_SEC +
lp_md->out.iv_comp_q_off_tod.tv_usec) -
(lp_md->out.iv_comp_q_on_tod.tv_sec * SB_US_PER_SEC +
lp_md->out.iv_comp_q_on_tod.tv_usec);
trace_where_printf(WHERE,
"done-to-break, (msgid=%d, md=%p) time=%lld us\n",
lp_md->iv_link.iv_id.i, pfp(lp_md),
lv_delta);
}
lp_md->ip_mgr->change_replies_done(-1, LDONE);
lv_fserr = lp_md->out.iv_fserr;
lp_results->rr_ctrlsize = lp_md->out.iv_reply_ctrl_count;
lp_results->rr_datasize = lp_md->out.iv_reply_data_count;
lp_results_raw->rrerr = 0;
if (lv_fserr != XZFIL_ERR_OK)
ms_fserr_to_results(lv_fserr, lp_results);
if (lp_md->out.iv_reply_data_count > 0)
lp_results->rrerr_datareceivedb = 1;
else
lp_results->rrerr_datareceivedb = 0;
if ((lv_fserr != XZFIL_ERR_OK) && pv_reply_ctrl)
ms_err_break_err(WHERE, lv_fserr, lp_md, pp_results);
if (lv_fserr == XZFIL_ERR_OK) {
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"repC=%p, repCcount=%d\n",
pfp(lp_md->out.ip_reply_ctrl),
lp_md->out.iv_reply_ctrl_count);
trace_print_data(lp_md->out.ip_reply_ctrl,
lp_md->out.iv_reply_ctrl_count,
gv_ms_trace_data_max);
trace_where_printf(WHERE,
"repD=%p, repDcount=%d\n",
lp_md->out.ip_reply_data,
lp_md->out.iv_reply_data_count);
trace_print_data(lp_md->out.ip_reply_data,
lp_md->out.iv_reply_data_count,
gv_ms_trace_data_max);
}
}
// TODO remove next two lines
if (!gv_ms_recv_q.remove_list(&lp_md->iv_link))
lp_md->ip_fs_comp_q->remove_list(&lp_md->iv_link);
if ((lv_fserr != XZFIL_ERR_OK) &&
(lp_md->out.iv_fserr_hard) &&
(lp_stream != NULL)) {
if (lp_stream->error_of_generation(lp_md->out.iv_fserr_generation)) {
if (gv_ms_trace)
trace_where_printf(WHERE, "fserr=%d in md, msgid=%d, gen=%d\n",
lv_fserr, pv_msgid,
lp_md->out.iv_fserr_generation);
// close stream
msg_mon_close_process_com(pp_phandle, false); // don't free oid
}
}
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR_C2S)
if (!(lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR_S2C))
lp_md->iv_send_done = true; // need for md to free
if (ppp_md == NULL)
SB_Trans::Msg_Mgr::put_md_link(lp_md, "msg-break");
else
*ppp_md = lp_md;
if (gv_ms_trace_params) {
if (gv_ms_msg_timestamp) {
// 123456789012345
// HH:MM:SS.UUUUUU
char la_c_link[20];
char la_s_rcvd[20];
char la_s_list[20];
char la_s_reply[20];
char la_c_rcvd[20];
char la_c_break[20];
ms_trace_msg_ts(la_c_link, &lp_md->iv_ts_msg_cli_link);
ms_trace_msg_ts(la_s_rcvd, &lp_md->iv_ts_msg_srv_rcvd);
ms_trace_msg_ts(la_s_list, &lp_md->iv_ts_msg_srv_listen);
ms_trace_msg_ts(la_s_reply, &lp_md->iv_ts_msg_srv_reply);
ms_trace_msg_ts(la_c_rcvd, &lp_md->iv_ts_msg_cli_rcvd);
ms_trace_msg_ts(la_c_break, &lp_md->iv_ts_msg_cli_break);
trace_where_printf(WHERE,
"c-link=%s, s-rcvd=%s, s-list=%s, s-reply=%s, c-rcvd=%s, c-break=%s\n",
la_c_link,
la_s_rcvd,
la_s_list,
la_s_reply,
la_c_rcvd,
la_c_break);
}
trace_where_printf(WHERE,
"EXIT ret=%d, msgid=%d, results.ctrl=%u, results.data=%u\n",
lv_fserr,
pv_msgid,
lp_results->rr_ctrlsize,
lp_results->rr_datasize);
} else if (gv_ms_trace && (lv_fserr != XZFIL_ERR_OK))
trace_where_printf(WHERE, "EXIT ret=%d, msgid=%d\n",
lv_fserr, pv_msgid);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: emulate MSG_GETREQINFO_
//
SB_Export short BMSG_GETREQINFO_(int pv_item_code,
int pv_msgid,
int *pp_item) {
const char *WHERE = "BMSG_GETREQINFO_";
MS_Md_Type *lp_md;
int lv_nid;
int lv_pid;
int lv_ptype;
SB_API_CTR (lv_zctr, BMSG_GETREQINFO_);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER item-code=%d, msgid=%d, item=%p\n",
pv_item_code, pv_msgid, pfp(pp_item));
if (!gv_ms_calls_ok)
return ms_err_rtn_msg(WHERE, "msg_init() not called or shutdown",
XZFIL_ERR_INVALIDSTATE);
if (pp_item == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [item == NULL]",
XZFIL_ERR_BOUNDSERR);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, NULL); // don't mess up where
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
switch (pv_item_code) {
case MSGINFO_NID:
lv_nid = lp_md->out.iv_nid;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "item=%d (nid)\n", lv_nid);
*pp_item = lv_nid;
break;
case MSGINFO_PID:
lv_pid = lp_md->out.iv_pid;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "item=%d (pid)\n", lv_pid);
*pp_item = lv_pid;
break;
case MSGINFO_PTYPE:
lv_ptype = lp_md->out.iv_ptype;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "item=%d (ptype)\n", lv_ptype);
*pp_item = lv_ptype;
break;
default:
return ms_err_rtn_msg(WHERE, " EXIT [invalid item-code]",
XZFIL_ERR_BOUNDSERR);
}
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=0\n");
return ms_err_rtn(XZFIL_ERR_OK);
}
//
// Purpose: emulate MSG_HOLD_
//
SB_Export void BMSG_HOLD_(int pv_msgid) {
const char *WHERE = "BMSG_HOLD_";
MS_Md_Type *lp_md;
SB_API_CTR (lv_zctr, BMSG_HOLD_);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER msgid=%d\n", pv_msgid);
// NSK would do a halt
SB_util_assert_it(gv_ms_calls_ok); // sw fault
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, NULL); // don't mess up where
if (lp_md == NULL) {
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT unknown msgid=%d\n", pv_msgid);
// NSK does a halt
SB_util_assert_pne(lp_md, NULL); // sw fault
}
gv_ms_hold_q.add(&lp_md->iv_link);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT\n");
}
//
// Purpose: emulate MSG_ISCANCELED_
//
SB_Export short BMSG_ISCANCELED_(int pv_msgid) {
const char *WHERE = "BMSG_ISCANCELED_";
short lv_abandoned;
MS_Md_Type *lp_md;
SB_API_CTR (lv_zctr, BMSG_ISCANCELED_);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER msgid=%d\n", pv_msgid);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, NULL); // don't mess up where (ISCANCELED)
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
lv_abandoned = lp_md->iv_abandoned;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_abandoned);
return lv_abandoned;
}
//
// Purpose: emulate MSG_ISDONE_
//
// do receive (if not already done)
//
SB_Export short BMSG_ISDONE_(int pv_msgid) {
const char *WHERE = "BMSG_ISDONE_";
short lv_done;
MS_Md_Type *lp_md;
SB_API_CTR (lv_zctr, BMSG_ISDONE_);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER msgid=%d\n", pv_msgid);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, NULL); // don't mess up where (ISDONE)
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
lv_done = lp_md->iv_reply_done;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_done);
return lv_done;
}
//
// Purpose: emulate MSG_LINK_
//
short BMSG_LINK_common(SB_Phandle_Type *pp_phandle,
int *pp_msgid,
short *pp_reqctrl,
int pv_reqctrlsize,
short *pp_replyctrl,
int pv_replyctrlmax,
char *pp_reqdata,
int pv_reqdatasize,
char *pp_replydata,
int pv_replydatamax,
long pv_linkertag,
short pv_pri,
short pv_xmitclass,
short pv_linkopts,
bool pv_nskcheck) {
const char *WHERE = "BMSG_LINK_";
SB_Buf_Line la_log_buf;
MS_Md_Type *lp_md;
void *lp_od;
short lv_fserr;
short lv_lfserr;
int lv_msgid;
int lv_opts;
bool lv_ts;
SB_API_CTR (lv_zctr, BMSG_LINK_);
if (gv_ms_trace_params) {
trace_where_printf(WHERE, "ENTER to=%s, msgid=%p, reqC=%p, size=%d, repC=%p, max=%d\n",
ms_od_map_phandle_to_name(pp_phandle),
pfp(pp_msgid),
pfp(pp_reqctrl), pv_reqctrlsize,
pfp(pp_replyctrl), pv_replyctrlmax);
trace_where_printf(WHERE,
"reqD=%p, size=%d, repD=%p, max=%d, ltag=0x%lx, pri=%d, xcls=%d, lopts=0x%x\n",
pp_reqdata, pv_reqdatasize,
pp_replydata, pv_replydatamax,
pv_linkertag, pv_pri, pv_xmitclass, pv_linkopts);
}
if (pp_msgid != NULL)
*pp_msgid = 0; // mark no need for break
if (!gv_ms_calls_ok)
return ms_err_rtn_msg(WHERE, "msg_init() not called or shutdown",
XZFIL_ERR_INVALIDSTATE);
if (pp_phandle == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [phandle == NULL]",
XZFIL_ERR_BOUNDSERR);
if (pp_msgid == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msgid == NULL]",
XZFIL_ERR_BOUNDSERR);
SB_util_assert_ige(pv_reqctrlsize, 0); // insist ctrl is non-negative
SB_util_assert_ige(pv_reqdatasize, 0); // insist data is non-negative
if (pv_nskcheck) {
if (pp_reqctrl == NULL) {
sprintf(la_log_buf, "%s: reqC is NULL", WHERE);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
if (pv_reqctrlsize & 1) {
sprintf(la_log_buf, "%s: reqCsize(%d) must be even\n",
WHERE, pv_reqctrlsize);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
if (pv_reqctrlsize < MSG_MINREQCTRLSIZE) {
sprintf(la_log_buf, "%s: reqCsize(%d) is too small, needs to be at least %d\n",
WHERE, pv_reqctrlsize, MSG_MINREQCTRLSIZE);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
if (pv_reqctrlsize > MSG_MAXREQCTRLSIZE) {
sprintf(la_log_buf, "%s: reqCsize(%d) is too big, must not be bigger than %d\n",
WHERE, pv_reqctrlsize, MSG_MAXREQCTRLSIZE);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
if (pp_replyctrl == NULL) {
sprintf(la_log_buf, "%s: repC is NULL\n", WHERE);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
if (pv_replyctrlmax & 1) {
sprintf(la_log_buf, "%s: repCmax(%d) must be even\n",
WHERE, pv_replyctrlmax);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
if (pv_replyctrlmax < MSG_MINREPLYCTRLSIZE) {
sprintf(la_log_buf, "%s: repCmax(%d) is too small, needs to be at least %d\n",
WHERE, pv_reqctrlsize, MSG_MINREPLYCTRLSIZE);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
if (pv_replyctrlmax > MSG_MAXREPLYCTRLSIZE) {
sprintf(la_log_buf, "%s: repCmax(%d) is too big, must not be bigger than %d\n",
WHERE, pv_reqctrlsize, MSG_MAXREPLYCTRLSIZE);
if (gv_ms_trace_errors)
trace_printf("%s\n", la_log_buf);
SB_util_fatal(la_log_buf, true);
}
}
int lv_oid = ms_od_map_phandle_to_oid(pp_phandle);
if (!ms_od_valid_oid(lv_oid))
return ms_err_rtn_msg(WHERE, "EXIT [bad oid in phandle]",
XZFIL_ERR_NOTOPEN);
lp_od = ms_od_lock(lv_oid);
SB_Trans::Stream_Base *lp_stream = ms_od_map_phandle_to_stream(pp_phandle);
if ((lv_oid > 0) && (lp_stream == NULL)) {
// there's an open, but no stream
lv_fserr = static_cast<short>(msg_mon_reopen_process(pp_phandle));
if (lv_fserr != XZFIL_ERR_OK) {
ms_od_unlock(lp_od);
lv_msgid = SB_Trans::Msg_Mgr::get_md(&lp_md, // BMSG_LINK_
NULL,
gv_ms_event_mgr.get_mgr(NULL),
true, // send
&lv_lfserr, // fserr
WHERE,
MD_STATE_MSG_REOPEN_FAIL);
if (lv_msgid < 0)
return ms_err_rtn_msg(WHERE, "EXIT [msgid < 0]",
lv_lfserr);
// fill out md enough to complete
lv_opts = 0;
lv_ts = (pv_linkopts & XMSG_LINK_FSDONETSQ);
if (lv_ts)
lv_opts |= SB_Trans::MS_OPTS_FSDONETS;
if (pv_linkopts & XMSG_LINK_FSDONEQ)
lv_opts |= SB_Trans::MS_OPTS_FSDONE;
else if (pv_linkopts & XMSG_LINK_LDONEQ)
lv_opts |= SB_Trans::MS_OPTS_LDONE;
lp_md->out.iv_opts = lv_opts;
lp_md->iv_tag = pv_linkertag;
lp_md->ip_comp_q = ms_ldone_get_comp_q();
lp_md->ip_fs_comp_q = ms_fsdone_get_comp_q(lv_ts);
lp_md->iv_ss.ip_req_ctrl = pp_reqctrl;
lp_md->iv_ss.iv_req_ctrl_size = pv_reqctrlsize;
lp_md->iv_ss.ip_req_data = pp_reqdata;
lp_md->iv_ss.iv_req_data_size = pv_reqdatasize;
lp_md->out.ip_reply_ctrl = pp_replyctrl,
lp_md->out.iv_reply_ctrl_max = pv_replyctrlmax,
lp_md->out.ip_reply_data = pp_replydata;
lp_md->out.iv_reply_data_max = pv_replydatamax,
lp_md->iv_send_done = true;
SB_Trans::Trans_Stream::finish_reply_static(lp_md,
lv_fserr,
true,
-1, // generation
NULL, // req_map
true,
msg_mon_is_self(pp_phandle), // self
&ms_ldone_cbt); // ms_comp_callback
lv_fserr = XZFIL_ERR_OK; // even if there's an error, clear it
*pp_msgid = lv_msgid;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d, msgid=%d\n",
lv_fserr, lv_msgid);
return ms_err_rtn(lv_fserr);
}
// reacquire stream
lp_stream = ms_od_map_phandle_to_stream(pp_phandle);
}
lv_msgid = SB_Trans::Msg_Mgr::get_md(&lp_md, // BMSG_LINK_
lp_stream,
gv_ms_event_mgr.get_mgr(NULL),
true, // send
&lv_fserr, // fserr
WHERE,
MD_STATE_MSG_LINK);
ms_od_unlock(lp_od); // after get_md - ref added
if (lv_msgid < 0)
return ms_err_rtn_msg(WHERE, "EXIT [msgid < 0]", lv_fserr);
lp_md->ip_comp_q = ms_ldone_get_comp_q();
lv_ts = (pv_linkopts & XMSG_LINK_FSDONETSQ);
lp_md->ip_fs_comp_q = ms_fsdone_get_comp_q(lv_ts);
if (gv_ms_trace)
trace_where_printf(WHERE, "to=%s, msgid=%d, reqC=%d, reqD=%d\n",
ms_od_map_phandle_to_name(pp_phandle),
lv_msgid, pv_reqctrlsize, pv_reqdatasize);
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"reqC=%p, reqCsize=%d\n",
pfp(pp_reqctrl), pv_reqctrlsize);
trace_print_data(pp_reqctrl, pv_reqctrlsize, gv_ms_trace_data_max);
trace_where_printf(WHERE,
"reqD=%p, reqDsize=%d\n",
pp_reqdata, pv_reqdatasize);
trace_print_data(pp_reqdata, pv_reqdatasize, gv_ms_trace_data_max);
}
lv_opts = 0;
if (pv_linkopts) {
if (lv_ts)
lv_opts |= SB_Trans::MS_OPTS_FSDONETS;
if (pv_linkopts & BMSG_LINK_FSDONEQ)
lv_opts |= SB_Trans::MS_OPTS_FSDONE;
else if (pv_linkopts & BMSG_LINK_LDONEQ)
lv_opts |= SB_Trans::MS_OPTS_LDONE;
if (pv_linkopts & BMSG_LINK_AGGR)
lv_opts |= SB_Trans::MS_OPTS_AGGR;
if (pv_linkopts & XMSG_LINK_FSREQ)
lv_opts |= SB_Trans::MS_OPTS_FSREQ;
if (pv_linkopts & BMSG_LINK_MSINTERCEPTOR)
lv_opts |= SB_Trans::MS_OPTS_MSIC;
}
lp_md->out.iv_opts = lv_opts;
lp_md->iv_tag = pv_linkertag;
lv_fserr = lp_stream->exec_wr(lp_md,
0, // src
0, // dest
lp_md->iv_link.iv_id.i, // reqid
pv_pri,
pp_reqctrl,
pv_reqctrlsize,
pp_reqdata,
pv_reqdatasize,
pp_replyctrl,
pv_replyctrlmax,
pp_replydata,
pv_replydatamax,
lv_opts); // opts
lv_fserr = XZFIL_ERR_OK; // even if there's an error, clear it
*pp_msgid = lv_msgid;
SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MS_MSG_LINK, lv_msgid);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d, msgid=%d\n",
lv_fserr, lv_msgid);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: emulate MSG_LINK_
//
SB_Export short BMSG_LINK_(SB_Phandle_Type *pp_phandle,
int *pp_msgid,
short *pp_reqctrl,
int pv_reqctrlsize,
short *pp_replyctrl,
int pv_replyctrlmax,
char *pp_reqdata,
int pv_reqdatasize,
char *pp_replydata,
int pv_replydatamax,
long pv_linkertag,
short pv_pri,
short pv_xmitclass,
short pv_linkopts) {
return BMSG_LINK_common(pp_phandle,
pp_msgid,
pp_reqctrl,
pv_reqctrlsize,
pp_replyctrl,
pv_replyctrlmax,
pp_reqdata,
pv_reqdatasize,
pp_replydata,
pv_replydatamax,
pv_linkertag,
pv_pri,
pv_xmitclass,
pv_linkopts,
false);
}
//
// Purpose: emulate MSG_LINK_
//
SB_Export short BMSG_LINK2_(SB_Phandle_Type *pp_phandle,
int *pp_msgid,
short *pp_reqctrl,
int pv_reqctrlsize,
short *pp_replyctrl,
int pv_replyctrlmax,
char *pp_reqdata,
int pv_reqdatasize,
char *pp_replydata,
int pv_replydatamax,
long pv_linkertag,
short pv_pri,
short pv_xmitclass,
short pv_linkopts) {
return BMSG_LINK_common(pp_phandle,
pp_msgid,
pp_reqctrl,
pv_reqctrlsize,
pp_replyctrl,
pv_replyctrlmax,
pp_reqdata,
pv_reqdatasize,
pp_replydata,
pv_replydatamax,
pv_linkertag,
pv_pri,
pv_xmitclass,
pv_linkopts,
true); // nsk check
}
//
// Purpose: emulate MSG_LISTEN_
//
static short BMSG_LISTEN_common(short *pp_sre,
short pv_listenopts,
long pv_listenertag,
bool pv_big) {
const char *WHERE = "BMSG_LISTEN_";
bool lv_abandoned = false;
short lv_fserr;
bool lv_repeat;
bool lv_traced = false;
MS_Md_Type *lp_md = NULL;
void *lp_tle = NULL;
SB_API_CTR (lv_zctr, BMSG_LISTEN_);
if (gv_ms_trace_params && gv_ms_trace_verbose)
trace_where_printf(WHERE,
"ENTER sre=%p, listenopts=0x%x, listenertag=%ld\n",
pfp(pp_sre), pv_listenopts, pv_listenertag);
if (!gv_ms_calls_ok)
return ms_err_rtn_msg(WHERE, "msg_init() not called or shutdown",
XSRETYPE_NOWORK);
if (pv_listenopts == 0)
pv_listenopts = BLISTEN_DEFAULTM;
else if (pv_listenopts == BLISTEN_TEST_ILIMREQM) {
if (gv_ms_trace_params && gv_ms_trace_verbose)
trace_where_printf(WHERE,
"ENTER sre=%p, listenopts=0x%x, listenertag=%ld\n",
pfp(pp_sre), pv_listenopts, pv_listenertag);
gv_ms_lim_q.lock();
lp_md = reinterpret_cast<MS_Md_Type *>(gv_ms_lim_q.head());
if (lp_md == NULL) {
lv_fserr = XSRETYPE_NOWORK;
if (gv_ms_trace_params && gv_ms_trace_verbose)
trace_where_printf(WHERE,
"EXIT No Work, ret=NOWORK\n");
} else {
if (gv_ms_msg_timestamp)
gettimeofday(&lp_md->iv_ts_msg_srv_listen, NULL);
lv_fserr = XSRETYPE_IREQ;
if (pv_big) {
BMS_SRE *lp_sre = reinterpret_cast<BMS_SRE *>(pp_sre);
lp_sre->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre->sre_flags = BSRE_REMM;
if (lp_md->out.iv_mon_msg)
lp_sre->sre_flags |= BSRE_MON;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR)
lp_sre->sre_flags |= BSRE_AGGR;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_PROCDEAD)
lp_sre->sre_flags |= BSRE_PROCDEAD;
lp_sre->sre_pri = lp_md->out.iv_pri;
lp_sre->sre_reqCtrlSize = lp_md->out.iv_recv_ctrl_size;
lp_sre->sre_reqDataSize = lp_md->out.iv_recv_data_size;
lp_sre->sre_replyCtrlMax = lp_md->out.iv_recv_ctrl_max;
lp_sre->sre_replyDataMax = lp_md->out.iv_recv_data_max;
if (gv_ms_trace_params && gv_ms_trace_verbose) {
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
char *lp_from;
if (lp_stream == NULL)
lp_from = NULL;
else
lp_from = lp_stream->get_name();
trace_where_printf(WHERE,
"EXIT from=%s, reqid=%d, ret=%d, sre.msgid=%d, .flags=0x%x, .pri=%d, .ctrl=%d, .data=%d\n",
lp_from,
lp_md->out.iv_recv_req_id,
lv_fserr,
lp_sre->sre_msgId,
lp_sre->sre_flags,
lp_sre->sre_pri,
lp_sre->sre_reqCtrlSize,
lp_sre->sre_reqDataSize);
}
} else {
MS_SRE *lp_sre = reinterpret_cast<MS_SRE *>(pp_sre);
lp_sre->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre->sre_flags = XSRE_REMM;
if (lp_md->out.iv_mon_msg)
lp_sre->sre_flags |= XSRE_MON;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR)
lp_sre->sre_flags |= XSRE_AGGR;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_PROCDEAD)
lp_sre->sre_flags |= XSRE_PROCDEAD;
lp_sre->sre_pri = static_cast<short>(lp_md->out.iv_pri);
lp_sre->sre_reqCtrlSize =
static_cast<ushort>(lp_md->out.iv_recv_ctrl_size);
lp_sre->sre_reqDataSize =
static_cast<ushort>(lp_md->out.iv_recv_data_size);
lp_sre->sre_replyCtrlMax =
static_cast<ushort>(lp_md->out.iv_recv_ctrl_max);
lp_sre->sre_replyDataMax =
static_cast<ushort>(lp_md->out.iv_recv_data_max);
if (gv_ms_trace_params && gv_ms_trace_verbose) {
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
char *lp_from;
if (lp_stream == NULL)
lp_from = NULL;
else
lp_from = lp_stream->get_name();
trace_where_printf(WHERE,
"EXIT from=%s, reqid=%d, ret=%d, sre.msgid=%d, .flags=0x%x, .pri=%d, .ctrl=%d, .data=%d\n",
lp_from,
lp_md->out.iv_recv_req_id,
lv_fserr,
lp_sre->sre_msgId,
lp_sre->sre_flags,
lp_sre->sre_pri,
lp_sre->sre_reqCtrlSize,
lp_sre->sre_reqDataSize);
}
}
}
gv_ms_lim_q.unlock();
return lv_fserr;
} else if (pv_listenopts == BLISTEN_TEST_IREQM) {
if (gv_ms_trace_params && gv_ms_trace_verbose)
trace_where_printf(WHERE,
"ENTER sre=%p, listenopts=0x%x, listenertag=%ld\n",
pfp(pp_sre), pv_listenopts, pv_listenertag);
gv_ms_recv_q.lock();
lp_md = reinterpret_cast<MS_Md_Type *>(gv_ms_recv_q.head());
if (lp_md == NULL) {
lv_fserr = XSRETYPE_NOWORK;
if (gv_ms_trace_params && gv_ms_trace_verbose)
trace_where_printf(WHERE,
"EXIT No Work, ret=NOWORK\n");
} else {
if (gv_ms_msg_timestamp)
gettimeofday(&lp_md->iv_ts_msg_srv_listen, NULL);
lv_fserr = XSRETYPE_IREQ;
if (pv_big) {
BMS_SRE *lp_sre = reinterpret_cast<BMS_SRE *>(pp_sre);
lp_sre->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre->sre_flags = BSRE_REMM;
if (lp_md->out.iv_mon_msg)
lp_sre->sre_flags |= BSRE_MON;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR)
lp_sre->sre_flags |= BSRE_AGGR;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_PROCDEAD)
lp_sre->sre_flags |= BSRE_PROCDEAD;
lp_sre->sre_pri = lp_md->out.iv_pri;
lp_sre->sre_reqCtrlSize = lp_md->out.iv_recv_ctrl_size;
lp_sre->sre_reqDataSize = lp_md->out.iv_recv_data_size;
lp_sre->sre_replyCtrlMax = lp_md->out.iv_recv_ctrl_max;
lp_sre->sre_replyDataMax = lp_md->out.iv_recv_data_max;
if (gv_ms_trace_params && gv_ms_trace_verbose) {
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
char *lp_from;
if (lp_stream == NULL)
lp_from = NULL;
else
lp_from = lp_stream->get_name();
trace_where_printf(WHERE,
"EXIT from=%s, reqid=%d, ret=%d, sre.msgid=%d, .flags=0x%x, .pri=%d, .ctrl=%d, .data=%d\n",
lp_from,
lp_md->out.iv_recv_req_id,
lv_fserr,
lp_sre->sre_msgId,
lp_sre->sre_flags,
lp_sre->sre_pri,
lp_sre->sre_reqCtrlSize,
lp_sre->sre_reqDataSize);
}
} else {
MS_SRE *lp_sre = reinterpret_cast<MS_SRE *>(pp_sre);
lp_sre->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre->sre_flags = XSRE_REMM;
if (lp_md->out.iv_mon_msg)
lp_sre->sre_flags |= XSRE_MON;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR)
lp_sre->sre_flags |= XSRE_AGGR;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_PROCDEAD)
lp_sre->sre_flags |= XSRE_PROCDEAD;
lp_sre->sre_pri = static_cast<short>(lp_md->out.iv_pri);
lp_sre->sre_reqCtrlSize =
static_cast<ushort>(lp_md->out.iv_recv_ctrl_size);
lp_sre->sre_reqDataSize =
static_cast<ushort>(lp_md->out.iv_recv_data_size);
lp_sre->sre_replyCtrlMax =
static_cast<ushort>(lp_md->out.iv_recv_ctrl_max);
lp_sre->sre_replyDataMax =
static_cast<ushort>(lp_md->out.iv_recv_data_max);
if (gv_ms_trace_params && gv_ms_trace_verbose) {
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
char *lp_from;
if (lp_stream == NULL)
lp_from = NULL;
else
lp_from = lp_stream->get_name();
trace_where_printf(WHERE,
"EXIT from=%s, reqid=%d, ret=%d, sre.msgid=%d, .flags=0x%x, .pri=%d, .ctrl=%d, .data=%d\n",
lp_from,
lp_md->out.iv_recv_req_id,
lv_fserr,
lp_sre->sre_msgId,
lp_sre->sre_flags,
lp_sre->sre_pri,
lp_sre->sre_reqCtrlSize,
lp_sre->sre_reqDataSize);
}
}
}
gv_ms_recv_q.unlock();
return lv_fserr;
}
do {
lv_fserr = -1;
lv_repeat = false;
if (pv_listenopts & BLISTEN_ALLOW_ABANDONM) {
// abandon check requested, check abandon
lp_md = static_cast<MS_Md_Type *>(gv_ms_abandon_comp_q.remove());
if (lp_md != NULL) {
lv_abandoned = true;
break; // finish abandon
}
}
if (pv_listenopts & BLISTEN_ALLOW_LDONEM) {
// ldone check requested, check ldone
lp_md = static_cast<MS_Md_Type *>(ms_ldone_get_comp_q()->remove());
if (lp_md != NULL)
break; // finish ldone
}
if (pv_listenopts & BLISTEN_ALLOW_TPOPM) {
// tpop check requested, check tpop
lp_tle = sb_timer_comp_q_remove();
if (lp_tle != NULL)
break; // finish tpop
}
if (!(pv_listenopts & (BLISTEN_ALLOW_ILIMREQM | BLISTEN_ALLOW_IREQM))) {
// NO ireq check requested, so we're done
lv_fserr = XSRETYPE_NOWORK;
break;
}
if (pv_listenopts & BLISTEN_ALLOW_ILIMREQM) {
// check ilimreqs
lp_md = static_cast<MS_Md_Type *>(gv_ms_lim_q.remove());
}
if ((lp_md == NULL) && (pv_listenopts & BLISTEN_ALLOW_IREQM)) {
// check ireqs
lp_md = static_cast<MS_Md_Type *>(gv_ms_recv_q.remove());
}
if (lp_md == NULL) {
lv_fserr = XSRETYPE_NOWORK;
break;
}
if (gv_ms_msg_timestamp)
gettimeofday(&lp_md->iv_ts_msg_srv_listen, NULL);
if (lp_md->out.iv_mon_msg) {
if (!lv_traced && gv_ms_trace_params && !gv_ms_trace_verbose) {
lv_traced = true;
trace_where_printf(WHERE,
"ENTER sre=%p, listenopts=0x%x, listenertag=%ld\n",
pfp(pp_sre), pv_listenopts, pv_listenertag);
}
msg_mon_recv_msg(lp_md);
if (!gv_ms_enable_messages) {
lv_repeat = true;
if (gv_ms_trace_mon)
trace_where_printf(WHERE,
"disabled mon-messages, deleting mon message, sre.msgid=%d\n",
lp_md->iv_link.iv_id.i);
MS_BUF_MGR_FREE(lp_md->out.ip_recv_data);
lp_md->out.ip_recv_data = NULL;
SB_Trans::Msg_Mgr::put_md(lp_md->iv_link.iv_id.i, "mon-msg disabled");
}
}
} while (lv_repeat);
// set LREQ according to whether there are more messages [timers]
gv_ms_recv_q.lock(); // good for timer too
if (gv_ms_recv_q.empty() && sb_timer_comp_q_empty())
gv_ms_event_mgr.get_mgr(NULL)->clear_event(LREQ);
else
gv_ms_event_mgr.get_mgr(NULL)->set_event(LREQ, NULL);
gv_ms_recv_q.unlock();
// set LCAN if there are more cancel messages (don't clear if there aren't)
if (!gv_ms_abandon_comp_q.empty())
gv_ms_event_mgr.get_mgr(NULL)->set_event(LCAN, NULL);
if (lv_fserr == XSRETYPE_NOWORK) {
if (gv_ms_trace_verbose)
return ms_err_rtn_msg(WHERE,
"EXIT No work, ret=NOWORK",
lv_fserr);
else
return lv_fserr;
}
if (!lv_traced && gv_ms_trace_params && !gv_ms_trace_verbose)
trace_where_printf(WHERE,
"ENTER sre=%p, listenopts=0x%x, listenertag=%ld\n",
pfp(pp_sre), pv_listenopts, pv_listenertag);
if (lp_tle == NULL)
lp_md->ip_mgr = gv_ms_event_mgr.get_mgr(NULL);
if (lp_tle != NULL) {
BMS_SRE_TPOP *lp_sre_tpop = reinterpret_cast<BMS_SRE_TPOP *>(pp_sre);
sb_timer_set_sre_tpop(lp_sre_tpop, lp_tle);
lv_fserr = XSRETYPE_TPOP;
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_TPOP,
lp_sre_tpop->sre_tleId,
lv_fserr);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"EXIT from=self(tpop), ret=%d, sre.tleid=%d, .toval=%d, .p1=%d, .p2=%ld\n",
lv_fserr,
lp_sre_tpop->sre_tleId,
lp_sre_tpop->sre_tleTOVal,
lp_sre_tpop->sre_tleParm1,
lp_sre_tpop->sre_tleParm2);
} else if (lv_abandoned) {
BMS_SRE_ABANDON *lp_sre_abandon = reinterpret_cast<BMS_SRE_ABANDON *>(pp_sre);
lp_sre_abandon->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre_abandon->sre_servTag = lp_md->iv_tag;
lv_fserr = BSRETYPE_ABANDON;
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_ABANDON,
lp_md->iv_link.iv_id.i,
lv_fserr);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"EXIT from=self(abandon), ret=%d, sre.msgid=%d, sre.servTag=" PFTAG "\n",
lv_fserr,
lp_sre_abandon->sre_msgId,
lp_sre_abandon->sre_servTag);
} else if (lp_md->out.iv_ldone) {
BMS_SRE_LDONE *lp_sre_ldone = reinterpret_cast<BMS_SRE_LDONE *>(pp_sre);
lp_sre_ldone->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre_ldone->sre_linkTag = lp_md->iv_tag;
lv_fserr = XSRETYPE_LDONE;
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_LDONE,
lp_md->iv_link.iv_id.i,
lv_fserr);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"EXIT from=self(ldone), ret=%d, sre.msgid=%d, sre.linkTag=" PFTAG "\n",
lv_fserr,
lp_sre_ldone->sre_msgId,
lp_sre_ldone->sre_linkTag);
} else {
// unfortunately, the code is replicated due to different
// structs being used
lp_md->iv_tag = pv_listenertag;
if (pv_big) {
BMS_SRE *lp_sre = reinterpret_cast<BMS_SRE *>(pp_sre);
lp_sre->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre->sre_flags = BSRE_REMM;
if (lp_md->out.iv_mon_msg)
lp_sre->sre_flags |= BSRE_MON;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR)
lp_sre->sre_flags |= BSRE_AGGR;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_PROCDEAD)
lp_sre->sre_flags |= BSRE_PROCDEAD;
lp_sre->sre_pri = lp_md->out.iv_pri;
lp_sre->sre_reqCtrlSize = lp_md->out.iv_recv_ctrl_size;
lp_sre->sre_reqDataSize = lp_md->out.iv_recv_data_size;
lp_sre->sre_replyCtrlMax = lp_md->out.iv_recv_ctrl_max;
lp_sre->sre_replyDataMax = lp_md->out.iv_recv_data_max;
lv_fserr = XSRETYPE_IREQ;
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_IREQ,
lp_md->iv_link.iv_id.i,
lv_fserr);
if (lp_md->out.iv_recv_ctrl_size > 0)
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_IREQ_CTRL,
lp_md->out.iv_recv_ctrl_size,
reinterpret_cast<long>(lp_md->out.ip_recv_ctrl));
if (lp_md->out.iv_recv_data_size > 0)
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_IREQ_DATA,
lp_md->out.iv_recv_data_size,
reinterpret_cast<long>(lp_md->out.ip_recv_data));
if (gv_ms_trace_params) {
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
char *lp_from;
if (lp_stream == NULL)
lp_from = NULL;
else
lp_from = lp_stream->get_name();
trace_where_printf(WHERE,
"EXIT from=%s, reqid=%d, ret=%d, sre.msgid=%d, .flags=0x%x, .pri=%d, .ctrl=%d, .data=%d\n",
lp_from,
lp_md->out.iv_recv_req_id,
lv_fserr,
lp_sre->sre_msgId,
lp_sre->sre_flags,
lp_sre->sre_pri,
lp_sre->sre_reqCtrlSize,
lp_sre->sre_reqDataSize);
}
} else {
MS_SRE *lp_sre = reinterpret_cast<MS_SRE *>(pp_sre);
lp_sre->sre_msgId = lp_md->iv_link.iv_id.i;
lp_sre->sre_flags = XSRE_REMM;
if (lp_md->out.iv_mon_msg)
lp_sre->sre_flags |= XSRE_MON;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_AGGR)
lp_sre->sre_flags |= XSRE_AGGR;
if (lp_md->out.iv_opts & SB_Trans::MS_OPTS_PROCDEAD)
lp_sre->sre_flags |= XSRE_PROCDEAD;
lp_sre->sre_pri = static_cast<short>(lp_md->out.iv_pri);
lp_sre->sre_reqCtrlSize =
static_cast<ushort>(lp_md->out.iv_recv_ctrl_size);
lp_sre->sre_reqDataSize =
static_cast<ushort>(lp_md->out.iv_recv_data_size);
lp_sre->sre_replyCtrlMax =
static_cast<ushort>(lp_md->out.iv_recv_ctrl_max);
lp_sre->sre_replyDataMax =
static_cast<ushort>(lp_md->out.iv_recv_data_max);
lv_fserr = XSRETYPE_IREQ;
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_IREQ,
lp_md->iv_link.iv_id.i,
lv_fserr);
if (lp_md->out.iv_recv_ctrl_size > 0)
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_IREQ_CTRL,
lp_md->out.iv_recv_ctrl_size,
reinterpret_cast<long>(lp_md->out.ip_recv_ctrl));
if (lp_md->out.iv_recv_data_size > 0)
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MSG_LISTEN_IREQ_DATA,
lp_md->out.iv_recv_data_size,
reinterpret_cast<long>(lp_md->out.ip_recv_data));
if (gv_ms_trace_params) {
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
char *lp_from;
if (lp_stream == NULL)
lp_from = NULL;
else
lp_from = lp_stream->get_name();
trace_where_printf(WHERE,
"EXIT from=%s, reqid=%d, ret=%d, sre.msgid=%d, .flags=0x%x, .pri=%d, .ctrl=%d, .data=%d\n",
lp_from,
lp_md->out.iv_recv_req_id,
lv_fserr,
lp_sre->sre_msgId,
lp_sre->sre_flags,
lp_sre->sre_pri,
lp_sre->sre_reqCtrlSize,
lp_sre->sre_reqDataSize);
}
}
}
return lv_fserr;
}
SB_Export short BMSG_LISTEN_(short *pp_sre,
short pv_listenopts,
long pv_listenertag) {
return BMSG_LISTEN_common(pp_sre, pv_listenopts, pv_listenertag, true);
}
//
// Purpose: emulate READCTRL_
//
SB_Export short BMSG_READCTRL_(int pv_msgid,
short *pp_reqctrl,
int pv_bytecount) {
const char *WHERE = "BMSG_READCTRL_";
MS_Md_Type *lp_md;
int lv_rc;
SB_API_CTR (lv_zctr, BMSG_READCTRL_);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER msgid=%d, reqC=%p, bytecount=%d\n",
pv_msgid, pfp(pp_reqctrl), pv_bytecount);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, WHERE);
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
if (lp_md->iv_abandoned)
return ms_err_rtn_msg(WHERE, "EXIT [msg abandoned]", 1); // spec says 1
SB_Trans::Trans_Stream::recv_copy(WHERE,
&lp_md->out.ip_recv_ctrl,
lp_md->out.iv_recv_ctrl_size,
reinterpret_cast<char *>(pp_reqctrl),
pv_bytecount,
&lv_rc,
false);
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"reqC=%p, bytecount=%d\n",
pfp(pp_reqctrl), lv_rc);
trace_print_data(pp_reqctrl, lv_rc, gv_ms_trace_data_max);
}
short lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: emulate MSG_READDATA_
//
SB_Export short BMSG_READDATA_(int pv_msgid,
char *pp_reqdata,
int pv_bytecount) {
const char *WHERE = "BMSG_READDATA_";
MS_Md_Type *lp_md;
int lv_rc;
SB_API_CTR (lv_zctr, BMSG_READDATA_);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER msgid=%d, reqD=%p, bytecount=%d\n",
pv_msgid, pp_reqdata, pv_bytecount);
lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, WHERE);
if (lp_md == NULL)
return ms_err_rtn_msg(WHERE, "EXIT [msg == NULL]", XZFIL_ERR_NOTFOUND);
if (lp_md->iv_abandoned)
return ms_err_rtn_msg(WHERE, "EXIT [msg abandoned]", 1); // spec says 1
SB_Trans::Trans_Stream::recv_copy(WHERE,
&lp_md->out.ip_recv_data,
lp_md->out.iv_recv_data_size,
pp_reqdata,
pv_bytecount,
&lv_rc,
false);
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"reqD=%p, bytecount=%d\n",
pp_reqdata, lv_rc);
trace_print_data(pp_reqdata, lv_rc, gv_ms_trace_data_max);
}
short lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
//
// Purpose: emulate MSG_RELEASEALLHELD_
//
SB_Export void BMSG_RELEASEALLHELD_() {
const char *WHERE = "BMSG_RELEASEALLHELD_";
SB_API_CTR (lv_zctr, BMSG_RELEASEALLHELD_);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "ENTER\n");
// NSK would do a halt
SB_util_assert_it(gv_ms_calls_ok); // sw fault
// move hold-q to recv-q
MS_Md_Type *lp_md = static_cast<MS_Md_Type *>(gv_ms_hold_q.remove());
while (lp_md != NULL) {
gv_ms_recv_q.add(&lp_md->iv_link);
lp_md = static_cast<MS_Md_Type *>(gv_ms_hold_q.remove());
}
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT\n");
}
//
// Purpose: emulate MSG_REPLY_
//
SB_Export void BMSG_REPLY_(int pv_msgid,
short *pp_replyctrl,
int pv_replyctrlsize,
char *pp_replydata,
int pv_replydatasize,
short pv_errorclass,
SB_Phandle_Type *pp_newphandle) {
const char *WHERE = "BMSG_REPLY_";
long long lv_delta;
short lv_fserr;
SB_API_CTR (lv_zctr, BMSG_REPLY_);
SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MS_MSG_REPLY, pv_msgid);
MS_Md_Type *lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, WHERE);
if (lp_md == NULL) {
if (gv_ms_trace_params) {
trace_where_printf(WHERE, "ENTER msgid=%d, repC=%d, repD=%d\n",
pv_msgid, pv_replyctrlsize, pv_replydatasize);
trace_where_printf(WHERE, "EXIT unknown msgid=%d\n", pv_msgid);
}
// NSK does a halt
SB_util_assert_pne(lp_md, NULL); // sw fault
}
SB_Trans::Stream_Base *lp_stream = static_cast<SB_Trans::Stream_Base *>(lp_md->ip_stream);
if (gv_ms_trace_params) {
char *lp_to;
if (lp_stream == NULL)
lp_to = NULL;
else
lp_to = lp_stream->get_name();
trace_where_printf(WHERE,
"ENTER to=%s (reqid=%d), msgid=%d, repC=%p, repCsize=%d\n",
lp_to,
lp_md->out.iv_recv_req_id,
pv_msgid,
pfp(pp_replyctrl),
pv_replyctrlsize);
gettimeofday(&lp_md->out.iv_reply_tod, NULL);
lv_delta = (lp_md->out.iv_reply_tod.tv_sec * SB_US_PER_SEC +
lp_md->out.iv_reply_tod.tv_usec) -
(lp_md->out.iv_recv_q_off_tod.tv_sec * SB_US_PER_SEC +
lp_md->out.iv_recv_q_off_tod.tv_usec);
trace_where_printf(WHERE,
"repD=%p, repDsize=%d, ecls=%d, nphdl=%p, listen-to-reply=%lld us\n",
pfp(pp_replydata),
pv_replydatasize,
pv_errorclass,
pfp(pp_newphandle),
lv_delta);
}
if (gv_ms_trace_data) {
trace_where_printf(WHERE,
"repC=%p, repCsize=%d\n",
pfp(pp_replyctrl), pv_replyctrlsize);
trace_print_data(pp_replyctrl, pv_replyctrlsize, gv_ms_trace_data_max);
trace_where_printf(WHERE,
"repD=%p, repDsize=%d\n",
pp_replydata, pv_replydatasize);
trace_print_data(pp_replydata, pv_replydatasize, gv_ms_trace_data_max);
}
if (lp_md->out.iv_mon_msg) {
if (lp_md->out.iv_requeue) {
lp_md->out.iv_requeue = false;
gv_ms_recv_q.add_at_front(&lp_md->iv_link);
gv_ms_event_mgr.set_event_all(LREQ);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT mon message requeue\n");
} else {
// could be timer (no stream)
ms_free_recv_bufs(lp_md);
if (lp_stream == NULL)
SB_Trans::Msg_Mgr::put_md(lp_md->iv_link.iv_id.i, "free mon-reply-md");
else
lp_stream->free_reply_md(lp_md);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT mon message\n");
}
return;
}
if (!lp_md->out.iv_reply) {
ms_free_recv_bufs(lp_md);
if (lp_stream == NULL)
SB_Trans::Msg_Mgr::put_md(lp_md->iv_link.iv_id.i, "free no-reply-md");
else
lp_stream->free_reply_md(lp_md);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT no reply\n");
return;
}
// if client limits max, then we need to limit our response
int lv_csize = sbmin(pv_replyctrlsize, lp_md->out.iv_recv_ctrl_max);
int lv_dsize = sbmin(pv_replydatasize, lp_md->out.iv_recv_data_max);
lv_fserr = lp_stream->exec_reply(lp_md,
0, // src
lp_md->out.iv_recv_mpi_source_rank, // dest
lp_md->out.iv_recv_req_id,
pp_replyctrl,
lv_csize,
pp_replydata,
lv_dsize,
XZFIL_ERR_OK);
// if pathdown, don't worry about it
ms_err_check_mpi_pathdown_ok(WHERE, "sending reply", lv_fserr);
if (lv_fserr == XZFIL_ERR_OK)
lp_stream->wait_rep_done(lp_md); // don't wait if path is down
// free recv buffers after reply in case user uses them in reply
ms_free_recv_bufs(lp_md);
lp_stream->free_reply_md(lp_md);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT\n");
}
//
// Purpose: emulate MSG_SETTAG_
//
SB_Export short BMSG_SETTAG_(int pv_msgid,
long pv_tag) {
const char *WHERE = "BMSG_SETTAG_";
SB_API_CTR (lv_zctr, BMSG_SETTAG_);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER msgid=%d, tag=%ld\n",
pv_msgid,
pv_tag);
MS_Md_Type *lp_md = SB_Trans::Msg_Mgr::map_to_md(pv_msgid, WHERE);
if (lp_md == NULL) {
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT unknown msgid=%d\n", pv_msgid);
SB_util_assert_pne(lp_md, NULL); // sw fault
}
lp_md->iv_tag = pv_tag;
short lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
SB_Export short XCONTROLMESSAGESYSTEM(short pv_actioncode, short pv_value) {
const char *WHERE = "XCONTROLMESSAGESYSTEM";
short lv_fserr;
SB_API_CTR (lv_zctr, XCONTROLMESSAGESYSTEM);
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_CONTROLMESSAGESYSTEM,
pv_actioncode, pv_value);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER actioncode=%d, value=%d\n",
pv_actioncode, pv_value);
switch (pv_actioncode) {
case XCTLMSGSYS_SETRECVLIMIT:
if ((pv_value > 0) && (pv_value <= XMAX_SETTABLE_RECVLIMIT_TM)) {
lv_fserr = XZFIL_ERR_OK;
SB_Trans::Msg_Mgr::set_md_max_recv(pv_value);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "setting SETRECVLIMIT value=%d\n",
pv_value);
} else {
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT bad value\n");
lv_fserr = XZFIL_ERR_BADCOUNT;
}
break;
case XCTLMSGSYS_SETSENDLIMIT:
if ((pv_value > 0) && (pv_value <= XMAX_SETTABLE_SENDLIMIT_TM)) {
lv_fserr = XZFIL_ERR_OK;
SB_Trans::Msg_Mgr::set_md_max_send(pv_value);
if (gv_ms_trace_params)
trace_where_printf(WHERE, "setting SETSENDLIMIT value=%d\n",
pv_value);
} else {
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT bad value\n");
lv_fserr = XZFIL_ERR_BADCOUNT;
}
break;
default:
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT bad actioncode\n");
lv_fserr = XZFIL_ERR_INVALOP;
break;
}
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
SB_Export short XMESSAGESYSTEMINFO(short pv_itemcode, short *pp_value) {
const char *WHERE = "XMESSAGESYSTEMINFO";
short lv_fserr;
short lv_value;
SB_API_CTR (lv_zctr, XMESSAGESYSTEMINFO);
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MESSAGESYSTEMINFO, pv_itemcode, 0);
if (gv_ms_trace_params)
trace_where_printf(WHERE,
"ENTER itemcode=%d, value=%p\n",
pv_itemcode, pfp(pp_value));
if (pp_value == NULL) {
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT bad value\n");
lv_fserr = XZFIL_ERR_BADCOUNT;
} else {
lv_fserr = XZFIL_ERR_OK;
switch (pv_itemcode) {
case XMSGSYSINFO_RECVLIMIT:
lv_value = static_cast<short>(SB_Trans::Msg_Mgr::get_md_max_recv());
if (gv_ms_trace_params)
trace_where_printf(WHERE, "returning RECVLIMIT value=%d\n",
lv_value);
break;
case XMSGSYSINFO_SENDLIMIT:
lv_value = static_cast<short>(SB_Trans::Msg_Mgr::get_md_max_send());
if (gv_ms_trace_params)
trace_where_printf(WHERE, "returning SENDLIMIT value=%d\n",
lv_value);
break;
case XMSGSYSINFO_RECVUSE:
lv_value = static_cast<short>(SB_Trans::Msg_Mgr::get_md_count_recv());
if (gv_ms_trace_params)
trace_where_printf(WHERE, "returning RECVUSE value=%d\n",
lv_value);
break;
case XMSGSYSINFO_SENDUSE:
lv_value = static_cast<short>(SB_Trans::Msg_Mgr::get_md_count_send());
if (gv_ms_trace_params)
trace_where_printf(WHERE, "returning SENDUSE value=%d\n",
lv_value);
break;
default:
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT bad itemcode\n");
lv_fserr = XZFIL_ERR_INVALOP;
break;
}
if (lv_fserr == XZFIL_ERR_OK) {
SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_MS_MESSAGESYSTEMINFO,
pv_itemcode, lv_value);
*pp_value = lv_value;
}
}
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return ms_err_rtn(lv_fserr);
}
SB_Export short XMSG_ABANDON_(int pv_msgid) {
return BMSG_ABANDON_(pv_msgid);
}
SB_Export short XMSG_AWAIT_(int pv_msgid, int pv_tov) {
return BMSG_AWAIT_(pv_msgid, pv_tov);
}
SB_Export short XMSG_BREAK_(int pv_msgid,
short *pp_results,
SB_Phandle_Type *pp_phandle) {
return BMSG_BREAK_(pv_msgid,
pp_results,
pp_phandle);
}
SB_Export void XMSG_BREAK2_(int pv_msgid,
short *pp_results,
SB_Phandle_Type *pp_phandle) {
BMSG_BREAK2_(pv_msgid,
pp_results,
pp_phandle);
}
SB_Export short XMSG_GETREQINFO_(int pv_item_code,
int pv_msgid,
int *pp_item) {
return BMSG_GETREQINFO_(pv_item_code,
pv_msgid,
pp_item);
}
SB_Export void XMSG_HOLD_(int pv_msgid) {
BMSG_HOLD_(pv_msgid);
}
SB_Export short XMSG_ISCANCELED_(int pv_msgid) {
return BMSG_ISCANCELED_(pv_msgid);
}
SB_Export short XMSG_ISDONE_(int pv_msgid) {
return BMSG_ISDONE_(pv_msgid);
}
SB_Export short XMSG_LINK_(SB_Phandle_Type *pp_phandle,
int *pp_msgid,
short *pp_reqctrl,
ushort pv_reqctrlsize,
short *pp_replyctrl,
ushort pv_replyctrlmax,
char *pp_reqdata,
ushort pv_reqdatasize,
char *pp_replydata,
ushort pv_replydatamax,
long pv_linkertag,
short pv_pri,
short pv_xmitclass,
short pv_linkopts) {
return BMSG_LINK_common(pp_phandle,
pp_msgid,
pp_reqctrl,
pv_reqctrlsize,
pp_replyctrl,
pv_replyctrlmax,
pp_reqdata,
pv_reqdatasize,
pp_replydata,
pv_replydatamax,
pv_linkertag,
pv_pri,
pv_xmitclass,
pv_linkopts,
false);
}
SB_Export short XMSG_LINK2_(SB_Phandle_Type *pp_phandle,
int *pp_msgid,
short *pp_reqctrl,
ushort pv_reqctrlsize,
short *pp_replyctrl,
ushort pv_replyctrlmax,
char *pp_reqdata,
ushort pv_reqdatasize,
char *pp_replydata,
ushort pv_replydatamax,
long pv_linkertag,
short pv_pri,
short pv_xmitclass,
short pv_linkopts) {
return BMSG_LINK_common(pp_phandle,
pp_msgid,
pp_reqctrl,
pv_reqctrlsize,
pp_replyctrl,
pv_replyctrlmax,
pp_reqdata,
pv_reqdatasize,
pp_replydata,
pv_replydatamax,
pv_linkertag,
pv_pri,
pv_xmitclass,
pv_linkopts,
true); // nsk check
}
SB_Export short XMSG_LISTEN_(short *pp_sre,
short pv_listenopts,
long pv_listenertag) {
return BMSG_LISTEN_common(pp_sre,
pv_listenopts,
pv_listenertag,
false);
}
SB_Export short XMSG_READCTRL_(int pv_msgid,
short *pp_reqctrl,
ushort pv_bytecount) {
return BMSG_READCTRL_(pv_msgid,
pp_reqctrl,
pv_bytecount);
}
SB_Export short XMSG_READDATA_(int pv_msgid,
char *pp_reqdata,
ushort pv_bytecount) {
return BMSG_READDATA_(pv_msgid,
pp_reqdata,
pv_bytecount);
}
SB_Export void XMSG_REPLY_(int pv_msgid,
short *pp_replyctrl,
ushort pv_replyctrlsize,
char *pp_replydata,
ushort pv_replydatasize,
short pv_errorclass,
SB_Phandle_Type *pp_newphandle) {
return BMSG_REPLY_(pv_msgid,
pp_replyctrl,
pv_replyctrlsize,
pp_replydata,
pv_replydatasize,
pv_errorclass,
pp_newphandle);
}
SB_Export void XMSG_RELEASEALLHELD_() {
BMSG_RELEASEALLHELD_();
}
SB_Export short XMSG_SETTAG_(int pv_msgid, long pv_tag) {
return BMSG_SETTAG_(pv_msgid, pv_tag);
}
//
// Purpose: send-to-self
// format md and queue to $receive
// no reply allowed
//
void msg_send_self(SB_Phandle_Type *pp_phandle,
short *pp_reqctrl,
int pv_reqctrlsize,
char *pp_reqdata,
int pv_reqdatasize) {
const char *WHERE = "msg_send_self";
MS_Md_Type *lp_md;
SB_Trans::Stream_Base *lp_stream;
lp_stream = ms_od_map_phandle_to_stream(pp_phandle);
SB_Trans::Msg_Mgr::get_md(&lp_md, // msg_send_self
lp_stream,
NULL,
false, // recv
NULL, // fserr
WHERE,
MD_STATE_MSG_SEND_SELF);
SB_util_assert_pne(lp_md, NULL); // TODO: can't get md
lp_md->iv_tag = -1;
lp_md->iv_self = true;
lp_md->out.iv_mon_msg = false;
lp_md->out.iv_nid = gv_ms_su_nid;
lp_md->out.iv_opts = 0;
lp_md->out.iv_pid = gv_ms_su_pid;
lp_md->out.iv_recv_req_id = 0;
lp_md->out.iv_pri = -1;
lp_md->out.iv_recv_mpi_source_rank = -1;
lp_md->out.iv_recv_mpi_tag = -1;
lp_md->out.ip_recv_ctrl = reinterpret_cast<char *>(pp_reqctrl);
lp_md->out.iv_recv_ctrl_size = pv_reqctrlsize;
lp_md->out.ip_reply_ctrl = NULL;
lp_md->out.iv_reply_ctrl_max = 0;
lp_md->out.ip_recv_data = pp_reqdata;
lp_md->out.iv_recv_data_size = pv_reqdatasize;
lp_md->out.ip_reply_data = NULL;
lp_md->out.iv_reply_data_max = 0;
gv_ms_recv_q.add(&lp_md->iv_link);
gv_ms_event_mgr.set_event_all(LREQ);
}
SB_Export short msg_set_phandle(char *pp_pname,
SB_Phandle_Type *pp_phandle) {
const char *WHERE = "msg_set_phandle";
char la_pname[MS_MON_MAX_PROCESS_NAME+1];
SB_Phandle_Type *lp_phandle;
short lv_fserr;
SB_API_CTR (lv_zctr, MSG_SET_PHANDLE);
if (gv_ms_trace_params) {
char la_phandle[MSG_UTIL_PHANDLE_LEN];
msg_util_format_phandle(la_phandle, pp_phandle);
trace_where_printf(WHERE,
"ENTER pname=%s, phandle=%s\n",
pp_pname,
la_phandle);
}
if (pp_pname == NULL) {
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=-1, name is NULL\n");
return -1;
}
if (gv_ms_init_phandle) {
gv_ms_init_phandle = false;
gv_ms_max_phandles = 0;
ms_getenv_int(gp_ms_env_max_cap_phandles, &gv_ms_max_phandles);
}
SB_util_get_case_insensitive_name(pp_pname, la_pname);
if (pp_phandle == NULL) {
gv_ms_phandle_map.remove(la_pname, NULL);
} else {
if (gv_ms_trace)
trace_where_printf(WHERE, "PHANDLES-inuse-count=%d\n",
gv_ms_phandle_map.size());
if (gv_ms_max_phandles)
SB_util_assert_ilt(gv_ms_phandle_map.size(), gv_ms_max_phandles);
lp_phandle = new SB_Phandle_Type;
memcpy(lp_phandle, pp_phandle, sizeof(SB_Phandle_Type));
gv_ms_phandle_map.putv(la_pname, lp_phandle);
}
lv_fserr = XZFIL_ERR_OK;
if (gv_ms_trace_params)
trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr);
return lv_fserr;
}
int msg_test_assert_disable() {
int lv_aret = gv_ms_assert_error;
gv_ms_assert_error = 0;
return lv_aret;
}
void msg_test_assert_enable(int pv_state) {
gv_ms_assert_error = pv_state;
}
void msg_trace_args(char *pp_line, char **ppp_argv, int pv_argc, int pv_len) {
int lv_len = static_cast<int>(strlen(pp_line));
for (int lv_arg = 0; lv_arg < pv_argc; lv_arg++) {
lv_len += 3 + static_cast<int>(strlen(ppp_argv[lv_arg]));
if (lv_len > pv_len)
break;
strcat(pp_line, "'");
strcat(pp_line, ppp_argv[lv_arg]);
strcat(pp_line, "'");
if (lv_arg != (pv_argc - 1))
strcat(pp_line, ",");
}
}
//
// For future use - called when library is loaded
// Note that other constructors may have been called
// before this one gets called.
//
void __msg_init(void) {
}
//
// For future use - called when library is unloaded
//
void __msg_fini(void) {
}
| [
"steve.varnau@hp.com"
] | steve.varnau@hp.com |
2f38f87049c9beb21c2c298c1900fb2d2e0ef7c1 | fda021e2c1e18249254d2235a23de309d015ce02 | /ass1/lencode.cpp | bd6371a88f42361c0dc4e0c430ee29e669b9e9e0 | [] | no_license | lianfengluo/comp9319_2019 | 176b1ddd1c5f14a6f3b3f2a6f1569ace6322e8ab | fa15e255fa86ae5f5ad95feb3d21f5b34a8efa26 | refs/heads/master | 2020-06-15T10:33:28.239987 | 2019-09-18T06:44:32 | 2019-09-18T06:44:32 | 195,273,938 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,929 | cpp | #include <cstdint>
#include <iostream>
#include <string>
#include <unordered_map>
const size_t MAX_ENTRIES = 16384;
int main(int argc, char *argv[])
{
bool listing = false;
if (argc == 2)
{
if (std::string(argv[1]) == "-l")
{
listing = true;
}
else
{
std::cerr << "Error flag!" << std::endl;
exit(1);
}
}
std::string input;
getline(std::cin, input);
std::unordered_map<std::string, int32_t> entries;
entries.reserve(MAX_ENTRIES);
for (int i = 0; i != 256; ++i)
entries.emplace(std::string{static_cast<int8_t>(i)}, i);
int32_t cur = 256;
std::string pre, combine, out_s;
if (!listing)
{
for (size_t i = 0;; ++i)
{
if (i != input.size())
{
combine = pre + input[i];
if (entries.find(combine) != entries.end())
{
// in the entries
pre = combine;
continue;
}
if (pre.size() == 1)
{
// output visible char
std::cout << pre;
}
else
{
// string in dictionary
std::cout << entries.find(pre)->second;
}
std::cout << ' ';
}
else
{
if (pre.size() == 1)
{
// output visible char
std::cout << pre;
}
else
{
// string in dictionary
std::cout << entries.find(pre)->second;
}
break;
}
pre = std::string{combine.back()};
if (cur != MAX_ENTRIES)
{
entries.emplace(combine, cur++);
}
}
std::cout << std::endl;
}
else
{
for (size_t i = 0;; ++i)
{
if (i != input.size())
{
combine = pre + input[i];
if (entries.find(combine) != entries.end())
{
// in the entries
if (pre.size() == 0)
{
std::cout << "NIL " << input[i];
}
else
{
std::cout << pre << ' ' << input[i];
}
std::cout << '\n';
pre = combine;
continue;
}
if (entries.find(pre)->second > 255)
{
out_s = std::to_string(entries.find(pre)->second);
}
else
{
out_s = std::string{static_cast<int8_t>(pre[0])};
}
}
else
{
if (entries.find(pre)->second > 255)
{
out_s = std::to_string(entries.find(pre)->second);
}
else
{
out_s = std::string{static_cast<int8_t>(pre[0])};
}
break;
}
std::cout << pre << ' ' << input[i] << ' ' << out_s;
pre = std::string{combine.back()};
if (cur != MAX_ENTRIES)
{
entries.emplace(combine, cur);
std::cout << ' ' << cur << ' ' << combine;
++cur;
}
std::cout << '\n';
}
std::cout << pre << " EOF " << out_s << std::endl;
}
return 0;
}
| [
"richard@Richard-2.local"
] | richard@Richard-2.local |
048d5bd966974398215caf69c7b72964f2cdd32b | ecb533068b5fc24bdfd7aa714a38bddc85b5b4e5 | /Solution in C++/question2.cpp | 51fd9aaa25fb07ccfa7d1fa2e4bd0b895f455933 | [
"MIT"
] | permissive | PIYSocial-India/ProjectEuler | 26ccd50f3998c012458b27bfc64b8599a53e9e44 | 10b93019ddc87941c9f4ce726c0db0dd43b66989 | refs/heads/main | 2023-01-01T12:33:13.038551 | 2020-10-24T13:52:19 | 2020-10-24T13:52:19 | 306,375,915 | 1 | 3 | MIT | 2020-10-24T13:52:21 | 2020-10-22T15:10:37 | Java | UTF-8 | C++ | false | false | 351 | cpp | //even fibbo
#include<iostream>
using namespace std;
#include<conio.h>
#include<stdlib.h>
int main()
{
system("cls");
long long n=4000000;
if(n<2)
{
exit (0);
}
long long x=1,y=2,sum=0,z=0;
while(1==1)
{
if(x>=n)
break;
if(x%2==0)
sum=sum+x;
z=x+y;
x=y;
y=z;
}
cout<<sum;
getch();
}
| [
"noreply@github.com"
] | noreply@github.com |
78263e73fbfe0e607a1ee3f4ca48cf8086941105 | d7cfbfe07a5425a44a9dc26fbb6d8fb036c3133b | /src/cir/cirDef.h | e35f88f6c0730090429b1b837b2d99c65e60147d | [] | no_license | kidkcl/CAD_Contest_2017_A | 1b1900065b64d2f42a6dbf9f4e3fd48cce31db27 | dbfea202a4fb241a5043edadde3085dd3e4c16e0 | refs/heads/master | 2021-01-18T03:39:18.558167 | 2017-04-25T11:46:14 | 2017-04-25T11:46:14 | 85,801,144 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 720 | h | /****************************************************************************
FileName [ cirDef.h ]
PackageName [ cir ]
Synopsis [ Define basic data or var for cir package ]
Author [ Chung-Yang (Ric) Huang ]
Copyright [ Copyleft(c) 2012-present LaDs(III), GIEE, NTU, Taiwan ]
****************************************************************************/
#ifndef CIR_DEF_H
#define CIR_DEF_H
#include <vector>
#include "myHashMap.h"
using namespace std;
// TODO: define your own typedef or enum
class CirGate;
class CirGateV;
class CirMgr;
class SatSolver;
typedef vector<CirGate*> GateList;
typedef vector<unsigned> IdList;
typedef vector<CirGateV> fanoutArr;
#endif // CIR_DEF_H
| [
"yagamigin@gmail.com"
] | yagamigin@gmail.com |
6b6c715fb7b552f7445b3ee7d2a177a86a9d6035 | 5364f1c44ddb405f2f02685b9a66babd2852a5c5 | /fullcard_data_parser.h | cb3c50cbc2affe027870bebbb2d724b0447aeca9 | [] | no_license | zhangyu74/fc | 9cc45faf97a1a477ac7b215e8595aca154cd811a | 9435224e44b00a98683f86b7eae097369947838f | refs/heads/master | 2020-07-06T19:02:58.483693 | 2019-08-19T06:27:15 | 2019-08-19T06:27:15 | 203,111,441 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,614 | h | #pragma once
#include "Trilateration.h"
#include <stdlib.h>
#include <stddef.h>
#include <cstring> /**< memset */
#include <vector> /**< std::vector */
#include <iostream> /**< std::cout std::cerr std::endl */
#include <fstream> /**< std::ifstream */
#include <assert.h> /** assert */
#include "rapidjson/document.h" /**< rapidjson::Document */
#include "rapidjson/istreamwrapper.h" /**< rapidjson::IStreamWrapper */
class FullCardDataParser
{
public:
FullCardDataParser(rapidjson::Document &config)
: m_Offset(0)
{
//init
memset(m_buffer, 0, sizeof(m_buffer));
m_r1 = 0;
m_r2 = 0;
m_r3 = 0;
m_totalcount = 0;
m_lostcount = 0;
memset(&m_finalPose, 0, sizeof(m_finalPose));
memset(&m_finalonlat, 0, sizeof(m_finalonlat));
double x0 = config["x0"].GetDouble();
double y0 = config["y0"].GetDouble();
double x1 = config["x1"].GetDouble();
double y1 = config["y1"].GetDouble();
double x2 = config["x2"].GetDouble();
double y2 = config["y2"].GetDouble();
Cartesian_p1 = {x0, y0};
Cartesian_p2 = {x1, y1};
Cartesian_p3 = {x2, y2};
m_r1_lon = config["lon0"].GetDouble();
m_r1_lat = config["lat0"].GetDouble();
m_r2_lon = config["lon1"].GetDouble();
m_r2_lat = config["lat1"].GetDouble();
m_r3_lon = config["lon2"].GetDouble();
m_r3_lat = config["lat2"].GetDouble();
//open log file
time_t t = time(NULL);
char originalFileName[64] = {0};
char resultFileName[64] = {0};
strftime(originalFileName, sizeof(originalFileName) - 1, "%Y-%m-%d_%H-%M-%S_originalFC.log", localtime(&t));
strftime(resultFileName, sizeof(resultFileName) - 1, "%Y-%m-%d_%H-%M-%S_resultFC.log", localtime(&t));
m_resultLog.open(resultFileName, std::ios::binary);
if (m_resultLog.fail())
{
printf("open fullcard record log error!");
exit(0);
}
m_originalLog.open(originalFileName, std::ios::binary);
if (m_originalLog.fail())
{
printf("open fullcard all data record log error!");
exit(0);
}
}
virtual ~FullCardDataParser();
// This API will regard the input as a stream data.
void parse(const uint8_t *data, size_t length);
Point_XY get2dXY(int fildis, int tag, int anchor);
Point_LonLat get2dLonLat(int fildis, int tag, int anchor);
private:
uint8_t m_buffer[1024];
int m_Offset;
int m_totalcount;
int m_lostcount;
//point
Point_XY Cartesian_p1;
Point_XY Cartesian_p2;
Point_XY Cartesian_p3;
double m_r1_lon;
double m_r1_lat;
double m_r2_lon;
double m_r2_lat;
double m_r3_lon;
double m_r3_lat;
//distance to anchor
double m_r1;
double m_r2;
double m_r3;
//result
Point_XY m_finalPose;
Point_LonLat m_finalonlat;
//save log
std::ofstream m_resultLog;
std::ofstream m_originalLog;
//lon,lat
//20190715
//double m_r1_lon = 116.263654;
//double m_r1_lat = 40.065778;
//double m_r2_lon = 116.263428;
//double m_r2_lat = 40.065321;
//double m_r3_lon = 116.263832;
//double m_r3_lat = 40.065444;
//double m_r1_lon = 116.26370117;
//double m_r1_lat = 40.06577167;
//double m_r2_lon = 116.26339674;
//double m_r2_lat = 40.06529852;
//double m_r3_lon = 116.26379371;
//double m_r3_lat = 40.06541142;
//20190717 gongsi test
//double m_r1_lon = 116.2396329638889;
//double m_r1_lat = 40.0716846;
//double m_r2_lon = 116.23977256666667;
//double m_r2_lat = 40.07140895;
//double m_r3_lon = 116.23980405277777;
//double m_r3_lat = 40.071637808333335;
//20190717 gongsi anchor
//double m_r1_lon = 116.2395025728;
//double m_r1_lat = 40.0717291061;
//double m_r2_lon = 116.2397069754;
//double m_r2_lat = 40.0713133828;
//double m_r3_lon = 116.2399420473;
//double m_r3_lat = 40.0717547668;
//20190717 qiaoshang
//double m_r1_lon = 116.26413570833333;
//double m_r1_lat = 40.065572458333335;
//double m_r2_lon = 116.26276603888888;
//double m_r2_lat = 40.06545097777778;
//double m_r3_lon = 116.26366968055555;
//double m_r3_lat = 40.06570475;
//20190717 gongsi anchor
//double m_r1_lon = 116.2395591;
//double m_r1_lat = 40.07030046;
//double m_r2_lon = 116.2396496500;
//double m_r2_lat = 40.070114700;
//double m_r3_lon = 116.239933900;
//double m_r3_lat = 40.070313500;
};
| [
"427843255@qq.com"
] | 427843255@qq.com |
7c27974e468724fa06c8e23e2b9e11431cbd2a65 | b415063b60d516e0de0e7a83e36fa17e2e802c56 | /countCenters.cpp | 5a294a9757b6cdd454482a5ae0f06275d4bcb2fd | [] | no_license | pashadag/Hammer | 762bdd338f7261a89ceb960cd25695c038d7ff27 | 6f8aa50a16a57bf02c906a2e1eb2c8f9e42a8c71 | refs/heads/master | 2021-01-13T02:23:24.422602 | 2012-08-09T16:21:18 | 2012-08-09T16:21:18 | 2,020,873 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,344 | cpp | #include<cassert>
#include<cmath>
#include<string>
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<cstdarg>
#include<algorithm>
using namespace std;
ostringstream oMsg;
string sbuf;
#include "defs.h"
class Line {
public:
string idx;
string h1;
string h2;
};
int types[6] = {0,0,0,0,0,0};
int bigblock = 0;
void process_block(deque<Line> & block) {
int type;
int cats[4] = {0,0,0,0};
// 0 = -1 -1,
// 1 = -1 maps,
// 2 = maps -1,
// 3 = maps maps
for (int i = 0; i < block.size(); i++) {
if (block[i].h1 == "-1" && block[i].h2 == "-1") {
cats[0]++;
} else if (block[i].h1 == "-1" && block[i].h2 == "maps") {
cats[1]++;
} else if (block[i].h1 == "maps" && block[i].h2 == "-1") {
cats[2]++;
} else if (block[i].h1 == "maps" && block[i].h2 == "maps") {
cats[3]++;
}
}
if (cats[1] + cats[3] > 0) {
if (cats[3] > 1) {
type = 0;
} else if (cats[3] == 1) {
type = 1;
} else if (cats[3] == 0) {
type = 2;
}
} else {
if (cats[2] > 0) {
type = 3;
} else {
type = 4;
}
}
//for (int i = 0; i < block.size(); i++) cout << "\t" << block[i].idx << "\t" << block[i].h1 << "\t" << block[i].h2 << endl; cout << "CAT\t" <<type << endl << endl;
types[type]++;
}
int main(int argc, char * argv[]) {
deque<Line> block;
Line line, lastline;
cin >> line.idx >> line.h1 >> line.h2;
lastline = line;
block.push_back(line);
while (cin >> line.idx >> line.h1 >> line.h2) {
if (lastline.idx == line.idx) {
block.push_back(line);
} else {
process_block(block);
block.clear();
block.push_back(line);
}
lastline = line;
}
process_block(block);
cout << "0\t" << types[0] << endl;
cout << "1\t" << types[1] << endl;
cout << "2\t" << types[2] << endl;
cout << "3\t" << types[3] << endl;
cout << "4\t" << types[4] << endl;
cout << "unknown\t" << types[5] << endl;
cout << "bigblock\t" << bigblock << endl;
return 0;
}
/*
int main(int argc, char * argv[]) {
deque<Line> block;
Line line, lastline;
cin >> line.count >> line.idx >> line.h1 >> line.h2;
lastline = line;
block.push_back(line);
while (cin >> line.count >> line.idx >> line.h1 >> line.h2) {
if (lastline.idx == line.idx) {
block.push_back(line);
} else {
process_block(block);
block.clear();
block.push_back(line);
}
lastline = line;
}
process_block(block);
cout << "0\t" << types[0] << endl;
cout << "1\t" << types[1] << endl;
cout << "2\t" << types[2] << endl;
cout << "3\t" << types[3] << endl;
cout << "4\t" << types[4] << endl;
cout << "bigblcok\t" << bigblock << endl;
return 0;
}
void process_block(deque<Line> & block) {
if (block.size() > 2) {
bigblock++;
return;
}
int type;
if (block[0].h2 == "-1" ) { //type3 or 4
if (block.size() == 1) {
type = 4;
} else {
type = 3;
}
} else if (block.size() == 1) {
if (block[0].h1 == "-1") {
type = 2;
} else {
type = 0;
}
} else if (block[1].count == 1) {
type = 1;
} else {
type = 0;
}
//for (int i = 0; i < block.size(); i++) cout << block[i].count << "\t" << block[i].idx << "\t" << block[i].h1 << "\t" << block[i].h2 << endl; cout << "CAT\t" <<type << endl << endl;
types[type]++;
}
*/
| [
"pashadag@combine-102.biolab.sandbox"
] | pashadag@combine-102.biolab.sandbox |
18f5486fb7c65252ed40428e653d1c29f0bfed46 | d4ff5b85886d7dbd8fc2dd10334a553d5e0e7c5d | /src/core/testing/plg_dialog_test/custom_dialog_model.hpp | a9cc3def93c99a0116c730cae3c01a5500cc305c | [] | permissive | karajensen/wgtf | 8737d41cd936e541554389a901c9fb0da4d3b9c4 | 740397bcfdbc02bc574231579d57d7c9cd5cc26d | refs/heads/master | 2021-01-12T19:02:00.575154 | 2018-05-03T10:03:57 | 2018-05-03T10:03:57 | 127,282,403 | 1 | 0 | BSD-3-Clause | 2018-04-27T08:15:26 | 2018-03-29T11:32:36 | C++ | UTF-8 | C++ | false | false | 1,754 | hpp | #ifndef CUSTOM_REFLECTED_DIALOG_MODEL_HPP
#define CUSTOM_REFLECTED_DIALOG_MODEL_HPP
#include "core_data_model/dialog/reflected_dialog_model.hpp"
namespace wgt
{
/**
* Custom model for a basic dialog
*/
class CustomDialogModel : public DialogModel
{
DECLARE_REFLECTED
public:
const std::string& getChosenOption() const
{
return option_;
}
private:
virtual const char* getUrl() const override
{
return "plg_dialog_test/custom_dialog.qml";
}
virtual void onClose(IDialog::Result result) override
{
DialogModel::onClose(result);
switch (result)
{
case 1:
option_ = "A";
break;
case 2:
option_ = "B";
break;
case 3:
option_ = "C";
break;
}
}
std::string option_;
};
/**
* Custom model for a reflected dialog
*/
template <bool ModifyDataDirectly>
class CustomDialogReflectedModel : public ReflectedDialogModel
{
DECLARE_REFLECTED
public:
CustomDialogReflectedModel() : dataSaved_(false)
{
}
~CustomDialogReflectedModel()
{
}
bool dataSaved() const
{
return dataSaved_;
}
private:
virtual const char* getUrl() const override
{
return "plg_dialog_test/reflected_dialog.qml";
}
virtual void onClose(IDialog::Result result) override
{
ReflectedDialogModel::onClose(result);
dataSaved_ = result == ReflectedDialogModel::SAVE && dataEdited();
}
virtual bool modifyDataDirectly() const override
{
return ModifyDataDirectly;
}
bool dataSaved_;
};
BEGIN_EXPOSE(CustomDialogModel, DialogModel, MetaNone())
END_EXPOSE()
BEGIN_EXPOSE(CustomDialogReflectedModel<true>, ReflectedDialogModel, MetaNone())
END_EXPOSE()
BEGIN_EXPOSE(CustomDialogReflectedModel<false>, ReflectedDialogModel, MetaNone())
END_EXPOSE()
} // end namespace wgt
#endif // CUSTOM_REFLECTED_DIALOG_MODEL_HPP | [
"k_jensen@wargaming.net"
] | k_jensen@wargaming.net |
636c1e03d6104e907013af026c73731575204cdf | 1f40abf77c33ebb9f276f34421ad98e198427186 | /tools/output/stubs/Game/Players/PlayerStatistics_stub.cpp | a314c44cb3d482e02c33f7e12e5ce764bb732ae2 | [] | no_license | fzn7/rts | ff0f1f17bc01fe247ea9e6b761738f390ece112e | b63d3f8a72329ace0058fa821f8dd9a2ece1300d | refs/heads/master | 2021-09-04T14:09:26.159157 | 2018-01-19T09:25:56 | 2018-01-19T09:25:56 | 103,816,815 | 0 | 2 | null | 2018-05-22T10:37:40 | 2017-09-17T09:17:14 | C++ | UTF-8 | C++ | false | false | 630 | cpp | #include <iostream>
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#include "PlayerStatistics.h"
#include "System/Platform/byteorder.h"
CR_BIND(PlayerStatistics, )
CR_REG_METADATA(PlayerStatistics,
(CR_MEMBER(mousePixels),
CR_MEMBER(mouseClicks),
CR_MEMBER(keyPresses),
CR_MEMBER(numCommands),
CR_MEMBER(unitCommands)))
PlayerStatistics::PlayerStatistics()
: TeamControllerStatistics()
, mousePixels(0)
, mouseClicks(0)
, keyPresses(0)
{
//stub method
std::cout << _FUNCTION_ << std::endl;
}
| [
"plotnikov@teamidea.ru"
] | plotnikov@teamidea.ru |
01fe75c638a350454cdb9b4d884ea31185ced7cd | 3c1b5c246994d9a932cac69139b5ca6c538478a4 | /BToDKTo3piK/analysis/dalitzTest.cc | 2123945f4cb257602b2e164a2129c781039a7612 | [] | no_license | roun/scripts | 31dc598b2f56658f8aeb0095a5fc444fe279d08c | 80069ca084306d4bd3002ac1aa02d24e72d3aa4a | refs/heads/master | 2020-04-08T15:04:12.554056 | 2014-03-03T05:42:57 | 2014-03-03T05:42:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,329 | cc | // $Id: dalitzTest.cc,v 1.10 2006/04/28 01:56:00 fwinkl Exp $
// Script to test the daliz integration and boundaries
void dalitzTest(Bool_t boundaryTest = false, Bool_t invert = kFALSE)
{
RooNumIntConfig* cfg = RooAbsReal::defaultIntegratorConfig();
cfg->setEpsAbs(1E-5);
cfg->setEpsRel(1E-5);
cfg->method1D().setLabel("RooSegmentedIntegrator1D");
// RooRealVar m12("m12","",1.5,0,3);
// RooRealVar m13("m13","",1.5,0,3);
/*
//RooRealVar a0("a0","",6.25247e+00);
RooRealVar a0("a0","",0);
// RooRealVar a1("a1","",-1.33799e+01);
RooRealVar a1("a1","",0);
RooRealVar a2("a2","",-1.54353e+01);
RooRealVar a3("a3","",4.42504e+00);
RooRealVar a4("a4","",7.61593e+00);
RooRealVar a5("a5","",8.72822e+00);
RooRealVar a6("a6","",-4.41505e-01);
RooRealVar a7("a7","",-1.23653e+00);
RooRealVar a8("a8","",-1.10855e+00);
// RooRealVar a9("a9","",-2.52116e+00);
RooRealVar a9("a9","",0);
*/
RooRealVar a0("a0","",1);
RooRealVar a1("a1","",0);
RooRealVar a2("a2","",0);
RooRealVar a3("a3","",0);
RooRealVar a4("a4","",0);
RooRealVar a5("a5","",0);
RooRealVar a6("a6","",0);
RooRealVar a7("a7","",0);
RooRealVar a8("a8","",0);
RooRealVar a9("a9","",0);
RooRealVar *a[10] = {&a0,&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9};
// Need three pdfs here since RooFit caches the normalization
BdkPdf2DpolyDalitz pdf("pdf","",*s12,*s13,1,a);
BdkPdf2DpolyDalitz pdf2("pdf","",*s12,*s13,1,a);
BdkPdf2DpolyDalitz pdf3("pdf","",*s12,*s13,1,a);
RooAbsPdf::verboseEval(0);
/*
for (int i = 0;i<100;i++) {
*s13.setVal(3.0/100*i);
cout << "Value of PDF at "<< *s13.getVal()<<" "<<*s12.getVal()<<" "<< pdf.getPdf()->getVal()<<endl;
}
RooDataSet *data = pdf.generate(500);
pdf.getPdf()->forceNumInt();
pdf.getPdf()->verboseEval(0);
RooPlot *plot = *s12.frame();
data->plotOn(plot);
pdf.getPdf()->plotOn(plot);
plot->Draw();
*/
// Pure numerical integration
pdf2.getPdf()->forceNumInt();
pdf2.getPdf()->setIntegratorConfig(*cfg);
Double_t num1 = pdf2.getPdf()->getNorm(&RooArgSet(*s12));
Double_t num2 = pdf2.getPdf()->getNorm(&RooArgSet(*s13));
Double_t num3 = pdf2.getPdf()->getNorm(&RooArgSet(*s12,*s13));
cout << "numerical int over m12 "<<num1<<endl;
cout << "numerical int over m13 "<<num2<<endl;
cout << "numerical int over both "<<num3<<endl;
// Pure analytical integration
((Bdk2DpolyDalitz*)pdf3.getPdf())->customInt(1);
Double_t ana1 = pdf3.getPdf()->getNorm(&RooArgSet(*s12,*s13));
cout << "analytical int over both " << ana1 <<endl;
// Hybrid integrations
RooAbsPdf::verboseEval(0);
//pdf.setM23VetoMass(0.4,0.401);
Double_t custom1 = pdf.getPdf()->getNorm(&RooArgSet(*s12));
Double_t custom2 = pdf.getPdf()->getNorm(&RooArgSet(*s13));
Double_t custom3 = pdf.getPdf()->getNorm(&RooArgSet(*s12,*s13));
cout << "custom int over m12 " << custom1 <<endl;
cout << "custom int over m13 " << custom2 <<endl;
cout << "custom int over both " << custom3 <<endl;
//((BdkDalitzBase*)pdf.getPdf())->setMasses(2,0.1,0.2,0.4);
if (boundaryTest) {
const int POINTS = 3000;
RooAbsPdf::verboseEval(0);
gStyle->SetOptStat(0);
TCanvas *c = new TCanvas("c","dalitzTest",600,600);
TGraph* g2 = new TGraph(POINTS);
// This tests the drawBoundary method
TGraph *g = ((BdkDalitzBase*)pdf.getPdf())->drawBoundary(1000);
if (invert) {
g->SetLineColor(kBlue);
g->SetLineWidth(2);
}
else {
g->SetLineColor(kRed);
g->SetLineWidth(1);
}
int p = 0;
// This tests the inDalitz method
for (Double_t x=0;x<=3;x+=(3.0/POINTS)) {
for (Double_t y=0;y<=3;y+=(3.0/POINTS)) {
if (invert) {
if (((BdkDalitzBase*)pdf.getPdf())->inM23Veto(x,y) &&
((BdkDalitzBase*)pdf.getPdf())->inDalitzBounds(x,y))
g2->SetPoint(p++,x,y);
}
else {
if (((BdkDalitzBase*)pdf.getPdf())->inDalitz(x,y))
g2->SetPoint(p++,x,y);
}
}
}
g2->SetMarkerColor(kBlue);
g2->SetMarkerStyle(20);
g2->SetMarkerSize(0.1);
g->Draw("ac");
g2->Draw("p same");
g->GetXaxis()->SetTitle(m12->GetTitle());
g->GetYaxis()->SetTitle(m13->GetTitle());
g->SetTitle("");
c->Update();
c->SaveAs("dalitzTest.eps");
}
}
| [
"kalanand@gmail.com"
] | kalanand@gmail.com |
42e1b4ecc7ead9e6f6f614590cf72033619b0a91 | 46979fcfde19382dbdf290cc516436a4ec0ddb04 | /DoubleListNode.h | d2483f0fb6799eaf4efce172d3c8fd40b0ccf816 | [] | no_license | cs2100-utec-aed-2019ii/cs2100-listas-ga | d391cf55d025129029d5d2c9058d15d0d76dc5c1 | b70d9f4f8a6c7f0e25e5f8b75547d0f10fe6e155 | refs/heads/master | 2020-07-13T07:18:59.383924 | 2019-09-19T04:20:17 | 2019-09-19T04:20:17 | 205,030,445 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 299 | h | #ifndef DOUBLELISTNODE_H
#define DOUBLELISTNODE_H
template <typename T>
class DoubleListNode : public Node<T>{
protected:
Node<T> * next;
Node<T> * prev;
public:
DoubleListNode(void){
}
~DoubleListNode(void){
}
};
#endif
| [
"alejandrogoicochea@gmail.com"
] | alejandrogoicochea@gmail.com |
a5bb74cc84756cddfbad45af4ed3bba52d13ade7 | ab25bd1d3cf197c6323bc73321cc7becc8ddf1c9 | /src/ofApp.h | 022623f49dfe3b59b6a64252374821c7546644af | [] | no_license | wilcotomassen/ofGlsl | 4635b9e97043b55e0b3c38f51e51cd12ff1b4df4 | 2f8d4e07b0723f1ecbba28767bedbcac9acbf8b5 | refs/heads/master | 2020-03-21T04:56:06.467994 | 2018-06-21T13:39:40 | 2018-06-21T13:39:40 | 138,135,014 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 159 | h | #pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
private:
ofShader shader;
};
| [
"wilco@cleverfranke.com"
] | wilco@cleverfranke.com |
5caff2abc1c65a2e2c9db476854d1fb900fb0b7d | a3264571df4f5cd24008c9a274a4ab3ef54d6f5f | /lit_tests/TestCases/strncpy-overflow.cc | 5b89dadd6e542aa265613c59ce1d5337a5ebea4a | [] | no_license | hellok/address-sanitizer | 3ead6ceed49247d0c517a68ec8192bf8439c9f89 | c687d3f6f5ab7717400ee3637d2a4f9eb3c7378e | refs/heads/master | 2020-04-05T23:32:48.966698 | 2013-11-15T10:24:36 | 2013-11-15T10:24:36 | 13,957,312 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,410 | cc | // RUN: %clangxx_asan -O0 %s -o %t && not %t 2>%t.out
// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-%os < %t.out
// RUN: %clangxx_asan -O1 %s -o %t && not %t 2>%t.out
// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-%os < %t.out
// RUN: %clangxx_asan -O2 %s -o %t && not %t 2>%t.out
// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-%os < %t.out
// RUN: %clangxx_asan -O3 %s -o %t && not %t 2>%t.out
// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-%os < %t.out
// REQUIRES: compiler-rt-optimized
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv) {
char *hello = (char*)malloc(6);
strcpy(hello, "hello");
char *short_buffer = (char*)malloc(9);
strncpy(short_buffer, hello, 10); // BOOM
// CHECK: {{WRITE of size 10 at 0x.* thread T0}}
// CHECK-Linux: {{ #0 0x.* in .*strncpy}}
// CHECK-Darwin: {{ #0 0x.* in wrap_strncpy}}
// CHECK: {{ #1 0x.* in main .*strncpy-overflow.cc:}}[[@LINE-4]]
// CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}}
// CHECK: {{allocated by thread T0 here:}}
// CHECK-Linux: {{ #0 0x.* in .*malloc}}
// CHECK-Linux: {{ #1 0x.* in main .*strncpy-overflow.cc:}}[[@LINE-10]]
// CHECK-Darwin: {{ #0 0x.* in wrap_malloc.*}}
// CHECK-Darwin: {{ #1 0x.* in main .*strncpy-overflow.cc:}}[[@LINE-13]]
return short_buffer[8];
}
| [
"warptencq@gmail.com"
] | warptencq@gmail.com |
10360970c6072e39de44166ffbc0d1a0fec1dad0 | 211962006bed20ffb54c1060c7c5c1279414dbd3 | /BRICK BREAKER/Paddle.h | 67a2a14da9e9f62235dd089006ff9e800f5b8201 | [] | no_license | davidmelvin/Brick-Breaker | 1b9f9ad23714bcfb5f3f388e82320f9fd5de7e87 | 7771a7d872aa9b1f2f7cbff42b798f02760c1324 | refs/heads/master | 2020-12-31T02:43:28.832928 | 2013-10-23T02:58:56 | 2013-10-23T02:58:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 302 | h | #ifndef PADDLE_H
#define PADDLE_H
#include "Include.h"
using namespace std;
class Paddle
{
private:
ALLEGRO_BITMAP *image;
int posX, posY, height, width;
public:
void move(int,int);
void collision();
void draw();
void checkspace();
Paddle(string, int, int, int, int);
~Paddle();
};
#endif
| [
"vivekjain03@gmail.com"
] | vivekjain03@gmail.com |
ddc6b576dcdd92f4cfa84ccb3ebdfabcfa029bff | b73b04e269d3c8d23a4e378832e502997f017c6d | /GEENIE/inspectorwidget.h | 79c782b91c50ceb99dc48aeadfb4ed39d8d47d7c | [] | no_license | SoftwareprojektGameEngine/GEENIE | 5775bcd068f70b907c46af4fd70d2d0639029c1c | 8eaf5b16303aeb7fddb001b94dbee133fbd5ed37 | refs/heads/master | 2021-01-17T13:03:27.200212 | 2016-06-03T13:28:32 | 2016-06-03T13:28:32 | 57,308,147 | 9 | 3 | null | 2016-06-03T13:28:33 | 2016-04-28T14:27:40 | C++ | UTF-8 | C++ | false | false | 451 | h | #ifndef INSPECTORWIDGET_H
#define INSPECTORWIDGET_H
#include <QWidget>
namespace Ui {
class InspectorWidget;
}
class InspectorWidget : public QWidget
{
Q_OBJECT
public:
explicit InspectorWidget(QWidget *parent = 0);
~InspectorWidget();
void addWidget(QWidget* widget);
void removeWidget(QWidget* widget);
public slots:
void resizeSlot(int h, int w);
private:
Ui::InspectorWidget *ui;
};
#endif // INSPECTORWIDGET_H
| [
"artem.dontsov@tu-ilmenau.de"
] | artem.dontsov@tu-ilmenau.de |
29565ca11b3c095b6122a3f1bdc1517db1d7eddb | c507b4a07636ea09314e8f4b6d0e9f54fbd8e0b8 | /ISI/D02 – Introduction to structured programming (C) - WEB1909B - M.St-Germain/ClassWork/OnSiteWork/Pre_Post_Increment.cpp | 5bbdf38ddd44f34653c9f03772de3b89a1b51142 | [] | no_license | Binarianz/Dataons | d4937ddbdef6333c5f924542d2e8350e5890362d | f519700c1276fd3fefdfdf6b19fac1dfb6e91afe | refs/heads/master | 2023-05-12T14:20:55.607324 | 2020-08-26T07:53:35 | 2020-08-26T07:53:35 | 223,552,008 | 0 | 0 | null | 2023-05-07T09:48:51 | 2019-11-23T07:51:18 | Python | UTF-8 | C++ | false | false | 320 | cpp | #include <iostream>
using namespace std;
int main()
{
int value = 5, result;
result = ++value + 5;
cout << "PRE-INCREMENT\n";
cout << result << endl;
cout << value << endl
<< endl;
cout << "POST-INCREMENT\n";
result = value++ + 5;
cout << result << endl;
cout << value << endl;
system("pause");
return 0;
} | [
"jemmanue@isimtl.local"
] | jemmanue@isimtl.local |
cc1f5e2dc4c71aff0e3dc31ca9b32ab472bbeb33 | 5c751e00a88389c0a9f77243374f9da89bfe3b51 | /cpp/day28_regexpatternsanddatabases.cpp | bfb15dd23f4335c37e8a13fa9d6b899f79e33dba | [] | no_license | analyticalmonk/hackerrank_30daysofcode | 92868f3dd251b124519660e3a34d5f7a0c3d1892 | 4c0d9f85c9640e6981fa1bff99672b768df9576c | refs/heads/master | 2020-04-15T06:53:18.827568 | 2016-06-24T09:02:27 | 2016-06-24T09:02:27 | 60,090,089 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 566 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N;
string first_name, email_id;
vector<string> gmail_names;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> first_name >> email_id;
if (email_id.find("@gmail.com") != string::npos) {
gmail_names.push_back(first_name);
}
}
if (gmail_names.size() > 0) {
sort(begin(gmail_names), end(gmail_names));
for (int i = 0; i < (int)gmail_names.size(); i++) {
cout << gmail_names[i] << endl;
}
}
return 0;
}
| [
"akashtndn.acm@gmail.com"
] | akashtndn.acm@gmail.com |
b2370962a2177d56eacd96bbafc4a7e9c50d3205 | e47a5b8b36761f288c5c7738bb5a1e820985230c | /Sakshi Mishra/Assignment 0/if-else/letter.cpp | c76d52d07650fab2ccf3b0460c08617976d74a08 | [] | no_license | codedazzlers/DSA-Bootcamps | 3a03e64c2514a3c4183b1c57b301a0827e96301a | f5a47dca998449e075f37b8bb4d075f6660bb083 | refs/heads/main | 2023-08-28T09:52:09.732810 | 2021-11-06T11:52:47 | 2021-11-06T11:52:47 | 408,450,942 | 13 | 66 | null | 2021-11-06T11:52:48 | 2021-09-20T13:18:44 | C++ | UTF-8 | C++ | false | false | 256 | cpp | #include <iostream>
using namespace std;
int main(){
char letter;
cout<<"Enter a letter";
cin>>letter;
if(letter>=97 && 122>=letter){
cout<<"lowercase letter";
}
else{
cout<<"Uppercase letter";
}
return 0;
} | [
"sakshimishra577.hitece2020@gmail.com"
] | sakshimishra577.hitece2020@gmail.com |
e62f1520ed536191ed80d3447b0b4ccfbf0872ac | 293279d940b97ad5a2b98f27d2fe8368f7a7f50c | /gammaee/mcsuper/src/EvtGenModels/EvtGenModels/EvtPythia.hh | 24d5aa6021fe4d6d300ea18fea6e1d9257373241 | [] | no_license | jpivarski-talks/1999-2006_gradschool-1 | 51a59a9d262a34d4d613d84bd6a78a0e2675db06 | 11abf09e8dc3b901627e9a7349d9c98bea250647 | refs/heads/master | 2022-11-19T12:16:19.477335 | 2020-07-25T01:18:29 | 2020-07-25T01:18:29 | 282,235,487 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,157 | hh | //--------------------------------------------------------------------------
//
// Environment:
// This software is part of the EvtGen package developed jointly
// for the BaBar and CLEO collaborations. If you use all or part
// of it, please give an appropriate acknowledgement.
//
// Copyright Information: See BelEvtGen/COPYRIGHT
// Copyright (C) 1998 Caltech, UCSB
//
// Module: BelEvtGen/EvtJetSet.hh
//
// Description:
//
// Modification history:
//
// DJL/RYD August 11, 1998 Module created
// RS October 28, 2002 copied from JETSET module
//
//------------------------------------------------------------------------
#ifndef EVTPYTHIA_HH
#define EVTPYTHIA_HH
#include "EvtGenBase/EvtDecayIncoherent.hh"
#include "EvtGenBase/EvtParticle.hh"
#include <string>
class ofstream;
typedef EvtDecayBase* EvtDecayBasePtr;
class EvtPythia:public EvtDecayIncoherent {
public:
EvtPythia();
virtual ~EvtPythia();
void getName(std::string& name);
EvtDecayBase* clone();
void decay(EvtParticle *p);
std::string commandName();
void command(std::string cmd);
void init();
void initProbMax();
//initialize jetset; sets up decay table and
//paramters. Static so it can be invoked from
//from EvtJscont.
static void pythiaInit(int f);
static void pythiacont(double *,int *, int *,
double *,double *,double *,double *);
private:
void store(EvtDecayBase* jsdecay);
void fixPolarizations(EvtParticle* p);
static void MakePythiaFile(char* fname);
static void WritePythiaParticle(std::ofstream &outdec,EvtId ipar,EvtId iparname,int &first);
static void WritePythiaEntryHeader(std::ofstream &outdec, int lundkc,
EvtId evtnum,std::string name,
int chg, int cchg, int spin2,double mass,
double width, double maxwidth,double ctau,
int stable,double rawbrfrsum);
static bool diquark(int);
static double NominalMass(int);
static int njetsetdecays;
static EvtDecayBasePtr* jetsetdecays;
static int ntable;
static int ncommand;
static int lcommand;
static std::string* commands;
};
#endif
| [
"jpivarski@gmail.com"
] | jpivarski@gmail.com |
2ed7cfb43b6b355aada7338acfdea4a03c9c38d5 | c5d89945a24d5ec1a363d77b7e4f24848bd5bcc2 | /opencv32/opencv32/test.cpp | 63221639b087a0b8f2a8f9227f4054c7bda7c03a | [
"MIT"
] | permissive | Akshaybj0221/ENPM808X_Midterm | ecdf6760f1360256ae8b7f9ca8fc826ee8e53d27 | e5282b6055fa9f2b724f39a82e77ed5ab556bdbb | refs/heads/master | 2021-07-12T20:20:34.122803 | 2017-10-18T05:34:27 | 2017-10-18T05:34:27 | 106,374,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,696 | cpp | /****************************************************************************************
* * * *
* *
* MIT License *
* *
* Copyright (c) [2017] [Akshay Bajaj] *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy *
* of this software and associated documentation files (the "Software"), to deal *
* in the Software without restriction, including without limitation the rights *
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in all *
* copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
* SOFTWARE. *
* *
****************************************************************************************/
/** @file test.cpp
* @brief Implementation of unit test for Motion Tracker
*
* This file contains implementation of unit test for
* MotionTracker.
*
* @author Akshay Bajaj
* @date 2017/10/10
*/
/*
#include <gtest/gtest.h>
#include "MotionTracker.h"
/**
* @brief Test the getVideo parameter function of
* MotionTracker
*
* @param none
* @return get
*/
/*
TEST(testGetVideoreturnValue, should_not_be_null) {
MotionTracker mt;
VideoCapture val = mt.getVideo();
val = 0;
ASSERT_TRUE(val = 0);
}
*/
/**
* @brief Test the Processing parameter function of
* MotionTracker
*
* @param capture, frame1, frame2
* @return thresholdImage
*/
/*
TEST(testProcessing, return_value_notNull) {
MotionTracker mt;
VideoCapture capture;
Mat frame1;
Mat frame2;
Mat val;
val = mt.Processing(capture, frame1, frame2);
ASSERT_TRUE(val > 0);
} */ | [
"akshaybj0221@gmail.com"
] | akshaybj0221@gmail.com |
d8f86b0852038b461655810fb49681b7918f3df5 | 407707d8e5065e162627164593e4b7f753adc6f7 | /Canny/Canny.cpp | 185479f340ccd0a5ad7ae6ebb713e6647db9b7d8 | [] | no_license | Andromeda2333/ImageProcessing | 5cf7ce1c9160bac4d15dfc0c83be0961af0e7962 | 8000384233dfe066dbe0b127ae7de43151e4c025 | refs/heads/master | 2020-05-04T19:28:13.522050 | 2015-10-22T17:03:49 | 2015-10-22T17:03:49 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,092 | cpp | // Canny.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <string>
#include <iostream>
cv::Mat src,dst,srcGray,detectedEdges;
int kernelSize=3;
int lowThreshold;
int const maxThreshold=100;
std::string windowName="±ßԵͼÏñ";
void CannyThreshold(int,void*);
int _tmain(int argc, _TCHAR* argv[])
{
src=cv::imread("image.jpg");
if (!src.data)
{
std::cerr<<"error!!\n";
}
cv::cvtColor(src,srcGray,CV_RGB2GRAY);
dst.create(srcGray.size(),srcGray.type());
cv::namedWindow(windowName,CV_WINDOW_AUTOSIZE);
cv::createTrackbar("Min threshold:",windowName,&lowThreshold,
maxThreshold,CannyThreshold);
CannyThreshold(0,0);
cv::waitKey();
return 0;
}
void CannyThreshold( int,void* )
{
cv::blur(srcGray,detectedEdges,cv::Size(kernelSize,kernelSize));
cv::Canny(detectedEdges,detectedEdges,lowThreshold,3*lowThreshold,kernelSize);
dst=cv::Scalar::all(0);
src.copyTo(dst,detectedEdges);
cv::imshow(windowName,dst);
}
| [
"zcc136314853@hotmail.com"
] | zcc136314853@hotmail.com |
e88413c2c165ef356cc8125c718d55b4d39ccd7b | 137fb1dffbf1e7e8331fa05c3238c213c89dee5a | /source/Communications/SysMsgSender.cpp | 28d0716fef37acf65671896931533fb5025e4083 | [] | no_license | sky13121501531/ANBO-souce | a09cd063b73be26c02ac53118845aaef8de77d99 | 4d13e62d19f3bb7035ef167d01246b7ea0384d0d | refs/heads/master | 2020-08-31T12:00:24.591290 | 2020-03-20T06:53:26 | 2020-03-20T06:53:26 | 216,489,538 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,167 | cpp |
#include "SysMsgSender.h"
#include "../Foundation/OSFunction.h"
#include "../Foundation/AppLog.h"
SysMsgSender::SysMsgSender()
{
bFlag = false;
bSendFlag =true;
Print_Level = 0;
WriteLog_Level = 0;
//string RemoteIP = "225.1.1.10";
//int RemotePort = 30000;
//RemoteAddr.set(htons(RemotePort),inet_addr(RemoteIP.c_str()),0,0);
//LocalAddr.set_port_number((u_short)0);
//MsgSender.open(LocalAddr);
}
SysMsgSender::~SysMsgSender()
{
MsgSender.close();
}
int SysMsgSender::open(void*)
{
//启动线程
this->activate();
return 0;
}
int SysMsgSender::Start()
{
bFlag = true;
this->open(0);
return 0;
}
int SysMsgSender::svc()
{
ACE_DEBUG ((LM_DEBUG,"(%T | %t)系统信息发送线程开始执行 !\n"));
ACE_Message_Block *mb = 0;
ACE_Time_Value OutTime(ACE_OS::gettimeofday()+ACE_Time_Value(2));
ACE_Time_Value SendOutTime(0,30);
while (bFlag)
{
OSFunction::Sleep(0,100);
try
{
//if (getq(mb,&OutTime) != -1 && mb != NULL)
//{
// MsgSender.send(mb->rd_ptr(),mb->length(),RemoteAddr,0,&SendOutTime);//发送数据
// mb->release();
//}
}
catch (...)
{
ACE_DEBUG ((LM_DEBUG,"(%T | %t)系统信息发送异常 !\n"));
}
}
bFlag = false;
ACE_DEBUG ((LM_DEBUG,"(%T | %t)系统信息发送线程停止执行 !\n"));
return 0;
}
bool SysMsgSender::SendMsg(std::string msg,enumDVBType DVBType,enumSysMsgType sysmsgtype,eModuleType Module,eLogType LogType,bool forceprint,bool forcelog)
{
if (msg.empty())
return false;
if (bSendFlag == false)
return true;
//控制台输出
if ((forceprint == true) || (Print_Level==0 && sysmsgtype == VS_MSG_SYSALARM) || \
(Print_Level==1 && (sysmsgtype == VS_MSG_SYSALARM || sysmsgtype == VS_MSG_PROALARM)) || \
(Print_Level==2))
{
ACE_DEBUG ((LM_DEBUG,"(%T | %t)%s\n",msg.c_str()));
}
//写日志
if ((forcelog == true) || (WriteLog_Level==0 && sysmsgtype == VS_MSG_SYSALARM) || \
(WriteLog_Level==1 && (sysmsgtype == VS_MSG_SYSALARM || sysmsgtype == VS_MSG_PROALARM)) || \
(WriteLog_Level==2))
{
APPLOG::instance()->WriteLog(Module,LogType,msg,LOG_OUTPUT_FILE);
}
//组播数据
//std::string strmsgtype = "VS_MSG_SYSTINFO";
//switch (sysmsgtype)
//{
//case VS_MSG_SYSTINFO:
// strmsgtype = "VS_MSG_SYSTINFO";
// break;
//case VS_MSG_PROALARM:
// strmsgtype = "VS_MSG_PROALARM";
// break;
//case VS_MSG_SYSALARM:
// strmsgtype = "VS_MSG_SYSALARM";
// break;
//default:
// strmsgtype = "VS_MSG_SYSTINFO";
// break;
//}
//
//std::string strdvbtype = OSFunction::GetStrDVBType(DVBType);
//if (strdvbtype == "UNKNOWN")
//{
// strdvbtype = "SYSTEM";
//}
//string sysinfo = std::string("[") + strmsgtype + std::string("] ") + std::string("[") + strdvbtype + std::string("] ") + msg;
//ACE_Time_Value OutTime(ACE_OS::gettimeofday()+ACE_Time_Value(2));
//ACE_Message_Block *mb = new ACE_Message_Block(sysinfo.length()+1);
//memcpy(mb->wr_ptr(),sysinfo.c_str(),sysinfo.length());
//mb->wr_ptr(sysinfo.length());
//this->putq(mb,&OutTime);
return true;
}
bool SysMsgSender::SetSendFlag(bool flag)
{
bSendFlag = flag;
return true;
}
int SysMsgSender::Stop()
{
bFlag = false;
this->wait();
return 0;
} | [
"sky13121501531@163.com"
] | sky13121501531@163.com |
2d69c72d8f8d940c3b40ae5e5574546e1ba4cc77 | 76f0efb245ff0013e0428ee7636e72dc288832ab | /out/Default/gen/services/shell/public/interfaces/service.mojom.h | 199074dc3810bc96e073db65e9358bd6195262ec | [] | no_license | dckristiono/chromium | e8845d2a8754f39e0ca1d3d3d44d01231957367c | 8ad7c1bd5778bfda3347cf6b30ef60d3e4d7c0b9 | refs/heads/master | 2020-04-22T02:34:41.775069 | 2016-08-24T14:05:09 | 2016-08-24T14:05:09 | 66,465,243 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,296 | h | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_SHELL_PUBLIC_INTERFACES_SERVICE_MOJOM_H_
#define SERVICES_SHELL_PUBLIC_INTERFACES_SERVICE_MOJOM_H_
#include <stdint.h>
#include <type_traits>
#include <utility>
#include "base/callback.h"
#include "base/optional.h"
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/union_accessor.h"
#include "mojo/public/cpp/bindings/map.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/message_filter.h"
#include "mojo/public/cpp/bindings/native_struct.h"
#include "mojo/public/cpp/bindings/native_struct_data_view.h"
#include "mojo/public/cpp/bindings/no_interface.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "services/shell/public/interfaces/service.mojom-shared.h"
#include "services/shell/public/interfaces/capabilities.mojom.h"
#include "services/shell/public/interfaces/connector.mojom.h"
#include "services/shell/public/interfaces/interface_provider.mojom.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/string.h"
#include "services/shell/public/cpp/capabilities.h"
#include "services/shell/public/cpp/identity.h"
#include "base/values.h"
#include "base/version.h"
#include "base/time/time.h"
#include "base/strings/string16.h"
#include "base/files/file_path.h"
namespace shell {
namespace mojom {
class Service;
using ServicePtr = mojo::InterfacePtr<Service>;
using ServicePtrInfo = mojo::InterfacePtrInfo<Service>;
using ServiceRequest = mojo::InterfaceRequest<Service>;
using ServiceAssociatedPtr =
mojo::AssociatedInterfacePtr<Service>;
using ServiceAssociatedPtrInfo =
mojo::AssociatedInterfacePtrInfo<Service>;
using ServiceAssociatedRequest =
mojo::AssociatedInterfaceRequest<Service>;
class ServiceProxy;
class ServiceStub;
class ServiceRequestValidator;
class ServiceResponseValidator;
class Service {
public:
static const char Name_[];
static const uint32_t Version_ = 0;
static const bool PassesAssociatedKinds_ = false;
static const bool HasSyncMethods_ = false;
using Proxy_ = ServiceProxy;
using Stub_ = ServiceStub;
using RequestValidator_ = ServiceRequestValidator;
using ResponseValidator_ = ServiceResponseValidator;
virtual ~Service() {}
using OnStartCallback = base::Callback<void(::shell::mojom::ConnectorRequest)>;
virtual void OnStart(const ::shell::Identity& identity, const OnStartCallback& callback) = 0;
virtual void OnConnect(const ::shell::Identity& source, ::shell::mojom::InterfaceProviderRequest interfaces, const ::shell::CapabilityRequest& allowed_capabilities) = 0;
};
class ServiceProxy
: public Service,
public NON_EXPORTED_BASE(mojo::internal::ControlMessageProxy) {
public:
explicit ServiceProxy(mojo::MessageReceiverWithResponder* receiver);
void OnStart(const ::shell::Identity& identity, const OnStartCallback& callback) override;
void OnConnect(const ::shell::Identity& source, ::shell::mojom::InterfaceProviderRequest interfaces, const ::shell::CapabilityRequest& allowed_capabilities) override;
mojo::internal::SerializationContext* serialization_context() {
return &serialization_context_;
}
private:
mojo::internal::SerializationContext serialization_context_;
};
class ServiceStub : public NON_EXPORTED_BASE(mojo::MessageReceiverWithResponderStatus) {
public:
ServiceStub();
~ServiceStub() override;
void set_sink(Service* sink) { sink_ = sink; }
Service* sink() { return sink_; }
mojo::internal::SerializationContext* serialization_context() {
return &serialization_context_;
}
bool Accept(mojo::Message* message) override;
bool AcceptWithResponder(mojo::Message* message,
mojo::MessageReceiverWithStatus* responder) override;
private:
Service* sink_;
mojo::internal::SerializationContext serialization_context_;
mojo::internal::ControlMessageHandler control_message_handler_;
};
class ServiceRequestValidator : public NON_EXPORTED_BASE(mojo::MessageFilter) {
public:
explicit ServiceRequestValidator(mojo::MessageReceiver* sink = nullptr);
bool Accept(mojo::Message* message) override;
};
class ServiceResponseValidator : public NON_EXPORTED_BASE(mojo::MessageFilter) {
public:
explicit ServiceResponseValidator(mojo::MessageReceiver* sink = nullptr);
bool Accept(mojo::Message* message) override;
};
} // namespace mojom
} // namespace shell
namespace mojo {
} // namespace mojo
#endif // SERVICES_SHELL_PUBLIC_INTERFACES_SERVICE_MOJOM_H_ | [
"dckristiono@gmail.com"
] | dckristiono@gmail.com |
09fad990ac76b7682b22442841307059661b5fe5 | 9f616812b68bb039d366a0452e6194e8d3f5180b | /Darknet_YOLO_Streamer/Darknet_YOLO_Streamer.cpp | f676cb8c2b34d1a43ced5584faa9556681220f2e | [] | no_license | jjhartmann/Darknet-Yolo-Streamer | 62bf221d2e950ee6a808c31a4aaedc7045589696 | 916f5aabe36ad96462d11d80e33e9788acafd891 | refs/heads/master | 2020-03-11T15:36:35.148209 | 2018-04-12T22:07:06 | 2018-04-12T22:07:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,048 | cpp | // Darknet_YOLO_Streamer.cpp : Defines the entry point for the console application.
//
#pragma once
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <fstream>
#include "stdafx.h"
#define OPENCV
// OpenCV
#include <opencv2/opencv.hpp> // C++
#include "opencv2/highgui/highgui_c.h" // C
#include "opencv2/imgproc/imgproc_c.h" // C
// Yolo
#include "yolo_v2_class.hpp" // imported functions from DLL
// Load OpenCV Libs
#pragma comment(lib, "opencv_core2413.lib")
#pragma comment(lib, "opencv_imgproc2413.lib")
#pragma comment(lib, "opencv_highgui2413.lib")
// TCPClient
#include "TCPClient.h"
#define UNITY_YOLO_STREAM_IP "192.168.137.1"
#define UNITY_YOLO_STREAM_PORT "10045"
// YOLO Stream to Unity
TCPClient *UnityYoloStream;
#ifdef _WIN32
#include <windows.h>
void sleep(unsigned milliseconds)
{
Sleep(milliseconds);
}
#else
#include <unistd.h>
void sleep(unsigned milliseconds)
{
usleep(milliseconds * 1000); // takes microseconds
}
#endif
void draw_boxes(cv::Mat mat_img, std::vector<bbox_t> result_vec, std::vector<std::string> obj_names, unsigned int wait_msec = 0) {
int iter = 0;
for (auto &i : result_vec) {
cv::Scalar color(60 + (iter * 10), 160 + (iter * 5), 260 - (iter * 20));
cv::rectangle(mat_img, cv::Rect(i.x, i.y, i.w, i.h), color, 3);
if (obj_names.size() > i.obj_id)
putText(mat_img, obj_names[i.obj_id], cv::Point2f(i.x, i.y - 10), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, color);
if (i.track_id > 0)
putText(mat_img, std::to_string(i.track_id), cv::Point2f(i.x + 5, i.y + 15), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, color);
iter++;
}
cv::imshow("window name", mat_img);
//cv::waitKey(wait_msec);
}
void show_result(std::vector<bbox_t> const result_vec, std::vector<std::string> const obj_names) {
for (auto &i : result_vec) {
if (obj_names.size() > i.obj_id) std::cout << obj_names[i.obj_id] << " - ";
std::cout << "obj_id = " << i.obj_id << ", x = " << i.x << ", y = " << i.y
<< ", w = " << i.w << ", h = " << i.h
<< std::setprecision(3) << ", prob = " << i.prob << std::endl;
}
}
std::vector<std::string> objects_names_from_file(std::string const filename) {
std::ifstream file(filename);
std::vector<std::string> file_lines;
if (!file.is_open()) return file_lines;
for (std::string line; file >> line;) file_lines.push_back(line);
std::cout << "object names loaded \n";
return file_lines;
}
int main(int argc, const char* argv[])
{
std::string config = "";
std::string weights = "";
std::string cocodataset = "";
if (argc < 3)
{
config = "yolo-voc.cfg";
weights = "yolo-voc.weights";
cocodataset = "voc.names";
std::cout << "Not enough arguments" << std::endl;
}
else
{
cocodataset = argv[3];
config = argv[1];
weights = argv[2];
}
// Init TCP Cleint
UnityYoloStream = new TCPClient(UNITY_YOLO_STREAM_IP, UNITY_YOLO_STREAM_PORT, "unity_yolo_stream");
// Setup
std::cout << "Before Detector" << std::endl;
Detector detector(config, weights);
std::cout << "After Detector" << std::endl;
auto obj_names = objects_names_from_file(cocodataset);
cv::VideoCapture cap;
cap.open(0);
//cap.set(CV_CAP_PROP_FPS, 20);
cv::Mat frame;
while (cap.isOpened() && cap.read(frame))
{
//std::cout << "input image or video filename: ";
//std::string filename = "D:\\GIT_DIR\\ANDROID_EVERYWHERE_PROJECTS\\Darknet_YOLO_Streamer\\config\\data\\dog.jpg";
//std::cin >> filename;
//if (filename.size() == 0) break;
//try {
// std::string const file_ext = filename.substr(filename.find_last_of(".") + 1);
// if (file_ext == "avi" || file_ext == "mp4" || file_ext == "mjpg" || file_ext == "mov") { // video file
// cv::Mat frame;
// detector.nms = 0.02; // comment it - if track_id is not required
// for (cv::VideoCapture cap(filename); cap >> frame, cap.isOpened();) {
// std::vector<bbox_t> result_vec = detector.detect(frame, 0.2);
// result_vec = detector.tracking(result_vec); // comment it - if track_id is not required
// draw_boxes(frame, result_vec, obj_names, 3);
// show_result(result_vec, obj_names);
// }
// }
// else { // image file
// std::cout << filename << std::endl;
// cv::Mat mat_img = cv::imread(filename);
// std::vector<bbox_t> result_vec = detector.detect(mat_img);
// draw_boxes(mat_img, result_vec, obj_names);
// show_result(result_vec, obj_names);
// }
//
//}
//catch (std::exception &e) { std::cerr << "exception: " << e.what() << "\n"; getchar(); }
//catch (...) { std::cerr << "unknown exception \n"; getchar(); }
try {
detector.nms = 0.4;// 0.02; // comment it - if track_id is not required
std::vector<bbox_t> result_vec = detector.detect(frame, 0.2);
result_vec = detector.tracking(result_vec); // comment it - if track_id is not required
// Send data to Unity
if (UnityYoloStream->IsConnected())
{
UnityYoloStream->SendBoundingBoxDataArray(result_vec);
}
draw_boxes(frame, result_vec, obj_names, 0);
show_result(result_vec, obj_names);
}
catch (std::exception &e) { std::cerr << "exception: " << e.what() << "\n"; getchar(); }
catch (...) { std::cerr << "unknown exception \n"; getchar(); }
if (cv::waitKey(1) == 'q')
{
break;
}
// Articifially Slow down stream
sleep(100);
}
// Delete content
delete UnityYoloStream;
return 0;
}
| [
"jeremy.hartmann@gmail.com"
] | jeremy.hartmann@gmail.com |
2abc6bbe0717df3b7ec01e8a8c012174bb2bb2fa | cb4b9a6f11c9ff5276ce77ba5c48a197dff6d5a0 | /cv_resizing.cpp | 95d896b9725ba292012a08ff48851664811328f2 | [] | no_license | Louisdec/Projet_multimedia | 5dcb81473e8ef6ba73bd7a69b4c1cb94cabaef37 | 384b8b14be34ef5b0346fd960aa1fcdd66ca2e73 | refs/heads/master | 2020-05-20T21:46:27.845233 | 2019-05-16T07:37:43 | 2019-05-16T07:37:43 | 185,769,350 | 0 | 0 | null | 2019-05-09T09:32:40 | 2019-05-09T09:32:40 | null | UTF-8 | C++ | false | false | 977 | cpp | #include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main( int argc, char** argv )
{
Mat image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
Mat new_image;
if (argc < 3 or argc > 4) {
cout << "Wrong number of arguments" << endl;
cout << "Check the manuel with 'man cv_resize' to verify" << endl;
return 0;
}
else if (argc == 3) {
float X = atof(argv[2]);
float xe = image.cols*X;
float ye = image.rows*X;
resize(image, new_image, Size(int(xe),int(ye)));
}
else if (argc == 4) {
int x = strtol(argv[2], nullptr, 0);
int y = strtol(argv[3], nullptr, 0);
resize(image, new_image, Size(x, y));
}
namedWindow( "image originale", WINDOW_AUTOSIZE);
namedWindow( "image modifiée", WINDOW_AUTOSIZE);
//show original and new image
imshow( "image originale", image);
imshow( "image modifiée", new_image);
waitKey();
return 0;
}
| [
"vcharbonnieras@ma-3020-lx"
] | vcharbonnieras@ma-3020-lx |
e29f14a738ea8a854ba1b2bc0d4a27c343fa1209 | 3dd3dd8faf076031d849e3d8fdcda07a00d76f89 | /prismapp/include/prism_gif_reader.h | c3d8f675705fd9b8d34d947e10d4f58031c1dd15 | [] | no_license | o-panel-project/wpcom-selfchecker-armhf | 512f6fe0083765c2cd7da9ff134196374db41725 | 60ebfbbd9f52d4bd695e60e22a4a6f9e8911e576 | refs/heads/master | 2023-01-23T04:53:20.219259 | 2017-05-16T03:06:11 | 2017-05-16T03:06:11 | 91,411,148 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,920 | h | ///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2010 by Blue Water Embedded, Inc.
//
// This software is copyrighted by and is the sole property of Blue Water
// Embedded, Inc. All rights, title, ownership, or other intersts in the
// software remain the property of Blue Water Embedded, Inc. This software
// may only be used in accordance with the corresponding license agreement.
// Any unauthorized use, duplications, transmission, distribution, or
// disclosure of this software is expressly forbidden.
//
// This Copyright notice may not be removed or modified without prior
// written consent of Blue Water Embedded, Inc.
//
// Blue Water Embedded, Inc. reserves the right to modify this software
// without notice.
//
// Blue Water Embedded, Inc. info@bwembedded.com
// 3847 Pine Grove Ave http://www.bwembedded.com
// Suite A
// Fort Gratiot, MI 48059
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// prism_gif_reader.h - Prism GIF file reader class definition
//
// Author: Kenneth G. Maxwell
//
// Revision History:
// Refer to SVN revision history.
//
///////////////////////////////////////////////////////////////////////////////
#ifdef PRISM_RUNTIME_GIF_READER
#ifndef _PRISM_GIF_READER_
#define _PRISM_GIF_READER_
BEGIN_NAMESPACE_PRISM
#define GIF_CODE_STACK_SIZE 1024
#define MAX_LWZ_BITS 12
#define INTERLACE 0x40
#define LOCALCOLORMAP 0x80
#define GIF16(a, b) (((b) << 8) | (a))
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
typedef struct {
uint8_t IsGif89;
pm_uint_t Width;
pm_uint_t Height;
pm_uint_t Colors;
pm_color_t BackColor;
uint8_t BackColorIndex;
uint8_t AspectRatio;
} GIF_HEADER;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
typedef struct {
uint8_t *pPalette;
pm_int_t PalSize;
pm_int_t xOffset;
pm_int_t yOffset;
pm_uint_t Width;
pm_uint_t Height;
pm_uint_t Delay;
uint8_t HasTrans;
uint8_t TransColorIndex;
uint8_t InputFlag;
uint8_t Disposal;
} GIF_IMAGE_INFO;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class Pm_Gif_Reader : public Pm_Graphic_Reader
{
public:
Pm_Gif_Reader(pm_uint_t Id = 0);
virtual ~Pm_Gif_Reader(void);
void DestroyImages(void);
GIF_HEADER *GetGifHeader(void) {return &mGifHead;}
GIF_IMAGE_INFO *GetGifInfo(void) {return mpImageInfo;}
#ifdef PRISM_GRAPHIC_READER_FILEIO
virtual pm_bool_t GetGraphicInfo(Pm_File *pSrc, pm_graphic_info_t *info);
#endif
pm_bool_t ReadFrame();
#ifdef PRISM_GRAPHIC_READER_FILEIO
pm_bool_t ReadHeader(Pm_File *pSrc);
virtual pm_bool_t ReadImage(Pm_File *pSrc, pm_int_t Count = 10);
#else
pm_bool_t ReadHeader();
virtual pm_bool_t ReadImage(pm_int_t Count = 10);
#endif
private:
pm_int_t CheckStack(void);
GIF_IMAGE_INFO *CurrentImageInfo(void);
void DeleteImageInfo(void);
pm_int_t DoExtension(pm_int_t label);
pm_int_t GetCode(pm_int_t code_size, pm_int_t flag);
pm_int_t GetDataBlock(uint8_t *pBuf);
pm_int_t LWZReadByte(pm_int_t flag, pm_int_t input_code_size);
pm_int_t ReadColorMap(pm_int_t number, uint8_t *pPalette);
pm_bool_t ReadImage(pm_int_t len, pm_int_t height, pm_int_t interlace);
#if defined(PRISM_GRAPHIC_SCALING)
pm_bool_t ReadImageToSize(pm_int_t len, pm_int_t height, pm_int_t interlace);
#endif
virtual void SetLocalPalette(pm_uint_t Index);
GIF_IMAGE_INFO *mpImageInfo;
int16_t *mpStack;
uint8_t *mpDataBuf;
pm_bool_t mZeroDataBlock;
pm_bool_t mFresh;
pm_int_t mCurbit;
pm_int_t mLastbit;
pm_int_t mMaxCode;
pm_int_t mMaxCodeSize;
pm_int_t mInfoCount;
pm_int_t mDone;
pm_int_t mLastByte;
pm_int_t mCodeSize;
pm_int_t mSetCodeSize;
pm_int_t mFirstCode;
pm_int_t mOldCode;
pm_int_t mClearCode;
pm_int_t mEndCode;
GIF_HEADER mGifHead;
int16_t mCodeTable[2][( 1 << MAX_LWZ_BITS)];
int16_t mStack[GIF_CODE_STACK_SIZE];
};
END_NAMESPACE_PRISM
#endif
#endif
| [
"darren@cubietech.com"
] | darren@cubietech.com |
10b1b3dc5713754ebc41f98c630fa85d251e212d | 8dae58cc27c27e0f20028579ec8f27ff94ef4869 | /sum.cpp | 559e34d473d2413f3d76c73ae23396ef3bf0a9ef | [] | no_license | NesquikPlz/sum-test | c920c2b63eb1304c8e4786ba4e8e1f5d941e85fc | 9e23ef2f40d609f141927f9bf44cdda89fbea463 | refs/heads/master | 2023-06-20T03:49:12.801016 | 2021-07-07T08:43:42 | 2021-07-07T08:43:42 | 383,712,605 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 83 | cpp | int sum(int n) {
int res = 0;
for (int i=1; i<=n; ++i)
res += i;
return res;
} | [
"ok2006818@gmail.com"
] | ok2006818@gmail.com |
ef0e03717109931c04c1decbeae1aa9265bcd116 | 80839e8bfdd02fb591a9fee2ac99e5d36af21f1e | /Classes/Components/Physics/ColliderComponent.cpp | 4cc78b930a7a7bca9a97f87929cac4bb5aa55a7e | [] | no_license | rokoDev/SpaceInvaders | e4e289324cd297e8a2d3690fbfc6f364bb5d0341 | 348b73fc2a3ad4711bc3073867124319a9334a8d | refs/heads/master | 2020-06-10T22:02:41.777563 | 2016-12-28T23:25:29 | 2016-12-28T23:25:29 | 75,860,466 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,852 | cpp | //
// ColliderComponent.cpp
// SpaceInvaders
//
// Created by roko on 12/15/16.
//
//
#include "ColliderComponent.hpp"
#include "ComponentDefinitions.hpp"
#include "PhysicsWorldComponent.hpp"
USING_NS_CC;
ColliderComponent::ColliderComponent():
m_bitMask(0),
m_groupID(0),
m_leftBottomCellCoord({0, 0}),
m_topRightCellCoord({0, 0}),
m_gridID(0),
m_ownerTag(-1)
{
}
ColliderComponent::~ColliderComponent()
{
}
cocos2d::Rect ColliderComponent::getRect() const
{
if (_owner) {
Size s = _owner->getContentSize();
Vec2 p = _owner->getPosition()-Vec2(s.width*_owner->getAnchorPoint().x, s.height*_owner->getAnchorPoint().y);
return cocos2d::Rect(p, s);
}
return Rect::ZERO;
}
bool ColliderComponent::init()
{
this->setName(kColliderKeyStr);
return true;
}
void ColliderComponent::update(float delta)
{
}
ColliderComponent* ColliderComponent::create()
{
ColliderComponent * ret = new (std::nothrow) ColliderComponent();
if (ret && ret->init())
{
ret->autorelease();
}
else
{
CC_SAFE_DELETE(ret);
}
return ret;
}
ColliderComponent* ColliderComponent::create(const BitMaskType bitMask, const GroupIDType groupID)
{
ColliderComponent * ret = ColliderComponent::create();
if (ret) {
ret->setBitMask(bitMask);
ret->setGroupID(groupID);
}
return ret;
}
void ColliderComponent::setValueAll(cocos2d::Node * pComponentContainerNode, const BitMaskType bitMask, const GroupIDType groupID)
{
auto pComponent = static_cast<ColliderComponent *>(pComponentContainerNode->getComponent(kColliderKeyStr));
if (pComponent) {
pComponent->setGroupID(groupID);
pComponent->setBitMask(bitMask);
}
}
void ColliderComponent::setValueBitMask(cocos2d::Node * pComponentContainerNode, const BitMaskType bitMask)
{
auto pComponent = static_cast<ColliderComponent *>(pComponentContainerNode->getComponent(kColliderKeyStr));
if (pComponent) {
pComponent->setBitMask(bitMask);
}
}
void ColliderComponent::setValueGroupID(cocos2d::Node * pComponentContainerNode, const GroupIDType groupID)
{
auto pComponent = static_cast<ColliderComponent *>(pComponentContainerNode->getComponent(kColliderKeyStr));
if (pComponent) {
pComponent->setGroupID(groupID);
}
}
void ColliderComponent::onEnter()
{
Component::onEnter();
auto physicsWorld = static_cast<PhysicsWorldComponent *>(_owner->getParent()->getComponent(kPhysicsWorldKeyStr));
if (physicsWorld) {
physicsWorld->addCollider(this);
}
}
void ColliderComponent::onExit()
{
Component::onExit();
auto physicsWorld = static_cast<PhysicsWorldComponent *>(_owner->getParent()->getComponent(kPhysicsWorldKeyStr));
if (physicsWorld) {
physicsWorld->removeCollider(this);
}
}
| [
"mishaDoter@gmail.com"
] | mishaDoter@gmail.com |
10b1a77cf37b5ab90d3af3b1d0bf7a4da89eccc4 | 4bedcf7b83a9a31464c1e2308604e5001b7fa9b5 | /all-applications/tools/OnyX-0.4.1/.onyx/OnyxMenuItem.cc | dc18e5dc96910dc54b529c98d87abaac213b79b1 | [] | no_license | rn10950/FVWM95-Updated | 847e48d21acb2bec404cb66719b7b5881d2a20a1 | efbe3376e00860ad5ac9de00b143b11a9cab43e6 | refs/heads/master | 2021-01-18T13:59:58.287835 | 2018-08-09T03:25:53 | 2018-08-09T03:25:53 | 38,997,038 | 16 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,211 | cc | /**************************************************************************
This file is part of OnyX, a visual development environment
using the xclass toolkit. Copyright (C) 1997, 1998 Frank Hall.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**************************************************************************/
#include "OnyxBase.h"
#include "OnyxMenuItem.h"
extern MessageCenter *CentralMessageCenter;
//----------------------------------------------------------------------
OnyxMenuItem::OnyxMenuItem() : OnyxObject("OnyxMenuItem") {
MenuItemExists = 0;
IsChecked = False;
IsSeparator = False;
X = 0;
Y = 0;
Width = 0;
Height = 0;
}
int OnyxMenuItem::Create() {
OnyxObject::Create();
if (!MenuItemExists) {
if (strlen(Text)) {
IsSeparator = False;
MenuParent->AddEntry(Text, ID);
if (IsChecked) Check();
if (!IsEnabled) Disable();
} else {
IsSeparator = True;
MenuParent->AddSeparator();
}
MenuItemExists++;
}
return MenuItemExists;
}
void OnyxMenuItem::Check() {
if (!IsSeparator) {
IsChecked = True;
MenuParent->CheckEntry(ID);
}
}
void OnyxMenuItem::UnCheck() {
if (!IsSeparator) {
IsChecked = False;
MenuParent->UnCheckEntry(ID);
}
}
void OnyxMenuItem::Enable() {
OnyxObject::Enable();
if (!IsSeparator) {
MenuParent->EnableEntry(ID);
}
}
void OnyxMenuItem::Disable() {
OnyxObject::Disable();
if (!IsSeparator) {
MenuParent->DisableEntry(ID);
}
}
OnyxMenuItem::~OnyxMenuItem() {
}
| [
"root@FVWm95-TestVM.WORKGROUP"
] | root@FVWm95-TestVM.WORKGROUP |
1aaa97b22eedc97fb7dbdb386b14008c282e4790 | ebf7654231c1819cef2097f60327c968b2fa6daf | /message/message_struct/Msg_Campfire_Struct.h | 787d0b9a09060ec52a346c08c2511f7ec8884d77 | [] | no_license | hdzz/game-server | 71195bdba5825c2c37cb682ee3a25981237ce2ee | 0abf247c107900fe36819454ec6298f3f1273e8b | refs/heads/master | 2020-12-30T09:15:17.606172 | 2015-07-29T07:40:01 | 2015-07-29T07:40:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,439 | h | /*
* Generate by devtool
*/
#ifndef _MSG_CAMPFIRE_H_
#define _MSG_CAMPFIRE_H_
#include "Msg_Struct.h"
/* SERVER MSG */
/*
请求进入篝火晚会
*/
struct MSG_10100700 {
MSG_10100700(void) { reset(); };
void serialize(Block_Buffer & w) const {
}
int deserialize(Block_Buffer & r) {
return 0;
}
void reset(void) {
}
};
/*
请求添加篝火柴火
*/
struct MSG_10200701 {
int64_t role_id;
MSG_10200701(void) { reset(); };
void serialize(Block_Buffer & w) const {
w.write_int64(role_id);
}
int deserialize(Block_Buffer & r) {
if( r.read_int64(role_id) )
return -1;
return 0;
}
void reset(void) {
role_id = 0;
}
};
/*
请求点燃篝火
*/
struct MSG_10200702 {
int64_t role_id;
MSG_10200702(void) { reset(); };
void serialize(Block_Buffer & w) const {
w.write_int64(role_id);
}
int deserialize(Block_Buffer & r) {
if( r.read_int64(role_id) )
return -1;
return 0;
}
void reset(void) {
role_id = 0;
}
};
/*
请求篝火排名
*/
struct MSG_10200703 {
MSG_10200703(void) { reset(); };
void serialize(Block_Buffer & w) const {
}
int deserialize(Block_Buffer & r) {
return 0;
}
void reset(void) {
}
};
/*
请求篝火排名(返回)
*/
struct MSG_50200703 : public Base_Msg {
std::vector<campfire_rank_info> rank_info;
int8_t rank;
uint32_t time;
MSG_50200703(void) { reset(); };
void serialize(Block_Buffer & w) const {
uint16_t __rank_info_vec_size = rank_info.size();
w.write_uint16(__rank_info_vec_size);
for(uint16_t i = 0; i < __rank_info_vec_size; ++i) {
rank_info[i].serialize(w);
}
w.write_int8(rank);
w.write_uint32(time);
}
int deserialize(Block_Buffer & r) {
uint16_t __rank_info_vec_size;
if(r.read_uint16(__rank_info_vec_size) )
return -1;
rank_info.reserve(__rank_info_vec_size);
for(uint16_t i = 0; i < __rank_info_vec_size; ++i) {
campfire_rank_info v;
if(v.deserialize(r))
return -1;
rank_info.push_back(v);
}
if( r.read_int8(rank) || r.read_uint32(time) )
return -1;
return 0;
}
void reset(void) {
msg_id = 50200703;
rank_info.clear();
rank = 0;
time = 0;
}
};
/*
请求点燃/添柴奖励
备注:请求点燃/添柴奖励
*/
struct MSG_10200704 {
MSG_10200704(void) { reset(); };
void serialize(Block_Buffer & w) const {
}
int deserialize(Block_Buffer & r) {
return 0;
}
void reset(void) {
}
};
/*
请求点燃/添柴奖励(返回)
备注:请求点燃/添柴奖励(返回)
*/
struct MSG_50200704 : public Base_Msg {
int32_t result;
MSG_50200704(void) { reset(); };
void serialize(Block_Buffer & w) const {
w.write_int32(result);
}
int deserialize(Block_Buffer & r) {
if( r.read_int32(result) )
return -1;
return 0;
}
void reset(void) {
msg_id = 50200704;
result = 0;
}
};
/*
请求篝火结算奖励
*/
struct MSG_10200705 {
MSG_10200705(void) { reset(); };
void serialize(Block_Buffer & w) const {
}
int deserialize(Block_Buffer & r) {
return 0;
}
void reset(void) {
}
};
/*
请求篝火结算奖励(返回)
备注:请求篝火结算奖励(返回)
*/
struct MSG_50200705 : public Base_Msg {
int32_t result;
MSG_50200705(void) { reset(); };
void serialize(Block_Buffer & w) const {
w.write_int32(result);
}
int deserialize(Block_Buffer & r) {
if( r.read_int32(result) )
return -1;
return 0;
}
void reset(void) {
msg_id = 50200705;
result = 0;
}
};
#endif | [
"zuti@avatarworks.com"
] | zuti@avatarworks.com |
808ff2cd8f947b84306d53a2cce64e5db6b3a9f8 | 0619c7338863d71320658d10607b5e1bac32b854 | /Debug/ui_levelselectwindow.h | 348eca35296329db344b0cfd23720db8118a1fa2 | [] | no_license | tmpope/typersblock | 997f2c0cf25f55657f29c6cddc33a263fb0498d3 | 9a7fc7eb8de8434d548b9201caa9caf087ffa356 | refs/heads/master | 2021-03-19T15:22:05.410045 | 2015-12-16T21:25:46 | 2015-12-16T21:25:46 | 46,524,978 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,527 | h | /********************************************************************************
** Form generated from reading UI file 'levelselectwindow.ui'
**
** Created by: Qt User Interface Compiler version 5.5.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_LEVELSELECTWINDOW_H
#define UI_LEVELSELECTWINDOW_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QRadioButton>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_LevelSelectWindow
{
public:
QWidget *centralWidget;
QLabel *label;
QPushButton *logOutButton;
QPushButton *Level1;
QPushButton *Level2;
QPushButton *Level3;
QPushButton *Level4;
QPushButton *Level6;
QPushButton *Level8;
QPushButton *Level7;
QPushButton *Level5;
QPushButton *Level9;
QLabel *merLabel;
QLabel *venLable;
QLabel *earLabel;
QLabel *marLabel;
QLabel *satLabel;
QLabel *jupLabel;
QLabel *uraLabel;
QLabel *pluLabel;
QLabel *nepLabel;
QRadioButton *dvorakButton;
void setupUi(QWidget *LevelSelectWindow)
{
if (LevelSelectWindow->objectName().isEmpty())
LevelSelectWindow->setObjectName(QStringLiteral("LevelSelectWindow"));
LevelSelectWindow->resize(1366, 768);
centralWidget = new QWidget(LevelSelectWindow);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
centralWidget->setGeometry(QRect(0, 0, 1366, 768));
centralWidget->setStyleSheet(QStringLiteral("background-image: url(:/new/images/levelSelectBackground.jpg);"));
label = new QLabel(centralWidget);
label->setObjectName(QStringLiteral("label"));
label->setGeometry(QRect(60, 40, 501, 91));
QFont font;
font.setFamily(QStringLiteral("GALACTIC VANGUARDIAN NCV"));
font.setPointSize(24);
label->setFont(font);
label->setStyleSheet(QLatin1String("color: white;\n"
"background-image: url(:/new/images/alpha.png);"));
logOutButton = new QPushButton(centralWidget);
logOutButton->setObjectName(QStringLiteral("logOutButton"));
logOutButton->setGeometry(QRect(10, 700, 101, 51));
QFont font1;
font1.setPointSize(16);
logOutButton->setFont(font1);
logOutButton->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level1 = new QPushButton(centralWidget);
Level1->setObjectName(QStringLiteral("Level1"));
Level1->setEnabled(true);
Level1->setGeometry(QRect(260, 200, 250, 90));
QFont font2;
font2.setPointSize(20);
Level1->setFont(font2);
Level1->setStyleSheet(QLatin1String("color: white;\n"
"background-color: gold;"));
Level2 = new QPushButton(centralWidget);
Level2->setObjectName(QStringLiteral("Level2"));
Level2->setEnabled(false);
Level2->setGeometry(QRect(260, 300, 250, 90));
Level2->setFont(font2);
Level2->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level3 = new QPushButton(centralWidget);
Level3->setObjectName(QStringLiteral("Level3"));
Level3->setEnabled(false);
Level3->setGeometry(QRect(260, 400, 250, 90));
Level3->setFont(font2);
Level3->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level4 = new QPushButton(centralWidget);
Level4->setObjectName(QStringLiteral("Level4"));
Level4->setEnabled(false);
Level4->setGeometry(QRect(640, 200, 250, 90));
Level4->setFont(font2);
Level4->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level6 = new QPushButton(centralWidget);
Level6->setObjectName(QStringLiteral("Level6"));
Level6->setEnabled(false);
Level6->setGeometry(QRect(640, 400, 250, 90));
Level6->setFont(font2);
Level6->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level8 = new QPushButton(centralWidget);
Level8->setObjectName(QStringLiteral("Level8"));
Level8->setEnabled(false);
Level8->setGeometry(QRect(1020, 300, 250, 90));
Level8->setFont(font2);
Level8->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level7 = new QPushButton(centralWidget);
Level7->setObjectName(QStringLiteral("Level7"));
Level7->setEnabled(false);
Level7->setGeometry(QRect(1020, 200, 250, 90));
Level7->setFont(font2);
Level7->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level5 = new QPushButton(centralWidget);
Level5->setObjectName(QStringLiteral("Level5"));
Level5->setEnabled(false);
Level5->setGeometry(QRect(640, 300, 250, 90));
Level5->setFont(font2);
Level5->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
Level9 = new QPushButton(centralWidget);
Level9->setObjectName(QStringLiteral("Level9"));
Level9->setEnabled(false);
Level9->setGeometry(QRect(1020, 400, 250, 90));
Level9->setFont(font2);
Level9->setStyleSheet(QLatin1String("color: white;\n"
"background-color: black;"));
merLabel = new QLabel(centralWidget);
merLabel->setObjectName(QStringLiteral("merLabel"));
merLabel->setGeometry(QRect(160, 200, 90, 90));
merLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/mercury.jpg")));
merLabel->setAlignment(Qt::AlignCenter);
venLable = new QLabel(centralWidget);
venLable->setObjectName(QStringLiteral("venLable"));
venLable->setGeometry(QRect(160, 300, 90, 90));
venLable->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/venus.jpg")));
venLable->setAlignment(Qt::AlignCenter);
earLabel = new QLabel(centralWidget);
earLabel->setObjectName(QStringLiteral("earLabel"));
earLabel->setGeometry(QRect(160, 400, 90, 90));
earLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/earth.jpg")));
earLabel->setAlignment(Qt::AlignCenter);
marLabel = new QLabel(centralWidget);
marLabel->setObjectName(QStringLiteral("marLabel"));
marLabel->setGeometry(QRect(540, 200, 90, 90));
marLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/mars.jpg")));
marLabel->setAlignment(Qt::AlignCenter);
satLabel = new QLabel(centralWidget);
satLabel->setObjectName(QStringLiteral("satLabel"));
satLabel->setGeometry(QRect(540, 400, 90, 90));
satLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/saturn.jpg")));
satLabel->setAlignment(Qt::AlignCenter);
jupLabel = new QLabel(centralWidget);
jupLabel->setObjectName(QStringLiteral("jupLabel"));
jupLabel->setGeometry(QRect(540, 300, 90, 90));
jupLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/jupiter.jpg")));
jupLabel->setAlignment(Qt::AlignCenter);
uraLabel = new QLabel(centralWidget);
uraLabel->setObjectName(QStringLiteral("uraLabel"));
uraLabel->setGeometry(QRect(920, 200, 90, 90));
uraLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/uranus.jpg")));
uraLabel->setAlignment(Qt::AlignCenter);
pluLabel = new QLabel(centralWidget);
pluLabel->setObjectName(QStringLiteral("pluLabel"));
pluLabel->setGeometry(QRect(920, 400, 90, 90));
pluLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/pluto.jpg")));
pluLabel->setAlignment(Qt::AlignCenter);
nepLabel = new QLabel(centralWidget);
nepLabel->setObjectName(QStringLiteral("nepLabel"));
nepLabel->setGeometry(QRect(920, 300, 90, 90));
nepLabel->setPixmap(QPixmap(QString::fromUtf8(":/new/images/Images/neptune.jpg")));
nepLabel->setAlignment(Qt::AlignCenter);
dvorakButton = new QRadioButton(centralWidget);
dvorakButton->setObjectName(QStringLiteral("dvorakButton"));
dvorakButton->setGeometry(QRect(170, 510, 101, 41));
QFont font3;
font3.setPointSize(18);
dvorakButton->setFont(font3);
dvorakButton->setStyleSheet(QLatin1String("background-image: url(:/new/images/alpha.png);\n"
"color: white;"));
retranslateUi(LevelSelectWindow);
QMetaObject::connectSlotsByName(LevelSelectWindow);
} // setupUi
void retranslateUi(QWidget *LevelSelectWindow)
{
LevelSelectWindow->setWindowTitle(QApplication::translate("LevelSelectWindow", "Level Select", 0));
label->setText(QApplication::translate("LevelSelectWindow", "Level Select", 0));
logOutButton->setText(QApplication::translate("LevelSelectWindow", "Log Out", 0));
Level1->setText(QApplication::translate("LevelSelectWindow", "Level 1", 0));
Level2->setText(QApplication::translate("LevelSelectWindow", "Level 2", 0));
Level3->setText(QApplication::translate("LevelSelectWindow", "Level 3", 0));
Level4->setText(QApplication::translate("LevelSelectWindow", "Level 4", 0));
Level6->setText(QApplication::translate("LevelSelectWindow", "Level 6", 0));
Level8->setText(QApplication::translate("LevelSelectWindow", "Level 8", 0));
Level7->setText(QApplication::translate("LevelSelectWindow", "Level 7", 0));
Level5->setText(QApplication::translate("LevelSelectWindow", "Level 5", 0));
Level9->setText(QApplication::translate("LevelSelectWindow", "Level 9", 0));
merLabel->setText(QString());
venLable->setText(QString());
earLabel->setText(QString());
marLabel->setText(QString());
satLabel->setText(QString());
jupLabel->setText(QString());
uraLabel->setText(QString());
pluLabel->setText(QString());
nepLabel->setText(QString());
dvorakButton->setText(QApplication::translate("LevelSelectWindow", "Dvorak", 0));
} // retranslateUi
};
namespace Ui {
class LevelSelectWindow: public Ui_LevelSelectWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_LEVELSELECTWINDOW_H
| [
"ssong3k@gmail.com"
] | ssong3k@gmail.com |
80968818daf91b690e6de2aea36d8243d40615e5 | d0acc586b3961b0cda97fe2be746b95d148d98d0 | /clinkedlist.h | 2cd63c2b66b3caafef6848249f7ddc4ed5d43aa6 | [] | no_license | ecrisost/LinkedListTrio | bd69853a247514185d43672cf56196c9bb321e58 | b23deab1ccc88c0d3233078b4cb31625cdd6e1cd | refs/heads/master | 2020-12-24T21:00:53.497874 | 2016-05-07T15:04:36 | 2016-05-07T15:04:36 | 58,149,887 | 0 | 0 | null | 2016-05-07T14:56:20 | 2016-05-05T17:50:20 | C++ | UTF-8 | C++ | false | false | 1,116 | h | #ifndef _CLINKEDLIST_H_
#define _CLINKEDLIST_H_
#include <vector>
template <class T>
class Node
{
public:
Node<T>* next;
Node<T>* prev;
T data;
Node(T value)
{
data = value;
next = NULL;
prev = NULL;
}
};
template <class T>
class CLinkedList
{
private:
Node<T>* front;
Node<T>* back;
int size;
void CopyHelper (const CLinkedList &ll);
void DeleteList();
public:
CLinkedList();//default constructor
CLinkedList(const CLinkedList &ll); //parameterized copy constructor
~CLinkedList(); //destructor
//|| MUTATORS ||
bool InsertFront(T item);
bool InsertBack(T item);
bool InsertAt(T item, int p);
bool Remove(T item);
//|| ACCESSORS ||
int GetSize() const;//size of the list
bool IsEmpty() const;
bool Search(T item);//search for item
T Retrieve(T item); //retrieve data
// vector<T> Dump() const;//dump items in the list into a vector
//|| OVERLOADED OPERATORS ||
//overload assignment operator
CLinkedList& operator =(const CLinkedList &ll);
};
#include "clinkedlist.cpp"
#endif | [
"ecrisost@sfu.ca"
] | ecrisost@sfu.ca |
a3453a470bfe0af7c2d157caf734fd3538c3f679 | 2ef774ea8b767a4bf2b57156e3537d687fb66d88 | /fb/peaktraffic/cpp/old/main2.cpp | a393853edece5962130968a02e2bc45bf239f59d | [] | no_license | santiago739/puzzles | 04a543d5b540832434d2baf8810c04c951043292 | c2fe5b92c7817cade92669552993cc648a192164 | refs/heads/master | 2020-05-19T21:07:08.548763 | 2011-06-10T14:42:06 | 2011-06-10T14:42:06 | 1,294,989 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,208 | cpp | #include <fstream>
#include <sstream>
#include <iostream>
#include <set>
#include <vector>
#include <iterator>
#include <map>
#include <algorithm>
#include <ctime>
#include <boost/concept_check.hpp>
using namespace std;
struct Vertex;
typedef map<string, Vertex*, less<string> > vmap;
typedef set<Vertex*> vset;
class Timer
{
public:
Timer( )
: period_( 0 ) {}
/* Timer()
{
startTime_ = clock();
}*/
void start( )
{
startTime_ = clock();
}
void finish( )
{
finishTime_ = clock();
setPeriod();
}
double getPeriod( )
{
// return static_cast<double>(finishTime_ - startTime_) / CLOCKS_PER_SEC;
return period_;
}
private:
// string name_;
double period_;
clock_t startTime_;
clock_t finishTime_;
void setPeriod( )
{
period_ += static_cast<double>(finishTime_ - startTime_) / CLOCKS_PER_SEC;
}
};
struct Vertex
{
string name;
vset neighbours;
Vertex( const string& nm )
: name( nm ) { }
};
class Graph
{
public:
Graph( ) { }
~Graph( );
void addEdge( const string& sourceName, const string& destName );
void printGraph( );
const vmap& getVertexMap( );
const vset& getVertexSet( );
void makeNotOriented( );
private:
vmap vertexMap;
vset vertexSet;
Vertex* getVertex( const string& vertexName );
// Copy semantics are disabled; these make no sense.
Graph( const Graph & rhs ) { }
const Graph & operator= ( const Graph & rhs )
{ return *this; }
};
const vmap& Graph::getVertexMap( )
{
return vertexMap;
}
const vset& Graph::getVertexSet( )
{
return vertexSet;
}
void Graph::addEdge( const string& sourceName, const string& destName )
{
Vertex* v = getVertex( sourceName );
Vertex* w = getVertex( destName );
v->neighbours.insert( w );
}
Vertex* Graph::getVertex( const string& vertexName )
{
vmap::iterator i = vertexMap.find( vertexName );
if ( i == vertexMap.end( ) )
{
Vertex* newv = new Vertex( vertexName );
vertexMap[ vertexName ] = newv;
vertexSet.insert( newv );
return newv;
}
return ( *i ).second;
}
void Graph::makeNotOriented( )
{
for ( vmap::iterator i = vertexMap.begin( ); i != vertexMap.end( ); ++i )
{
vset::const_iterator j;
for ( j = ( *i ).second->neighbours.begin(); j != ( *i ).second->neighbours.end(); ++j )
{
//cout << ( *j )->name << " ";
vmap::iterator k = vertexMap.find( ( *j )->name );
if ( k == vertexMap.end() )
{
( *i ).second->neighbours.erase( j );
}
}
}
}
void Graph::printGraph( )
{
cout << "=== Graph ===" << "\n";
for ( vmap::iterator i = vertexMap.begin( ); i != vertexMap.end( ); ++i )
{
cout << "Vertex: " << ( *i ).first << " ";
cout << "Edges: ";
vset::const_iterator j;
for ( j = ( *i ).second->neighbours.begin(); j != ( *i ).second->neighbours.end(); ++j )
{
cout << ( *j )->name << " ";
}
cout << "\n";
}
}
Graph::~Graph( )
{
for ( vmap::iterator i = vertexMap.begin( ); i != vertexMap.end( ); ++i )
{
delete( *i ).second;
}
}
vector<string> & split( const string& s, char delim, vector<string>& elems )
{
stringstream ss( s );
string item;
while ( getline( ss, item, delim ) )
{
elems.push_back( item );
}
return elems;
}
vector<string> split( const string& s, char delim )
{
vector<string> elems;
return split( s, delim, elems );
}
void printAsciiString( const string& s )
{
for ( int i = 0; i < int( s.size() ); i++ )
{
cout << int( s[i] ) << " ";
}
}
bool readInput( const char* fileName, Graph& g )
{
ifstream inFile( fileName );
string fileLine;
vector<string> tokens;
if ( !inFile )
{
cerr << "Cannot open " << fileName << endl;
return false;
}
while ( getline( inFile, fileLine ) )
{
fileLine.erase( remove( fileLine.begin(), fileLine.end(), '\n'), fileLine.end() );
fileLine.erase( remove( fileLine.begin(), fileLine.end(), '\r'), fileLine.end() );
tokens = split( fileLine, '\t' );
// cout << tokens[1] << " " << tokens[2] << "\n";
if ( tokens[1] == tokens[2] )
{
continue;
}
// cout << "\"" << tokens[1] << "\"" << " " << "\"" << tokens[2] << "\"" << endl;
// cout << tokens[1].size() << " " << tokens[2].size() << endl;
// cout << "s1: ";
// printAsciiString(tokens[1]);
// cout << " s2: ";
// printAsciiString(tokens[2]);
// cout << endl;
g.addEdge( tokens[1], tokens[2] );
}
return true;
}
void printSet( const vset& s )
{
// cout << "{ ";
for ( vset::iterator i = s.begin( ); i != s.end( ); i++ )
{
cout << ( *i )->name << " ";
}
// cout << "}" << endl;
}
void bronKerboschOne( vset setR, vset setP, vset setX, vector<vset>& cliques, int level = 0 )
{
vset setNewR, setNewP, setNewX, setTmpP, neighbours;
vset::iterator k;
int j = level;
while ( j > 0 )
{
cout << " ";
j--;
}
cout << "=== bronKerboschOne( ";
printSet( setR );
cout << ", ";
printSet( setP );
cout << ", ";
printSet( setX );
cout << " ) ===" << "\n";
// printSet( setP );
if ( setP.size() == 0 && setX.size() == 0 )
{
// cout << "Maximal clique: ";
// printSet( setR );
// cout << "\n";
cliques.push_back(setR);
return;
}
setTmpP = setP;
for ( vset::iterator i = setTmpP.begin( ); i != setTmpP.end( ); i++ )
{
neighbours = ( *i )->neighbours;
// cout << "=== Vertex ===" << "\n";
// cout << ( *i )->name << "\n";
// cout << "=== Neighbours ===" << "\n";
// printSet( neighbours );
// cout << "\n";
//setNewR.clear();
setNewR = setR;
setNewR.insert( *i );
// cout << "=== setNewR ===" << "\n";
// printSet( setNewR );
setNewP.clear();
set_intersection( setP.begin(), setP.end(),
neighbours.begin(), neighbours.end(),
inserter( setNewP, setNewP.begin() ) );
setNewX.clear();
set_intersection( setX.begin(), setX.end(),
neighbours.begin(), neighbours.end(),
inserter( setNewX, setNewX.begin() ) );
// cout << "=== setNewP ===" << "\n";
// printSet( setNewP );
// cout << "=== setNewX ===" << "\n";
// printSet( setNewX );
// cout << "\n";
// r.insert( *itr );
// n.insert( ( *itr ).adj.be )
bronKerboschOne( setNewR, setNewP, setNewX, cliques, level + 1 );
setX.insert( *i );
setP.erase( *i );
}
}
Vertex* getPivotOne( const vset& setP )
{
if ( setP.size() > 0 )
{
vset::iterator i = setP.begin();
return ( *i );
}
else
{
return NULL;
}
}
Vertex* getPivotTwo( const vset& setP )
{
Vertex* pivot = NULL;
if ( setP.size() > 0 )
{
size_t n = 0;
for ( vset::iterator i = setP.begin( ); i != setP.end( ); i++ )
{
if ( (*i)->neighbours.size() > n )
{
n = (*i)->neighbours.size();
pivot = *i;
}
}
}
return pivot;
}
const int nTimers = 8;
Timer timers[nTimers];
void bronKerboschTwo( vset setR, vset setP, vset setX, vector<vset>& cliques, int level = 0 )
{
vset setNewR, setNewP, setNewX, setTmpP, neighboursV, neighboursU;
vset::iterator k;
Vertex* pivot;
// int j = level;
// while ( j > 0 )
// {
// cout << " ";
// j--;
// }
// cout << "=== bronKerboschTwo( ";
// printSet( setR );
// cout << ", ";
// printSet( setP );
// cout << ", ";
// printSet( setX );
// cout << " ) ===" << "\n";
// printSet( setP );
if ( setP.size() == 0 && setX.size() == 0 )
{
timers[0].start();
cliques.push_back(setR);
timers[0].finish();
return;
}
timers[1].start();
set_union( setP.begin(), setP.end(), setX.begin(), setX.end(),
inserter( setNewP, setNewP.begin() ) );
timers[1].finish();
timers[2].start();
// pivot = getPivotOne( setNewP );
pivot = getPivotTwo( setNewP );
timers[2].finish();
if ( pivot != NULL )
{
// cout << "Pivot: " << pivot->name << "\n";
neighboursU = pivot->neighbours;
timers[3].start();
set_difference( setP.begin(), setP.end(),
neighboursU.begin(), neighboursU.end(),
inserter( setTmpP, setTmpP.begin() ) );
timers[3].finish();
}
else
{
setTmpP = setP;
}
for ( vset::iterator i = setTmpP.begin( ); i != setTmpP.end( ); i++ )
{
timers[4].start();
neighboursV = ( *i )->neighbours;
// cout << "=== Vertex ===" << "\n";
// cout << ( *i )->name << "\n";
// cout << "=== Neighbours ===" << "\n";
// printSet( neighbours );
// cout << "\n";
//setNewR.clear();
setNewR = setR;
setNewR.insert( *i );
timers[4].finish();
// cout << "=== setNewR ===" << "\n";
// printSet( setNewR );
timers[5].start();
setNewP.clear();
set_intersection( setP.begin(), setP.end(),
neighboursV.begin(), neighboursV.end(),
inserter( setNewP, setNewP.begin() ) );
timers[5].finish();
timers[6].start();
setNewX.clear();
set_intersection( setX.begin(), setX.end(),
neighboursV.begin(), neighboursV.end(),
inserter( setNewX, setNewX.begin() ) );
timers[6].finish();
// cout << "=== setNewP ===" << "\n";
// printSet( setNewP );
// cout << "=== setNewX ===" << "\n";
// printSet( setNewX );
// cout << "\n";
// r.insert( *itr );
// n.insert( ( *itr ).adj.be )
bronKerboschTwo( setNewR, setNewP, setNewX, cliques, level + 1 );
timers[7].start();
setX.insert( *i );
setP.erase( *i );
timers[7].finish();
}
}
int main( int argc, char* argv[] )
{
Graph g;
vset setR, setP, setX;
vector<vset> cliques;
Timer inputTimer, processTimer, outputTimer;
double totalTimerTime = 0;
inputTimer.start();
if ( argc != 2 || !readInput( argv[1], g ) )
{
return 1;
}
g.makeNotOriented();
// g.printGraph( );
setP = g.getVertexSet( );
inputTimer.finish();
processTimer.start();
// bronKerboschOne( setR, setP, setX, cliques );
bronKerboschTwo( setR, setP, setX, cliques );
processTimer.finish();
outputTimer.start();
cout << "=== Maximal cliques ===\n";
for ( vector<vset>::iterator i = cliques.begin( ); i != cliques.end( ); i++ )
{
printSet( *i );
cout << "\n";
}
outputTimer.finish();
cerr << "Input time: " << inputTimer.getPeriod() << " seconds." << endl;
cerr << "Process time: " << processTimer.getPeriod() << " seconds." << endl;
for ( int t = 0; t < nTimers; t++ )
{
totalTimerTime += timers[t].getPeriod();
cerr << " Timer #" << ( t + 1) <<" time: " << timers[t].getPeriod() << " seconds." << endl;
}
cerr << " Timer total time: " << totalTimerTime << " seconds." << endl;
cerr << "Output time: " << outputTimer.getPeriod() << " seconds." << endl;
return 0;
}
| [
"santiago739@gmail.com"
] | santiago739@gmail.com |
05d7075b8b34a44d6801d205edc57d0ff359f8e0 | 82acbf8affc0392b8f9417a903807802b39164e4 | /src/Vehicle.h | afcef037e8d1d2f030e7d0fcff5037819686f261 | [
"MIT"
] | permissive | SandroWissmann/Traffic-Simulation | 632581467c93b8020b8715114dcfe4ed791d36cd | 1e8f8bc293ebde51c55f0c1a9367fe079d7d2b49 | refs/heads/master | 2022-07-29T13:22:49.196960 | 2020-06-13T17:27:30 | 2020-06-13T17:27:30 | 265,171,453 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,093 | h | #ifndef VEHICLE_H
#define VEHICLE_H
#include "TrafficObject.h"
// forward declarations to avoid include cycle
class Street;
class Intersection;
class Vehicle : public TrafficObject,
public std::enable_shared_from_this<Vehicle> {
public:
// constructor / desctructor
Vehicle();
// getters / setters
void setCurrentStreet(std::shared_ptr<Street> street)
{
_currStreet = street;
};
void setCurrentDestination(std::shared_ptr<Intersection> destination);
// typical behaviour methods
void simulate();
// miscellaneous
std::shared_ptr<Vehicle> get_shared_this()
{
return shared_from_this();
}
private:
// typical behaviour methods
void drive();
std::shared_ptr<Street>
_currStreet; // street on which the vehicle is currently on
std::shared_ptr<Intersection>
_currDestination; // destination to which the vehicle is currently
// driving
double _posStreet; // position on current street
double _speed; // ego speed in m/s
};
#endif | [
"sandro.wissmann@gmail.com"
] | sandro.wissmann@gmail.com |
e6dbc56667de948a790521edfb56953e112e27a3 | 4c88cc1789b774cce49e6ba1bf5a95fbf81ce173 | /6_ZigZagConversion/stdafx.cpp | 03f6f01551b7447c20c2da8249a063fb75a03231 | [] | no_license | shiqiabi/Algorithem | abbf7572338ac42af2513c48c2a83ae8cd09a9a9 | 9227d00aebc8b4524465cbe87e70f2982d94a85c | refs/heads/master | 2020-04-22T16:44:33.039498 | 2019-02-22T05:04:13 | 2019-02-22T05:04:13 | 170,518,874 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 297 | cpp | // stdafx.cpp : source file that includes just the standard includes
// 6_ZigZagConversion.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"shi-qiang.bi@keysight.com"
] | shi-qiang.bi@keysight.com |
d1d0e3a8287353e7ead38b51658e9612d609fb31 | 39bc881db29ab18f118caad681d8bf4449ce678b | /src/nodes/pcf_directional_light_depth_node.cpp | ef6e9d1b3069611ed97949f16d0b9f7f6ce1f1ed | [
"MIT"
] | permissive | Hanggansta/Nimble | 0133d2960551072b6384864d1acc7e09fdecf851 | 291c1bae6308c49f4e86a7ecabc97e9fe8fce654 | refs/heads/master | 2020-05-02T10:43:21.494642 | 2019-03-26T23:45:04 | 2019-03-26T23:45:04 | 177,905,445 | 0 | 1 | MIT | 2019-03-27T02:41:25 | 2019-03-27T02:41:24 | null | UTF-8 | C++ | false | false | 2,839 | cpp | #include "pcf_directional_light_depth_node.h"
#include "../render_graph.h"
#include "../renderer.h"
namespace nimble
{
DEFINE_RENDER_NODE_FACTORY(PCFDirectionalLightDepthNode)
// -----------------------------------------------------------------------------------------------------------------------------------
PCFDirectionalLightDepthNode::PCFDirectionalLightDepthNode(RenderGraph* graph) :
RenderNode(graph)
{
}
// -----------------------------------------------------------------------------------------------------------------------------------
PCFDirectionalLightDepthNode::~PCFDirectionalLightDepthNode()
{
}
// -----------------------------------------------------------------------------------------------------------------------------------
void PCFDirectionalLightDepthNode::declare_connections()
{
}
// -----------------------------------------------------------------------------------------------------------------------------------
bool PCFDirectionalLightDepthNode::initialize(Renderer* renderer, ResourceManager* res_mgr)
{
m_library = renderer->shader_cache().load_library("shader/shadows/directional_light/shadow_map/directional_light_depth_vs.glsl", "shader/shadows/directional_light/shadow_map/directional_light_depth_fs.glsl");
return true;
}
// -----------------------------------------------------------------------------------------------------------------------------------
void PCFDirectionalLightDepthNode::execute(double delta, Renderer* renderer, Scene* scene, View* view)
{
int32_t w = 0;
int32_t h = 0;
if (view->dest_render_target_view->texture->target() == GL_TEXTURE_2D)
{
Texture2D* texture = (Texture2D*)view->dest_render_target_view->texture.get();
w = texture->width();
h = texture->height();
}
else
{
TextureCube* texture = (TextureCube*)view->dest_render_target_view->texture.get();
w = texture->width();
h = texture->height();
}
renderer->bind_render_targets(0, nullptr, view->dest_render_target_view);
glViewport(0, 0, h, h);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glClear(GL_DEPTH_BUFFER_BIT);
render_scene(renderer, scene, view, m_library.get(), NODE_USAGE_SHADOW_MAP);
}
// -----------------------------------------------------------------------------------------------------------------------------------
void PCFDirectionalLightDepthNode::shutdown()
{
}
// -----------------------------------------------------------------------------------------------------------------------------------
std::string PCFDirectionalLightDepthNode::name()
{
return "PCF Directional Light Depth";
}
// -----------------------------------------------------------------------------------------------------------------------------------
} // namespace nimble | [
"shredhead94@gmail.com"
] | shredhead94@gmail.com |
e0baf8a93000e8b96322057a189f6497ee048b02 | 4da78da3d68c27516444c6fd23dea0e268c2894f | /GCM Framework/GCM Framework/Camera.h | baaaa9b87627a3e801c9039e8abf95eb002b490a | [] | no_license | esc0rtd3w/ps3Game | 437124bde68fdb63add3e368c496a62de22e0a9d | d8873d76d0fef7d40cb9f0f5d1bb730d63ddefb0 | refs/heads/master | 2021-01-19T13:37:42.960391 | 2015-05-06T15:47:27 | 2015-05-06T15:47:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,435 | h | /******************************************************************************
Class:CameraNode
Implements:SceneNode
Author:Rich Davison
Description:FPS-Style camera. Can be attached to a specific joypad, so multiple
joypads can all control multiple cameras (handy for split screen!)
This class is pretty much the Camera class from the Graphics for Games
Framework, but derived from a SceneNode
-_-_-_-_-_-_-_,------,
_-_-_-_-_-_-_-| /\_/\ NYANYANYAN
-_-_-_-_-_-_-~|__( ^ .^) /
_-_-_-_-_-_-_-"" ""
*//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "SceneNode.h"
#include "Input.h"
#include "common.h"
#include <vectormath/cpp/vectormath_aos.h>
using namespace Vectormath::Aos;
class Camera {
public:
Camera(void);
virtual ~Camera(void);
Matrix4 BuildViewMatrix();
virtual void UpdateCamera(float msec = 10.0f);
////Gets position in world space
Vector3 GetPosition() const { return position;}
//Sets position in world space
void SetPosition(Vector3 val) { position = val;}
//Gets yaw, in degrees
float GetYaw() const { return yaw;}
//Sets yaw, in degrees
void SetYaw(float y) {yaw = y;}
//Gets pitch, in degrees
float GetPitch() const { return pitch;}
//Sets pitch, in degrees
void SetPitch(float p) {pitch = p;}
void SetControllingPad(JoyPadNum p) {pad = p;}
protected:
JoyPadNum pad;
float yaw;
float pitch;
Vector3 position;
};
| [
"borjade@hotmail.fr"
] | borjade@hotmail.fr |
888ad3649f302e5bf2b77bafeff56bdcd51d4795 | 16d6b03067fecde1bde7be31199d1596ff65a28e | /threepp/geometry/Circle.cpp | fc2a6bd16ee14ee73bf5f3860d5c458d31c0c151 | [
"MIT"
] | permissive | sarathsi/three.cpp | e33fb41717fe1ed7fc8a4102f9c51ec06420eb8e | 698b249a57fdde7062f1de6be0b77e2d488982c8 | refs/heads/master | 2020-04-02T05:48:37.393129 | 2018-10-21T23:08:25 | 2018-10-21T23:08:25 | 154,107,102 | 1 | 0 | null | 2018-10-22T08:03:58 | 2018-10-22T08:03:51 | null | UTF-8 | C++ | false | false | 1,574 | cpp | //
// Created by byter on 12/21/17.
//
#include "Circle.h"
namespace three {
namespace geometry {
Circle::Circle(float radius, unsigned segments, float thetaStart, float thetaLength)
: _radius(radius), _segments(segments), _thetaStart(thetaStart), _thetaLength(thetaLength)
{
set(buffer::Circle(radius, segments, thetaStart, thetaLength));
mergeVertices();
}
namespace buffer {
Circle::Circle(float radius, unsigned segments, float thetaStart, float thetaLength)
{
segments = std::max(3u, segments);
// buffers
auto indices = attribute::prealloc<uint32_t>(segments * 3, true);
auto vertices = attribute::prealloc<float, Vertex>(segments + 2, true);
auto normals = attribute::prealloc<float, Vertex>(segments + 2, true);
auto uvs = attribute::prealloc<float, UV>(segments + 2, true);
// center point
vertices->next() = {0, 0, 0};
normals->next() = {0, 0, 1};
uvs->next() = {0.5, 0.5};
for (unsigned s = 0; s <= segments; s ++ ) {
float segment = thetaStart + s / segments * thetaLength;
// vertex
float x = radius * std::cos( segment );
float y = radius * std::sin( segment );
vertices->next() = {x, y, 0};
// normal
normals->next() = {0, 0, 1};
// uvs
float uvx = (x / radius + 1) / 2;
float uvy = (y / radius + 1) / 2;
uvs->next() = {uvx, uvy};
}
// indices
for (uint32_t i = 1; i <= segments; i ++ ) {
indices->next() = i;
indices->next() = i + 1;
indices->next() = 0u;
}
setIndex(indices);
setPosition(vertices);
setNormal(normals);
setUV(uvs);
}
}
}
} | [
"c.sell@byterefinery.de"
] | c.sell@byterefinery.de |
714e009aab68d78124b5247e8b76942e4f42a63a | e60ca08722245d732f86701cf28b581ac5eeb737 | /xbmc/addons/Visualisation.cpp | 4b2eccb55166f1561d96a457f2bee1c81fd9a0b0 | [] | no_license | paulopina21/plxJukebox-11 | 6d915e60b3890ce01bc8a9e560342c982f32fbc7 | 193996ac99b99badab3a1d422806942afca2ad01 | refs/heads/master | 2020-04-09T13:31:35.220058 | 2013-02-06T17:31:23 | 2013-02-06T17:31:23 | 8,056,228 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,938 | cpp |
#include "system.h"
#include "Visualisation.h"
#include "utils/fft.h"
#include "GUIInfoManager.h"
#include "Application.h"
#include "music/tags/MusicInfoTag.h"
#include "settings/Settings.h"
#include "windowing/WindowingFactory.h"
#include "utils/URIUtils.h"
#ifdef _LINUX
#include <dlfcn.h>
#include "filesystem/SpecialProtocol.h"
#endif
using namespace std;
using namespace MUSIC_INFO;
using namespace ADDON;
CAudioBuffer::CAudioBuffer(int iSize)
{
m_iLen = iSize;
m_pBuffer = new short[iSize];
}
CAudioBuffer::~CAudioBuffer()
{
delete [] m_pBuffer;
}
const short* CAudioBuffer::Get() const
{
return m_pBuffer;
}
void CAudioBuffer::Set(const unsigned char* psBuffer, int iSize, int iBitsPerSample)
{
if (iSize<0)
{
return;
}
if (iBitsPerSample == 16)
{
iSize /= 2;
for (int i = 0; i < iSize && i < m_iLen; i++)
{ // 16 bit -> convert to short directly
m_pBuffer[i] = ((short *)psBuffer)[i];
}
}
else if (iBitsPerSample == 8)
{
for (int i = 0; i < iSize && i < m_iLen; i++)
{ // 8 bit -> convert to signed short by multiplying by 256
m_pBuffer[i] = ((short)((char *)psBuffer)[i]) << 8;
}
}
else // assume 24 bit data
{
iSize /= 3;
for (int i = 0; i < iSize && i < m_iLen; i++)
{ // 24 bit -> ignore least significant byte and convert to signed short
m_pBuffer[i] = (((int)psBuffer[3 * i + 1]) << 0) + (((int)((char *)psBuffer)[3 * i + 2]) << 8);
}
}
for (int i = iSize; i < m_iLen;++i) m_pBuffer[i] = 0;
}
bool CVisualisation::Create(int x, int y, int w, int h)
{
m_pInfo = new VIS_PROPS;
#ifdef HAS_DX
m_pInfo->device = g_Windowing.Get3DDevice();
#else
m_pInfo->device = NULL;
#endif
m_pInfo->x = x;
m_pInfo->y = y;
m_pInfo->width = w;
m_pInfo->height = h;
m_pInfo->pixelRatio = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].fPixelRatio;
m_pInfo->name = strdup(Name().c_str());
m_pInfo->presets = strdup(_P(Path()).c_str());
m_pInfo->profile = strdup(_P(Profile()).c_str());
m_pInfo->submodule = NULL;
if (CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>::Create())
{
// Start the visualisation
CStdString strFile = URIUtils::GetFileName(g_application.CurrentFile());
CLog::Log(LOGDEBUG, "Visualisation::Start()\n");
try
{
m_pStruct->Start(m_iChannels, m_iSamplesPerSec, m_iBitsPerSample, strFile);
}
catch (std::exception e)
{
HandleException(e, "m_pStruct->Start() (CVisualisation::Create)");
return false;
}
GetPresets();
if (GetSubModules())
m_pInfo->submodule = strdup(_P(m_submodules.front()).c_str());
else
m_pInfo->submodule = NULL;
CreateBuffers();
if (g_application.m_pPlayer)
g_application.m_pPlayer->RegisterAudioCallback(this);
return true;
}
return false;
}
void CVisualisation::Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const CStdString strSongName)
{
// notify visz. that new song has been started
// pass it the nr of audio channels, sample rate, bits/sample and offcourse the songname
if (Initialized())
{
try
{
m_pStruct->Start(iChannels, iSamplesPerSec, iBitsPerSample, strSongName.c_str());
}
catch (std::exception e)
{
HandleException(e, "m_pStruct->Start (CVisualisation::Start)");
}
}
}
void CVisualisation::AudioData(const short* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength)
{
// pass audio data to visz.
// audio data: is short audiodata [channel][iAudioDataLength] containing the raw audio data
// iAudioDataLength = length of audiodata array
// pFreqData = fft-ed audio data
// iFreqDataLength = length of pFreqData
if (Initialized())
{
try
{
m_pStruct->AudioData(pAudioData, iAudioDataLength, pFreqData, iFreqDataLength);
}
catch (std::exception e)
{
HandleException(e, "m_pStruct->AudioData (CVisualisation::AudioData)");
}
}
}
void CVisualisation::Render()
{
// ask visz. to render itself
g_graphicsContext.BeginPaint();
if (Initialized())
{
try
{
m_pStruct->Render();
}
catch (std::exception e)
{
HandleException(e, "m_pStruct->Render (CVisualisation::Render)");
}
}
g_graphicsContext.EndPaint();
}
void CVisualisation::Stop()
{
if (g_application.m_pPlayer) g_application.m_pPlayer->UnRegisterAudioCallback();
if (Initialized())
{
CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>::Stop();
}
}
void CVisualisation::GetInfo(VIS_INFO *info)
{
if (Initialized())
{
try
{
m_pStruct->GetInfo(info);
}
catch (std::exception e)
{
HandleException(e, "m_pStruct->GetInfo (CVisualisation::GetInfo)");
}
}
}
bool CVisualisation::OnAction(VIS_ACTION action, void *param)
{
if (!Initialized())
return false;
// see if vis wants to handle the input
// returns false if vis doesnt want the input
// returns true if vis handled the input
try
{
if (action != VIS_ACTION_NONE && m_pStruct->OnAction)
{
// if this is a VIS_ACTION_UPDATE_TRACK action, copy relevant
// tags from CMusicInfoTag to VisTag
if ( action == VIS_ACTION_UPDATE_TRACK && param )
{
const CMusicInfoTag* tag = (const CMusicInfoTag*)param;
VisTrack track;
track.title = tag->GetTitle().c_str();
track.artist = tag->GetArtist().c_str();
track.album = tag->GetAlbum().c_str();
track.albumArtist = tag->GetAlbumArtist().c_str();
track.genre = tag->GetGenre().c_str();
track.comment = tag->GetComment().c_str();
track.lyrics = tag->GetLyrics().c_str();
track.trackNumber = tag->GetTrackNumber();
track.discNumber = tag->GetDiscNumber();
track.duration = tag->GetDuration();
track.year = tag->GetYear();
track.rating = tag->GetRating();
return m_pStruct->OnAction(action, &track);
}
return m_pStruct->OnAction((int)action, param);
}
}
catch (std::exception e)
{
HandleException(e, "m_pStruct->OnAction (CVisualisation::OnAction)");
}
return false;
}
void CVisualisation::OnInitialize(int iChannels, int iSamplesPerSec, int iBitsPerSample)
{
if (!m_pStruct)
return ;
CLog::Log(LOGDEBUG, "OnInitialize() started");
m_iChannels = iChannels;
m_iSamplesPerSec = iSamplesPerSec;
m_iBitsPerSample = iBitsPerSample;
UpdateTrack();
CLog::Log(LOGDEBUG, "OnInitialize() done");
}
void CVisualisation::OnAudioData(const unsigned char* pAudioData, int iAudioDataLength)
{
if (!m_pStruct)
return ;
// FIXME: iAudioDataLength should never be less than 0
if (iAudioDataLength<0)
return;
// Save our audio data in the buffers
auto_ptr<CAudioBuffer> pBuffer ( new CAudioBuffer(2*AUDIO_BUFFER_SIZE) );
pBuffer->Set(pAudioData, iAudioDataLength, m_iBitsPerSample);
m_vecBuffers.push_back( pBuffer.release() );
if ( (int)m_vecBuffers.size() < m_iNumBuffers) return ;
auto_ptr<CAudioBuffer> ptrAudioBuffer ( m_vecBuffers.front() );
m_vecBuffers.pop_front();
// Fourier transform the data if the vis wants it...
if (m_bWantsFreq)
{
// Convert to floats
const short* psAudioData = ptrAudioBuffer->Get();
for (int i = 0; i < 2*AUDIO_BUFFER_SIZE; i++)
{
m_fFreq[i] = (float)psAudioData[i];
}
// FFT the data
twochanwithwindow(m_fFreq, AUDIO_BUFFER_SIZE);
// Normalize the data
float fMinData = (float)AUDIO_BUFFER_SIZE * AUDIO_BUFFER_SIZE * 3 / 8 * 0.5 * 0.5; // 3/8 for the Hann window, 0.5 as minimum amplitude
float fInvMinData = 1.0f/fMinData;
for (int i = 0; i < AUDIO_BUFFER_SIZE + 2; i++)
{
m_fFreq[i] *= fInvMinData;
}
// Transfer data to our visualisation
AudioData(ptrAudioBuffer->Get(), AUDIO_BUFFER_SIZE, m_fFreq, AUDIO_BUFFER_SIZE);
}
else
{ // Transfer data to our visualisation
AudioData(ptrAudioBuffer->Get(), AUDIO_BUFFER_SIZE, NULL, 0);
}
return ;
}
void CVisualisation::CreateBuffers()
{
ClearBuffers();
// Get the number of buffers from the current vis
VIS_INFO info;
m_pStruct->GetInfo(&info);
m_iNumBuffers = info.iSyncDelay + 1;
m_bWantsFreq = (info.bWantsFreq != 0);
if (m_iNumBuffers > MAX_AUDIO_BUFFERS)
m_iNumBuffers = MAX_AUDIO_BUFFERS;
if (m_iNumBuffers < 1)
m_iNumBuffers = 1;
}
void CVisualisation::ClearBuffers()
{
m_bWantsFreq = false;
m_iNumBuffers = 0;
while (m_vecBuffers.size() > 0)
{
CAudioBuffer* pAudioBuffer = m_vecBuffers.front();
delete pAudioBuffer;
m_vecBuffers.pop_front();
}
for (int j = 0; j < AUDIO_BUFFER_SIZE*2; j++)
{
m_fFreq[j] = 0.0f;
}
}
bool CVisualisation::UpdateTrack()
{
bool handled = false;
if (Initialized())
{
// get the current album art filename
m_AlbumThumb = _P(g_infoManager.GetImage(MUSICPLAYER_COVER, WINDOW_INVALID));
// get the current track tag
const CMusicInfoTag* tag = g_infoManager.GetCurrentSongTag();
if (m_AlbumThumb == "DefaultAlbumCover.png")
m_AlbumThumb = "";
else
CLog::Log(LOGDEBUG,"Updating visualisation albumart: %s", m_AlbumThumb.c_str());
// inform the visualisation of the current album art
if (OnAction( VIS_ACTION_UPDATE_ALBUMART, (void*)( m_AlbumThumb.c_str() ) ) )
handled = true;
// inform the visualisation of the current track's tag information
if ( tag && OnAction( VIS_ACTION_UPDATE_TRACK, (void*)tag ) )
handled = true;
}
return handled;
}
bool CVisualisation::GetPresetList(std::vector<CStdString> &vecpresets)
{
vecpresets = m_presets;
return !m_presets.empty();
}
bool CVisualisation::GetPresets()
{
m_presets.clear();
char **presets = NULL;
unsigned int entries = 0;
try
{
entries = m_pStruct->GetPresets(&presets);
}
catch (std::exception e)
{
HandleException(e, "m_pStruct->OnAction (CVisualisation::GetPresets)");
return false;
}
if (presets && entries > 0)
{
for (unsigned i=0; i < entries; i++)
{
if (presets[i])
{
m_presets.push_back(presets[i]);
}
}
}
return (!m_presets.empty());
}
bool CVisualisation::GetSubModuleList(std::vector<CStdString> &vecmodules)
{
vecmodules = m_submodules;
return !m_submodules.empty();
}
bool CVisualisation::GetSubModules()
{
m_submodules.clear();
char **modules = NULL;
unsigned int entries = 0;
try
{
entries = m_pStruct->GetSubModules(&modules);
}
catch (...)
{
CLog::Log(LOGERROR, "Exception in Visualisation::GetSubModules()");
return false;
}
if (modules && entries > 0)
{
for (unsigned i=0; i < entries; i++)
{
if (modules[i])
{
m_submodules.push_back(modules[i]);
}
}
}
return (!m_submodules.empty());
}
CStdString CVisualisation::GetFriendlyName(const CStdString& strVisz,
const CStdString& strSubModule)
{
// should be of the format "moduleName (visName)"
return CStdString(strSubModule + " (" + strVisz + ")");
}
bool CVisualisation::IsLocked()
{
if (!m_presets.empty())
{
if (!m_pStruct)
return false;
return m_pStruct->IsLocked();
}
return false;
}
void CVisualisation::Destroy()
{
// Free what was allocated in method CVisualisation::Create
if (m_pInfo)
{
free((void *) m_pInfo->name);
free((void *) m_pInfo->presets);
free((void *) m_pInfo->profile);
free((void *) m_pInfo->submodule);
delete m_pInfo;
m_pInfo = NULL;
}
CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>::Destroy();
}
unsigned CVisualisation::GetPreset()
{
unsigned index = 0;
try
{
index = m_pStruct->GetPreset();
}
catch(...)
{
return 0;
}
return index;
}
CStdString CVisualisation::GetPresetName()
{
if (!m_presets.empty())
return m_presets[GetPreset()];
else
return "";
}
| [
"pontesmail@gmail.com"
] | pontesmail@gmail.com |
aa19dec96fd2050b6f3801661b62b09fddebe8a1 | ca20c31c2d5e36497a3bf4d67b7c3d4260518f44 | /src/qt/editaddressdialog.cpp | 44b319865b7b11d2f8c9768c7c3dcccecf781523 | [
"MIT"
] | permissive | SamaelDNM/Checoin | 17cdab27490f0b88668655f7a2aa33d15c42ac1f | 1eae885384476f410c4291a243edef82a60932b9 | refs/heads/master | 2020-04-07T15:58:01.636636 | 2018-11-21T08:27:39 | 2018-11-21T08:27:39 | 158,509,366 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,731 | cpp | #include "editaddressdialog.h"
#include "ui_editaddressdialog.h"
#include "addresstablemodel.h"
#include "guiutil.h"
#include <QDataWidgetMapper>
#include <QMessageBox>
EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0)
{
ui->setupUi(this);
GUIUtil::setupAddressWidget(ui->addressEdit, this);
switch(mode)
{
case NewReceivingAddress:
setWindowTitle(tr("New receiving address"));
ui->addressEdit->setEnabled(false);
break;
case NewSendingAddress:
setWindowTitle(tr("New sending address"));
break;
case EditReceivingAddress:
setWindowTitle(tr("Edit receiving address"));
ui->addressEdit->setEnabled(false);
break;
case EditSendingAddress:
setWindowTitle(tr("Edit sending address"));
break;
}
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
}
EditAddressDialog::~EditAddressDialog()
{
delete ui;
}
void EditAddressDialog::setModel(AddressTableModel *model)
{
this->model = model;
if(!model)
return;
mapper->setModel(model);
mapper->addMapping(ui->labelEdit, AddressTableModel::Label);
mapper->addMapping(ui->addressEdit, AddressTableModel::Address);
}
void EditAddressDialog::loadRow(int row)
{
mapper->setCurrentIndex(row);
}
bool EditAddressDialog::saveCurrentRow()
{
if(!model)
return false;
switch(mode)
{
case NewReceivingAddress:
case NewSendingAddress:
address = model->addRow(
mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
ui->labelEdit->text(),
ui->addressEdit->text());
break;
case EditReceivingAddress:
case EditSendingAddress:
if(mapper->submit())
{
address = ui->addressEdit->text();
}
break;
}
return !address.isEmpty();
}
void EditAddressDialog::accept()
{
if(!model)
return;
if(!saveCurrentRow())
{
switch(model->getEditStatus())
{
case AddressTableModel::OK:
// Failed with unknown reason. Just reject.
break;
case AddressTableModel::NO_CHANGES:
// No changes were made during edit operation. Just reject.
break;
case AddressTableModel::INVALID_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is not a valid checoin address.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::DUPLICATE_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::WALLET_UNLOCK_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("Could not unlock wallet."),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::KEY_GENERATION_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("New key generation failed."),
QMessageBox::Ok, QMessageBox::Ok);
break;
}
return;
}
QDialog::accept();
}
QString EditAddressDialog::getAddress() const
{
return address;
}
void EditAddressDialog::setAddress(const QString &address)
{
this->address = address;
ui->addressEdit->setText(address);
}
| [
"samaelnottaro@gmail.com"
] | samaelnottaro@gmail.com |
0e99d072a67123afe74dafc2a299c6c08efca693 | 8bf7addcda783062fed51f386a4dac6ab7ed77a6 | /src/serialize.h | 61c0fa1a3f37d27e481fdf309fb61a77cec607a1 | [
"MIT"
] | permissive | yeahitsme2/HSC2 | f9fc61934fc10f9d8aad7a7a0a717381b22ed0b4 | c7750fa512cfb3584fcee541288ae8f57678f661 | refs/heads/master | 2021-01-09T06:19:34.794125 | 2017-02-05T02:27:53 | 2017-02-05T02:27:53 | 80,841,916 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 41,627 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Copyright (c) 2012 The HSC developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_SERIALIZE_H
#define BITCOIN_SERIALIZE_H
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cassert>
#include <limits>
#include <cstring>
#include <cstdio>
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
#include <boost/tuple/tuple_io.hpp>
#include "allocators.h"
#include "version.h"
typedef long long int64;
typedef unsigned long long uint64;
class CScript;
class CDataStream;
class CAutoFile;
static const unsigned int MAX_SIZE = 0x02000000;
// Used to bypass the rule against non-const reference to temporary
// where it makes sense with wrappers such as CFlatData or CTxDB
template<typename T>
inline T& REF(const T& val)
{
return const_cast<T&>(val);
}
/////////////////////////////////////////////////////////////////
//
// Templates for serializing to anything that looks like a stream,
// i.e. anything that supports .read(char*, int) and .write(char*, int)
//
enum
{
// primary actions
SER_NETWORK = (1 << 0),
SER_DISK = (1 << 1),
SER_GETHASH = (1 << 2),
// modifiers
SER_SKIPSIG = (1 << 16),
SER_BLOCKHEADERONLY = (1 << 17),
};
#define IMPLEMENT_SERIALIZE(statements) \
unsigned int GetSerializeSize(int nType, int nVersion) const \
{ \
CSerActionGetSerializeSize ser_action; \
const bool fGetSize = true; \
const bool fWrite = false; \
const bool fRead = false; \
unsigned int nSerSize = 0; \
ser_streamplaceholder s; \
assert(fGetSize||fWrite||fRead); /* suppress warning */ \
s.nType = nType; \
s.nVersion = nVersion; \
{statements} \
return nSerSize; \
} \
template<typename Stream> \
void Serialize(Stream& s, int nType, int nVersion) const \
{ \
CSerActionSerialize ser_action; \
const bool fGetSize = false; \
const bool fWrite = true; \
const bool fRead = false; \
unsigned int nSerSize = 0; \
assert(fGetSize||fWrite||fRead); /* suppress warning */ \
{statements} \
} \
template<typename Stream> \
void Unserialize(Stream& s, int nType, int nVersion) \
{ \
CSerActionUnserialize ser_action; \
const bool fGetSize = false; \
const bool fWrite = false; \
const bool fRead = true; \
unsigned int nSerSize = 0; \
assert(fGetSize||fWrite||fRead); /* suppress warning */ \
{statements} \
}
#define READWRITE(obj) (nSerSize += ::SerReadWrite(s, (obj), nType, nVersion, ser_action))
//
// Basic types
//
#define WRITEDATA(s, obj) s.write((char*)&(obj), sizeof(obj))
#define READDATA(s, obj) s.read((char*)&(obj), sizeof(obj))
inline unsigned int GetSerializeSize(char a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(signed char a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(unsigned char a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(signed short a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(unsigned short a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(signed int a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(unsigned int a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(signed long a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(unsigned long a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(int64 a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(uint64 a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(float a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(double a, int, int=0) { return sizeof(a); }
template<typename Stream> inline void Serialize(Stream& s, char a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, signed char a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, unsigned char a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, signed short a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, unsigned short a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, signed int a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, unsigned int a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, signed long a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, unsigned long a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, int64 a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, uint64 a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, float a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, double a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, char& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, signed char& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, unsigned char& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, signed short& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, unsigned short& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, signed int& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, unsigned int& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, signed long& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, unsigned long& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, int64& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, uint64& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, float& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, double& a, int, int=0) { READDATA(s, a); }
inline unsigned int GetSerializeSize(bool a, int, int=0) { return sizeof(char); }
template<typename Stream> inline void Serialize(Stream& s, bool a, int, int=0) { char f=a; WRITEDATA(s, f); }
template<typename Stream> inline void Unserialize(Stream& s, bool& a, int, int=0) { char f; READDATA(s, f); a=f; }
#ifndef THROW_WITH_STACKTRACE
#define THROW_WITH_STACKTRACE(exception) \
{ \
LogStackTrace(); \
throw (exception); \
}
void LogStackTrace();
#endif
//
// Compact size
// size < 253 -- 1 byte
// size <= USHRT_MAX -- 3 bytes (253 + 2 bytes)
// size <= UINT_MAX -- 5 bytes (254 + 4 bytes)
// size > UINT_MAX -- 9 bytes (255 + 8 bytes)
//
inline unsigned int GetSizeOfCompactSize(uint64 nSize)
{
if (nSize < 253) return sizeof(unsigned char);
else if (nSize <= std::numeric_limits<unsigned short>::max()) return sizeof(unsigned char) + sizeof(unsigned short);
else if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int);
else return sizeof(unsigned char) + sizeof(uint64);
}
template<typename Stream>
void WriteCompactSize(Stream& os, uint64 nSize)
{
if (nSize < 253)
{
unsigned char chSize = nSize;
WRITEDATA(os, chSize);
}
else if (nSize <= std::numeric_limits<unsigned short>::max())
{
unsigned char chSize = 253;
unsigned short xSize = nSize;
WRITEDATA(os, chSize);
WRITEDATA(os, xSize);
}
else if (nSize <= std::numeric_limits<unsigned int>::max())
{
unsigned char chSize = 254;
unsigned int xSize = nSize;
WRITEDATA(os, chSize);
WRITEDATA(os, xSize);
}
else
{
unsigned char chSize = 255;
uint64 xSize = nSize;
WRITEDATA(os, chSize);
WRITEDATA(os, xSize);
}
return;
}
template<typename Stream>
uint64 ReadCompactSize(Stream& is)
{
unsigned char chSize;
READDATA(is, chSize);
uint64 nSizeRet = 0;
if (chSize < 253)
{
nSizeRet = chSize;
}
else if (chSize == 253)
{
unsigned short xSize;
READDATA(is, xSize);
nSizeRet = xSize;
}
else if (chSize == 254)
{
unsigned int xSize;
READDATA(is, xSize);
nSizeRet = xSize;
}
else
{
uint64 xSize;
READDATA(is, xSize);
nSizeRet = xSize;
}
if (nSizeRet > (uint64)MAX_SIZE)
THROW_WITH_STACKTRACE(std::ios_base::failure("ReadCompactSize() : size too large"));
return nSizeRet;
}
#define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj)))
/** Wrapper for serializing arrays and POD.
* There's a clever template way to make arrays serialize normally, but MSVC6 doesn't support it.
*/
class CFlatData
{
protected:
char* pbegin;
char* pend;
public:
CFlatData(void* pbeginIn, void* pendIn) : pbegin((char*)pbeginIn), pend((char*)pendIn) { }
char* begin() { return pbegin; }
const char* begin() const { return pbegin; }
char* end() { return pend; }
const char* end() const { return pend; }
unsigned int GetSerializeSize(int, int=0) const
{
return pend - pbegin;
}
template<typename Stream>
void Serialize(Stream& s, int, int=0) const
{
s.write(pbegin, pend - pbegin);
}
template<typename Stream>
void Unserialize(Stream& s, int, int=0)
{
s.read(pbegin, pend - pbegin);
}
};
//
// Forward declarations
//
// string
template<typename C> unsigned int GetSerializeSize(const std::basic_string<C>& str, int, int=0);
template<typename Stream, typename C> void Serialize(Stream& os, const std::basic_string<C>& str, int, int=0);
template<typename Stream, typename C> void Unserialize(Stream& is, std::basic_string<C>& str, int, int=0);
// vector
template<typename T, typename A> unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename T, typename A> unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
template<typename T, typename A> inline unsigned int GetSerializeSize(const std::vector<T, A>& v, int nType, int nVersion);
template<typename Stream, typename T, typename A> void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename Stream, typename T, typename A> void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
template<typename Stream, typename T, typename A> inline void Serialize(Stream& os, const std::vector<T, A>& v, int nType, int nVersion);
template<typename Stream, typename T, typename A> void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename Stream, typename T, typename A> void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
template<typename Stream, typename T, typename A> inline void Unserialize(Stream& is, std::vector<T, A>& v, int nType, int nVersion);
// others derived from vector
extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion);
template<typename Stream> void Serialize(Stream& os, const CScript& v, int nType, int nVersion);
template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion);
// pair
template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K, T>& item, int nType, int nVersion);
template<typename Stream, typename K, typename T> void Serialize(Stream& os, const std::pair<K, T>& item, int nType, int nVersion);
template<typename Stream, typename K, typename T> void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion);
// 3 tuple
template<typename T0, typename T1, typename T2> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2>& item, int nType, int nVersion);
template<typename Stream, typename T0, typename T1, typename T2> void Serialize(Stream& os, const boost::tuple<T0, T1, T2>& item, int nType, int nVersion);
template<typename Stream, typename T0, typename T1, typename T2> void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion);
// 4 tuple
template<typename T0, typename T1, typename T2, typename T3> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Serialize(Stream& os, const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Unserialize(Stream& is, boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
// map
template<typename K, typename T, typename Pred, typename A> unsigned int GetSerializeSize(const std::map<K, T, Pred, A>& m, int nType, int nVersion);
template<typename Stream, typename K, typename T, typename Pred, typename A> void Serialize(Stream& os, const std::map<K, T, Pred, A>& m, int nType, int nVersion);
template<typename Stream, typename K, typename T, typename Pred, typename A> void Unserialize(Stream& is, std::map<K, T, Pred, A>& m, int nType, int nVersion);
// set
template<typename K, typename Pred, typename A> unsigned int GetSerializeSize(const std::set<K, Pred, A>& m, int nType, int nVersion);
template<typename Stream, typename K, typename Pred, typename A> void Serialize(Stream& os, const std::set<K, Pred, A>& m, int nType, int nVersion);
template<typename Stream, typename K, typename Pred, typename A> void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion);
//
// If none of the specialized versions above matched, default to calling member function.
// "int nType" is changed to "long nType" to keep from getting an ambiguous overload error.
// The compiler will only cast int to long if none of the other templates matched.
// Thanks to Boost serialization for this idea.
//
template<typename T>
inline unsigned int GetSerializeSize(const T& a, long nType, int nVersion)
{
return a.GetSerializeSize((int)nType, nVersion);
}
template<typename Stream, typename T>
inline void Serialize(Stream& os, const T& a, long nType, int nVersion)
{
a.Serialize(os, (int)nType, nVersion);
}
template<typename Stream, typename T>
inline void Unserialize(Stream& is, T& a, long nType, int nVersion)
{
a.Unserialize(is, (int)nType, nVersion);
}
//
// string
//
template<typename C>
unsigned int GetSerializeSize(const std::basic_string<C>& str, int, int)
{
return GetSizeOfCompactSize(str.size()) + str.size() * sizeof(str[0]);
}
template<typename Stream, typename C>
void Serialize(Stream& os, const std::basic_string<C>& str, int, int)
{
WriteCompactSize(os, str.size());
if (!str.empty())
os.write((char*)&str[0], str.size() * sizeof(str[0]));
}
template<typename Stream, typename C>
void Unserialize(Stream& is, std::basic_string<C>& str, int, int)
{
unsigned int nSize = ReadCompactSize(is);
str.resize(nSize);
if (nSize != 0)
is.read((char*)&str[0], nSize * sizeof(str[0]));
}
//
// vector
//
template<typename T, typename A>
unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&)
{
return (GetSizeOfCompactSize(v.size()) + v.size() * sizeof(T));
}
template<typename T, typename A>
unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&)
{
unsigned int nSize = GetSizeOfCompactSize(v.size());
for (typename std::vector<T, A>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
nSize += GetSerializeSize((*vi), nType, nVersion);
return nSize;
}
template<typename T, typename A>
inline unsigned int GetSerializeSize(const std::vector<T, A>& v, int nType, int nVersion)
{
return GetSerializeSize_impl(v, nType, nVersion, boost::is_fundamental<T>());
}
template<typename Stream, typename T, typename A>
void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&)
{
WriteCompactSize(os, v.size());
if (!v.empty())
os.write((char*)&v[0], v.size() * sizeof(T));
}
template<typename Stream, typename T, typename A>
void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&)
{
WriteCompactSize(os, v.size());
for (typename std::vector<T, A>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
::Serialize(os, (*vi), nType, nVersion);
}
template<typename Stream, typename T, typename A>
inline void Serialize(Stream& os, const std::vector<T, A>& v, int nType, int nVersion)
{
Serialize_impl(os, v, nType, nVersion, boost::is_fundamental<T>());
}
template<typename Stream, typename T, typename A>
void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&)
{
// Limit size per read so bogus size value won't cause out of memory
v.clear();
unsigned int nSize = ReadCompactSize(is);
unsigned int i = 0;
while (i < nSize)
{
unsigned int blk = std::min(nSize - i, (unsigned int)(1 + 4999999 / sizeof(T)));
v.resize(i + blk);
is.read((char*)&v[i], blk * sizeof(T));
i += blk;
}
}
template<typename Stream, typename T, typename A>
void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&)
{
v.clear();
unsigned int nSize = ReadCompactSize(is);
unsigned int i = 0;
unsigned int nMid = 0;
while (nMid < nSize)
{
nMid += 5000000 / sizeof(T);
if (nMid > nSize)
nMid = nSize;
v.resize(nMid);
for (; i < nMid; i++)
Unserialize(is, v[i], nType, nVersion);
}
}
template<typename Stream, typename T, typename A>
inline void Unserialize(Stream& is, std::vector<T, A>& v, int nType, int nVersion)
{
Unserialize_impl(is, v, nType, nVersion, boost::is_fundamental<T>());
}
//
// others derived from vector
//
inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion)
{
return GetSerializeSize((const std::vector<unsigned char>&)v, nType, nVersion);
}
template<typename Stream>
void Serialize(Stream& os, const CScript& v, int nType, int nVersion)
{
Serialize(os, (const std::vector<unsigned char>&)v, nType, nVersion);
}
template<typename Stream>
void Unserialize(Stream& is, CScript& v, int nType, int nVersion)
{
Unserialize(is, (std::vector<unsigned char>&)v, nType, nVersion);
}
//
// pair
//
template<typename K, typename T>
unsigned int GetSerializeSize(const std::pair<K, T>& item, int nType, int nVersion)
{
return GetSerializeSize(item.first, nType, nVersion) + GetSerializeSize(item.second, nType, nVersion);
}
template<typename Stream, typename K, typename T>
void Serialize(Stream& os, const std::pair<K, T>& item, int nType, int nVersion)
{
Serialize(os, item.first, nType, nVersion);
Serialize(os, item.second, nType, nVersion);
}
template<typename Stream, typename K, typename T>
void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion)
{
Unserialize(is, item.first, nType, nVersion);
Unserialize(is, item.second, nType, nVersion);
}
//
// 3 tuple
//
template<typename T0, typename T1, typename T2>
unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2>& item, int nType, int nVersion)
{
unsigned int nSize = 0;
nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion);
nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion);
nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion);
return nSize;
}
template<typename Stream, typename T0, typename T1, typename T2>
void Serialize(Stream& os, const boost::tuple<T0, T1, T2>& item, int nType, int nVersion)
{
Serialize(os, boost::get<0>(item), nType, nVersion);
Serialize(os, boost::get<1>(item), nType, nVersion);
Serialize(os, boost::get<2>(item), nType, nVersion);
}
template<typename Stream, typename T0, typename T1, typename T2>
void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion)
{
Unserialize(is, boost::get<0>(item), nType, nVersion);
Unserialize(is, boost::get<1>(item), nType, nVersion);
Unserialize(is, boost::get<2>(item), nType, nVersion);
}
//
// 4 tuple
//
template<typename T0, typename T1, typename T2, typename T3>
unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)
{
unsigned int nSize = 0;
nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion);
nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion);
nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion);
nSize += GetSerializeSize(boost::get<3>(item), nType, nVersion);
return nSize;
}
template<typename Stream, typename T0, typename T1, typename T2, typename T3>
void Serialize(Stream& os, const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)
{
Serialize(os, boost::get<0>(item), nType, nVersion);
Serialize(os, boost::get<1>(item), nType, nVersion);
Serialize(os, boost::get<2>(item), nType, nVersion);
Serialize(os, boost::get<3>(item), nType, nVersion);
}
template<typename Stream, typename T0, typename T1, typename T2, typename T3>
void Unserialize(Stream& is, boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)
{
Unserialize(is, boost::get<0>(item), nType, nVersion);
Unserialize(is, boost::get<1>(item), nType, nVersion);
Unserialize(is, boost::get<2>(item), nType, nVersion);
Unserialize(is, boost::get<3>(item), nType, nVersion);
}
//
// map
//
template<typename K, typename T, typename Pred, typename A>
unsigned int GetSerializeSize(const std::map<K, T, Pred, A>& m, int nType, int nVersion)
{
unsigned int nSize = GetSizeOfCompactSize(m.size());
for (typename std::map<K, T, Pred, A>::const_iterator mi = m.begin(); mi != m.end(); ++mi)
nSize += GetSerializeSize((*mi), nType, nVersion);
return nSize;
}
template<typename Stream, typename K, typename T, typename Pred, typename A>
void Serialize(Stream& os, const std::map<K, T, Pred, A>& m, int nType, int nVersion)
{
WriteCompactSize(os, m.size());
for (typename std::map<K, T, Pred, A>::const_iterator mi = m.begin(); mi != m.end(); ++mi)
Serialize(os, (*mi), nType, nVersion);
}
template<typename Stream, typename K, typename T, typename Pred, typename A>
void Unserialize(Stream& is, std::map<K, T, Pred, A>& m, int nType, int nVersion)
{
m.clear();
unsigned int nSize = ReadCompactSize(is);
typename std::map<K, T, Pred, A>::iterator mi = m.begin();
for (unsigned int i = 0; i < nSize; i++)
{
std::pair<K, T> item;
Unserialize(is, item, nType, nVersion);
mi = m.insert(mi, item);
}
}
//
// set
//
template<typename K, typename Pred, typename A>
unsigned int GetSerializeSize(const std::set<K, Pred, A>& m, int nType, int nVersion)
{
unsigned int nSize = GetSizeOfCompactSize(m.size());
for (typename std::set<K, Pred, A>::const_iterator it = m.begin(); it != m.end(); ++it)
nSize += GetSerializeSize((*it), nType, nVersion);
return nSize;
}
template<typename Stream, typename K, typename Pred, typename A>
void Serialize(Stream& os, const std::set<K, Pred, A>& m, int nType, int nVersion)
{
WriteCompactSize(os, m.size());
for (typename std::set<K, Pred, A>::const_iterator it = m.begin(); it != m.end(); ++it)
Serialize(os, (*it), nType, nVersion);
}
template<typename Stream, typename K, typename Pred, typename A>
void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion)
{
m.clear();
unsigned int nSize = ReadCompactSize(is);
typename std::set<K, Pred, A>::iterator it = m.begin();
for (unsigned int i = 0; i < nSize; i++)
{
K key;
Unserialize(is, key, nType, nVersion);
it = m.insert(it, key);
}
}
//
// Support for IMPLEMENT_SERIALIZE and READWRITE macro
//
class CSerActionGetSerializeSize { };
class CSerActionSerialize { };
class CSerActionUnserialize { };
template<typename Stream, typename T>
inline unsigned int SerReadWrite(Stream& s, const T& obj, int nType, int nVersion, CSerActionGetSerializeSize ser_action)
{
return ::GetSerializeSize(obj, nType, nVersion);
}
template<typename Stream, typename T>
inline unsigned int SerReadWrite(Stream& s, const T& obj, int nType, int nVersion, CSerActionSerialize ser_action)
{
::Serialize(s, obj, nType, nVersion);
return 0;
}
template<typename Stream, typename T>
inline unsigned int SerReadWrite(Stream& s, T& obj, int nType, int nVersion, CSerActionUnserialize ser_action)
{
::Unserialize(s, obj, nType, nVersion);
return 0;
}
struct ser_streamplaceholder
{
int nType;
int nVersion;
};
/** Double ended buffer combining vector and stream-like interfaces.
*
* >> and << read and write unformatted data using the above serialization templates.
* Fills with data in linear time; some stringstream implementations take N^2 time.
*/
class CDataStream
{
protected:
typedef std::vector<char, zero_after_free_allocator<char> > vector_type;
vector_type vch;
unsigned int nReadPos;
short state;
short exceptmask;
public:
int nType;
int nVersion;
typedef vector_type::allocator_type allocator_type;
typedef vector_type::size_type size_type;
typedef vector_type::difference_type difference_type;
typedef vector_type::reference reference;
typedef vector_type::const_reference const_reference;
typedef vector_type::value_type value_type;
typedef vector_type::iterator iterator;
typedef vector_type::const_iterator const_iterator;
typedef vector_type::reverse_iterator reverse_iterator;
explicit CDataStream(int nTypeIn, int nVersionIn)
{
Init(nTypeIn, nVersionIn);
}
CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend)
{
Init(nTypeIn, nVersionIn);
}
#if !defined(_MSC_VER) || _MSC_VER >= 1300
CDataStream(const char* pbegin, const char* pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend)
{
Init(nTypeIn, nVersionIn);
}
#endif
CDataStream(const vector_type& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
CDataStream(const std::vector<char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
{
Init(nTypeIn, nVersionIn);
}
void Init(int nTypeIn, int nVersionIn)
{
nReadPos = 0;
nType = nTypeIn;
nVersion = nVersionIn;
state = 0;
exceptmask = std::ios::badbit | std::ios::failbit;
}
CDataStream& operator+=(const CDataStream& b)
{
vch.insert(vch.end(), b.begin(), b.end());
return *this;
}
friend CDataStream operator+(const CDataStream& a, const CDataStream& b)
{
CDataStream ret = a;
ret += b;
return (ret);
}
std::string str() const
{
return (std::string(begin(), end()));
}
//
// Vector subset
//
const_iterator begin() const { return vch.begin() + nReadPos; }
iterator begin() { return vch.begin() + nReadPos; }
const_iterator end() const { return vch.end(); }
iterator end() { return vch.end(); }
size_type size() const { return vch.size() - nReadPos; }
bool empty() const { return vch.size() == nReadPos; }
void resize(size_type n, value_type c=0) { vch.resize(n + nReadPos, c); }
void reserve(size_type n) { vch.reserve(n + nReadPos); }
const_reference operator[](size_type pos) const { return vch[pos + nReadPos]; }
reference operator[](size_type pos) { return vch[pos + nReadPos]; }
void clear() { vch.clear(); nReadPos = 0; }
iterator insert(iterator it, const char& x=char()) { return vch.insert(it, x); }
void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); }
void insert(iterator it, const_iterator first, const_iterator last)
{
if (it == vch.begin() + nReadPos && last - first <= nReadPos)
{
// special case for inserting at the front when there's room
nReadPos -= (last - first);
memcpy(&vch[nReadPos], &first[0], last - first);
}
else
vch.insert(it, first, last);
}
void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last)
{
if (it == vch.begin() + nReadPos && last - first <= nReadPos)
{
// special case for inserting at the front when there's room
nReadPos -= (last - first);
memcpy(&vch[nReadPos], &first[0], last - first);
}
else
vch.insert(it, first, last);
}
#if !defined(_MSC_VER) || _MSC_VER >= 1300
void insert(iterator it, const char* first, const char* last)
{
if (it == vch.begin() + nReadPos && last - first <= nReadPos)
{
// special case for inserting at the front when there's room
nReadPos -= (last - first);
memcpy(&vch[nReadPos], &first[0], last - first);
}
else
vch.insert(it, first, last);
}
#endif
iterator erase(iterator it)
{
if (it == vch.begin() + nReadPos)
{
// special case for erasing from the front
if (++nReadPos >= vch.size())
{
// whenever we reach the end, we take the opportunity to clear the buffer
nReadPos = 0;
return vch.erase(vch.begin(), vch.end());
}
return vch.begin() + nReadPos;
}
else
return vch.erase(it);
}
iterator erase(iterator first, iterator last)
{
if (first == vch.begin() + nReadPos)
{
// special case for erasing from the front
if (last == vch.end())
{
nReadPos = 0;
return vch.erase(vch.begin(), vch.end());
}
else
{
nReadPos = (last - vch.begin());
return last;
}
}
else
return vch.erase(first, last);
}
inline void Compact()
{
vch.erase(vch.begin(), vch.begin() + nReadPos);
nReadPos = 0;
}
bool Rewind(size_type n)
{
// Rewind by n characters if the buffer hasn't been compacted yet
if (n > nReadPos)
return false;
nReadPos -= n;
return true;
}
//
// Stream subset
//
void setstate(short bits, const char* psz)
{
state |= bits;
if (state & exceptmask)
THROW_WITH_STACKTRACE(std::ios_base::failure(psz));
}
bool eof() const { return size() == 0; }
bool fail() const { return state & (std::ios::badbit | std::ios::failbit); }
bool good() const { return !eof() && (state == 0); }
void clear(short n) { state = n; } // name conflict with vector clear()
short exceptions() { return exceptmask; }
short exceptions(short mask) { short prev = exceptmask; exceptmask = mask; setstate(0, "CDataStream"); return prev; }
CDataStream* rdbuf() { return this; }
int in_avail() { return size(); }
void SetType(int n) { nType = n; }
int GetType() { return nType; }
void SetVersion(int n) { nVersion = n; }
int GetVersion() { return nVersion; }
void ReadVersion() { *this >> nVersion; }
void WriteVersion() { *this << nVersion; }
CDataStream& read(char* pch, int nSize)
{
// Read from the beginning of the buffer
assert(nSize >= 0);
unsigned int nReadPosNext = nReadPos + nSize;
if (nReadPosNext >= vch.size())
{
if (nReadPosNext > vch.size())
{
setstate(std::ios::failbit, "CDataStream::read() : end of data");
memset(pch, 0, nSize);
nSize = vch.size() - nReadPos;
}
memcpy(pch, &vch[nReadPos], nSize);
nReadPos = 0;
vch.clear();
return (*this);
}
memcpy(pch, &vch[nReadPos], nSize);
nReadPos = nReadPosNext;
return (*this);
}
CDataStream& ignore(int nSize)
{
// Ignore from the beginning of the buffer
assert(nSize >= 0);
unsigned int nReadPosNext = nReadPos + nSize;
if (nReadPosNext >= vch.size())
{
if (nReadPosNext > vch.size())
{
setstate(std::ios::failbit, "CDataStream::ignore() : end of data");
nSize = vch.size() - nReadPos;
}
nReadPos = 0;
vch.clear();
return (*this);
}
nReadPos = nReadPosNext;
return (*this);
}
CDataStream& write(const char* pch, int nSize)
{
// Write to the end of the buffer
assert(nSize >= 0);
vch.insert(vch.end(), pch, pch + nSize);
return (*this);
}
template<typename Stream>
void Serialize(Stream& s, int nType, int nVersion) const
{
// Special case: stream << stream concatenates like stream += stream
if (!vch.empty())
s.write((char*)&vch[0], vch.size() * sizeof(vch[0]));
}
template<typename T>
unsigned int GetSerializeSize(const T& obj)
{
// Tells the size of the object if serialized to this stream
return ::GetSerializeSize(obj, nType, nVersion);
}
template<typename T>
CDataStream& operator<<(const T& obj)
{
// Serialize to this stream
::Serialize(*this, obj, nType, nVersion);
return (*this);
}
template<typename T>
CDataStream& operator>>(T& obj)
{
// Unserialize from this stream
::Unserialize(*this, obj, nType, nVersion);
return (*this);
}
};
#ifdef TESTCDATASTREAM
// VC6sp6
// CDataStream:
// n=1000 0 seconds
// n=2000 0 seconds
// n=4000 0 seconds
// n=8000 0 seconds
// n=16000 0 seconds
// n=32000 0 seconds
// n=64000 1 seconds
// n=128000 1 seconds
// n=256000 2 seconds
// n=512000 4 seconds
// n=1024000 8 seconds
// n=2048000 16 seconds
// n=4096000 32 seconds
// stringstream:
// n=1000 1 seconds
// n=2000 1 seconds
// n=4000 13 seconds
// n=8000 87 seconds
// n=16000 400 seconds
// n=32000 1660 seconds
// n=64000 6749 seconds
// n=128000 27241 seconds
// n=256000 109804 seconds
#include <iostream>
int main(int argc, char *argv[])
{
vector<unsigned char> vch(0xcc, 250);
printf("CDataStream:\n");
for (int n = 1000; n <= 4500000; n *= 2)
{
CDataStream ss;
time_t nStart = time(NULL);
for (int i = 0; i < n; i++)
ss.write((char*)&vch[0], vch.size());
printf("n=%-10d %d seconds\n", n, time(NULL) - nStart);
}
printf("stringstream:\n");
for (int n = 1000; n <= 4500000; n *= 2)
{
stringstream ss;
time_t nStart = time(NULL);
for (int i = 0; i < n; i++)
ss.write((char*)&vch[0], vch.size());
printf("n=%-10d %d seconds\n", n, time(NULL) - nStart);
}
}
#endif
/** RAII wrapper for FILE*.
*
* Will automatically close the file when it goes out of scope if not null.
* If you're returning the file pointer, return file.release().
* If you need to close the file early, use file.fclose() instead of fclose(file).
*/
class CAutoFile
{
protected:
FILE* file;
short state;
short exceptmask;
public:
int nType;
int nVersion;
CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn)
{
file = filenew;
nType = nTypeIn;
nVersion = nVersionIn;
state = 0;
exceptmask = std::ios::badbit | std::ios::failbit;
}
~CAutoFile()
{
fclose();
}
void fclose()
{
if (file != NULL && file != stdin && file != stdout && file != stderr)
::fclose(file);
file = NULL;
}
FILE* release() { FILE* ret = file; file = NULL; return ret; }
operator FILE*() { return file; }
FILE* operator->() { return file; }
FILE& operator*() { return *file; }
FILE** operator&() { return &file; }
FILE* operator=(FILE* pnew) { return file = pnew; }
bool operator!() { return (file == NULL); }
//
// Stream subset
//
void setstate(short bits, const char* psz)
{
state |= bits;
if (state & exceptmask)
THROW_WITH_STACKTRACE(std::ios_base::failure(psz));
}
bool fail() const { return state & (std::ios::badbit | std::ios::failbit); }
bool good() const { return state == 0; }
void clear(short n = 0) { state = n; }
short exceptions() { return exceptmask; }
short exceptions(short mask) { short prev = exceptmask; exceptmask = mask; setstate(0, "CAutoFile"); return prev; }
void SetType(int n) { nType = n; }
int GetType() { return nType; }
void SetVersion(int n) { nVersion = n; }
int GetVersion() { return nVersion; }
void ReadVersion() { *this >> nVersion; }
void WriteVersion() { *this << nVersion; }
CAutoFile& read(char* pch, size_t nSize)
{
if (!file)
throw std::ios_base::failure("CAutoFile::read : file handle is NULL");
if (fread(pch, 1, nSize, file) != nSize)
setstate(std::ios::failbit, feof(file) ? "CAutoFile::read : end of file" : "CAutoFile::read : fread failed");
return (*this);
}
CAutoFile& write(const char* pch, size_t nSize)
{
if (!file)
throw std::ios_base::failure("CAutoFile::write : file handle is NULL");
if (fwrite(pch, 1, nSize, file) != nSize)
setstate(std::ios::failbit, "CAutoFile::write : write failed");
return (*this);
}
template<typename T>
unsigned int GetSerializeSize(const T& obj)
{
// Tells the size of the object if serialized to this stream
return ::GetSerializeSize(obj, nType, nVersion);
}
template<typename T>
CAutoFile& operator<<(const T& obj)
{
// Serialize to this stream
if (!file)
throw std::ios_base::failure("CAutoFile::operator<< : file handle is NULL");
::Serialize(*this, obj, nType, nVersion);
return (*this);
}
template<typename T>
CAutoFile& operator>>(T& obj)
{
// Unserialize from this stream
if (!file)
throw std::ios_base::failure("CAutoFile::operator>> : file handle is NULL");
::Unserialize(*this, obj, nType, nVersion);
return (*this);
}
};
#endif
| [
"seymour40@ymail.com"
] | seymour40@ymail.com |
0202e0e6a0dbdf48e53e694f04960863288675ec | cf05db386f1495272f3adcb07342d0fe57894d40 | /stdafx.cpp | f7e806258c35122ee28d7cba93516ab2faa28a08 | [] | no_license | bmoretz/UUID | ba13e630444ab95d31d5aa046930ad70a959e5c6 | 657133e2027c4f8d2c024a9b5944af1e468d1d9f | refs/heads/master | 2016-09-05T14:46:53.066808 | 2013-01-23T01:04:27 | 2013-01-23T01:04:27 | 7,764,678 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 54 | cpp | #include "stdafx.h"
CRITICAL_SECTION CriticalSection; | [
"bmoretz@ionicsolutions.net"
] | bmoretz@ionicsolutions.net |
de419dc40fd536c24e4689dc631cab5b6ac56855 | 99edb32be409ad0814ca7c4f21f2f0868df4daa2 | /qmlstring.h | 095e40fde8a51127dc51d52dbd35cc74887c5cb2 | [] | no_license | matteosan1/mercante_in_fiera | 74aeefbdd99430f2daa925cdd7558c91c0f7978e | fd83f5d8d82d0ea64cb2f84d33eecdeaf77ab08b | refs/heads/master | 2021-09-02T09:31:48.698233 | 2018-01-01T12:56:08 | 2018-01-01T12:56:08 | 115,918,869 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 554 | h | #ifndef QMLSTRING_H
#define QMLSTRING_H
#include <QObject>
class QmlString : public QObject
{
Q_OBJECT
Q_PROPERTY(QString string READ string WRITE setstring NOTIFY stringChanged)
public:
QmlString(const QString& string, QObject* parent = 0);
void setstring(const QString &a) {
if (a != m_string) {
m_string = a;
emit stringChanged();
}
}
QString string() const {
return m_string;
}
signals:
void stringChanged();
private:
QString m_string;
};
#endif // QMLSTRING_H
| [
"matteosan1@gmail.com"
] | matteosan1@gmail.com |
2069f66aae376b09638049d230aaa3bdecb3a94b | db73d139f8670c0a51ce49c449f087fc69031b50 | /customDelegate/drag_drop.cpp | 8b301a9bc4a50b0a0a90230e5f264e81aae30eca | [] | no_license | cantren/blogCodes2 | b7c6b14540bfd51b96065d7045da6058a18699f0 | fdb1154b38c2e69d2c6d95c276c50dc378101d9c | refs/heads/master | 2021-01-21T09:53:17.511608 | 2015-03-01T07:10:28 | 2015-03-01T07:10:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,476 | cpp | #include "drag_drop.hpp"
#include "ui_drag_drop.h"
#include <QDebug>
drag_drop::drag_drop(QWidget *parent) :
QDialog(parent),
left_model_(QStringList()<<"baba"<<"doremi"<<"onpu"<<"majo rika"),
right_model_(QStringList()<<"dojimi"<<"hana"<<"terry"<<"kimi"<<"nana"),
ui(new Ui::drag_drop)
{
ui->setupUi(this);
ui->listViewLeft->setModel(&left_model_);
ui->listViewRight->setModel(&right_model_);
ui->listViewLeft->set_name("list view left");
ui->listViewRight->set_name("list view right");
ui->listViewLeft->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui->listViewRight->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui->listViewLeft->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listViewLeft, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(handle_custom_context(QPoint)));
connect(ui->listViewLeft,
SIGNAL(my_drop_action(int,QModelIndex,QStringList)),
this,
SLOT(drop_action_from_left(int,QModelIndex,QStringList)));
connect(ui->listViewRight,
SIGNAL(my_drop_action(int,QModelIndex,QStringList)),
this,
SLOT(drop_action_from_right(int,QModelIndex,QStringList)));
}
drag_drop::~drag_drop()
{
delete ui;
}
void drag_drop::on_pushButtonPrint_clicked()
{
left_model_.setStringList(QStringList()<<"baba"<<"doremi"<<"onpu"<<"majo rika");
right_model_.setStringList(QStringList()<<"dojimi"<<"hana"<<"terry"<<"kimi"<<"nana");
}
void drag_drop::drop_action_from_left(int row,
QModelIndex const &target,
QStringList const &text)
{
qDebug()<<__FUNCTION__;
drop_action_impl(row, target, text, left_model_);
}
void drag_drop::drop_action_from_right(int row,
QModelIndex const &target,
QStringList const &text)
{
qDebug()<<__FUNCTION__;
drop_action_impl(row, target, text, right_model_);
}
void drag_drop::handle_custom_context(const QPoint &point)
{
qDebug()<<point;
}
void drag_drop::drop_action_impl(int row,
const QModelIndex &target,
const QStringList &text,
QStringListModel &model)
{
qDebug()<<"source row : "<<row;
qDebug()<<"drop impl";
if(target.isValid()){
if(row >= target.row()){
qDebug()<<"row >= target.row";
int target_row = target.row();
model.insertRows(target.row(), text.size());
for(int i = 0; i != text.size(); ++i){
model.setData(model.index(target_row, 0), text[i]);
++target_row;
}
}else if(row < target.row()){
qDebug()<<"row < target.row";
int target_row = target.row() + 1;
model.insertRows(target_row, text.size());
for(int i = 0; i != text.size(); ++i){
model.setData(model.index(target_row, 0), text[i]);
++target_row;
}
}
}else{
qDebug()<<"insert data";
int target_row = model.rowCount();
model.insertRows(target_row, text.size());
for(int i = 0; i != text.size(); ++i){
model.setData(model.index(target_row, 0), text[i]);
++target_row;
}
}
}
| [
"stereomatchingkiss@gmail.com"
] | stereomatchingkiss@gmail.com |
7d50bb7d9ac3d25ff14e70185792ca54ad38b013 | d0c82d7665c3b676b56097cfa944abe18f709c7e | /C++相关/catkin_test/af_xinyuan/costmap_2d/include/costmap_2d/range_layer.h | 9077c7d4615d7fa27f48ac4b184def67a94529d3 | [] | no_license | LRoel/collection | 78e7d83e942cfa305105b9584712a9977d0334e9 | 2890ac462c68e3b0f7bf8f30b208bbdc458521ba | refs/heads/master | 2021-05-16T12:29:21.102179 | 2017-05-11T12:56:26 | 2017-05-11T12:56:26 | 105,291,256 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,190 | h | /*********************************************************************
*
* Software License Agreement (BSD License)
*
* Copyright (c) 2008, 2013, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Author: Eitan Marder-Eppstein
* David V. Lu!!
*********************************************************************/
#ifndef COSTMAP_2D_RANGE_LAYER_H_
#define COSTMAP_2D_RANGE_LAYER_H_
#include <ros/ros.h>
#include <costmap_2d/layer.h>
#include <costmap_2d/layered_costmap.h>
#include <costmap_2d/observation_buffer.h>
#include <nav_msgs/OccupancyGrid.h>
#include <sensor_msgs/LaserScan.h>
#include <laser_geometry/laser_geometry.h>
#include <sensor_msgs/PointCloud.h>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/point_cloud_conversion.h>
#include <tf/message_filter.h>
#include <message_filters/subscriber.h>
#include <costmap_2d/RangePluginConfig.h>
#include <dynamic_reconfigure/server.h>
#include <costmap_2d/obstacle_layer.h>
namespace costmap_2d
{
class RangeLayer : public ObstacleLayer
{
public:
virtual void onInitialize();
protected:
virtual void setupDynamicReconfigure(ros::NodeHandle& nh);
private:
void reconfigureCB(costmap_2d::RangePluginConfig &config, uint32_t level);
virtual void raytraceFreespace(const costmap_2d::Observation& clearing_observation,
double* min_x, double* min_y, double* max_x, double* max_y);
dynamic_reconfigure::Server<costmap_2d::RangePluginConfig> *range_dsrv_;
double raytrace_limit_;
};
} // namespace costmap_2d
#endif // COSTMAP_2D_RANGE_LAYER_H_
| [
"lroel@LRMB.local"
] | lroel@LRMB.local |
6bf956fee47b789bc8a25848170d43e2f2294846 | 2cb4e3de24662353e4e0813218d78897965a611e | /WRF工具集合/WRF_Tools_Official/OBSGRID/src/namelist.inc | f3143569fd4a0fa76967408757b237f6dd968b02 | [] | no_license | vyesubabu/Code-Backup | 602296c60c15d1dddf58b8f469910eddc80b1af9 | 36cd64b9edff42948ef8a9cea90dcdbff64e6f45 | refs/heads/master | 2023-08-21T11:26:30.666121 | 2021-09-13T05:45:14 | 2021-09-13T05:45:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,911 | inc | ! Record 1 NAMELIST variables.
INTEGER :: start_year , &
start_month , &
start_day , &
start_hour , &
start_minute , &
start_second , &
end_year , &
end_month , &
end_day , &
end_hour , &
end_minute , &
end_second
INTEGER :: interval
! Record 2 NAMELIST variables.
CHARACTER ( LEN = 132 ) :: fg_filename
CHARACTER ( LEN = 132 ) :: obs_filename
LOGICAL :: trim_domain, remove_unverified_data
INTEGER :: trim_value, grid_id, remove_data_above_qc_flag
! Record 3 NAMELIST variables.
INTEGER :: max_number_of_obs
LOGICAL :: fatal_if_exceed_max_obs
! Record 4 NAMELIST variables.
LOGICAL :: qc_test_error_max , &
qc_test_buddy , &
qc_test_vert_consistency , &
! BPR BEGIN
! qc_test_convective_adj
qc_test_convective_adj , &
qc_psfc
! BPR END
REAL :: max_error_t , &
max_error_uv , &
max_error_z , &
max_error_rh , &
! BPR BEGIN
max_error_dewpoint , &
! BPR END
max_error_p , &
max_buddy_t , &
max_buddy_uv , &
max_buddy_z , &
max_buddy_rh , &
! BPR BEGIN
max_buddy_dewpoint , &
! BPR END
max_buddy_p , &
buddy_weight , &
max_p_extend_t , &
max_p_extend_w
!BPR BEGIN
LOGICAL :: use_p_tolerance_one_lev
INTEGER :: max_p_tolerance_one_lev_qc
!BPR END
! Record 5 NAMELIST variables.
LOGICAL :: print_found_obs , &
print_header , &
print_analysis , &
print_qc_vert , &
print_qc_dry , &
print_obs_files , &
print_error_max , &
print_buddy , &
print_oa
! Record 7 NAMELIST variables.
LOGICAL :: use_first_guess , &
f4d , &
lagtem
INTEGER :: intf4d
! Record 8 NAMELIST variables.
INTEGER :: smooth_type , &
smooth_sfc_wind , &
smooth_sfc_temp , &
smooth_sfc_rh , &
smooth_sfc_slp , &
smooth_upper_wind , &
smooth_upper_temp , &
smooth_upper_rh
! Record 9 NAMELIST variables.
CHARACTER ( LEN = 132 ) :: oa_type , oa_3D_type
INTEGER :: mqd_minimum_num_obs , &
mqd_maximum_num_obs
INTEGER , DIMENSION(10) :: radius_influence
LOGICAL :: oa_min_switch , &
oa_max_switch
INTEGER :: oa_3D_option
!BPR BEGIN
LOGICAL :: oa_psfc
LOGICAL :: scale_cressman_rh_decreases
REAL :: radius_influence_sfc_mult
INTEGER :: max_p_tolerance_one_lev_oa
!BPR END
| [
"qqf1403321992@gmail.com"
] | qqf1403321992@gmail.com |
759c79c22ed73fa956d3b4339d4ea978a12602d7 | 85d52657c72a7830dd5357a238f805b520cf4847 | /USACO/2014/feb/COW.cpp | 5c7354b498f8c645a7e0b2208eac16e9d370da12 | [
"MIT"
] | permissive | nalinbhardwaj/olympiad | 7477d789e5249322e7afc96f152bc4cb5b94e810 | 6b640d8cef2fa16fb4e9776f8416575519357edf | refs/heads/master | 2021-01-15T10:42:13.941115 | 2018-04-12T13:32:17 | 2018-04-12T13:32:17 | 99,594,178 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 522 | cpp | /*
PROG: COW
LANG: C++
ID: nibnalin
*/
//USACO February Contest
#include <fstream>
#include <vector>
using namespace std;
int main(void)
{
ios_base::sync_with_stdio(0);
ifstream fin ("cow.in");
ofstream fout ("cow.out");
long long n;
string ins;
fin >> n;
fin >> ins;
vector<long long> combi(3, 0);
for(long long i = 0;i < n;i++)
{
if(ins[i] == 'C')
{
combi[0]++;
}
else if(ins[i] == 'O')
{
combi[1] += combi[0];
}
else
{
combi[2] += combi[1];
}
}
fout << combi[2] << endl;
} | [
"nalin.bhardwaj@icloud.com"
] | nalin.bhardwaj@icloud.com |
19456b13f2f5edeab0a9e0c0d0f1fcef3df6ba60 | a8750439f200e4efc11715df797489f30e9828c6 | /LeetCodeContests/64/753_64_4.cpp | a0afffe2b6ba81dd475a9cc835f054c9d4d7982f | [] | no_license | rajlath/rkl_codes | f657174305dc85c3fa07a6fff1c7c31cfe6e2f89 | d4bcee3df2f501349feed7a26ef9828573aff873 | refs/heads/master | 2023-02-21T10:16:35.800612 | 2021-01-27T11:43:34 | 2021-01-27T11:43:34 | 110,989,354 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,336 | cpp | /*
753. Cracking the Safe My SubmissionsBack to Contest
Difficulty: Hard
There is a box protected by a password. The password is n digits, where each letter can be one of the first k digits
0, 1, ..., k-1.
You can keep inputting the password, the password will automatically be matched against the last n digits entered.
For example, assuming the password is "345", I can open it when I type "012345", but I enter a total of 6 digits.
Please return any string of minimum length that is guaranteed to open the box after the entire string is inputted.
Example 1:
Input: n = 1, k = 2
Output: "01"
Note: "10" will be accepted too.
Example 2:
Input: n = 2, k = 2
Output: "00110"
Note: "01100", "10011", "11001" will be accepted too.
Note:
n will be in the range [1, 4].
k will be in the range [1, 10].
k^n will be at most 4096.
*/
class Solution {
public:
int kn, n, k;
char c[10000];
bool vis[10000];
void dfs(int x, int h)
{
// printf("%s\n", c);
if(x == kn + n - 1) throw 233;
for(int i = 0; i < k; ++i)
{
int t = h * k + i;
if(!vis[t])
{
vis[t] = true;
c[x] = '0' + i;
dfs(x + 1, t % (kn / k));
c[x] = 0;
vis[t] = false;
}
}
}
string crackSafe(int n, int k) {
this->n = n; this->k = k;
kn = 1;
for(int i = 0; i < n; ++i) kn *= k;
memset(vis, 0, sizeof(vis));
memset(c, 0, sizeof(c));
for(int i = 0; i < n - 1; ++i) c[i] = '0';
try
{
dfs(n - 1, 0);
}
catch(int)
{
}
return c;
}
};
class Solution {
public:
string crackSafe(int n, int k) {
string result(n,'0'),s(n-1,'0');
unordered_set<string> hash;
hash.insert(result);
while(1)
{
bool flag=true;
for(int i=k-1;i>=0;i--)
{
char c=i+'0';
if(hash.count(s+c)==0)
{
hash.insert(s+c);
flag=false;
result+=c;
s+=c;
s.erase(s.begin());
break;
}
}
if(flag==true)
return result;
}
}
};
| [
"raj.lath@gmail.com"
] | raj.lath@gmail.com |
83662ddf6e8917e425caf0dff3b64543287afcda | aca4f00c884e1d0e6b2978512e4e08e52eebd6e9 | /2010/srm484/proA/src/proA.cpp | 802c557ed2bece700d9cbade3e43c7d358f77bd3 | [] | no_license | jki14/competitive-programming | 2d28f1ac8c7de62e5e82105ae1eac2b62434e2a4 | ba80bee7827521520eb16a2d151fc0c3ca1f7454 | refs/heads/master | 2023-08-07T19:07:22.894480 | 2023-07-30T12:18:36 | 2023-07-30T12:18:36 | 166,743,930 | 2 | 0 | null | 2021-09-04T09:25:40 | 2019-01-21T03:40:47 | C++ | UTF-8 | C++ | false | false | 3,979 | cpp | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define lim 16
int res[lim]={16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1};
class NumberMagicEasy {
public:
int theNumber(string);
};
int NumberMagicEasy::theNumber(string a) {
int k=0;
for(int i=0;i<4;i++){
k*=2;if(a[i]=='Y')k+=1;
}
return res[k];
}
double test0() {
string p0 = "YNYY";
NumberMagicEasy * obj = new NumberMagicEasy();
clock_t start = clock();
int my_answer = obj->theNumber(p0);
clock_t end = clock();
delete obj;
cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
int p1 = 5;
cout <<"Desired answer: " <<endl;
cout <<"\t" << p1 <<endl;
cout <<"Your answer: " <<endl;
cout <<"\t" << my_answer <<endl;
if (p1 != my_answer) {
cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
return -1;
}
else {
cout <<"Match :-)" <<endl <<endl;
return (double)(end-start)/CLOCKS_PER_SEC;
}
}
double test1() {
string p0 = "YNNN";
NumberMagicEasy * obj = new NumberMagicEasy();
clock_t start = clock();
int my_answer = obj->theNumber(p0);
clock_t end = clock();
delete obj;
cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
int p1 = 8;
cout <<"Desired answer: " <<endl;
cout <<"\t" << p1 <<endl;
cout <<"Your answer: " <<endl;
cout <<"\t" << my_answer <<endl;
if (p1 != my_answer) {
cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
return -1;
}
else {
cout <<"Match :-)" <<endl <<endl;
return (double)(end-start)/CLOCKS_PER_SEC;
}
}
double test2() {
string p0 = "NNNN";
NumberMagicEasy * obj = new NumberMagicEasy();
clock_t start = clock();
int my_answer = obj->theNumber(p0);
clock_t end = clock();
delete obj;
cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
int p1 = 16;
cout <<"Desired answer: " <<endl;
cout <<"\t" << p1 <<endl;
cout <<"Your answer: " <<endl;
cout <<"\t" << my_answer <<endl;
if (p1 != my_answer) {
cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
return -1;
}
else {
cout <<"Match :-)" <<endl <<endl;
return (double)(end-start)/CLOCKS_PER_SEC;
}
}
double test3() {
string p0 = "YYYY";
NumberMagicEasy * obj = new NumberMagicEasy();
clock_t start = clock();
int my_answer = obj->theNumber(p0);
clock_t end = clock();
delete obj;
cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
int p1 = 1;
cout <<"Desired answer: " <<endl;
cout <<"\t" << p1 <<endl;
cout <<"Your answer: " <<endl;
cout <<"\t" << my_answer <<endl;
if (p1 != my_answer) {
cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
return -1;
}
else {
cout <<"Match :-)" <<endl <<endl;
return (double)(end-start)/CLOCKS_PER_SEC;
}
}
double test4() {
string p0 = "NYNY";
NumberMagicEasy * obj = new NumberMagicEasy();
clock_t start = clock();
int my_answer = obj->theNumber(p0);
clock_t end = clock();
delete obj;
cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
int p1 = 11;
cout <<"Desired answer: " <<endl;
cout <<"\t" << p1 <<endl;
cout <<"Your answer: " <<endl;
cout <<"\t" << my_answer <<endl;
if (p1 != my_answer) {
cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
return -1;
}
else {
cout <<"Match :-)" <<endl <<endl;
return (double)(end-start)/CLOCKS_PER_SEC;
}
}
int main() {
int time;
bool errors = false;
time = test0();
if (time < 0)
errors = true;
time = test1();
if (time < 0)
errors = true;
time = test2();
if (time < 0)
errors = true;
time = test3();
if (time < 0)
errors = true;
time = test4();
if (time < 0)
errors = true;
if (!errors)
cout <<"You're a stud (at least on the example cases)!" <<endl;
else
cout <<"Some of the test cases had errors." <<endl;
}
//Powered by [KawigiEdit] 2.0!
| [
"jki14wz@gmail.com"
] | jki14wz@gmail.com |
787a0a895907cf78d1dae5cc132da27f6394ce8e | eacdb2112c5f2251ba7fdcdc30ffec5fb1c40dd5 | /07-01-2/07-01-2/07-01-2.cpp | e77aac528f93a8cfca8e6311ab746dd90042fd9f | [] | no_license | PeriD/alalei | 38630418eb4dcd4888d170b019b348868dcade6f | 54f865ff15b3adc1ac85c677a42777b09bda25f3 | refs/heads/master | 2020-06-11T05:34:00.829137 | 2020-03-05T15:15:08 | 2020-03-05T15:15:08 | 193,864,095 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 720 | cpp | #define _CRT_SECURE_NO_WARNINGS 1
/*#include<iostream>
#include<vector>
using namespace std;
int main(){
char num[10000];
int i = 0;
while (gets(num) != NULL)
{
for (i = 0; i < strlen(num); i++)
{
cin >> num[i];
}
int a, b = 0;
for (int i = 0; i < 10; i++)
{
a = num[i] % 10;
b = num[i] / 10;
int count = a + b;
cout << count;
cout << " ";
}
}
system("pause");
return 0;
}*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int i,num;char str[1005];
while(gets(str)!=NULL && str[0]!='0')
{
num=0;
for(i=0;i<strlen(str);i++)
{
num+=str[i]-'0';
}
printf("%d\n",(num-1)%9+1);
}
system("pause");
return 0;
} | [
"1002906778@qq.com"
] | 1002906778@qq.com |
1385d003aa0733b9c1f49c55ea71049c8da63f67 | 2964b4384e3d45043c1d1e1ec58844e9c595cd9a | /KeyboardInterface/Keyboard.h | 05195686c74f41f164a44810cd9900a436f0bde7 | [] | no_license | logannathanson/Foot-to-Text | 4f15aa4c0e3be48a05f48d8024bbc443bb1112c6 | dede7961aea866182a6789ed1e84eaa0b89ad391 | refs/heads/master | 2021-03-25T02:56:43.243040 | 2017-04-26T17:37:13 | 2017-04-26T17:37:13 | 79,939,634 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 954 | h | #pragma once
#define WINVER 0x0500
#include <windows.h>
#include <WinUser.h>
#include <string>
struct ModifierPkg
{
bool ctrl = false;
bool shift = false;
bool alt = false;
};
class Keyboard
{
public:
struct Key
{
Key(const std::string& key_str);
friend class Keyboard;
private:
SHORT virtual_key;
};
static Keyboard& get_instance();
void send_word(const std::string& word);
void send_shortcut(ModifierPkg mods, Key key);
private:
Keyboard();
void send_char(char c);
void send_newline();
void send_key_down(WORD virtual_key);
void send_key_up(WORD virtual_key);
SHORT get_virtual_key(char c);
class ModifierGuard
{
public:
ModifierGuard(SHORT vk_package);
ModifierGuard(ModifierPkg mods);
~ModifierGuard();
private:
void set_entry_state();
bool is_shift = false;
bool is_ctrl = false;
bool is_alt = false;
};
INPUT input;
};
| [
"aymarino@umich.edu"
] | aymarino@umich.edu |
1d370cf63e23b6fef08dce3c2dcfe7a4f6fafdc7 | 21105b2722cdef7163a3a3bb87c622f1e0803d35 | /1641.cpp | a613c22d6f1dbaba68f1ad7e47bbd39df44c93c9 | [] | no_license | refatulfahad/CSES_problem_solution | 79e6c4a9e6faf3789361b684cc16373f178c140b | f57472c006cbc5f899c0b9a179a16a6816e78269 | refs/heads/master | 2021-07-15T15:17:07.148390 | 2021-02-28T14:25:48 | 2021-02-28T14:25:48 | 240,215,352 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,820 | cpp | #include<bits/stdc++.h>
using namespace std;
const int N=5005;
int ar[N];
pair<int,int>a[N];
int n;
int binarysearch(int l,int r,int val,int i,int j) {
while(l<=r) {
int mid=(l+r)>>1;
if(a[mid].first==val) {
int in1=mid+1,in2=mid-1;
if(a[mid].second!=i&&a[mid].second!=j) {
return a[mid].second;
}
while(a[in1].first==val&&in1<=n) {
if(a[in1].second!=i&&a[in1].second!=j)
return a[in1].second;
in1++;
}
while(a[in2].first==val&&in2>=1) {
if(a[in2].second!=i&&a[in2].second!=j)
return a[in2].second;
in2--;
}
return 0;
} else if(a[mid].first>val) {
r=mid-1;
} else {
l=mid+1;
}
}
return 0;
}
int main() {
int x;
scanf("%d %d",&n,&x);
a[0]= {-1,-1};
a[n+1]= {-1,-1};
for(int i=1; i<=n; i++) {
scanf("%d",&ar[i]);
a[i]= {ar[i],i};
}
sort(a+1,a+n+1);
int half=ceil((double)n/(double)2.0);
int ck=0;
for(int i=1; i<=half; i++) {
for(int j=i+1; j<=half; j++) {
if(x>=ar[i]+ar[j])
ck=binarysearch(1,n,x-ar[i]-ar[j],i,j);
if(ck) {
printf("%d %d %d",i,j,ck);
return 0;
}
}
}
for(int i=half+1; i<=n; i++) {
for(int j=i+1; j<=n; j++) {
if(x>=ar[i]+ar[j])
ck=binarysearch(1,n,x-ar[i]-ar[j],i,j);
if(ck) {
printf("%d %d %d",i,j,ck);
return 0;
}
}
}
printf("IMPOSSIBLE\n");
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
5beaa5a5e06329ec3f67e97e39f7fdddab46ec27 | 15abfc1e458635249d1c082a3ccba68bbfa5f89c | /src/glpp/frame_buffer.cpp | 7c6be5e15a8e5d003fb9c6ca8efefdb9446500ea | [
"MIT"
] | permissive | sque/glpp | 7e301e8ee57e3d91cc70b6823911b1670c938c7d | f2ffee025e4925d9986023bf3a9d1f21687890b8 | refs/heads/master | 2020-04-23T20:59:50.841865 | 2017-02-10T16:46:27 | 2017-02-10T16:46:27 | 8,701,998 | 11 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 4,536 | cpp | /**
* Copyright (c) 2012 Konstantinos Paliouras <squarious _ gmail _dot com>.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "frame_buffer.hpp"
namespace glpp{
frame_buffer_attachment_point::frame_buffer_attachment_point(const frame_buffer * pfbo, fbo_point point) :
mp_fbo(pfbo),
m_point(point){
}
void frame_buffer_attachment_point::attach(shared_texture_t & ptex, int level) {
mp_fbo->bind();
::glFramebufferTexture(GLPP_CAST_TO_SCALAR(GLenum, mp_fbo->target()), GLPP_CAST_TO_SCALAR(GLenum, m_point), ptex->object_name(), level);
}
void frame_buffer_attachment_point::attach(shared_texture_t & ptex, int level, tex2d_update_target tex_target, int layer) {
mp_fbo->bind();
if (ptex->type() == texture_type::TEX_1D) {
::glFramebufferTexture1D(GLPP_CAST_TO_SCALAR(GLenum, mp_fbo->target()), GLPP_CAST_TO_SCALAR(GLenum, m_point), GLPP_CAST_TO_SCALAR(GLenum, tex_target), ptex->object_name(), level);
} else if (ptex->type() == texture_type::TEX_2D) {
::glFramebufferTexture2D(GLPP_CAST_TO_SCALAR(GLenum, mp_fbo->target()), GLPP_CAST_TO_SCALAR(GLenum, m_point), GLPP_CAST_TO_SCALAR(GLenum, tex_target), ptex->object_name(), level);
} else if (ptex->type() == texture_type::TEX_3D) {
::glFramebufferTexture3D(GLPP_CAST_TO_SCALAR(GLenum, mp_fbo->target()), GLPP_CAST_TO_SCALAR(GLenum, m_point), GLPP_CAST_TO_SCALAR(GLenum, tex_target), ptex->object_name(), level, layer);
}
}
void frame_buffer_attachment_point::attach(shared_render_buffer_t prbo) {
mp_fbo->bind();
::glFramebufferRenderbuffer(GLPP_CAST_TO_SCALAR(GLenum, mp_fbo->target()), GLPP_CAST_TO_SCALAR(GLenum, m_point), GL_RENDERBUFFER, prbo->object_name());
}
void frame_buffer_attachment_point::detach() {
mp_fbo->bind();
::glFramebufferRenderbuffer(GLPP_CAST_TO_SCALAR(GLenum, mp_fbo->target()), GLPP_CAST_TO_SCALAR(GLenum, m_point), GL_RENDERBUFFER, 0);
}
void frame_buffer_attachment_point::read_pixels(int x, int y, size_t width, size_t height, pixel_data_format format, fbo_pixel_type pix_type, void * dst) const{
mp_fbo->bind();
::glReadBuffer(GLPP_CAST_TO_SCALAR(GLenum, m_point));
::glReadPixels(x, y, width, height, GLPP_CAST_TO_SCALAR(GLenum, format), GLPP_CAST_TO_SCALAR(GLenum, pix_type), dst);
}
frame_buffer::frame_buffer(frame_buffer_target target) :
m_target(target){
::glGenFramebuffers(1, &m_gl_name);
assert_no_glerror("glGenFramebuffers failed. ");
}
frame_buffer::frame_buffer(name_type name, frame_buffer_target target) :
m_target(target){
m_gl_name = name;
}
frame_buffer::~frame_buffer() {
if (::glIsFramebuffer(object_name()))
::glDeleteFramebuffers(1, &m_gl_name);
}
void frame_buffer::bind() const{
::glBindFramebuffer(GLPP_CAST_TO_SCALAR(GLenum, target()), object_name());
}
shared_frame_buffer_attachment_point_t frame_buffer::point(fbo_point point) {
points_container_type::iterator it;
if ((it = m_points.find(point)) != m_points.end())
return it->second;
return m_points[point] = shared_frame_buffer_attachment_point_t(new frame_buffer_attachment_point(this, point));
}
frame_buffer_status frame_buffer::status() const {
bind();
return GLPP_CAST_TO_SAFE_ENUM(frame_buffer_status, ::glCheckFramebufferStatus(GLPP_CAST_TO_SCALAR(GLenum, target())));
}
const frame_buffer & frame_buffer::window_default() {
if (ms_window_fbo == NULL)
ms_window_fbo = new frame_buffer(0, frame_buffer_target::DRAW);
return *ms_window_fbo;
}
frame_buffer * frame_buffer::ms_window_fbo = NULL;
}
| [
"sque@tolabaki.gr"
] | sque@tolabaki.gr |
743185d75bf6e45f421d24f4bf58caa699eec098 | 0398a11552a502bf01e99835a9e61bf43990260f | /thirdpart/play_plugin/wav_plugin/wav_plugin.cpp | 44f393357236d9e3adab3d118a03acc873790ec8 | [
"BSD-2-Clause",
"MIT"
] | permissive | ren19890419/MyDuiLib | 5384b23ed47dba049285165791e67d196dba06b4 | 23e4af233e8a0ee7b8377d59e0c3cde58ab6e6e7 | refs/heads/master | 2021-03-14T06:23:33.183184 | 2020-01-06T14:53:16 | 2020-01-06T14:53:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,448 | cpp | #include "decoder_plugin.h"
#include <list>
#include <string>
#include <algorithm>
#ifdef _MSC_VER
#include <Windows.h>
#else
#endif
#include "flib.h"
class pcm_data_buf;
struct wav_decoder_data
{
int mn_size;
char buf_head[44];
char buf_data[1024*64];
int nSampleRate;
int byte_read;
int mn_availiable_bytes_count;
__int64 mn_cur_position;
float mf_cur_percent;
bool mb_online;
bool mb_data_completed;
std::list<pcm_data_buf *> m_raw_pcm_data_list;
_FStd(FFile) mh_read;
player_audio_info *mp_audio_info;
};
static decoder_handle wav_open(const char * sz_file_name,bool b_is_online,int nFileType,int nBegin,int nEnd);
static int wav_get_audio_info(decoder_handle handle,struct player_audio_info* p_info);
static int wav_decode_once(decoder_handle handle);
static int wav_get_available_samples_count(decoder_handle handle);
static int wav_get_data(decoder_handle handle,unsigned char *p_data,int n_buf_size);
static int wav_write_data(decoder_handle handle,unsigned char *p_data,int n_buf_size);
static __int64 wav_seek(decoder_handle handle,float f_percent);
static __int64 wav_get_download_data_length(decoder_handle handle);
static __int64 wav_get_current_position(decoder_handle handle);
static bool wav_is_finish(decoder_handle handle);
static void wav_close(decoder_handle handle);
static float wav_get_percent(decoder_handle handle);
static int wav_get_decoder_type();
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void* get_xiami_decoder_proc()
{
decoder_plugin* p_plugin = new decoder_plugin();
p_plugin->n_size = sizeof(decoder_plugin);
p_plugin->open = wav_open;
p_plugin->get_audio_info = wav_get_audio_info;
p_plugin->decode_once = wav_decode_once;
p_plugin->get_available_samples_count = wav_get_available_samples_count;
p_plugin->get_data = wav_get_data;
p_plugin->write_data = wav_write_data;
p_plugin->get_download_data_length = wav_get_download_data_length;
p_plugin->get_current_position = wav_get_current_position;
p_plugin->is_finish = wav_is_finish;
p_plugin->close = wav_close;
p_plugin->seek = wav_seek;
p_plugin->get_percent = wav_get_percent;
p_plugin->get_decoder_type = wav_get_decoder_type;
return p_plugin;
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
class pcm_data_buf
{
private:
int mn_size;
unsigned char * mp_data;
int mn_cur_position;
public:
pcm_data_buf(int n_size)
{
mn_size = n_size;
mp_data = NULL;
mn_cur_position = 0;
if(n_size > 0)
{
mp_data = new unsigned char[n_size];
}
}
~pcm_data_buf()
{
if(mp_data != NULL)
{
delete []mp_data;
mp_data = NULL;
}
}
unsigned char *get_buf()
{
return mp_data;
}
int set_cur_position(int n_pos)
{
return mn_cur_position == n_pos;
}
int get_cur_position(int n_pos)
{
return mn_cur_position ;
}
int copy_data(unsigned char *p_data,int n_size)
{
int n_copy = get_data_size();
if(n_copy > n_size)
{
n_copy = n_size;
}
memcpy(p_data,mp_data + mn_cur_position,n_copy);
mn_cur_position +=n_copy;
return n_copy;
}
int get_data_size()
{
return mn_size - mn_cur_position ;
}
int empty()
{
return mn_cur_position == mn_size;
}
};
static decoder_handle wav_open(const char * sz_file_name,bool is_online,int nFileType,int nBegin,int nEnd)
{
if(sz_file_name == NULL)
return NULL;
std::string s_file_name = sz_file_name;
if (s_file_name.length() < 4)
return NULL;
std::transform(s_file_name.begin(), s_file_name.end(), s_file_name.begin(), ::tolower);
auto pos2 = s_file_name.rfind('.');
std::string ext = pos2 != s_file_name.npos ? s_file_name.substr(pos2) : "";
if (ext != ".wav")
return NULL;
wav_decoder_data *p_decoder_data = new wav_decoder_data();
if(p_decoder_data == NULL)
return NULL;
p_decoder_data->mp_audio_info= new player_audio_info();
if(p_decoder_data->mp_audio_info == NULL)
{
delete p_decoder_data;
return NULL;
}
p_decoder_data->mn_size = sizeof(wav_decoder_data);
memset(p_decoder_data->buf_head,0,sizeof(p_decoder_data->buf_head));
memset(p_decoder_data->buf_data,0,sizeof(p_decoder_data->buf_data));
p_decoder_data->mh_read.Open(sz_file_name, true);
if (!(p_decoder_data->mh_read))
{
delete p_decoder_data;
return NULL;
}
p_decoder_data->mp_audio_info->n_file_size = p_decoder_data->mh_read.GetSize();
long dwRead = p_decoder_data->mh_read.Read(p_decoder_data->buf_head, 44);
if (dwRead < 44)
{
//sLog(_T("%s:锟侥硷拷锟斤拷锟斤拷锟斤拷"),s_file_name.GetBuffer());
p_decoder_data->mh_read.Close();
delete p_decoder_data;
return NULL;
}
if ((p_decoder_data->buf_head[0] != 'R' ||
p_decoder_data->buf_head[1] != 'I' ||
p_decoder_data->buf_head[2] != 'F' ||
p_decoder_data->buf_data[3] != 'F') &&
(p_decoder_data->buf_head[8] != 'W' ||
p_decoder_data->buf_head[9] != 'A' ||
p_decoder_data->buf_head[10] != 'V' ||
p_decoder_data->buf_head[11] != 'E'))
{
//sLog(_T("%s:锟斤拷锟角憋拷准WAV锟侥硷拷"),s_file_name.GetBuffer());
p_decoder_data->mh_read.Close();
delete p_decoder_data;
return NULL;
}
p_decoder_data->mp_audio_info->n_channal = *((p_decoder_data->buf_head)+22);
p_decoder_data->mp_audio_info->n_sample_size_in_bit = *(p_decoder_data->buf_head+34);
if(p_decoder_data->mp_audio_info->n_sample_size_in_bit == 0)
{
p_decoder_data->mh_read.Close();
delete p_decoder_data;
return NULL;
}
p_decoder_data->mh_read.Seek(-20, _FStd(FFile)::ENUM_SEEK::SEEK_FILE_CURRENT);
dwRead = p_decoder_data->mh_read.Read(&p_decoder_data->nSampleRate,sizeof(int));
p_decoder_data->mp_audio_info->n_sample_rate = p_decoder_data->nSampleRate;
p_decoder_data->byte_read = 0;
p_decoder_data->mn_cur_position = 44;
p_decoder_data->mf_cur_percent = 0.0;
if (p_decoder_data->mp_audio_info->n_channal != 0 &&
p_decoder_data->mp_audio_info->n_sample_size_in_bit != 0 &&
p_decoder_data->mp_audio_info->n_sample_rate != 0
)
{
__int64 nTemp1 = ((__int64)p_decoder_data->mp_audio_info->n_file_size - 44) * 8000 ;
p_decoder_data->mp_audio_info->n_total_play_time_in_ms = nTemp1 / (p_decoder_data->mp_audio_info->n_channal * p_decoder_data->mp_audio_info->n_sample_rate * p_decoder_data->mp_audio_info->n_sample_size_in_bit);
}
return p_decoder_data;
}
static int wav_get_audio_info(decoder_handle handle,struct player_audio_info* p_info)
{
if(p_info == NULL)
return DECODER_ERROR;
wav_decoder_data *p_decoder_data = (wav_decoder_data *)handle;
if(p_decoder_data == NULL)
return DECODER_ERROR;
if(p_decoder_data->mp_audio_info == NULL)
{
return DECODER_WAIT;
}
else
{
memcpy(p_info,p_decoder_data->mp_audio_info ,sizeof(struct player_audio_info));
return DECODER_SUCCEED;
}
}
static int wav_decode_once(decoder_handle handle)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data *)handle;
if(p_decoder_data == NULL)
return DECODER_ERROR;
p_decoder_data->mh_read.Seek(p_decoder_data->mn_cur_position, _FStd(FFile)::ENUM_SEEK::SEEK_FILE_BEGIN);
p_decoder_data->byte_read = p_decoder_data->mh_read.Read(p_decoder_data->buf_data,sizeof(p_decoder_data->buf_data));
p_decoder_data->mf_cur_percent = (float)p_decoder_data->mn_cur_position / p_decoder_data->mp_audio_info->n_file_size;
if (p_decoder_data->byte_read > 0)
{
pcm_data_buf *p_data_buf = new pcm_data_buf(p_decoder_data->byte_read);
if(p_data_buf == NULL)
return DECODER_ERROR;
memcpy(p_data_buf->get_buf(),p_decoder_data->buf_data,p_decoder_data->byte_read);
p_decoder_data->m_raw_pcm_data_list.push_back(p_data_buf);
p_decoder_data->mn_cur_position += p_decoder_data->byte_read;
int nRes = p_decoder_data->mp_audio_info->n_sample_size_in_bit/8;
if(nRes > 0)
return p_decoder_data->byte_read/(nRes);
}
return DECODER_WAIT;
}
static int wav_get_available_samples_count(decoder_handle handle)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data *)handle;
if (p_decoder_data == NULL)
{
return DECODER_ERROR;
}
else
{
//return (p_decoder_data->byte_read)/(p_decoder_data->mp_audio_info->n_sample_size_in_bit/8);
return p_decoder_data->m_raw_pcm_data_list.size();
}
}
static int wav_get_data(decoder_handle handle,unsigned char *p_data,int n_buf_size)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data*)handle;
if (!p_decoder_data)
{
return DECODER_ERROR;
}
int n_bytes_write = 0;
while(n_bytes_write < n_buf_size && p_decoder_data->m_raw_pcm_data_list.size() > 0)
{
int n_remain_count = n_buf_size - n_bytes_write;
pcm_data_buf *p_buf = *p_decoder_data->m_raw_pcm_data_list.begin();
if(p_buf == NULL)
return DECODER_ERROR;
n_bytes_write += p_buf->copy_data(p_data+n_bytes_write,n_remain_count);
if(p_buf->empty())
{
p_decoder_data->m_raw_pcm_data_list.pop_front();
delete p_buf;
}
}
p_decoder_data->mn_availiable_bytes_count-=n_bytes_write;
return n_bytes_write;
}
static int wav_write_data(decoder_handle handle,unsigned char *p_data,int n_buf_size)
{
return DECODER_ERROR;
}
static __int64 wav_seek(decoder_handle handle,float f_percent)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data*)handle;
if (p_decoder_data == NULL)
{
return DECODER_ERROR;
}
p_decoder_data->mn_cur_position = f_percent * (p_decoder_data->mp_audio_info->n_file_size - 44);
switch (p_decoder_data->mp_audio_info->n_sample_size_in_bit)
{
case 8:
case 16:
p_decoder_data->mn_cur_position = p_decoder_data->mn_cur_position / 2 * 2;
break;
case 24:
p_decoder_data->mn_cur_position = p_decoder_data->mn_cur_position / 3 * 3 + 44;
break;
case 32:
p_decoder_data->mn_cur_position = p_decoder_data->mn_cur_position / 4 * 4;
}
while(p_decoder_data->m_raw_pcm_data_list.size() > 0)
{
pcm_data_buf *p_buf = *p_decoder_data->m_raw_pcm_data_list.begin();
delete p_buf;
p_decoder_data->m_raw_pcm_data_list.pop_front();
}
return DECODER_SUCCEED;
}
static __int64 wav_get_download_data_length(decoder_handle handle)
{
return DECODER_ERROR;
}
static __int64 wav_get_current_position(decoder_handle handle)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data *)handle;
if(p_decoder_data == NULL)
return DECODER_ERROR;
return p_decoder_data->mn_cur_position;
}
static bool wav_is_finish(decoder_handle handle)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data *)handle;
if(p_decoder_data == NULL)
return true;
if(p_decoder_data->m_raw_pcm_data_list.size() > 0)
return false;
if(p_decoder_data->mb_online)
{
return p_decoder_data->mp_audio_info->n_file_size == p_decoder_data->mn_cur_position && p_decoder_data->mb_data_completed;
}
else
{
return p_decoder_data->mp_audio_info->n_file_size == p_decoder_data->mn_cur_position ;
}
}
static void wav_close(decoder_handle handle)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data *)handle;
if(p_decoder_data == NULL)
return;
if(!(p_decoder_data->mh_read))
{
p_decoder_data->mh_read.Close();
}
if(p_decoder_data->mp_audio_info != NULL)
{
delete p_decoder_data->mp_audio_info;
}
while (p_decoder_data->m_raw_pcm_data_list.size())
{
pcm_data_buf *p_buf = *p_decoder_data->m_raw_pcm_data_list.begin();
p_decoder_data->m_raw_pcm_data_list.pop_front();
delete p_buf;
}
delete p_decoder_data;
}
static float wav_get_percent(decoder_handle handle)
{
wav_decoder_data *p_decoder_data = (wav_decoder_data *)handle;
if(p_decoder_data == NULL)
return 0;
return p_decoder_data->mf_cur_percent;
}
static int wav_get_decoder_type()
{
return DT_WAV;
} | [
"libyyu@qq.com"
] | libyyu@qq.com |
f0956a4f62219aeb88987344e6bb6ec5173355d0 | e49863bbbc510201b1c22b389f39a7d9caf450ed | /LinkedList/DoublyLL.cp | 2ee8d867259b002490563da60b6e60a6895e9c8a | [] | no_license | kumar2021ashish/DSA_Coding_Implementation | e5617ebdff7657de21e2ffe375eb69aa5a8ab914 | 1ab145c399425e06ecf4ef70700d2aba09529b47 | refs/heads/main | 2023-07-26T06:10:21.988849 | 2021-09-11T20:44:14 | 2021-09-11T20:44:14 | 403,628,811 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,678 | cp | // Double LL :
#include <iostream>
using namespace std;
struct Node{
int data;
Node *next;
Node *prev;
};
void front(Node **head_ref,int newData){
Node *newNode=new Node();
newNode->data=newData;
newNode->next=*head_ref;
newNode->prev=NULL;
if((*head_ref)!=NULL)
(*head_ref)->prev=newNode;
*head_ref=newNode;
}
void insertAfter(Node *prev_node,int newData){
if(prev_node==NULL){
cout<<"given node cant be null\n";
return;
}
Node *newNode=new Node();
newNode->data=newData;
newNode->next=prev_node->next;
prev_node->next=newNode;
newNode->prev=prev_node;
if(newNode->next !=NULL)
newNode->next->prev=newNode;
}
void append(Node **head_ref,int newData){
Node *newNode=new Node();
newNode->data=newData;
newNode->next=NULL;
Node *last=*head_ref;
if(*head_ref==NULL){
newNode->prev=NULL;
*head_ref=newNode;
return;
}
while(last->next !=NULL){
last=last->next;
}
last->next=newNode;
newNode->prev=last;
return;
}
void display(Node *p){
while(p!=NULL){
cout<<p->data<<"\t";
p=p->next;
}
}
int main() {
cout<<"Doubly LinkList :\n";
Node *head=NULL;
front(&head,1);
front(&head,2);
front(&head,3);
front(&head,4);
front(&head,5);
display(head);
cout<<endl;
insertAfter(head->next,6);
cout<<"middle insert in Doubly LL :\n";
display(head);
cout<<endl;
cout<<"Last insert in Doubly LL :\n";
append(&head,10);
display(head);
cout<<endl;
return 0;
}
| [
"ashish2020kashyap@gmail.com"
] | ashish2020kashyap@gmail.com |
18fe6ca2e0b1e139875bb0d7ffa1985799f5125a | 6ed471f36e5188f77dc61cca24daa41496a6d4a0 | /SDK/PrimalItem_WeaponMetalPick_functions.cpp | 88340d46230a22c46c79b5b02f51f27cb1f196dd | [] | no_license | zH4x-SDK/zARKSotF-SDK | 77bfaf9b4b9b6a41951ee18db88f826dd720c367 | 714730f4bb79c07d065181caf360d168761223f6 | refs/heads/main | 2023-07-16T22:33:15.140456 | 2021-08-27T13:40:06 | 2021-08-27T13:40:06 | 400,521,086 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,066 | cpp |
#include "../SDK.h"
// Name: ARKSotF, Version: 178.8.0
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
// Function PrimalItem_WeaponMetalPick.PrimalItem_WeaponMetalPick_C.ExecuteUbergraph_PrimalItem_WeaponMetalPick
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void UPrimalItem_WeaponMetalPick_C::ExecuteUbergraph_PrimalItem_WeaponMetalPick(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function PrimalItem_WeaponMetalPick.PrimalItem_WeaponMetalPick_C.ExecuteUbergraph_PrimalItem_WeaponMetalPick");
UPrimalItem_WeaponMetalPick_C_ExecuteUbergraph_PrimalItem_WeaponMetalPick_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
f0af22a68257a91513e26dea2a5153b010a54b2f | 43193782119bdd410538c0f9c8a83be0053351e4 | /Opportunity.ChakraBridge.WinRT/Value/JsTypedArray.cpp | 21d46073fc4e7def9910aebe22269d54114d76c0 | [
"MIT"
] | permissive | OpportunityLiu/ChakraBridge | 454e89ed1d766a139a3228ab1178f1c89ad7237e | 38e3eb058a94fb2f8bab0aed19af2dbfdbb556f3 | refs/heads/master | 2020-03-21T20:52:55.327616 | 2018-07-31T08:31:49 | 2018-07-31T08:31:49 | 139,034,175 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,947 | cpp | #include "pch.h"
#include "JsTypedArray.h"
#include "Native\NativeBuffer.h"
using namespace Opportunity::ChakraBridge::WinRT;
JsTypedArrayImpl::JsTypedArrayImpl(RawValue ref, uint8*const bufferPtr, const uint32 bufferLen, const JsArrayType arrType, const uint32 elementSize)
: JsObjectImpl(std::move(ref)), BufferPtr(bufferPtr), BufferLen(bufferLen), ArrType(arrType), ElementSize(elementSize) {}
IJsArrayBuffer^ JsTypedArrayImpl::Buffer::get()
{
JsValueRef buf;
CHAKRA_CALL(JsGetTypedArrayInfo(Reference.Ref, nullptr, &buf, nullptr, nullptr));
return safe_cast<IJsArrayBuffer^>(JsValue::CreateTyped(RawValue(buf)));
}
IBuffer^ JsTypedArrayImpl::Data::get()
{
return CreateNativeBuffer(this);
}
uint32 JsTypedArrayImpl::ByteLength::get()
{
return BufferLen;
}
uint32 JsTypedArrayImpl::ByteOffset::get()
{
uint32 offset;
CHAKRA_CALL(JsGetTypedArrayInfo(Reference.Ref, nullptr, nullptr, &offset, nullptr));
return offset;
}
JsArrayType JsTypedArrayImpl::ArrayType::get()
{
return ArrType;
}
uint32 JsTypedArrayImpl::BytesPerElement::get()
{
return ElementSize;
}
void JsTypedArrayImpl::ThrowForFixedSize()
{
Throw(E_NOTIMPL, L"The typed array is fixed size.");
}
uint32 JsTypedArrayImpl::ArraySize::get()
{
return BufferLen / ElementSize;
}
void JsTypedArrayImpl::BoundCheck(uint32 index)
{
if (index >= ArraySize)
Throw(E_INVALIDARG, L"index is larger than the size of the typed array.");
}
JsTypedArrayImpl^ JsTypedArray::CreateTyped(RawValue ref)
{
using AT = JsArrayType;
uint8* bufferPtr;
unsigned int bufferLen;
AT arrType;
int elementSize;
CHAKRA_CALL(JsGetTypedArrayStorage(ref.Ref, &bufferPtr, &bufferLen, reinterpret_cast<::JsTypedArrayType*>(&arrType), &elementSize));
#define CASE(name) \
case AT::name: return ref new JsTypedArrayTempImpl<AT::name>(ref, bufferPtr, bufferLen, arrType, static_cast<unsigned int>(elementSize))
switch (arrType)
{
CASE(Int8);
CASE(Uint8);
CASE(Uint8Clamped);
CASE(Int16);
CASE(Uint16);
CASE(Int32);
CASE(Uint32);
CASE(Float32);
CASE(Float64);
}
#undef CASE
Throw(E_NOTIMPL, L"Unknown array type.");
}
uint32 GetSize(JsArrayType arrType)
{
using AT = JsArrayType;
#define CASE(name) case AT::name: return sizeof(typename JsTypedArrayTempInfo<AT::name>::t_ele)
switch (arrType)
{
CASE(Int8);
CASE(Uint8);
CASE(Uint8Clamped);
CASE(Int16);
CASE(Uint16);
CASE(Int32);
CASE(Uint32);
CASE(Float32);
CASE(Float64);
}
#undef CASE
Throw(E_NOTIMPL, L"Unknown array type.");
}
IJsTypedArray^ JsTypedArray::Create(JsArrayType arrayType)
{
return CreateTyped(RawValue::CreateTypedArray(arrayType, nullptr, 0, 0));
}
IJsTypedArray^ JsTypedArray::Create(JsArrayType arrayType, uint32 length)
{
return CreateTyped(RawValue::CreateTypedArray(arrayType, nullptr, 0, length));
}
IJsTypedArray^ JsTypedArray::Create(JsArrayType arrayType, IJsValue^ arrayLike)
{
NULL_CHECK(arrayLike);
auto ref = to_impl(arrayLike)->Reference;
if (dynamic_cast<IJsObject^>(arrayLike) == nullptr)
ref = ref.ToJsObjet();
return CreateTyped(RawValue::CreateTypedArray(arrayType, ref, 0, 0));
}
IJsTypedArray^ JsTypedArray::Create(JsArrayType arrayType, IJsArrayBuffer^ buffer)
{
return Create(arrayType, buffer, 0);
}
IJsTypedArray^ JsTypedArray::Create(JsArrayType arrayType, IJsArrayBuffer^ buffer, uint32 byteOffset)
{
NULL_CHECK(buffer);
return Create(arrayType, buffer, byteOffset, (to_impl(buffer)->BufferLen - byteOffset) / GetSize(arrayType));
}
IJsTypedArray^ JsTypedArray::Create(JsArrayType arrayType, IJsArrayBuffer^ buffer, uint32 byteOffset, uint32 length)
{
NULL_CHECK(buffer);
return CreateTyped(RawValue::CreateTypedArray(arrayType, to_impl(buffer)->Reference, byteOffset, length));
}
| [
"opportunity@live.in"
] | opportunity@live.in |
fc3dcee15542c1f3af9e2bba67ab696d764f4f1c | 5d6794a2d3af0d84c59783e110f33538d0e9b830 | /problems/C/abc067c.cpp | 3e4d0076f014f16596fa7fa9e73be3c17b51246d | [] | no_license | ryotgm0417/AtCoder | e641336365e1c3b4812471ebf86f55e69ee09e2f | a70a0be85beb925a3e488e9e0d8191f0bbf1bcc1 | refs/heads/master | 2020-11-28T21:21:35.171770 | 2020-08-29T13:50:15 | 2020-08-29T13:50:15 | 229,922,379 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 849 | cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;
ll MAX = 1000000000000000000;
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
if(comp(x, xmin)) {
xmin = x;
return true;
}
return false;
}
int main(){
int n;
cin >> n;
vector<ll> a(n);
rep(i,n) cin >> a[i];
vector<ll> sum(n);
sum[0] = a[0];
rep(i,n-1){
sum[i+1] = sum[i] + a[i+1];
}
ll ans = MAX;
rep(i,n-1){
ll snuke = sum[i], arai = sum[n-1] - sum[i];
chmin(ans, abs(snuke - arai));
}
cout << ans << endl;
return 0;
} | [
"ryothailand98@gmail.com"
] | ryothailand98@gmail.com |
5bf10e75299caa6ccb01642d535fc913ba44faae | fedfd83c0762e084235bf5562d46f0959b318b6f | /L1 小学生趣味编程/ch06/ch62-01.cpp | bd874b5a35f36217e17a12fbd364bd41589b7b76 | [] | no_license | mac8088/noip | 7843b68b6eeee6b45ccfb777c3e389e56b188549 | 61ee051d3aff55b3767d0f2f7d5cc1e1c8d3cf20 | refs/heads/master | 2021-08-17T21:25:37.951477 | 2020-08-14T02:03:50 | 2020-08-14T02:03:50 | 214,208,724 | 6 | 0 | null | null | null | null | GB18030 | C++ | false | false | 452 | cpp | #include <iostream>
using namespace std;
/*
第62课,捉迷藏
--数组越界
*/
int main()
{
bool a[11];
int i, cishu;
for(i=1;i<=10;i++)
a[i] = true;
i = 10;
a[i] = false;
cishu = 1;
while(cishu<=1000)
{
i=(i+cishu)%10;
if(i==0) i=10;
a[i] = false;
cishu++;
}
for(i=1;i<=10;i++)
{
if(a[i]) cout << i << endl;
}
return 0;
}
//--------------------------------
//2
//4
//7
//9
//--------------------------------
| [
"chun.ma@qq.com"
] | chun.ma@qq.com |
c07dd406540034f320a76f20b5827d6f5ce82e65 | ba9322f7db02d797f6984298d892f74768193dcf | /emr/include/alibabacloud/emr/model/ListExecutionPlanInstanceTrendResult.h | 5aa900f864c268e0caeb3ae8b68441ef176faa48 | [
"Apache-2.0"
] | permissive | sdk-team/aliyun-openapi-cpp-sdk | e27f91996b3bad9226c86f74475b5a1a91806861 | a27fc0000a2b061cd10df09cbe4fff9db4a7c707 | refs/heads/master | 2022-08-21T18:25:53.080066 | 2022-07-25T10:01:05 | 2022-07-25T10:01:05 | 183,356,893 | 3 | 0 | null | 2019-04-25T04:34:29 | 2019-04-25T04:34:28 | null | UTF-8 | C++ | false | false | 1,582 | h | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_EMR_MODEL_LISTEXECUTIONPLANINSTANCETRENDRESULT_H_
#define ALIBABACLOUD_EMR_MODEL_LISTEXECUTIONPLANINSTANCETRENDRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/emr/EmrExport.h>
namespace AlibabaCloud
{
namespace Emr
{
namespace Model
{
class ALIBABACLOUD_EMR_EXPORT ListExecutionPlanInstanceTrendResult : public ServiceResult
{
public:
struct Trend
{
std::string status;
int count;
std::string day;
};
ListExecutionPlanInstanceTrendResult();
explicit ListExecutionPlanInstanceTrendResult(const std::string &payload);
~ListExecutionPlanInstanceTrendResult();
std::vector<Trend> getTrends()const;
protected:
void parse(const std::string &payload);
private:
std::vector<Trend> trends_;
};
}
}
}
#endif // !ALIBABACLOUD_EMR_MODEL_LISTEXECUTIONPLANINSTANCETRENDRESULT_H_ | [
"haowei.yao@alibaba-inc.com"
] | haowei.yao@alibaba-inc.com |
e40f212c24591ddf1ef39176ed7afb908e01a99e | 6247777e38b1015b848c177b9b43d9ab4123cca8 | /gecode/int/view/iter.hpp | 4f56cef59e2acd6eba16d24fc4251a66b6f8a8b9 | [
"MIT"
] | permissive | feserafim/gecode | f8287439e74cb168c7a7c7fdbb78103a4fec5b9b | 760bf24f1fecd2f261f6e9c1391e80467015fdf4 | refs/heads/master | 2021-01-11T16:05:54.829564 | 2012-06-16T17:17:38 | 2012-06-16T17:17:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,105 | hpp | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Contributing authors:
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Christian Schulte, 2003
* Guido Tack, 2004
*
* Last modified:
* $Date: 2009-09-09 04:10:29 +0900 (水, 09 9 2009) $ by $Author: schulte $
* $Revision: 9692 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode { namespace Int {
template<class View>
forceinline
ViewValues<View>::ViewValues(void) {}
template<class View>
forceinline
ViewValues<View>::ViewValues(const View& x) {
ViewRanges<View> r(x);
Iter::Ranges::ToValues<ViewRanges<View> >::init(r);
}
template<class View>
forceinline void
ViewValues<View>::init(const View& x) {
ViewRanges<View> r(x);
Iter::Ranges::ToValues<ViewRanges<View> >::init(r);
}
}}
// STATISTICS: int-var
| [
"kenhys@gmail.com"
] | kenhys@gmail.com |
a52b8eb295c3cb16427fcefc88938dbb8301b4bd | 2277375bd4a554d23da334dddd091a36138f5cae | /ThirdParty/CUDA/include/thrust/detail/copy.inl | e631b27be85c84ddd44166d519bed9b2828f7456 | [] | no_license | kevinmore/Project-Nebula | 9a0553ccf8bdc1b4bb5e2588fc94516d9e3532bc | f6d284d4879ae1ea1bd30c5775ef8733cfafa71d | refs/heads/master | 2022-10-22T03:55:42.596618 | 2020-06-19T09:07:07 | 2020-06-19T09:07:07 | 25,372,691 | 6 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 4,325 | inl | /*
* Copyright 2008-2013 NVIDIA 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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/copy.h>
#include <thrust/system/detail/generic/select_system.h>
#include <thrust/system/detail/generic/copy.h>
#include <thrust/system/detail/adl/copy.h>
namespace thrust
{
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator>
OutputIterator copy(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
InputIterator first,
InputIterator last,
OutputIterator result)
{
using thrust::system::detail::generic::copy;
return copy(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, result);
} // end copy()
template<typename DerivedPolicy, typename InputIterator, typename Size, typename OutputIterator>
OutputIterator copy_n(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
InputIterator first,
Size n,
OutputIterator result)
{
using thrust::system::detail::generic::copy_n;
return copy_n(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, n, result);
} // end copy_n()
namespace detail
{
template<typename System1,
typename System2,
typename InputIterator,
typename OutputIterator>
OutputIterator two_system_copy(thrust::execution_policy<System1> &system1,
thrust::execution_policy<System2> &system2,
InputIterator first,
InputIterator last,
OutputIterator result)
{
using thrust::system::detail::generic::select_system;
return thrust::copy(select_system(thrust::detail::derived_cast(thrust::detail::strip_const(system1)), thrust::detail::derived_cast(thrust::detail::strip_const(system2))), first, last, result);
} // end two_system_copy()
template<typename System1,
typename System2,
typename InputIterator,
typename Size,
typename OutputIterator>
OutputIterator two_system_copy_n(thrust::execution_policy<System1> &system1,
thrust::execution_policy<System2> &system2,
InputIterator first,
Size n,
OutputIterator result)
{
using thrust::system::detail::generic::select_system;
return thrust::copy_n(select_system(thrust::detail::derived_cast(thrust::detail::strip_const(system1)), thrust::detail::derived_cast(thrust::detail::strip_const(system2))), first, n, result);
} // end two_system_copy_n()
} // end detail
template<typename InputIterator,
typename OutputIterator>
OutputIterator copy(InputIterator first,
InputIterator last,
OutputIterator result)
{
typedef typename thrust::iterator_system<InputIterator>::type System1;
typedef typename thrust::iterator_system<OutputIterator>::type System2;
System1 system1;
System2 system2;
return thrust::detail::two_system_copy(system1, system2, first, last, result);
} // end copy()
template<typename InputIterator,
typename Size,
typename OutputIterator>
OutputIterator copy_n(InputIterator first,
Size n,
OutputIterator result)
{
typedef typename thrust::iterator_system<InputIterator>::type System1;
typedef typename thrust::iterator_system<OutputIterator>::type System2;
System1 system1;
System2 system2;
return thrust::detail::two_system_copy_n(system1, system2, first, n, result);
} // end copy_n()
} // end namespace thrust
| [
"dingfengyu@gmail.com"
] | dingfengyu@gmail.com |
a97921bd3e946a85636460672c1e777f756c4afb | dcd772f567ef8a8a1173a9f437cd68f211fb9362 | /crow/contrib/include/boost/math/tools/detail/rational_horner2_14.hpp | 78edfbbe1b6d5851119ec0b930062f5104820c13 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0"
] | permissive | idaholab/raven | 39cdce98ad916c638399232cdc01a9be00e200a2 | 2b16e7aa3325fe84cab2477947a951414c635381 | refs/heads/devel | 2023-08-31T08:40:16.653099 | 2023-08-29T16:21:51 | 2023-08-29T16:21:51 | 85,989,537 | 201 | 126 | Apache-2.0 | 2023-09-13T21:55:43 | 2017-03-23T19:29:27 | C++ | UTF-8 | C++ | false | false | 9,467 | hpp | // (C) Copyright John Maddock 2007.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// This file is machine generated, do not edit by hand
// Polynomial evaluation using second order Horners rule
#ifndef BOOST_MATH_TOOLS_RAT_EVAL_14_HPP
#define BOOST_MATH_TOOLS_RAT_EVAL_14_HPP
namespace boost{ namespace math{ namespace tools{ namespace detail{
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*)
{
return static_cast<V>(0);
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*)
{
return static_cast<V>(a[0]) / static_cast<V>(b[0]);
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*)
{
return static_cast<V>((a[1] * x + a[0]) / (b[1] * x + b[0]));
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*)
{
return static_cast<V>(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0]));
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*)
{
return static_cast<V>((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0]));
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>(((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x) / ((b[4] * x2 + b[2]) * x2 + b[0] + (b[3] * x2 + b[1]) * x));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>(((a[0] * z2 + a[2]) * z2 + a[4] + (a[1] * z2 + a[3]) * z) / ((b[0] * z2 + b[2]) * z2 + b[4] + (b[1] * z2 + b[3]) * z));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>((((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]) / (((b[5] * x2 + b[3]) * x2 + b[1]) * x + (b[4] * x2 + b[2]) * x2 + b[0]));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>((((a[0] * z2 + a[2]) * z2 + a[4]) * z + (a[1] * z2 + a[3]) * z2 + a[5]) / (((b[0] * z2 + b[2]) * z2 + b[4]) * z + (b[1] * z2 + b[3]) * z2 + b[5]));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>((((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x) / (((b[6] * x2 + b[4]) * x2 + b[2]) * x2 + b[0] + ((b[5] * x2 + b[3]) * x2 + b[1]) * x));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6] + ((a[1] * z2 + a[3]) * z2 + a[5]) * z) / (((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6] + ((b[1] * z2 + b[3]) * z2 + b[5]) * z));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>(((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]) / ((((b[7] * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x + ((b[6] * x2 + b[4]) * x2 + b[2]) * x2 + b[0]));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>(((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z + ((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) / ((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z + ((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>(((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x) / ((((b[8] * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0] + (((b[7] * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>(((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8] + (((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z) / ((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8] + (((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>((((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]) / (((((b[9] * x2 + b[7]) * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x + (((b[8] * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0]));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>((((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8]) * z + (((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z2 + a[9]) / (((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8]) * z + (((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z2 + b[9]));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>((((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x) / (((((b[10] * x2 + b[8]) * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0] + ((((b[9] * x2 + b[7]) * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>((((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8]) * z2 + a[10] + ((((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z2 + a[9]) * z) / (((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8]) * z2 + b[10] + ((((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z2 + b[9]) * z));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>(((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]) / ((((((b[11] * x2 + b[9]) * x2 + b[7]) * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x + ((((b[10] * x2 + b[8]) * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0]));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>(((((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8]) * z2 + a[10]) * z + ((((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z2 + a[9]) * z2 + a[11]) / ((((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8]) * z2 + b[10]) * z + ((((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z2 + b[9]) * z2 + b[11]));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>(((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x) / ((((((b[12] * x2 + b[10]) * x2 + b[8]) * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0] + (((((b[11] * x2 + b[9]) * x2 + b[7]) * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>(((((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8]) * z2 + a[10]) * z2 + a[12] + (((((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z2 + a[9]) * z2 + a[11]) * z) / ((((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8]) * z2 + b[10]) * z2 + b[12] + (((((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z2 + b[9]) * z2 + b[11]) * z));
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*)
{
if(x <= 1)
{
V x2 = x * x;
return static_cast<V>((((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]) / (((((((b[13] * x2 + b[11]) * x2 + b[9]) * x2 + b[7]) * x2 + b[5]) * x2 + b[3]) * x2 + b[1]) * x + (((((b[12] * x2 + b[10]) * x2 + b[8]) * x2 + b[6]) * x2 + b[4]) * x2 + b[2]) * x2 + b[0]));
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
return static_cast<V>((((((((a[0] * z2 + a[2]) * z2 + a[4]) * z2 + a[6]) * z2 + a[8]) * z2 + a[10]) * z2 + a[12]) * z + (((((a[1] * z2 + a[3]) * z2 + a[5]) * z2 + a[7]) * z2 + a[9]) * z2 + a[11]) * z2 + a[13]) / (((((((b[0] * z2 + b[2]) * z2 + b[4]) * z2 + b[6]) * z2 + b[8]) * z2 + b[10]) * z2 + b[12]) * z + (((((b[1] * z2 + b[3]) * z2 + b[5]) * z2 + b[7]) * z2 + b[9]) * z2 + b[11]) * z2 + b[13]));
}
}
}}}} // namespaces
#endif // include guard
| [
"codypermann@gmail.com"
] | codypermann@gmail.com |
8e7742b700e13b4ca900875879e1bfaf7a38e087 | be26eee78e52ce9afbac359b93eebb754c7514f3 | /tHeader.h | 18ea1739d55efd579766571b04742db1eb12f051 | [] | no_license | Xavi55/cpp-server-client | ed299c160781676fde90cc42de4b36b569ffcc01 | 705d7f1d814c92ded48a75780b8a3138b7788487 | refs/heads/master | 2021-05-11T21:11:54.033449 | 2018-01-14T20:08:28 | 2018-01-14T20:08:28 | 117,462,632 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 312 | h | using namespace std;
class tHeader
{
//int map;
public:
int id;
string ver, table, type,body;
public:
tHeader(int m);//different int = different routing table
void set(int i, string v, string tab, string typ,string b);
string print();
//tHeader(int v,int c,int i,string m,string typ);
};
| [
"kxg2@afsaccess1.njit.edu"
] | kxg2@afsaccess1.njit.edu |
021cbc74aee9e4cd61f4a0dbf5f7d8da022a31a0 | a006ade0bf5c96e8835b186e91d8d72c41b4cf06 | /example/basic_tuple/make.cpp | dee187a626c7c42dc766235dd03ecb6e9370d549 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | qicosmos/hana | f49237459fc3dbe9587947a8462756d3e35be360 | b0f8cf2bf19d491b7b739dcb7b8d7497b0e5829f | refs/heads/master | 2021-01-21T06:19:34.457909 | 2015-10-22T21:59:03 | 2015-10-22T21:59:03 | 44,804,270 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 647 | cpp | /*
@copyright Louis Dionne 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana/basic_tuple.hpp>
#include <boost/hana/core/make.hpp>
#include <type_traits>
namespace hana = boost::hana;
constexpr hana::basic_tuple<int, char, double> xs{1, '2', 3.3};
constexpr auto ys = hana::make<hana::basic_tuple_tag>(1, '2', 3.3);
constexpr auto zs = hana::make_basic_tuple(1, '2', 3.3);
static_assert(std::is_same<decltype(ys), decltype(xs)>::value, "");
static_assert(std::is_same<decltype(zs), decltype(xs)>::value, "");
int main() { }
| [
"ldionne.2@gmail.com"
] | ldionne.2@gmail.com |
c32a68acdd37fa00e52749993d6c0793d019370c | 4a671003f6757a6f73985a2f203e5ace8ee86426 | /src/ui/ui_debugWindow.h | a10018e16e99745cdc6dd5bc2f6625b976ec0fca | [] | no_license | cdbishop/gameboyEmu-qt | c43aeb838e27ed079a876b5f02c8bccd8f870b42 | 34fdcf17f035a1b441bf5da2bfcc75c774c85275 | refs/heads/master | 2020-05-19T08:42:33.211377 | 2020-04-20T19:00:35 | 2020-04-20T19:00:35 | 184,927,047 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,737 | h | /********************************************************************************
** Form generated from reading UI file 'debugWindowRliOog.ui'
**
** Created by: Qt User Interface Compiler version 5.11.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef DEBUGWINDOWRLIOOG_H
#define DEBUGWINDOWRLIOOG_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QFrame>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QTableWidget>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralwidget;
QHBoxLayout *horizontalLayout_3;
QHBoxLayout *horizontalLayout;
QFrame *frame;
QPushButton *btn_Next;
QPushButton *btn_Run;
QListWidget *lst_History;
QPushButton *btn_Pause;
QListWidget *lst_rom;
QComboBox *cmbo_RunSpeed;
QHBoxLayout *horizontalLayout_2;
QFrame *frame_2;
QLabel *lblRegA;
QLineEdit *lineEditRegA;
QLineEdit *lineEditRegB;
QLabel *lblRegB;
QLabel *lblRegC;
QLineEdit *lineEditRegC;
QLineEdit *lineEditRegD;
QLabel *lblRegD;
QLineEdit *lineEditRegE;
QLabel *lblRegE;
QLineEdit *lineEditRegH;
QLabel *lblRegH;
QLineEdit *lineEditRegL;
QLabel *lblRegL;
QLineEdit *lineEditRegFlag;
QLabel *lblRegFlag;
QLabel *lblRegPC;
QLineEdit *lineEditRegPC;
QLabel *lblRegSP;
QLineEdit *lineEditRegSP;
QLineEdit *lineEditRegBC;
QLabel *lblRegBC;
QLineEdit *lineEditRegDE;
QLabel *lblRegDE;
QLabel *lblRegHL;
QLineEdit *lineEditRegHL;
QGroupBox *groupBox_debugSection;
QLabel *lbl_breakOnPC;
QLineEdit *lineEdit_BreakPCValue;
QComboBox *cmbo_BreakRegSelect;
QLabel *lblBreakOnReg;
QLabel *lbl_BreakRegVal;
QLineEdit *lineEdit_BreakRegVal;
QPushButton *btn_AddPCBreak;
QPushButton *btn_AddRegBreak;
QPushButton *btn_RemoveBreak;
QTableWidget *tbl_Breaks;
QCheckBox *chk_flagCarry;
QCheckBox *chk_flagHalfCarry;
QCheckBox *chk_flagSubOp;
QCheckBox *chk_flagZero;
QLabel *lblTimerM;
QLineEdit *lineEditTimerM;
QLabel *lblTimerT;
QLineEdit *lineEditTimerT;
QMenuBar *menubar;
QStatusBar *statusbar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QStringLiteral("MainWindow"));
MainWindow->resize(1103, 700);
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QStringLiteral("centralwidget"));
horizontalLayout_3 = new QHBoxLayout(centralwidget);
horizontalLayout_3->setObjectName(QStringLiteral("horizontalLayout_3"));
horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
frame = new QFrame(centralwidget);
frame->setObjectName(QStringLiteral("frame"));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Raised);
btn_Next = new QPushButton(frame);
btn_Next->setObjectName(QStringLiteral("btn_Next"));
btn_Next->setGeometry(QRect(10, 340, 31, 23));
btn_Run = new QPushButton(frame);
btn_Run->setObjectName(QStringLiteral("btn_Run"));
btn_Run->setGeometry(QRect(50, 340, 31, 23));
lst_History = new QListWidget(frame);
lst_History->setObjectName(QStringLiteral("lst_History"));
lst_History->setGeometry(QRect(0, 0, 401, 331));
btn_Pause = new QPushButton(frame);
btn_Pause->setObjectName(QStringLiteral("btn_Pause"));
btn_Pause->setGeometry(QRect(170, 340, 31, 23));
lst_rom = new QListWidget(frame);
lst_rom->setObjectName(QStringLiteral("lst_rom"));
lst_rom->setGeometry(QRect(0, 390, 401, 241));
cmbo_RunSpeed = new QComboBox(frame);
cmbo_RunSpeed->addItem(QString());
cmbo_RunSpeed->addItem(QString());
cmbo_RunSpeed->setObjectName(QStringLiteral("cmbo_RunSpeed"));
cmbo_RunSpeed->setGeometry(QRect(90, 340, 69, 22));
horizontalLayout->addWidget(frame);
horizontalLayout_3->addLayout(horizontalLayout);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
frame_2 = new QFrame(centralwidget);
frame_2->setObjectName(QStringLiteral("frame_2"));
frame_2->setFrameShape(QFrame::StyledPanel);
frame_2->setFrameShadow(QFrame::Raised);
lblRegA = new QLabel(frame_2);
lblRegA->setObjectName(QStringLiteral("lblRegA"));
lblRegA->setGeometry(QRect(10, 20, 47, 13));
lineEditRegA = new QLineEdit(frame_2);
lineEditRegA->setObjectName(QStringLiteral("lineEditRegA"));
lineEditRegA->setGeometry(QRect(20, 20, 31, 20));
lineEditRegA->setReadOnly(true);
lineEditRegB = new QLineEdit(frame_2);
lineEditRegB->setObjectName(QStringLiteral("lineEditRegB"));
lineEditRegB->setGeometry(QRect(20, 50, 31, 20));
lineEditRegB->setReadOnly(true);
lblRegB = new QLabel(frame_2);
lblRegB->setObjectName(QStringLiteral("lblRegB"));
lblRegB->setGeometry(QRect(10, 50, 16, 16));
lblRegC = new QLabel(frame_2);
lblRegC->setObjectName(QStringLiteral("lblRegC"));
lblRegC->setGeometry(QRect(10, 80, 16, 16));
lineEditRegC = new QLineEdit(frame_2);
lineEditRegC->setObjectName(QStringLiteral("lineEditRegC"));
lineEditRegC->setGeometry(QRect(20, 80, 31, 20));
lineEditRegC->setReadOnly(true);
lineEditRegD = new QLineEdit(frame_2);
lineEditRegD->setObjectName(QStringLiteral("lineEditRegD"));
lineEditRegD->setGeometry(QRect(20, 110, 31, 20));
lineEditRegD->setReadOnly(true);
lblRegD = new QLabel(frame_2);
lblRegD->setObjectName(QStringLiteral("lblRegD"));
lblRegD->setGeometry(QRect(10, 110, 16, 16));
lineEditRegE = new QLineEdit(frame_2);
lineEditRegE->setObjectName(QStringLiteral("lineEditRegE"));
lineEditRegE->setGeometry(QRect(20, 140, 31, 20));
lineEditRegE->setReadOnly(true);
lblRegE = new QLabel(frame_2);
lblRegE->setObjectName(QStringLiteral("lblRegE"));
lblRegE->setGeometry(QRect(10, 140, 16, 16));
lineEditRegH = new QLineEdit(frame_2);
lineEditRegH->setObjectName(QStringLiteral("lineEditRegH"));
lineEditRegH->setGeometry(QRect(20, 170, 31, 20));
lineEditRegH->setReadOnly(true);
lblRegH = new QLabel(frame_2);
lblRegH->setObjectName(QStringLiteral("lblRegH"));
lblRegH->setGeometry(QRect(10, 170, 16, 16));
lineEditRegL = new QLineEdit(frame_2);
lineEditRegL->setObjectName(QStringLiteral("lineEditRegL"));
lineEditRegL->setGeometry(QRect(20, 200, 31, 20));
lineEditRegL->setReadOnly(true);
lblRegL = new QLabel(frame_2);
lblRegL->setObjectName(QStringLiteral("lblRegL"));
lblRegL->setGeometry(QRect(10, 200, 16, 16));
lineEditRegFlag = new QLineEdit(frame_2);
lineEditRegFlag->setObjectName(QStringLiteral("lineEditRegFlag"));
lineEditRegFlag->setGeometry(QRect(110, 20, 31, 20));
lineEditRegFlag->setReadOnly(true);
lblRegFlag = new QLabel(frame_2);
lblRegFlag->setObjectName(QStringLiteral("lblRegFlag"));
lblRegFlag->setGeometry(QRect(80, 20, 31, 16));
lblRegPC = new QLabel(frame_2);
lblRegPC->setObjectName(QStringLiteral("lblRegPC"));
lblRegPC->setGeometry(QRect(190, 170, 31, 16));
lineEditRegPC = new QLineEdit(frame_2);
lineEditRegPC->setObjectName(QStringLiteral("lineEditRegPC"));
lineEditRegPC->setGeometry(QRect(220, 170, 41, 20));
lineEditRegPC->setReadOnly(true);
lblRegSP = new QLabel(frame_2);
lblRegSP->setObjectName(QStringLiteral("lblRegSP"));
lblRegSP->setGeometry(QRect(190, 200, 31, 16));
lineEditRegSP = new QLineEdit(frame_2);
lineEditRegSP->setObjectName(QStringLiteral("lineEditRegSP"));
lineEditRegSP->setGeometry(QRect(220, 200, 41, 20));
lineEditRegSP->setReadOnly(true);
lineEditRegBC = new QLineEdit(frame_2);
lineEditRegBC->setObjectName(QStringLiteral("lineEditRegBC"));
lineEditRegBC->setGeometry(QRect(220, 20, 41, 20));
lineEditRegBC->setReadOnly(true);
lblRegBC = new QLabel(frame_2);
lblRegBC->setObjectName(QStringLiteral("lblRegBC"));
lblRegBC->setGeometry(QRect(190, 20, 31, 16));
lineEditRegDE = new QLineEdit(frame_2);
lineEditRegDE->setObjectName(QStringLiteral("lineEditRegDE"));
lineEditRegDE->setGeometry(QRect(220, 50, 41, 20));
lineEditRegDE->setReadOnly(true);
lblRegDE = new QLabel(frame_2);
lblRegDE->setObjectName(QStringLiteral("lblRegDE"));
lblRegDE->setGeometry(QRect(190, 50, 31, 16));
lblRegHL = new QLabel(frame_2);
lblRegHL->setObjectName(QStringLiteral("lblRegHL"));
lblRegHL->setGeometry(QRect(190, 80, 31, 16));
lineEditRegHL = new QLineEdit(frame_2);
lineEditRegHL->setObjectName(QStringLiteral("lineEditRegHL"));
lineEditRegHL->setGeometry(QRect(220, 80, 41, 20));
lineEditRegHL->setReadOnly(true);
groupBox_debugSection = new QGroupBox(frame_2);
groupBox_debugSection->setObjectName(QStringLiteral("groupBox_debugSection"));
groupBox_debugSection->setGeometry(QRect(10, 359, 381, 171));
lbl_breakOnPC = new QLabel(groupBox_debugSection);
lbl_breakOnPC->setObjectName(QStringLiteral("lbl_breakOnPC"));
lbl_breakOnPC->setGeometry(QRect(10, 20, 71, 16));
lineEdit_BreakPCValue = new QLineEdit(groupBox_debugSection);
lineEdit_BreakPCValue->setObjectName(QStringLiteral("lineEdit_BreakPCValue"));
lineEdit_BreakPCValue->setGeometry(QRect(100, 20, 41, 20));
cmbo_BreakRegSelect = new QComboBox(groupBox_debugSection);
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->addItem(QString());
cmbo_BreakRegSelect->setObjectName(QStringLiteral("cmbo_BreakRegSelect"));
cmbo_BreakRegSelect->setGeometry(QRect(100, 40, 41, 22));
lblBreakOnReg = new QLabel(groupBox_debugSection);
lblBreakOnReg->setObjectName(QStringLiteral("lblBreakOnReg"));
lblBreakOnReg->setGeometry(QRect(10, 40, 91, 16));
lbl_BreakRegVal = new QLabel(groupBox_debugSection);
lbl_BreakRegVal->setObjectName(QStringLiteral("lbl_BreakRegVal"));
lbl_BreakRegVal->setGeometry(QRect(150, 41, 31, 16));
lineEdit_BreakRegVal = new QLineEdit(groupBox_debugSection);
lineEdit_BreakRegVal->setObjectName(QStringLiteral("lineEdit_BreakRegVal"));
lineEdit_BreakRegVal->setGeometry(QRect(180, 40, 41, 20));
btn_AddPCBreak = new QPushButton(groupBox_debugSection);
btn_AddPCBreak->setObjectName(QStringLiteral("btn_AddPCBreak"));
btn_AddPCBreak->setEnabled(false);
btn_AddPCBreak->setGeometry(QRect(230, 20, 41, 23));
btn_AddRegBreak = new QPushButton(groupBox_debugSection);
btn_AddRegBreak->setObjectName(QStringLiteral("btn_AddRegBreak"));
btn_AddRegBreak->setEnabled(false);
btn_AddRegBreak->setGeometry(QRect(230, 40, 41, 23));
btn_RemoveBreak = new QPushButton(groupBox_debugSection);
btn_RemoveBreak->setObjectName(QStringLiteral("btn_RemoveBreak"));
btn_RemoveBreak->setEnabled(false);
btn_RemoveBreak->setGeometry(QRect(324, 70, 51, 23));
tbl_Breaks = new QTableWidget(groupBox_debugSection);
if (tbl_Breaks->columnCount() < 2)
tbl_Breaks->setColumnCount(2);
QTableWidgetItem *__qtablewidgetitem = new QTableWidgetItem();
tbl_Breaks->setHorizontalHeaderItem(0, __qtablewidgetitem);
QTableWidgetItem *__qtablewidgetitem1 = new QTableWidgetItem();
tbl_Breaks->setHorizontalHeaderItem(1, __qtablewidgetitem1);
tbl_Breaks->setObjectName(QStringLiteral("tbl_Breaks"));
tbl_Breaks->setGeometry(QRect(10, 70, 311, 91));
tbl_Breaks->setEditTriggers(QAbstractItemView::NoEditTriggers);
tbl_Breaks->setSelectionMode(QAbstractItemView::SingleSelection);
tbl_Breaks->setSelectionBehavior(QAbstractItemView::SelectRows);
tbl_Breaks->horizontalHeader()->setDefaultSectionSize(154);
tbl_Breaks->horizontalHeader()->setHighlightSections(true);
chk_flagCarry = new QCheckBox(frame_2);
chk_flagCarry->setObjectName(QStringLiteral("chk_flagCarry"));
chk_flagCarry->setGeometry(QRect(90, 50, 70, 17));
chk_flagHalfCarry = new QCheckBox(frame_2);
chk_flagHalfCarry->setObjectName(QStringLiteral("chk_flagHalfCarry"));
chk_flagHalfCarry->setGeometry(QRect(90, 80, 70, 17));
chk_flagSubOp = new QCheckBox(frame_2);
chk_flagSubOp->setObjectName(QStringLiteral("chk_flagSubOp"));
chk_flagSubOp->setGeometry(QRect(90, 110, 70, 17));
chk_flagZero = new QCheckBox(frame_2);
chk_flagZero->setObjectName(QStringLiteral("chk_flagZero"));
chk_flagZero->setGeometry(QRect(90, 140, 70, 17));
lblTimerM = new QLabel(frame_2);
lblTimerM->setObjectName(QStringLiteral("lblTimerM"));
lblTimerM->setGeometry(QRect(300, 20, 20, 20));
lineEditTimerM = new QLineEdit(frame_2);
lineEditTimerM->setObjectName(QStringLiteral("lineEditTimerM"));
lineEditTimerM->setGeometry(QRect(320, 20, 21, 20));
lblTimerT = new QLabel(frame_2);
lblTimerT->setObjectName(QStringLiteral("lblTimerT"));
lblTimerT->setGeometry(QRect(300, 50, 20, 20));
lineEditTimerT = new QLineEdit(frame_2);
lineEditTimerT->setObjectName(QStringLiteral("lineEditTimerT"));
lineEditTimerT->setGeometry(QRect(320, 50, 21, 20));
horizontalLayout_2->addWidget(frame_2);
horizontalLayout_3->addLayout(horizontalLayout_2);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QStringLiteral("menubar"));
menubar->setGeometry(QRect(0, 0, 1103, 21));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QStringLiteral("statusbar"));
MainWindow->setStatusBar(statusbar);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", nullptr));
btn_Next->setText(QApplication::translate("MainWindow", ">", nullptr));
btn_Run->setText(QApplication::translate("MainWindow", ">>", nullptr));
btn_Pause->setText(QApplication::translate("MainWindow", "||", nullptr));
cmbo_RunSpeed->setItemText(0, QApplication::translate("MainWindow", "Debug", nullptr));
cmbo_RunSpeed->setItemText(1, QApplication::translate("MainWindow", "Full", nullptr));
lblRegA->setText(QApplication::translate("MainWindow", "A", nullptr));
lblRegB->setText(QApplication::translate("MainWindow", "B", nullptr));
lblRegC->setText(QApplication::translate("MainWindow", "C", nullptr));
lblRegD->setText(QApplication::translate("MainWindow", "D", nullptr));
lblRegE->setText(QApplication::translate("MainWindow", "E", nullptr));
lblRegH->setText(QApplication::translate("MainWindow", "H", nullptr));
lblRegL->setText(QApplication::translate("MainWindow", "L", nullptr));
lblRegFlag->setText(QApplication::translate("MainWindow", "Flag", nullptr));
lblRegPC->setText(QApplication::translate("MainWindow", "PC", nullptr));
lblRegSP->setText(QApplication::translate("MainWindow", "SP", nullptr));
lblRegBC->setText(QApplication::translate("MainWindow", "BC", nullptr));
lblRegDE->setText(QApplication::translate("MainWindow", "DE", nullptr));
lblRegHL->setText(QApplication::translate("MainWindow", "HL", nullptr));
groupBox_debugSection->setTitle(QApplication::translate("MainWindow", "Debug", nullptr));
lbl_breakOnPC->setText(QApplication::translate("MainWindow", "Break on PC", nullptr));
cmbo_BreakRegSelect->setItemText(0, QApplication::translate("MainWindow", "A", nullptr));
cmbo_BreakRegSelect->setItemText(1, QApplication::translate("MainWindow", "B", nullptr));
cmbo_BreakRegSelect->setItemText(2, QApplication::translate("MainWindow", "C", nullptr));
cmbo_BreakRegSelect->setItemText(3, QApplication::translate("MainWindow", "D", nullptr));
cmbo_BreakRegSelect->setItemText(4, QApplication::translate("MainWindow", "E", nullptr));
cmbo_BreakRegSelect->setItemText(5, QApplication::translate("MainWindow", "H", nullptr));
cmbo_BreakRegSelect->setItemText(6, QApplication::translate("MainWindow", "L", nullptr));
cmbo_BreakRegSelect->setItemText(7, QApplication::translate("MainWindow", "BC", nullptr));
cmbo_BreakRegSelect->setItemText(8, QApplication::translate("MainWindow", "DE", nullptr));
cmbo_BreakRegSelect->setItemText(9, QApplication::translate("MainWindow", "HL", nullptr));
lblBreakOnReg->setText(QApplication::translate("MainWindow", "Break on Register", nullptr));
lbl_BreakRegVal->setText(QApplication::translate("MainWindow", "Value", nullptr));
btn_AddPCBreak->setText(QApplication::translate("MainWindow", "Add", nullptr));
btn_AddRegBreak->setText(QApplication::translate("MainWindow", "Add", nullptr));
btn_RemoveBreak->setText(QApplication::translate("MainWindow", "Remove", nullptr));
QTableWidgetItem *___qtablewidgetitem = tbl_Breaks->horizontalHeaderItem(0);
___qtablewidgetitem->setText(QApplication::translate("MainWindow", "Reg", nullptr));
QTableWidgetItem *___qtablewidgetitem1 = tbl_Breaks->horizontalHeaderItem(1);
___qtablewidgetitem1->setText(QApplication::translate("MainWindow", "Value", nullptr));
chk_flagCarry->setText(QApplication::translate("MainWindow", "Carry", nullptr));
chk_flagHalfCarry->setText(QApplication::translate("MainWindow", "Half Carry", nullptr));
chk_flagSubOp->setText(QApplication::translate("MainWindow", "Sub", nullptr));
chk_flagZero->setText(QApplication::translate("MainWindow", "Zero", nullptr));
lblTimerM->setText(QApplication::translate("MainWindow", "m", nullptr));
lblTimerT->setText(QApplication::translate("MainWindow", "t", nullptr));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // DEBUGWINDOWRLIOOG_H
| [
"craig.bishop@vcatechnology.com"
] | craig.bishop@vcatechnology.com |
5a0bae524e02035ce3a73c04c02eb3b19163fdf2 | b992358888e045eff5ccb143f44ddae5ea799a40 | /ExerciciosAeds/ModRecursivo.cpp | 7dd464cccf8a866d7e26c8274a9a7a90bce2fdae | [] | no_license | Matheusxlive99/ExeciciosAeds | 3b374ea05d1142c0dbfb7620bff275dae90d47c8 | 5ab0ac21b83939f98a3c5db32d4116111fa0f18d | refs/heads/master | 2020-07-13T21:56:40.819750 | 2019-10-04T13:01:49 | 2019-10-04T13:01:49 | 205,163,252 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 663 | cpp | #include <iostream>
#include <locale>
//Matheus Felipe
//Exercicio 5
using namespace std;
int Mod(int x, int y){
if(x>y){
return Mod(x-y,y);//Caso base
}
else if(x<y){//Chmada recursiva 1
return x;
}
else{ //demais casos
return 0;
}
}
int main()
{
setlocale(LC_ALL, "Portuguese");
int x,y;
cout<<"Você deseja calcular o resto da divisão de: "<<endl;
cin>>x;
cout<<"\n";//Quebra de linha
cout<<"Por: "<<endl;
cin>>y;
cout<<"\n";
cout<<"O Resto da divisão de "<<x<<" por "<<y<<" é: "<<endl;
cout<<"\n";
cout<<Mod(x,y);//Chamada da função recursiva
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
5e38e1ea71e3ed214b77d005eeee8c2accf76ca9 | fcbd714c3812d3dde82f5d4fa5454619e1506c2e | /log4cplus/demos/log4cplus_demo.cpp | f639cdeef8820c491e3b8c45412b0105ed424b38 | [] | no_license | jjfsq1985/cplusplus | 1df8d54bc9517a15d05cf03cd5af8df3d0608c10 | 2b574c3f127ec9761388a1eeb02a2721fc1a3bd4 | refs/heads/master | 2020-04-12T06:17:23.795742 | 2017-10-18T08:46:34 | 2017-10-18T08:46:34 | 25,578,748 | 7 | 2 | null | null | null | null | GB18030 | C++ | false | false | 1,128 | cpp |
#include <iostream>
#include "log4cplus/configurator.h"
#include "log4cplus/loggingmacros.h"
#include "log4cplus/customappender.h"
#include "log4cplus/loglog.h"
using namespace std;
using namespace log4cplus;
static Logger logFile1 = Logger::getInstance("logFile1");
static Logger logFile2 = Logger::getInstance("logFile2");
#ifdef _WIN32
void __stdcall customFunc(const char* sz)
{
OutputDebugString(sz);
}
#else //__linux__
void customFunc(const char* sz)
{
//
}
#endif
int main()
{
log4cplus::CustomAppender::setCustomFunc(customFunc);
log4cplus::PropertyConfigurator::doConfigure("urconfig.properties");
LogLog::getLogLog()->setInternalDebugging(true);
for (int i = 0; i < 3; i++)
{
LOG4CPLUS_DEBUG(logFile1, "1中文logFile1.\n");
LOG4CPLUS_INFO(logFile1, "2中文logFile1.\n");
LOG4CPLUS_ERROR(logFile1, "4中文logFile1.\n");
LOG4CPLUS_FATAL(logFile1, "5中文logFile1.\n");
LOG4CPLUS_DEBUG(logFile2, "1中文logFile2.\n");
LOG4CPLUS_INFO(logFile2, "2中文logFile2.\n");
LOG4CPLUS_ERROR(logFile2, "4中文logFile2.\n");
LOG4CPLUS_FATAL(logFile2, "5中文logFile2.\n");
}
return 0;
}
| [
"jjfsq1985@gmail.com"
] | jjfsq1985@gmail.com |
72a3e643e8201a4f52d7a45df35d5f5c18e4b31a | ae7caa892571146c2747e74d19f52fb98cdb791c | /airec/src/model/DescribeExposureSettingsRequest.cc | 42848ddcca4676f5e825b8c46d799e06e16fde14 | [
"Apache-2.0"
] | permissive | hitlqh/aliyun-openapi-cpp-sdk | f01460a23d0370301b99a84b4c3b1563d74a763b | 65f76cc2c832833341cd18118abba666037edaa9 | refs/heads/master | 2023-03-14T04:03:37.128843 | 2021-03-08T03:22:15 | 2021-03-08T03:22:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,326 | cc | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/airec/model/DescribeExposureSettingsRequest.h>
using AlibabaCloud::Airec::Model::DescribeExposureSettingsRequest;
DescribeExposureSettingsRequest::DescribeExposureSettingsRequest() :
RoaServiceRequest("airec", "2018-10-12")
{
setResourcePath("/openapi/instances/[InstanceId]/exposure-settings");
setMethod(HttpRequest::Method::Get);
}
DescribeExposureSettingsRequest::~DescribeExposureSettingsRequest()
{}
std::string DescribeExposureSettingsRequest::getInstanceId()const
{
return instanceId_;
}
void DescribeExposureSettingsRequest::setInstanceId(const std::string& instanceId)
{
instanceId_ = instanceId;
setParameter("InstanceId", instanceId);
}
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
ff1ce26eea3a5eb24a9977a1f00bb86e0a92b64f | afdcb0197d1b0fca263951df435fa92a3cb10b07 | /hbs_context.cpp | 5b782bf5e6177902a5f7271b3e3e615aa34f1683 | [] | no_license | mugisaku/hbscript | 065daae4e7fd23957d9d18679ca99f5dbf986d11 | 32b33c46d001e0b0ec9acae15f976b5ccf994c01 | refs/heads/master | 2020-04-06T03:37:28.837271 | 2016-07-25T04:03:04 | 2016-07-25T04:03:04 | 63,355,887 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,140 | cpp | #include"hbs_context.hpp"
#include"hbs_memory.hpp"
#include"hbs_expression_node.hpp"
#include"hbs_block.hpp"
#include"hbs_function.hpp"
#include"hbs_calling.hpp"
#include"hbs_structure.hpp"
Context::
Context(Memory& mem, Block& gblk):
memory(mem),
global_block(gblk)
{
}
FunctionFrame&
Context::
get_top_frame()
{
return functionframe_list.back();
}
int
Context::
get_level() const
{
return functionframe_list.size();
}
Memory&
Context::
get_memory()
{
return memory;
}
const Memory&
Context::
get_const_memory() const
{
return memory;
}
void
Context::
release_auto_object(const ObjectList& objls)
{
for(auto& obj: objls)
{
if(obj.kind == ObjectKind::auto_variable)
{
memory[obj.value].clear();
}
}
}
Value
Context::
call(const Function& fn, const Calling& cal)
{
if(fn.parameters.size() != cal.arguments.size())
{
report;
printf("仮引数に対して、実引数の数が一致しません\n");
return false;
}
int n = fn.parameters.size();
auto arg_it = cal.arguments.cbegin();
auto prm_it = fn.parameters.cbegin();
ObjectList buf;
while(n--)
{
auto& prm = *prm_it++;
auto& arg = *arg_it++;
auto argval = arg.get_value(*this);
make_auto_object(buf,prm.identifier,prm.flags,argval);
}
functionframe_list.emplace_back(fn,cal);
Value retval;
enter(fn,std::move(buf),retval);
functionframe_list.back().leave(*this);
functionframe_list.pop_back();
return std::move(retval);
}
void
Context::
make_auto_object(ObjectList& buf, const std::string& id, int flags, const Value& val)
{
if(flags&Parameter::reference_flag)
{
if(val.kind != ValueKind::reference)
{
printf("式の値が参照型ではありません\n");
}
buf.emplace_back(std::string(id),flags,ObjectKind::reference,val.data.i);
}
else
{
Pointer ptr = memory.allocate();
buf.emplace_back(std::string(id),flags,ObjectKind::auto_variable,ptr);
if(val.kind == ValueKind::expression)
{
memory[ptr] = val.data.expr->get_value(*this);
}
else
if(val.kind == ValueKind::structure)
{
val.data.st->initialize(*this);
memory[ptr] = val;
}
else
{
memory[ptr] = val;
}
}
}
void
Context::
make_auto_object(const std::string& id, int flags, const Value& val)
{
make_auto_object(get_top_frame().get_top_frame()->get_object_list(),id,flags,val);
}
const Object*
Context::
find_object(const std::string& id) const
{
if(functionframe_list.size())
{
auto obj = functionframe_list.back().find_object(id);
if(obj)
{
return obj;
}
}
return global_block.find_static_object(id);
}
void
Context::
print() const
{
printf("****\n");
auto n = functionframe_list.size();
printf("context level is %3d\n",n);
if(n)
{
functionframe_list.back().print(memory);
}
global_block.print(memory);
printf("****\n\n");
}
| [
"lentilspring@gmail.com"
] | lentilspring@gmail.com |
82241bacca355e475ffa8e9f8b7a179afcdb7905 | 1ecbd7ec752a7ac20dc1a9e4556cfd47a68494ee | /scopehal/OscilloscopeChannel.cpp | 3ed85ba1479a9236b1e4691de9736dc799af7440 | [
"BSD-3-Clause"
] | permissive | CyberpunkDre/scopehal | a205dda79803345556f8463417adff7bf740f25d | d9772b64012d66827db1c8359b2b60f73a7bc9b9 | refs/heads/master | 2023-02-01T06:01:19.854198 | 2020-12-19T23:11:33 | 2020-12-19T23:11:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,139 | cpp | /***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/
/**
@file
@author Andrew D. Zonenberg
@brief Implementation of OscilloscopeChannel
*/
#include "scopehal.h"
#include "OscilloscopeChannel.h"
using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction
OscilloscopeChannel::OscilloscopeChannel(
Oscilloscope* scope,
const string& hwname,
OscilloscopeChannel::ChannelType type,
const string& color,
int width,
size_t index,
bool physical)
: m_displaycolor(color)
, m_displayname(hwname)
, m_scope(scope)
, m_type(type)
, m_hwname(hwname)
, m_width(width)
, m_index(index)
, m_physical(physical)
, m_refcount(0)
, m_xAxisUnit(Unit::UNIT_FS)
, m_yAxisUnit(Unit::UNIT_VOLTS)
{
SharedCtorInit();
}
OscilloscopeChannel::OscilloscopeChannel(
Oscilloscope* scope,
const string& hwname,
OscilloscopeChannel::ChannelType type,
const string& color,
Unit xunit,
Unit yunit,
int width,
size_t index,
bool physical)
: m_displaycolor(color)
, m_displayname(hwname)
, m_scope(scope)
, m_type(type)
, m_hwname(hwname)
, m_width(width)
, m_index(index)
, m_physical(physical)
, m_refcount(0)
, m_xAxisUnit(xunit)
, m_yAxisUnit(yunit)
{
SharedCtorInit();
}
void OscilloscopeChannel::SharedCtorInit()
{
//Create a stream for our output.
//Normal channels only have one stream.
//Special instruments like SDRs with complex output, or filters/decodes, can have arbitrarily many.
AddStream("data");
}
/**
@brief Gives a channel a default display name if there's not one already.
MUST NOT be called until the channel has been added to its parent scope.
*/
void OscilloscopeChannel::SetDefaultDisplayName()
{
//If we have a scope, m_displayname is ignored.
//Start out by pulling the name from hardware.
//If it's not set, use our hardware name as the default.
if(m_scope)
{
auto name = m_scope->GetChannelDisplayName(m_index);
if(name == "")
m_scope->SetChannelDisplayName(m_index, m_hwname);
}
}
OscilloscopeChannel::~OscilloscopeChannel()
{
for(auto p : m_streamData)
delete p;
m_streamData.clear();
m_streamNames.clear();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Helpers for calling scope functions
void OscilloscopeChannel::AddRef()
{
if(m_refcount == 0)
Enable();
m_refcount ++;
}
void OscilloscopeChannel::Release()
{
m_refcount --;
if(m_refcount == 0)
Disable();
}
double OscilloscopeChannel::GetOffset()
{
if(m_scope != NULL)
return m_scope->GetChannelOffset(m_index);
else
return 0;
}
void OscilloscopeChannel::SetOffset(double offset)
{
if(m_scope != NULL)
m_scope->SetChannelOffset(m_index, offset);
}
bool OscilloscopeChannel::IsEnabled()
{
if(m_scope != NULL)
return m_scope->IsChannelEnabled(m_index);
else
return true;
}
void OscilloscopeChannel::Enable()
{
if(m_scope != NULL)
m_scope->EnableChannel(m_index);
}
void OscilloscopeChannel::Disable()
{
if(m_scope != NULL)
m_scope->DisableChannel(m_index);
}
OscilloscopeChannel::CouplingType OscilloscopeChannel::GetCoupling()
{
if(m_scope)
return m_scope->GetChannelCoupling(m_index);
else
return OscilloscopeChannel::COUPLE_SYNTHETIC;
}
void OscilloscopeChannel::SetCoupling(CouplingType type)
{
if(m_scope)
m_scope->SetChannelCoupling(m_index, type);
}
double OscilloscopeChannel::GetAttenuation()
{
if(m_scope)
return m_scope->GetChannelAttenuation(m_index);
else
return 1;
}
void OscilloscopeChannel::SetAttenuation(double atten)
{
if(m_scope)
m_scope->SetChannelAttenuation(m_index, atten);
}
int OscilloscopeChannel::GetBandwidthLimit()
{
if(m_scope)
return m_scope->GetChannelBandwidthLimit(m_index);
else
return 0;
}
void OscilloscopeChannel::SetBandwidthLimit(int mhz)
{
if(m_scope)
m_scope->SetChannelBandwidthLimit(m_index, mhz);
}
double OscilloscopeChannel::GetVoltageRange()
{
if(m_scope)
return m_scope->GetChannelVoltageRange(m_index);
else
return 1; //TODO: get from input
}
void OscilloscopeChannel::SetVoltageRange(double range)
{
if(m_scope)
return m_scope->SetChannelVoltageRange(m_index, range);
}
void OscilloscopeChannel::SetDeskew(int64_t skew)
{
if(m_scope)
m_scope->SetDeskewForChannel(m_index, skew);
}
int64_t OscilloscopeChannel::GetDeskew()
{
if(m_scope)
return m_scope->GetDeskewForChannel(m_index);
return 0;
}
void OscilloscopeChannel::SetDigitalHysteresis(float level)
{
if(m_scope)
m_scope->SetDigitalHysteresis(m_index, level);
}
void OscilloscopeChannel::SetDigitalThreshold(float level)
{
if(m_scope)
m_scope->SetDigitalThreshold(m_index, level);
}
void OscilloscopeChannel::SetCenterFrequency(int64_t freq)
{
if(m_scope)
m_scope->SetCenterFrequency(m_index, freq);
}
void OscilloscopeChannel::SetDisplayName(string name)
{
if(m_scope)
m_scope->SetChannelDisplayName(m_index, name);
else
m_displayname = name;
}
string OscilloscopeChannel::GetDisplayName()
{
if(m_scope)
return m_scope->GetChannelDisplayName(m_index);
else
return m_displayname;
}
bool OscilloscopeChannel::CanInvert()
{
if(m_scope)
return m_scope->CanInvert(m_index);
else
return false;
}
void OscilloscopeChannel::Invert(bool invert)
{
if(m_scope)
m_scope->Invert(m_index, invert);
}
bool OscilloscopeChannel::IsInverted()
{
if(m_scope)
return m_scope->IsInverted(m_index);
else
return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors
void OscilloscopeChannel::SetData(WaveformBase* pNew, size_t stream)
{
if(m_streamData[stream] == pNew)
return;
if(m_streamData[stream] != NULL)
delete m_streamData[stream];
m_streamData[stream] = pNew;
}
| [
"azonenberg@drawersteak.com"
] | azonenberg@drawersteak.com |
3725647139bec20c3b8a5980f72fe83d6ec59c11 | e0272152c6fadf91dd3567605c77e700706df812 | /BuscaPelotas/buscaPelotas.h | 1638e446fdb42e7a665bdd76a44df8bb0dd91f6a | [] | no_license | saulibanez/Robotica | bb0e4cae009463bce4d990f35f0ac343d03970ae | 05ee6ceaf1bca7816befab482d72caa90f914497 | refs/heads/master | 2021-01-10T04:05:26.379192 | 2016-01-20T23:21:20 | 2016-01-20T23:21:20 | 50,067,095 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,198 | h | /*
* Autor: Saúl Ibáñez Cerro
*/
#ifndef BuscoPelotas
#define BuscoPelotas
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <kobuki_msgs/Sound.h>
#include "usarPid.h"
#include "time.h"
class Pelotas{
public:
Pelotas();
void OperarBuscarPelotas(const sensor_msgs::ImageConstPtr& msg);
private:
float x,y,vx;
int contadorPixeles;
int hUpper, hLower;
int sUpper, sLower;
int vUpper, vLower;
int estados;
int height;
int width;
int step;
int channels;
//creo las variables para usar el PID
float error;
Pid velDeGiro;
Pid TotalMedia;
float usoPid;
static const int Avance=0;
static const int Gira_Avanza=1;
static const int Gira=2;
static const int Pito=3;
ros::Time begin;
ros::Time later;
ros::NodeHandle nh_;
kobuki_msgs::Sound sound;
geometry_msgs::Twist Coordenadas;
ros::Subscriber sub;
ros::Publisher chatter_pub;
ros::Publisher sonido;
bool VerPelotaRoja, VerPelotaNarPeq, VerPelotaNarGra;
bool exitRoja,exitNarPeq,exitNarGra;
int arr [10];
int ValueH;
int ValueS;
int ValueV;
int contador;
int TotalFiltrado;
int SumarCeldasArray;
float Total;
};
#endif | [
"saul.ibanez.cerro@gmail.com"
] | saul.ibanez.cerro@gmail.com |
742a67dc9ade5efb912c07fac1104c47bf216ffa | 90d39aa2f36783b89a17e0687980b1139b6c71ce | /SPOJ/PERIOD.cpp | 2b097ac2f4cc559e5ad80c6853d95208ff150ee7 | [] | no_license | nims11/coding | 634983b21ad98694ef9badf56ec8dfc950f33539 | 390d64aff1f0149e740629c64e1d00cd5fb59042 | refs/heads/master | 2021-03-22T08:15:29.770903 | 2018-05-28T23:27:37 | 2018-05-28T23:27:37 | 247,346,971 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,198 | cpp | /*
Nimesh Ghelani (nims11)
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<utility>
#define in_T int t;for(scanf("%d",&t);t--;)
#define in_I(a) scanf("%d",&a)
#define in_F(a) scanf("%lf",&a)
#define in_L(a) scanf("%lld",&a)
#define in_S(a) scanf("%s",a)
#define newline printf("\n")
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define SWAP(a,b) {int tmp=a;a=b;b=tmp;}
#define P_I(a) printf("%d",a)
#include<cstring>
using namespace std;
char str[1000003];
int n;
int pref_f[1000003];
void calc_pref_f()
{
pref_f[0] = 0;
int k = 0;
for(int q=1;q<n;q++)
{
while(k && str[k] != str[q])
k = pref_f[k-1];
if(str[k] == str[q])
k++;
pref_f[q] = k;
// cout<<k<<endl;
if(k != 0 && (q+1)%(q+1-k) == 0)
printf("%d %d\n", q+1, (q+1)/(q+1-k));
}
}
int main()
{
int c = 0;
in_T
{
c++;
in_I(n);
in_S(str);
printf("Test case #%d\n", c);
calc_pref_f();
newline;
}
}
| [
"nimeshghelani@gmail.com"
] | nimeshghelani@gmail.com |
68db349a0188a28d6693d7a338287b9b63789174 | c6fae54cb4aec39e228254a99a50dd8bc0546af4 | /cpp/linked_list/445_add_two_numbers_2.cpp | 975f6a1f358829da6b25dc7723f0b148fc5da9e0 | [] | no_license | songanz/Learn_coding | 77c08d61c9a4f2917f147624c2e8013148588311 | e2185b4c936b226f106e4f7f449b2b50a463f9e9 | refs/heads/master | 2020-04-18T05:36:21.586154 | 2020-04-13T18:30:23 | 2020-04-13T18:30:23 | 167,284,886 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,744 | cpp | #include "../header.h"
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
// 利用stack后进先出的数据结构
class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
stack<int> list1;
stack<int> list2;
while (l1) {
list1.push(l1->val);
l1 = l1->next;
}
while (l2) {
list2.push(l2->val);
l2 = l2->next;
}
ListNode* header = new ListNode(0);
int res = 0;
while (!list1.empty() || !list2.empty()) {
int n1 = list1.empty() ? 0 : list1.top();
int n2 = list2.empty() ? 0 : list2.top();
int val = n1 + n2 + res;
if (val >= 10) {
// insert node right after the header
ListNode* temp = new ListNode(val-10);
temp->next = header->next;
header->next = temp;
res = 1;
}
else {
ListNode* temp = new ListNode(val);
temp->next = header->next;
header->next = temp;
res = 0;
}
if (!list1.empty()) list1.pop();
if (!list2.empty()) list2.pop();
}
if (res != 0) {
ListNode* temp = new ListNode(res);
temp->next = header->next;
header->next = temp;
}
return header->next;
}
// 用list也行,就是有各种push_back, pop_top啥的
ListNode* addTwoNumbers2(ListNode* l1, ListNode* l2) {
list<int> n1;
list<int> n2;
ListNode* ans = new ListNode(0);
ListNode* head = ans;
while (l1) {
n1.push_back(l1->val);
l1 = l1->next;
}
while (l2) {
n2.push_back(l2->val);
l2 = l2->next;
}
list<int> num;
int res = 0;
while (n1.size() != 0 or n2.size() != 0) {
int d1 = 0;
if (n1.size() != 0) {
d1 = n1.back();
n1.pop_back();
}
int d2 = 0;
if (n2.size() != 0) {
d2 = n2.back();
n2.pop_back();
}
int a = d1 + d2 + res;
if (a>=10) {
num.push_front(a-10);
res = 1;
}
else {
num.push_front(a);
res = 0;
}
}
if (res != 0) num.push_front(res);
while (num.size() != 0) {
head->val = num.front();
num.pop_front();
if (num.size() != 0) {
head->next = new ListNode(0);
head = head->next;
}
}
return ans;
}
};
int main() {
Solution s;
vector<ListNode*> lists;
ListNode l1(1);
ListNode l2(1);
ListNode l3(2);
ListNode temp(4);
l1.next = &temp;
ListNode temp2(5);
temp.next = &temp2;
ListNode temp3(3);
l2.next = &temp3;
ListNode temp4(4);
temp.next = &temp4;
ListNode temp5(6);
l3.next = &temp5;
lists.push_back(&l1);
lists.push_back(&l2);
lists.push_back(&l3);
ListNode* ans = s.addTwoNumbers(lists[0], lists[1]);
while (ans){
cout << ans->val << ',';
ans = ans->next;
}
cout << "\n";
ListNode* ans2 = s.addTwoNumbers2(lists[0], lists[1]);
while (ans2){
cout << ans2->val << ',';
ans2 = ans2->next;
}
cout << "\n";
} | [
"songanz@umich.edu"
] | songanz@umich.edu |
86f5e25d733347b0ab9995d03947c4be7482871a | a5d6c1040f264bfa8e2cc1f5472edae7457b15f5 | /src/percvoice.cpp | 1d0ac8e1889d8dad3e3e8a8c79b44d0542f6e802 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | rossco255/moduleDEV | 9f5830477fd6c21ac1e34105d89fbcc8f3483d89 | 2e4263e27231c7e35647e124f8c4aa923a819687 | refs/heads/master | 2021-04-09T15:08:55.568923 | 2018-03-27T21:37:56 | 2018-03-27T21:37:56 | 125,685,070 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 53,968 | cpp | //
// percvoice.cpp
// rackdevstuff
//
// Created by Ross Cameron on 25/03/2018.
// Copyright © 2018 Ross Cameron. All rights reserved.
//
#include "percvoice.hpp"
extern float sawTable[2048];
extern float triTable[2048];
////////////////
////VCO section from Fundamental VCO by Andrew Belt
////There's some functionality in here that isn't used eg pulsewidth, saw & sqr oscs, should maybe remove
template <int OVERSAMPLE, int QUALITY>
struct VoltageControlledOscillator {
float phase = 0.0f;
float freq;
float pw = 0.5f;
float pitch;
Decimator<OVERSAMPLE, QUALITY> sinDecimator;
Decimator<OVERSAMPLE, QUALITY> triDecimator;
Decimator<OVERSAMPLE, QUALITY> sawDecimator;
Decimator<OVERSAMPLE, QUALITY> sqrDecimator;
RCFilter sqrFilter;
// For analog detuning effect
float pitchSlew = 0.0f;
int pitchSlewIndex = 0;
float sinBuffer[OVERSAMPLE] = {};
float triBuffer[OVERSAMPLE] = {};
float sawBuffer[OVERSAMPLE] = {}; //not used
float sqrBuffer[OVERSAMPLE] = {}; //not used
void setPitch(float pitchKnob, float pitchCv) { //pitch param knob and modulation from the LFO
// Compute frequency
pitch = pitchKnob;
// Apply pitch slew
const float pitchSlewAmount = 3.0f;
pitch += pitchSlew * pitchSlewAmount;
pitch += pitchCv;
// Note C4
freq = 261.626f * powf(2.0f, pitch / 12.0f);
}
void setPulseWidth(float pulseWidth) { //not used
const float pwMin = 0.01f;
pw = clamp(pulseWidth, pwMin, 1.0f - pwMin);
}
void process(float deltaTime) {
// Adjust pitch slew
if (++pitchSlewIndex > 32) {
const float pitchSlewTau = 100.0f; // Time constant for leaky integrator in seconds
pitchSlew += (randomNormal() - pitchSlew / pitchSlewTau) * engineGetSampleTime();
pitchSlewIndex = 0;
}
// Advance phase
float deltaPhase = clamp(freq * deltaTime, 1e-6, 0.5f);
sqrFilter.setCutoff(40.0f * deltaTime);
for (int i = 0; i < OVERSAMPLE; i++) {
// Quadratic approximation of sine, slightly richer harmonics
if (phase < 0.5f)
sinBuffer[i] = 1.f - 16.f * powf(phase - 0.25f, 2);
else
sinBuffer[i] = -1.f + 16.f * powf(phase - 0.75f, 2);
sinBuffer[i] *= 1.08f;
triBuffer[i] = 1.25f * interpolateLinear(triTable, phase * 2047.f);
sawBuffer[i] = 1.66f * interpolateLinear(sawTable, phase * 2047.f);
sqrBuffer[i] = (phase < pw) ? 1.f : -1.f;
// Simply filter here
sqrFilter.process(sqrBuffer[i]);
sqrBuffer[i] = 0.71f * sqrFilter.highpass();
// Advance phase
phase += deltaPhase / OVERSAMPLE;
phase = eucmod(phase, 1.0f);
}
}
float sin() {
return sinDecimator.process(sinBuffer);
}
float tri() {
return triDecimator.process(triBuffer);
}
float saw() { //not used
return sawDecimator.process(sawBuffer);
}
float sqr() { //not used
return sqrDecimator.process(sqrBuffer);
}
float light() { //not used
return sinf(2*M_PI * phase);
}
};
////////////////
////LFO section from Fundamental LFO by Andrew Belt
struct LowFrequencyOscillator {
float phase = 0.0;
float pw = 0.5;
float freq = 1.0;
float sample = 0;
SchmittTrigger resetTrigger;
LowFrequencyOscillator() {}
void setPitch(float pitch) { //value is from mod-speed knob param
pitch = fminf(pitch, 8.0);
freq = powf(2.0, pitch);
}
void setReset(float reset) { //reset is used to sync the LFO with the gate triggers
if (resetTrigger.process(reset / 0.01f )) {
phase = 0.0;
}
}
void step(float dt) {
float deltaPhase = fminf(freq * dt, 0.5);
phase += deltaPhase;
if (phase >= 1.0) {
phase -= 1.0;
sample = randomNormal() / 2.3548;
}
}
float tri(float x) {
return 4.0 * fabsf(x - roundf(x));
}
float tri() {
return -1.0 + tri(phase - 0.75);
}
float saw(float x) { return 2.0 * (x - roundf(x)); }
float saw() { return saw(phase); }
float sqr() {
float sqr = (phase < pw) ? 1.0 : -1.0;
return sqr;
}
float light() {
return sinf(2*M_PI * phase);
}
};
////////////////
////decay section from Fundamental ADSR by Andrew Belt
struct decay {
float output = 0.0;
bool decaying = false;
float env = 0.0;
SchmittTrigger trigger;
const float base = 20000.0;
const float maxTime = 1.0;
float decay = 0.0;
bool gated = false;
void setDecay (float decayParamValue){ //value taken from decay param knob
decay = clamp(decayParamValue, 0.0f, 1.0f);
}
void setGated (float gateInputValue) {
gated = gateInputValue >= 1.0f;
}
void process (float decayParamValue, float gateInputValue, float attack) {
setDecay(decayParamValue);
setGated(gateInputValue);
if (gated) {
if (decaying){
// Decay
if (decay < 1e-4){
env = 0;}
else{
env += powf(base, 1 - decay) / maxTime * (0 - env) * engineGetSampleTime();}
}
else{
env += powf(base, 1 - attack) / maxTime * (1.01f - env) * engineGetSampleTime();
if (env >= 1.0f) {
env = 1.0f;
decaying = true;
}
}
}
else{
// Release
if (decay < 1e-4) {
env = 0.0f;}
else {
env += powf(base, 1 - decay) / maxTime * (0.0f - env) * engineGetSampleTime();}
decaying = false;
}
}
float envOut(){
output = 10 * env;
return output;
}
};
////////////////
////S&H taken from Audible Instruments Utilities by Andrew Belt
struct sampleHold {
float env = 0.0;
SchmittTrigger trigger;
float sample = 0.0;
float noiseGen (){
float noise = 2.0 * randomNormal();
return noise;
}
void process (float sqr){ //S&H is clocked by the sqr output of the LFO
// Gaussian noise generator
float noise = noiseGen();
// S&H
if (trigger.process(sqr / 0.7)) {
sample = noise;
}
}
float SHout (){
return sample;
}
};
////////////////
////VCA section from Fundamental VCA by Andrew Belt
float VCA (float OSCIn, float envIn, float levelParamValue) {
float v = OSCIn * levelParamValue;
const float expBase = 50.0f;
v *= rescale(powf(expBase, clamp(envIn / 10.0f, 0.0f, 1.0f)), 1.0f, expBase, 0.0f, 1.0f);
return v;
};
struct percvoice : Module {
enum ParamIds {
PITCH_PARAM,
WAVE_PARAM,
MODDEPTH_PARAM,
MODRATE_PARAM,
MODTYPE_PARAM,
LEVEL_PARAM,
DECAY_PARAM,
NUM_PARAMS
};
enum InputIds {
GATE_INPUT,
NUM_INPUTS
};
enum OutputIds {
AUDIO_OUTPUT,
NUM_OUTPUTS
};
enum LightIds {
NUM_LIGHTS
};
VoltageControlledOscillator<16, 16> oscillator;
LowFrequencyOscillator mod;
sampleHold SH;
decay envmod;
decay VCAenv;
SchmittTrigger oscTypeTrig;
float modValue = 0.0;
int modType = 0;
float oscValue = 0.0;
bool oscType = true;
const float expBase = 50.0f;
percvoice() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
void step() override;
};
void percvoice::step() {
//VCO wave button
if (oscTypeTrig.process(params[WAVE_PARAM].value)){
oscType ^= true;
}
//option for not having the vca be gate triggered?????
/////////modulators
//LFO
mod.setPitch(params[MODRATE_PARAM].value);
mod.step(1.0 / engineGetSampleRate());
mod.setReset(inputs[GATE_INPUT].value);
//S&H
SH.process(mod.sqr());
//Noise is generated during S&H process
//Env
envmod.process(params[MODRATE_PARAM].value, inputs[GATE_INPUT].value, 0.1);
//modulation type
modType = round(params[MODTYPE_PARAM].value);
switch (modType) {
case 0:
modValue = mod.saw();
break;
case 1:
modValue = mod.sqr();
break;
case 2:
modValue = mod.tri();
break;
case 3:
modValue = SH.SHout();
break;
case 4:
modValue = SH.noiseGen();
break;
case 5:
modValue = envmod.envOut();
break;
default:
break;
}
//oscillator
oscillator.setPitch(params[PITCH_PARAM].value,(quadraticBipolar(modValue) * 12.0f));
oscillator.process(engineGetSampleTime());
if (oscType){
oscValue = 5.0f * oscillator.sin();
}
else{
oscValue = 5.0f * oscillator.tri();
}
//should add clipping and bass boost????
//output
VCAenv.process(params[DECAY_PARAM].value, inputs[GATE_INPUT].value, 0.3);
outputs[AUDIO_OUTPUT].value = VCA(oscValue, VCAenv.envOut(), params[LEVEL_PARAM].value);
};
struct percvoiceWidget : ModuleWidget {
percvoiceWidget(percvoice *module) : ModuleWidget(module){
box.size = Vec(6 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
{
SVGPanel *panel = new SVGPanel();
panel->box.size = box.size;
panel->setBackground(SVG::load(assetPlugin(plugin, "res/percvoice.svg")));
addChild(panel);
}
addInput(Port::create<PJ301MPort>(Vec(60, 15), Port::INPUT, module, percvoice::GATE_INPUT));
addParam(ParamWidget::create<TL1105>(Vec(10, 10), module, percvoice::WAVE_PARAM, 0.0f, 1.0f, 0.0f));
addParam(ParamWidget::create<Rogan1PSRed>(Vec(10, 60), module, percvoice::PITCH_PARAM, -54.0f, 54.0f, 0.0f));
addParam(ParamWidget::create<Rogan1PSRed>(Vec(10, 110), module, percvoice::MODDEPTH_PARAM, -1.0f, 1.0f, 0.0f));
addParam(ParamWidget::create<Rogan1PSRed>(Vec(10, 160), module, percvoice::MODRATE_PARAM, -8.0f, 6.0f, -1.0f));
addParam(ParamWidget::create<Rogan1PSGreenSnap>(Vec(10, 210), module, percvoice::MODTYPE_PARAM, 0.0f, 5.0f, 0.0f));
addParam(ParamWidget::create<Rogan1PSRed>(Vec(10, 260), module, percvoice::LEVEL_PARAM, 0.0f, 1.0f, 0.0f));
addParam(ParamWidget::create<Rogan1PSRed>(Vec(10, 320), module, percvoice::DECAY_PARAM, 0.0f, 1.0f, 0.5f));
addOutput(Port::create<PJ301MPort>(Vec(60, 330), Port::OUTPUT, module, percvoice::AUDIO_OUTPUT));
}
};
Model *modelpercvoice = Model::create<percvoice, percvoiceWidget>("moduleDEV", "percvoice", "percvoice", SYNTH_VOICE_TAG, OSCILLATOR_TAG, ENVELOPE_GENERATOR_TAG, AMPLIFIER_TAG);
float sawTable[2048] = {
0.00221683, 0.00288535, 0.00382874, 0.00493397, 0.006088, 0.00717778, 0.0080962, 0.00887097, 0.00957292, 0.0102536, 0.0109644, 0.0117569, 0.0126765, 0.0137091, 0.014811, 0.0159388, 0.0170492, 0.0180987, 0.0190781, 0.0200243, 0.0209441, 0.0218439, 0.0227299, 0.023608, 0.0244664, 0.0253042, 0.0261303, 0.0269533, 0.0277823, 0.0286234, 0.0294678, 0.0303142, 0.0311635, 0.0320168, 0.0328749, 0.0337369, 0.0346001, 0.0354672, 0.0363411, 0.0372246, 0.0381206, 0.0390346, 0.039964, 0.0409017, 0.0418407, 0.042774, 0.0436961, 0.0446189, 0.0455409, 0.0464563, 0.047359, 0.0482433, 0.0491029, 0.049938, 0.0507563, 0.0515658, 0.0523744, 0.0531901, 0.0540067, 0.0548165, 0.0556269, 0.0564456, 0.0572799, 0.0581378, 0.0590252, 0.059934, 0.0608529, 0.0617707, 0.0626761, 0.0635623, 0.0644415, 0.0653142, 0.0661789, 0.0670339, 0.0678778, 0.0687058, 0.0695165, 0.070317, 0.0711147, 0.0719168, 0.0727304, 0.0735539, 0.0743828, 0.075215, 0.0760485, 0.0768811, 0.07771, 0.0785292, 0.0793449, 0.0801652, 0.080998, 0.0818513, 0.082737, 0.0836581, 0.0845968, 0.0855346, 0.0864532, 0.0873342, 0.0881769, 0.0889945, 0.0897932, 0.0905797, 0.0913603, 0.0921398, 0.0929034, 0.0936544, 0.0944023, 0.0951566, 0.0959267, 0.0967196, 0.0975297, 0.0983516, 0.09918, 0.10001, 0.100836, 0.101666, 0.102504, 0.103342, 0.104172, 0.104985, 0.105773, 0.106533, 0.107272, 0.107999, 0.108722, 0.109449, 0.110184, 0.110909, 0.11163, 0.112359, 0.113107, 0.113883, 0.114701, 0.115559, 0.116438, 0.117321, 0.118187, 0.119019, 0.11982, 0.120602, 0.121371, 0.122131, 0.122889, 0.123648, 0.124405, 0.125157, 0.125905, 0.126649, 0.127387, 0.128116, 0.128828, 0.129533, 0.130244, 0.130971, 0.131727, 0.132522, 0.133348, 0.134189, 0.13503, 0.135856, 0.136654, 0.137426, 0.138182, 0.13893, 0.13968, 0.140439, 0.141215, 0.142006, 0.142805, 0.143602, 0.144389, 0.145159, 0.145905, 0.146633, 0.147351, 0.148066, 0.148785, 0.149516, 0.150256, 0.151, 0.151747, 0.152495, 0.153242, 0.15399, 0.154742, 0.155496, 0.156248, 0.156992, 0.157725, 0.158443, 0.15915, 0.159849, 0.160542, 0.16123, 0.161916, 0.162592, 0.163258, 0.163921, 0.164589, 0.165267, 0.165962, 0.166664, 0.167374, 0.168094, 0.168827, 0.169575, 0.170347, 0.171149, 0.171967, 0.172788, 0.173595, 0.174376, 0.175127, 0.17586, 0.17658, 0.177293, 0.178003, 0.178717, 0.179439, 0.180163, 0.180879, 0.181579, 0.182254, 0.182887, 0.183461, 0.184006, 0.184553, 0.185136, 0.185786, 0.186519, 0.187312, 0.188146, 0.189001, 0.189859, 0.190701, 0.191556, 0.192426, 0.193296, 0.194149, 0.194968, 0.195739, 0.19647, 0.197172, 0.197852, 0.198518, 0.199177, 0.199827, 0.200455, 0.20107, 0.201683, 0.202303, 0.202941, 0.203594, 0.204255, 0.204924, 0.205599, 0.206279, 0.206967, 0.207672, 0.208389, 0.209106, 0.209812, 0.210497, 0.211154, 0.211791, 0.212413, 0.213022, 0.213622, 0.214216, 0.214789, 0.215338, 0.21588, 0.216432, 0.21701, 0.217632, 0.218309, 0.219022, 0.219748, 0.220466, 0.221152, 0.221789, 0.222391, 0.22297, 0.223536, 0.224097, 0.224665, 0.225227, 0.225769, 0.22631, 0.226866, 0.227457, 0.2281, 0.228809, 0.229566, 0.230349, 0.231134, 0.231897, 0.232619, 0.233316, 0.233998, 0.234672, 0.235345, 0.236023, 0.236715, 0.237415, 0.238118, 0.238815, 0.239499, 0.240162, 0.240802, 0.241424, 0.242035, 0.242638, 0.24324, 0.243846, 0.244452, 0.245055, 0.245654, 0.24625, 0.246841, 0.247425, 0.248001, 0.248572, 0.249141, 0.249711, 0.250285, 0.250867, 0.251454, 0.252043, 0.252627, 0.253202, 0.253762, 0.254314, 0.254859, 0.255395, 0.255918, 0.256428, 0.256916, 0.257372, 0.257809, 0.258245, 0.258695, 0.259177, 0.259689, 0.260217, 0.260762, 0.26133, 0.261924, 0.262549, 0.263221, 0.263934, 0.264667, 0.2654, 0.266114, 0.266792, 0.267451, 0.268097, 0.268732, 0.269357, 0.269973, 0.270576, 0.271158, 0.271729, 0.2723, 0.272879, 0.273479, 0.274107, 0.274757, 0.275414, 0.276063, 0.27669, 0.277282, 0.277837, 0.278368, 0.278887, 0.279406, 0.279937, 0.280489, 0.281057, 0.281633, 0.282207, 0.282772, 0.283319, 0.283845, 0.284355, 0.284855, 0.285351, 0.285848, 0.286353, 0.286861, 0.287368, 0.287877, 0.288389, 0.288904, 0.289424, 0.289941, 0.290461, 0.290987, 0.291524, 0.292076, 0.292648, 0.293238, 0.293841, 0.294449, 0.295058, 0.295663, 0.296276, 0.296899, 0.297519, 0.298127, 0.29871, 0.299257, 0.299765, 0.300247, 0.300716, 0.301185, 0.301669, 0.302178, 0.302707, 0.303244, 0.303774, 0.304286, 0.304765, 0.305192, 0.305574, 0.305941, 0.306323, 0.306748, 0.307245, 0.307827, 0.308466, 0.309123, 0.309764, 0.310351, 0.310859, 0.311312, 0.311727, 0.312122, 0.312512, 0.312915, 0.313329, 0.313739, 0.314148, 0.314558, 0.314972, 0.315393, 0.315812, 0.316231, 0.316656, 0.317095, 0.317554, 0.318043, 0.318572, 0.319125, 0.319683, 0.320227, 0.320739, 0.321207, 0.321641, 0.322057, 0.322467, 0.322886, 0.323327, 0.32378, 0.324239, 0.324707, 0.325188, 0.325686, 0.326205, 0.326755, 0.327327, 0.327907, 0.328484, 0.329045, 0.329585, 0.330116, 0.33064, 0.331156, 0.331664, 0.332165, 0.332653, 0.33313, 0.3336, 0.334068, 0.334539, 0.33502, 0.33552, 0.33603, 0.336536, 0.337024, 0.337481, 0.337893, 0.338261, 0.3386, 0.338927, 0.339258, 0.33961, 0.339982, 0.340358, 0.340742, 0.341136, 0.341541, 0.34196, 0.342407, 0.342874, 0.343348, 0.343815, 0.344261, 0.344675, 0.345061, 0.345429, 0.345787, 0.346144, 0.346507, 0.346879, 0.347253, 0.347628, 0.348002, 0.348377, 0.34875, 0.349118, 0.349481, 0.349845, 0.350216, 0.350597, 0.350995, 0.351411, 0.351838, 0.352273, 0.352708, 0.353139, 0.353563, 0.353984, 0.354404, 0.354824, 0.355243, 0.355661, 0.356077, 0.356489, 0.356901, 0.357316, 0.357737, 0.358168, 0.358608, 0.359055, 0.359506, 0.35996, 0.360414, 0.360869, 0.361328, 0.361789, 0.36225, 0.362706, 0.363154, 0.363596, 0.364034, 0.364466, 0.364893, 0.365313, 0.365724, 0.366133, 0.366538, 0.366935, 0.367317, 0.367681, 0.36802, 0.368324, 0.368606, 0.36888, 0.369159, 0.369458, 0.369786, 0.370135, 0.370494, 0.370854, 0.371206, 0.371541, 0.371852, 0.372145, 0.372432, 0.372726, 0.373037, 0.373377, 0.373753, 0.374151, 0.374555, 0.374948, 0.375316, 0.375645, 0.375944, 0.376225, 0.376497, 0.376772, 0.377061, 0.377367, 0.377681, 0.377998, 0.378314, 0.378622, 0.378916, 0.379197, 0.379469, 0.379735, 0.380002, 0.380274, 0.380552, 0.380831, 0.38111, 0.381395, 0.381687, 0.381992, 0.382311, 0.382642, 0.382983, 0.383329, 0.383676, 0.384021, 0.384367, 0.384716, 0.385066, 0.385417, 0.385767, 0.386116, 0.38647, 0.386824, 0.387177, 0.387522, 0.387858, 0.388187, 0.388517, 0.388841, 0.389149, 0.389433, 0.389684, 0.389883, 0.390037, 0.390171, 0.39031, 0.390476, 0.390693, 0.390945, 0.391221, 0.391516, 0.391825, 0.392141, 0.392465, 0.392808, 0.393164, 0.393524, 0.393881, 0.394226, 0.39456, 0.394891, 0.395217, 0.395538, 0.395851, 0.396157, 0.396451, 0.396736, 0.397016, 0.397296, 0.39758, 0.397874, 0.39818, 0.39849, 0.398797, 0.399095, 0.399375, 0.399634, 0.399877, 0.400107, 0.400331, 0.400554, 0.40078, 0.401001, 0.401216, 0.401431, 0.401652, 0.401885, 0.402136, 0.402411, 0.402699, 0.402992, 0.403279, 0.403551, 0.403804, 0.404051, 0.404289, 0.404515, 0.404728, 0.404924, 0.405086, 0.405215, 0.405334, 0.405465, 0.405629, 0.405848, 0.406118, 0.406424, 0.406751, 0.407085, 0.407412, 0.407728, 0.408054, 0.408384, 0.408707, 0.409011, 0.409286, 0.40952, 0.409718, 0.409896, 0.410074, 0.410268, 0.410495, 0.410756, 0.411038, 0.411329, 0.411618, 0.411891, 0.412139, 0.41237, 0.412589, 0.412802, 0.413013, 0.413229, 0.413447, 0.413663, 0.413878, 0.414097, 0.414321, 0.414556, 0.4148, 0.415051, 0.415309, 0.41557, 0.415834, 0.416101, 0.416385, 0.416677, 0.416965, 0.417238, 0.417483, 0.417691, 0.417871, 0.418029, 0.418173, 0.418311, 0.418451, 0.418583, 0.418702, 0.418816, 0.418934, 0.419064, 0.419214, 0.419382, 0.419563, 0.419752, 0.419942, 0.42013, 0.420312, 0.420491, 0.420669, 0.420849, 0.42103, 0.421215, 0.421399, 0.421577, 0.421758, 0.421949, 0.42216, 0.422397, 0.422673, 0.422978, 0.423295, 0.423607, 0.4239, 0.424162, 0.424418, 0.424664, 0.424892, 0.425091, 0.425255, 0.425365, 0.425417, 0.425437, 0.425453, 0.425491, 0.425579, 0.425726, 0.425913, 0.426116, 0.426313, 0.426481, 0.426598, 0.42666, 0.426688, 0.426709, 0.426745, 0.42682, 0.426953, 0.427125, 0.427325, 0.427539, 0.427754, 0.427957, 0.428158, 0.428365, 0.428571, 0.42877, 0.428954, 0.429116, 0.429254, 0.429373, 0.429483, 0.429592, 0.429707, 0.429833, 0.429956, 0.43008, 0.430211, 0.430356, 0.43052, 0.430711, 0.430923, 0.431151, 0.431385, 0.431618, 0.431843, 0.432075, 0.432315, 0.43255, 0.432772, 0.432969, 0.43313, 0.43326, 0.433365, 0.433455, 0.433539, 0.433624, 0.4337, 0.433748, 0.43379, 0.433848, 0.433947, 0.434111, 0.434373, 0.434713, 0.435083, 0.435437, 0.435726, 0.435907, 0.435996, 0.436022, 0.436011, 0.435989, 0.435982, 0.435999, 0.436012, 0.436022, 0.436035, 0.436054, 0.436083, 0.436125, 0.436177, 0.436234, 0.436294, 0.436352, 0.436403, 0.436434, 0.436453, 0.436478, 0.436526, 0.436614, 0.43676, 0.436966, 0.437211, 0.43747, 0.43772, 0.437936, 0.438113, 0.438274, 0.43842, 0.438554, 0.438679, 0.438796, 0.438898, 0.438986, 0.439067, 0.439145, 0.439229, 0.439323, 0.439421, 0.439522, 0.439625, 0.43973, 0.439836, 0.439943, 0.440053, 0.440164, 0.440277, 0.440389, 0.440502, 0.440621, 0.440748, 0.440873, 0.440989, 0.441088, 0.441163, 0.441213, 0.441245, 0.441266, 0.441282, 0.441302, 0.441323, 0.441334, 0.441341, 0.441354, 0.441383, 0.441436, 0.44152, 0.441628, 0.441752, 0.441883, 0.442013, 0.442135, 0.44226, 0.44239, 0.442518, 0.442638, 0.442745, 0.44283, 0.442892, 0.442939, 0.442982, 0.443033, 0.4431, 0.443186, 0.443279, 0.443381, 0.443494, 0.443621, 0.443764, 0.443936, 0.444132, 0.444338, 0.444539, 0.44472, 0.444871, 0.445005, 0.445125, 0.445231, 0.445322, 0.445397, 0.445451, 0.445479, 0.445491, 0.445496, 0.445505, 0.445526, 0.445556, 0.445586, 0.445621, 0.445663, 0.445715, 0.445779, 0.445858, 0.445947, 0.446044, 0.446145, 0.446248, 0.44635, 0.446452, 0.446557, 0.446667, 0.446784, 0.446909, 0.447046, 0.447194, 0.447348, 0.447505, 0.447661, 0.447814, 0.447987, 0.448173, 0.448351, 0.4485, 0.448599, 0.448623, 0.448552, 0.448426, 0.448289, 0.448186, 0.448161, 0.448239, 0.448392, 0.44859, 0.448805, 0.449007, 0.449168, 0.449302, 0.449424, 0.449536, 0.449637, 0.449728, 0.44981, 0.449878, 0.449934, 0.449982, 0.450025, 0.450064, 0.450101, 0.45013, 0.450154, 0.450176, 0.450199, 0.450225, 0.450252, 0.450279, 0.450307, 0.450338, 0.450373, 0.450413, 0.450461, 0.450514, 0.45057, 0.450625, 0.450677, 0.450725, 0.450775, 0.450825, 0.45087, 0.450906, 0.450929, 0.450938, 0.450934, 0.450921, 0.450901, 0.450877, 0.45085, 0.450811, 0.450761, 0.45071, 0.450664, 0.450633, 0.450621, 0.45062, 0.450628, 0.450649, 0.450683, 0.450732, 0.450802, 0.450892, 0.450997, 0.45111, 0.451225, 0.451334, 0.451451, 0.451579, 0.451705, 0.451819, 0.451909, 0.451964, 0.451985, 0.451981, 0.451963, 0.451939, 0.451919, 0.451906, 0.451887, 0.451865, 0.451845, 0.451832, 0.45183, 0.451841, 0.451861, 0.451888, 0.451919, 0.451949, 0.451977, 0.452007, 0.452039, 0.452071, 0.452102, 0.452129, 0.452153, 0.452177, 0.452199, 0.452217, 0.452231, 0.452237, 0.452233, 0.452219, 0.452199, 0.452179, 0.452163, 0.452155, 0.452151, 0.452149, 0.452152, 0.452159, 0.452173, 0.452194, 0.452227, 0.452267, 0.45231, 0.452352, 0.452388, 0.452422, 0.45246, 0.452497, 0.452525, 0.452538, 0.452531, 0.452507, 0.452471, 0.45242, 0.452351, 0.452262, 0.452146, 0.451988, 0.451802, 0.451605, 0.451418, 0.45126, 0.451143, 0.451054, 0.450984, 0.450924, 0.450866, 0.450801, 0.450725, 0.450645, 0.450566, 0.450496, 0.45044, 0.450406, 0.450404, 0.450422, 0.450449, 0.450469, 0.450469, 0.450438, 0.450381, 0.450308, 0.450229, 0.450154, 0.450093, 0.450049, 0.450013, 0.449983, 0.449957, 0.449933, 0.449908, 0.449892, 0.449885, 0.449877, 0.449858, 0.449822, 0.44976, 0.449688, 0.449602, 0.449498, 0.449371, 0.449217, 0.449034, 0.448826, 0.448593, 0.448337, 0.448059, 0.447758, 0.447436, 0.44709, 0.446721, 0.446331, 0.445918, 0.445483, 0.445027, 0.444548, 0.444047, 0.443524, 0.44298, 0.442413, 0.441818, 0.441202, 0.440567, 0.439919, 0.439262, 0.438614, 0.437974, 0.437319, 0.436626, 0.43587, 0.435049, 0.434402, 0.433835, 0.433123, 0.432039, 0.430358, 0.428368, 0.427503, 0.426601, 0.424216, 0.418905, 0.409225, 0.396402, 0.382576, 0.365547, 0.34307, 0.312906, 0.272788, 0.221013, 0.159633, 0.091601, 0.0198945, -0.0525338, -0.124172, -0.201123, -0.28145, -0.361514, -0.437677, -0.506323, -0.565947, -0.61981, -0.668566, -0.712743, -0.752877, -0.789483, -0.821637, -0.849041, -0.872562, -0.893078, -0.911459, -0.928371, -0.94253, -0.953999, -0.963373, -0.971244, -0.978205, -0.984408, -0.988963, -0.992177, -0.994451, -0.996186, -0.997786, -0.999106, -0.999791, -1.0, -0.999892, -0.999627, -0.99935, -0.998924, -0.998293, -0.997489, -0.996544, -0.99549, -0.994324, -0.992938, -0.9914, -0.989797, -0.988217, -0.98675, -0.985459, -0.984295, -0.983177, -0.982026, -0.98076, -0.9793, -0.977576, -0.975661, -0.973667, -0.971707, -0.969891, -0.968331, -0.967043, -0.965911, -0.964815, -0.963632, -0.962241, -0.960532, -0.958548, -0.956417, -0.954273, -0.952245, -0.950466, -0.948995, -0.947739, -0.946587, -0.94543, -0.944156, -0.942662, -0.940966, -0.939147, -0.937271, -0.935407, -0.933622, -0.931964, -0.930389, -0.928864, -0.927356, -0.925834, -0.924266, -0.922637, -0.920969, -0.919284, -0.917603, -0.915947, -0.914338, -0.912774, -0.91124, -0.909724, -0.908215, -0.9067, -0.905174, -0.903657, -0.902144, -0.900623, -0.899085, -0.897519, -0.895907, -0.894246, -0.892562, -0.890886, -0.889245, -0.887668, -0.886183, -0.884763, -0.883367, -0.881952, -0.880476, -0.878893, -0.877185, -0.875402, -0.873605, -0.871856, -0.870213, -0.868734, -0.867403, -0.866151, -0.864909, -0.863607, -0.862175, -0.86057, -0.85884, -0.857056, -0.855289, -0.853607, -0.852081, -0.850725, -0.849477, -0.848268, -0.847031, -0.845696, -0.844208, -0.842597, -0.840914, -0.839205, -0.83752, -0.835907, -0.834385, -0.83292, -0.831484, -0.830055, -0.828605, -0.827111, -0.825575, -0.824013, -0.82244, -0.820868, -0.81931, -0.817777, -0.816267, -0.814769, -0.813273, -0.811771, -0.810251, -0.808705, -0.807134, -0.805552, -0.803974, -0.802414, -0.800886, -0.799393, -0.797924, -0.796471, -0.795025, -0.793575, -0.792118, -0.790676, -0.78924, -0.787798, -0.786332, -0.784828, -0.78326, -0.781618, -0.77994, -0.778267, -0.776639, -0.775098, -0.773676, -0.772344, -0.771056, -0.769763, -0.768417, -0.766973, -0.765427, -0.763815, -0.762179, -0.760556, -0.758986, -0.757505, -0.756108, -0.754755, -0.753405, -0.752018, -0.750554, -0.748967, -0.747275, -0.745539, -0.743822, -0.742186, -0.740694, -0.739378, -0.738183, -0.737041, -0.735882, -0.734639, -0.73325, -0.731736, -0.730147, -0.728531, -0.726936, -0.725409, -0.723977, -0.722606, -0.721272, -0.719951, -0.718621, -0.717259, -0.715868, -0.714464, -0.713052, -0.711638, -0.710226, -0.708824, -0.707431, -0.706042, -0.704652, -0.703255, -0.701847, -0.700422, -0.698983, -0.697535, -0.696081, -0.694629, -0.693182, -0.691736, -0.690286, -0.688838, -0.687396, -0.685967, -0.684557, -0.683176, -0.681815, -0.680459, -0.679094, -0.677703, -0.676271, -0.674794, -0.673291, -0.671787, -0.670306, -0.668872, -0.66751, -0.666213, -0.664942, -0.663664, -0.66234, -0.660935, -0.659418, -0.657823, -0.656203, -0.654607, -0.653087, -0.651693, -0.650422, -0.649228, -0.648061, -0.64687, -0.645608, -0.64424, -0.642798, -0.641314, -0.639821, -0.638352, -0.636938, -0.635586, -0.634273, -0.63298, -0.631688, -0.630378, -0.629033, -0.627661, -0.626273, -0.624876, -0.623477, -0.622085, -0.620705, -0.619334, -0.617966, -0.616596, -0.615218, -0.613827, -0.612416, -0.61099, -0.609555, -0.608122, -0.606697, -0.60529, -0.603898, -0.602516, -0.60114, -0.599766, -0.598392, -0.597014, -0.595638, -0.594262, -0.592886, -0.59151, -0.590132, -0.588747, -0.587351, -0.585953, -0.584565, -0.583196, -0.581857, -0.580561, -0.579296, -0.578045, -0.576789, -0.575509, -0.574187, -0.572823, -0.571433, -0.570038, -0.568655, -0.567304, -0.566, -0.564732, -0.563486, -0.562244, -0.560992, -0.559712, -0.558394, -0.557048, -0.555694, -0.55435, -0.553035, -0.551767, -0.550554, -0.549377, -0.548213, -0.547039, -0.545833, -0.544579, -0.543296, -0.541991, -0.540673, -0.539347, -0.538023, -0.536698, -0.535368, -0.534033, -0.532691, -0.531345, -0.529992, -0.528625, -0.527247, -0.525867, -0.524493, -0.523133, -0.521796, -0.520479, -0.519176, -0.517878, -0.51658, -0.515273, -0.513957, -0.512638, -0.511316, -0.509991, -0.508665, -0.507338, -0.506007, -0.504673, -0.503337, -0.502003, -0.500672, -0.499347, -0.498028, -0.496714, -0.495401, -0.494085, -0.492762, -0.491429, -0.490084, -0.488734, -0.487386, -0.486047, -0.484726, -0.483416, -0.482114, -0.480822, -0.479543, -0.478281, -0.477039, -0.475822, -0.474626, -0.473441, -0.47226, -0.471073, -0.469878, -0.468688, -0.467499, -0.466305, -0.465101, -0.463881, -0.462642, -0.461385, -0.460117, -0.458846, -0.457581, -0.456327, -0.455092, -0.453867, -0.452643, -0.451408, -0.450154, -0.448868, -0.447541, -0.44619, -0.444838, -0.443506, -0.442214, -0.44098, -0.439791, -0.438628, -0.437473, -0.436306, -0.43511, -0.433885, -0.432645, -0.431396, -0.430143, -0.428894, -0.427652, -0.426416, -0.425183, -0.423949, -0.422711, -0.421466, -0.420212, -0.418951, -0.417684, -0.416414, -0.415141, -0.413868, -0.412589, -0.411302, -0.410015, -0.408732, -0.407459, -0.406204, -0.404969, -0.403749, -0.402535, -0.401316, -0.400084, -0.398829, -0.397551, -0.396262, -0.394973, -0.393697, -0.392445, -0.391224, -0.390027, -0.388843, -0.387665, -0.386484, -0.385291, -0.384089, -0.382883, -0.381676, -0.380469, -0.379266, -0.378068, -0.37687, -0.375674, -0.374482, -0.373293, -0.372111, -0.370936, -0.369768, -0.368605, -0.367445, -0.366287, -0.365128, -0.36397, -0.362812, -0.361657, -0.360503, -0.359351, -0.358203, -0.357061, -0.355922, -0.354784, -0.353643, -0.352495, -0.351336, -0.350168, -0.348994, -0.34782, -0.346649, -0.345486, -0.344334, -0.343189, -0.342048, -0.340906, -0.339762, -0.338611, -0.337458, -0.336305, -0.335148, -0.333984, -0.33281, -0.331624, -0.330426, -0.329218, -0.328005, -0.326791, -0.32558, -0.324371, -0.323158, -0.321945, -0.320736, -0.319535, -0.318345, -0.317165, -0.315991, -0.314825, -0.313666, -0.312516, -0.311376, -0.310249, -0.309132, -0.30802, -0.30691, -0.305796, -0.304683, -0.30358, -0.302479, -0.301367, -0.300236, -0.299074, -0.297859, -0.296599, -0.295325, -0.294068, -0.292855, -0.291717, -0.290659, -0.289654, -0.28867, -0.287676, -0.286641, -0.28555, -0.284431, -0.28329, -0.282128, -0.280946, -0.279746, -0.278513, -0.277246, -0.27596, -0.274674, -0.273405, -0.272167, -0.270948, -0.26974, -0.268546, -0.26737, -0.266215, -0.265084, -0.263983, -0.262904, -0.261837, -0.260774, -0.259706, -0.258637, -0.257578, -0.256522, -0.255458, -0.254379, -0.253276, -0.252151, -0.251008, -0.249851, -0.248684, -0.247511, -0.246333, -0.245133, -0.243922, -0.242709, -0.241508, -0.240329, -0.239178, -0.238042, -0.236921, -0.235815, -0.234725, -0.233651, -0.232605, -0.231587, -0.230582, -0.229575, -0.228551, -0.227496, -0.226409, -0.225303, -0.22419, -0.223083, -0.221996, -0.22094, -0.219911, -0.218897, -0.217885, -0.216863, -0.215818, -0.214744, -0.213651, -0.212546, -0.211438, -0.210337, -0.209249, -0.208177, -0.207112, -0.20605, -0.204984, -0.203909, -0.202819, -0.201716, -0.200605, -0.19949, -0.198377, -0.197271, -0.196173, -0.195078, -0.193985, -0.192896, -0.191809, -0.190725, -0.189653, -0.188591, -0.187529, -0.186458, -0.185368, -0.18425, -0.183097, -0.181922, -0.180741, -0.179569, -0.17842, -0.1773, -0.17619, -0.175094, -0.174015, -0.172958, -0.171927, -0.170938, -0.169986, -0.169054, -0.168122, -0.167172, -0.166186, -0.165179, -0.164157, -0.163123, -0.162077, -0.161021, -0.159952, -0.158857, -0.157749, -0.15664, -0.155542, -0.15447, -0.153432, -0.152424, -0.151428, -0.150429, -0.149413, -0.148364, -0.147283, -0.146183, -0.145069, -0.14395, -0.142834, -0.141724, -0.140608, -0.139489, -0.138373, -0.137265, -0.136171, -0.135093, -0.134025, -0.132968, -0.131919, -0.130878, -0.129844, -0.128821, -0.127809, -0.126804, -0.125801, -0.124797, -0.123787, -0.122773, -0.121758, -0.120744, -0.119733, -0.118728, -0.117733, -0.11675, -0.115771, -0.114792, -0.113806, -0.112807, -0.111794, -0.110771, -0.109741, -0.108707, -0.107672, -0.106636, -0.105591, -0.104541, -0.103491, -0.102448, -0.10142, -0.100412, -0.0994198, -0.0984399, -0.0974673, -0.0964976, -0.0955265, -0.0945581, -0.0935982, -0.0926402, -0.0916777, -0.0907045, -0.0897139, -0.0887001, -0.0876694, -0.0866321, -0.0855982, -0.0845778, -0.0835811, -0.0826095, -0.0816517, -0.0806952, -0.0797277, -0.0787369, -0.0777107, -0.0766526, -0.075579, -0.0745061, -0.0734503, -0.0724281, -0.0714473, -0.0704955, -0.0695569, -0.0686153, -0.067655, -0.0666595, -0.0656228, -0.0645626, -0.0634995, -0.0624539, -0.0614458, -0.0604904, -0.0595764, -0.0586898, -0.0578174, -0.0569453, -0.0560601, -0.0551719, -0.0542917, -0.0534099, -0.0525163, -0.0516014, -0.0506555, -0.0496757, -0.0486708, -0.0476511, -0.0466261, -0.0456061, -0.044596, -0.0435836, -0.0425703, -0.0415587, -0.040552, -0.0395533, -0.0385637, -0.0375815, -0.0366045, -0.0356314, -0.0346604, -0.0336902, -0.0327247, -0.0317635, -0.0308037, -0.0298422, -0.0288762, -0.0279032, -0.026925, -0.025943, -0.0249582, -0.0239714, -0.0229839, -0.0219896, -0.0209822, -0.0199722, -0.0189704, -0.0179881, -0.0170357, -0.0161152, -0.0152188, -0.0143404, -0.0134736, -0.0126123, -0.0117534, -0.0109179, -0.0100977, -0.00927668, -0.00843894, -0.0075681, -0.00664104, -0.0056472, -0.00462252, -0.00360524, -0.00263304, -0.00174417
};
float triTable[2048] = {
0.00205034, 0.00360933, 0.00578754, 0.00835358, 0.0110761, 0.0137236, 0.0160981, 0.0183687, 0.020617, 0.0228593, 0.0251122, 0.027392, 0.0297206, 0.0321003, 0.034499, 0.0368839, 0.0392222, 0.0414812, 0.0436497, 0.0457532, 0.0478204, 0.0498797, 0.0519597, 0.0540801, 0.0562156, 0.0583599, 0.0605111, 0.0626673, 0.0648265, 0.0669885, 0.069155, 0.0713261, 0.0735021, 0.0756831, 0.0778692, 0.0800601, 0.0822559, 0.0844568, 0.086663, 0.0888749, 0.091096, 0.0933308, 0.095572, 0.097812, 0.100043, 0.102257, 0.104463, 0.106663, 0.108853, 0.111028, 0.113181, 0.115309, 0.11741, 0.11949, 0.121555, 0.123613, 0.125667, 0.127712, 0.129738, 0.131757, 0.133783, 0.135828, 0.137904, 0.140002, 0.142116, 0.144248, 0.146397, 0.148564, 0.150756, 0.152981, 0.155227, 0.157478, 0.159719, 0.161935, 0.164142, 0.166348, 0.16854, 0.170706, 0.172831, 0.174903, 0.176915, 0.178884, 0.180829, 0.18277, 0.184725, 0.186695, 0.188658, 0.190622, 0.192593, 0.194577, 0.196582, 0.198611, 0.200659, 0.202715, 0.204773, 0.206824, 0.208863, 0.210895, 0.212924, 0.214952, 0.216985, 0.219024, 0.221064, 0.223103, 0.225147, 0.227201, 0.229273, 0.231368, 0.23349, 0.235633, 0.237784, 0.239934, 0.242072, 0.244201, 0.246336, 0.248466, 0.250583, 0.252677, 0.254738, 0.256759, 0.258749, 0.260722, 0.26269, 0.264667, 0.26666, 0.268659, 0.27066, 0.272662, 0.274664, 0.276664, 0.278666, 0.280672, 0.282676, 0.284675, 0.286663, 0.288636, 0.290596, 0.292546, 0.294487, 0.296422, 0.298354, 0.300276, 0.30218, 0.304077, 0.305982, 0.307905, 0.309861, 0.311873, 0.313923, 0.315983, 0.318021, 0.320007, 0.321913, 0.323747, 0.325536, 0.327304, 0.329078, 0.330883, 0.33272, 0.334568, 0.336425, 0.338291, 0.340166, 0.342047, 0.34393, 0.345818, 0.347717, 0.349633, 0.351571, 0.353541, 0.355551, 0.357581, 0.359612, 0.361626, 0.363604, 0.365556, 0.367494, 0.369414, 0.371311, 0.373181, 0.375019, 0.376812, 0.378576, 0.380325, 0.382078, 0.38385, 0.385646, 0.387452, 0.389264, 0.391078, 0.39289, 0.394698, 0.396507, 0.398318, 0.400125, 0.401927, 0.403717, 0.405494, 0.407256, 0.40901, 0.41076, 0.41251, 0.414267, 0.416024, 0.41778, 0.419538, 0.421301, 0.423072, 0.424857, 0.426659, 0.428472, 0.430287, 0.432097, 0.433893, 0.435678, 0.437459, 0.439233, 0.440997, 0.442746, 0.444477, 0.446184, 0.44787, 0.449548, 0.451226, 0.452915, 0.454622, 0.456343, 0.45807, 0.459797, 0.461518, 0.463227, 0.464921, 0.466606, 0.468285, 0.469962, 0.47164, 0.473324, 0.475015, 0.476707, 0.478398, 0.480083, 0.481759, 0.483424, 0.485082, 0.486734, 0.488379, 0.490016, 0.491647, 0.493268, 0.49488, 0.496487, 0.49809, 0.499692, 0.501294, 0.502892, 0.504487, 0.506082, 0.507679, 0.509283, 0.510886, 0.512485, 0.514089, 0.515705, 0.51734, 0.519007, 0.520729, 0.522484, 0.524239, 0.52596, 0.527614, 0.529175, 0.530657, 0.532094, 0.533515, 0.534954, 0.53644, 0.537952, 0.539475, 0.541016, 0.542579, 0.544171, 0.545804, 0.547497, 0.549225, 0.550958, 0.552666, 0.554319, 0.555907, 0.557451, 0.558968, 0.560474, 0.561985, 0.563516, 0.565063, 0.566615, 0.568164, 0.569701, 0.571217, 0.572711, 0.574192, 0.575659, 0.577106, 0.578532, 0.579932, 0.581296, 0.582629, 0.583943, 0.585252, 0.586569, 0.5879, 0.589228, 0.590557, 0.591892, 0.593238, 0.594602, 0.595985, 0.597385, 0.598797, 0.600218, 0.601643, 0.603069, 0.604501, 0.605938, 0.60738, 0.608827, 0.610277, 0.61173, 0.613187, 0.614649, 0.616114, 0.617584, 0.619058, 0.620545, 0.622044, 0.623545, 0.625037, 0.62651, 0.627958, 0.629403, 0.630838, 0.632249, 0.633624, 0.634949, 0.636201, 0.63738, 0.63852, 0.639657, 0.640828, 0.642065, 0.643361, 0.644693, 0.646047, 0.647405, 0.648753, 0.650083, 0.651415, 0.652746, 0.654072, 0.655389, 0.656694, 0.65799, 0.659279, 0.660559, 0.661826, 0.663078, 0.664312, 0.665526, 0.666724, 0.667911, 0.66909, 0.670267, 0.671435, 0.672582, 0.673724, 0.674874, 0.676046, 0.677253, 0.678497, 0.679767, 0.681053, 0.682348, 0.683643, 0.684935, 0.686242, 0.687554, 0.688863, 0.690158, 0.691429, 0.692672, 0.693896, 0.695105, 0.696306, 0.697506, 0.698708, 0.699909, 0.701106, 0.7023, 0.703489, 0.704673, 0.705857, 0.707048, 0.708236, 0.709408, 0.710553, 0.711661, 0.712721, 0.713743, 0.714746, 0.715747, 0.716765, 0.71781, 0.718864, 0.719926, 0.720996, 0.722076, 0.723167, 0.724272, 0.725391, 0.726519, 0.727651, 0.728784, 0.729915, 0.731064, 0.732222, 0.733373, 0.734501, 0.73559, 0.736625, 0.737607, 0.738559, 0.739503, 0.740458, 0.741448, 0.742462, 0.74349, 0.744529, 0.745577, 0.746634, 0.747701, 0.748797, 0.749906, 0.751012, 0.752098, 0.753145, 0.754144, 0.755107, 0.756048, 0.756979, 0.757913, 0.758861, 0.759812, 0.760762, 0.761714, 0.76267, 0.763634, 0.76461, 0.765599, 0.766594, 0.76759, 0.768579, 0.769555, 0.770513, 0.77146, 0.772402, 0.773347, 0.774301, 0.775274, 0.776266, 0.777269, 0.778272, 0.779266, 0.780239, 0.781189, 0.782124, 0.783047, 0.783961, 0.784869, 0.785775, 0.786678, 0.787576, 0.788467, 0.78935, 0.790223, 0.791082, 0.791926, 0.79276, 0.793589, 0.794419, 0.795256, 0.796098, 0.79694, 0.797783, 0.79863, 0.799482, 0.80034, 0.801205, 0.802075, 0.802947, 0.80382, 0.804691, 0.805566, 0.806452, 0.807338, 0.808211, 0.80906, 0.809874, 0.810645, 0.811386, 0.81211, 0.812829, 0.813558, 0.814304, 0.815056, 0.815811, 0.816566, 0.81732, 0.818071, 0.818818, 0.819561, 0.820303, 0.821046, 0.821791, 0.82254, 0.823293, 0.824047, 0.824803, 0.825561, 0.82632, 0.827082, 0.827848, 0.828615, 0.829381, 0.830142, 0.830896, 0.83163, 0.832351, 0.833072, 0.833807, 0.83457, 0.835373, 0.83622, 0.837092, 0.837972, 0.838841, 0.839683, 0.840509, 0.841335, 0.842146, 0.842929, 0.84367, 0.844352, 0.844957, 0.845509, 0.846038, 0.846575, 0.847151, 0.847775, 0.848416, 0.849075, 0.849755, 0.850456, 0.851183, 0.85195, 0.852752, 0.85357, 0.854387, 0.855184, 0.855947, 0.856677, 0.857391, 0.858105, 0.858834, 0.859596, 0.860406, 0.861255, 0.862121, 0.86298, 0.863811, 0.864592, 0.86533, 0.86604, 0.866731, 0.867413, 0.868096, 0.868783, 0.869464, 0.87014, 0.870811, 0.871481, 0.872149, 0.872817, 0.873483, 0.874146, 0.874806, 0.875459, 0.876105, 0.876739, 0.877367, 0.877993, 0.878622, 0.879259, 0.879906, 0.880561, 0.88122, 0.881879, 0.882535, 0.883182, 0.883819, 0.884449, 0.885079, 0.885715, 0.886363, 0.887038, 0.887757, 0.888489, 0.889203, 0.889868, 0.890451, 0.890953, 0.891393, 0.891786, 0.892143, 0.892477, 0.8928, 0.89311, 0.893397, 0.893649, 0.893858, 0.894011, 0.894122, 0.894207, 0.894245, 0.894213, 0.894089, 0.893852, 0.893506, 0.893064, 0.892538, 0.891937, 0.891272, 0.890547, 0.889748, 0.888879, 0.887944, 0.886946, 0.885891, 0.884773, 0.883588, 0.882343, 0.881043, 0.879694, 0.878299, 0.876848, 0.875342, 0.87379, 0.872197, 0.87057, 0.868908, 0.867204, 0.86546, 0.863682, 0.861874, 0.860039, 0.858177, 0.856286, 0.854363, 0.852406, 0.850414, 0.848385, 0.846323, 0.844227, 0.842095, 0.839925, 0.837715, 0.835457, 0.83315, 0.830807, 0.82844, 0.826061, 0.82368, 0.821277, 0.818856, 0.816424, 0.81399, 0.811562, 0.80915, 0.806747, 0.804345, 0.801937, 0.799514, 0.797067, 0.7946, 0.792119, 0.789623, 0.787112, 0.784586, 0.782038, 0.779443, 0.776826, 0.774214, 0.771636, 0.76912, 0.766686, 0.764314, 0.761978, 0.759652, 0.757309, 0.754927, 0.752535, 0.750137, 0.747724, 0.745288, 0.742821, 0.740305, 0.737727, 0.73512, 0.732517, 0.72995, 0.727452, 0.725032, 0.722667, 0.72033, 0.717997, 0.715644, 0.713254, 0.710851, 0.708438, 0.706014, 0.703575, 0.701121, 0.698641, 0.696136, 0.693616, 0.691095, 0.688585, 0.686098, 0.683641, 0.6812, 0.678761, 0.676308, 0.673827, 0.671306, 0.668755, 0.666184, 0.663599, 0.661012, 0.65843, 0.655845, 0.653253, 0.65066, 0.64807, 0.645488, 0.64292, 0.640369, 0.637827, 0.635287, 0.632742, 0.630183, 0.6276, 0.624998, 0.622388, 0.619784, 0.617199, 0.614645, 0.612122, 0.60962, 0.607132, 0.60465, 0.602168, 0.599682, 0.597203, 0.594727, 0.592252, 0.589774, 0.58729, 0.584793, 0.582286, 0.579778, 0.577277, 0.57479, 0.572324, 0.569874, 0.567436, 0.56501, 0.562592, 0.560181, 0.557782, 0.555401, 0.553029, 0.550655, 0.548272, 0.545869, 0.543444, 0.541004, 0.538559, 0.536116, 0.533683, 0.531266, 0.52886, 0.52646, 0.524064, 0.521671, 0.519279, 0.516893, 0.514518, 0.512143, 0.50976, 0.507362, 0.504938, 0.502484, 0.50001, 0.497529, 0.495055, 0.4926, 0.490175, 0.487775, 0.485386, 0.482995, 0.480589, 0.478154, 0.475672, 0.473159, 0.47064, 0.468141, 0.46569, 0.463311, 0.460999, 0.458729, 0.456477, 0.454215, 0.451918, 0.449584, 0.44723, 0.444865, 0.442494, 0.440126, 0.437766, 0.43542, 0.433079, 0.430733, 0.428371, 0.425982, 0.423555, 0.421087, 0.418597, 0.416105, 0.413627, 0.411182, 0.408763, 0.406361, 0.403972, 0.401595, 0.399227, 0.396868, 0.394526, 0.392195, 0.389871, 0.387547, 0.385218, 0.382886, 0.380556, 0.378225, 0.375891, 0.373548, 0.371195, 0.368828, 0.366452, 0.364071, 0.361691, 0.359317, 0.356948, 0.354579, 0.352212, 0.349851, 0.347498, 0.345159, 0.342839, 0.340534, 0.338236, 0.335938, 0.333632, 0.331313, 0.328992, 0.326667, 0.324335, 0.321992, 0.319635, 0.317258, 0.314862, 0.312455, 0.310044, 0.307636, 0.305238, 0.30284, 0.300442, 0.298047, 0.29566, 0.293284, 0.290916, 0.288546, 0.286183, 0.283838, 0.281522, 0.279246, 0.277034, 0.274878, 0.272745, 0.270602, 0.268418, 0.266164, 0.263851, 0.261499, 0.259129, 0.256758, 0.254405, 0.25208, 0.249766, 0.247457, 0.245146, 0.242826, 0.240491, 0.238132, 0.235759, 0.233382, 0.231014, 0.228664, 0.22634, 0.224037, 0.221748, 0.219468, 0.217193, 0.214919, 0.212651, 0.210391, 0.208136, 0.205878, 0.203614, 0.201338, 0.19905, 0.196756, 0.194458, 0.192161, 0.189868, 0.187578, 0.185288, 0.182999, 0.180713, 0.178434, 0.176164, 0.173903, 0.171648, 0.1694, 0.167155, 0.164912, 0.162674, 0.16045, 0.158231, 0.156008, 0.153768, 0.151502, 0.149211, 0.146903, 0.144578, 0.142234, 0.139871, 0.137483, 0.135038, 0.132556, 0.130074, 0.127626, 0.125247, 0.12297, 0.120783, 0.118646, 0.116519, 0.114362, 0.112133, 0.109827, 0.107474, 0.105099, 0.102728, 0.100388, 0.0980987, 0.0958451, 0.0936141, 0.0913946, 0.0891749, 0.0869439, 0.084699, 0.0824483, 0.0801958, 0.0779458, 0.0757025, 0.073469, 0.0712418, 0.06902, 0.066804, 0.0645945, 0.0623925, 0.0602031, 0.0580333, 0.0558718, 0.0537071, 0.0515269, 0.0493195, 0.0470875, 0.0448382, 0.0425741, 0.0402977, 0.0380118, 0.0357137, 0.0333861, 0.0310419, 0.028698, 0.0263721, 0.0240815, 0.0218298, 0.019603, 0.0173978, 0.015211, 0.013039, 0.0108804, 0.00875302, 0.00665008, 0.00455578, 0.00245417, 0.000329488, -0.00183022, -0.00401578, -0.00621704, -0.00842485, -0.0106295, -0.0128215, -0.0149995, -0.0171705, -0.019339, -0.0215093, -0.0236866, -0.0258755, -0.0280772, -0.0302866, -0.0324974, -0.0347034, -0.0368983, -0.0390758, -0.0412378, -0.0433932, -0.0455518, -0.0477225, -0.0499145, -0.0521294, -0.0543603, -0.056599, -0.0588375, -0.0610684, -0.0632876, -0.0655037, -0.0677167, -0.0699247, -0.0721264, -0.0743201, -0.0765108, -0.0786993, -0.0808802, -0.0830487, -0.0851995, -0.0873284, -0.089439, -0.0915334, -0.0936121, -0.0956753, -0.0977242, -0.0997517, -0.101752, -0.103736, -0.105717, -0.107708, -0.10972, -0.111741, -0.113769, -0.115806, -0.117857, -0.119925, -0.122017, -0.124138, -0.126278, -0.128425, -0.130568, -0.132695, -0.134806, -0.136907, -0.139004, -0.141099, -0.143195, -0.145297, -0.147412, -0.149533, -0.151649, -0.15375, -0.155824, -0.157859, -0.159851, -0.161824, -0.163796, -0.16579, -0.167825, -0.169907, -0.172019, -0.174147, -0.176275, -0.178386, -0.18047, -0.182542, -0.184604, -0.186657, -0.188702, -0.19074, -0.192767, -0.19478, -0.196787, -0.198791, -0.200797, -0.202811, -0.204826, -0.206843, -0.208861, -0.210884, -0.212911, -0.214946, -0.216992, -0.219043, -0.221093, -0.223135, -0.225165, -0.227174, -0.229169, -0.231159, -0.233156, -0.235167, -0.237203, -0.239262, -0.241337, -0.243416, -0.245491, -0.247553, -0.249605, -0.251657, -0.253703, -0.255735, -0.257747, -0.25973, -0.261673, -0.263588, -0.265491, -0.267398, -0.269325, -0.271286, -0.27327, -0.275268, -0.277268, -0.279258, -0.281228, -0.283188, -0.285145, -0.28709, -0.289016, -0.290914, -0.292773, -0.294573, -0.296337, -0.298095, -0.299876, -0.301711, -0.303622, -0.305594, -0.307596, -0.309599, -0.311574, -0.313491, -0.315348, -0.31717, -0.318975, -0.320785, -0.322621, -0.324499, -0.326405, -0.328328, -0.330257, -0.332182, -0.334093, -0.33599, -0.337882, -0.339769, -0.341653, -0.343533, -0.345412, -0.347287, -0.34916, -0.351029, -0.352894, -0.354757, -0.356615, -0.358471, -0.360323, -0.362171, -0.364016, -0.365857, -0.367695, -0.36953, -0.371361, -0.373187, -0.375008, -0.376822, -0.378625, -0.380423, -0.382218, -0.384017, -0.385823, -0.387639, -0.389461, -0.391286, -0.393111, -0.39493, -0.396744, -0.398568, -0.400394, -0.402209, -0.404001, -0.405756, -0.407455, -0.409092, -0.410699, -0.412308, -0.41395, -0.415656, -0.417438, -0.419271, -0.421126, -0.422972, -0.424782, -0.426532, -0.428234, -0.429909, -0.431572, -0.433239, -0.434928, -0.436646, -0.438382, -0.440124, -0.44186, -0.443579, -0.445267, -0.446914, -0.448535, -0.450152, -0.451785, -0.453454, -0.455174, -0.456935, -0.458721, -0.460517, -0.462308, -0.464079, -0.465839, -0.467598, -0.46935, -0.471092, -0.472818, -0.474526, -0.476213, -0.477884, -0.479547, -0.481207, -0.482871, -0.484546, -0.486228, -0.487908, -0.489577, -0.491226, -0.492845, -0.49444, -0.496014, -0.497571, -0.499113, -0.500644, -0.502158, -0.503643, -0.505112, -0.506581, -0.508065, -0.509579, -0.511122, -0.512685, -0.514262, -0.515847, -0.517436, -0.519026, -0.520626, -0.522233, -0.523842, -0.525448, -0.527046, -0.528634, -0.530216, -0.531793, -0.533369, -0.534945, -0.536525, -0.538114, -0.539707, -0.541298, -0.542879, -0.544443, -0.545986, -0.54751, -0.549021, -0.550522, -0.552019, -0.553515, -0.555017, -0.556521, -0.558019, -0.559502, -0.56096, -0.562383, -0.563768, -0.565125, -0.566468, -0.567813, -0.569172, -0.57054, -0.571898, -0.573261, -0.574643, -0.576059, -0.577525, -0.579052, -0.580624, -0.582221, -0.583824, -0.585413, -0.586978, -0.588546, -0.590111, -0.591667, -0.593204, -0.594717, -0.596205, -0.597674, -0.599125, -0.600559, -0.601977, -0.60338, -0.604764, -0.606132, -0.607485, -0.608824, -0.610153, -0.611468, -0.612764, -0.614047, -0.615324, -0.616602, -0.617887, -0.619173, -0.620458, -0.621743, -0.623032, -0.624325, -0.625623, -0.626915, -0.628209, -0.629514, -0.630837, -0.632189, -0.633581, -0.635008, -0.636455, -0.637902, -0.639332, -0.640731, -0.642122, -0.643505, -0.644871, -0.646211, -0.647516, -0.648774, -0.649981, -0.651157, -0.652322, -0.653495, -0.654696, -0.655923, -0.657163, -0.658409, -0.659653, -0.660887, -0.662105, -0.66331, -0.664506, -0.6657, -0.666896, -0.668101, -0.669321, -0.670557, -0.671796, -0.673025, -0.674233, -0.675407, -0.676535, -0.677633, -0.678721, -0.679822, -0.680957, -0.682138, -0.683351, -0.684586, -0.685833, -0.687084, -0.688329, -0.689583, -0.69085, -0.692118, -0.69337, -0.694595, -0.69578, -0.696928, -0.698049, -0.699154, -0.700253, -0.701358, -0.702475, -0.703598, -0.704718, -0.705824, -0.70691, -0.707963, -0.708967, -0.709937, -0.710897, -0.711871, -0.712884, -0.713953, -0.715065, -0.716205, -0.717357, -0.718507, -0.719638, -0.720763, -0.721891, -0.723013, -0.724122, -0.725208, -0.726265, -0.72729, -0.728292, -0.72928, -0.730265, -0.731255, -0.732248, -0.73323, -0.734211, -0.7352, -0.736205, -0.737238, -0.738311, -0.739412, -0.740521, -0.741619, -0.742686, -0.743708, -0.744696, -0.745661, -0.746613, -0.747561, -0.748516, -0.749476, -0.750434, -0.75139, -0.752341, -0.753286, -0.754223, -0.75515, -0.756071, -0.756987, -0.757902, -0.758819, -0.759739, -0.760661, -0.761581, -0.762501, -0.763418, -0.764331, -0.765241, -0.76615, -0.767056, -0.767958, -0.768856, -0.769747, -0.770623, -0.771492, -0.772365, -0.773251, -0.77416, -0.775104, -0.776077, -0.777062, -0.778043, -0.779001, -0.779922, -0.780812, -0.781681, -0.782536, -0.783385, -0.784234, -0.785089, -0.785946, -0.7868, -0.787644, -0.788474, -0.789283, -0.790058, -0.790807, -0.791546, -0.792295, -0.793069, -0.793885, -0.79474, -0.795619, -0.796505, -0.797383, -0.798236, -0.799069, -0.799894, -0.800708, -0.801505, -0.802282, -0.803032, -0.80375, -0.804442, -0.80512, -0.805793, -0.806474, -0.807167, -0.807859, -0.808552, -0.809247, -0.809944, -0.810644, -0.811352, -0.812064, -0.812778, -0.813491, -0.814198, -0.814899, -0.815595, -0.816289, -0.816978, -0.817663, -0.818343, -0.819017, -0.819684, -0.820347, -0.821007, -0.821667, -0.822327, -0.822983, -0.823637, -0.824291, -0.824947, -0.82561, -0.826279, -0.826953, -0.827631, -0.828313, -0.829, -0.82969, -0.830403, -0.831135, -0.831867, -0.832579, -0.833252, -0.833867, -0.834421, -0.834934, -0.835429, -0.835926, -0.836447, -0.836999, -0.837564, -0.838138, -0.838714, -0.839288, -0.839852, -0.840397, -0.840932, -0.841471, -0.842025, -0.842609, -0.843234, -0.843893, -0.844576, -0.845274, -0.845979, -0.846681, -0.847395, -0.848127, -0.848861, -0.849583, -0.850275, -0.850926, -0.851554, -0.85216, -0.852739, -0.853287, -0.853801, -0.85427, -0.854693, -0.855083, -0.855456, -0.855826, -0.856207, -0.85659, -0.856966, -0.857339, -0.857712, -0.858088, -0.858469, -0.858855, -0.859243, -0.85963, -0.860011, -0.860383, -0.86074, -0.861083, -0.861421, -0.861764, -0.862121, -0.862499, -0.862889, -0.863289, -0.863701, -0.86413, -0.864576, -0.865053, -0.865568, -0.866101, -0.866632, -0.867139, -0.867603, -0.86803, -0.868434, -0.868816, -0.86918, -0.869529, -0.869881, -0.870272, -0.870662, -0.871001, -0.871238, -0.871324, -0.87118, -0.870828, -0.870378, -0.869937, -0.869614, -0.869502, -0.869488, -0.869554, -0.869727, -0.870037, -0.870513, -0.871247, -0.872318, -0.873557, -0.874789, -0.875836, -0.876525, -0.876945, -0.877194, -0.877256, -0.877115, -0.876754, -0.87615, -0.875272, -0.874164, -0.872877, -0.871464, -0.869974, -0.868396, -0.866678, -0.864844, -0.862921, -0.860934, -0.858903, -0.856797, -0.854614, -0.852368, -0.850075, -0.84775, -0.845392, -0.842974, -0.840512, -0.838024, -0.83553, -0.833047, -0.830567, -0.828078, -0.825584, -0.823086, -0.820586, -0.818085, -0.815569, -0.813046, -0.810528, -0.808027, -0.805556, -0.803131, -0.800752, -0.798393, -0.796028, -0.79363, -0.791176, -0.788669, -0.786125, -0.783558, -0.780983, -0.778414, -0.775859, -0.773306, -0.770751, -0.768194, -0.765633, -0.763064, -0.76048, -0.757883, -0.755282, -0.752691, -0.750121, -0.747581, -0.745068, -0.742576, -0.740095, -0.737621, -0.735144, -0.732669, -0.730205, -0.727744, -0.725278, -0.722802, -0.720306, -0.717784, -0.715244, -0.712698, -0.710156, -0.707631, -0.70513, -0.702646, -0.700175, -0.697711, -0.695248, -0.692784, -0.69032, -0.687859, -0.6854, -0.682941, -0.680482, -0.67802, -0.675555, -0.673088, -0.670622, -0.668159, -0.665703, -0.663256, -0.660822, -0.658392, -0.655958, -0.653513, -0.651048, -0.64856, -0.646055, -0.643541, -0.641026, -0.63852, -0.636029, -0.633553, -0.631083, -0.628611, -0.626129, -0.62363, -0.62111, -0.618576, -0.616031, -0.613479, -0.610924, -0.608366, -0.605796, -0.603217, -0.600638, -0.598067, -0.59551, -0.592974, -0.590451, -0.58794, -0.585435, -0.582935, -0.580436, -0.577928, -0.575415, -0.572911, -0.570425, -0.567972, -0.565563, -0.563209, -0.560889, -0.55858, -0.55626, -0.553906, -0.551515, -0.549106, -0.546682, -0.544246, -0.541801, -0.53935, -0.536897, -0.534438, -0.531967, -0.529476, -0.526961, -0.524413, -0.521828, -0.519219, -0.516602, -0.513988, -0.511392, -0.508796, -0.506192, -0.503597, -0.501024, -0.498489, -0.496007, -0.493576, -0.491182, -0.488812, -0.486449, -0.484079, -0.481706, -0.479345, -0.476989, -0.474628, -0.472254, -0.46986, -0.467445, -0.465015, -0.462576, -0.460135, -0.457698, -0.455269, -0.452846, -0.450424, -0.448, -0.445567, -0.443123, -0.440673, -0.438221, -0.435759, -0.433282, -0.430783, -0.428251, -0.425661, -0.423039, -0.420415, -0.417822, -0.415292, -0.412848, -0.410474, -0.40814, -0.405816, -0.40347, -0.401075, -0.39863, -0.396155, -0.393671, -0.391196, -0.388748, -0.386341, -0.38396, -0.381597, -0.379251, -0.376914, -0.374584, -0.372274, -0.369988, -0.367709, -0.365422, -0.36311, -0.360759, -0.358377, -0.355973, -0.353552, -0.35112, -0.348683, -0.346232, -0.343757, -0.341272, -0.338791, -0.33633, -0.333904, -0.331509, -0.329135, -0.326778, -0.324435, -0.322102, -0.319783, -0.317494, -0.315222, -0.312948, -0.310658, -0.308332, -0.305972, -0.303591, -0.301191, -0.298771, -0.296331, -0.293869, -0.291362, -0.288824, -0.286279, -0.28375, -0.281261, -0.278825, -0.276424, -0.274049, -0.27169, -0.269337, -0.266981, -0.264622, -0.262268, -0.259921, -0.257585, -0.255261, -0.252955, -0.250671, -0.248402, -0.246138, -0.243872, -0.241594, -0.239308, -0.237026, -0.234738, -0.232437, -0.230116, -0.227767, -0.225386, -0.222981, -0.220562, -0.218139, -0.215721, -0.213308, -0.210888, -0.208467, -0.206051, -0.203648, -0.201264, -0.198897, -0.196543, -0.194201, -0.191873, -0.18956, -0.187264, -0.184994, -0.182742, -0.180497, -0.178248, -0.175985, -0.173709, -0.17143, -0.169145, -0.16685, -0.164542, -0.162215, -0.159862, -0.15749, -0.15511, -0.152733, -0.150369, -0.148029, -0.145705, -0.143391, -0.141079, -0.138761, -0.136432, -0.134085, -0.131728, -0.129367, -0.127009, -0.124661, -0.122327, -0.119997, -0.117672, -0.115358, -0.113058, -0.110777, -0.108528, -0.106311, -0.10411, -0.101907, -0.0996853, -0.097427, -0.0951316, -0.0928122, -0.0904801, -0.0881476, -0.0858269, -0.0835248, -0.0812303, -0.0789414, -0.0766578, -0.074378, -0.0721014, -0.0698264, -0.0675536, -0.0652851, -0.0630235, -0.0607712, -0.0585312, -0.0563106, -0.0541026, -0.0518976, -0.0496861, -0.0474588, -0.0452096, -0.0429452, -0.040671, -0.0383926, -0.0361152, -0.0338438, -0.0315732, -0.0293009, -0.0270301, -0.024764, -0.0225054, -0.0202499, -0.0179787, -0.0157089, -0.0134595, -0.011251, -0.00910325
};
| [
"rossco255@gmail.com"
] | rossco255@gmail.com |
00f2e90560ee672966cca47a7cb5a2459335e6ef | 3a00a110129f20af629ca0e1f72b27784700a784 | /C++/learn/mystdlib.cpp | 6d469da264a152b28e351fabfed9d9f9660e803e | [] | no_license | clintonyeb/CPP-Programs | bd70d7d2886c1ad4c124cf7bcf0a74bc6729b4b1 | 3e9f1d7ee67297fa3beb73b55ae57cf46343d2ad | refs/heads/master | 2020-03-22T00:21:51.692809 | 2018-06-30T10:32:58 | 2018-06-30T10:32:58 | 139,240,070 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 199 | cpp | #include <cstdio>
int main() {
int r = remove("temp.txt");
if (r != 0) {
perror("Error deleting file");
} else {
puts("Deleted file successfully");
}
return 0;
}
| [
"clintonyeb@gmail.com"
] | clintonyeb@gmail.com |
57a37b57f58a2f6a9ea10ac4fd85519f6b9b7186 | bc90e70ee2139b034c65a5755395ff55faac87d0 | /sprout/functional/negate.hpp | ade511755206aff977a88c181c7b0be4f6f51fba | [
"BSL-1.0"
] | permissive | Manu343726/Sprout | 0a8e2d090dbede6f469f6b875d217716d0200bf7 | feac3f52c785deb0e5e6cd70c8b4960095b064be | refs/heads/master | 2021-01-21T07:20:16.742204 | 2015-05-28T04:11:39 | 2015-05-28T04:11:39 | 37,670,169 | 0 | 1 | null | 2015-06-18T16:09:41 | 2015-06-18T16:09:41 | null | UTF-8 | C++ | false | false | 1,284 | hpp | /*=============================================================================
Copyright (c) 2011 RiSK (sscrisk)
https://github.com/sscrisk/CEL---ConstExpr-Library
Copyright (c) 2011-2015 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_FUNCTIONAL_NEGATE_HPP
#define SPROUT_FUNCTIONAL_NEGATE_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
// 20.8.4 Arithmetic operations
template<typename T = void>
struct negate {
public:
typedef T argument_type;
typedef T result_type;
public:
SPROUT_CONSTEXPR T operator()(T const& x) const {
return -x;
}
};
template<>
struct negate<void> {
public:
typedef void is_transparent;
public:
template<typename T>
SPROUT_CONSTEXPR decltype(-std::declval<T>())
operator()(T&& x)
const SPROUT_NOEXCEPT_IF_EXPR(-std::declval<T>())
{
return -SPROUT_FORWARD(T, x);
}
};
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_NEGATE_HPP
| [
"bolero.murakami@gmail.com"
] | bolero.murakami@gmail.com |
12c3e64cee53d1a62a629aadacbde311142e04b7 | ee5ebad94040ce009b9cb0cc49fab81788a79099 | /leetcode/17. Letter Combinations of a Phone Number/main.cpp | 9e222af18e832ff3cd3e42d3005533b4cc82db27 | [] | no_license | samiksjsu/CLionProjects | 7d97755d6cc22763971df1daf2856fbc6b523cf1 | 002319d85195484d96337cc9acec70177385e78d | refs/heads/master | 2020-12-12T00:27:26.498923 | 2020-01-17T19:20:38 | 2020-01-17T19:20:38 | 233,992,445 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,435 | cpp | #include <iostream>
#include <string>
#include <unordered_map>
#include <queue>
using namespace std;
int main() {
string digits = "2";
vector<string> result;
unordered_map<char, string> m;
m['2'] = "abc";
m['3'] = "def";
m['4'] = "ghi";
m['5'] = "jkl";
m['6'] = "mno";
m['7'] = "pqrs";
m['8'] = "tuv";
m['9'] = "wxyz";
if (digits.length() == 1) {
string temp = m[digits[0]];
for (auto &c: temp) {
string t(1, c);
result.push_back(t);
}
}
queue<string> q;
string first = m[digits.at(0)];
string second = m[digits.at(1)];
string temp = "";
for(auto &c1: first) {
for(auto &c2: second) {
temp = "";
temp.push_back(c1);
temp.push_back(c2);
q.push(temp);
}
}
int ptr = 2;
while (!q.empty() && ptr < digits.length()) {
int size = q.size();
first = m[digits.at(ptr)];
while (size > 0) {
temp = "";
second = q.front();
q.pop();
temp = second;
for (auto &c: first) {
string temp2 = temp;
temp2.push_back(c);
q.push(temp2);
}
size--;
}
ptr++;
}
while(!q.empty()) {
result.push_back(q.front());
q.pop();
}
cout << "Hello" << endl;
}
| [
"samikdada@gmail.com"
] | samikdada@gmail.com |
86e4ade4fbd69cd88af8ebbbf756ed16afeadc55 | eb2ee68fe646bc8a67329ee7ab67fcf403091948 | /新建文件夹/sharesrc net/MyPrinterInfo.cpp | b159ee6a6eb245e5b0d9b58cd6d4d747060732fd | [] | no_license | huatuwmk/HTTransferService | a62af1a4ebba33e03c8d0d7249e1ac57e5af9bad | e6761b2519d2f9e820a90d84f65685e0e6679c51 | refs/heads/master | 2021-01-21T03:09:30.926689 | 2014-12-12T08:22:36 | 2014-12-12T08:22:36 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,240 | cpp | #include "StdAfx.h"
#include "MyPrinterInfo.h"
#include <Windows.h>
#include <WinSpool.h>
#define safe_delete_array(p) if (NULL != p) { delete [] p; p = NULL;}
//#define __PrinterInfo_Ini_Path L".\\PrinterInfo.ini"
#define __PrinterInfo_Ini_AppName L"PrinterInfo"
CMyPrinterInfo::CMyPrinterInfo(void)
{
m_pInfo = NULL;
}
CMyPrinterInfo::~CMyPrinterInfo(void)
{
safe_delete_array(m_pInfo);
}
int CMyPrinterInfo::GetMyPrinterInfo( int& nArraySize, MyPrinter_Info* pPrinterInfoArray)
{
int nRet = 0;
//EnumPrinters
DWORD Flags = PRINTER_ENUM_LOCAL; //local printers
DWORD cbBuf;
DWORD pcReturned = 0;
DWORD Level = 2;
TCHAR Name[500];
PPRINTER_INFO_2 pPrinterEnum = NULL;
memset(Name, 0, sizeof(TCHAR)*500);
//检测需要开辟内存大小
EnumPrinters(Flags, Name, Level, NULL, 0, &cbBuf, &pcReturned);
pPrinterEnum = (LPPRINTER_INFO_2)LocalAlloc(LPTR, cbBuf+ 4) ;
if (!pPrinterEnum)
{
return -1;
}
EnumPrinters( Flags, Name,Level,(LPBYTE)pPrinterEnum,cbBuf, &cbBuf, &pcReturned);
if ( nArraySize == 0)
{
//检测重复
for ( int i = 0; i < pcReturned; i++)
{
if ( 1 == isNeedSendToDB(pPrinterEnum[i].pDriverName,false))
{
nRet++;
}
}
nArraySize = nRet;
LocalFree(pPrinterEnum);
return 1;
}
for ( int i = 0; i < pcReturned; i++)
{
if ( 1 == isNeedSendToDB(pPrinterEnum[i].pDriverName,true))
{
memcpy(pPrinterInfoArray[nRet].szDriverName, pPrinterEnum[nRet].pDriverName, wcslen(pPrinterEnum[i].pDriverName)*2);
memcpy(pPrinterInfoArray[nRet].szPrinterName, pPrinterEnum[nRet].pPrinterName, wcslen(pPrinterEnum[i].pPrinterName)*2);
nRet++;
}
}
LocalFree(pPrinterEnum);
return nRet;
}
MyPrinter_Info* CMyPrinterInfo::GetInfo(int& nSize)
{
safe_delete_array(m_pInfo);
//获取需要开辟数组大小
GetMyPrinterInfo(nSize,m_pInfo);
if ( 0 == nSize )
{
//没有打印机信息
return NULL;
}
m_pInfo = new MyPrinter_Info[nSize];
memset(m_pInfo,0,sizeof(MyPrinter_Info)*nSize);
nSize = GetMyPrinterInfo(nSize,m_pInfo);
return m_pInfo;
}
int CMyPrinterInfo::isNeedSendToDB(TCHAR* PrinterDriverName, bool bWriteToIni)
{
if ( !PrinterDriverName )
{
return -1;
}
TCHAR str[128];
memset(str,0,sizeof(str));
//遍历INI中打印机驱动名
CString strPrintInfoIniPath;
TCHAR tcDGPath[4096+1] = {0};
GetModuleFileName(NULL,tcDGPath,4096);
CAString strDGPath = tcDGPath;
int pos = strDGPath.ReverseFind(TEXT('\\'));
strDGPath = strDGPath.Left(pos+1);
strPrintInfoIniPath = strDGPath + _T("PrinterInfo.ini");
int nPos = 1;
for ( ; ; nPos++ )
{
TCHAR tPos[8] = {0};
_stprintf_s(tPos,L"%d",nPos);
memset(str,0,sizeof(str));
GetPrivateProfileString(__PrinterInfo_Ini_AppName,tPos,NULL,str,128,strPrintInfoIniPath);
if ( 0 == _tcscmp(str,L""))
{
//遍历到末尾,跳出循环
break;
}
if ( 0 == _tcscmp(str,PrinterDriverName) )
{
//已经有不需要上传
return 0;
}
}
//将没有上传的打印机驱动名添加到INI中
if (bWriteToIni)
{
TCHAR tPos[8] = {0};
_stprintf_s(tPos,L"%d",nPos);
WritePrivateProfileString(__PrinterInfo_Ini_AppName,tPos,PrinterDriverName,strPrintInfoIniPath);
}
return 1;
}
| [
"930071049@qq.com"
] | 930071049@qq.com |
e04483a6c6d0d62acb5b114bbc7708aa42542b40 | d396171b05504dec8e9b70a7ad0e6badd11f5d2b | /ceee/ie/broker/common_api_module.h | c4b69619574b4ef657ae4d0284d399c148d71c08 | [] | no_license | madecoste/ceee | 6e312b18b28e2c39418f769a274e71c9f592943b | 30efa2b3ea7b4cef459b4763686bd0664aa7798f | refs/heads/master | 2016-09-05T18:26:19.713716 | 2011-02-02T20:02:52 | 2011-02-02T20:02:52 | 32,116,269 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,823 | h | // Copyright (c) 2010 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.
//
// Common functions for various API implementation modules.
#ifndef CEEE_IE_BROKER_COMMON_API_MODULE_H_
#define CEEE_IE_BROKER_COMMON_API_MODULE_H_
#include <string>
#include "ceee/ie/broker/api_dispatcher.h"
#include "toolband.h" // NOLINT
namespace common_api {
class CommonApiResult : public ApiDispatcher::InvocationResult {
public:
explicit CommonApiResult(int request_id)
: ApiDispatcher::InvocationResult(request_id) {
}
// Returns true if the given window is an IE "server" window, i.e. a tab.
static bool IsTabWindowClass(HWND window);
// Returns true if the given window is a top-level IE window.
static bool IsIeFrameClass(HWND window);
// Returns the IE frame window at the top of the Z-order. This will generally
// be the last window used or the new window just created.
// @return The HWND of the top IE window.
static HWND TopIeWindow();
// Build the result_ value from the provided window info. It will set the
// value if it is currently NULL, otherwise it assumes it is a ListValue and
// adds a new Value to it.
// @param window The window handle
// @param window_info The info about the window to create a new value for.
// @param populate_tabs To specify if we want to populate the tabs info.
virtual void SetResultFromWindowInfo(HWND window,
const CeeeWindowInfo& window_info,
bool populate_tabs);
// Creates a list value of all tabs in the given list.
// @param tab_list A list of HWND and index of the tabs for which we want to
// create a value JSON encoded as a list of (id, index) pairs.
// @Return A ListValue containing the individual Values for each tab info.
virtual Value* CreateTabList(BSTR tab_list);
// Creates a value for the given window, populating tabs if requested.
// Sets value_ with the appropriate value content, or resets it in case of
// errors. Also calls PostError() if there is an error and returns false.
// The @p window parameter contrasts with CreateTabValue because we most
// often use this function with HWND gotten without Ids (ie. from
// TopIeWindow()). This was not the case with CreateTabValue.
// @param window The identifier of the window for which to create the value.
// @param populate_tabs To specify if we want to populate the tabs info.
virtual bool CreateWindowValue(HWND window, bool populate_tabs);
};
// Helper class to handle the data cleanup.
class WindowInfo : public CeeeWindowInfo {
public:
WindowInfo();
~WindowInfo();
};
} // namespace common_api
#endif // CEEE_IE_BROKER_COMMON_API_MODULE_H_
| [
"mad@chromium.org@08a922ab-59a6-2b78-e7d4-e11e5aec3cef"
] | mad@chromium.org@08a922ab-59a6-2b78-e7d4-e11e5aec3cef |
0328ee55ffbea2801a13ba50ec6489fd7e165f6c | f20e965e19b749e84281cb35baea6787f815f777 | /Online/Online/OnlineBase/src/CPP/TimeSensor.cpp | cf6836ac29d86c67d9974ddfcef9456c778774eb | [] | no_license | marromlam/lhcb-software | f677abc9c6a27aa82a9b68c062eab587e6883906 | f3a80ecab090d9ec1b33e12b987d3d743884dc24 | refs/heads/master | 2020-12-23T15:26:01.606128 | 2016-04-08T15:48:59 | 2016-04-08T15:48:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,325 | cpp | #include <cstdio>
#include <cstdlib>
#include <map>
#include "CPP/Event.h"
#include "CPP/TimeSensor.h"
#include "CPP/Interactor.h"
#include "WT/wtdef.h"
#include "RTL/rtl.h"
namespace {
class Period;
class InteractorTarget;
class Period {
friend class CPP::TimeSensor;
private:
int Time;
unsigned long m_alrmID;
std::string m_ascTime;
bool m_rearmPending;
bool m_cyclic;
Period* m_next;
public:
/// Initializing constructor
explicit Period( char* );
/// Default destructor
~Period();
void Set();
void cancel();
// unsigned long& id() { return m_alrmID; }
Period* next() const { return m_next; }
void setNext(Period* n) { m_next = n; }
static int ast( void* param );
};
class InteractorTarget {
friend class CPP::TimeSensor;
private:
Interactor* Inter;
void* Data;
public:
/// Initializing constructor
explicit InteractorTarget( Interactor* i, void* d = 0 ) { Inter = i; Data = d;}
};
//----------------------------------------------------------------------------
Period::Period(char* period) : m_alrmID(0) {
int day, hour, minute, sec;
if( *period == '+' ) period++, m_cyclic = true;
else m_cyclic = false;
m_ascTime = period;
sscanf(m_ascTime.c_str(), "%d %d:%d:%d.0", &day, &hour, &minute, &sec);
Time = sec + day*86400 + hour*3600 + minute*60;
m_rearmPending = true;
m_next = 0;
}
//----------------------------------------------------------------------------
Period::~Period() {
}
//----------------------------------------------------------------------------
void Period::cancel() {
if ( m_alrmID ) {
int status = lib_rtl_kill_timer(m_alrmID);
if ( !lib_rtl_is_success(status) ) {
lib_rtl_signal_message(status,"Failed to cancel period timer.");
}
}
}
//----------------------------------------------------------------------------
void Period::Set() {
int status = lib_rtl_set_timer(Time*1000, ast, this, &m_alrmID);
if ( !lib_rtl_is_success(status) ) {
lib_rtl_signal_message(status,"Failed to set period timer.");
}
}
//----------------------------------------------------------------------------
int Period::ast( void* param ) {
Period *period = (Period*)param;
period->m_alrmID = 0;
return wtc_insert(WT_FACILITY_SENSOR1, param);
}
typedef std::map<Period*, InteractorTarget*> InteractorTable;
static Period* s_periodHead = 0;
static InteractorTable s_interactorTable;
}
//----------------------------------------------------------------------------
TimeSensor::TimeSensor() : Sensor( WT_FACILITY_SENSOR1, "TimeSensor" ) {
}
//----------------------------------------------------------------------------
TimeSensor::~TimeSensor() {
s_interactorTable.clear();
}
//----------------------------------------------------------------------------
void TimeSensor::add( Interactor* interactor, void* newperiod) {
return add(interactor,newperiod,0);
}
//----------------------------------------------------------------------------
void TimeSensor::add( Interactor* interactor, void* newperiod, void* data) {
Period *temperiod = new Period( (char*)newperiod );
InteractorTarget *inttar = new InteractorTarget(interactor,data);
temperiod->setNext(s_periodHead);
s_periodHead = temperiod;
s_interactorTable.insert( std::make_pair(temperiod,inttar));
//---If the TimeSensor is the only active sensor, then it is necessary to
// rearm it here and not delay it.
rearm();
m_rearmPending = false;
}
//----------------------------------------------------------------------------
void TimeSensor::add( Interactor* interactor, int timesec, void* data ) {
char times[64];
int day = (timesec)/86400;
int hour = (timesec - day*86400)/3600;
int minute = (timesec - day*86400 - hour*3600)/60;
int sec = (timesec - day*86400 - hour*3600 - minute*60);
::snprintf(times,sizeof(times),"%d %d:%d:%d.0", day, hour, minute, sec);
add( interactor, times, data );
}
//----------------------------------------------------------------------------
void TimeSensor::remove( Interactor* interactor, void* data ) {
for( Period* pd = s_periodHead, *last = 0; pd; last = pd, pd = pd->next()) {
InteractorTable::iterator i = s_interactorTable.find(pd);
if ( i != s_interactorTable.end() ) {
InteractorTarget *it = (*i).second;
if( it->Inter == interactor && (data == 0 || it->Data == data) ) {
s_interactorTable.erase(i);
pd->cancel();
if( !last )
s_periodHead = pd->next();
else
last->setNext(pd->next());
delete pd;
delete it;
break;
}
}
}
}
//----------------------------------------------------------------------------
void TimeSensor::dispatch( void* id ) {
Period *period = (Period*)id;
InteractorTable::iterator i = s_interactorTable.find(period);
if ( i != s_interactorTable.end() ) {
InteractorTarget *it = (*i).second;
if( period->m_cyclic ) {
period->m_rearmPending = true;
Event ev(it->Inter,TimeEvent);
ev.timer_id = id;
ev.timer_data = it->Data;
ev.target->handle(ev);
}
else {
if ( period == s_periodHead ) {
s_periodHead = period->m_next;
}
else {
for(Period* pd = s_periodHead; pd; pd = pd->m_next) {
if( pd->m_next == period ) {
pd->m_next = period->m_next; break;
}
}
}
s_interactorTable.erase(i);
Event ev(it->Inter, TimeEvent);
ev.timer_id = id;
ev.timer_data = it->Data;
delete period;
delete it;
ev.target->handle(ev);
}
}
}
//----------------------------------------------------------------------------
void TimeSensor::rearm() {
for(Period * pd = s_periodHead; pd; pd = pd->m_next) {
if ( pd->m_rearmPending ) {
pd->Set();
pd->m_rearmPending = false;
}
}
}
//----------------------------------------------------------------------------
TimeSensor& TimeSensor::instance() {
static TimeSensor *sensor = new TimeSensor;
return *sensor;
}
| [
"frankb@cern.ch"
] | frankb@cern.ch |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.