blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
be9bf4d633add3efa7b9fadb6c190aeefe38a149 | 54f8416303a7c0d91fdcb503fdc2b7c9af79ea7c | /src/utils/args.hpp | 4fdd88297e3626c61c79585fcf89d874217d2cd8 | [
"MIT"
] | permissive | praveenmunagapati/ccompiler | 2d564bd726e45253e70f49c9d55f07023ce680fd | f87418d5fb3f47e404b6e9004a06cb0e6faeea8d | refs/heads/master | 2021-07-16T15:51:16.914335 | 2017-09-16T23:25:21 | 2017-09-20T18:37:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,728 | hpp | args.hpp | #pragma once
#include <cstring>
#include <cassert>
#include <stdexcept>
#include "../cpp/string_view.hpp"
#include "../cpp/variant.hpp"
#include "../cpp/format.hpp"
#include "../cpp/contracts.hpp"
namespace utils
{
struct invalid_option : std::logic_error
{
using std::logic_error::logic_error;
};
inline auto is_opt(char** argv) -> bool
{
Expects(argv != nullptr);
Expects(*argv != nullptr);
string_view arg = *argv;
// Every argument starting with - is a valid option.
return arg.size() >= 2 && arg[0] == '-';
}
inline auto opt_exists(char**& argv, const string_view& short_opt, const string_view& long_opt) -> bool
{
Expects(argv != nullptr);
Expects(*argv != nullptr);
Expects(short_opt.size() <= 2);
Expects(long_opt.empty() || long_opt.size() >= 2);
if (!is_opt(argv))
{
return false;
}
const string_view arg = *argv;
if (!short_opt.empty() && arg.substr(0, 2) == short_opt)
{
if (arg.size() > 2)
{
std::advance(*argv, 1);
(*argv)[0] = '-';
}
else
{
std::advance(argv, 1);
}
return true;
}
if (!long_opt.empty() && arg == long_opt)
{
// Just skip once, no argument should be present.
std::advance(argv, 1);
return true;
}
return false;
}
inline auto opt_get(char**& argv, const string_view& short_opt, const string_view& long_opt) -> string_view
{
Expects(argv != nullptr);
Expects(*argv != nullptr);
Expects(short_opt.size() <= 2);
Expects(long_opt.empty() || long_opt.size() >= 2);
if (!is_opt(argv))
{
return string_view{};
}
const string_view arg = *argv;
if (!short_opt.empty() && arg.substr(0, 2) == short_opt)
{
if (arg.size() > 2)
{
const auto arg_value = arg.substr((arg[2] == '=') ? 3 : 2);
if (!arg_value.empty())
{
std::advance(argv, 1);
return arg_value;
}
}
else if (*std::next(argv) != nullptr)
{
std::advance(argv, 2);
return *std::prev(argv);
}
else
{
throw invalid_option(fmt::format("missing argument to `{}'", short_opt.data()));
}
}
const auto equal_pos = std::min(arg.find('='), arg.size());
if (!long_opt.empty() && arg.substr(0, equal_pos) == long_opt)
{
if (equal_pos != arg.size())
{
auto arg_value = arg.substr(equal_pos + 1);
if (!arg_value.empty())
{
std::advance(argv, 1);
return arg_value;
}
}
else if (*std::next(argv) != nullptr)
{
auto it = std::next(argv);
std::advance(argv, 2);
return *it;
}
else
{
throw invalid_option(fmt::format("missing argument to `{}'", long_opt.data()));
}
}
return string_view{};
}
} // namespace utils
|
dd1fe0497e13e13682a8127522867f5a98c93a28 | 90d253b075c47054ab1d6bf6206f37e810330068 | /LeetCode/Weekly322/2490.cpp | f01f36a1affa2819b4a38f81df780edce1beea88 | [
"MIT"
] | permissive | eyangch/competitive-programming | 45684aa804cbcde1999010332627228ac1ac4ef8 | de9bb192c604a3dfbdd4c2757e478e7265516c9c | refs/heads/master | 2023-07-10T08:59:25.674500 | 2023-06-25T09:30:43 | 2023-06-25T09:30:43 | 178,763,969 | 22 | 8 | null | null | null | null | UTF-8 | C++ | false | false | 477 | cpp | 2490.cpp | class Solution {
public:
bool isCircularSentence(string sentence) {
istringstream iss(sentence);
string cur;
char f = '~';
char l = '~';
while(getline(iss, cur, ' ')){
if(l == '~'){
f = cur[0];
}else{
if(cur[0] != l) return false;
}
l = cur[cur.length()-1];
}
if(f != l){
return false;
}
return true;
}
}; |
7f3065ebe3a0ac4ce151fbd0aead0598f68a5eb2 | 1c43294f43549c3ebfa6b5bc038b955ef5e64cf3 | /food_and_drink.cpp | ce753bef744aca0ff52e8b56995a393227a48a04 | [] | no_license | J3B60/CPP-exercises-Week-2 | 6ac814864e124df539c5353091f2d0dfc5e98e3b | a02add32f3813340e3f2a21aaf1e792413696420 | refs/heads/master | 2023-03-15T00:44:12.122885 | 2021-02-22T18:56:09 | 2021-02-22T18:56:09 | 341,576,351 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,569 | cpp | food_and_drink.cpp | // Let's include the C++ string header
#include <string>
// I can also include any of the C standard library files
// by dropping the ".h" off the end, and putting a "c" at the front.
// So, if I want stuff contained in <stdlib.h> and <time.h>...
#include <cstdlib>
#include <ctime>
// Finally, we'll include our header files
// Remember: standard header files use <>, ours use ""
#include "food_and_drink.h"
// We're using the standard namespace (containing string)
// Alternatively, we could have skipped this line, and instead written "std::string" everywhere we used "string" in the code (like we did in the header)
// Namespaces are useful when you've got code that comes from (or will be used in) a lot of different people's work
using namespace std;
// Selecting a random food item and a random drink item are both the same sort of thing,
// so I'd prefer to not have to write the same code twice.
// Because GetRandomItemFromList is NOT in the header file, only functions in this file can see it
// GetRandomItemFromList returns a string, and requires 2 arguments: an array of strings, and an integer to let us know how many strings we have
string GetRandomItemFromList(string list[], int num_items_in_list)
{
// We want to pick an item from the list at random.
// rand is a cheap function defined by the C standard library in stdlib
// It's got some poor statistical characteristics, but our application is simple enough to not care
// srand initialises the random number generator (without this, we get the same numbers every time)
// We'll initialise it using the current time, as this is fairly difficult to predict.
// Note: It is generally bad practice to call srand multiple times. This is because programs
// execute very fast on a modern processor, and there is a good chance that the next call to time() will
// be within the same second. srand will then return the same value, and when you call rand you'll
// end up with the same value from the generator.
// Ordinarily, you would place this in the main function, call it once on program start and then never call it again.
srand(time(NULL));
// rand will pick a random number between 0 and INT_MAX. We'd like to pick a number between 0 and the end of our list
// Our good friend modulus (%) helps us here
// rand will pick some arbitrary big number, but since we only take the remainder, we know the end value will be in the range we want
// (work it out with a pen and paper if you don't see how this works: divide a big number by the list count, and look at the remainder)
int index = rand() % num_items_in_list;
// Now we know which position in the array we want, we'll return it.
return list[index];
}
string GetRandomFoodItem()
{
// An array of foods.
// Note that I only need a one-dimensional array,
// and that I don't care how long a string is.
// This is the magic that is the string class
string foods[10] =
{
"carrots",
"apples",
"oranges",
"biscuits",
"sweets",
"sandwiches",
"lemons", // do children eat lemons? Probably.
"boiled eggs",
"slices of cake",
"bowls of ice-cream"
};
// Pick something from the list, and return it.
return GetRandomItemFromList(foods, 10);
}
string GetRandomDrinkItem()
{
// An array of drinks.
// Again, the string class has made it a bit easier than in C
string drinks[5] =
{
"cups of milk",
"glasses of water",
"mugs of hot chocolate",
"cups of tea",
"cans of fizzy pop"
};
// Pick something from the list, and return it.
return GetRandomItemFromList(drinks, 5);
}
|
e3135254c6020227e2727cf523957f3973e52e66 | a3d99125d2070073b4245223727cd58e81c43d68 | /CPPFileExample/src/CPPFileExample.cpp | e6d0fbb5233680e3c7f3de98fe7ed8033528f856 | [] | no_license | joseph2186/Prep-2017 | af7a7f66f5acdf5780ffd0f5a621e2e5501c7e15 | 386b59654eb0b0388a5e53ec0f694321bfb619d2 | refs/heads/master | 2021-01-09T06:20:23.666497 | 2017-10-18T03:38:32 | 2017-10-18T03:38:32 | 80,965,791 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 840 | cpp | CPPFileExample.cpp | //============================================================================
// Name : CPPFileExample.cpp
// Author : JKB
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string str("My name is Joseph");
char out[str.size()];
ofstream ofile;
ofile.open("file.txt");
if ( ofile.is_open() )
{
ofile << str;
}
ofile.close();
ifstream ifile;
ifile.open("file.txt");
#if 0
if ( ifile.is_open() )
{
while ( !ifile.eof() )
{
ifile >> out;
cout << out;
}
}
#else
if (ifile.is_open())
{
ifile.getline(out, str.size()+1);
cout << out;
}
#endif
ifile.close();
return 0;
}
|
9557aa64b292d83d625b46d5326e054ded23fdd0 | c9fbcd2712bccb1c64286497842da4585779b70b | /TwoDeeFramework/TwoDeeFramework/SDL_Manager.h | 3fe9b252766585cff124049452c11b24a3988785 | [] | no_license | ruulaasz/TwoDeeFramework | fae773a0b7c3f1fb6aec188e1c0754fa05dcf011 | 099dd73c7acb9ac63fc97b4f11fcc05679c521b1 | refs/heads/master | 2020-03-26T15:54:13.303361 | 2018-10-31T22:58:57 | 2018-10-31T22:58:57 | 145,070,677 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,633 | h | SDL_Manager.h | #pragma once
#pragma comment(lib, "SDL2.lib")
#pragma comment(lib, "SDL2_image.lib")
#pragma comment(lib, "SDL2_ttf.lib")
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include "Module.h"
namespace TDF
{
class Texture;
//! A manager class for SDL 2.0.
/*!
Used to initialize and use the SDL 2.0 modules.
*/
class SDL_Manager : public Module<SDL_Manager>
{
public:
//! Default constructor.
/*!
Initialize the members of the class.
*/
SDL_Manager();
//! Default destructor.
/*!
Does nothing use the release() function instead.
\sa release()
*/
~SDL_Manager();
//! Initialize SDL 2.0 subsystems and creates the window and renderer.
/*!
\sa initSubSystems(), createWindowAndRenderer()
*/
void init();
//! Shut down the SDL 2.0 subsystems and cleans the memory.
/*!
\sa ~SDL_Manager()
*/
void release();
//! Update the manager.
/*!
\param _deltaTime a float, the change of time.
*/
void update(float _deltaTime);
//! Creates the window and renderer.
/*!
\param _fullscreen an integer, 0 for windowed 1 for fullscreen.
*/
void setFullscreen(int _fullscreen);
//! Change the size of the window.
/*!
\param _w an integer, the new width of the window.
\param _h an integer, the new height of the window.
*/
void resizeWindow(int _w, int _h);
//! Updates the manager values with the current window size.
void updateWindowSize();
//! Set the title of the window.
void setWindowTitle(const char* _title);
private:
//! Initialize SDL 2.0 subsystems.
/*!
\sa init()
*/
void initSubSystems();
//! Creates the window and renderer.
/*!
\param _name a constant character pointer, the window name.
\param _windowWidth an integer, the width of the window.
\param _windowHeight an integer, the height of the window.
\sa init()
*/
void createWindowAndRenderer(const char* _name = "New Window",
int _windowWidth = 1920,
int _windowHeight = 1000);
public:
//! A pointer to a SDL renderer.
SDL_Renderer* m_renderer;
//! A pointer to a SDL window.
SDL_Window* m_window;
//! The SDL events.
SDL_Event m_events;
//! A joystick handler.
SDL_GameController* m_controller;
//! The width of the window.
int m_windowWidth;
//! The height of the window.
int m_windowHeight;
//! If the window is fullscreen.
bool m_fullscreen;
//! The X position of the mouse.
int m_mousePosX;
//! The Y position of the mouse.
int m_mousePosY;
//! The X position of the mouse.
int m_mouseWorldPosX;
//! The Y position of the mouse.
int m_mouseWorldPosY;
};
} |
99c64d593874bc3de658020841f6d094185c9cba | 4be9494f8b5f4b77cbdcf7ff5b1780d4a3f27a9d | /test/unittests/lib/core/stack_unittest.hpp | cfabcbe08d6c30f82f5a0ae16db18c2a3a10b90b | [
"BSD-3-Clause"
] | permissive | PunchShadow/WasmVM | 122bcaef2888557f7b2018bf547557d04145c689 | 824ca57eb2d699b8c641382c867af089d7518b8a | refs/heads/master | 2020-04-05T15:21:26.343054 | 2019-04-30T11:14:55 | 2019-04-30T11:14:55 | 153,037,301 | 0 | 0 | BSD-3-Clause | 2018-10-15T01:40:13 | 2018-10-15T01:40:13 | null | UTF-8 | C++ | false | false | 857 | hpp | stack_unittest.hpp | #include <skypat/skypat.h>
#define _Bool bool
extern "C" {
#include <dataTypes/Value.h>
#include <core/Stack.h>
#include <dataTypes/Label.h>
#include <dataTypes/Frame.h>
#include <dataTypes/Value.h>
}
#undef _Bool
SKYPAT_F(Stack, create_delete)
{
// Prepare
Stack* stack = new_Stack();
// Check
EXPECT_EQ(stack->entries->size, 0);
EXPECT_EQ(stack->entries->head, NULL);
free_Stack(stack);
}
SKYPAT_F(Stack, push_Label)
{
// Prepare
Stack* stack = new_Stack();
push_Label(stack, new_Label(0, 1, 2));
// Check
EXPECT_EQ(stack->entries->size, 1);
EXPECT_NE(stack->entries->head, NULL);
Label* result = NULL;
stack->entries->top(stack->entries, (void**)&result);
EXPECT_EQ(result->funcAddr, 0);
EXPECT_EQ(result->instrIndex, 1);
EXPECT_EQ(result->contInstr, 2);
free_Stack(stack);
} |
c7f6252aff5a25957835ffae48d73c9ff9b4e326 | 55c9e34fc7deb751a553c1c3ed99d90d050a8b05 | /363A - Soroban.cpp | cd274513eb7758bb38f3ffe95400522deee3f334 | [] | no_license | WaterPlimpie/CodeforcesSolutions | 3287f496bc7d3b83f4bf7b11e6b97bca1b991e83 | edd5307449891ab23c53b4caf4046f6580468141 | refs/heads/master | 2020-03-22T06:31:51.504396 | 2018-07-03T23:23:57 | 2018-07-03T23:23:57 | 139,640,729 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 410 | cpp | 363A - Soroban.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
string nums[] {
"O-|-OOOO",
"O-|O-OOO",
"O-|OO-OO",
"O-|OOO-O",
"O-|OOOO-",
"-O|-OOOO",
"-O|O-OOO",
"-O|OO-OO",
"-O|OOO-O",
"-O|OOOO-"
};
for (int i = s.length() - 1; i >= 0; --i) {
cout << nums[s[i] - '0'] << '\n';
}
} |
6d063c7961ac8aacc86b5509c2eb9521f8098aa2 | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /ash/app_list/model/search/search_result.h | e4ce65c0720604430613cfbbf7ec64a5ca642593 | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 8,841 | h | search_result.h | // Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_APP_LIST_MODEL_SEARCH_SEARCH_RESULT_H_
#define ASH_APP_LIST_MODEL_SEARCH_SEARCH_RESULT_H_
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "ash/app_list/model/app_list_model_export.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "base/observer_list.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/range/range.h"
namespace ui {
class ImageModel;
} // namespace ui
namespace ash {
class SearchResultObserver;
// SearchResult consists of an icon, title text and details text. Title and
// details text can have tagged ranges that are displayed differently from
// default style.
class APP_LIST_MODEL_EXPORT SearchResult {
public:
using Category = ash::AppListSearchResultCategory;
using ResultType = ash::AppListSearchResultType;
using DisplayType = ash::SearchResultDisplayType;
using MetricsType = ash::SearchResultType;
using Tag = ash::SearchResultTag;
using Tags = ash::SearchResultTags;
using Action = ash::SearchResultAction;
using Actions = ash::SearchResultActions;
using IconInfo = ash::SearchResultIconInfo;
using IconShape = ash::SearchResultIconShape;
using TextItem = ash::SearchResultTextItem;
using TextVector = std::vector<TextItem>;
SearchResult();
SearchResult(const SearchResult&) = delete;
SearchResult& operator=(const SearchResult&) = delete;
virtual ~SearchResult();
const IconInfo& icon() const { return metadata_->icon; }
void SetIcon(const IconInfo& icon);
const gfx::ImageSkia& chip_icon() const { return metadata_->chip_icon; }
void SetChipIcon(const gfx::ImageSkia& chip_icon);
const ui::ImageModel& badge_icon() const { return metadata_->badge_icon; }
void SetBadgeIcon(const ui::ImageModel& badge_icon);
const std::u16string& title() const { return metadata_->title; }
void SetTitle(const std::u16string& title);
const Tags& title_tags() const { return metadata_->title_tags; }
void SetTitleTags(const Tags& tags);
const TextVector& title_text_vector() const {
return metadata_->title_vector;
}
void SetTitleTextVector(const TextVector& vector);
bool multiline_title() const { return metadata_->multiline_title; }
void SetMultilineTitle(bool multiline_title);
const std::u16string& details() const { return metadata_->details; }
void SetDetails(const std::u16string& details);
const Tags& details_tags() const { return metadata_->details_tags; }
void SetDetailsTags(const Tags& tags);
const TextVector& details_text_vector() const {
return metadata_->details_vector;
}
void SetDetailsTextVector(const TextVector& vector);
bool multiline_details() const { return metadata_->multiline_details; }
void SetMultilineDetails(bool multiline_details);
const TextVector& big_title_text_vector() const {
return metadata_->big_title_vector;
}
void SetBigTitleTextVector(const TextVector& vector);
const TextVector& big_title_superscript_text_vector() const {
return metadata_->big_title_superscript_vector;
}
void SetBigTitleSuperscriptTextVector(const TextVector& vector);
const TextVector& keyboard_shortcut_text_vector() const {
return metadata_->keyboard_shortcut_vector;
}
void SetKeyboardShortcutTextVector(const TextVector& vector);
const std::u16string& accessible_name() const {
return metadata_->accessible_name;
}
void SetAccessibleName(const std::u16string& name);
float rating() const { return metadata_->rating; }
void SetRating(float rating);
const std::u16string& formatted_price() const {
return metadata_->formatted_price;
}
void SetFormattedPrice(const std::u16string& formatted_price);
const std::string& id() const { return metadata_->id; }
double display_score() const { return metadata_->display_score; }
void set_display_score(double display_score) {
metadata_->display_score = display_score;
}
Category category() const { return metadata_->category; }
void set_category(Category category) { metadata_->category = category; }
bool best_match() const { return metadata_->best_match; }
void set_best_match(bool best_match) { metadata_->best_match = best_match; }
DisplayType display_type() const { return metadata_->display_type; }
void set_display_type(DisplayType display_type) {
metadata_->display_type = display_type;
}
ResultType result_type() const { return metadata_->result_type; }
void set_result_type(ResultType result_type) {
metadata_->result_type = result_type;
}
MetricsType metrics_type() const { return metadata_->metrics_type; }
void set_metrics_type(MetricsType metrics_type) {
metadata_->metrics_type = metrics_type;
}
const Actions& actions() const { return metadata_->actions; }
void SetActions(const Actions& sets);
bool is_omnibox_search() const { return metadata_->is_omnibox_search; }
void set_is_omnibox_search(bool is_omnibox_search) {
metadata_->is_omnibox_search = is_omnibox_search;
}
bool is_visible() const { return is_visible_; }
void set_is_visible(bool is_visible) { is_visible_ = is_visible; }
bool is_recommendation() const { return metadata_->is_recommendation; }
void set_is_recommendation(bool is_recommendation) {
metadata_->is_recommendation = is_recommendation;
}
bool is_system_info_card() const {
return metadata_->system_info_answer_card_data.has_value();
}
bool is_system_info_card_bar_chart() const {
return metadata_->system_info_answer_card_data.has_value() &&
metadata_->system_info_answer_card_data->bar_chart_percentage
.has_value();
}
bool has_extra_system_data_details() const {
return metadata_->system_info_answer_card_data.has_value() &&
metadata_->system_info_answer_card_data->extra_details.has_value();
}
absl::optional<std::u16string> system_info_extra_details() const {
return has_extra_system_data_details()
? metadata_->system_info_answer_card_data->extra_details
: absl::nullopt;
}
absl::optional<double> bar_chart_value() const {
return is_system_info_card_bar_chart()
? metadata_->system_info_answer_card_data->bar_chart_percentage
: absl::nullopt;
}
absl::optional<double> upper_limit_for_bar_chart() const {
return is_system_info_card_bar_chart()
? metadata_->system_info_answer_card_data
->upper_warning_limit_bar_chart
: absl::nullopt;
}
absl::optional<double> lower_limit_for_bar_chart() const {
return is_system_info_card_bar_chart()
? metadata_->system_info_answer_card_data
->lower_warning_limit_bar_chart
: absl::nullopt;
}
bool skip_update_animation() const {
return metadata_->skip_update_animation;
}
void set_skip_update_animation(bool skip_update_animation) {
metadata_->skip_update_animation = skip_update_animation;
}
bool use_badge_icon_background() const {
return metadata_->use_badge_icon_background;
}
void set_system_info_answer_card_data(
const ash::SystemInfoAnswerCardData& system_info_data) {
metadata_->system_info_answer_card_data = system_info_data;
}
base::FilePath file_path() const { return metadata_->file_path; }
ash::FileMetadataLoader* file_metadata_loader() {
return &metadata_->file_metadata_loader;
}
void set_file_metadata_loader_for_test(ash::FileMetadataLoader* loader) {
metadata_->file_metadata_loader = *loader;
}
void AddObserver(SearchResultObserver* observer);
void RemoveObserver(SearchResultObserver* observer);
// Invokes a custom action on the result. It does nothing by default.
virtual void InvokeAction(int action_index, int event_flags);
void SetMetadata(std::unique_ptr<SearchResultMetadata> metadata);
std::unique_ptr<SearchResultMetadata> TakeMetadata() {
return std::move(metadata_);
}
std::unique_ptr<SearchResultMetadata> CloneMetadata() const {
return std::make_unique<SearchResultMetadata>(*metadata_);
}
protected:
void set_id(const std::string& id) { metadata_->id = id; }
private:
friend class SearchController;
// TODO(crbug.com/1352636) Remove this friend class. Currently used to mock
// results for SearchResultImageView prototyping.
friend class SearchResultImageView;
// Opens the result. Clients should use AppListViewDelegate::OpenSearchResult.
virtual void Open(int event_flags);
bool is_visible_ = true;
std::unique_ptr<SearchResultMetadata> metadata_;
base::ObserverList<SearchResultObserver> observers_;
};
} // namespace ash
#endif // ASH_APP_LIST_MODEL_SEARCH_SEARCH_RESULT_H_
|
96414def7200902a097c0ee0ba466fd537b5310c | 5d134a52c1a0148efd7c95bbdef486f4223be936 | /src/Simulation/Handler/ThermostatHandler.h | c4953de7b6d78f4982e228879c7bf53d6987bb6c | [] | no_license | molekulardynamik/projekt | d0ace5820cd36e35aa0ff29adfa0e4f7fe94e206 | 5c231bb997e70c4c9c403cea0c5ddbf8dae9573c | refs/heads/master | 2021-01-22T03:05:28.191968 | 2015-01-22T14:13:14 | 2015-01-22T14:13:14 | 25,927,925 | 0 | 0 | null | 2014-10-29T15:53:06 | 2014-10-29T15:40:16 | null | UTF-8 | C++ | false | false | 2,801 | h | ThermostatHandler.h | #pragma once
#include "ParticleHandler.h"
#include "../MaxwellBoltzmannDistribution.h"
namespace Simulation
{
/// \class Thermostat
/// \brief stores global data for temperature calculations
class Thermostat
{
public:
static int& numDimensions()
{
static int dim_;
return dim_;
}
static double& kineticEnergy()
{
static double kineticEnergy_;
return kineticEnergy_;
}
};
/// \class ThermostatHandler
/// \brief applies temperature scaling to all particles
class ThermostatHandler: public ParticleHandler
{
public:
ThermostatHandler(int wallT, utils::Vector<bool, 3> m):
wallType(wallT), mask(m)
{
}
void compute(Particle& p)
{
if(p.getType() == wallType)
return;
if(mask[0])
p.getV()[0] *= tempScale_;
if(mask[1])
p.getV()[1] *= tempScale_;
if(mask[2])
p.getV()[2] *= tempScale_;
}
/// sets the target temperature
/// \param temp target tempertaure
/// \param interpolation value between 0 and 1 and scales the how much the thermostat effect the particles
/// \param numParticles number of particles
void setTargetTemp(double temp, double interpolation, int numParticles)
{
double desiredEnergy = numParticles * Thermostat::numDimensions() * 0.5 * temp;
tempScale_ = sqrt(desiredEnergy / Thermostat::kineticEnergy());
tempScale_ = tempScale_ * interpolation + (1 - interpolation);
}
private:
double tempScale_;
utils::Vector<bool, 3> mask; /// < mask for which axis should be affected
int wallType; /// < particles of this type should be ignored
};
/// \class BrownianMotionHandler
/// \brief applies initail velocity based on temperature
class BrownianMotionHandler : public ParticleHandler
{
public:
BrownianMotionHandler(int initTemp, int wallT) :
initialTemp_(initTemp), wallType(wallT)
{
}
void compute(Particle& p)
{
if(p.getType() == wallType)
return;
double meanVelocity = sqrt(initialTemp_ / p.getM());
MaxwellBoltzmannDistribution(p, meanVelocity, Thermostat::numDimensions());
}
private:
double initialTemp_;
int wallType; /// < particles of this type should be ignored
};
/// \class KineticEnergyHandler
/// \brief calculates kinetic energy in the simulation
class KineticEnergyHandler : public ParticleHandler
{
public:
KineticEnergyHandler(int wallT, utils::Vector<bool, 3> m):
wallType(wallT), mask(m)
{
}
void compute(Particle& p)
{
if(p.getType() == wallType)
return;
utils::Vector<double, 3> vel = p.getV();
if(!mask[0])
vel[0] = 0;
if(!mask[1])
vel[1] = 0;
if(!mask[2])
vel[2] = 0;
Thermostat::kineticEnergy() += (vel * vel) * p.getM() * 0.5;
}
void reset()
{
Thermostat::kineticEnergy() = 0;
}
private:
int wallType; /// < particles of this type should be ignored
utils::Vector<bool, 3> mask; /// < mask for which axis should be affected
};
}
|
92b44d2fe3060f99afcc55eaf45e8e7e3f3078ed | 84ce9ea0aaf0978485a357939e09bfe8e863305f | /RemoteEye/GoalkeeperAnalysis/src/VideoSession.h | e478404efb8a1b38ad60c421dd526c1cbb521907 | [
"MIT"
] | permissive | dmikushin/RemoteEye | af13043c19188b0ab9e486cf86efe9ecbcdbbcd6 | f467594e8d0246d7cc87bf843da1d09e105fcca7 | refs/heads/master | 2022-11-27T21:33:55.330974 | 2020-08-08T16:05:37 | 2020-08-08T16:05:37 | 286,013,449 | 0 | 0 | MIT | 2020-08-08T09:31:59 | 2020-08-08T09:31:58 | null | UTF-8 | C++ | false | false | 272 | h | VideoSession.h | #ifndef VIDEO_SOURCE_H_
#define VIDEO_SOURCE_H_
#include <functional>
class VideoSession
{
public:
virtual ~VideoSession() = default;
virtual bool startCapture(std::function<void(unsigned char*, unsigned int)> callback) = 0;
virtual void stopCapture() = 0;
};
#endif |
ac03c0d579e90a6e1c11babdc775d4815d2b0e87 | 26b8dec14c742c8f476e49ca3a3c6f2a86d43dd1 | /LIKECS04.cpp | 5163bef2f9df3eecd7865be002dad58b5e3846a7 | [] | no_license | anonyhostvn/WorkSpaceCpp | 758aa4aa4cd748c733dc92b1bed614408e51d422 | 83aa8eb3f07b0057f47a89f8dd9fe1473badb811 | refs/heads/master | 2021-10-27T11:54:59.894720 | 2019-04-16T19:27:17 | 2019-04-16T19:27:17 | 114,501,246 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,533 | cpp | LIKECS04.cpp | #include <bits/stdc++.h>
#define forinc(i,a,b) for (int i = a ; i <= b ; i ++)
#define fordec(i,a,b) for (int i = a ; i >= b ; i --)
#define forv(j,u) for (int j = 0 ; j < u.size() ; j++)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
#define maxN 51
#define base 1000000007
using namespace std ;
int n , a[maxN] , f[maxN][maxN*maxN][maxN] , maxs = 0 , maxa = 0 , fgcd[maxN][maxN] ;
bool ok[5000] ;
void enter()
{
cin >> n ;
forinc(i,1,n) cin >> a[i] , maxs += a[i] , maxa = max(maxa,a[i]) ;
}
int gcd(int a , int b)
{
if (a == 0) return b ; else if (b == 0) return a ;
while (b != 0) {
int tmp = a % b ;
a = b ; b = tmp ;
}
return a ;
}
void prepare()
{
forinc(i,0,12) ok[(1<<i)] = true ;
forinc(i,0,50)
forinc(j,0,50) fgcd[i][j] = gcd(i,j) ;
}
bool check(int a , int b)
{
double c = (double) a / b ;
if ((int) c != c) return false ;
return ok[(int) c] ;
}
void process()
{
prepare() ;
forinc(i,0,a[1]) f[1][i][i] = 1 ;
forinc(i,1,n-1)
forinc(sum,0,maxs)
forinc(g,0,maxa) if (f[i][sum][g] > 0)
forinc(nxt,0,a[i+1]) f[i+1][sum+nxt][fgcd[g][nxt]] += f[i][sum][g] , f[i+1][sum+nxt][fgcd[g][nxt]] %= base ;
int res = 0 ;
forinc(sum,1,maxs)
forinc(g,1,maxa) if (check(sum,g)) res += f[n][sum][g] , res %= base ;
cout << res << endl ;
}
int main()
{
//freopen("LIKECS04.inp" , "r" , stdin) ;
enter() ;
process() ;
return 0 ;
}
|
acf0bb9a4dc467bc63b97c844436a2cea8988ff4 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_19003.cpp | 6148d0444f5f96c1ce553d0ca322835c251cd931 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,311 | cpp | Kitware_CMake_repos_basic_block_block_19003.cpp | {
switch (sys_err) {
case 0: return 0;
#if defined(EAI_ADDRFAMILY)
case EAI_ADDRFAMILY: return UV_EAI_ADDRFAMILY;
#endif
#if defined(EAI_AGAIN)
case EAI_AGAIN: return UV_EAI_AGAIN;
#endif
#if defined(EAI_BADFLAGS)
case EAI_BADFLAGS: return UV_EAI_BADFLAGS;
#endif
#if defined(EAI_BADHINTS)
case EAI_BADHINTS: return UV_EAI_BADHINTS;
#endif
#if defined(EAI_CANCELED)
case EAI_CANCELED: return UV_EAI_CANCELED;
#endif
#if defined(EAI_FAIL)
case EAI_FAIL: return UV_EAI_FAIL;
#endif
#if defined(EAI_FAMILY)
case EAI_FAMILY: return UV_EAI_FAMILY;
#endif
#if defined(EAI_MEMORY)
case EAI_MEMORY: return UV_EAI_MEMORY;
#endif
#if defined(EAI_NODATA)
case EAI_NODATA: return UV_EAI_NODATA;
#endif
#if defined(EAI_NONAME)
# if !defined(EAI_NODATA) || EAI_NODATA != EAI_NONAME
case EAI_NONAME: return UV_EAI_NONAME;
# endif
#endif
#if defined(EAI_OVERFLOW)
case EAI_OVERFLOW: return UV_EAI_OVERFLOW;
#endif
#if defined(EAI_PROTOCOL)
case EAI_PROTOCOL: return UV_EAI_PROTOCOL;
#endif
#if defined(EAI_SERVICE)
case EAI_SERVICE: return UV_EAI_SERVICE;
#endif
#if defined(EAI_SOCKTYPE)
case EAI_SOCKTYPE: return UV_EAI_SOCKTYPE;
#endif
#if defined(EAI_SYSTEM)
case EAI_SYSTEM: return -errno;
#endif
}
assert(!"unknown EAI_* error code");
abort();
return 0; /* Pacify compiler. */
} |
86787e77917ef6d0a201a6e76dbe826c4f9659cf | e2c364f6c0f38554ec8cf07035744dfc6ddd5484 | /graphics-fundamentals/ray-tracing/src/surfaces/world.hpp | 253cb64fa71fed13a20b1ae848c577aac97e26a1 | [] | no_license | gfxpg/gpu-studies | 0b39de7f2d77f3deb23a1190b9c8aa2a6c86ae9a | 26512842620ae2240b125a290ef02a07ab4c484b | refs/heads/master | 2022-03-30T15:08:06.800353 | 2019-12-30T04:50:10 | 2019-12-30T04:50:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 773 | hpp | world.hpp | #pragma once
#include <memory>
#include <numeric>
#include <vector>
#include "surface.hpp"
class World : public Surface {
public:
World() {}
World(std::vector<std::unique_ptr<Surface>> surfaces)
: surfaces(std::move(surfaces)) {}
virtual SurfaceHitResult hit(const Ray& r, float t_min, float t_max) const {
return std::accumulate(
surfaces.cbegin(), surfaces.cend(), SurfaceHitResult(),
[r, t_min, t_max](SurfaceHitResult closest_hit,
const std::unique_ptr<Surface>& s) {
float t_limit = closest_hit ? closest_hit->first.t : t_max;
auto hit = s->hit(r, t_min, t_limit);
return hit ? hit : closest_hit;
});
}
private:
std::vector<std::unique_ptr<Surface>> surfaces;
};
|
d1c7b3cbe0395fb9b5bc9322880752df50784c9e | 63dec0bbc41c6153e3de7e62091810d32f6b6191 | /060_The_Game_of_Life/060_The_Game_of_Life.cpp | 8231736e9f733b64f920b2755e2fccae675869cb | [] | no_license | naddu77/ModernCppChallenge | e02d4d6dac040338e39aed1133259ff104adf7f6 | 002d47e25424410cdb483813d4ef51a13a96e5d8 | refs/heads/master | 2021-06-09T09:13:23.735985 | 2021-04-18T06:57:59 | 2021-04-18T06:57:59 | 153,773,593 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,458 | cpp | 060_The_Game_of_Life.cpp | // 060_The_Game_of_Life.cpp : 이 파일에는 'main' 함수가 포함됩니다. 거기서 프로그램 실행이 시작되고 종료됩니다.
// Note
// - Range-v3 이용
// - 좀 더 간결?
#include "pch.h"
#include <range/v3/all.hpp>
#include <iostream>
#include <vector>
#include <random>
#include <array>
#include <chrono>
#include <thread>
#include <iterator>
namespace std
{
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> const& v)
{
std::copy(std::cbegin(v), std::cend(v), std::ostream_iterator<T>(os));
return os;
}
}
class Universe
{
public:
enum class Seed
{
RANDOM,
TEN_CELL_ROW
};
Universe(size_t const width, size_t const height) :
rows(height), columns(width), grid(rows, std::vector<char>(columns)), dist(0, 4)
{
std::random_device rd;
auto seed_data = std::array<int, std::mt19937::state_size> {};
std::generate(std::begin(seed_data), std::end(seed_data), std::ref(rd));
std::seed_seq seq(std::begin(seed_data), std::end(seed_data));
mt.seed(seq);
}
void Run(Seed const s, int const generations,
std::chrono::milliseconds const ms =
std::chrono::milliseconds(100))
{
Reset();
Initialize(s);
Display();
auto i = 0;
do
{
NextGeneration();
Display();
std::this_thread::sleep_for(ms);
} while (i++ < generations || generations == 0);
}
private:
size_t rows;
size_t columns;
using Grid = std::vector<std::vector<char>>;
Grid grid;
const char alive = '*';
const char dead = ' ';
std::uniform_int_distribution<> dist;
std::mt19937 mt;
Universe() = delete;
void NextGeneration()
{
auto input = ranges::view::iota(0, rows) >>= [this](auto const r) { return
ranges::view::iota(0, columns) >>= [=](auto const c) { return
ranges::yield(std::pair{ r, c });
}; };
Grid newgrid(rows, std::vector<char>(columns));
for (auto const&[r, c] : input)
{
auto count = CountNeighbors(r, c);
newgrid[r][c] = (grid[r][c] == alive ?
((count == 2 || count == 3) ? alive : dead) :
((count == 3) ? alive : dead));
}
grid.swap(newgrid);
}
void ResetDisplay()
{
system("cls");
}
void Display()
{
ResetDisplay();
std::copy(std::cbegin(grid), std::cend(grid), std::ostream_iterator<std::vector<char>>(std::cout, "\n"));
}
void Initialize(Seed const s)
{
if (s == Seed::TEN_CELL_ROW)
{
for (size_t c = columns / 2 - 5; c < columns / 2 + 5; c++)
grid[rows / 2][c] = alive;
}
else
{
ranges::transform(grid, std::begin(grid), [this](auto&& rng) {
ranges::transform(rng, std::begin(rng), [this](auto&&) {
return dist(mt) == 0 ? alive : dead;
});
return std::move(rng);
});
}
}
void Reset()
{
std::fill(std::begin(grid), std::end(grid), std::vector<char>(columns, dead));
}
std::size_t CountNeighbors(size_t const row, size_t const col)
{
auto directions = ranges::view::iota(-1, 2) >>= [](int const r) { return
ranges::view::iota(-1, 2) >>= [=](int const c) { return
ranges::yield_if(r != 0 || c != 0, std::pair{ r, c });
}; };
return ranges::count(directions
| ranges::view::filter([row, col, this](auto const& p) { return row + p.first < rows && col + p.second < columns; })
| ranges::view::transform([row, col, this](auto const& p) { return grid[row + p.first][col + p.second]; }),
alive);
}
};
int main()
{
using namespace std::chrono_literals;
Universe(50, 20).Run(Universe::Seed::RANDOM, 100, 100ms);
return 0;
} |
dfcf0ccd3c3fe78eeb8acc955436b44974641a04 | 4f1ed533ad46a7706a2bb43d60c4df97eecbf0a7 | /src/server.h | 902a003ade7757760e7e719c4f68684ef5da3b70 | [] | no_license | joebain/Simple-Sampler | 913a26a431833a66e90aebc1d6094201e2061205 | b9e941c750bad53f7fa052a3b0c467e220d81700 | refs/heads/master | 2021-01-25T08:54:39.473437 | 2010-08-08T18:54:35 | 2010-08-08T18:54:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,182 | h | server.h | #ifndef _SERVER_H_
#define _SERVER_H_
#include <list>
#include <map>
#include "jack.h"
#include "sound_maker.h"
#include "sample.h"
#include "synth.h"
#include "loader.h"
#include "pad_event.h"
#include "effect.h"
#include "bit_effect.h"
class Server {
private:
bool running;
void update();
Jack* jack;
float* outbound_frames;
int samples_to_pads_lock;
std::list<SoundMaker*> sound_makers;
std::list<Synth> synths;
std::list<Sample> samples;
std::list<Effect*> effects;
std::list<BitEffect> bit_effects;
BitEffect* bit_effect;
Sample* last_played_or_playing;
std::list<Pad> pads;
std::map<int, Pad*> events_to_pads;
std::map<int, std::list<Pad*> > samples_to_pads;
bool remove_sound_maker(SoundMaker* sound_maker);
bool add_sound_maker(SoundMaker* sound_maker);
bool remove_effect(Effect* effect);
bool add_effect(Effect* effect);
public:
Server();
~Server();
bool start();
bool stop();
void midi_on(int event_number, int velocity);
void midi_off(int event_number);
void pitch_bend(int on, int value);
void controller_change(int controller_number, int value);
Jack* get_jack() {return jack;}
void get_frames(float frames[], int length);
void take_frames(float frames[], int length);
bool add_sample(Sample sample);
bool add_samples(std::list<Sample> sample);
std::list<Sample> & get_samples() { return samples; }
bool remove_sample(Sample sample);
int get_new_sample_id();
void link_samples_to_pads();
std::list<Pad*> get_pads_for_sample(Sample* sample);
bool add_bit_effect(BitEffect effect);
bool add_bit_effects(std::list<BitEffect> effect);
std::list<BitEffect> & get_bit_effects() { return bit_effects; }
BitEffect* get_bit_effect() {return bit_effect;}
bool remove_bit_effect(BitEffect effect);
std::list<Effect*> get_effects() { return effects; }
SoundMaker* get_sound_maker(int id);
bool add_synth(Synth synth);
bool remove_synth(Synth synth);
void set_pads(std::list<Pad> pads);
void add_pad(Pad pad);
std::list<Pad> & get_pads() { return pads; }
};
#endif
|
f94d794f5cfbe16b57de8097ce19b76c90a1afaa | 39bac101a463852304207694072ed5db205b8794 | /week8/week08_ex00_move.cpp | da5a62689e480bba34d7165d88cd9b828dfae96a | [] | no_license | hyunbingil/OpenCV_lecture | bfbd482a0bad331984b2259227f36576f5dbe54b | d84e4783fcc3102df897d3b5147d782334571484 | refs/heads/master | 2022-07-27T05:27:05.796672 | 2020-05-19T10:58:20 | 2020-05-19T10:58:20 | 259,516,359 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 689 | cpp | week08_ex00_move.cpp | #include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main_1() {
int x, y, w, h;
w = 400;
h = 300;
Mat image1(h, w, CV_8U, Scalar(255));
string szTitle = "창 제어";
namedWindow(szTitle, WINDOW_NORMAL);
// WINDOW_NORMAL 옵션은 크기 재조정 가능. => 그래서 밑에서 resize할 경우 이미지가 window 창에 맞춰서 커진다.
// 하지만, WINDOW_AUTOSIZE 옵션을 사용할 경우, 이미지는 그대로, window창만 커진다.
imshow(szTitle, image1);
x = 100;
y = 100;
for (int i = 0; i < 10; i++) {
moveWindow(szTitle, x, y);
resizeWindow(szTitle, w, h);
waitKey();
x = x + 20;
w = w + 20;
}
waitKey();
return 0;
} |
c2f2cc93a09327444e030188cedbe5144b973a63 | 6c6082bfbd8a2f9f2645149545d0f1aba8ea939a | /Projects/Honey/Honey/Core/IBindable.h | 6924928249ed28618f468e61f7f96da925c49a0a | [
"MIT"
] | permissive | dSyncro/Honey | e33fa5b03b1a443cbfdea104056369d0ae0ed85c | 571862e56d2a977d319779be751e5c0ef79de5a1 | refs/heads/master | 2023-01-01T00:53:57.717544 | 2020-10-25T18:11:02 | 2020-10-25T18:11:02 | 254,705,369 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 481 | h | IBindable.h | /**
* @file IBindable.h
*/
#pragma once
namespace Honey {
/**
* @brief Interface for Bindable objects.
*/
class IBindable {
public:
virtual ~IBindable() = default;
/**
* @brief Bind object.
*/
virtual void bind() const = 0;
/**
* @brief Unbind object.
*/
virtual void unbind() const = 0;
/**
* @brief Check if object is bound.
* @return A boolean expressing if the object is bound or not.
*/
virtual bool isBound() const = 0;
};
}
|
8f9f5ca56d56bdff41263599d8dd2da962754b2d | 9015268b0fe377d80abe0f84f41f235218774a2b | /XBee/XBee.ino | b565704161cb2c6c6d1a13c60ec235ce7ae94f45 | [] | no_license | houcy/WallE_Xbee_Arduino | 6827270d122e78268211064bad716c3112ab0397 | 4a78faf02eaa5f34bbddff37eee88e4c7b87daad | refs/heads/master | 2020-04-07T10:34:35.826855 | 2017-01-20T13:19:52 | 2017-01-20T13:19:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 361 | ino | XBee.ino | #include <SoftwareSerial.h>
SoftwareSerial Xbee(11,12);
void setup() {
Xbee.begin(9600); // opens serial port, sets data rate to 9600 bps
Xbee.print("Hello!!!");
}
void loop() {
if (Xbee.available()) { // is there any information available on serial port ?
Xbee.print("I received something!");
Xbee.println(char(Xbee.read()));
}
}
|
129c30768ec216043a0dc77367b4152daa99b1b4 | 5930303ea7c3ecc76657b8a118c7539d1d0a5403 | /MyLevelDB/status.h | ca906b86db473322c417b12b7ddcb059ca899e5b | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | Ja3on/LevelDB-1 | 2862f16e4209d138f76b89050e5c2f1390e4cfb2 | ab78f2c19468666f1db171dec8a87c792e909d09 | refs/heads/master | 2020-12-24T09:07:46.980557 | 2016-07-11T00:58:05 | 2016-07-11T00:58:05 | 62,025,105 | 0 | 0 | null | 2016-06-27T04:18:41 | 2016-06-27T04:18:41 | null | UTF-8 | C++ | false | false | 1,832 | h | status.h | #pragma once
#ifndef _MYLEVELDB_STATUS_H
#define _MYLEVELDB_STATUS_H
#include <string>
#include "../MyLevelDB/Slice.h"
namespace MyLevelDB
{
class Status
{
public:
Status():_state(NULL){}
~Status() { delete[] _state; }
Status(const Status&);
void operator=(const Status&);
static Status OK() { return Status(); }
static Status NotFound(const Slice& msg,const Slice& msg2=Slice())
{
return Status(kNotFound, msg, msg2);
}
static Status Corruption(const Slice& msg, const Slice& msg2 = Slice())
{
return Status(kCorruption, msg, msg2);
}
static Status NotSupported(const Slice& msg, const Slice& msg2)
{
return Status(kNotSupported, msg, msg2);
}
static Status InvalidArgument(const Slice& msg, const Slice& msg2)
{
return Status(kInvalidArgument, msg, msg2);
}
static Status IoError(const Slice& msg, const Slice& msg2)
{
return Status(kIoError, msg, msg2);
}
bool ok() const { return (_state == NULL); }
bool IsNotFound() const { return code() == kNotFound; }
std::string ToString() const;
private:
//_state[0...3] == length of message
//_state[4] == Code
//_state[5...]==message
const char* _state;
enum Code
{
kOk = 0,
kNotFound = 1,
kCorruption = 2,
kNotSupported = 3,
kInvalidArgument = 4,
kIoError = 5
};
Code code() const
{
return (_state == NULL) ? kOk : static_cast<Code>(_state[4]);
}
Status(Code code, const Slice& msg, const Slice& msg2);
static const char* CopyState(const char*);
};
inline Status::Status(const Status& s)
{
_state = (s._state == NULL) ? NULL : CopyState(s._state);
}
inline void Status::operator=(const Status& rhs)
{
if (_state != rhs._state)
{
delete[] _state;
_state = (rhs._state == NULL) ? NULL : CopyState(rhs._state);
}
}
}
#endif // !_MYLEVELDB_STATUS_H |
3efb1b757a656bc92205c6626907df16d7596569 | 29b1e4d18e6e4e45c838492b465630bd734acf61 | /List/list_selectinsort.h | 1cd1613688b604fd68fef64d0683df23fbf4236f | [] | no_license | RanchoCooper/DateStructure | e150c4c190ff8a38f1494f8fe9990f41e2299f52 | f798703bc353af8fecc4b3deeefe41833a4d3197 | refs/heads/master | 2016-09-13T08:36:05.389321 | 2016-05-23T14:25:44 | 2016-05-23T14:25:44 | 55,966,450 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 853 | h | list_selectinsort.h | /*
* @author: Rancho (rancho941110@gmail. com)
* @date : 2016-05-09 14:52:17
*
* Brief: 列表的选择排序算法:对起始于位置p的n个元素排序
*/
#pragma once
template <typename T>
void List<T>::selectionSort(ListNodePosi(T) p, int n) {
ListNodePosi(T) head = p->pred;
ListNodePosi(T) tail = p;
for (int i = 0; i < n; ++i)
tail = tail->succ;
while (1 < n) {
ListNodePosi(T) max = selectMax(head->succ, n);
insertBefort(tail, remove(max));
tail = tail->pred;
n--;
}
}
template <typename T> //从起始于位置p的n个元素中选出最大者
ListNodePosi(T) List<T>::selectMax(ListNodePosi(T) p, int n) {
ListNodePosi(T) max = p;
for (ListNodePosi(T) cur = p; 1 < n; --n)
if ((cur = cur->succ)->data > max->data)
max = cur;
return max;
}
|
3f2c8b2364917b994e21ea6e10311ffc8c56b1bc | 7dea08ae1ee8217793fb01b2964b60937ab28587 | /BestTimeToBuyAndSellStock.cpp | 3a8048c9aee8752230d9250523416e4f5816c395 | [] | no_license | chunyang-wen/leetcode | 4ade9e7bb49851f73b369eb118d6cd803923d990 | 109e9b957c06989c163b110c32b0f392d182517c | refs/heads/master | 2021-03-13T00:06:50.952274 | 2016-11-02T04:14:32 | 2016-11-02T04:14:32 | 25,857,398 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 733 | cpp | BestTimeToBuyAndSellStock.cpp | class Solution {
public:
int maxProfit(vector<int> &prices) {
if (prices.empty())
return 0;
int profit = 0;
// pre-processing
int len = prices.size() - 1;
int i = 0;
while (i < len) {
prices[i] = prices[i+1] - prices[i];
++i;
}
int maxSubSum = 0;
i = 0;
while (i < len) {
profit += prices[i];
if (profit > maxSubSum)
maxSubSum = profit;
if (profit < 0)
profit = 0;
++i;
}
return maxSubSum;
}
}; |
ed3a29468a4b2ba98ad21fc4401be4891fcb9b12 | 7d5ca669279b53580383315225fc242bbeb3049b | /Classes/BagSprite.cpp | 568ea904105249eda3ea725aa00936d5cfa53e21 | [] | no_license | Everstar/FinalWar-Code-Refactoring | 25219e304a7d95933137e4a5bee2ce0f36eda150 | 8cfacd88efd41375c9721c641546b3a22c66c5cc | refs/heads/master | 2021-06-11T23:29:26.864040 | 2016-12-07T14:33:33 | 2016-12-07T14:33:33 | 72,450,964 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 415 | cpp | BagSprite.cpp | #include "BagSprite.h"
BagSprite* BagSprite::Instance = new BagSprite();
BagSprite::BagSprite()
{
}
bool BagSprite::init()
{
this->BindSprite(Sprite::createWithSpriteFrameName(PATH_MONSTER_BAGSPRITE));
this->setScale(0.18f);
this->atk = 20;
this->hp = 100;
this->type = MonsterType::BAGSPRITE;
return true;
}
Monster* BagSprite::clone()
{
BagSprite* self = new BagSprite();
self->init();
return self;
} |
50c154f19cde73b7412a3012cd4226b8395486c6 | 0f08276e557de8437759659970efc829a9cbc669 | /tests/p919.cpp | d56b9b72e9bef5f2e85ab349689edccb3fe95d16 | [] | no_license | petru-d/leetcode-solutions-reboot | 4fb35a58435f18934b9fe7931e01dabcc9d05186 | 680dc63d24df4c0cc58fcad429135e90f7dfe8bd | refs/heads/master | 2023-06-14T21:58:53.553870 | 2021-07-11T20:41:57 | 2021-07-11T20:41:57 | 250,795,996 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 107 | cpp | p919.cpp | #include "pch.h"
#include "../problems/p919.h"
TEST(p919, t0)
{
[[maybe_unused]] p919::Solution s;
}
|
d985325cf49299d73c0b016449b3a8cd096cf0fb | cfeac52f970e8901871bd02d9acb7de66b9fb6b4 | /generated/src/aws-cpp-sdk-medical-imaging/source/model/ImageSetsMetadataSummary.cpp | 4850d32b2deb0898eaf26d271cc2e94164377808 | [
"Apache-2.0",
"MIT",
"JSON"
] | permissive | aws/aws-sdk-cpp | aff116ddf9ca2b41e45c47dba1c2b7754935c585 | 9a7606a6c98e13c759032c2e920c7c64a6a35264 | refs/heads/main | 2023-08-25T11:16:55.982089 | 2023-08-24T18:14:53 | 2023-08-24T18:14:53 | 35,440,404 | 1,681 | 1,133 | Apache-2.0 | 2023-09-12T15:59:33 | 2015-05-11T17:57:32 | null | UTF-8 | C++ | false | false | 2,357 | cpp | ImageSetsMetadataSummary.cpp | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/medical-imaging/model/ImageSetsMetadataSummary.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace MedicalImaging
{
namespace Model
{
ImageSetsMetadataSummary::ImageSetsMetadataSummary() :
m_imageSetIdHasBeenSet(false),
m_version(0),
m_versionHasBeenSet(false),
m_createdAtHasBeenSet(false),
m_updatedAtHasBeenSet(false),
m_dICOMTagsHasBeenSet(false)
{
}
ImageSetsMetadataSummary::ImageSetsMetadataSummary(JsonView jsonValue) :
m_imageSetIdHasBeenSet(false),
m_version(0),
m_versionHasBeenSet(false),
m_createdAtHasBeenSet(false),
m_updatedAtHasBeenSet(false),
m_dICOMTagsHasBeenSet(false)
{
*this = jsonValue;
}
ImageSetsMetadataSummary& ImageSetsMetadataSummary::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("imageSetId"))
{
m_imageSetId = jsonValue.GetString("imageSetId");
m_imageSetIdHasBeenSet = true;
}
if(jsonValue.ValueExists("version"))
{
m_version = jsonValue.GetInteger("version");
m_versionHasBeenSet = true;
}
if(jsonValue.ValueExists("createdAt"))
{
m_createdAt = jsonValue.GetDouble("createdAt");
m_createdAtHasBeenSet = true;
}
if(jsonValue.ValueExists("updatedAt"))
{
m_updatedAt = jsonValue.GetDouble("updatedAt");
m_updatedAtHasBeenSet = true;
}
if(jsonValue.ValueExists("DICOMTags"))
{
m_dICOMTags = jsonValue.GetObject("DICOMTags");
m_dICOMTagsHasBeenSet = true;
}
return *this;
}
JsonValue ImageSetsMetadataSummary::Jsonize() const
{
JsonValue payload;
if(m_imageSetIdHasBeenSet)
{
payload.WithString("imageSetId", m_imageSetId);
}
if(m_versionHasBeenSet)
{
payload.WithInteger("version", m_version);
}
if(m_createdAtHasBeenSet)
{
payload.WithDouble("createdAt", m_createdAt.SecondsWithMSPrecision());
}
if(m_updatedAtHasBeenSet)
{
payload.WithDouble("updatedAt", m_updatedAt.SecondsWithMSPrecision());
}
if(m_dICOMTagsHasBeenSet)
{
payload.WithObject("DICOMTags", m_dICOMTags.Jsonize());
}
return payload;
}
} // namespace Model
} // namespace MedicalImaging
} // namespace Aws
|
35b825fcd8ab66035d1b89e9226a8ad9b8983d4d | dcb416cb97848d3eebc2349c69b92e2038b21bb5 | /includes/Smalltalk.h | 65c513187bc895aff22b2d2040f4303e6458e881 | [] | no_license | CNUClasses/327_Proj5_Lib | 6fd9ef8bd3d26e498cff5d0995e74c5906c1e809 | 1b06490af137bf85c5f15c8f122ce6eb6cae6805 | refs/heads/master | 2021-04-12T05:23:47.644192 | 2018-11-13T00:42:40 | 2018-11-13T00:42:40 | 125,701,065 | 0 | 8 | null | null | null | null | UTF-8 | C++ | false | false | 2,083 | h | Smalltalk.h | #pragma once
#include <string>
#include <vector>
#include "Watch.h"
class Smalltalk
{
public:
//derived class will set Nationality, iPerson. iPerson is just a counter used to distinguish between objects of the same type
Smalltalk(std::string myNationality,int iPerson=1);
//if pWatch !=0 then be sure to delete what it points to
virtual ~Smalltalk(void);
//cycles through phrases added in populatePhrases. Returns them 1 by 1 starting with the first and ending
//with the last and then it starts over
//takes the form Nationality iPerson: phrase
//for instance the following string comes from an American instance, the 10th iPerson and it is printing AMERICAN_PHRASE_2
//AMERICAN 10:Why yes, I would like to supersize that
std::string saySomething();
//returns the time (if pWatch != 0) in the form of THE_CURRENT_TIME_IS: and then the time
//or I_DO_NOT_HAVE_A_WATCH string (if pWatch == 0)
std::string getTime();
//if this object has a watch it is taken away, otherwise a NULL pointer is returned
//this means return the pointer to the watch so another smalltalker
//can use the watch. Set this->pWatch =NULL. This transaction simulates giving up a watch
//this is one of the few times when a shallow copy is appropriate
Watch* takeWatch();
//if already have a watch then return false and dont change pWatch pointer
//otherwise accept watch (return true) and set this->pWatch=pWatch
//this is one of the few times when a shallow copy is appropriate
bool giveWatch(Watch *pWatch);
//Abstract Base Class (ABC), implement in derived classes
virtual void populatePhrases()=0;
protected:
const std::string nationality; //populated by derived classes using initilizer list from constants.h
std::vector<std::string> mySmallTalk; //populated by populatePhrases in derived classes
int iPerson; //what number this person is (just a way to track objects)
int current_phrase; //which phrase was last returned (use % operator to cycle through phrases)
Watch *pWatch; //if 0 don't have a watch, otherwise does have a watch
};
|
05c80959efdbd3106f9015ddca58bc76adb961b7 | b2ada748d391209322edfa2096bf9fcf946c7f0b | /1DAM/programacion en c++/ejercicios y practicas/UD5/ordenacion_selecion.cpp | 0c90b75edb8a1471dbf7a2645341ca544e50574f | [] | no_license | antonioguerrerocarrillo/1DESARROLLO-DE-APLICACIONES-MULTIPLATAFORMA | c790e9fcd1664485178c2c43d250180e8b667ce6 | 2906b345775bacc2d29a4ee9670597c781d5c7e4 | refs/heads/main | 2023-03-01T22:46:28.126945 | 2021-02-05T00:15:15 | 2021-02-05T00:15:15 | 336,117,504 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,445 | cpp | ordenacion_selecion.cpp | #include <iostream>
#include <cmath>
using namespace std;
void selecion (int vector[], int util_vector){
int pos_min = 0;
int aux = 0;
//util <= para que pare en una antes de lo que suele parar
for (int i = 0; i <= util_vector; i++) {
//guardo la i en posicion_min
pos_min = i;
//j = i+1 ya que sera la siguiente posicion... cada vez que lo ejecute, parara en la util estricto
for (int j = i+1; j < util_vector; j++) {
//si lo que hay en la posicion de [j] que es la siguiente es menor que la anterior entra
// asi vamos a ordenar si lo pusiera > lo ordenaria de mayor a menor, asi lo ordenara de menor a mayor
if (vector[j] < vector[pos_min]){
//guardo en la poscion j ya que es menor
pos_min = j;
}
}
// guardo la posicion de i en aux
aux = vector[i];
//guardo la pos_min en el vector
vector[i] = vector[pos_min];
// y por ultimo lo que contiene el aux lo guardo en la pos_min y ya estaria ordenado el vector
vector[pos_min] = aux;
}
}
void imprimir(int util, int v[]){
cout << " lo que hay dentro de las celdas del vector es ";
for (int i = 0; i < util; i++){
cout << v[i] << ", ";
}
cout << " " << endl;
}
int main (){
const int dim = 50;
int vector[dim] = {2,4,5,7,11,33,1,44,56};
int util = 9;
cout << " imprimiendo vector desordenado " << endl;
imprimir(util, vector);
selecion(vector, util);
cout << " imprimiendo vector ya ordenado " << endl;
imprimir(util, vector);
} |
1074df704f9e8ef0ce52459fa7b06a4f5b0811b6 | e48bbf5115838fbb7c2474cd3864e686f6191b91 | /FIBOSUM.cpp | cefa05825e25ba3eb192be40b678b6e5fc05ae30 | [] | no_license | Vtech181/SPOJ_SOLUTIONS | a7af11b97ea8a78266891255fae931d35a78e96a | 3f0e52a2b7985395124a0aa6a5dfa37406bdc6b8 | refs/heads/master | 2020-06-13T17:56:03.946114 | 2018-06-28T17:06:51 | 2018-06-28T17:06:51 | 75,571,657 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,001 | cpp | FIBOSUM.cpp | #include <iostream>
#include <cstring>
using namespace std;
long long fibonacci(long long n)
{
long long fib[2][2]= {{1,1},{1,0}},ret[2][2]= {{1,0},{0,1}},tmp[2][2]= {{0,0},{0,0}};
int i,j,k;
while(n)
{
if(n&1)
{
memset(tmp,0,sizeof tmp);
for(i=0; i<2; i++) for(j=0; j<2; j++) for(k=0; k<2; k++)
tmp[i][j]=(tmp[i][j]+ret[i][k]*fib[k][j])%1000000007;
for(i=0; i<2; i++) for(j=0; j<2; j++) ret[i][j]=tmp[i][j];
}
memset(tmp,0,sizeof tmp);
for(i=0; i<2; i++) for(j=0; j<2; j++) for(k=0; k<2; k++)
tmp[i][j]=(tmp[i][j]+fib[i][k]*fib[k][j])%1000000007;
for(i=0; i<2; i++) for(j=0; j<2; j++) fib[i][j]=tmp[i][j];
n/=2;
}
return ((ret[0][1]));
}
int main()
{
long long t;
long long a,b;
cin>>t;
while(t--)
{
cin>>a>>b;
cout<<(fibonacci(b+2)-fibonacci(a+1) + 1000000007 )%1000000007<<endl;
}
return 0;
}
|
97ce6aeaae43adb4cb0b97731569f5fc0b2818a1 | a57065b28eb6ffdda65617d719b06421cb4d9e6e | /2020.12.14/0111/0111/01 operation.cpp | a0df0bb6038b0bf35104a9503b1407a4b84559cc | [] | no_license | Kelia373/LearnCPP | 1862ec721c85f443a5d986c7a6bd2c30919a5b6f | 17b8411b400f48cb886a066498fe4c25cc9e9cdd | refs/heads/main | 2023-02-05T00:59:24.123339 | 2020-12-30T06:28:47 | 2020-12-30T06:28:47 | 325,472,828 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 191 | cpp | 01 operation.cpp | #include<iostream>
using namespace std;
int main_1()
{
int a1 = 10;
int b1 = 3;
cout <<"a1+b1 = "<< a1 + b1 << endl;
cout <<"a1 - 1 = "<< a1 - b1 << endl;
system("pause");
return 0;
} |
20d4b4730173597f27dd032df623e6c90ff09ab4 | ffcbe8d0222448caefd9e797e3451f1f354176e7 | /the main validate.cpp | 3e2f283e99a39d6e0554a9948f4c570a29a928b6 | [] | no_license | Rukiyat/Chessgroup | f426ee9a7b79456235e9b2add5c4b4d06ea484b1 | d83e2aebed07eb687bb8190321b5ae63d63d7a20 | refs/heads/master | 2021-01-17T12:07:43.121395 | 2017-03-27T00:09:44 | 2017-03-27T00:09:44 | 84,058,118 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 20,203 | cpp | the main validate.cpp | #include "validatemoves.h"
#include <QDebug>
validatemoves::validatemoves()
{
}
//switch base case to validate which ever piece that has been clicked on.
int validatemoves::chooser(walls *temp)
{
switch(temp->pieceName)
{
case 'S': flag=validateSoldier(temp); // S = Soldier
break;
case 'B': flag=validateBomb(temp); // B = Bomb
break;
case 'H': flag=validateHorse(temp); // H = Horse
break;
case 'Z': flag=validateWizard(temp); // Z = Wizard
break;
case 'W': flag=validateWitch(temp); // W = Witch
break;
case 'P': flag=validatePriest(temp); // P = Priest
break;
}
orange();
return flag;
}
//SOLDIER
int validatemoves::validateSoldier(walls *temp)
{
int row,col;
row=temp->row;
col=temp->col;
retVal=0;
if(temp->pieceColor)
{
//White soldier first move two possible squares.
if(row-1>=0 && !tile[row-1][col]->piece)
{
expw[max++]=tile[row-1][col]->tileNum;
retVal=1;
}
//white soldier move after first move, one square at a time.
if(row==6 && !tile[5][col]->piece && !tile[4][col]->piece)
{
expw[max++]=tile[row-2][col]->tileNum;
retVal=1;
}
//white soldier capturing a black soldier
if(row-1>=0 && col-1>=0)
{
if(tile[row-1][col-1]->pieceColor!=temp->pieceColor && tile[row-1][col-1]->piece)
{
expw[max++]=tile[row-1][col-1]->tileNum;
retVal=1;
}
}
//white soldier capturing other pieces besides black soldier.
if(row-1>=0 && col+1<=7)
{
if(tile[row-1][col+1]->pieceColor!=temp->pieceColor && tile[row-1][col+1]->piece)
{
expw[max++]=tile[row-1][col+1]->tileNum;
retVal=1;
}
}
}
else
{
//black soldier first move can move two squares ahead
if(row+1<=7 && !tile[row+1][col]->piece)
{
expw[max++]=tile[row+1][col]->tileNum;
retVal=1;
}
//black soldier move after first move can move one square ahead each time
if(row==1 && !tile[2][col]->piece && !tile[3][col]->piece)
{
expw[max++]=tile[row+2][col]->tileNum;
retVal=1;
}
//if black soldier captures white soldier.
if(row+1<=7 && col-1>=0)
{
if(tile[row+1][col-1]->pieceColor!=temp->pieceColor && tile[row+1][col-1]->piece)
{
expw[max++]=tile[row+1][col-1]->tileNum;
retVal=1;
}
}
//if black soldier captures any piece besides white soldier.
if(row+1<=7 && col+1<=7)
{
if(tile[row+1][col+1]->pieceColor!=temp->pieceColor && tile[row+1][col+1]->piece)
{
expw[max++]=tile[row+1][col+1]->tileNum;
retVal=1;
}
}
}
return retVal;
}
//Bomb
int validatemoves::validateBomb(walls *temp)
{
int r,c;
retVal=0;
//White bomb
r=temp->row;
c=temp->col;
//when bomb is moving upwards
while(r-->0)
{
//Bomb moves any number of squares upwards as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the bomb piece is moving upwards and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Bomb captures opponent piece above it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
//when bomb is moving downwards
while(r++<7)
{
//Bomb moves any number of squares downwards as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the bomb piece is moving downwards and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Bomb captures opponent piece below it
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when bomb is moving to the right
while(c++<7)
{
//Bomb moves any number of squares to the right as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the bomb piece is moving to the right and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Bomb captures opponent piece to the right of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when bomb is moving to the left
while(c-->0)
{
//Bomb moves any number of squares to the left as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the bomb piece is moving to the left and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Bomb captures opponent piece to the left of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
return retVal;
}
//HORSE
int validatemoves::validateHorse(walls *temp)
{
int r,c;
retVal=0;
r=temp->row;
c=temp->col;
//horse moving upwards two squares to the left
if(r-2>=0 && c-1>=0)
{
if(tile[r-2][c-1]->pieceColor!=temp->pieceColor || !tile[r-2][c-1]->piece)
{
expw[max++]=tile[r-2][c-1]->tileNum;
retVal=1;
}
}
//horse moving upwards two squares to the right;
if(r-2>=0 && c+1<=7)
{
if(tile[r-2][c+1]->pieceColor!=temp->pieceColor || !tile[r-2][c+1]->piece)
{
expw[max++]=tile[r-2][c+1]->tileNum;
retVal=1;
}
}
//horse moving one square to the left
if(r-1>=0 && c-2>=0)
{
if(tile[r-1][c-2]->pieceColor!=temp->pieceColor || !tile[r-1][c-2]->piece)
{
expw[max++]=tile[r-1][c-2]->tileNum;
retVal=1;
}
}
//horse upwards one square to the right
if(r-1>=0 && c+2<=7)
{
if(tile[r-1][c+2]->pieceColor!=temp->pieceColor || !tile[r-1][c+2]->piece)
{
expw[max++]=tile[r-1][c+2]->tileNum;
retVal=1;
}
}
//horse moving downwards one square to the right
if(r+2<=7 && c+1<=7)
{
if(tile[r+2][c+1]->pieceColor!=temp->pieceColor || !tile[r+2][c+1]->piece)
{
expw[max++]=tile[r+2][c+1]->tileNum;
retVal=1;
}
}
//horse moving downwards two squares to the left
if(r+2<=7 && c-1>=0)
{
if(tile[r+2][c-1]->pieceColor!=temp->pieceColor || !tile[r+2][c-1]->piece)
{
expw[max++]=tile[r+2][c-1]->tileNum;
retVal=1;
}
}
//horse moving downwards to the left one square.
if(r+1<=7 && c-2>=0)
{
if(tile[r+1][c-2]->pieceColor!=temp->pieceColor || !tile[r+1][c-2]->piece)
{
expw[max++]=tile[r+1][c-2]->tileNum;
retVal=1;
}
}
//horse capturing a piece and one square from an enemy opponent.
if(r+1<=7 && c+2<=7)
{
if(tile[r+1][c+2]->pieceColor!=temp->pieceColor || !tile[r+1][c+2]->piece)
{
expw[max++]=tile[r+1][c+2]->tileNum;
retVal=1;
}
}
return retVal;
}
//Wizard
int validatemoves::validateWizard(walls *temp)
{
int r,c;
retVal=0;
r=temp->row;
c=temp->col;
// wizard moves upwards by one square
if(r-1>=0)
{
if(!tile[r-1][c]->piece || tile[r-1][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r-1][c]->tileNum;
retVal=1;
}
}
//Wizard moves downwards by one square
if(r+1<=7)
{
if(!tile[r+1][c]->piece || tile[r+1][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r+1][c]->tileNum;
retVal=1;
}
}
//Wizard moves left by one square
if(c-1>=0)
{
if(!tile[r][c-1]->piece || tile[r][c-1]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c-1]->tileNum;
retVal=1;
}
}
//Wizard moves right by one square
if(c+1<=7)
{
if(!tile[r][c+1]->piece || tile[r][c+1]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c+1]->tileNum;
retVal=1;
}
}
//Wizard moves upwards by one square to the left
if(r-1>=0 && c-1>=0)
{
if(!tile[r-1][c-1]->piece || tile[r-1][c-1]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r-1][c-1]->tileNum;
retVal=1;
}
}
//Wizard move upwards by one square to the right
if(r-1>=0 && c+1<=7)
{
if(!tile[r-1][c+1]->piece || tile[r-1][c+1]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r-1][c+1]->tileNum;
retVal=1;
}
}
//Wizard moves downwards by one square to the right
if(r+1<=7 && c-1>=0)
{
if(!tile[r+1][c-1]->piece || tile[r+1][c-1]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r+1][c-1]->tileNum;
retVal=1;
}
}
//Wizard move downwards by one square to the left
if(r+1<=7 && c+1<=7)
{
if(!tile[r+1][c+1]->piece || tile[r+1][c+1]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r+1][c+1]->tileNum;
retVal=1;
}
}
return retVal;
}
//Witch
int validatemoves::validateWitch(walls *temp)
{
int r,c;
retVal=0;
r=temp->row;
c=temp->col;
//when witch is moving upwards
while(r-->0)
{
//Witch moves any number of squares upwards as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving upwards and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece above it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
//when witch is moving downwards
while(r++<7)
{
//Witch moves any number of squares downwards as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving downwards and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece below it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when witch is moving to the right
while(c++<7)
{
//Witch moves any number of squares to the right as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving to the right and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece to the right of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when witch is moving to the left
while(c-->0)
{
//Witch moves any number of squares to the left as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving to the left and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece to the left of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when witch is moving upwards and diagonally to the right
while(r-->0 && c++<7)
{ //Witch moves upwards any number of squares diagonaly to the right as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving upwards to the right and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece diagonally to the right and above it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when witch is moving upwards and diagonally to the left
while(r-->0 && c-->0)
{
//Witch moves upwards any number of squares diagonally to the left as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving upwards to the left and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece diagonally to the left and above of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when witch is moving downwards and diagonally to the right
while(r++<7 && c++<7)
{
//Witch moves downwards any number of squares diagonally to the right as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving downwards to the right and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece diagonally to the right and below of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when witch is moving downwards and diagonally to the left
while(r++<7 && c-->0)
{
//Witch moves downwards any number of squares diagonally to the left as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the witch piece is moving downwards to the left and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Witch captures opponent piece diagonally to the left and below of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
return retVal;
}
//Priest
int validatemoves::validatePriest(walls *temp)
{
int r,c;
retVal=0;
r=temp->row;
c=temp->col;
//when priest is moving upwards and diagonally to the right
while(r-->0 && c++<7)
{
//Priest moves upwards any number of squares diagonaly to the right as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the priest piece is moving upwards to the right and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Priest captures opponent piece diagonally to the right and above it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
//when priest is moving upwards and diagonally to the left
while(r-->0 && c-->0)
{
//Priest moves upwards any number of squares diagonally to the left as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the priest piece is moving upwards to the left and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Priest captures opponent piece diagonally to the left and above of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
//when priest is moving downwards and diagonally to the right
while(r++<7 && c++<7)
{
// Priest moves downwards any number of squares diagonally to the right as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the priest piece is moving downwards to the right and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Priest captures opponent piece diagonally to the right and below of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
r=temp->row;
c=temp->col;
// when priest is moving downwards and diagonally to the left
while(r++<7 && c-->0)
{
//Priest moves downwards any number of squares diagonally to the left as long as there is no piece in it's way
if(!tile[r][c]->piece)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
}
//when the priest piece is moving downwards to the left and detetcts one of its own it stops.
else if(tile[r][c]->pieceColor==temp->pieceColor)
break;
//Priest captures opponent piece diagonally to the left and below of it.
else if(tile[r][c]->pieceColor!=temp->pieceColor)
{
expw[max++]=tile[r][c]->tileNum;
retVal=1;
break;
}
}
return retVal;
}
//intiliasing the retval to be null at the start of the game
int validatemoves::check(walls *temp)
{
int r,c,flag;
retVal=0;
return retVal;
}
//highlights the path of each of piece that is movable.
void validatemoves::orange()
{
int i,n;
for(i=0;i<max;i++)
tile[expw[i]/8][expw[i]%8]->setStyleSheet("QLabel {background-color: orange;}");
}
|
3eb939b1900477a4299bb0806356b8719c804364 | 41781f63a3f8ae236406ba3a797f52344da000bf | /00_src/MessageBox/MessageBox.cpp | 0506877b6aefc1cafb16845b893bcc59f1070936 | [] | no_license | tonnac/Study_0 | 760cd9d5847d1c6a7c9b0fd73efbe7d94e3d6e03 | dfbaaa5697ad30254bf4684246d0e84131ee595c | refs/heads/master | 2020-03-25T04:58:55.017853 | 2019-01-22T06:00:16 | 2019-01-22T06:00:16 | 143,423,294 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 195 | cpp | MessageBox.cpp | #include <windows.h>
int WINAPI wWinMain(HINSTANCE hins, HINSTANCE hprev, LPWSTR szCmdLine, int iCmdShow)
{
MessageBox(nullptr, L"Hello, Windows98!", L"HelloMsg", MB_ICONWARNING);
return 0;
} |
f04f70c9a1aed7be5701cbbac7efa8457cc4f42f | 1e00f34e0bb01f6e525b3d14a6125b7b960decfa | /Calibration_O2_sensor/pressure.h | 5ffef2039e87837443dea94782822c621c2fc373 | [
"MIT"
] | permissive | FastTachyon/CodeLife_uSherbrooke | 5f46fd446ab800bfda2d72cfe79a532a925387e9 | 8cd11cbfa3f610f3fd2848c10709a226d276db02 | refs/heads/master | 2021-04-17T23:29:11.294969 | 2020-04-01T02:17:54 | 2020-04-01T02:17:54 | 249,485,579 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 880 | h | pressure.h | #ifndef PRESSURE_H
#define PRESSURE_H
#include "Wire.h"
#include <Arduino.h>
#include <EEPROM.h>
#define OUTPUT_MIN 1638 // 1638 counts (10% of 2^14 counts or 0x0666)
#define OUTPUT_MAX 14745 // 14745 counts (90% of 2^14 counts or 0x3999)
#define PRESSURE_MIN -34740 // min is 0 for sensors that give absolute values
#define PRESSURE_MAX 34740 // 1.6bar (I want results in bar)
class Pressure_gauge
{
public:
Pressure_gauge(int addr);
virtual ~Pressure_gauge();
void init();
float calibrate();
void send();
int read();
void set_offset_pressure(int offset);
int address;
float pressure;
float temperature;
float offset_pressure;
int get_address();
float get_pressure();
float get_temperature();
};
#endif // PRESSURE_H
|
a3be98b11ab377db453dcc7edda49f217e17ce38 | e759e684c8b799a2363f435e49ea99cd6d356870 | /math/psd.h | 3ad195069f38c5d24ef3beb285239aef57f66b5c | [] | no_license | Jorjor70/meuh | 56e115c107cc82bfc42dbfefef1101e64b34c3b5 | 0e2ee0227281c08f6e1dd8c892c03b162d3802dc | refs/heads/master | 2021-01-18T10:10:26.416036 | 2013-01-30T12:01:30 | 2013-01-30T12:01:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 281 | h | psd.h | #ifndef MATH_PSD_H
#define MATH_PSD_H
#include <math/types.h>
namespace math {
template<class A>
struct psd;
template<>
struct psd< mat > {
const mat& M;
psd(const mat& M);
vec operator()(const vec& v) const;
natural dim() const;
};
}
#endif
|
c14e6153663a512752ae3272a4157321814e677f | d61d05748a59a1a73bbf3c39dd2c1a52d649d6e3 | /chromium/ui/aura/mus/capture_synchronizer.cc | 8afbb3e232fe28817fe12f2c2127871d0f8e5d67 | [
"BSD-3-Clause"
] | permissive | Csineneo/Vivaldi | 4eaad20fc0ff306ca60b400cd5fad930a9082087 | d92465f71fb8e4345e27bd889532339204b26f1e | refs/heads/master | 2022-11-23T17:11:50.714160 | 2019-05-25T11:45:11 | 2019-05-25T11:45:11 | 144,489,531 | 5 | 4 | BSD-3-Clause | 2022-11-04T05:55:33 | 2018-08-12T18:04:37 | null | UTF-8 | C++ | false | false | 4,958 | cc | capture_synchronizer.cc | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/aura/mus/capture_synchronizer.h"
#include "base/auto_reset.h"
#include "services/ws/public/mojom/window_tree.mojom.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/mus/capture_synchronizer_delegate.h"
#include "ui/aura/mus/window_mus.h"
#include "ui/aura/window.h"
namespace aura {
CaptureSynchronizer::CaptureSynchronizer(CaptureSynchronizerDelegate* delegate,
ws::mojom::WindowTree* window_tree)
: delegate_(delegate), window_tree_(window_tree) {}
CaptureSynchronizer::~CaptureSynchronizer() {}
void CaptureSynchronizer::SetCaptureFromServer(WindowMus* window) {
if (window == capture_window_)
return;
DCHECK(!setting_capture_);
// Don't immediately set |capture_window_|. It's possible the change
// will be rejected. |capture_window_| is set in OnCaptureChanged() if
// capture succeeds.
base::AutoReset<bool> capture_reset(&setting_capture_, true);
base::AutoReset<WindowMus*> window_setting_capture_to_reset(
&window_setting_capture_to_, window);
client::CaptureClient* capture_client =
window ? client::GetCaptureClient(window->GetWindow()->GetRootWindow())
: client::GetCaptureClient(
capture_window_->GetWindow()->GetRootWindow());
capture_client->SetCapture(window ? window->GetWindow() : nullptr);
}
void CaptureSynchronizer::AttachToCaptureClient(
client::CaptureClient* capture_client) {
capture_client->AddObserver(this);
}
void CaptureSynchronizer::DetachFromCaptureClient(
client::CaptureClient* capture_client) {
if (capture_window_ &&
client::GetCaptureClient(capture_window_->GetWindow()->GetRootWindow()) ==
capture_client) {
SetCaptureWindow(nullptr);
}
capture_client->RemoveObserver(this);
}
void CaptureSynchronizer::SetCaptureWindow(WindowMus* window) {
if (capture_window_) {
capture_window_->GetWindow()->RemoveObserver(this);
// If |window| is in a different root, then need to tell the old
// CaptureClient that it lost capture. This assumes that if |window| is null
// the change was initiated from the old CaptureClient.
Window* old_capture_window_root =
capture_window_->GetWindow()->GetRootWindow();
if (old_capture_window_root && window &&
window->GetWindow()->GetRootWindow() != old_capture_window_root) {
client::CaptureClient* capture_client =
client::GetCaptureClient(old_capture_window_root);
if (capture_client) {
// Remove this as an observer to avoid trying to react to the change.
capture_client->RemoveObserver(this);
capture_client->ReleaseCapture(capture_window_->GetWindow());
capture_client->AddObserver(this);
}
}
}
capture_window_ = window;
if (capture_window_)
capture_window_->GetWindow()->AddObserver(this);
}
void CaptureSynchronizer::OnWindowDestroying(Window* window) {
// The CaptureClient implementation handles resetting capture when a window
// is destroyed, but because of observer ordering this may be called first.
DCHECK_EQ(window, capture_window_->GetWindow());
SetCaptureWindow(nullptr);
// The server will release capture when a window is destroyed, so no need
// explicitly schedule a change.
}
void CaptureSynchronizer::OnCaptureChanged(Window* lost_capture,
Window* gained_capture) {
if (!gained_capture && !capture_window_)
return; // Happens if the window is deleted during notification.
// Happens if the window that just lost capture is not the most updated window
// that has capture to avoid setting the current |capture_window_| to null by
// accident. This can occur because CaptureSynchronizer can be the observer
// for multiple capture clients; after we set capture for one capture client
// and then set capture for another capture client, releasing capture on the
// first capture client could potentially reset the |capture_window_| to null
// while the correct |capture_window_| should be the capture window for the
// second capture client at that time.
if (!gained_capture && lost_capture != capture_window_->GetWindow())
return;
WindowMus* gained_capture_mus = WindowMus::Get(gained_capture);
if (setting_capture_ && gained_capture_mus == window_setting_capture_to_) {
SetCaptureWindow(gained_capture_mus);
return;
}
const uint32_t change_id =
delegate_->CreateChangeIdForCapture(capture_window_);
WindowMus* old_capture_window = capture_window_;
SetCaptureWindow(gained_capture_mus);
if (capture_window_)
window_tree_->SetCapture(change_id, capture_window_->server_id());
else
window_tree_->ReleaseCapture(change_id, old_capture_window->server_id());
}
} // namespace aura
|
bcd728ed092dd881431f26d3a231327ff0eab19c | 36c31b485a5906ab514c964491b8f001a70a67f5 | /Codeforces/CF 1200 - 1299/CF1244/CF1244B.cpp | 5099e647790b3d0e1709648e5ee4a08ac689e999 | [] | no_license | SMiles02/CompetitiveProgramming | 77926918d5512824900384639955b31b0d0a5841 | 035040538c7e2102a88a2e3587e1ca984a2d9568 | refs/heads/master | 2023-08-18T22:14:09.997704 | 2023-08-13T20:30:42 | 2023-08-13T20:30:42 | 277,504,801 | 25 | 5 | null | 2022-11-01T01:34:30 | 2020-07-06T09:54:44 | C++ | UTF-8 | C++ | false | false | 734 | cpp | CF1244B.cpp | #include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
void solve(int n, string s)
{
if (s[0]=='1'||s[n-1]=='1')
{
cout<<2*n<<"\n";
return;
}
int first=0,last=0;
for (int i=1;i<n;++i)
{
if (s[i]=='1')
{
last=i;
if (!first)
{
first=i;
}
}
}
if (!last)
{
cout<<n<<"\n";
return;
}
cout<<max(2*(n-first),2*(last+1))<<"\n";
return;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int t,n;
string s;
cin>>t;
while (t--)
{
cin>>n;
cin>>s;
solve(n,s);
}
return 0;
} |
2037210702b8353ac1f0d7d1c7633ba92dac1441 | 5b7e69802b8075da18dc14b94ea968a4a2a275ad | /DRG-SDK/SDK/DRG_ENE_PF_SpiderBase_classes.hpp | 650ae4a2fc8e125d9a4b709c627d04ec2b76de6b | [] | no_license | ue4sdk/DRG-SDK | 7effecf98a08282e07d5190467c71b1021732a00 | 15cc1f8507ccab588480528c65b9623390643abd | refs/heads/master | 2022-07-13T15:34:38.499953 | 2019-03-16T19:29:44 | 2019-03-16T19:29:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,584 | hpp | DRG_ENE_PF_SpiderBase_classes.hpp | #pragma once
// Deep Rock Galactic (0.22) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "DRG_ENE_PF_SpiderBase_structs.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass ENE_PF_SpiderBase.ENE_PF_SpiderBase_C
// 0x0078 (0x0500 - 0x0488)
class AENE_PF_SpiderBase_C : public ASpiderEnemy
{
public:
struct FPointerToUberGraphFrame UberGraphFrame; // 0x0488(0x0008) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient)
class UImpactAudioComponent* ImpactAudio; // 0x0490(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_InstancedReference, CPF_IsPlainOldData)
class UPathfinderReactiveTerrainTrackerComponent* PathfinderReactiveTerrainTracker; // 0x0498(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_InstancedReference, CPF_IsPlainOldData)
class UOutlineComponent* Outline; // 0x04A0(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_InstancedReference, CPF_IsPlainOldData)
class UEnemyComponent* enemy; // 0x04A8(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_InstancedReference, CPF_IsPlainOldData)
class UPawnSensingComponent* PawnSensing; // 0x04B0(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_InstancedReference, CPF_IsPlainOldData)
class UParticleSystem* Death_Particles; // 0x04B8(0x0008) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_IsPlainOldData)
class USoundCue* Death_Sound; // 0x04C0(0x0008) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
float DeathDuration; // 0x04C8(0x0004) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x04CC(0x0004) MISSED OFFSET
class UMaterialInstanceDynamic* DynamicMaterial; // 0x04D0(0x0008) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
float AlertOthersRadius; // 0x04D8(0x0004) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
float MeshScale; // 0x04DC(0x0004) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
class UAnimMontage* SpawnMontage; // 0x04E0(0x0008) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_IsPlainOldData)
float DecalSize; // 0x04E8(0x0004) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
unsigned char UnknownData01[0x4]; // 0x04EC(0x0004) MISSED OFFSET
class USoundCue* FleeSound; // 0x04F0(0x0008) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
class USoundBase* AlertedScream; // 0x04F8(0x0008) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindObject<UClass>("BlueprintGeneratedClass ENE_PF_SpiderBase.ENE_PF_SpiderBase_C");
return ptr;
}
void ChangeVisibility(bool bNewVisibility);
void AlertNearbySpiders();
void ActivateSpider(class AActor* Target);
void InitBlackboard();
void PlayDeathEffects();
void UserConstructionScript();
void OnNotifyEnd_994DB7944B827DB8A3582CB9C470D4B6(const struct FName& NotifyName);
void OnNotifyBegin_994DB7944B827DB8A3582CB9C470D4B6(const struct FName& NotifyName);
void OnInterrupted_994DB7944B827DB8A3582CB9C470D4B6(const struct FName& NotifyName);
void OnBlendOut_994DB7944B827DB8A3582CB9C470D4B6(const struct FName& NotifyName);
void OnCompleted_994DB7944B827DB8A3582CB9C470D4B6(const struct FName& NotifyName);
void ReceiveBeginPlay();
void BndEvt__PawnSensing_K2Node_ComponentBoundEvent_3_SeePawnDelegate__DelegateSignature(class APawn* Pawn);
void BndEvt__HealthComponent_K2Node_ComponentBoundEvent_0_DeathSig__DelegateSignature(class UHealthComponentBase* HealthComponent);
void OnDeathBase();
void AlertNearbyEnemies();
void Spawn();
void OnFrozen();
void OnUnFrozen();
void OnStartedFleeing();
void PlayFleeSound();
void ExecuteUbergraph_ENE_PF_SpiderBase(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
e0be5385fce8f031dabc4785d1b7faf731eac04f | 04ba084d459b8030f7992660a6f1b39ebb08c15a | /Source code/Game/Header files/Main/Settings.h | cde1532d78992cdf445b63633b93d7c713bdf9a7 | [
"MIT"
] | permissive | Ansoulom/cat-rush | 0735596fb7b19c69d0ff1c4c4919cb5f7fa20e0a | e99b18d7bf7b72f0e4918f0cc24a190dd55747e6 | refs/heads/master | 2021-09-28T08:12:30.595627 | 2018-11-15T20:20:02 | 2018-11-15T20:20:02 | 104,118,660 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,126 | h | Settings.h | #pragma once
#include <filesystem>
#include "Window.h"
namespace Game
{
namespace Core
{
class User_settings
{
public:
explicit User_settings(const std::filesystem::path& file);
int resolution_width() const;
int resolution_height() const;
Window_fullscreen_mode fullscreen_mode() const;
bool vsync() const;
private:
int resolution_width_{}, resolution_height_{};
Window_fullscreen_mode fullscreen_mode_{};
bool vsync_{};
};
class Game_constants
{
public:
explicit Game_constants(const std::filesystem::path& file);
std::string name() const;
int source_width() const;
int source_height() const;
private:
std::string name_{};
int source_width_{}, source_height_{};
};
class Settings
{
public:
Settings(const std::filesystem::path& game_constants_file, const std::filesystem::path& user_settings_file);
Game_constants& constants();
const Game_constants& constants() const;
User_settings& user_settings();
const User_settings& user_settings() const;
private:
Game_constants constants_;
User_settings settings_;
};
}
}
|
fd0d38c3ccdd2245bf2e0a29730faa8a93dfe952 | 71c7531ebc75b060982eb9dbb99e1c0adebf2afa | /U_8/ShoppingCart.cpp | 902e470d3dc841d94531fb7e1b110540dd457d4a | [] | no_license | WeiqiKong/ws1718_PR3 | 757ea09aefb5ed7bf331fdcc736aafb21763a5df | cd083f017393c3fa692e5c7db02e31fee1726cd2 | refs/heads/master | 2021-09-03T01:39:37.754075 | 2018-01-04T16:24:58 | 2018-01-04T16:24:58 | 106,850,266 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,188 | cpp | ShoppingCart.cpp | //
// Created by XUEXI on 2017/12/1.
//
#include <sstream>
#include <iomanip>
#include <iostream>
#include "ShoppingCart.h"
void ShoppingCart::add(CartItem* cartItem){
cartItems.push_back(cartItem);
}
double ShoppingCart::getTotalCost(){
double summe=0;
for(CartItem *cartItem:cartItems)
summe=summe+cartItem->getCost();
return summe;
}
CartItem * ShoppingCart::getItem(int pos){
return cartItems.at(pos);
//siez_type __u was kann das bedeuten?
}
int ShoppingCart::getNumberOfItems(){
return cartItems.size();
}
ShoppingCart::ShoppingCart() {
}
void ShoppingCart::toString() {
ostringstream os;
for(auto item:cartItems)
item->toString();
os<<right<<setw(49)<<getTotalCost()<<endl;
std::cout << os.str();
}
long* ShoppingCart::getTeamIds() {
long *array {new long[CartItem::lastId]};
for (int i = 0; i <CartItem::lastId; ++i) {
array[i]= getCartItems().at(i)->getItemId();
}
return array;
}
const vector<CartItem *> &ShoppingCart::getCartItems() const {
return cartItems;
}
void ShoppingCart::setCartItems(const vector<CartItem *> &cartItems) {
ShoppingCart::cartItems = cartItems;
}
|
d951af8686ae89b23cfbb06327af157873a0759f | 19c066b929c30ed3e1ae85b2d1f8a9985fb88072 | /COption.cpp | ee160ff45b52ee02fcbef9b0eab6e35911f23709 | [] | no_license | MuhammadRehmanRabbani/DataStructure | 4318b3da6f9dbf285f889dd74a479a363f2b9a45 | 0fa14b9cf355686aca6f388bbce6bdeaf19c1a79 | refs/heads/master | 2023-08-17T13:37:08.679994 | 2021-09-14T21:09:23 | 2021-09-14T21:09:23 | 406,521,694 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,891 | cpp | COption.cpp |
/********************** Warship repair facility for Tie Fighters and Star Destroyers*****************************/
//including libraries
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <chrono>
#include <time.h>
#include<string>
#include <random>
#include <map>
#include <windows.h>
#define MAX 22
using namespace std;
using namespace std::chrono;
//Declaring of dual stack
typedef struct
{
int tie;
int star;
int max;
string str[MAX];
}DualStack;
//Initialization of Double Stack
void initialize(DualStack* s)
{
s->tie = 0;
s->max = 0;
s->star = MAX - 1;
s->str[0] = "TieBase";
s->str[21] = "StarBase";
}
//Defining push Operation on Tie Stack
void pushTie(DualStack* s, string item)
{
if (s->star == s->tie + 1)
{
s->max++;
printf("\nSpace is full. Kindly direct towards repair facility in the Dagaba system\n");
cout << "Vehicle " << item << " has been rejected" << endl;
return;
}
s->tie++;
s->str[s->tie] = item;
cout << "Inserted vehicle in TieStack :" << item << endl;
}
//defining push Operation on Star Stack
void pushStar(DualStack* s, string item)
{
if (s->star == s->tie + 1)
{
s->max++;
printf("\nSpace is full. Kindly direct towards repair facility in the Dagaba system\n");
cout << "Vehicle " << item << " has been rejected" << endl;
return;
}
s->star--;
s->str[s->star] = item;
cout << "Inserted vehicle in StarStack :" << item << endl;
}
//defining pop operation on Tie Stack
int popTie(DualStack* s, string* item)
{
if (s->tie == -1)
{
printf("\nStack Underflow TieStack\n");
return -1;
}
*item = s->str[s->tie--];
return 0;
}
//defining pop operation on Star Stack
int popStar(DualStack* s, string* item)
{
if (s->star == MAX - 1)
{
printf("\nStack Underflow StarStack\n");
return -1;
}
*item = s->str[s->star++];
return 0;
}
// method to implemet vehicle maintenance record
void report(string type, string name) {
cout << "Vehicle Type: " << type << endl; //printing type of vehicle
cout << "Vehicle Name: " << name << endl; // printing name of vehicle
auto start = std::chrono::system_clock::now();
time_t startTime = std::chrono::system_clock::to_time_t(start);
cout << "Start Time: " << ctime(&startTime); // printing start time
// since Sleep takes the amount of time in milliseconds, and 1000 ms = 1 second
if (type == "Star Destroyer")
Sleep(7 * 1000);
else if (type == "Tie Fighter")
Sleep(3 * 1000);
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSeconds = end - start;
time_t endTime = std::chrono::system_clock::to_time_t(end);
std::cout << "Finish Time " << ctime(&endTime)
<< "Time to repair: " << elapsedSeconds.count() << "s\n";
Sleep(2 * 1000);
cout << "Time consumed for preparation of facility: 2 seconds" << endl;
}
// Main method starts from here
int main()
{
//declaring variables
string vName;
string vehicle;
int startTime;
int count;
int starCount = 0;
int tieCount = 0;
int starRepaired = 0;
int tieRepaired = 0;
int spaceOccupied = 0;
const int range_from = 0.0;
const int range_to = 1.0;
char i = 'A'; // concatenate alphabet with vehicle name i.e. TieA
char j = 'A'; // concatenate alphabet with vehicle name i.e. TieB
double randCount;
//declaring dual stack
DualStack stack;
//initializing the dual stack
initialize(&stack);
// seed value for random numbers
srand(time(0));
freopen("Time.txt", "w", stdout);
// creating map object for concatenating two strings i.e. Tie + A = TieA
std::map<std::string, std::string> variables;
// generating random numbers between range 0 and 1
std::random_device rand_dev;
std::mt19937 generator(rand_dev());
std::uniform_real_distribution<> dis(range_from, range_to);
//Starting timepoint
auto timenow = chrono::system_clock::to_time_t(chrono::system_clock::now());
//Get start time from the system clock and write it to the file
cout << "Start Time : " << ctime(&timenow) << endl;
while (true) {
count = 0;
// 4 vehicles can come at a time in the station, pushing them in appropriate stack
while (count < 4) {
randCount = dis(generator);
// type of vehicle is determined using srtep function
if (randCount >= 0 && randCount < 0.75) {
vehicle = "tie";
vehicle.push_back(i);
// if 5 vehicles are rejected, we chould end the program
if (stack.max == 5) {
spaceOccupied = 1;
break;
}
pushTie(&stack, vehicle);
// If we get tieZ, start with tieA
if (i == 'Z') {
i = 'A';
continue;
}
i++;
tieCount++;
}
else if (randCount >= 0.75 && randCount < 1) {
vehicle = "star";
vehicle.push_back(j);
// if 5 vehicles are rejected, we chould end the program
if (stack.max == 5) {
spaceOccupied = 1;
break;
}
pushStar(&stack, vehicle);
// If we get starZ, start with starA
if (j == 'Z') {
j = 'A';
continue;
}
j++;
starCount++;
}
count++;
}// end while
// if 5 vehicles are rejected, end the program
if (spaceOccupied == 1)
break;
//if there is start destroyer availabe, recover it first
if (starCount > 0) {
if (popStar(&stack, &vName) == 0) {
cout << "Vehicle poped out of stack: " << vName << endl;
// calling repair function to print information of vehicle
report("Star Destroyer", vName);
starRepaired++;
}
starCount--;
continue;
}
//if there is tie fighter available, recover it
if (tieCount > 0) {
if (popTie(&stack, &vName) == 0) {
cout << "Vehicle poped out of stack: " << vName << endl;
// calling repair function to print information of vehicle
report("Tie Fighter", vName);
tieRepaired++;
}
tieCount--;
continue;
}
}
cout << "\n" << "Total Star Destroyers Repaired: " << starRepaired << endl;
cout << "\n" << "Total Tie Destroyers Repaired: " << tieRepaired << endl;
return 0;
} |
f312df44e1a6d9cde26d4cc4eb02516384872653 | 9d30d1e62b919b68c5f2fe1c559aca1c93314a11 | /Recursion&DynamicProgramming/8.5.cpp | 066906691fe11bf40deae1542cc4e0ce2dcf050a | [] | no_license | 4msha/crackingTheCodingInteview | b78b6ad3e79bbfdd48eabc6ca709f88b970d2ecb | f117ab1d04518dc76d6ce08e1198a7c103c1b96b | refs/heads/main | 2023-07-09T06:41:56.338277 | 2021-08-06T07:38:06 | 2021-08-06T07:38:06 | 309,102,816 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 465 | cpp | 8.5.cpp | #include <bits/stdc++.h>
using namespace std;
int multiply(int small, int big)
{
if (small == 0)
return 0;
if (small == 1)
return big;
int s = small >> 2;
int half = multiply(s, big);
if (small % 2 == 0)
{
return half + half;
}
return half + half + big;
}
int main()
{
int a, b;
cin >> a >> b;
int small = a < b ? a : b;
int big = a < b ? b : a;
cout << multiply(small, big) << endl;
} |
cc018c3ddfe80525c31dff19a4ee3b5c5f711abb | 55ae5fddaece08d883c438654bf0a7b7fef625b9 | /Src/ProtocolGenerator/GenerateCode.cpp | 99ad96cc4729588dc9394593c4dab99cde191dc5 | [
"MIT"
] | permissive | sysfce2/Network-Library | fc33842079c436d555e2b832533be53029c4bf50 | 77fd989ad3229e31e52742ade73a7cf6967725e9 | refs/heads/master | 2023-08-01T02:06:00.786239 | 2021-09-17T02:51:55 | 2021-09-17T02:51:55 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 22,948 | cpp | GenerateCode.cpp |
#include "pch.h"
#include "GenerateCode.h"
#include <direct.h>
using namespace network2;
using namespace std;
namespace compiler
{
// Write Protocol Handler Code
bool WriteFirstHandlerHeader(sRmi *rmi, const string &marshallingName);
bool WriteHandlerHeader(ofstream &fs, sRmi *rmi);
bool WriteFirstHandlerCpp(sRmi *rmi, const string &pchFileName);
bool WriteHandlerCpp(ofstream &fs, sRmi *rmi);
void WriteDeclProtocolList(ofstream &fs, sProtocol *pProtocol, bool isVirtual, bool isImpl, bool isTarget);
void WriteFirstArg(ofstream &fs, sArg*p, bool isTarget);
void WriteArg(ofstream &fs, sArg *arg, bool comma);
void WriteArgVar(ofstream &fs, sArg *arg, bool comma);
// Write Protocol Data Code
bool WriteFirstDataHeader(sRmi *rmi, const string &marshallingName);
bool WriteProtocolDataHeader(ofstream &fs, sRmi *rmi);
bool WriteProtocolData(ofstream &fs, sProtocol *pProtocol);
void WriteProtocolDataArg(ofstream &fs, sArg *arg);
// Write Dispatcher
void WriteProtocolDispatchFunc(ofstream &fs, sRmi *rmi);
void WriteDispatchSwitchCase(ofstream &fs, sProtocol *pProtocol);
void WriteDispatchImpleArg(ofstream &fs, sArg*p);
void WriteLastDispatchSwitchCase(ofstream &fs, sProtocol *pProtocol);
void WriteDispatchImpleArg2(ofstream &fs, sArg*p);
void WriteLastDispatchSwitchCase2(ofstream &fs, sProtocol *pProtocol);
// Write Protocol Code
bool WriteFirstProtocolClassHeader(sRmi *rmi, const string &marshallingName);
bool WriteProtocolClassHeader(ofstream &fs, sRmi *rmi);
bool WriteFirstProtocolCpp(sRmi *rmi, const string &pchFileName);
bool WriteProtocolCpp(ofstream &fs, sRmi *rmi);
void WriteImplProtocolList(ofstream &fs, sProtocol *pProtocol);
void WriteFirstImpleProtocol(ofstream &fs, sProtocol *pProtocol, sArg*p);
void WriteImpleArg(ofstream &fs, sArg*p);
void WriteLastImpleProtocol(ofstream &fs);
string GetFileNameExceptExt(const string &fileName);
string GetProtocolName(const string &fileName);
string GetProtocolClassName(const string &protocolName, const string &rmiName );
string GetProtocolHandlerClassName(const string &protocolName, const string &rmiName );
string GetProtocolDispatcherClassName(const string &protocolName, const string &rmiName );
string g_className; // Protocol, ProtocolHandler 공동으로 사용하고 있다.
string g_protocolId;
string n_fileName;
string g_protocolName; // *.prt 파일의 확장자와 경로를 제외한 파일이름을 저장한다.
string n_OrigianlFileName;
string g_handlerClassName;
string n_SrcFolderName = "Src";
}
using namespace compiler;
//------------------------------------------------------------------------
// ProtocolHandler 클래스 헤더파일을 생성한다.
//------------------------------------------------------------------------
bool compiler::WriteProtocolCode(const string &protocolFileName, sRmi *rmi
, const string &pchFileName, const string &marshallingName
)
{
if (!rmi)
return true;
const std::string fileName = common::GetFileNameExceptExt(protocolFileName);
const std::string path = common::GetFilePathExceptFileName(protocolFileName);
const std::string folder = (path.empty())? n_SrcFolderName : path + "\\" + n_SrcFolderName;
_mkdir(folder.c_str());
n_OrigianlFileName = folder + "\\" + fileName;
g_protocolName = GetProtocolName(protocolFileName);
WriteFirstProtocolClassHeader(rmi, marshallingName);
WriteFirstProtocolCpp(rmi, pchFileName);
WriteFirstHandlerHeader(rmi, marshallingName);
WriteFirstHandlerCpp(rmi, pchFileName);
WriteFirstDataHeader(rmi, marshallingName);
return true;
}
//------------------------------------------------------------------------
// 파일이름의 경로와 확장자를 제외한 파일 이름
//------------------------------------------------------------------------
string compiler::GetProtocolName(const string &fileName)
{
return common::GetFileNameExceptExt(fileName);
}
//------------------------------------------------------------------------
// *.prt 파일이름(protocolName)과 프로토콜이름(rmiName) 의 조합으로
// 프로토콜 클래스 이름을 리턴한다.
//------------------------------------------------------------------------
string compiler::GetProtocolClassName(const string &protocolName, const string &rmiName )
{
return rmiName + "_Protocol";
}
//------------------------------------------------------------------------
// *.prt 파일이름(protocolName)과 프로토콜이름(rmiName) 의 조합으로
// 프로토콜리스너 클래스 이름을 리턴한다.
//------------------------------------------------------------------------
string compiler::GetProtocolHandlerClassName(const string &protocolName, const string &rmiName )
{
return rmiName + "_ProtocolHandler";
}
//------------------------------------------------------------------------
// 프로토콜 디스패쳐 클래스 이름을 리턴한다.
//------------------------------------------------------------------------
string compiler::GetProtocolDispatcherClassName(const string &protocolName, const string &rmiName )
{
return rmiName + "_Dispatcher";
}
//------------------------------------------------------------------------
// Protocol Header 파일을 생성하는 처음부분의 코드를 생성한다.
//------------------------------------------------------------------------
bool compiler::WriteFirstProtocolClassHeader(sRmi *rmi, const string &marshallingName)
{
n_fileName = n_OrigianlFileName + "_Protocol.h";
std::ofstream fs;
fs.open(n_fileName.c_str());
if (!fs.is_open()) return false;
fs << "//------------------------------------------------------------------------\n";
fs << "// Name: " << common::GetFileName(n_fileName) << endl;
fs << "// Author: ProtocolGenerator (by jjuiddong)\n";
fs << "// Date: \n";
fs << "//------------------------------------------------------------------------\n";
fs << "#pragma once\n";
fs << endl;
fs << "namespace " << g_protocolName << " {\n";
fs << endl;
fs << "using namespace network2;\n";
fs << "using namespace " << marshallingName << ";\n";
WriteProtocolClassHeader(fs, rmi);
fs << "}\n";
return true;
}
//------------------------------------------------------------------------
// Protocol 헤더 소스코드를 생성한다.
//------------------------------------------------------------------------
bool compiler::WriteProtocolClassHeader(ofstream &fs, sRmi *rmi)
{
if (!rmi) return true;
g_className = GetProtocolClassName(g_protocolName, rmi->name );
g_protocolId = g_className + "_ID";
fs << "static const int " << g_protocolId << " = " << rmi->number << ";\n";
fs << endl;
fs << "class " << g_className << " : public network2::iProtocol\n";
fs << "{" << endl;
fs << "public:" << endl;
fs << "\t" << g_className << "() : iProtocol(" << g_protocolId << ") {}\n";
// print protocol list
WriteDeclProtocolList( fs, rmi->protocol, false, false, true);
fs << "};\n";
return WriteProtocolClassHeader(fs, rmi->next);
}
/**
@brief WriteFirstDataHeader
*/
bool compiler::WriteFirstDataHeader(sRmi *rmi, const string &marshallingName)
{
n_fileName = n_OrigianlFileName + "_ProtocolData.h";
ofstream fs;
fs.open( n_fileName.c_str());
if (!fs.is_open()) return false;
fs << "//------------------------------------------------------------------------\n";
fs << "// Name: " << common::GetFileName(n_fileName) << endl;
fs << "// Author: ProtocolGenerator (by jjuiddong)\n";
fs << "// Date: \n";
fs << "//------------------------------------------------------------------------\n";
fs << "#pragma once\n";
fs << endl;
fs << "namespace " << g_protocolName << " {\n";
fs << endl;
fs << "using namespace network2;\n";
fs << "using namespace " << marshallingName << ";\n";
WriteProtocolDataHeader(fs, rmi);
fs << "}\n";
return true;
}
/**
@brief WriteDataHeader
*/
bool compiler::WriteProtocolDataHeader(ofstream &fs, sRmi *rmi)
{
if (!rmi) return true;
g_className = GetProtocolDispatcherClassName(g_protocolName, rmi->name);
g_protocolId = g_className + "_ID";
fs << endl;
fs << endl;
WriteProtocolData(fs, rmi->protocol );
fs << endl;
fs << endl;
return WriteProtocolDataHeader(fs, rmi->next);
}
/**
@brief
*/
bool compiler::WriteProtocolData(ofstream &fs, sProtocol *pProtocol)
{
if (!pProtocol) return true;
fs << "\tstruct " << pProtocol->name << "_Packet {" << endl;
fs << "\t\tcProtocolDispatcher *pdispatcher;\n";
fs << "\t\tnetid senderId;\n";
WriteProtocolDataArg(fs, pProtocol->argList );
fs << "\t};";
fs << endl;
fs << endl;
return WriteProtocolData(fs, pProtocol->next);
}
/**
@brief
*/
void compiler::WriteProtocolDataArg(ofstream &fs, sArg *arg)
{
if (!arg) return;
fs << "\t\t" << arg->var->type << " " << arg->var->var << ";" << endl;
WriteProtocolDataArg(fs, arg->next);
}
//------------------------------------------------------------------------
// ProtocolHandler 헤더파일에서 처음 들어갈 주석 코드 추가
//------------------------------------------------------------------------
bool compiler::WriteFirstHandlerHeader(sRmi *rmi, const string &marshallingName)
{
n_fileName = n_OrigianlFileName + "_ProtocolHandler.h";
ofstream fs;
fs.open( n_fileName.c_str());
if (!fs.is_open()) return false;
fs << "//------------------------------------------------------------------------\n";
fs << "// Name: " << common::GetFileName(n_fileName) << endl;
fs << "// Author: ProtocolGenerator (by jjuiddong)\n";
fs << "// Date: \n";
fs << "//------------------------------------------------------------------------\n";
fs << "#pragma once\n";
fs << endl;
fs << "#include \"" << g_protocolName << "_ProtocolData.h\"" << endl;
fs << endl;
fs << "namespace " << g_protocolName << " {\n";
fs << endl;
fs << "using namespace network2;\n";
fs << "using namespace " << marshallingName << ";\n";
WriteHandlerHeader(fs, rmi);
fs << "}\n";
return true;
}
//------------------------------------------------------------------------
// ProtocolHandler 헤더 클래스 소스파일을 생성한다.
//------------------------------------------------------------------------
bool compiler::WriteHandlerHeader(ofstream &fs, sRmi *rmi)
{
if (!rmi) return true;
g_className = GetProtocolDispatcherClassName(g_protocolName, rmi->name);
g_protocolId = g_className + "_ID";
fs << "static const int " << g_protocolId << " = " << rmi->number << ";\n";
fs << endl;
// Protocol Dispatcher
fs << "// Protocol Dispatcher\n";
fs << "class " << g_className << ": public network2::cProtocolDispatcher\n";
fs << "{\n";
fs << "public:\n";
fs << "\t" << g_className << "();\n";
fs << "protected:\n";
fs << "\tvirtual bool Dispatch(cPacket &packet, const ProtocolHandlers &handlers) override;\n";
fs << "};\n";
fs << "static " << g_className << " g_" << g_protocolName << "_" << g_className << ";\n";// 전역변수 선언
fs << endl;
fs << endl;
// CProtocolHandler class
g_className = GetProtocolHandlerClassName(g_protocolName, rmi->name);
string dispatcherClassName = GetProtocolDispatcherClassName(g_protocolName, rmi->name);
fs << "// ProtocolHandler\n";
fs << "class " << g_className << " : virtual public network2::iProtocolHandler\n";
fs << "{\n";
fs << "\tfriend class " << dispatcherClassName << ";\n";
WriteDeclProtocolList( fs, rmi->protocol, true, true, false);
fs << "};\n";
fs << endl;
fs << endl;
return WriteHandlerHeader(fs, rmi->next);
}
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------
bool compiler::WriteFirstHandlerCpp(sRmi *rmi, const string &pchFileName)
{
n_fileName = n_OrigianlFileName + "_ProtocolHandler.cpp";
string headerFileName = g_protocolName + "_ProtocolHandler.h";
ofstream fs(n_fileName.c_str());
if (!fs.is_open())
return false;
if (!pchFileName.empty())
fs << "#include \"" << pchFileName << "\"\n";
fs << "#include \"" << headerFileName << "\"\n";
//fs << "#include \"network/Controller/Controller.h\"\n";
fs << endl;
//fs << "using namespace network2;\n";
//fs << "using namespace marshalling;\n";
fs << "using namespace " << g_protocolName << ";\n";
fs << endl;
WriteHandlerCpp(fs, rmi);
return true;
}
//------------------------------------------------------------------------
// ProtocolHandler Cpp 파일을 생성한다.
//------------------------------------------------------------------------
bool compiler::WriteHandlerCpp(ofstream &fs, sRmi *rmi)
{
if (!rmi) return true;
g_className = GetProtocolDispatcherClassName(g_protocolName, rmi->name);
g_protocolId = g_className + "_ID";
// Dispatcher 생성자 코드 생성
//fs << "static " << g_protocolName << "::" << g_className << " g_" << g_protocolName << "_" << g_className << ";\n";// 전역변수 선언
fs << "\n";
fs << g_protocolName << "::" << g_className << "::" << g_className << "()\n";
fs << "\t: cProtocolDispatcher(" << g_protocolName << "::" << g_protocolId << ")\n";
fs << "{\n";
fs << "\tcProtocolDispatcher::GetDispatcherMap()->insert({" << g_protocolId << ", this });\n";
fs << "}\n";
fs << endl;
//
// Dispatcher 클래스의 Dispatch() 함수 코드 생성
WriteProtocolDispatchFunc(fs, rmi);
fs << endl;
fs << endl;
fs << endl;
return WriteHandlerCpp(fs, rmi->next);
}
//------------------------------------------------------------------------
// 헤더 클래스파일에 있을 프로토콜 리스트를 출력한다.
//------------------------------------------------------------------------
void compiler::WriteDeclProtocolList(ofstream &fs, sProtocol *pProtocol, bool isVirtual, bool isImpl, bool isTarget)
{
if (!pProtocol) return;
// First Interface
if (!isImpl)
{
fs << "\t";
if (isVirtual)
fs << "virtual ";
if (isImpl)
fs << "bool "; // Handler header file
else
fs << "void "; // protocol header file
//fs << "bool " << pProtocol->name << "(";
fs << pProtocol->name << "(";
WriteFirstArg(fs, pProtocol->argList, isTarget);
fs << ")";
if (isImpl)
fs << "{ return true; }"; // Handler header file
else
fs << ";"; // protocol header file
fs << endl;
}
// Second Interface
if (isVirtual && isImpl)
{
fs << "\t";
fs << "virtual ";
fs << "bool "; // Handler header file
fs << pProtocol->name << "(";
fs << g_protocolName << "::";
fs << pProtocol->name << "_Packet &packet";
fs << ") { return true; }"; // Handler header file
fs << endl;
}
WriteDeclProtocolList(fs, pProtocol->next, isVirtual, isImpl, isTarget);
}
//------------------------------------------------------------------------
// Cpp 파일에 있을 프로토콜 리스트를 출력한다.
//------------------------------------------------------------------------
void compiler::WriteImplProtocolList(ofstream &fs, sProtocol *pProtocol)
{
if (!pProtocol) return;
fs << "//------------------------------------------------------------------------\n";
fs << "// Protocol: " << pProtocol->name << endl;
fs << "//------------------------------------------------------------------------\n";
fs << "void " << g_protocolName << "::" << g_className << "::" << pProtocol->name << "(";
WriteFirstArg(fs, pProtocol->argList, true);
fs << ")\n";
fs << "{\n";
WriteFirstImpleProtocol(fs, pProtocol, pProtocol->argList);
fs << "}\n";
fs << "\n";
WriteImplProtocolList(fs, pProtocol->next);
}
//------------------------------------------------------------------------
// 프로토콜 인자리스트 출력
//------------------------------------------------------------------------
void compiler::WriteFirstArg(ofstream &fs, sArg*p, bool isTarget)
{
if (isTarget)
{
fs <<"netid targetId";
//fs << ", const SEND_FLAG flag";
}
else
{
fs << "cProtocolDispatcher &dispatcher, ";
fs << "netid senderId";
}
WriteArg(fs, p, true);
}
void compiler::WriteArg(ofstream &fs, sArg *arg, bool comma)
{
if (!arg) return;
if (comma)
fs << ", ";
fs << "const " << arg->var->type << " &" << arg->var->var;
WriteArg(fs, arg->next, true);
}
//------------------------------------------------------------------------
// 프로토콜 인자값의 변수 이름만 출력한다. (함수 호출시 사용)
//------------------------------------------------------------------------
void compiler::WriteArgVar(ofstream &fs, sArg *arg, bool comma)
{
if (!arg) return;
if (comma)
fs << ", ";
fs << arg->var->var;
WriteArgVar(fs, arg->next, true);
}
//------------------------------------------------------------------------
// Cpp 파일에 들어갈 프로토콜 함수의 처음에 나올 코드
//------------------------------------------------------------------------
void compiler::WriteFirstImpleProtocol(ofstream &fs, sProtocol *pProtocol
, sArg*p)
{
fs << "\tcPacket packet(m_node->GetPacketHeader());\n";
fs << "\tpacket.SetProtocolId( GetId() );\n";
fs << "\tpacket.SetPacketId( " << pProtocol->packetId << " );\n";
WriteImpleArg(fs, p);
fs << "\tpacket.EndPack();\n";
WriteLastImpleProtocol(fs);
}
//------------------------------------------------------------------------
// Cpp 파일에 들어갈 프로토콜 코드에서 패킷에 인자값을 넣는 코드
//------------------------------------------------------------------------
void compiler::WriteImpleArg(ofstream &fs, sArg*p)
{
if (!p) return;
fs << "\tpacket << " << p->var->var << ";\n";
fs << "\tAddDelimeter(packet);\n";
WriteImpleArg(fs, p->next);
}
//------------------------------------------------------------------------
// Cpp 파일에 들어갈 프로토콜 함수의 마지막에 나올 코드
//------------------------------------------------------------------------
void compiler::WriteLastImpleProtocol(ofstream &fs)
{
fs << "\tGetNode()->Send(targetId, packet);\n";
}
//------------------------------------------------------------------------
// Protocol Cpp 코드를 생성한다.
//------------------------------------------------------------------------
bool compiler::WriteFirstProtocolCpp(sRmi *rmi, const string &pchFileName)
{
n_fileName = n_OrigianlFileName + "_Protocol.cpp";
string headerFileName = g_protocolName + "_Protocol.h";
ofstream fs(n_fileName.c_str());
if (!fs.is_open()) return false;
if (!pchFileName.empty())
fs << "#include \"" << pchFileName << "\"\n";
fs << "#include \"" << headerFileName << "\"\n";
//fs << "using namespace network2;\n";
//fs << "using namespace marshalling;\n";
fs << "using namespace " << g_protocolName << ";\n";
fs << endl;
WriteProtocolCpp(fs, rmi);
return true;
}
//------------------------------------------------------------------------
// ProtocolHandler Cpp 파일 생성
//------------------------------------------------------------------------
bool compiler::WriteProtocolCpp(ofstream &fs, sRmi *rmi)
{
if (!rmi) return true;
g_className = GetProtocolClassName(g_protocolName, rmi->name);
WriteImplProtocolList( fs, rmi->protocol );
fs << endl;
fs << endl;
return WriteProtocolCpp(fs, rmi->next);
}
//------------------------------------------------------------------------
// Handler::Dispatch() 함수 코드 생성
//------------------------------------------------------------------------
void compiler::WriteProtocolDispatchFunc(ofstream &fs, sRmi *rmi)
{
g_handlerClassName = GetProtocolHandlerClassName(g_protocolName, rmi->name);
fs << "//------------------------------------------------------------------------\n";
fs << "// 패킷의 프로토콜에 따라 해당하는 핸들러를 호출한다.\n";
fs << "//------------------------------------------------------------------------\n";
fs << "bool " << g_protocolName << "::" << g_className << "::Dispatch(cPacket &packet, const ProtocolHandlers &handlers)\n",
fs << "{\n";
fs << "\tconst int protocolId = packet.GetProtocolId();\n";
fs << "\tconst int packetId = packet.GetPacketId();\n";
if (rmi->protocol)
{
fs << "\tswitch (packetId)\n";
fs << "\t{\n";
WriteDispatchSwitchCase(fs, rmi->protocol);
fs << "\tdefault:\n";
fs << "\t\tassert(0);\n";
fs << "\t\tbreak;\n";
fs << "\t}\n";
}
fs << "\treturn true;\n";
fs << "}\n";
}
//------------------------------------------------------------------------
// Dispatch 함수에서case 문 코드 생성
//------------------------------------------------------------------------
void compiler::WriteDispatchSwitchCase(ofstream &fs, sProtocol *pProtocol)
{
if (!pProtocol) return;
fs << "\tcase " << pProtocol->packetId << ":\n";
fs << "\t\t{\n";
// call HandlerMatching<T> function
fs << "\t\t\tProtocolHandlers prtHandler;\n";
fs << "\t\t\tif (!HandlerMatching<" << g_handlerClassName << ">(handlers, prtHandler))\n";
fs << "\t\t\t\treturn false;\n";
fs << endl;
// set current packet
fs << "\t\t\tSetCurrentDispatchPacket( &packet );\n";
fs << endl;
fs << "\t\t\t" << pProtocol->name << "_Packet data;\n";
fs << "\t\t\tdata.pdispatcher = this;\n";
fs << "\t\t\tdata.senderId = packet.GetSenderId();\n";
WriteDispatchImpleArg2(fs, pProtocol->argList);
WriteLastDispatchSwitchCase2(fs, pProtocol);
fs << "\t\t}\n";
fs << "\t\tbreak;\n";
fs << "\n";
WriteDispatchSwitchCase(fs, pProtocol->next);
}
//------------------------------------------------------------------------
// Dispatch 함수의 switch case 문에 들어가는 각 패킷 인자를 얻어오는 코드를
// 생성한다.
//------------------------------------------------------------------------
void compiler::WriteDispatchImpleArg(ofstream &fs, sArg*p)
{
if (!p) return;
// 변수 선언
fs << "\t\t\t" << p->var->type << " " << p->var->var << ";\n";
// 패킷에서 데이타 얻음
fs << "\t\t\tpacket >> " << p->var->var << ";\n";
WriteDispatchImpleArg(fs, p->next);
}
void compiler::WriteDispatchImpleArg2(ofstream &fs, sArg*p)
{
if (!p) return;
// 변수 선언
//fs << "\t\t\t" << p->var->type << " " << p->var->var << ";\n";
// 패킷에서 데이타 얻음
fs << "\t\t\tpacket >> " << "data." << p->var->var << ";\n";
WriteDispatchImpleArg2(fs, p->next);
}
//------------------------------------------------------------------------
// Dispatch 함수의 switch case 문의 마지막에 들어가는 코드로, 프로토콜에 해당하는
// 핸들러를 호출하는 코드를 생성한다.
//------------------------------------------------------------------------
void compiler::WriteLastDispatchSwitchCase(ofstream &fs, sProtocol *pProtocol)
{
fs << "\t\t\tSEND_HANDLER(" << g_handlerClassName << ", prtHandler, " << pProtocol->name << "(*this, packet.GetSenderId()";
WriteArgVar(fs, pProtocol->argList, true );
fs << ") );\n";
}
void compiler::WriteLastDispatchSwitchCase2(ofstream &fs, sProtocol *pProtocol)
{
fs << "\t\t\tSEND_HANDLER(" << g_handlerClassName << ", prtHandler, " << pProtocol->name << "(data));\n";
//SEND_HANDLER(s2s_ProtocolHandler, prtHandler, ReqMovePlayer(data) );
//WriteArgVar(fs, pProtocol->argList, true );
//fs << ") );\n";
}
|
af5f84de9554e91c18880813808d4cd305d05090 | 819b29d01434ca930f99e8818293cc1f9aa58e18 | /src/contest/ccc/CCC_2015_Stage_2_Solar_Flight.cc | d6ddd0448638722e970bcb45c774282af84bfd2e | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ANUJ581/competitive-programming-1 | 9bd5de60163d9a46680043d480455c8373fe26a7 | d8ca9efe9762d9953bcacbc1ca1fe0da5cbe6ac4 | refs/heads/master | 2020-08-06T18:43:09.688000 | 2019-10-06T04:54:47 | 2019-10-06T04:54:47 | 213,110,718 | 0 | 0 | NOASSERTION | 2019-10-06T04:54:18 | 2019-10-06T04:54:18 | null | UTF-8 | C++ | false | false | 2,919 | cc | CCC_2015_Stage_2_Solar_Flight.cc | #include <bits/stdc++.h>
using namespace std;
#define SIZE 2001
#define EPS 0.000001
typedef long long ll;
struct query {
int index, plane, position;
query(int index_, int plane_, int position_) {
index = index_;
plane = plane_;
position = position_;
}
};
struct collision {
double startPos, endPos;
int inc, dec;
ll val;
collision(double pos, ll val_) {
startPos = pos;
val = val_;
}
collision(double pos, int inc_, int dec_) {
startPos = pos;
inc = inc_;
dec = dec_;
}
};
class cmp_query {
public:
bool operator()(const query &q1, const query &q2) const {
return q1.position < q2.position;
}
};
class cmp_collision {
public:
bool operator()(const collision &c1, const collision &c2) const {
return c1.startPos > c2.startPos;
}
};
int x, k, n, q;
int a[SIZE], b[SIZE];
ll c[SIZE];
vector<deque<collision>> maxState(SIZE);
ll curr[SIZE];
priority_queue<collision, vector<collision>, cmp_collision> pq;
void add(collision c, int plane) {
while (!maxState[plane].empty() && (maxState[plane].back().val <= c.val ||
abs(maxState[plane].back().startPos - c.startPos) <= EPS))
maxState[plane].pop_back();
maxState[plane].push_back(c);
}
int main() {
scanf("%d%d%d%d", &x, &k, &n, &q);
for (int i = 0; i < n; i++) {
maxState[i].push_back(collision(0, 0));
scanf("%d%d%lld", &a[i], &b[i], &c[i]);
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (a[i] > a[j])
pq.push(collision(0.0, j, i));
else
pq.push(collision(0.0, i, j));
double s1 = (double)(b[i] - a[i]) / x;
double s2 = (double)(b[j] - a[j]) / x;
double cx = (double)(a[j] - a[i]) / (s1 - s2);
if (0 <= cx && cx <= x) {
if (b[i] > b[j])
pq.push(collision(cx, j, i));
else
pq.push(collision(cx, i, j));
}
}
}
vector<query> queries;
for (int i = 0; i < q; i++) {
int plane, pos;
scanf("%d%d", &plane, &pos);
queries.push_back(query(i, plane - 1, pos));
}
sort(queries.begin(), queries.end(), cmp_query());
ll ans[q];
for (query qu : queries) {
while (!pq.empty() && pq.top().startPos <= qu.position + k) {
collision next = pq.top();
pq.pop();
curr[next.inc] += c[next.dec];
maxState[next.inc].back().endPos = next.startPos;
add(collision(next.startPos, curr[next.inc]), next.inc);
if (next.startPos != 0) {
curr[next.dec] -= c[next.inc];
maxState[next.dec].back().endPos = next.startPos;
add(collision(next.startPos, curr[next.dec]), next.dec);
}
}
while (maxState[qu.plane].size() > 1 && maxState[qu.plane][0].endPos <= qu.position)
maxState[qu.plane].pop_front();
ans[qu.index] = maxState[qu.plane].front().val;
}
for (int i = 0; i < q; i++)
printf("%lld\n", ans[i]);
return 0;
}
|
315c7b2c7b443fc829855ebd269161806d3ce6b6 | c0eb66b77b44c7b49d59abdeba6db9477597b618 | /lib/Module/ThreadPreemption.cpp | a6ec307e6058d3c4c4d7f132405a5394d5a67b5c | [
"NCSA"
] | permissive | lmcarril/kleerace | c370432197b892461868d014c5bdfe278b0b54b0 | 59699e1b55bb06e1fc2a6e935887b08633b28b44 | refs/heads/master | 2021-08-08T21:43:41.737858 | 2015-12-01T14:48:32 | 2015-12-01T14:48:32 | 110,336,068 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,843 | cpp | ThreadPreemption.cpp | //===-- ThreadPreemption.cpp - Introduce thread preemption points ---------===//
//
// The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
#include "Passes.h"
#include "klee/Config/Version.h"
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
#include "llvm/IR/LLVMContext.h"
#else
#include "llvm/LLVMContext.h"
#endif
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
using namespace llvm;
using namespace klee;
static cl::opt<bool>
ClPreemptBefore("preempt-before-pthread",
cl::desc("Add preemption points before pthread calls (default=off)"),
cl::init(false));
static cl::opt<bool>
ClPreemptAfterIfSuccess("preempt-after-pthread-success",
cl::desc("Add preemption points after pthread calls, if the call is succesful (default=off)"),
cl::init(false));
char ThreadPreemptionPass::ID = 0;
static Function *checkInterfaceFunction(Constant *FuncOrBitcast) {
if (Function *F = dyn_cast<Function>(FuncOrBitcast))
return F;
FuncOrBitcast->dump();
report_fatal_error("Instrument Memory Access Pass interface function redefined");
}
static const int nPthreadNames = 14;
static const char * pthreadFuncNames[nPthreadNames] = {
"pthread_create",
"pthread_mutex_lock",
"pthread_mutex_trylock",
"pthread_mutex_unlock",
"pthread_cond_wait",
"pthread_cond_signal",
"pthread_rwlock_rdlock",
"pthread_rwlock_tryrdlock",
"pthread_rwlock_wrlock",
"pthread_rwlock_trywrlock",
"pthread_rwlock_unlock",
"sem_wait",
"sem_trywait",
"sem_post"
};
bool ThreadPreemptionPass::doInitialization(Module &M) {
IRBuilder<> IRB(M.getContext());
// void klee_thread_preempt(int yield)
preemptFunction = checkInterfaceFunction(M.getOrInsertFunction("klee_thread_preempt",
IRB.getVoidTy(), IRB.getInt32Ty(), NULL));
ConstantInt *zero = ConstantInt::get(IRB.getInt32Ty(), 0);
for (int i = 0; i < nPthreadNames; i++)
if (Function* f = M.getFunction(pthreadFuncNames[i]))
pthreadFunctions.push_back(std::make_pair(f, zero));
if (Function* f = M.getFunction("pthread_barrier_wait"))
pthreadFunctions.push_back(std::make_pair(f, ConstantInt::get(IRB.getInt32Ty(),
PTHREAD_BARRIER_SERIAL_THREAD)));
return true;
}
bool ThreadPreemptionPass::runOnModule(Module &M) {
bool changed = false;
// Collect function call instructions
SmallVector<std::pair<CallInst *, ConstantInt *>, 32> pthreadCalls;
for (SmallVectorImpl<std::pair<Function*, ConstantInt*> >::iterator itF = pthreadFunctions.begin(),
itFe = pthreadFunctions.end(); itF != itFe; ++itF) {
Function *F = itF->first;
for (Value::use_iterator itU = F->use_begin(),
itUe = F->use_end(); itU != itUe; ++itU) {
if (CallInst* call = dyn_cast<CallInst>(*itU))
pthreadCalls.push_back(std::make_pair(call,itF->second));
}
}
if (ClPreemptBefore) {
for (SmallVectorImpl<std::pair<CallInst*,ConstantInt *> >::iterator it = pthreadCalls.begin(),
ite = pthreadCalls.end(); it != ite; ++it)
changed |= addPreemptionBefore(it->first);
}
if (ClPreemptAfterIfSuccess) {
for (SmallVectorImpl<std::pair<CallInst*,ConstantInt *> >::iterator it = pthreadCalls.begin(),
ite = pthreadCalls.end(); it != ite; ++it) {
// Check to avoid a double preeemption
if (CallInst *nCall = dyn_cast<CallInst>(it->first->getNextNode()))
if (nCall->getCalledFunction() == preemptFunction)
continue;
changed |= addPreemptionAfterIfSuccess(it->first, it->second);
}
}
return changed;
}
bool ThreadPreemptionPass::addPreemptionBefore(Instruction *I) {
IRBuilder<> IRB(I);
IRB.CreateCall(preemptFunction, ConstantInt::get(IRB.getInt32Ty(), 0), "");
return true;
}
bool ThreadPreemptionPass::addPreemptionAfter(Instruction *I) {
IRBuilder<> IRB(I->getNextNode());
IRB.CreateCall(preemptFunction, ConstantInt::get(IRB.getInt32Ty(), 0), "");
return true;
}
bool ThreadPreemptionPass::addPreemptionAfterIfSuccess(CallInst *inst, ConstantInt *ret) {
IRBuilder<> IRB(inst->getNextNode());
if (!(inst->getCalledFunction()->getFunctionType()->isValidReturnType(ret->getType())))
return false;
Value *cmp = IRB.CreateICmpEQ(inst, ret, "_preemptcmp");
TerminatorInst *term = SplitBlockAndInsertIfThen(cast<Instruction>(cmp), false, NULL);
addPreemptionBefore(term);
return true;
}
|
5d5bd2179dd780e003008c4150fff1d923de09a4 | 54f352a242a8ad6ff5516703e91da61e08d9a9e6 | /Source Codes/AtCoder/arc075/D/1440406.cpp | 4c851db69f38987f6304ed10f67d7fb1efa01fad | [] | no_license | Kawser-nerd/CLCDSA | 5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb | aee32551795763b54acb26856ab239370cac4e75 | refs/heads/master | 2022-02-09T11:08:56.588303 | 2022-01-26T18:53:40 | 2022-01-26T18:53:40 | 211,783,197 | 23 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 1,434 | cpp | 1440406.cpp | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;
int main(void)
{
LL D;
cin >> D;
vector<LL>ten;
ten.push_back(1);
for (int i = 0; i <= 18; ++i)ten.push_back(ten.back() * 10);
std::function<LL(LL, int, int)>f = [&](LL rem, int lev, int tot)
{
//?????
LL base = ten[tot - 1 - lev] - ten[lev];
if (base <= 0)
{
if (rem == 0)return (tot % 2) * 9 + 1LL;
return 0LL;
}
//div 10^lev mod 10 ???
LL mod = (rem / ten[lev]) % 10;
if (rem < 0)
{
mod += 10;
mod %= 10;
}
int ma = -mod;
int mb = ma + 10;
int za = 10 - abs(ma) - (lev == 0);
int zb = 10 - abs(mb) - (lev == 0);
LL ans = f(rem - ma * base, lev + 1, tot);
ans *= za;
if (mb < 10)
{
LL plus = f(rem - mb * base, lev + 1, tot);
plus *= zb;
ans += plus;
}
return ans;
};
LL ans = 0;
for (int L = 2; L <= 18; ++L)
{
ans += f(D, 0, L);
}
cout << ans << endl;
return 0;
} |
c702f69b8e454418287823cdd035073b0f498d59 | d1ac7405429c08aa4a7e9ba8f35a5a10e991d5e8 | /DD.cpp | 88c1b24531605922c39a7e0e3c719afa60d504f4 | [] | no_license | Badlylucky/SHIPC2018qual | 1459e5b9b28dabe037393f281afa60353acc1eb5 | 3b9dd1e8e2e7534e2afa6e57517b85d19a14981b | refs/heads/master | 2020-03-27T10:56:09.334918 | 2018-08-28T14:27:29 | 2018-08-28T14:27:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,659 | cpp | DD.cpp | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <utility>
#include <functional>
typedef long long ll;
using namespace std;
typedef pair<ll,int> P;
class Edge
{
public:
ll cost;
int from;
int to;
Edge(int n,ll c)
{
to=n;
cost=c;
}
Edge(int f,int t,int c)
{
from=f;
to=t;
cost=c;
}
};
vector<Edge> eng[100000];
vector<Edge> snug[100000];
ll endd[100000];
ll snud[100000];
ll zansnu[100000];//それぞれの料金所を経由したときの残スヌーク
void dijk(int s,ll d[],vector<Edge> g[])
{
priority_queue<P,vector<P>,greater<P>> que;
fill(d,d+100000,1e9-1);
d[s]=0;
que.push(P(0,s));
while(!que.empty())
{
P p=que.top();
que.pop();
int v=p.second;
if(d[v]<p.first)
continue;
for(int i=0;i<g[v].size();i++)
{
Edge e=g[v][i];
if(d[e.to]>d[v]+e.cost)
{
d[e.to]=d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
int main()
{
int n,m,s,t;
P best;//最もスヌークが多くなるときに経由する両替所とコスト
cin>>n>>m>>s>>t;
s--;t--;
for(int i=0;i<m;i++)
{
int u,v;
ll a,b;
cin>>u>>v>>a>>b;
u--;v--;
eng[u].push_back(Edge(v,a));
eng[v].push_back(Edge(u,a));
snug[u].push_back(Edge(v,b));
snug[v].push_back(Edge(u,b));
}
dijk(s,endd,eng);//あらかじめ円のほうは最短路を求めておく
dijk(t,snud,snug);//snuの方はゴールからの最短路を求めておく
for(int i=0;i<n;i++)
{
zansnu[i]=1e15-(endd[i]+snud[i]);
}
for(int i=n-2;i>-1;i--)
{
zansnu[i]=max(zansnu[i],zansnu[i+1]);
}
for(int i=0;i<n;i++)
cout<<zansnu[i]<<endl;
return 0;
} |
1ddaddaf24cadee63bcea2ea724dde41c3b8e5fd | 1299289ee0dfca66f5e43e17f311bab9ec1c8ef8 | /PL labs/lab3/src/Container.cpp | 09e03356c7ceed14eec8583d2e0f701c9beafa7b | [] | no_license | vangaru/labs | 3af62a7ce1369082be5d550c2039301ca2f5324c | 0b3be25ab782167acb91ee2486bccb2313857af3 | refs/heads/main | 2023-01-29T03:49:00.937672 | 2020-12-12T10:30:12 | 2020-12-12T10:30:12 | 303,487,417 | 0 | 1 | null | 2020-11-28T08:37:36 | 2020-10-12T19:04:16 | Python | WINDOWS-1252 | C++ | false | false | 3,373 | cpp | Container.cpp | #include "Container.h"
#include "Cube.h"
#include "Cylinder.h"
#include "Tetrahedron.h"
#include <iostream>
#include <cassert>
using namespace std;
Container::Container(int size) {
this->size = size;
this->container = new Figure* [this->size];
}
void Container::push_back(Figure* figure) {
Figure** tempContainer = new Figure * [this->size + 1];
for (int i = 0; i < this->size; i++) {
tempContainer[i] = this->container[i];
}
tempContainer[this->size] = figure;
this->size++;
delete[] this->container;
this->container = tempContainer;
}
void Container::insert(Figure* figure, int index) {
Figure** tempContainer = new Figure * [this->size + 1];
for (int i = 0; i < index; i++) {
tempContainer[i] = this->container[i];
}
tempContainer[index] = figure;
for (int i = index + 1; i < this->size + 1; i++) {
tempContainer[i] = this->container[i - 1];
}
this->size++;
delete[] this->container;
this->container = tempContainer;
}
void Container::index_delete(int index) {
Figure** tempContainer = new Figure * [this->size - 1];
for (int i = 0; i < index; i++) {
tempContainer[i] = this->container[i];
}
for (int i = index; i < this->size; i++) {
tempContainer[i] = this->container[i + 1];
}
this->size--;
delete[] this->container;
this->container = tempContainer;
}
void Container::delete_back() {
Figure** tempContainer = new Figure * [this->size - 1];
for (int i = 0; i < this->size - 1; i++) {
tempContainer[i] = this->container[i];
}
this->size--;
delete[] this->container;
this->container = tempContainer;
}
Container* Container::containerInitialize() {
cout << "\nÂâåäèòå ðàçìåð êîíòåéíåðà >>> ";
int size;
cin >> size;
Container* container = new Container(0);
cout << "\nÂÂÎÄÈÒÅ ÄÀÍÍÛÅ\n";
for (int i = 0; i < size; i++) {
cout << endl;
cout << "1 - ÊÓÁ\n";
cout << "2 - ÖÈËÈÍÄÐ\n";
cout << "3 - ÒÅÒÐÀÅÄÐ\n";
cout << "\nÂûáåðèòå ôèãóðó >>> ";
int figure;
cin >> figure;
switch (figure) {
case 1:
cout << "\nÂâåäèòå äëèíó ðåáðà êóáà >>> ";
float edgeLength;
cin >> edgeLength;
container->push_back(new Cube(edgeLength));
break;
case 2:
cout << "\nÂâåäèòå âûñîòó öèëèíäðà >>> ";
float height;
cin >> height;
cout << "\nÂâåäèòå ðàäèóñ îñíîâàíèÿ öèëèíäðà >>> ";
float baseRadius;
cin >> baseRadius;
container->push_back(new Cylinder(height, baseRadius));
break;
case 3:
cout << "\nÂâåäèòå äëèíó ðåáðà òåòðàåäðà >>> ";
float edgeLength2;
cin >> edgeLength2;
container->push_back(new Tetrahedron(edgeLength2));
break;
default:
cout << "\n ÍÅÂÅÐÍÛÉ ÂÂÎÄ!!! \n";
i--;
break;
}
}
return container;
}
void Container::containerOutput() {
for (int i = 0; i < this->size; i++) {
if (this->container[i] != nullptr) {
this->container[i]->infoOutput();
}
}
}
int Container::getSize() {
return this->size;
}
Figure*& Container::operator [] (const int index) {
assert(index >= 0 && index < this->size);
return this->container[index];
}
Container::~Container() {
for (int i = 0; i < this->size; i++) {
if (this->container[i] != nullptr) {
delete this->container[i];
}
}
delete[] this->container;
} |
a070d2d15201664bc9b268658a5670bf42db0aca | 550ba921208b501f36af0f8d8a0e7ed491ae92fa | /SoftwareRenderer/Structs/Vector3.cpp | cdfa1e9b1f38f6db2d5da45155b527ef9a945165 | [] | no_license | damianGray77/SoftwareRenderer_old_and_decrepit | 538ecdfee26697fe0a7a876fa3ce3c5ed8a0dad5 | 174963dc74306db36d0c07bf41b9ebd0f3a23b7e | refs/heads/master | 2021-05-27T18:53:35.158741 | 2013-11-07T06:09:17 | 2013-11-07T06:09:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,648 | cpp | Vector3.cpp | #include "stdafx.h"
#include "Vector3.h"
const Vector3 Vector3::operator +(const Vector3 &v) {
Vector3 res = {
x + v.x,
y + v.y,
z + v.z,
};
return res;
}
const Vector3 Vector3::operator -(const Vector3 &v) {
Vector3 res = {
x - v.x,
y - v.y,
z - v.z,
};
return res;
}
const Vector3 Vector3::operator *(const Vector3 &v) {
Vector3 res = {
x * v.x,
y * v.y,
z * v.z,
};
return res;
}
const Vector3 Vector3::operator /(const Vector3 &v) {
Vector3 res = {
x / v.x,
y / v.y,
z / v.z,
};
return res;
}
const Vector3 Vector3::operator *(const FLOAT num) {
Vector3 res = {
x * num,
y * num,
z * num,
};
return res;
}
const Vector3 Vector3::operator /(const FLOAT num) {
Vector3 res = {
x / num,
y / num,
z / num,
};
return res;
}
const Vector3 Vector3::operator *(const Matrix4x4 &m) {
Vector3 res = {
(x * m._00) + (y * m._10) + (z * m._20) + m._30,
(x * m._01) + (y * m._11) + (z * m._21) + m._31,
(x * m._02) + (y * m._12) + (z * m._22) + m._32,
};
return res;
}
const Vector3 Vector3::operator *(const Matrix3x3 &m) {
Vector3 res = {
(x * m._00) + (y * m._10) + (z * m._20),
(x * m._01) + (y * m._11) + (z * m._21),
(x * m._02) + (y * m._12) + (z * m._22),
};
return res;
}
Vector3 &Vector3::operator +=(const Vector3 &v) {
x += v.x;
y += v.y;
z += v.z;
return *this;
}
Vector3 &Vector3::operator -=(const Vector3 &v) {
x -= v.x;
y -= v.y;
z -= v.z;
return *this;
}
Vector3 &Vector3::operator *=(const Vector3 &v) {
x *= v.x;
y *= v.y;
z *= v.z;
return *this;
}
Vector3 &Vector3::operator /=(const Vector3 &v) {
x /= v.x;
y /= v.y;
z /= v.z;
return *this;
}
Vector3 &Vector3::operator *=(const FLOAT num) {
x *= num;
y *= num;
z *= num;
return *this;
}
Vector3 &Vector3::operator /=(const FLOAT num) {
x /= num;
y /= num;
z /= num;
return *this;
}
Vector3 &Vector3::operator *=(const Matrix4x4 &m) {
FLOAT tX = (x * m._00) + (y * m._10) + (z * m._20) + m._30;
FLOAT tY = (x * m._01) + (y * m._11) + (z * m._21) + m._31;
FLOAT tZ = (x * m._02) + (y * m._12) + (z * m._22) + m._32;
x = tX;
y = tY;
z = tZ;
return *this;
}
Vector3 &Vector3::operator *=(const Matrix3x3 &m) {
FLOAT tX = (x * m._00) + (y * m._10) + (z * m._20);
FLOAT tY = (x * m._01) + (y * m._11) + (z * m._21);
FLOAT tZ = (x * m._02) + (y * m._12) + (z * m._22);
x = tX;
y = tY;
z = tZ;
return *this;
}
const BOOL Vector3::operator ==(const Vector3 &v){
return ((x >= v.x - FLT_MARGIN && x <= v.x + FLT_MARGIN) &&
(y >= v.y - FLT_MARGIN && y <= v.y + FLT_MARGIN) &&
(z >= v.z - FLT_MARGIN && z <= v.z + FLT_MARGIN));
}
const BOOL Vector3::operator !=(const Vector3 &v) {
return ((x < v.x - FLT_MARGIN || x > v.x + FLT_MARGIN) ||
(y < v.y - FLT_MARGIN || y > v.y + FLT_MARGIN) ||
(z < v.z - FLT_MARGIN || z > v.z + FLT_MARGIN));
}
const FLOAT Vector3::Magnitude(const Vector3 &v) {
return (FLOAT)sqrt((v.x * v.x) + (v.y * v.y) + (v.z * v.z));
}
const FLOAT Vector3::Dot(const Vector3 &v1, const Vector3 &v2) {
return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
}
const Vector3 Vector3::Cross(const Vertex3 &v1, const Vertex3 &v2) {
Vector3 res = {
(v1.y * v2.z) - (v1.z * v2.y)
, (v1.z * v2.x) - (v1.x * v2.z)
, (v1.x * v2.y) - (v1.y * v2.x)
};
return res;
}
const Vector3 Vector3::Cross(const Vector3 &v1, const Vector3 &v2) {
Vector3 res = {
(v1.y * v2.z) - (v1.z * v2.y)
, (v1.z * v2.x) - (v1.x * v2.z)
, (v1.x * v2.y) - (v1.y * v2.x)
};
return res;
}
const Vector3 Vector3::Normal(Vector3 &v) {
//return v / Magnitude(v);
return v * inverseSqrt((v.x * v.x) + (v.y * v.y) + (v.z * v.z));
}
|
edf521666ea525a63da57363e8f327bc558c09c7 | d0f84f51a7f29eb18c21613477df93770b7000b9 | /tests/derivatives/grad.hpp | 60b8477916f5728b184e8014a567e91424629895 | [] | no_license | mposypkin/bnbshmem | c360b5ba670efd32b2c7893f5168380b800f864a | e2c6d0dda6cd130b4bf036ea6251824bcd5b5c1c | refs/heads/master | 2021-12-15T01:29:27.362493 | 2021-12-12T09:37:42 | 2021-12-12T09:37:42 | 136,309,843 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,625 | hpp | grad.hpp | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: grad.hpp
* Author: alusov
*
* Created on June 24, 2017, 8:46 PM
*/
#ifndef GRAD_HPP
#define GRAD_HPP
#include <iostream>
#include <initializer_list>
#include <vector>
#include <algorithm>
#include <memory>
namespace snowgoose {
namespace derivative {
template <class T> class Grad
{
public:
Grad(const std::initializer_list<T> &lst);
Grad(const std::vector<T> &grad) : m_grad(grad) {}
Grad(std::size_t size, const T &t) : m_grad(size, t) {}
T operator[](std::size_t i) const;
Grad operator+(const Grad &y) const;
Grad operator-(const Grad &y) const;
Grad operator*(const T &y) const;
template<class T2, class T3> friend Grad<T2> operator*(const T3 &x, const Grad<T2> &y);
Grad operator/(const T &y) const;
template<class T2> friend std::ostream& operator<<(std::ostream & out, const Grad<T2> &y);
std::size_t size() const {return m_grad.size();}
bool IsZero() const{
for(const T &d : m_grad)
if(d!=0.0)
return false;
return true;
}
const T* getGrad() const { return m_grad.data(); };
private:
std::vector<T> m_grad;
};
template<class T> Grad<T>::Grad(const std::initializer_list<T> &lst) : m_grad(lst)
{
}
template<class T> T Grad<T>::operator[](std::size_t i) const
{
return m_grad[i];
}
template<class T> Grad<T> Grad<T>::operator+(const Grad &y) const //error control
{
std::size_t sz = m_grad.size();
std::vector<T> grad(sz);
for(int i=0; i < sz; i++)
grad[i] = m_grad[i]+y.m_grad[i];
return Grad<T>(grad);
}
template<class T> Grad<T> Grad<T>::operator-(const Grad &y) const //error control
{
std::size_t sz = m_grad.size();
std::vector<T> grad(sz);
for(int i=0; i < sz; i++)
grad[i] = m_grad[i]-y.m_grad[i];
return Grad<T>(grad);
}
template<class T> Grad<T> Grad<T>::operator*(const T &y) const
{
std::size_t sz = m_grad.size();
std::vector<T> grad(sz);
for(int i=0; i < sz; i++)
grad[i]=m_grad[i]*y;
return grad;
}
template<class T2, class T3> Grad<T2> operator*(const T3 &x, const Grad<T2> &y)
{
std::size_t sz = y.m_grad.size();
std::vector<T2> grad(sz);
for(int i=0; i < sz; i++)
grad[i]=y.m_grad[i]*x;
return grad;
}
template<class T> Grad<T> Grad<T>::operator/(const T &y) const //error control
{
std::size_t sz = m_grad.size();
std::vector<T> grad(sz);
for(int i=0; i < sz; i++)
grad[i]=m_grad[i]/y;
return grad;
}
template<class T2> std::ostream& operator<<(std::ostream & out, const Grad<T2> &y)
{
std::size_t sz = y.m_grad.size();
for(int i=0; i< sz; i++)
std::cout << y[i] << ' ';
return out;
}
}
}
#endif /* GRAD_HPP */
|
d8bbeb8b0b7459c773cc02594f1bce97ebaac875 | 190f998aeaf776c82bf7c7fbce226df7ab4942ea | /src/formula.cpp | 134ebb486aaceaf99b326074b1e65fcca05af86e | [
"MIT"
] | permissive | eryxcc/lois | f83253b89a52dcdf84e83265b65ee57f0a5d9ae0 | 9fe3d85b17398bc41b23505fdeca3d13a1327b7a | refs/heads/master | 2021-01-10T23:48:21.602184 | 2018-01-21T19:31:32 | 2018-01-21T19:31:32 | 70,793,562 | 4 | 1 | null | 2017-06-06T17:34:42 | 2016-10-13T10:00:36 | C++ | UTF-8 | C++ | false | false | 21,263 | cpp | formula.cpp | #include "../include/loisinternal.h"
namespace lois {
void subJoin(std::shared_ptr<Subdomain>& s1, std::shared_ptr<Subdomain>& s2);
std::shared_ptr<Subdomain> subJoin(const term& t1, const term &t2);
std::shared_ptr<Subdomain> subGet(vptr v);
std::shared_ptr<Subdomain> subGet(const term& t);
int triesleft, vids, checkid;
#define CountOnce(x) (qty[0]++?0:x)
std::ostream& operator << (std::ostream& os, rbool a) { return a->display(os); }
// a shorthand for negation
rbool operator ! (rbool a) { return a->negate(); }
// a fixed rbool (either true or false)
struct FormulaFixed : Formula {
bool type;
FormulaFixed(bool t) : type(t) {}
std::ostream& display (std::ostream &os) const {
// fixed formulae usually are simplified and thus not sent to a solver
if(outlan == CVC3) return os << (type ? "(1=1)" : "(1=0)");
return os << (type ? "true" : "false");
}
virtual rbool subst(const varsubstlist& l) const { return type ? ftrue : ffalse; }
rbool negate() { return type ? ffalse : ftrue; }
bool verify() {
#ifdef AGGSYM
qty[type]++;
#endif
return type; }
virtual bool uses(vptr v) { return false; }
void initDomains() {}
void listFeatures(featurelist& f) {}
#ifdef AGGSYM
rbool qsimplify2() { return type ? ftrue : ffalse; }
int formulasize() { return 1; };
#endif
};
bool isused(vptr v, rbool phi) { return phi.p->uses(v); }
rbool ftrue(std::make_shared<FormulaFixed> (true));
rbool ffalse(std::make_shared<FormulaFixed> (false));
// a Boolean conjunctive, type is true for "AND", false for "OR"
struct FormulaBi : Formula {
bool type;
rbool left, right;
vptr lastusecheck; int usestat;
FormulaBi(bool t, rbool l, rbool r) : type(t), left(l), right(r) {
// vl_merge(fv, left->fv, right->fv);
}
std::ostream& display (std::ostream &os) const {
if(outlan == CVC3)
return os << "(" << left << (type ? " AND " : " OR ") << right << ")";
if(outlan == SMT || outlan == SMT_INC)
return os << "(" << (type ? "and " : "or ") << iindent << left << ieol << right << ieol << ")" << iunindent;
if(outlan == SPASS)
return os << (type ? "and " : "or ") << "(" << iindent << left << "," << ieol << right << ieol << ")" << iunindent;
left->display(os, type ? 1:2);
os << (type ? sym._and : sym._or);
return right->display(os, type ? 1:2);
}
virtual std::ostream& display (std::ostream &os, int prio) {
if(prio != (type?1:2)) { os << "("; display(os); return os << ")"; }
return display(os);
}
virtual rbool subst(const varsubstlist& l) const {
if(l.size() == 1 && l[0].first == lastusecheck && usestat < 3) {
if(usestat == 1 && type)
return substitute(left, l) && right;
if(usestat == 1 && !type)
return substitute(left, l) || right;
if(usestat == 2 && type)
return left && substitute(right, l);
if(usestat == 2 && !type)
return left || substitute(right, l);
}
if(type) return substitute(left, l) && substitute(right, l);
return substitute(left, l) || substitute(right, l);
// make_shared<FormulaBi> (type, left->alph(v1,v2), right->alph(v1,v2));
}
rbool negate() {
return rbool(std::make_shared<FormulaBi> (!type, !left, !right));
}
bool verify() {
bool b;
if(type) b= left->verify() && right->verify();
else b= left->verify() || right->verify();
#ifdef AGGSYM
qty[b]++;
#endif
return b;
}
bool uses(vptr v) {
if(v == lastusecheck) return usestat;
lastusecheck = v; usestat = 0;
if(left->uses(v)) usestat |= 1;
if(right->uses(v)) usestat |= 2;
return usestat; }
term valueKnown(vptr v, bool negated) {
// non-negated: AND => at least one
if(negated == type) {
// OR: both need the same value
term v1 = left->valueKnown(v, negated);
term v2 = right->valueKnown(v, negated);
if(v1.p == v2.p) return v1;
return nullterm;
}
else {
term v1 = left->valueKnown(v, negated);
if(v1.p) return v1;
return right->valueKnown(v, negated);
}
}
#ifdef AGGSYM
rbool qsimplify2() {
if(type) return left->qsimplify() && right->qsimplify();
else return left->qsimplify() || right->qsimplify();
}
void clearinfo() { qty[0] = qty[1] = 0; left->clearinfo(); right->clearinfo(); }
int formulasize() { return left->formulasize() + 1 + right->formulasize(); };
#endif
void initDomains() { left->initDomains(); right->initDomains(); }
void listFeatures(featurelist& f) { left->listFeatures(f); right->listFeatures(f); }
};
// an equality (type=true) or inequality (type=false)
struct FormulaEq : Formula {
bool type;
term t1, t2;
FormulaEq(bool t, term v1, term v2) : type(t), t1(v1), t2(v2) {
// todo
// if(t1 == t2) aerror("ta sama zmienna", t1, t2);
/* if(v1->sortid < v2->sortid) {
fv.push_back(v1);
fv.push_back(v2);
}
else {
fv.push_back(v2);
fv.push_back(v1);
} */
}
std::ostream& display (std::ostream &os) const {
if((outlan == SMT || outlan == SMT_INC) && type)
return os << "(= " << t1 << " " << t2 << ")";
if((outlan == SMT || outlan == SMT_INC) && !type)
return os << "(not (= " << t1 << " " << t2 << "))";
if(outlan == SPASS && type)
return os << "equal(" << t1 << ", " << t2 << ")";
if(outlan == SPASS && !type)
return os << "not(equal(" << t1 << ", " << t2 << "))";
return os << t1 << (type ? sym.eq : sym.neq) << t2;
}
virtual rbool subst(const varsubstlist& l) const {
if(type)
return substitute(t1, l) == substitute(t2, l);
return substitute(t1, l) != substitute(t2, l);
}
rbool negate() { return rbool(std::make_shared<FormulaEq> (!type, t1, t2)); }
bool verify() {
bool b;
if(type) b= t1.p->getValue() == t2.p->getValue();
else b = t1.p->getValue() != t2.p->getValue();
#ifdef AGGSYM
qty[b]++;
#endif
return b;
}
bool uses(vptr v) { return t1.p->uses(v) || t2.p->uses(v); }
term valueKnown(vptr v, bool negated) {
// non-negated: AND => at least one
if(negated == !type) {
if(t1.asVar() == v && t2.asVar()) return term(t2.asVar());
if(t2.asVar() == v && t1.asVar()) return term(t1.asVar());
}
return nullterm;
}
#ifdef AGGSYM
rbool qsimplify2() {
return rbool(std::make_shared<FormulaEq> (type, t1, t2));
}
int formulasize() { return 1; };
#endif
void initDomains() { subJoin(t1, t2)->numEq++; }
void listFeatures(featurelist& f) { t1.p->listFeatures(f); t2.p->listFeatures(f); }
};
struct FormulaBinary : Formula {
int id;
Relation *rel;
term t1, t2;
FormulaBinary(Relation *r, int i, term v1, term v2) : id(i), rel(r), t1(v1), t2(v2) {
/* if(v1->sortid < v2->sortid) {
fv.push_back(v1);
fv.push_back(v2);
}
else {
fv.push_back(v2);
fv.push_back(v1);
} */
}
std::ostream& display (std::ostream &os) const {
rel->display(os, id, t1, t2);
return os;
}
rbool subst(const varsubstlist& l) const {
return rel->binform(id, substitute(t1,l), substitute(t2,l));
}
rbool negate() { return rel->binform(rel->negate(id), t1, t2); }
bool verify() {
std::shared_ptr<Subdomain> d = subGet(t1);
if(d != subGet(t2)) throw subdomain_exception();
int i = 0;
while(d->rels[i]->rel != rel) i++;
bool b = d->rels[i]->check(id, t1.p->getValue(), t2.p->getValue());
#ifdef AGGSYM
qty[b]++;
#endif
return b;
}
bool uses(vptr v) { return t1.p->uses(v) || t2.p->uses(v); }
term valueKnown(vptr v, bool negated) {
return nullterm;
}
#ifdef AGGSYM
rbool qsimplify2() {
return rel->binform(id, t1, t2);
}
int formulasize() { return 1; };
#endif
void initDomains() {
subJoin(t1, t2)->useRelation(rel);
}
void listFeatures(featurelist& f) {
t1.p->listFeatures(f); t2.p->listFeatures(f);
f.relations.insert(rel);
}
};
std::ostream& FormulaQ::display (std::ostream &os) const {
if(!var.size()) return os << right;
if(outlan == CVC3) {
os << (type ? "(FORALL(" : "(EXISTS(");
bool comma = false;
for(auto v: var) {
if(comma) os << ", ";
comma = true;
os << v << ":" << v->dom->name;
}
return os << "): " << right << ")";
}
if(outlan == SMT) {
os << (type ? "(forall " : "(exists ");
for(auto v: var) {
os << "(" << v << " " << v->dom->name << ") ";
}
return os << iindent << right << ieol << ")" << iunindent;
}
if(outlan == SMT_INC) {
os << (type ? "(forall (" : "(exists (");
for(auto v: var) {
os << "(" << v << " " << smtsort() << ") ";
}
return os << ")" << iindent << right << ieol << ")" << iunindent;
}
if(outlan == SPASS) {
os << (type ? "forall([ " : "exists([ ");
bool had = false;
for(auto v: var) {
if(had) os << ", ";
os << v->dom->name << "(" << v << ")"; had = true;
}
return os << "], " << iindent << right << ieol << ")" << iunindent;
}
os << (type ? sym.forall : sym.exists);
for(auto v: var) {
os << v << sym.in << v->dom->name;
/* os << "[" << subFindv(v);
auto dom = subGet(v);
if(dom->numOrder) os << "!";
if(dom->numEdge) os << "?";
// os << dom->numEq << ":" << dom->numNeq << ":" << dom->numQuantifier << ":" << dom->numOrder;
os << "]"; */
os << " ";
}
return os << right;
}
void decomposeBin(rbool b, bool bt, std::vector<rbool>& v) {
auto dec = std::dynamic_pointer_cast<FormulaBi> (b.p);
if(dec && dec->type == bt) {
decomposeBin(dec->left, bt, v);
decomposeBin(dec->right, bt, v);
}
else
v.push_back(b);
}
rbool FormulaQ::simplify(std::shared_ptr<FormulaQ> def) {
using namespace std;
// we know the value of something, maybe?
for(size_t i=0; i<var.size(); i++) {
vptr v = var[i];
if(!right->uses(v)) {
var[i] = var[var.size()-1];
var.pop_back(); i--;
}
else {
term v1 = right->valueKnown(v, type);
if(v1.p) {
right = substitute(right, v, v1);
var[i] = var[var.size()-1];
var.pop_back(); i--;
}
}
}
// no variables
if(!var.size()) return right;
// quantified true/false
auto fix = std::dynamic_pointer_cast<FormulaFixed> (right.p);
if(fix) return right;
/*
// quantified binary, one side does not use the vars
auto bin = std::dynamic_pointer_cast<FormulaBi> (right.p);
if(bin) {
bool leftuses = false, rightuses = false;
for(auto v: var) leftuses |= bin->left->uses(v), rightuses |= bin->right->uses(v);
if(!leftuses && bin->type == true) return bin->left && makeq(type, bin->right, var);
if(!rightuses && bin->type == true) return bin->right && makeq(type, bin->left, var);
if(!leftuses && bin->type == false) return bin->left || makeq(type, bin->right, var);
if(!rightuses && bin->type == false) return bin->right || makeq(type, bin->left, var);
} */
// quantified (in)equality
// as long as we assume that !right->unused(all vars),
// and that they are variables,
// we know the value
auto eq = std::dynamic_pointer_cast<FormulaEq> (right.p);
if(eq && eq->t1.asVar() && eq->t2.asVar()) return type ? ffalse : ftrue;
// take the independent components out of the quantifier
auto bin = std::dynamic_pointer_cast<FormulaBi> (right.p);
if(bin) {
bool btype = bin->type;
std::vector<rbool> phi;
std::vector<int> vused;
decomposeBin(right, btype, phi);
bool suc = false;
for(size_t k=0; k<phi.size(); k++) {
size_t li = 0;
for(size_t i=0; i<var.size(); i++)
if(phi[k]->uses(var[i])) li = i+1;
if(li < var.size()) suc = true;
vused.push_back(li);
}
if(suc) {
for(int k=1; k<phi.size(); ) {
if(k && vused[k] < vused[k-1])
std::swap(vused[k], vused[k-1]), std::swap(phi[k], phi[k-1]), k--;
else
k++;
}
int at = phi.size()-1;
rbool nphi = phi[at];
int lev = vused[at];
/* std::cout << "SIMPLIFYING: ";
display(std::cout);
std::cout << std::endl;
for(int k=0; k<phi.size(); k++)
std::cout << k << "." << vused[k] << ") " << phi[k] << std::endl; */
while(true) {
at--;
int nlev = at >= 0 ? vused[at] : 0;
if(lev > nlev) {
varlist v;
while(lev > nlev) { lev--; v.push_back(var[lev]); }
nphi = makeq(type, nphi, v);
}
if(at < 0) {
/* std::cout << "SIMPLIFIED: ";
display(std::cout);
std::cout << " TO: " << nphi << std::endl; */
return nphi;
}
else if(btype) nphi = phi[at] && nphi;
else nphi = phi[at] || nphi;
}
}
}
return rbool(def);
}
bool FormulaQ::verifyAt(int at) {
if(at == -1) return right->verify();
auto dom = subGet(var[at]);
int& nextval(dom->nextval);
triesleft -= nextval;
if(triesleft < 0) return false;
for(int z=0; z<nextval; z++) {
var[at]->value = z;
if(verifyAt(at-1) != type) return !type;
}
var[at]->value = nextval;
nextval++;
bool b = generateAll(at, dom, nextval-1, 0);
nextval--;
return b;
}
bool FormulaQ::generateAll(int at, std::shared_ptr<Subdomain>& dom, int val, int rid) {
if(rid >= int(dom->rels.size())) {
if(val < dom->nextval-1)
return generateAll(at, dom, val+1, 0);
else
return verifyAt(at-1);
}
else return dom->rels[rid]->exists(this, at, dom, val, rid);
}
term FormulaQ::valueKnown(vptr v, bool negated) {
term v1 = right->valueKnown(v, negated);
if(!v1.p) return v1;
for(auto qx: var) if(qx == v1.asVar()) {
// should not happen if simplified!
std::cout << "should not happen: v= " <<v << " rbool= ";
display(std::cout); std::cout << std::endl;
term vk = right->valueKnown(qx, type);
if(!vk.p) std::cout << "value unknown!" << std::endl;
else std::cout << "valueKnown is " << vk <<std::endl;
return nullterm;
}
return v1;
}
void FormulaQ::initDomains() {
for(auto q: var) subGet(q)->numQuantifier++;
right->initDomains();
}
rbool makeq(bool t, rbool r, const varlist& va) {
auto q = std::make_shared<FormulaQ> (t,r,va);
return q->simplify(q);
}
// AND and OR, more effective than using FormulaBi due to simplifications
rbool operator && (rbool a, rbool b) {
if(a.isTrue()) return b;
if(b.isTrue()) return a;
if(a.isFalse() || b.isFalse()) return ffalse;
if(a.p == b.p) return a;
auto ae = std::dynamic_pointer_cast<FormulaEq>(a.p);
auto be = std::dynamic_pointer_cast<FormulaEq>(b.p);
if(ae) if(be) {
if(eqterm(ae->t1, be->t1) && eqterm(ae->t2, be->t2))
return ae->type == be->type ? a : ffalse;
if(eqterm(ae->t1, be->t2) && eqterm(ae->t2, be->t1))
return ae->type == be->type ? a : ffalse;
}
// if(a->formulasize() > b->formulasize()) swap(a, b);
return rbool(std::make_shared<FormulaBi> (true, a, b));
}
rbool operator || (rbool a, rbool b) {
if(a.isFalse()) return b;
if(b.isFalse()) return a;
if(a.isTrue() || b.isTrue()) return ftrue;
if(a.p == b.p) return a;
auto ae = std::dynamic_pointer_cast<FormulaEq>(a.p);
auto be = std::dynamic_pointer_cast<FormulaEq>(b.p);
if(ae) if(be) {
if(eqterm(ae->t1, be->t1) && eqterm(ae->t2, be->t2)) {
return ae->type == be->type ? a : ftrue;
}
if(eqterm(ae->t1, be->t2) && eqterm(ae->t2, be->t1)) {
return ae->type == be->type ? a : ftrue;
}
}
return rbool(std::make_shared<FormulaBi> (false, a, b));
}
rbool operator == (const term& a, const term& b) {
if(a.p->getDom() != b.p->getDom()) return ffalse;
if(eqterm(a, b)) return ftrue;
else return rbool(std::make_shared<FormulaEq> (true, a, b));
}
rbool operator != (const term& a, const term& b) {
if(a.p->getDom() != b.p->getDom()) return ftrue;
if(eqterm(a, b)) return ffalse;
return rbool(std::make_shared<FormulaEq> (false, a, b));
}
rbool makebinary(Relation *rel, int id, const term& a, const term& b) {
return rbool(std::make_shared<FormulaBinary> (rel,id,a,b));
}
void Subdomain::useRelation(Relation *r) {
for(size_t i=0; i<rels.size(); i++)
if(rels[i]->rel == r) return;
rels.push_back(r->genSub());
}
void autoname(std::ostream& os, int id) {
if(id >= 26) autoname(os, id/26-1);
os << char('a' + (id%26));
}
int sortids = 0;
std::string autoprefix = "";
std::ostream& Variable::display (std::ostream& os) const {
if(!id) id = ++vids;
if(outlan == SMT || outlan == SMT_INC) os << "?";
if(outlan == SPASS) os << "lois";
if(name != "") os << name;
else { os << autoprefix; autoname(os, id-1); }
return os;
}
std::shared_ptr<Subdomain> nullsub;
// Find & Union
void subInit(vptr v) {
if(v->curcheck < checkid) {
v->curcheck = checkid;
v->sublink = v;
v->sub = nullsub;
}
}
int recdepth;
vptr Variable::subFindv(tvptr v) {
vptr vv = std::dynamic_pointer_cast<Variable> (v);
subInit(vv);
vv->sublink = (vv->sublink == vv) ? vv : subFindv(vv->sublink);
return vv->sublink;
}
void subJoin(std::shared_ptr<Subdomain>& s1, std::shared_ptr<Subdomain>& s2);
vptr TermBinary::subFindv(tvptr v) {
if(v->curcheck < checkid) {
vptr v1 = left.p->subFindv(left.p);
vptr v2 = right.p->subFindv(right.p);
if(v1 == nullvptr) return v2;
if(v2 == nullvptr) return v1;
if(v1->sublink != v2->sublink) {
v2->sublink = v1->sublink;
subJoin(v1->sub, v2->sub);
}
if(!v1->sub) v1->sub = std::make_shared<Subdomain> ();
v1->sub->useRelation(r);
sublink = v1->sublink;
}
return sublink;
}
vptr TermConst::subFindv(tvptr inv) {
vptr vv = std::dynamic_pointer_cast<Variable> (inv);
if(!vv) vv = v;
subInit(vv);
vv->sublink = (vv->sublink == vv) ? vv : subFindv(vv->sublink);
return vv->sublink;
}
void TermBinary::listFeatures(featurelist& f) {
f.relations.insert(r);
left.p->listFeatures(f);
right.p->listFeatures(f);
}
void TermConst::listFeatures(featurelist& f) {
f.relations.insert(r);
}
void Variable::listFeatures(featurelist& f) {
f.domains.insert(dom);
}
std::shared_ptr<Subdomain> subGet(vptr v) {
v = v->subFindv(v);
if(!v->sub) v->sub = std::make_shared<Subdomain> ();
return v->sub;
}
std::shared_ptr<Subdomain> subGet(const term& t) {
vptr v = t.p->subFindv(t.p);
if(v == nullvptr) return nullsub;
if(!v->sub) v->sub = std::make_shared<Subdomain> ();
return v->sub;
}
void subJoin(std::shared_ptr<Subdomain>& s1, std::shared_ptr<Subdomain>& s2) {
if(s2 == nullsub) return;
if(s1 == nullsub) { swap(s1, s2); return; }
s1->numEq += s2->numEq;
s1->numQuantifier += s2->numQuantifier;
for(size_t i=0; i<s2->rels.size(); i++)
s1->useRelation(s2->rels[i]->rel);
s2 = nullsub;
}
std::shared_ptr<Subdomain> subJoin(const term& t1, const term &t2) {
vptr v1 = t1.p->subFindv(t1.p);
vptr v2 = t2.p->subFindv(t2.p);
if(v1->sublink != v2->sublink) {
v2->sublink = v1->sublink;
subJoin(v1->sub, v2->sub);
}
if(!v1->sub) v1->sub = std::make_shared<Subdomain> ();
return v1->sub;
}
int TermBinary::getValue() {
std::shared_ptr<Subdomain> d = subGet(left);
if(d != subGet(right)) throw subdomain_exception();
int i = 0;
while(d->rels[i]->rel != r) i++;
int r = d->rels[i]->checkterm(op, left.p->getValue(), right.p->getValue());
return r;
}
int TermConst::getValue() {
return r->checktermconst(op);
}
vptr term::asVar() const { return std::dynamic_pointer_cast<Variable> (p); }
term::term(tvptr v) : p(v) {}
std::ostream& operator << (std::ostream& os, vptr a) { return a->display(os); }
term substitute(vptr vthis, const varsubstlist& l) {
for(auto& p: l) if(vthis == p.first) return p.second;
return term(vthis);
}
// alpha-convert the term 'tthis' from 'v1' to 'v2'
term substitute(const term& tthis, const varsubstlist& l) {
return tthis.p->subst(tthis, l);
}
bool isused(vptr vthis, vptr v) {
return vthis == v;
}
/*
void vl_merge(varlist& vres, const varlist& v1, const varlist& v2) {
vres.clear();
size_t i = 0;
size_t j = 0;
while(i < v1.size() && j<v2.size())
if(v1[i]->sortid < v2[j]->sortid) vres.push_back(v1[i++]); else
if(v1[i]->sortid > v2[j]->sortid) vres.push_back(v2[j++]); else
vres.push_back(v1[i++]), j++;
while(i < v1.size()) vres.push_back(v1[i++]);
while(j < v2.size()) vres.push_back(v2[j++]);
}
// remove all variables in v2 from v1
void vl_split(varlist& vres, const varlist& v1, const varlist& v2) {
vres.clear();
size_t i = 0;
size_t j = 0;
while(i < v1.size() && j<v2.size())
if(v1[i]->sortid < v2[j]->sortid) vres.push_back(v1[i++]); else
if(v1[i] == v2[j]) i++, j++; else
j++;
while(i < v1.size()) vres.push_back(v1[i++]);
}
*/
rbool makequantifier(bool f, rbool& phi, varlist to_quantify) {
auto sphi = std::make_shared<FormulaQ> (f, phi, to_quantify);
return sphi->simplify(sphi);
}
rbool substitute(const rbool& phi, const varsubstlist& l) {
return phi->subst(l);
}
term valueKnown(rbool& phi, vptr v, bool negated) {
return phi->valueKnown(v, negated);
}
const term nullterm;
}
|
8a8e4cfbe182ce81fd48978d05ea50fb1f4873cd | 9b8147ba98c8d335505cb899ff7a3222c6f44a24 | /src/won_game/WonGameUpdateHandler.cpp | eebdafda51b509ee998d7c00d4820054a14e9e5b | [] | no_license | carcag/gauntlet | 582848e74b30526906be815df32aa3aad1565943 | d8956cef85ce9a323d3a1a067913586312b8eade | refs/heads/master | 2021-01-21T15:00:37.041360 | 2017-05-22T07:33:07 | 2017-05-22T07:33:07 | 91,828,594 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 358 | cpp | WonGameUpdateHandler.cpp | #include "WonGameUpdateHandler.hpp"
#include "StateManager.hpp"
WonGameUpdateHandler::WonGameUpdateHandler() {
}
WonGameUpdateHandler::~WonGameUpdateHandler() {
}
void WonGameUpdateHandler::HandleUpdate(std::list<Entity *>& entities) const {
for (std::list<Entity *>::iterator it = entities.begin(); it != entities.end(); it++) {
(*it)->Update();
}
}
|
2e68afdb2b657f3ed005ab0b6e77e0186324392c | 8f0588f3af7b617becd409dde57d2111a67247bd | /main.cpp | 41fb839b338ff1f3eca0828c3be1774e540f4a85 | [] | no_license | alvin-xian/QmlOpenglItem | 770140e4839f6bae853850176cec6a3234c814b1 | 87ffa684d39538d1b4b8c1d802d1e22b05a9af7f | refs/heads/master | 2021-03-07T17:04:55.789345 | 2020-06-09T04:58:03 | 2020-06-09T04:58:03 | 246,281,569 | 7 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 986 | cpp | main.cpp | #include <QtCore/qglobal.h>
#if QT_VERSION >= 0x050000
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#else
#endif
#include "qmlopenglitem.h"
int main(int argc, char *argv[])
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
// QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
QGuiApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#endif
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<QmlOpenglItem>("QmlOpenglItem", 1, 0, "QmlOpenglItem");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
|
da4f7fc52e177871b8589c1bec5f2d87d59a9219 | e6a55cfb3491c6bd6db8bc91bb1676faa78a3ea2 | /source/Components/Setting.cpp | 061bc6da9e334e85a16738823dbfbe2f0411b3c0 | [
"MIT"
] | permissive | 1pkg/halfo | 6c033c30e50ff82a263aa479ccbdeb59cf10117c | a57dc4b68d29165d6ab7ed36c7886326e414e269 | refs/heads/master | 2020-07-25T02:55:19.743753 | 2019-09-12T20:30:33 | 2020-04-26T17:09:17 | 208,142,067 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 978 | cpp | Setting.cpp | #include "constants.hpp"
#include "Setting.hpp"
namespace Components
{
const std::string Setting::PARAMETER_FIGURE_RESOURCE = "figure";
const std::string Setting::PARAMETER_BLADE_RESOURCE = "hammer";
const std::string Setting::FLAG_ADDS_DISABLED = "adds-disables";
const std::string Setting::FLAG_DEPLOY_FINISHED = "deploy-finished";
void
Setting::initialize()
{
_settings.insert(std::pair<std::string, std::string>(PARAMETER_FIGURE_RESOURCE, "figure-deault"));
_settings.insert(std::pair<std::string, std::string>(PARAMETER_BLADE_RESOURCE, "blade-crystal"));
_settings.insert(std::pair<std::string, std::string>(FLAG_ADDS_DISABLED, FLAG_NON));
_settings.insert(std::pair<std::string, std::string>(FLAG_DEPLOY_FINISHED, FLAG_NON));
}
const std::string &
Setting::get(const std::string & setting) const
{
return _settings.find(setting)->second;
}
void
Setting::set(const std::string & setting, const std::string & value)
{
_settings.find(setting)->second = value;
}
} |
7887f6ff23c62b6a20dfaca56fbb6ee68b178e75 | c8303fc4440df0409d14cfba1a3243fdc657bc10 | /include/rusty_cpp/iter/enumerate.h | c09829924e3bf0d8c5bd403532f92b50d723314a | [
"MIT"
] | permissive | EFanZh/rusty_cpp | 366718eca597627da20fd10c52ec5434457335ff | 985dd8992a978b47107ad60563d57e31212f32eb | refs/heads/master | 2021-04-10T00:42:06.887165 | 2020-03-22T03:22:07 | 2020-03-22T03:22:07 | 248,897,965 | 0 | 0 | MIT | 2020-03-22T03:23:17 | 2020-03-21T03:15:07 | C++ | UTF-8 | C++ | false | false | 2,884 | h | enumerate.h | #ifndef RUSTY_CPP_ITER_ENUMERATE_H
#define RUSTY_CPP_ITER_ENUMERATE_H
#include <iterator>
#include <rusty_cpp/iter/utilities.h>
#include <tuple>
namespace rusty_cpp::iter::enumerate {
template <class I, class N>
class Iterator {
static_assert(utilities::IsGoodObjectMemberV<I>);
static_assert(utilities::IsGoodObjectMemberV<N>);
I iter;
N count;
using BaseCategory = typename std::iterator_traits<I>::iterator_category;
public:
using difference_type = typename std::iterator_traits<I>::difference_type;
using value_type = std::tuple<N, typename std::iterator_traits<I>::reference>;
using pointer = void;
using reference = value_type;
using iterator_category = std::conditional_t<std::is_base_of_v<std::random_access_iterator_tag, BaseCategory>,
std::random_access_iterator_tag,
BaseCategory>;
Iterator(I iter, N count) : iter{iter}, count{count} {
}
bool operator==(Iterator rhs) const {
return this->iter == rhs.iter;
}
bool operator!=(Iterator rhs) const {
return this->iter != rhs.iter;
}
Iterator &operator++() {
++this->iter;
++this->count;
return *this;
}
reference operator*() const {
return reference{this->count, *this->iter};
}
auto operator-(Iterator rhs) const {
return this->iter - rhs.iter;
}
auto operator[](difference_type key) const {
return reference{this->count + static_cast<N>(key), this->iter[key]};
}
};
template <class I, class N>
Iterator<I, N> make_iterator(I iter, N count) {
return Iterator<I, N>{iter, count};
}
template <class C, class N>
class Enumerate {
static_assert(std::is_lvalue_reference_v<C> || (std::is_object_v<C> && !std::is_const_v<C>));
static_assert(std::is_object_v<N> && !std::is_const_v<N>);
C container;
N count;
public:
Enumerate(C &&container, N &&count) : container{std::forward<C>(container)}, count{std::forward<N>(count)} {
}
auto begin() {
return make_iterator(std::begin(this->container), std::forward<N>(this->count));
}
auto begin() const {
return make_iterator(std::begin(this->container), std::forward<const N>(this->count));
}
auto end() {
return make_iterator(std::end(this->container), std::forward<N>(this->count));
}
auto end() const {
return make_iterator(std::end(this->container), std::forward<const N>(this->count));
}
auto size() const {
return this->container.size();
}
};
template <class C, class N>
Enumerate<C, N> make_enumerate(C &&container, N &&count) {
return Enumerate<C, N>{std::forward<C>(container), std::forward<N>(count)};
}
} // namespace rusty_cpp::iter::enumerate
#endif // RUSTY_CPP_ITER_ENUMERATE_H
|
691de01ad3412f9fbc152ffcf33293bbc2177599 | 1a61e8d323e98836efe55fa34704031244feb5ac | /openMSYNC/server/Admin/MainFrm.h | 693d95211abfd5f015afc35878496db1f5a09f1d | [] | no_license | skwoo/openLamp | 0d37c59d239af6c851cfff48d5db5e32511ceae3 | 68bffd42f91a9978b4c8bf1df1b39f821acbe093 | refs/heads/master | 2022-01-10T04:40:30.881034 | 2019-07-05T04:04:48 | 2019-07-05T04:04:48 | 106,556,078 | 0 | 1 | null | 2019-07-05T04:04:49 | 2017-10-11T13:12:58 | C | ISO-8859-1 | C++ | false | false | 3,715 | h | MainFrm.h | /*
This file is part of openMSync Server module, DB synchronization software.
Copyright (C) 2012 Inervit Co., Ltd.
support@inervit.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__D289274A_DCD0_4DBD_8BF4_E224BB1437EB__INCLUDED_)
#define AFX_MAINFRM_H__D289274A_DCD0_4DBD_8BF4_E224BB1437EB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define MODIFY_LEFT 0
#define MODIFY_RIGHT 1
#define COPY_LEFT 2
#define COPY_RIGHT 3
#define REPORT_STYLE 0
#define FOLDER_STYLE 1
#define APP_STYLE 2
#define DSN_STYLE 3
#define TABLE_STYLE 4
#define MENU_USER_MGR 0
#define MENU_USER_PROFILE 1
#define MENU_CONNECTED_USER 2
#define MENU_SYNC_SCRIPT_MGR 3
#define MENU_LOG_MGR 4
#define APP_LEVEL 31
#define DSN_LEVEL 32
#define TABLE_LEVEL 33
#define ORACLE 1
#define MSSQL 2
#define MYSQL 3
#define ACCESS 4
#define SYBASE 5
#define CUBRID 6
#define DB2 7
class CRightListView;
class CRightView;
class CLeftTreeView;
class CSQLDirect;
#include "MSyncIPBar.h"
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
BOOL m_bConnectFlag;
CSplitterWnd m_wndSplitter;
CLeftTreeView* m_pLeftTreeView;
CRightListView* m_pRightListView;
CRightView* m_pRightView;
CString m_strDSNName;
CString m_strPWD;
CString m_strLoginID;
int m_nDBType;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
//}}AFX_VIRTUAL
// Implementation
public:
void GetDBServerType(CString strDSNName);
int GetFileCount(CString strItem);
BOOL DeleteTableScript(CSQLDirect *aSD, CString tableID);
BOOL DeleteDSNTableScript(CSQLDirect *aSD1, CSQLDirect *aSD2, CString strDBID);
BOOL CheckDBSetting();
void ShowSystemDSN(CComboBox *pWnd);
void ChangeTitleText(CString strTitle);
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
// CToolBar m_wndToolBar; // 2003.8.20 toolbar¿¡ mSync IP º¸À̰Ô
CMSyncIPBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnMenuCreatedsn();
afx_msg void OnMenuNewSyncScript();
afx_msg void OnMenuDBConnect();
afx_msg void OnMenuDBDisConnect();
afx_msg void OnMenuNewUser();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__D289274A_DCD0_4DBD_8BF4_E224BB1437EB__INCLUDED_)
|
6490269999ff730ab8223593ae0ad0303273cd63 | 428989cb9837b6fedeb95e4fcc0a89f705542b24 | /erle/ros2_ws/install/include/std_msgs/msg/dds_opensplice/Float64_Dcps_impl.cpp | e379498e935500b5118c38870081b7d33952ca65 | [] | no_license | swift-nav/ros_rover | 70406572cfcf413ce13cf6e6b47a43d5298d64fc | 308f10114b35c70b933ee2a47be342e6c2f2887a | refs/heads/master | 2020-04-14T22:51:38.911378 | 2016-07-08T21:44:22 | 2016-07-08T21:44:22 | 60,873,336 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 117 | cpp | Float64_Dcps_impl.cpp | /home/erle/ros2_ws/build/std_msgs/rosidl_typesupport_opensplice_cpp/std_msgs/msg/dds_opensplice/Float64_Dcps_impl.cpp |
496c99072fed2416a5488d2f10f5e0dfa6fcbf8f | dd7c0edcfe34a74690a09ed186d76559eb5dd4dc | /Classes/Scene_1_7.h | 95c1e779314d4b13441a6d04084ef5fb085a0344 | [] | no_license | cnsuhao/Defend | 9fa33f2e3abd8075edfa21f43012f00bee10390d | 03743c041e3ecdd2089ae1cb2542d544a0014089 | refs/heads/master | 2021-05-29T15:23:57.637465 | 2015-10-02T05:44:33 | 2015-10-02T05:44:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,487 | h | Scene_1_7.h | #ifndef Scene_1_7_
#define Scene_1_7_
#include "object.h"
#include "Scene_UI.h"
#include "Scene_1_8.h"
class Scene_1_7 : public Scene_UI
{
public:
static Scene* createScene();
virtual void removeRes()
{
SpriteFrameCache::getInstance()->removeSpriteFramesFromFile("Scene_1/Object02-hd.plist");
SpriteFrameCache::getInstance()->removeSpriteFramesFromFile("Scene_1/Monsters01-hd.plist");
}
virtual void initScene(Node*p)
{
if (rand() % 2 == 0)
{
SimpleAudioEngine::getInstance()->playBackgroundMusic("Music/BGMusic01.mp3", true);
}
else
{
SimpleAudioEngine::getInstance()->playBackgroundMusic("Music/BGMusic11.mp3", true);
}
base_money = 550;
key_to_ = "1_7";
auto bg = Sprite::create("Scene_1/BG0/BG2-hd.pvr.png");
p->addChild(bg);
bg->setPosition(WIDTH / 2, 640 / 2);
auto path__ = Sprite::create("Scene_1/BG7/BG-hd.pvr.png");
path__->setPosition(WIDTH / 2, -4);
p->addChild(path__);
path__->setAnchorPoint(Vec2(0.5, 0));
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Scene_1/Object02-hd.plist");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Scene_1/Monsters01-hd.plist");
current_level = 7;
callback_next = [=]()
{
Director::getInstance()->replaceScene(Scene_1_8::createScene());
};
callback_restart = [=]()
{
Director::getInstance()->replaceScene(Scene_1_7::createScene());
};
}
virtual void initQueue_way();
virtual void initAbleTower();
virtual void initBonus();
virtual void initWave_manager()
{
wave_manager->push_back(1, Each_One(12, 1), true);
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(1, Each_One(12, 1));
wave_manager->push_back(2, Each_One(13, 45), true);
wave_manager->push_back(2, Each_One(13, 45));
wave_manager->push_back(2, Each_One(13, 45));
wave_manager->push_back(2, Each_One(13, 45));
wave_manager->push_back(2, Each_One(13, 48));
wave_manager->push_back(2, Each_One(11, 48));
wave_manager->push_back(2, Each_One(11, 48));
wave_manager->push_back(2, Each_One(11, 48));
wave_manager->push_back(2, Each_One(11, 48));
wave_manager->push_back(2, Each_One(11, 48));
wave_manager->push_back(3, Each_One(12, 52), true);
wave_manager->push_back(3, Each_One(12, 52));
wave_manager->push_back(3, Each_One(12, 52));
wave_manager->push_back(3, Each_One(12, 52));
wave_manager->push_back(3, Each_One(12, 52));
wave_manager->push_back(3, Each_One(12, 52));
wave_manager->push_back(3, Each_One(11, 52));
wave_manager->push_back(3, Each_One(11, 52));
wave_manager->push_back(3, Each_One(11, 52));
wave_manager->push_back(3, Each_One(11, 52));
wave_manager->push_back(4, Each_One(13, 60), true);
wave_manager->push_back(4, Each_One(13, 60));
wave_manager->push_back(4, Each_One(13, 60));
wave_manager->push_back(4, Each_One(13, 60));
wave_manager->push_back(4, Each_One(13, 60));
wave_manager->push_back(4, Each_One(13, 60));
wave_manager->push_back(4, Each_One(3, 60));
wave_manager->push_back(4, Each_One(3, 60));
wave_manager->push_back(4, Each_One(3, 60));
wave_manager->push_back(4, Each_One(3, 60));
wave_manager->push_back(5, Each_One(11, 70), true);
wave_manager->push_back(5, Each_One(11, 70));
wave_manager->push_back(5, Each_One(11, 70));
wave_manager->push_back(5, Each_One(11, 70));
wave_manager->push_back(5, Each_One(11, 100));
wave_manager->push_back(5, Each_One(11, 100));
wave_manager->push_back(5, Each_One(12, 100));
wave_manager->push_back(5, Each_One(12, 100));
wave_manager->push_back(5, Each_One(12, 100));
wave_manager->push_back(5, Each_One(12, 100));
wave_manager->push_back(6, Each_One(13, 90), true);
wave_manager->push_back(6, Each_One(13, 90));
wave_manager->push_back(6, Each_One(13, 90));
wave_manager->push_back(6, Each_One(13, 90));
wave_manager->push_back(6, Each_One(13, 110));
wave_manager->push_back(6, Each_One(13, 110));
wave_manager->push_back(6, Each_One(13, 110));
wave_manager->push_back(6, Each_One(13, 110));
wave_manager->push_back(6, Each_One(4, 110));
wave_manager->push_back(6, Each_One(4, 110));
wave_manager->push_back(7, Each_One(13, 100), true);
wave_manager->push_back(7, Each_One(13, 100));
wave_manager->push_back(7, Each_One(13, 100));
wave_manager->push_back(7, Each_One(13, 100));
wave_manager->push_back(7, Each_One(13, 120));
wave_manager->push_back(7, Each_One(13, 120));
wave_manager->push_back(7, Each_One(13, 120));
wave_manager->push_back(7, Each_One(13, 120));
wave_manager->push_back(7, Each_One(13, 120));
wave_manager->push_back(7, Each_One(13, 120));
wave_manager->push_back(8, Each_One(4, 100), true);
wave_manager->push_back(8, Each_One(4, 100));
wave_manager->push_back(8, Each_One(4, 100));
wave_manager->push_back(8, Each_One(4, 100));
wave_manager->push_back(8, Each_One(7, 100));
wave_manager->push_back(8, Each_One(7, 100));
wave_manager->push_back(8, Each_One(7, 80));
wave_manager->push_back(8, Each_One(7, 80));
wave_manager->push_back(8, Each_One(7, 80));
wave_manager->push_back(8, Each_One(7, 80));
wave_manager->push_back(9, Each_One(12, 155), true);
wave_manager->push_back(9, Each_One(12, 155));
wave_manager->push_back(9, Each_One(12, 155));
wave_manager->push_back(9, Each_One(12, 155));
wave_manager->push_back(9, Each_One(12, 88));
wave_manager->push_back(9, Each_One(12, 88));
wave_manager->push_back(9, Each_One(13, 88));
wave_manager->push_back(9, Each_One(13, 88));
wave_manager->push_back(9, Each_One(13, 88));
wave_manager->push_back(9, Each_One(13, 88));
wave_manager->push_back(10, Each_One(8, 170), true);
wave_manager->push_back(11, Each_One(3, 200), true);
wave_manager->push_back(11, Each_One(3, 200));
wave_manager->push_back(11, Each_One(3, 200));
wave_manager->push_back(11, Each_One(3, 200));
wave_manager->push_back(11, Each_One(11, 180));
wave_manager->push_back(11, Each_One(11, 180));
wave_manager->push_back(11, Each_One(11, 180));
wave_manager->push_back(11, Each_One(11, 180));
wave_manager->push_back(11, Each_One(11, 180));
wave_manager->push_back(11, Each_One(11, 180));
wave_manager->push_back(12, Each_One(4, 150), true);
wave_manager->push_back(12, Each_One(4, 150));
wave_manager->push_back(12, Each_One(4, 150));
wave_manager->push_back(12, Each_One(4, 150));
wave_manager->push_back(12, Each_One(4, 100));
wave_manager->push_back(12, Each_One(4, 100));
wave_manager->push_back(12, Each_One(4, 100));
wave_manager->push_back(12, Each_One(4, 150));
wave_manager->push_back(12, Each_One(4, 100));
wave_manager->push_back(12, Each_One(4, 100));
wave_manager->push_back(12, Each_One(4, 100));
wave_manager->push_back(13, Each_One(7, 222), true);
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(13, Each_One(7, 222));
wave_manager->push_back(14, Each_One(12, 250), true);
wave_manager->push_back(14, Each_One(12, 250));
wave_manager->push_back(14, Each_One(12, 250));
wave_manager->push_back(14, Each_One(12, 250));
wave_manager->push_back(14, Each_One(12, 250));
wave_manager->push_back(14, Each_One(13, 250));
wave_manager->push_back(14, Each_One(13, 250));
wave_manager->push_back(14, Each_One(13, 250));
wave_manager->push_back(14, Each_One(13, 120));
wave_manager->push_back(14, Each_One(13, 120));
wave_manager->push_back(15, Each_One(6, 250), true);
wave_manager->push_back(16, Each_One(13, 280), true);
wave_manager->push_back(16, Each_One(13, 280));
wave_manager->push_back(16, Each_One(13, 280));
wave_manager->push_back(16, Each_One(13, 280));
wave_manager->push_back(16, Each_One(13, 280));
wave_manager->push_back(16, Each_One(13, 280));
wave_manager->push_back(16, Each_One(13, 150));
wave_manager->push_back(16, Each_One(13, 150));
wave_manager->push_back(16, Each_One(13, 150));
wave_manager->push_back(16, Each_One(13, 150));
wave_manager->push_back(17, Each_One(11, 170), true);
wave_manager->push_back(17, Each_One(11, 170));
wave_manager->push_back(17, Each_One(11, 170));
wave_manager->push_back(17, Each_One(11, 170));
wave_manager->push_back(17, Each_One(11, 170));
wave_manager->push_back(17, Each_One(7, 170));
wave_manager->push_back(17, Each_One(7, 300));
wave_manager->push_back(17, Each_One(7, 300));
wave_manager->push_back(17, Each_One(7, 300));
wave_manager->push_back(17, Each_One(7, 300));
wave_manager->push_back(18, Each_One(13, 300), true);
wave_manager->push_back(18, Each_One(13, 300));
wave_manager->push_back(18, Each_One(13, 300));
wave_manager->push_back(18, Each_One(13, 300));
wave_manager->push_back(18, Each_One(13, 300));
wave_manager->push_back(18, Each_One(3, 300));
wave_manager->push_back(18, Each_One(3, 300));
wave_manager->push_back(18, Each_One(3, 300));
wave_manager->push_back(18, Each_One(3, 300));
wave_manager->push_back(18, Each_One(3, 300));
wave_manager->push_back(19, Each_One(12, 333), true);
wave_manager->push_back(19, Each_One(12, 333));
wave_manager->push_back(19, Each_One(12, 333));
wave_manager->push_back(19, Each_One(12, 333));
wave_manager->push_back(19, Each_One(12, 333));
wave_manager->push_back(19, Each_One(3, 333));
wave_manager->push_back(19, Each_One(3, 333));
wave_manager->push_back(19, Each_One(3, 333));
wave_manager->push_back(19, Each_One(3, 220));
wave_manager->push_back(19, Each_One(3, 220));
wave_manager->push_back(20, Each_One(1, 3000), true);
wave_manager->push_back(20, Each_One(3, 333));
wave_manager->push_back(20, Each_One(3, 333));
wave_manager->push_back(20, Each_One(3, 333));
wave_manager->push_back(20, Each_One(3, 333));
}
CREATE_FUNC(Scene_1_7);
};
#endif
|
bd7da42ec26b4e7fc57e44e6b16d1d3efb8616fe | 800cb4371ba4d5744b57e5e37465971728a806ec | /Llama/source/graphics/llconstantset.cpp | 6f82921498a8fcec57c08c2241d8d1da2fe5cf02 | [] | no_license | jonathan-matai/llama | e204b66033163685b247cb8b96b78d938fd08b62 | e02da8373b712421d18c17817e77a9e767c9c6a3 | refs/heads/master | 2021-04-11T12:37:13.151414 | 2020-05-17T12:59:45 | 2020-05-17T12:59:45 | 249,021,011 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 410 | cpp | llconstantset.cpp | #include "llpch.h"
#include "graphics/llconstantset.h"
#include "graphics/llbuffer.h"
#include "graphics/llimage.h"
#include "vulkan/llconstantset_vk.h"
llama::ConstantSet llama::createConstantSet(Shader shader, uint32_t setIndex, std::initializer_list<ConstantResource> resources)
{
return std::make_shared<ConstantSet_IVulkan>(std::static_pointer_cast<Shader_IVulkan>(shader), setIndex, resources);
}
|
78b6c14e06d861c9db6f6a7e9214d6d3ed1212a1 | 3d79bd031067c210a3cdc702e899bdf0ac810fa6 | /2D_CircusChalie/winAPI/winAPI/animationTest.h | edb11cfd5c44a0c52d74a5411a779463d90afdb8 | [] | no_license | 1221kwj/PortpolioList | be115482bf372ea9274f990aa0f2ac624155e214 | a997578e78b7e95370cc6bfd8e9b204466f1924d | refs/heads/master | 2022-01-09T21:09:29.396760 | 2019-05-19T13:03:37 | 2019-05-19T13:03:37 | 169,703,866 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 362 | h | animationTest.h | #pragma once
#include "gamenode.h"
#include "animation.h"
class animationTest : public gameNode
{
private:
image* _kkr;
/*
animation* _ani1;
animation* _ani2;
animation* _ani3;
*/
public:
virtual HRESULT init(void);
virtual void release(void);
virtual void update(void);
virtual void render(void);
animationTest(void);
~animationTest(void);
};
|
4e06ce5bd1b8fb1f4327e7f98253c294043a5b96 | 8ef5cb1ce80f92d784e628fd72e682fe8d4a840a | /ALICE/src/GasModelParameters.cc | 907ffefee744592c40f3ab57a4f874b098b06a5f | [] | no_license | jeremyferguson/Geant4GarfieldDegradInterface | 59e497ec282d659907b47fddd1f7dee314eb6d60 | e0a271d33aa6d77a56b540eb3785d508a3d330f0 | refs/heads/master | 2022-12-02T05:45:23.793181 | 2020-08-19T19:33:02 | 2020-08-19T19:33:02 | 268,186,570 | 0 | 0 | null | 2020-05-31T01:06:02 | 2020-05-31T01:06:01 | null | UTF-8 | C++ | false | false | 1,322 | cc | GasModelParameters.cc | #include "GasModelParameters.hh"
#include "HeedDeltaElectronModel.hh"
#include "HeedNewTrackModel.hh"
#include "GasModelParametersMessenger.hh"
#include "DetectorConstruction.hh"
GasModelParameters::GasModelParameters(){
fMessenger = new GasModelParametersMessenger(this);
}
//Add particles (with energy range) to be included in the HeedNewTrack Model
void GasModelParameters::AddParticleNameHeedNewTrack(const G4String particleName,double ekin_min_keV,double ekin_max_keV){
if (ekin_min_keV >= ekin_max_keV) {
return;
}
fMapParticlesEnergyHeedNewTrack.insert(
std::make_pair(particleName, std::make_pair(ekin_min_keV, ekin_max_keV)));
G4cout << "HeedNewTrack: Particle added: " << ekin_min_keV << " " << ekin_max_keV << G4endl;
}
//Add particles (with energy range) to be included in the HeedDeltaElectron Model
void GasModelParameters::AddParticleNameHeedDeltaElectron(const G4String particleName,double ekin_min_keV,double ekin_max_keV){
if (ekin_min_keV >= ekin_max_keV) {
return;
}
fMapParticlesEnergyHeedDeltaElectron.insert(
std::make_pair(particleName, std::make_pair(ekin_min_keV, ekin_max_keV)));
G4cout << "HeedDeltaElectron: Particle added: " << ekin_min_keV << " " << ekin_max_keV << G4endl;
}
|
a3ed566e274ac1cb53b0049e44c81b8a9bd0775f | d0267d6f19e7f8c846f29b921a8a62bcc7f4c3b9 | /190.cpp | a2ac389de3da8cf21b91ec90cdb2484444258a57 | [] | no_license | hasancuet13/uva | 90952d700b3ba8175e79a38034513ef38daf8272 | 2ab083d09d0da0bb1bbf05b13615a319b19d9605 | refs/heads/master | 2021-06-05T07:19:10.801209 | 2017-11-28T10:51:44 | 2017-11-28T10:51:44 | 34,615,489 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,662 | cpp | 190.cpp | #include<bits/stdc++.h>
using namespace std;
vector<double>d;
int main()
{
float x1,y1,x2,y2,x3,y3,d,d1,d2,d3,c_x,c_y,c_1,h,k,r;
int t=0;
char c,c1,c2,c3,c4;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3){
if(t++) cout<<endl;
d=x1*(y2-y3)-y1*(x2-x3)+(x2*y3-x3*y2);
d1=(x1*x1+y1*y1)*(y2-y3)-y1*((x2*x2+y2*y2)-(x3*x3+y3*y3))+(y3*(x2*x2+y2*y2)-y2*(x3*x3+y3*y3));
d2=(x1*x1+y1*y1)*(x2-x3)-x1*((x2*x2+y2*y2)-(x3*x3+y3*y3))+(x3*(x2*x2+y2*y2)-x2*(x3*x3+y3*y3));
d3=(x1*x1+y1*y1)*(x2*y3-x3*y2)-x1*(y3*(x2*x2+y2*y2)-y2*(x3*x3+y3*y3))+y1*(x3*(x2*x2+y2*y2)-x2*(x3*x3+y3*y3));
c_x=-(d1/d);
c_y=(d2/d);
c_1=-(d3/d);
h=(c_x/-2);
k=(c_y/-2);
r=sqrt(h*h+k*k-c_1);
if(h<0){
h=-h;
c='+';
}
else{
h=h;
c='-';
}
if(k<0){
k=-k;
c1='+';
}
else{
k=k;
c1='-';
}
if(c_x>0){
c_x=-c_x;
c2='+';
}
else{
c_x=c_x;
c2='-';
}
if(c_y>0){
c_y=-c_y;
c3='+';
}
else{
c_y=c_y;
c3='-';
}
if(c_1>0){
c_1=-c_1;
c4='+';
}
else{
c_1=c_1;
c4='-';
}
printf("(x %c %.3lf)^2 + (y %c %.3lf)^2 = %.3lf^2\n",c,fabs(h),c1,fabs(k),r);
printf("x^2 + y^2 %c %.3lfx %c %.3lfy %c %.3lf = 0\n",c2,fabs(c_x),c3,fabs(c_y),c4,fabs(c_1));
}
}
|
46ca1cd7792557b0b4d189209987d1882b061646 | 22ee0b34382541ae9ab3aacd8e8257902aea1af6 | /stack/Largest_Rectangle_in_Histogram.cpp | 9430c625e9f66d8dbd6d73356636565f9c1917ba | [] | no_license | rohitishu/interview_prep | 3871e69ed9ede0e287e2be192ead9a7ae3b892b7 | 1e7844f7e2a8c1a52f03a98de059825b668a9108 | refs/heads/master | 2022-09-12T22:10:58.483807 | 2020-06-03T07:36:33 | 2020-06-03T07:36:33 | 262,955,157 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,425 | cpp | Largest_Rectangle_in_Histogram.cpp | //we can use stack for this problem. Here we need to find maximum histogram rectangle for that we need to find the minimum height
// minimum height because it can cover all the heights below it so we can calculate the total area
// suppose we have 2,1,5,6,2,3---> we can push all the number till we don't find number smaller number tham top of the stack
// Time Complexity---> O(N) Space Complexity----> O(N)
class Solution {
public:
int largestRectangleArea(vector<int>& v) {
stack<int> s;
int n=v.size();
if(n==0)
return 0;
s.push(0);
int area=0,maxi=INT_MIN,i;
for( i=1;i<n;i++)
{
while(!s.empty() and v[i]<v[s.top()])
{
int d=v[s.top()];
s.pop();
if(s.empty())
{
area=d*i;
}
else
{
area=d*(i-1-s.top());
}
maxi=max(maxi,area);
}
s.push(i);
}
while(!s.empty())
{
int d=v[s.top()];
s.pop();
if(s.empty())
{
area=d*i;
}
else
{
area=d*(i-1-s.top());
}
maxi=max(maxi,area);
}
return maxi;
}
};
|
eb48aaf3456625fc95172112e41359a74d6ea090 | 9a888c6ddd86c1938cd672c5f2ac24e928e48665 | /THREAD/USEREVT/USEREVT.HPP | 362d2b9f3605945963a079c30f2e801c2e60673b | [
"BSD-3-Clause"
] | permissive | OS2World/DEV-SAMPLES-BOOK-Power_GUI_Programming_with_VisualAge_for_Cpp | 228390f4876520bb72afd5a25fc985fb6ea82de8 | 919dfa422daf18d2bbb924213a0a813c06565720 | refs/heads/master | 2020-05-29T18:33:38.074186 | 2019-05-29T22:02:13 | 2019-05-29T22:02:13 | 189,303,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,744 | hpp | USEREVT.HPP | #ifndef _USEREVT_
#define _USEREVT_
/***************************************************************
* FILE NAME: userevt.hpp *
* *
* DESCRIPTION: *
* This file contains the declaration(s) of the class(es): *
* UserEvent - Portable user-defined event class. *
* UserHandler - Handler for UserEvents. *
* *
* COPYRIGHT: *
* Licensed Materials - Property of Solution Frameworks *
* Copyright (C) 1996, Solution Frameworks *
* All Rights Reserved *
***************************************************************/
#ifndef _IEVENT_
#include <ievent.hpp>
#endif
#ifndef _IHANDLER_
#include <ihandler.hpp>
#endif
/*------------------------ UserEvent ---------------------------
| Objects of this class represent "user-defined" events (i.e., |
| WM_USER events). |
| |
| You can provide these attributes when you construct a |
| UserEvent: |
| o an ID (which is ultimately added to WM_USER) |
| o event parameter 1 |
| o event parameter 2 |
| |
| Within a handler, you construct the UserEvent from the |
| IEvent received in your dispatchHandlerEvent function. |
| |
| See UserHandler, below. |
--------------------------------------------------------------*/
class UserEvent : public IEvent {
public:
UserEvent ( unsigned int id = 0,
const IEventParameter1 &mp1 = 0,
const IEventParameter2 &mp2 = 0 );
UserEvent ( const IEvent &genericEvent );
~UserEvent ( );
/*----------------------- userEventId --------------------------
| This function returns the user-defined event id for this |
| event object. Typically, you call this from within your |
| UserHandler-derived classes' handleUserEvent override to |
| determine the particular user-defined event that has |
| occurred. |
--------------------------------------------------------------*/
unsigned long
userEventId ( ) const;
/*---------------------- postTo/sendTo -------------------------
| You use these functions to post or send the user-defined |
| event object to a given window handle. |
--------------------------------------------------------------*/
void
postTo ( const IWindow &window ) const,
postTo ( const IWindowHandle &window ) const;
unsigned long
sendTo ( const IWindow &window ) const,
sendTo ( const IWindowHandle &window ) const;
/*-------------------------- baseId ----------------------------
| This function returns the "base" id for all user-defined |
| events. Essentially, it is a portable alias for "WM_USER." |
--------------------------------------------------------------*/
static unsigned long
baseId ( );
}; // class UserEvent
/*----------------------- UserHandler --------------------------
| This is the abstract base class for handlers of user-defined |
| events. You create handlers for such events by deriving |
| from this class and overriding the handleUserEvent function. |
| |
| The base class provides support for intercepting a range |
| of user-defined event identifiers. You provide the range
| of identifiers to the constructor. These identifiers are |
| added to UserEvent::baseId() to determine the event |
| identifiers that get handled. The default is to handle |
| just UserEvent::baseId(). |
--------------------------------------------------------------*/
class UserHandler : public IHandler {
protected:
UserHandler ( unsigned long id = 0 );
UserHandler ( unsigned long low, unsigned long high );
~UserHandler ( );
virtual Boolean
handleUserEvent( UserEvent &event ) = 0;
virtual Boolean
dispatchHandlerEvent ( IEvent &event );
private:
unsigned long
low,
high;
}; // class UserHandler
#endif // _USEREVT_
|
940a867ccad42f4a7db5549e49d62a343fc11785 | a94f4136b36b56b29f35054959fa26752841ad22 | /mightycity/graphics/mesh.cpp | 6144d7d84974d2e4ecea6717e59e1bd9410a2e3f | [] | no_license | lucafanselau/ovk | 63bc90a10dfb8932f6ec7ca11bd6496f5b57617f | 36232dddac2281b3d5b9cfc222052f7923ad30b2 | refs/heads/main | 2023-05-30T17:12:58.019713 | 2021-06-17T18:37:34 | 2021-06-17T18:37:34 | 377,928,763 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,892 | cpp | mesh.cpp | #include "mesh.h"
#include <base/device.h>
#include <cmath>
#include <tiny_obj_loader.h>
#include <noise/noise.h>
#include <sstream>
#include <boost/pfr.hpp>
#include "..\world\world.h"
Mesh::Mesh(ovk::Buffer &&buffer, uint32_t count, uint32_t offset)
: vertex(std::move(buffer)), vertices_count(count), dynamic_offset(offset) {
}
Model::Model(std::string n, std::vector<std::unique_ptr<Mesh>>&& m)
: name(n), meshes(std::move(m)) {}
ModelManager::ModelManager(std::shared_ptr<ovk::Device>& d) : device(d) {
// create materials buffer
// Here are some variables to tweak
// Maximum Number of Materials possible
const uint32_t material_count = 128;
{
auto buffer_usage = vk::BufferUsageFlagBits::eUniformBuffer;
size_t min_buffer_alignment = device->physical_device.getProperties().limits.minUniformBufferOffsetAlignment;
dynamic_alignment = sizeof(Material);
if (min_buffer_alignment > 0) {
dynamic_alignment = (dynamic_alignment + min_buffer_alignment - 1) & ~(min_buffer_alignment - 1);
}
const uint32_t size = material_count * dynamic_alignment;
materials = ovk::make_unique(device->create_buffer(
buffer_usage,
size,
nullptr,
{ ovk::QueueType::graphics },
ovk::mem::MemoryType::cpu_coherent_and_cached
));
}
}
void ModelManager::load(std::string name, std::string filename) {
if (auto it = models.find(name); it == models.end()) {
models.insert_or_assign(name, Model(name, do_load(filename)));
} else {
spdlog::error("[ModelManager] (load) name {} already exists!", name);
}
}
Model* ModelManager::get(std::string name) {
if (auto it = models.find(name); it != models.end()) {
return &it->second;
}
spdlog::error("[ModelManager] (get) model with name {} does not exists!", name);
return nullptr;
}
glm::vec3 to_vec3(float* a) {
return glm::vec3(*(a), *(a + 1), *(a + 2));
}
std::vector<std::unique_ptr<Mesh>> ModelManager::do_load(const std::string filename) {
// Load TinyOBJ
tinyobj::attrib_t attribute;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> obj_materials;
std::string error, warn;
const auto parse_result = tinyobj::LoadObj(
&attribute,
&shapes,
&obj_materials,
&warn,
&error,
filename.c_str(),
"res/materials/"
);
if (!warn.empty())
spdlog::warn("(load_mesh_from_obj) parse warning: {}", warn);
if (!error.empty())
spdlog::error("(load_mesh_from_obj) parse error: {}", error);
if (!parse_result)
spdlog::critical("(load_mesh_from_obj) failed to parse {}", filename);
std::vector<std::unique_ptr<Mesh>> meshes;
auto mem_pointer = (uint8_t*) materials->memory->map(*device);
auto base_head = materials_head;
for (auto& obj_m : obj_materials) {
Material material {
to_vec3(obj_m.ambient),
to_vec3(obj_m.diffuse),
to_vec3(obj_m.specular),
obj_m.shininess
};
// Copy it to the plan data buffer
memcpy(&mem_pointer[(int) materials_head], &material, sizeof(material));
materials_head += dynamic_alignment;
}
materials->memory->unmap(*device);
auto to_vertex = [&](tinyobj::index_t& idx) {
const auto vidx = idx.vertex_index;
const auto nidx = idx.normal_index;
const auto tidx = idx.texcoord_index;
// TODO: Ok we now that if any idx is -1 this value is not present but we dont handle that here
// DO THAT:
return MeshVertex {
glm::vec3(attribute.vertices[3 * vidx + 0], attribute.vertices[3 * vidx + 1], attribute.vertices[3 * vidx + 2]),
glm::vec3(attribute.normals[3 * nidx + 0], attribute.normals[3 * nidx + 1], attribute.normals[3 * nidx + 2]) * glm::vec3(-1.0f, 1.0f, -1.0f),
// TODO: should not be vec3
glm::vec3(0.0f) // glm::vec3(attribute.texcoords[ 2 * tidx + 0], attribute.texcoords[ 2 * tidx + 1], 0.0f)
};
};
ovk_assert(!shapes.empty());
for (auto& shape : shapes) {
auto& mesh = shape.mesh;
std::vector<MeshVertex> vertices;
auto push_mesh = [&](int idx) {
meshes.push_back(std::make_unique<Mesh>(
std::move(device->create_vertex_buffer(vertices, ovk::mem::MemoryType::device_local)),
vertices.size(),
base_head + idx * dynamic_alignment
));
vertices.clear();
};
int last_material_idx = mesh.material_ids[0];
for (size_t f = 0; f < mesh.indices.size() / 3; f++) {
// We expect a face to have a consistent material
auto& material_idx = mesh.material_ids[f];
if (last_material_idx != material_idx) {
push_mesh(last_material_idx);
last_material_idx = material_idx;
}
auto idx0 = mesh.indices[f * 3 + 0];
auto idx1 = mesh.indices[f * 3 + 1];
auto idx2 = mesh.indices[f * 3 + 2];
vertices.push_back(to_vertex(idx0));
vertices.push_back(to_vertex(idx1));
vertices.push_back(to_vertex(idx2));
}
push_mesh(last_material_idx);
}
return meshes;
}
void calculate_terrain(const Terrain* terrain, Chunk* chunk, ovk::Device& device) {
std::vector<TerrainVertex> vertices;
// TODO: this must not be a TerrainVertex but we dont care atm
// TODO: Possible Optimization
std::vector<TerrainVertex> picker_vertices;
// TODO: Make a function out of this
auto get_color = [](float height, float angle /*expected to be in rad*/) {
enum ColorType {
grass,
dirt,
stone,
water
};
ColorType type;
if (height < 0.0f) {
type = water;
} else {
if (height > 15.0f) {
type = stone;
} else {
if (angle < glm::radians(45.0)) {
type = grass;
} else if (angle < glm::radians(80.0)) {
type = dirt;
} else {
type = stone;
}
}
}
switch (type) {
case grass: return glm::vec3(143.0f / 255.0f, 203.0f / 255.0f, 98.0f / 255.0f);
case dirt: return glm::vec3(155.f / 255.f, 116.f / 255.f, 82.f / 255.f);
case stone: return glm::vec3(160.0f / 255.0f, 171.0f / 255.0f, 177.0f / 255.0f);
case water: return glm::vec3(67.0f / 255.0f, 94.0f / 255.0f, 219.0f / 255.0f);
default: return glm::vec3(1.0f);
}
};
for (int z = 0; z < chunk_size; z++) {
for (int x = 0; x < chunk_size; x++) {
glm::vec3 current(x, 0, z);
glm::vec3 a1(0, chunk->get_height(x, z), 0);
glm::vec3 a2(1, chunk->get_height(x + 1, z), 0);
glm::vec3 a3(0, chunk->get_height(x, z + 1), 1);
glm::vec3 a4(1, chunk->get_height(x + 1, z + 1), 1);
auto dx1 = a2 - a1;
auto dx2 = a4 - a3;
auto dz1 = a3 - a1;
auto dz2 = a4 - a2;
auto dd1 = a4 - a1;
auto dd2 = a3 - a2;
auto raw_normal1 = glm::normalize(glm::cross(a4 - a1, a2 - a1));
auto raw_normal2 = glm::normalize(glm::cross(a3 - a1, a4 - a1));
auto interpolation = 0.1f;
auto normal1 = raw_normal1 + (raw_normal2 - raw_normal1) * interpolation;
auto normal2 = raw_normal2 + (raw_normal1 - raw_normal2) * interpolation;
auto middle_normal = raw_normal1 + (raw_normal2 - raw_normal1) * 0.5f;
auto avg1 = (a1.y + a2.y + a4.y) / 3.0f;
auto avg2 = (a1.y + a4.y + a3.y) / 3.0f;
const glm::vec3 up(0.0f, 1.0f, 0.0f);
auto angle1 = glm::acos(glm::dot(raw_normal1, up));
auto angle2 = glm::acos(glm::dot(raw_normal2, up));
auto color1 = get_color(avg1, angle1);
auto color2 = get_color(avg2, angle2);
std::vector<TerrainVertex> current_vertices;
std::vector<TerrainVertex> current_picker_vertices;
if (chunk->get_type(x, z) == TileType::street) {
//color1 = glm::vec3(1.0f, 1.0f, 1.0f);
//color2 = glm::vec3(1.0f, 1.0f, 1.0f);
const auto inset = 0.2f;
const auto hypinset = sqrt(2 * inset * inset);
// Really ugly name for one minus inset
const auto ominset = 1.0f - inset;
// Inner vertices
auto a5 = a1 + inset * dd1;
auto a6 = a1 + ominset * dx1 + inset * dz2;
auto a7 = a1 + inset * dx2 + ominset * dz1;
auto a8 = a1 + ominset * dd1;
// the other ones
// NOTE: see OneNote for information
auto a9 = a1 + inset * dx1;
auto a10 = a1 + ominset * dx1;
auto a11 = a1 + dx1 + inset * dz2;
auto a12 = a1 + dx1 + ominset * dz2;
auto a13 = a1 + ominset * dx2 + dz1;
auto a14 = a1 + inset * dx2 + dz1;
auto a15 = a1 + ominset * dz1;
auto a16 = a1 + inset * dz1;
glm::vec3 street_color(0.5020f, 0.4941f, 0.4706f);
int world_pos_x = chunk->pos.x + x;
int world_pos_z = chunk->pos.y + z;
glm::vec3 street_top = color1;
if (z == 0) { if (auto type = terrain->get_type(world_pos_x, world_pos_z - 1); type.has_value() && type.value() == TileType::street) street_top = street_color; }
else { if (chunk->get_type(x, z - 1) == TileType::street) street_top = street_color; }
glm::vec3 street_bottom = color2;
if (z == 7) { if (terrain->get_type(world_pos_x, world_pos_z + 1) == TileType::street) street_bottom = street_color; }
else { if (chunk->get_type(x, z + 1) == TileType::street) street_bottom = street_color; }
glm::vec3 street_right = color1;
if (x == 7) { if(terrain->get_type(world_pos_x + 1, world_pos_z) == TileType::street) street_right = street_color; }
else { if (chunk->get_type(x + 1, z) == TileType::street) street_right = street_color; }
glm::vec3 street_left = color2;
if (x == 0) { if(terrain->get_type(world_pos_x - 1, world_pos_z) == TileType::street) street_left = street_color; }
else { if (chunk->get_type(x - 1, z) == TileType::street) street_left = street_color; }
// TOP LEFT Triangles
current_vertices.push_back(TerrainVertex { current + a1, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a9, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a5, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a1, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a5, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a16, raw_normal2, color2 });
// TOP MIDDLE
current_vertices.push_back(TerrainVertex { current + a9, raw_normal1, street_top });
current_vertices.push_back(TerrainVertex { current + a10, raw_normal1, street_top });
current_vertices.push_back(TerrainVertex { current + a6, raw_normal1, street_top });
current_vertices.push_back(TerrainVertex { current + a9, raw_normal1, street_top });
current_vertices.push_back(TerrainVertex { current + a6, raw_normal1, street_top });
current_vertices.push_back(TerrainVertex { current + a5, raw_normal1, street_top });
// TOP RIGHT
current_vertices.push_back(TerrainVertex { current + a10, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a2, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a11, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a10, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a11, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a6, raw_normal1, color1 });
// RIGHT MIDDLE
current_vertices.push_back(TerrainVertex { current + a6, raw_normal1, street_right });
current_vertices.push_back(TerrainVertex { current + a11, raw_normal1, street_right });
current_vertices.push_back(TerrainVertex { current + a12, raw_normal1, street_right });
current_vertices.push_back(TerrainVertex { current + a6, raw_normal1, street_right });
current_vertices.push_back(TerrainVertex { current + a12, raw_normal1, street_right });
current_vertices.push_back(TerrainVertex { current + a8, raw_normal1, street_right });
// BOTTOM RIGHT
current_vertices.push_back(TerrainVertex { current + a8, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a12, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a4, raw_normal1, color1 });
current_vertices.push_back(TerrainVertex { current + a8, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a4, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a13, raw_normal2, color2 });
// BOTTOM MIDDLE
current_vertices.push_back(TerrainVertex { current + a7, raw_normal2, street_bottom });
current_vertices.push_back(TerrainVertex { current + a8, raw_normal2, street_bottom });
current_vertices.push_back(TerrainVertex { current + a13, raw_normal2, street_bottom });
current_vertices.push_back(TerrainVertex { current + a7, raw_normal2, street_bottom });
current_vertices.push_back(TerrainVertex { current + a13, raw_normal2, street_bottom });
current_vertices.push_back(TerrainVertex { current + a14, raw_normal2, street_bottom });
// BOTTOM LEFT
current_vertices.push_back(TerrainVertex { current + a15, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a7, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a14, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a15, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a14, raw_normal2, color2 });
current_vertices.push_back(TerrainVertex { current + a3, raw_normal2, color2 });
// LEFT MIDDLE
current_vertices.push_back(TerrainVertex { current + a16, raw_normal2, street_left });
current_vertices.push_back(TerrainVertex { current + a5, raw_normal2, street_left });
current_vertices.push_back(TerrainVertex { current + a7, raw_normal2, street_left });
current_vertices.push_back(TerrainVertex { current + a16, raw_normal2, street_left });
current_vertices.push_back(TerrainVertex { current + a7, raw_normal2, street_left });
current_vertices.push_back(TerrainVertex { current + a15, raw_normal2, street_left });
// MIDDLE MIDDLE
current_vertices.push_back(TerrainVertex { current + a5, raw_normal1, street_color });
current_vertices.push_back(TerrainVertex { current + a6, raw_normal1, street_color });
current_vertices.push_back(TerrainVertex { current + a8, raw_normal1, street_color });
current_vertices.push_back(TerrainVertex { current + a5, raw_normal2, street_color });
current_vertices.push_back(TerrainVertex { current + a8, raw_normal2, street_color });
current_vertices.push_back(TerrainVertex { current + a7, raw_normal2, street_color });
} else {
// Normal Tile
current_vertices = {
TerrainVertex{ current + a1, raw_normal1, color1},
TerrainVertex{ current + a2, raw_normal1, color1},
TerrainVertex{ current + a4, raw_normal1, color1},
TerrainVertex{ current + a1, raw_normal2, color2},
TerrainVertex{ current + a4, raw_normal2, color2},
TerrainVertex{ current + a3, raw_normal2, color2},
};
}
// Since the picker figures out the pos by dividing gl_VertexID / 3
// currently the most simple solution is to have a mesh that does not have the data
current_picker_vertices = {
TerrainVertex{ current + a1, raw_normal1, color1},
TerrainVertex{ current + a2, raw_normal1, color1},
TerrainVertex{ current + a4, raw_normal1, color1},
TerrainVertex{ current + a1, raw_normal2, color2},
TerrainVertex{ current + a4, raw_normal2, color2},
TerrainVertex{ current + a3, raw_normal2, color2},
};
vertices.insert(vertices.end(), current_vertices.begin(), current_vertices.end());
picker_vertices.insert(picker_vertices.end(),
current_picker_vertices.begin(),
current_picker_vertices.end());
}
}
chunk->mesh = std::make_unique<TerrainMesh>(
std::move(TerrainMesh{
std::move(device.create_vertex_buffer(vertices, ovk::mem::MemoryType::device_local)),
static_cast<uint32_t>(vertices.size())
})
);
chunk->picker_mesh = std::make_unique<TerrainMesh>(
std::move(TerrainMesh{
std::move(device.create_vertex_buffer(picker_vertices, ovk::mem::MemoryType::device_local)),
static_cast<uint32_t>(picker_vertices.size())
})
);
}
// TODO: Remove
#if 0
std::vector<std::unique_ptr<Mesh>> load_meshes_from_obj(const std::string& filename, ovk::Device& device) {
// Ok we will need a dynamic uniform buffer for the materials
// this is currently not part of ovk so we are going to do it here
// TODO: This should be done in ovk
std::shared_ptr<ovk::Buffer> materials_buffer;
size_t dynamic_alignment;
{
auto buffer_usage = vk::BufferUsageFlagBits::eUniformBuffer;
// Figure out the size
// Calculate required alignment based on minimum device offset alignment
size_t min_buffer_alignment = device.physical_device.getProperties().limits.minUniformBufferOffsetAlignment;
dynamic_alignment = sizeof(Material);
if (min_buffer_alignment > 0) {
dynamic_alignment = (dynamic_alignment + min_buffer_alignment - 1) & ~(min_buffer_alignment - 1);
}
const size_t whole_size = dynamic_alignment * materials.size();
std::vector<uint8_t> data(whole_size, 0);
size_t current_offset = 0;
for (auto& obj_m : materials) {
Material material {
to_vec3(obj_m.ambient),
to_vec3(obj_m.diffuse),
to_vec3(obj_m.specular),
obj_m.shininess
};
// Copy it to the plan data buffer
memcpy(&data[current_offset], &material, sizeof(material));
current_offset += dynamic_alignment;
}
materials_buffer = ovk::make_shared(device.create_buffer(
buffer_usage,
whole_size,
data.data(),
{ ovk::QueueType::graphics },
ovk::mem::MemoryType::device_local
));
}
auto to_vertex = [&](tinyobj::index_t& idx) {
const auto vidx = idx.vertex_index;
const auto nidx = idx.normal_index;
const auto tidx = idx.texcoord_index;
// TODO: Ok we now that if any idx is -1 this value is not present but we dont handle that here
// DO THAT:
return MeshVertex {
glm::vec3(attribute.vertices[3 * vidx + 0], attribute.vertices[3 * vidx + 1], attribute.vertices[3 * vidx + 2]),
glm::vec3(attribute.normals[3 * nidx + 0], attribute.normals[3 * nidx + 1], attribute.normals[3 * nidx + 2]) * glm::vec3(-1.0f, 1.0f, -1.0f),
// TODO: should not be vec3
glm::vec3(0.0f) // glm::vec3(attribute.texcoords[ 2 * tidx + 0], attribute.texcoords[ 2 * tidx + 1], 0.0f)
};
};
ovk_assert(!shapes.empty());
for (auto& shape : shapes) {
auto& mesh = shape.mesh;
std::vector<MeshVertex> vertices;
auto push_mesh = [&](int idx) {
meshes.push_back(std::make_unique<Mesh>(
std::move(device.create_vertex_buffer(vertices, ovk::mem::MemoryType::device_local)),
vertices.size(),
std::move(materials_buffer),
idx * dynamic_alignment
));
vertices.clear();
};
int last_material_idx = mesh.material_ids[0];
for (size_t f = 0; f < mesh.indices.size() / 3; f++) {
// We expect a face to have a consistent material
auto& material_idx = mesh.material_ids[f];
if (last_material_idx != material_idx) {
push_mesh(last_material_idx);
last_material_idx = material_idx;
}
auto idx0 = mesh.indices[f * 3 + 0];
auto idx1 = mesh.indices[f * 3 + 1];
auto idx2 = mesh.indices[f * 3 + 2];
vertices.push_back(to_vertex(idx0));
vertices.push_back(to_vertex(idx1));
vertices.push_back(to_vertex(idx2));
}
push_mesh(last_material_idx);
}
return meshes;
}
#endif
|
17d052b48b1b117357d1ff23a9069dd87bd6dec6 | c2432c36ed258e450be2b1ecc517ac75a1e902cd | /FirePIC_PiTranslator.cp | c94a34cc5677487b38d5751179309f44ecf7b8f6 | [] | no_license | alennie1993/FireflyDiagnosticKit | c8a16c6fa920fe8b624f71c71c847a4cbae82b1d | 5da2cdd076cd860618af4ab9db1d2965de7261a3 | refs/heads/master | 2021-01-21T23:20:21.149842 | 2017-06-23T14:24:53 | 2017-06-23T14:24:53 | 95,227,737 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,435 | cp | FirePIC_PiTranslator.cp | #line 1 "C:/Users/alenn/Desktop/Summer Work 2017/FireflyDiagnosticKit/FirePIC_PiTranslator.c"
#line 18 "C:/Users/alenn/Desktop/Summer Work 2017/FireflyDiagnosticKit/FirePIC_PiTranslator.c"
char receivedByte = 0;
char counter = 0;
#line 27 "C:/Users/alenn/Desktop/Summer Work 2017/FireflyDiagnosticKit/FirePIC_PiTranslator.c"
void interrupt(){
asm{
ISR:
MOVLB 0
BTFSC PIR1, RCIF
GOTO SEND_DATA
RETFIE
RESET_9BIT_COUNTER:
MOVLB 0
MOVLW 2
MOVWF _counter
RETFIE
TURN_ON_BIT_9:
MOVLB 3
BSF TXSTA, TX9D
MOVLB 0
DECF _counter, 1
RETURN
SEND_DATA:
MOVLB 0
BCF PIR1, RCIF
MOVLB 3
MOVF RCREG, 0
MOVLB 0
MOVWF _receivedByte
SUBLW 0xF0;
BTFSC STATUS, Z
GOTO RESET_9BIT_COUNTER
MOVLB 3
BCF TXSTA, TX9D
MOVLB 0
MOVF _counter,0
BTFSS STATUS, Z
CALL TURN_ON_BIT_9
MOVLB 0
MOVF _receivedByte, 0
MOVLB 3
MOVWF TXREG
RETFIE
}
}
#line 98 "C:/Users/alenn/Desktop/Summer Work 2017/FireflyDiagnosticKit/FirePIC_PiTranslator.c"
void main(){
asm{
CONFIG_PIC:
MOVLB 1
MOVLW 0xFC
MOVWF TRISA
MOVLB 0
CLRF PORTA
MOVLB 1
MOVLW 0xF0
MOVWF OSCCON
MOVLB 3
CLRF ANSELA
MOVLB 2
MOVLW 0x84
MOVWF APFCON
MOVLB 3
CLRF SPBRGH
MOVLB 3
MOVLW 1
MOVWF SPBRGL
MOVLB 3
MOVLW 0x04
MOVWF BAUDCON
MOVLB 3
MOVLW 0x64
MOVWF TXSTA
MOVLB 3
MOVLW 0x90
MOVWF RCSTA
MOVLB 0
CLRF _counter
MOVLB 1
BSF PIE1, RCIE
CLRF INTCON
BSF INTCON, PEIE
BSF INTCON, GIE
}
while(1){}
}
|
675f7211943534d520a95770884fd0002754cacc | da02937fa8b8b5571fa55979f39bdf98aff5bc58 | /Capstone_Create_Testing/Capstone_Create_Testing/SerialPortWrapper.cpp | ea235902f5b17a61faa39577f510e9dfb1ba3416 | [] | no_license | Matt-A-D/UMLCornellCup-R2DR | 67be9620225cf5386abff992238461514d3e759b | 03c07c12b49ab4a687ceb41b70ba901f5cd3ce5d | refs/heads/master | 2021-01-10T16:16:17.300177 | 2016-05-03T18:43:39 | 2016-05-03T18:43:39 | 49,810,638 | 0 | 1 | null | 2016-01-25T15:30:21 | 2016-01-17T09:24:19 | C++ | UTF-8 | C++ | false | false | 1,757 | cpp | SerialPortWrapper.cpp | #include "SerialPortWrapper.h"
#include "iRobotCreate2.h"
using namespace std;
bool SerialPortWrapper::Open(SerialPort^ Port, unsigned __int16 PortNumber, unsigned __int32 BaudRate, Parity Parity, unsigned __int16 DataBits, StopBits StopBits, Handshake FlowControl)
{
String^ strPort = String::Format("COM{0}", PortNumber);
bool PortExists;
for each (String^ s in SerialPort::GetPortNames())
{
if (strPort->Equals(s))
{
PortExists = true;
break;
}
PortExists = false;
}
if (PortExists)
{
Port->DataReceived += gcnew SerialDataReceivedEventHandler(iRobotCreate2::CreateDataReceivedHandler);
SetPortName(Port, strPort);
SetPortBaudRate(Port, BaudRate);
SetPortParity(Port, Parity);
SetPortDataBits(Port, DataBits);
SetPortStopBits(Port, StopBits);
SetPortFlowControl(Port, FlowControl);
Port->ReadTimeout = 500;
Port->WriteTimeout = 500;
Port->Open();
if (Port->IsOpen)
{
return true;
}
}
return false;
}
void SerialPortWrapper::Close(SerialPort^ Port)
{
if (Port != nullptr)
{
Port->Close();
}
}
void SerialPortWrapper::SetPortName(SerialPort^ Port, String^ PortName)
{
Port->PortName = PortName;
}
void SerialPortWrapper::SetPortBaudRate(SerialPort^ Port, unsigned __int32 BaudRate)
{
Port->BaudRate = BaudRate;
}
void SerialPortWrapper::SetPortParity(SerialPort^ Port, Parity PortParity)
{
Port->Parity = PortParity;
}
void SerialPortWrapper::SetPortDataBits(SerialPort^ Port, unsigned __int16 PortDataBits)
{
Port->DataBits = PortDataBits;
}
void SerialPortWrapper::SetPortStopBits(SerialPort^ Port, StopBits PortStopBits)
{
Port->StopBits = PortStopBits;
}
void SerialPortWrapper::SetPortFlowControl(SerialPort^ Port, Handshake PortFlowControl)
{
Port->Handshake = PortFlowControl;
} |
c539855670d7dad55f804ef9c149e35be2c15f6b | 580fdf669753b29567be74b559148c875436a295 | /xcode/Controles.cpp | ea465e9a6efbf84aae7bb5274b99e837da4aa2ec | [] | no_license | leporino/PelucheOSC | f7465b367c79e21a404bf2ab65651ad7e01a9fd8 | 8a4cf02896c386a581ae4892dedf77d7e912e340 | refs/heads/master | 2016-09-06T18:17:28.643664 | 2014-11-30T18:12:50 | 2014-11-30T18:12:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,576 | cpp | Controles.cpp |
/*
#include <iostream>
#include "cinder/app/AppBasic.h"
#include "cinder/Rand.h"
#include "cinder/Vector.h"
//#include "Controles.h"
using namespace ci;
using std::list;
//ParticleController::ParticleController()
{
}
//ParticleController::ParticleController(int amt, const Vec2i &mouseLoc)
{
}
/*
ParticleController::ParticleController( int res )
{
mXRes = app::getWindowWidth()/res;
mYRes = app::getWindowHeight()/res;
for( int y=0; y<mYRes; y++ ){
for( int x=0; x<mXRes; x++ ){
addParticle( x, y, res );
}
}
}
void ParticleController::update()
{
for( list<Particula>::iterator p = mParticles.begin(); p != mParticles.end();){
//p->update();
if( p->mIsDead ) {
p = mParticles.erase( p );
}
else {
p->update();
++p;
}
}
}
void ParticleController::draw(float per3, float sl3)
{
for( list<Particula>::iterator p = mParticles.begin(); p != mParticles.end(); ++p ){
p->draw(per3, sl3);
}
}
void ParticleController::addParticles( int amt )
{
for( int i=0; i<amt; i++ )
{
float x = Rand::randFloat( app::getWindowWidth() );
float y = Rand::randFloat( app::getWindowHeight() );
mParticles.push_back( Particula( Vec2f( x, y ) ) );
}
}
void ParticleController::addParticles( int amt, const Vec2i &mouseLoc ) {
for( int i=0; i<amt; i++ ) {
Vec2f randVec = Rand::randVec2f() * 5.0f;
mParticles.push_back( Particula( mouseLoc + randVec ) );
}
}
void ParticleController::removeParticles( int amt )
{
for( int i=0; i<amt; i++ )
{
mParticles.pop_back();
}
}
*/ |
c1b0db32d871a7341ddbf607afb1059e06c958c2 | ece5f0f44b4f91d09af81d74c232852919488cf8 | /2021/CAMP_1/String/Peatty_Robot3.cpp | 2517363214513b294c8a428287a6cc7aac3195f0 | [] | no_license | Phatteronyyz/POSN | 57020f27065fe106d49be8b6f89248da0ccd21e9 | 3c6fa467377d367104476208801993697a15bd4d | refs/heads/main | 2023-04-30T03:42:57.386892 | 2021-05-16T13:23:57 | 2021-05-16T13:23:57 | 351,687,620 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 633 | cpp | Peatty_Robot3.cpp | #include<bits/stdc++.h>
using namespace std;
char a[200];
int main() {
int len,i,j,k,n=0,e=0,w=0,s=0;
scanf(" %s",a);
len=strlen(a);
scanf("%d",&k);
for(i=0;i<len;i++){
if(a[i]=='N') n++;
if(a[i]=='E') e++;
if(a[i]=='W') w++;
if(a[i]=='S') s++;
}
while(k--){
if(n>s&&s>0) s--;
else if(s>n&&n>0) n--;
else if(e>w&&w>0) w--;
else if(w>e&&e>0) e--;
else if(s==0&&n>0) n--;
else if(n==0&&s>0) s--;
else if(e==0&&w>0) w--;
else if(w==0&&e>0) e--;
}
printf("%d",(abs(n-s)+abs(e-w))*2);
return 0;
} |
55cf94b29ac7f530cf27dd29909cf03ef6031db9 | 9d4505327049d3b078848e3b16a4e641461354d6 | /79.cpp | 4d215608e90183f9e7a0bb27846eeea308287648 | [] | no_license | kosekitau/C100 | 04f402b3679f84869595c4301d0dd74a078caed6 | 114f816d74a76b152c9ec252ad098fb6f2edf96b | refs/heads/main | 2023-08-21T10:34:02.021110 | 2021-10-27T00:20:39 | 2021-10-27T00:20:39 | 399,457,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 845 | cpp | 79.cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
using namespace std;
using ll = long long;
using Graph = vector<vector<int> >;
using P = pair<int, int>;
#define INF 2000000003
#define MOD 100000
#define MAX_N 10000000
int main(){
int N, M, Q;
cin>>N>>M>>Q;
int cnt[N+1][N+1];
for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) cnt[i][j]=0;
for(int i=0;i<M;i++){
int L, R;
cin>>L>>R;
cnt[L][R]++;
}
for(int i=1;i<=N;i++) for(int j=2;j<=N;j++) cnt[i][j]+=cnt[i][j-1];
for(int i=0;i<Q;i++){
int p, q;
cin>>p>>q;
int ans=0;
for(int i=p;i<=q;i++) ans+=cnt[i][q];
cout<<ans<<endl;
}
return 0;
} |
824d4c301ac28739a819c945db405eef40fe46a0 | 8ff5d6f435da374cae475f0e6771fef8ac18321b | /Framework/Core/Src/DebugUtil.cpp | 2faa9c9ce38da30740a0781aee78072f450e24bd | [
"MIT"
] | permissive | CyroPCJr/OmegaEngine | 18f982ad351ad18f4a7124091a9b3f5276160a92 | 8399ef8786ad487d9c20d43f5e12e4972a8c413a | refs/heads/main | 2023-08-16T19:55:14.881116 | 2023-08-08T22:31:31 | 2023-08-08T22:31:31 | 350,535,694 | 5 | 1 | MIT | 2023-08-08T22:31:32 | 2021-03-23T00:56:54 | C++ | UTF-8 | C++ | false | false | 103 | cpp | DebugUtil.cpp | #include "Precompiled.h"
#include "DebugUtil.h"
Omega::Core::DebugLogEvent Omega::Core::OnDebugLog; |
7ce87a8254a4e117adc03743e4af02cd33950fd1 | b257bd5ea374c8fb296dbc14590db56cb7e741d8 | /Extras/DevExpress VCL/Library/RS17/Win64/cxSchedulerCustomControls.hpp | 88fb4dfedb4859c4c19d7bedd809b0d60a234fc6 | [] | no_license | kitesoft/Roomer-PMS-1 | 3d362069e3093f2a49570fc1677fe5682de3eabd | c2f4ac76b4974e4a174a08bebdb02536a00791fd | refs/heads/master | 2021-09-14T07:13:32.387737 | 2018-05-04T12:56:58 | 2018-05-04T12:56:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 147,684 | hpp | cxSchedulerCustomControls.hpp | // CodeGear C++Builder
// Copyright (c) 1995, 2012 by Embarcadero Technologies, Inc.
// All rights reserved
// (DO NOT EDIT: machine generated header) 'cxSchedulerCustomControls.pas' rev: 24.00 (Win64)
#ifndef CxschedulercustomcontrolsHPP
#define CxschedulercustomcontrolsHPP
#pragma delphiheader begin
#pragma option push
#pragma option -w- // All warnings off
#pragma option -Vx // Zero-length empty class member
#pragma pack(push,8)
#include <System.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.Classes.hpp> // Pascal unit
#include <System.SysUtils.hpp> // Pascal unit
#include <Winapi.Windows.hpp> // Pascal unit
#include <Winapi.Messages.hpp> // Pascal unit
#include <Vcl.Forms.hpp> // Pascal unit
#include <Vcl.StdCtrls.hpp> // Pascal unit
#include <Vcl.Controls.hpp> // Pascal unit
#include <Vcl.Graphics.hpp> // Pascal unit
#include <Vcl.ImgList.hpp> // Pascal unit
#include <System.Types.hpp> // Pascal unit
#include <System.Math.hpp> // Pascal unit
#include <Vcl.ExtCtrls.hpp> // Pascal unit
#include <Vcl.Menus.hpp> // Pascal unit
#include <Vcl.Clipbrd.hpp> // Pascal unit
#include <dxCore.hpp> // Pascal unit
#include <dxCoreClasses.hpp> // Pascal unit
#include <cxControls.hpp> // Pascal unit
#include <cxGraphics.hpp> // Pascal unit
#include <cxGeometry.hpp> // Pascal unit
#include <cxLookAndFeels.hpp> // Pascal unit
#include <cxLookAndFeelPainters.hpp> // Pascal unit
#include <dxCustomHint.hpp> // Pascal unit
#include <cxFormats.hpp> // Pascal unit
#include <cxSchedulerUtils.hpp> // Pascal unit
#include <cxSchedulerStorage.hpp> // Pascal unit
#include <cxStyles.hpp> // Pascal unit
#include <cxClasses.hpp> // Pascal unit
#include <cxEdit.hpp> // Pascal unit
#include <cxDateUtils.hpp> // Pascal unit
#include <cxStorage.hpp> // Pascal unit
#include <cxTextEdit.hpp> // Pascal unit
#include <cxNavigator.hpp> // Pascal unit
#include <cxVariants.hpp> // Pascal unit
#include <dxUxTheme.hpp> // Pascal unit
#include <dxTouch.hpp> // Pascal unit
#include <System.UITypes.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Cxschedulercustomcontrols
{
//-- type declarations -------------------------------------------------------
typedef System::TMetaClass* TcxSchedulerCustomViewClass;
enum TcxControlFlag : unsigned char { cfInvalidLayout, cfLocked, cfViewValid };
typedef System::Set<TcxControlFlag, TcxControlFlag::cfInvalidLayout, TcxControlFlag::cfViewValid> TcxControlFlags;
enum TcxSchedulerSplitterKind : unsigned char { skHorizontal, skVertical };
enum TcxSchedulerViewPosition : unsigned char { vpRight, vpLeft, vpTop, vpBottom };
enum TcxSchedulerGroupingKind : unsigned char { gkDefault, gkNone, gkByDate, gkByResource };
enum TcxSchedulerViewMode : unsigned char { vmDay, vmWeek, vmMonth, vmWorkWeek };
typedef bool __fastcall (__closure *TcxOnDeleteEventFunc)(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
enum TcxSchedulerContentPopupMenuItem : unsigned char { cpmiNewEvent, cpmiNewAllDayEvent, cpmiNewReccuringEvent, cpmiToday, cpmiGoToDate, cpmiGoToThisDay, cpmiResourcesLayout };
typedef System::Set<TcxSchedulerContentPopupMenuItem, TcxSchedulerContentPopupMenuItem::cpmiNewEvent, TcxSchedulerContentPopupMenuItem::cpmiResourcesLayout> TcxSchedulerContentPopupMenuItems;
class DELPHICLASS TcxSchedulerEventEditInfo;
class PASCALIMPLEMENTATION TcxSchedulerEventEditInfo : public System::TObject
{
typedef System::TObject inherited;
public:
bool AllowDelete;
bool AllowHiddenEvents;
System::TDateTime BiasTime;
bool DisableShare;
bool Intersection;
Cxschedulerstorage::TcxSchedulerControlEvent* Event;
bool ForcePatternEditing;
Cxlookandfeels::TcxLookAndFeel* LookAndFeel;
TcxOnDeleteEventFunc OnDeleteFunc;
bool ReadOnly;
bool Recurrence;
bool RecurrenceButton;
bool ShowResources;
bool ShowTaskComplete;
public:
/* TObject.Create */ inline __fastcall TcxSchedulerEventEditInfo(void) : System::TObject() { }
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerEventEditInfo(void) { }
};
class DELPHICLASS TcxSchedulerSubControl;
class DELPHICLASS TcxSchedulerSubControlController;
class DELPHICLASS TcxSchedulerSubControlHitTest;
class DELPHICLASS TcxSchedulerSubControlPainter;
class DELPHICLASS TcxCustomScheduler;
class DELPHICLASS TcxSchedulerSubControlViewInfo;
class DELPHICLASS TcxSchedulerStyles;
class PASCALIMPLEMENTATION TcxSchedulerSubControl : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
TcxSchedulerSubControlController* FController;
System::Uitypes::TCursor FCursor;
int FHeight;
TcxSchedulerSubControlHitTest* FHitTest;
int FLeft;
TcxSchedulerSubControlPainter* FPainter;
TcxCustomScheduler* FScheduler;
int FTop;
TcxSchedulerSubControlViewInfo* FViewInfo;
bool FVisible;
int FWidth;
int __fastcall GetBottom(void);
System::Types::TRect __fastcall GetBounds(void);
Cxgraphics::TcxCanvas* __fastcall GetCanvas(void);
Cxschedulerutils::TcxSchedulerDateTimeHelperClass __fastcall GetDateTimeHelperClass(void);
bool __fastcall GetIsGestureScrolling(void);
bool __fastcall GetIsScrollingContent(void);
Cxlookandfeelpainters::TcxCustomLookAndFeelPainter* __fastcall GetLookAndFeelPainter(void);
Cxschedulerutils::TcxSchedulerPainterHelperClass __fastcall GetPainterHelperClass(void);
int __fastcall GetRight(void);
TcxSchedulerStyles* __fastcall GetStyles(void);
void __fastcall InternalSetBounds(const System::Types::TRect &AValue);
void __fastcall SetBottom(const int Value);
void __fastcall SetHeight(int AValue);
void __fastcall SetLeft(int AValue);
void __fastcall SetRight(int Value);
void __fastcall SetTop(int AValue);
void __fastcall SetVisible(bool AValue);
void __fastcall SetWidth(int AValue);
protected:
virtual void __fastcall GetProperties(System::Classes::TStrings* AProperties);
virtual void __fastcall GetPropertyValue(const System::UnicodeString AName, System::Variant &AValue);
virtual void __fastcall SetPropertyValue(const System::UnicodeString AName, const System::Variant &AValue);
virtual bool __fastcall AllowDesignHitTest(int X, int Y, System::Classes::TShiftState AShift);
virtual void __fastcall BoundsChanged(void);
virtual void __fastcall CalculateViewInfo(void);
virtual bool __fastcall CanCapture(const System::Types::TPoint APoint);
virtual void __fastcall Changed(void);
virtual void __fastcall ClearCachedData(void);
virtual TcxSchedulerSubControlController* __fastcall CreateController(void);
virtual TcxSchedulerSubControlHitTest* __fastcall CreateHitTest(void);
virtual TcxSchedulerSubControlPainter* __fastcall CreatePainter(void);
virtual TcxSchedulerSubControlViewInfo* __fastcall CreateViewInfo(void);
virtual void __fastcall BoundsChanging(void);
virtual void __fastcall CreateSubClasses(void);
virtual void __fastcall DestroySubClasses(void);
void __fastcall DoBeforeMouseDown(System::Uitypes::TMouseButton AButton, System::Classes::TShiftState AShift, int X, int Y);
virtual void __fastcall DoCancelMode(void);
virtual void __fastcall DoLayoutChanged(void);
virtual void __fastcall DoMouseDown(System::Uitypes::TMouseButton AButton, System::Classes::TShiftState AShift, int X, int Y);
void __fastcall DoMouseMove(System::Classes::TShiftState AShift, int X, int Y);
void __fastcall DoMouseUp(System::Uitypes::TMouseButton AButton, System::Classes::TShiftState AShift, int X, int Y);
virtual void __fastcall DoPaint(void);
virtual void __fastcall DoScaleScroll(void);
virtual void __fastcall FormatChanged(void);
virtual System::Types::TRect __fastcall GetClientRect(void);
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
virtual System::Types::TRect __fastcall GetHScrollBarBounds(void);
Cxcontrols::_di_IcxControlScrollBar __fastcall GetScrollBar(Vcl::Forms::TScrollBarKind AKind);
virtual System::Types::TRect __fastcall GetSizeGripBounds(void);
virtual Cxdateutils::TDay __fastcall GetStartOfWeek(void);
virtual System::Types::TRect __fastcall GetVScrollBarBounds(void);
virtual void __fastcall InitScrollBarsParameters(void);
virtual bool __fastcall IsSpecialPaint(void);
virtual void __fastcall LookAndFeelChanged(Cxlookandfeels::TcxLookAndFeel* Sender, Cxlookandfeels::TcxLookAndFeelValues AChangedValues);
void __fastcall MousePositionChanged(int &X, int &Y);
virtual void __fastcall Notification(System::Classes::TComponent* AComponent, System::Classes::TOperation Operation);
void __fastcall Paint(void);
virtual void __fastcall PeriodChanged(void);
void __fastcall SetScrollBarInfo(Vcl::Forms::TScrollBarKind AScrollBarKind, int AMin, int AMax, int AStep, int APage, int APos, bool AAllowShow, bool AAllowHide);
virtual void __fastcall VisibleChanged(void);
__property int Bottom = {read=GetBottom, write=SetBottom, nodefault};
__property Cxgraphics::TcxCanvas* Canvas = {read=GetCanvas};
__property System::Types::TRect ClientRect = {read=GetClientRect};
__property TcxSchedulerSubControlController* Controller = {read=FController};
__property System::Uitypes::TCursor Cursor = {read=FCursor, write=FCursor, nodefault};
__property Cxschedulerutils::TcxSchedulerDateTimeHelperClass DateTimeHelper = {read=GetDateTimeHelperClass};
__property TcxSchedulerSubControlHitTest* HitTest = {read=FHitTest};
__property bool IsGestureScrolling = {read=GetIsGestureScrolling, nodefault};
__property bool IsScrollingContent = {read=GetIsScrollingContent, nodefault};
__property int Left = {read=FLeft, write=SetLeft, nodefault};
__property Cxlookandfeelpainters::TcxCustomLookAndFeelPainter* LookAndFeelPainter = {read=GetLookAndFeelPainter};
__property TcxSchedulerSubControlPainter* Painter = {read=FPainter};
__property Cxschedulerutils::TcxSchedulerPainterHelperClass PainterHelper = {read=GetPainterHelperClass};
__property int Right = {read=GetRight, write=SetRight, nodefault};
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
__property Cxdateutils::TDay StartOfWeek = {read=GetStartOfWeek, nodefault};
__property TcxSchedulerStyles* Styles = {read=GetStyles};
__property int Top = {read=FTop, write=SetTop, nodefault};
__property TcxSchedulerSubControlViewInfo* ViewInfo = {read=FViewInfo};
__property bool Visible = {read=FVisible, write=SetVisible, nodefault};
public:
__fastcall virtual TcxSchedulerSubControl(TcxCustomScheduler* AOwner);
__fastcall virtual ~TcxSchedulerSubControl(void);
void __fastcall Invalidate(void);
void __fastcall InvalidateRect(const System::Types::TRect &ARect);
void __fastcall LayoutChanged(void);
void __fastcall Refresh(void);
void __fastcall Repaint(void);
void __fastcall RepaintRect(const System::Types::TRect &ARect);
System::Types::TPoint __fastcall ScreenToClient(const System::Types::TPoint APos);
virtual void __fastcall SetBounds(int ALeft, int ATop, int AWidth, int AHeight);
__property System::Types::TRect Bounds = {read=GetBounds, write=InternalSetBounds};
__property int Height = {read=FHeight, write=SetHeight, nodefault};
__property int Width = {read=FWidth, write=SetWidth, nodefault};
};
class PASCALIMPLEMENTATION TcxSchedulerSubControlController : public Dxcoreclasses::TcxIUnknownObject
{
typedef Dxcoreclasses::TcxIUnknownObject inherited;
private:
bool FCanProcessMouseMove;
TcxSchedulerSubControl* FOwner;
TcxSchedulerSubControlHitTest* __fastcall GetHitTest(void);
Cxdateutils::TDay __fastcall GetStartOfWeek(void);
protected:
virtual void __fastcall BeginDragAndDrop(void);
virtual bool __fastcall CanDrag(int X, int Y);
virtual void __fastcall DragAndDrop(const System::Types::TPoint P, bool &Accepted);
virtual void __fastcall DragDrop(System::TObject* Source, int X, int Y);
virtual void __fastcall DragOver(System::TObject* Source, int X, int Y, System::Uitypes::TDragState State, bool &Accept);
virtual void __fastcall EndDrag(System::TObject* Target, int X, int Y);
virtual void __fastcall EndDragAndDrop(bool Accepted);
virtual Cxcontrols::TcxDragAndDropObjectClass __fastcall GetDragAndDropObjectClass(void);
virtual void __fastcall StartDrag(Vcl::Controls::TDragObject* &DragObject);
virtual bool __fastcall StartDragAndDrop(const System::Types::TPoint P);
virtual void __fastcall BeforeMouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall DoCancelMode(void);
virtual System::Uitypes::TCursor __fastcall GetCursor(int X, int Y);
virtual void __fastcall KeyDown(System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall KeyPress(System::WideChar &Key);
virtual void __fastcall KeyUp(System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall MouseEnter(void);
virtual void __fastcall MouseLeave(void);
virtual void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseMove(System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall Reset(void);
__property bool CanProcessMouseMove = {read=FCanProcessMouseMove, nodefault};
public:
__fastcall virtual TcxSchedulerSubControlController(TcxSchedulerSubControl* AOwner);
__property TcxSchedulerSubControlHitTest* HitTest = {read=GetHitTest};
__property TcxSchedulerSubControl* Owner = {read=FOwner};
__property Cxdateutils::TDay StartOfWeek = {read=GetStartOfWeek, nodefault};
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerSubControlController(void) { }
};
class PASCALIMPLEMENTATION TcxSchedulerSubControlHitTest : public System::TObject
{
typedef System::TObject inherited;
private:
TcxSchedulerSubControl* FOwner;
System::Types::TPoint FHitPoint;
int __fastcall GetPosValue(int AIndex);
TcxCustomScheduler* __fastcall GetScheduler(void);
void __fastcall SetHitPoint(const System::Types::TPoint APoint);
void __fastcall SetPosValue(int AIndex, int AValue);
protected:
System::TDateTime FTime;
__int64 Flags;
virtual void __fastcall Clear(void);
virtual void __fastcall DoCalculate(void);
bool __fastcall GetBitState(int AIndex);
bool __fastcall GetMaskState(int AMask);
bool __fastcall GetMaskStateEx(int AMask);
void __fastcall SetBitState(int AIndex, bool AValue);
void __fastcall SetMaskState(int AMask, bool AValue);
__property TcxSchedulerSubControl* Owner = {read=FOwner};
__property TcxCustomScheduler* Scheduler = {read=GetScheduler};
public:
__fastcall virtual TcxSchedulerSubControlHitTest(TcxSchedulerSubControl* AOwner);
__fastcall virtual ~TcxSchedulerSubControlHitTest(void);
void __fastcall Recalculate(void);
__property System::Types::TPoint HitPoint = {read=FHitPoint, write=SetHitPoint};
__property int HitX = {read=GetPosValue, write=SetPosValue, index=0, nodefault};
__property int HitY = {read=GetPosValue, write=SetPosValue, index=1, nodefault};
__property bool HitAtControl = {read=GetBitState, index=0, nodefault};
__property bool HitAtTime = {read=GetBitState, index=1, nodefault};
__property System::TDateTime Time = {read=FTime};
};
class PASCALIMPLEMENTATION TcxSchedulerSubControlPainter : public System::TObject
{
typedef System::TObject inherited;
private:
TcxSchedulerSubControl* FOwner;
Cxgraphics::TcxCanvas* __fastcall GetCanvas(void);
TcxSchedulerSubControlViewInfo* __fastcall GetViewInfo(void);
protected:
__property TcxSchedulerSubControl* Owner = {read=FOwner};
__property TcxSchedulerSubControlViewInfo* ViewInfo = {read=GetViewInfo};
public:
__fastcall virtual TcxSchedulerSubControlPainter(TcxSchedulerSubControl* AOwner);
virtual void __fastcall AfterPaint(void);
virtual void __fastcall BeforePaint(void);
virtual void __fastcall InitializePainter(void);
virtual void __fastcall Paint(void);
__property Cxgraphics::TcxCanvas* Canvas = {read=GetCanvas};
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerSubControlPainter(void) { }
};
class PASCALIMPLEMENTATION TcxSchedulerSubControlViewInfo : public Dxcoreclasses::TcxIUnknownObject
{
typedef Dxcoreclasses::TcxIUnknownObject inherited;
private:
TcxSchedulerSubControl* FOwner;
Cxschedulerutils::TcxSchedulerDateTimeHelperClass __fastcall GetDateTimeHelperClass(void);
Vcl::Graphics::TFont* __fastcall GetDefaultFont(void);
bool __fastcall GetIsSchedulerCreated(void);
Cxlookandfeelpainters::TcxCustomLookAndFeelPainter* __fastcall GetLookAndFeelPainter(void);
Cxschedulerutils::TcxSchedulerPainterHelperClass __fastcall GetPainterHelperClass(void);
TcxSchedulerStyles* __fastcall GetStyles(void);
protected:
System::Types::TRect FBounds;
virtual void __fastcall AfterCalculate(void);
virtual void __fastcall Clear(void);
virtual void __fastcall DoCalculate(void);
virtual System::Types::TRect __fastcall GetBounds(void);
__property Cxschedulerutils::TcxSchedulerDateTimeHelperClass DateTimeHelper = {read=GetDateTimeHelperClass};
__property Vcl::Graphics::TFont* DefaultFont = {read=GetDefaultFont};
__property bool IsSchedulerCreated = {read=GetIsSchedulerCreated, nodefault};
__property Cxlookandfeelpainters::TcxCustomLookAndFeelPainter* LookAndFeelPainter = {read=GetLookAndFeelPainter};
__property System::Types::TRect Bounds = {read=FBounds};
__property TcxSchedulerSubControl* Owner = {read=FOwner};
__property Cxschedulerutils::TcxSchedulerPainterHelperClass PainterHelper = {read=GetPainterHelperClass};
__property TcxSchedulerStyles* Styles = {read=GetStyles};
public:
__fastcall virtual TcxSchedulerSubControlViewInfo(TcxSchedulerSubControl* AOwner);
virtual void __fastcall Calculate(void);
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerSubControlViewInfo(void) { }
};
class DELPHICLASS TcxSchedulerBackground;
class PASCALIMPLEMENTATION TcxSchedulerBackground : public TcxSchedulerSubControl
{
typedef TcxSchedulerSubControl inherited;
protected:
virtual bool __fastcall IsSpecialPaint(void);
public:
/* TcxSchedulerSubControl.Create */ inline __fastcall virtual TcxSchedulerBackground(TcxCustomScheduler* AOwner) : TcxSchedulerSubControl(AOwner) { }
/* TcxSchedulerSubControl.Destroy */ inline __fastcall virtual ~TcxSchedulerBackground(void) { }
};
class DELPHICLASS TcxSchedulerControlBox;
class PASCALIMPLEMENTATION TcxSchedulerControlBox : public TcxSchedulerSubControl
{
typedef TcxSchedulerSubControl inherited;
private:
Vcl::Controls::TWinControl* FContainer;
Vcl::Controls::TAlign FControlAlign;
Vcl::Controls::TWinControl* FControlParent;
System::Types::TRect FControlRect;
Vcl::Controls::TControl* FControl;
Cxgraphics::TcxViewParams FViewParams;
void __fastcall RestorePosition(void);
void __fastcall SetControl(Vcl::Controls::TControl* AValue);
void __fastcall StorePosition(void);
protected:
virtual void __fastcall GetProperties(System::Classes::TStrings* AProperties);
virtual void __fastcall GetPropertyValue(const System::UnicodeString AName, System::Variant &AValue);
virtual void __fastcall SetPropertyValue(const System::UnicodeString AName, const System::Variant &AValue);
virtual void __fastcall BoundsChanged(void);
virtual Vcl::Controls::TWinControl* __fastcall CreateWndContainerControl(void);
virtual void __fastcall DoPaint(void);
virtual void __fastcall DoLayoutChanged(void);
bool __fastcall HasAsParent(Vcl::Controls::TControl* AValue);
virtual void __fastcall VisibleChanged(void);
__property Cxgraphics::TcxViewParams ViewParams = {read=FViewParams};
public:
__fastcall virtual TcxSchedulerControlBox(TcxCustomScheduler* AOwner);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__property Vcl::Controls::TWinControl* Container = {read=FContainer};
__property Height;
__property Width;
__published:
__property Vcl::Controls::TControl* Control = {read=FControl, write=SetControl};
__property Visible = {default=1};
public:
/* TcxSchedulerSubControl.Destroy */ inline __fastcall virtual ~TcxSchedulerControlBox(void) { }
};
class DELPHICLASS TcxSchedulerSplitterController;
class DELPHICLASS TcxSchedulerSplitter;
class PASCALIMPLEMENTATION TcxSchedulerSplitterController : public TcxSchedulerSubControlController
{
typedef TcxSchedulerSubControlController inherited;
private:
System::Types::TPoint FHitPoint;
System::Types::TRect FPrevInvertRect;
System::Types::TRect FPrevRect;
TcxSchedulerSubControl* FSaveKeyboardListener;
System::Types::TRect FSizingBoundsRect;
System::Types::TRect FStartBounds;
System::Types::TRect FScreenCanvasClipRect;
System::Types::TRect __fastcall GetDrawClipRect(void);
System::Types::TRect __fastcall GetHorzSizingRect(const System::Types::TPoint P);
TcxCustomScheduler* __fastcall GetScheduler(void);
System::Types::TPoint __fastcall GetScreenOffset(void);
TcxSchedulerSplitter* __fastcall GetSplitter(void);
System::Types::TRect __fastcall GetVertSizingRect(const System::Types::TPoint P);
void __fastcall SetHorzBounds(System::Types::TRect &R);
void __fastcall SetHorzDelta(int ADelta);
void __fastcall SetVertBounds(System::Types::TRect &R);
void __fastcall SetVertDelta(int ADelta);
protected:
virtual void __fastcall DoCancelMode(void);
virtual void __fastcall KeyDown(System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseMove(System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
void __fastcall DrawInvertRect(const System::Types::TRect &R);
void __fastcall EraseInvertRect(void);
System::Types::TSize __fastcall GetMonthSize(void);
System::Types::TPoint __fastcall GetOwnerMousePos(int X, int Y);
System::Types::TRect __fastcall GetSizingBoundsRect(void);
int __fastcall GetSizingIncrement(void);
System::Types::TRect __fastcall GetSizingRect(const System::Types::TPoint P);
void __fastcall InvertRect(Cxgraphics::TcxCanvas* ACanvas, System::Types::TRect &R);
virtual bool __fastcall IsIntegralSizing(void);
bool __fastcall IsDynamicUpdate(void);
void __fastcall Modified(void);
virtual void __fastcall SetSizeDelta(int ADelta);
void __fastcall UpdateSizing(const System::Types::TRect &R);
__property TcxCustomScheduler* Scheduler = {read=GetScheduler};
__property System::Types::TRect ScreenCanvasClipRect = {read=FScreenCanvasClipRect};
__property System::Types::TPoint ScreenOffset = {read=GetScreenOffset};
__property System::Types::TRect SizingBoundsRect = {read=FSizingBoundsRect};
__property TcxSchedulerSplitter* Splitter = {read=GetSplitter};
public:
/* TcxSchedulerSubControlController.Create */ inline __fastcall virtual TcxSchedulerSplitterController(TcxSchedulerSubControl* AOwner) : TcxSchedulerSubControlController(AOwner) { }
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerSplitterController(void) { }
};
class DELPHICLASS TcxSchedulerSplitterHitTest;
class PASCALIMPLEMENTATION TcxSchedulerSplitterHitTest : public TcxSchedulerSubControlHitTest
{
typedef TcxSchedulerSubControlHitTest inherited;
private:
TcxSchedulerSplitter* __fastcall GetSplitter(void);
public:
__property TcxSchedulerSplitter* Splitter = {read=GetSplitter};
public:
/* TcxSchedulerSubControlHitTest.Create */ inline __fastcall virtual TcxSchedulerSplitterHitTest(TcxSchedulerSubControl* AOwner) : TcxSchedulerSubControlHitTest(AOwner) { }
/* TcxSchedulerSubControlHitTest.Destroy */ inline __fastcall virtual ~TcxSchedulerSplitterHitTest(void) { }
};
class PASCALIMPLEMENTATION TcxSchedulerSplitter : public TcxSchedulerBackground
{
typedef TcxSchedulerBackground inherited;
private:
TcxSchedulerSplitterKind FKind;
Cxgraphics::TcxViewParams FViewParams;
TcxSchedulerSplitterHitTest* __fastcall GetHitTest(void);
protected:
virtual bool __fastcall AllowDesignHitTest(int X, int Y, System::Classes::TShiftState AShift);
virtual TcxSchedulerSubControlController* __fastcall CreateController(void);
virtual TcxSchedulerSubControlHitTest* __fastcall CreateHitTest(void);
virtual void __fastcall DoLayoutChanged(void);
virtual void __fastcall DoPaint(void);
virtual void __fastcall SetKind(TcxSchedulerSplitterKind AKind);
void __fastcall UpdateCursor(void);
__property TcxSchedulerSplitterHitTest* HitTest = {read=GetHitTest};
__property Cxgraphics::TcxViewParams ViewParams = {read=FViewParams};
public:
__property TcxSchedulerSplitterKind Kind = {read=FKind, nodefault};
public:
/* TcxSchedulerSubControl.Create */ inline __fastcall virtual TcxSchedulerSplitter(TcxCustomScheduler* AOwner) : TcxSchedulerBackground(AOwner) { }
/* TcxSchedulerSubControl.Destroy */ inline __fastcall virtual ~TcxSchedulerSplitter(void) { }
};
class DELPHICLASS TcxSchedulerResourceNavigator;
class DELPHICLASS TcxSchedulerNavigatorButton;
typedef void __fastcall (__closure *TcxSchedulerNavigatorButtonClickEvent)(TcxSchedulerResourceNavigator* Sender, TcxSchedulerNavigatorButton* AButton, bool &AHandled);
class PASCALIMPLEMENTATION TcxSchedulerNavigatorButton : public System::Classes::TCollectionItem
{
typedef System::Classes::TCollectionItem inherited;
private:
int FCommand;
bool FEnabled;
System::UnicodeString FHint;
int FImageIndex;
bool FVisible;
TcxCustomScheduler* __fastcall GetScheduler(void);
void __fastcall SetEnabled(bool AValue);
void __fastcall SetImageIndex(int AValue);
void __fastcall SetVisible(bool AValue);
bool __fastcall IsHintStored(void);
bool __fastcall IsEnabledStored(void);
bool __fastcall IsVisibleStored(void);
protected:
System::Types::TRect FBounds;
bool FRotated;
Cxlookandfeelpainters::TcxButtonState FState;
int FVisibleIndex;
HIDESBASE virtual void __fastcall Changed(void);
virtual void __fastcall Click(void);
virtual System::UnicodeString __fastcall GetDisplayName(void);
System::UnicodeString __fastcall GetHintText(void);
virtual void __fastcall Draw(Cxlookandfeelpainters::TcxCustomLookAndFeelPainter* APainter, Cxgraphics::TcxCanvas* ACanvas);
virtual int __fastcall GetActualImageIndex(void);
virtual Vcl::Imglist::TCustomImageList* __fastcall GetActualImageList(void);
Cxlookandfeelpainters::TcxButtonState __fastcall GetState(bool ACanDisabled = true);
virtual bool __fastcall GetIsStandard(void);
__property int Command = {read=FCommand, write=FCommand, nodefault};
public:
__fastcall virtual TcxSchedulerNavigatorButton(System::Classes::TCollection* Collection);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__property int ActualImageIndex = {read=GetActualImageIndex, nodefault};
__property Vcl::Imglist::TCustomImageList* ActualImageList = {read=GetActualImageList};
__property System::Types::TRect Bounds = {read=FBounds};
__property bool Enabled = {read=FEnabled, write=SetEnabled, stored=IsEnabledStored, nodefault};
__property bool Rotated = {read=FRotated, nodefault};
__property TcxCustomScheduler* Scheduler = {read=GetScheduler};
__property bool IsStandard = {read=GetIsStandard, nodefault};
__property Cxlookandfeelpainters::TcxButtonState State = {read=FState, nodefault};
__property int VisibleIndex = {read=FVisibleIndex, nodefault};
__published:
__property System::UnicodeString Hint = {read=FHint, write=FHint, stored=IsHintStored};
__property int ImageIndex = {read=FImageIndex, write=SetImageIndex, default=-1};
__property bool Visible = {read=FVisible, write=SetVisible, stored=IsVisibleStored, nodefault};
public:
/* TCollectionItem.Destroy */ inline __fastcall virtual ~TcxSchedulerNavigatorButton(void) { }
};
class DELPHICLASS TcxSchedulerNavigatorCustomButton;
class PASCALIMPLEMENTATION TcxSchedulerNavigatorCustomButton : public TcxSchedulerNavigatorButton
{
typedef TcxSchedulerNavigatorButton inherited;
__published:
__property Enabled;
public:
/* TcxSchedulerNavigatorButton.Create */ inline __fastcall virtual TcxSchedulerNavigatorCustomButton(System::Classes::TCollection* Collection) : TcxSchedulerNavigatorButton(Collection) { }
public:
/* TCollectionItem.Destroy */ inline __fastcall virtual ~TcxSchedulerNavigatorCustomButton(void) { }
};
typedef System::TMetaClass* TcxSchedulerNavigatorButtonClass;
class DELPHICLASS TcxSchedulerNavigatorCustomButtons;
class PASCALIMPLEMENTATION TcxSchedulerNavigatorCustomButtons : public System::Classes::TCollection
{
typedef System::Classes::TCollection inherited;
public:
TcxSchedulerNavigatorCustomButton* operator[](int AIndex) { return Items[AIndex]; }
private:
System::Classes::TPersistent* FOwner;
TcxCustomScheduler* FScheduler;
HIDESBASE TcxSchedulerNavigatorCustomButton* __fastcall GetItem(int AIndex);
int __fastcall GetVisibleCount(void);
HIDESBASE void __fastcall SetItem(int AIndex, TcxSchedulerNavigatorCustomButton* AValue);
protected:
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
virtual void __fastcall Update(System::Classes::TCollectionItem* Item);
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
public:
__fastcall virtual TcxSchedulerNavigatorCustomButtons(System::Classes::TPersistent* AOwner, System::Classes::TCollectionItemClass AItemClass);
__property int VisibleCount = {read=GetVisibleCount, nodefault};
__property TcxSchedulerNavigatorCustomButton* Items[int AIndex] = {read=GetItem, write=SetItem/*, default*/};
public:
/* TCollection.Create */ inline __fastcall TcxSchedulerNavigatorCustomButtons(System::Classes::TCollectionItemClass ItemClass) : System::Classes::TCollection(ItemClass) { }
/* TCollection.Destroy */ inline __fastcall virtual ~TcxSchedulerNavigatorCustomButtons(void) { }
};
class DELPHICLASS TcxSchedulerNavigatorButtons;
class PASCALIMPLEMENTATION TcxSchedulerNavigatorButtons : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
TcxSchedulerNavigatorCustomButtons* FButtons;
TcxSchedulerResourceNavigator* FOwner;
TcxSchedulerNavigatorButton* __fastcall GetButtonByIndex(int AIndex);
void __fastcall SetButtonByIndex(int AIndex, TcxSchedulerNavigatorButton* AValue);
protected:
TcxSchedulerNavigatorButton* __fastcall AddButton(int ACommand, bool AVisible = true);
virtual void __fastcall CreateButtons(void);
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
public:
__fastcall virtual TcxSchedulerNavigatorButtons(TcxSchedulerResourceNavigator* AOwner);
__fastcall virtual ~TcxSchedulerNavigatorButtons(void);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__property TcxSchedulerNavigatorCustomButtons* Buttons = {read=FButtons};
__property TcxSchedulerResourceNavigator* ResourceNavigator = {read=FOwner};
__published:
__property TcxSchedulerNavigatorButton* First = {read=GetButtonByIndex, write=SetButtonByIndex, index=0};
__property TcxSchedulerNavigatorButton* PrevPage = {read=GetButtonByIndex, write=SetButtonByIndex, index=1};
__property TcxSchedulerNavigatorButton* Prev = {read=GetButtonByIndex, write=SetButtonByIndex, index=2};
__property TcxSchedulerNavigatorButton* Next = {read=GetButtonByIndex, write=SetButtonByIndex, index=3};
__property TcxSchedulerNavigatorButton* NextPage = {read=GetButtonByIndex, write=SetButtonByIndex, index=4};
__property TcxSchedulerNavigatorButton* Last = {read=GetButtonByIndex, write=SetButtonByIndex, index=5};
__property TcxSchedulerNavigatorButton* ShowFewerResources = {read=GetButtonByIndex, write=SetButtonByIndex, index=7};
__property TcxSchedulerNavigatorButton* ShowMoreResources = {read=GetButtonByIndex, write=SetButtonByIndex, index=6};
};
class DELPHICLASS TcxSchedulerResourceNavigatorController;
class DELPHICLASS TcxSchedulerHintController;
class PASCALIMPLEMENTATION TcxSchedulerResourceNavigatorController : public TcxSchedulerSubControlController
{
typedef TcxSchedulerSubControlController inherited;
private:
TcxSchedulerNavigatorButton* FHotTrackButton;
TcxSchedulerHintController* __fastcall GetHintController(void);
TcxSchedulerResourceNavigator* __fastcall GetResourceNavigator(void);
void __fastcall SetHotTrackButton(TcxSchedulerNavigatorButton* Value);
protected:
virtual void __fastcall BeforeMouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall CheckButtonDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift);
TcxSchedulerNavigatorButton* __fastcall GetHotTrackButton(bool ACanDisabled = true);
virtual void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseMove(System::Classes::TShiftState AShift, int X, int Y);
virtual void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseEnter(void);
virtual void __fastcall MouseLeave(void);
__property TcxSchedulerHintController* HintController = {read=GetHintController};
__property TcxSchedulerNavigatorButton* HotTrackButton = {read=FHotTrackButton, write=SetHotTrackButton};
__property TcxSchedulerResourceNavigator* ResourceNavigator = {read=GetResourceNavigator};
public:
/* TcxSchedulerSubControlController.Create */ inline __fastcall virtual TcxSchedulerResourceNavigatorController(TcxSchedulerSubControl* AOwner) : TcxSchedulerSubControlController(AOwner) { }
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerResourceNavigatorController(void) { }
};
class DELPHICLASS TcxSchedulerResourceNavigatorHitTest;
class PASCALIMPLEMENTATION TcxSchedulerResourceNavigatorHitTest : public TcxSchedulerSubControlHitTest
{
typedef TcxSchedulerSubControlHitTest inherited;
private:
TcxSchedulerNavigatorButton* __fastcall GetCurrentButton(TcxSchedulerNavigatorCustomButtons* AButtons);
bool __fastcall GetHitAtButton(void);
TcxSchedulerNavigatorButton* __fastcall GetHitButton(void);
TcxSchedulerResourceNavigator* __fastcall GetResourceNavigator(void);
public:
__property bool HitAtButton = {read=GetHitAtButton, nodefault};
__property TcxSchedulerNavigatorButton* HitButton = {read=GetHitButton};
__property TcxSchedulerResourceNavigator* ResourceNavigator = {read=GetResourceNavigator};
public:
/* TcxSchedulerSubControlHitTest.Create */ inline __fastcall virtual TcxSchedulerResourceNavigatorHitTest(TcxSchedulerSubControl* AOwner) : TcxSchedulerSubControlHitTest(AOwner) { }
/* TcxSchedulerSubControlHitTest.Destroy */ inline __fastcall virtual ~TcxSchedulerResourceNavigatorHitTest(void) { }
};
typedef void __fastcall (__closure *TcxSchedulerNavigatorCustomDrawButtonEvent)(TcxSchedulerResourceNavigator* Sender, Cxgraphics::TcxCanvas* ACanvas, TcxSchedulerNavigatorButton* AButton, bool &ADone);
enum TcxSchedulerNavigatorVisibilityMode : unsigned char { snvNever, snvAlways, snvAuto };
class PASCALIMPLEMENTATION TcxSchedulerResourceNavigator : public TcxSchedulerSubControl
{
typedef TcxSchedulerSubControl inherited;
private:
TcxSchedulerNavigatorButtons* FButtons;
Vcl::Imglist::TCustomImageList* FButtonImages;
TcxSchedulerNavigatorCustomButtons* FCustomButtons;
bool FShowButtons;
Vcl::Extctrls::TTimer* FTimer;
Vcl::Forms::TScrollBarKind FScrollBarKind;
TcxSchedulerNavigatorVisibilityMode FVisibility;
TcxSchedulerNavigatorButtonClickEvent FOnButtonClick;
TcxSchedulerNavigatorCustomDrawButtonEvent FOnCustomDrawButton;
int __fastcall GetFirstVisibleResourceIndex(void);
TcxSchedulerResourceNavigatorHitTest* __fastcall GetHitTest(void);
TcxSchedulerNavigatorButton* __fastcall GetItem(int AIndex);
int __fastcall GetItemCount(void);
int __fastcall GetResourceCount(void);
int __fastcall GetResourcesPerPage(void);
int __fastcall GetVisibleButtonCount(void);
void __fastcall SetButtonImages(Vcl::Imglist::TCustomImageList* Value);
void __fastcall SetButtons(TcxSchedulerNavigatorButtons* Value);
void __fastcall SetCustomButtons(TcxSchedulerNavigatorCustomButtons* Value);
void __fastcall SetFirstVisibleResourceIndex(int AValue);
void __fastcall SetResourcesPerPage(int AValue);
void __fastcall SetShowButtons(bool AValue);
void __fastcall SetVisibility(TcxSchedulerNavigatorVisibilityMode AValue);
bool __fastcall IsCustomButtonsStored(void);
protected:
TcxSchedulerNavigatorButton* FPressedButton;
int FVisibleButtonCount;
virtual void __fastcall BoundsChanged(void);
virtual void __fastcall ButtonClickHandler(TcxSchedulerNavigatorButton* AButton);
virtual void __fastcall CalculateBounds(void);
virtual void __fastcall CheckButtonsState(void);
void __fastcall Click(TcxSchedulerNavigatorButton* Sender);
virtual TcxSchedulerSubControlController* __fastcall CreateController(void);
virtual TcxSchedulerSubControlHitTest* __fastcall CreateHitTest(void);
virtual TcxSchedulerNavigatorCustomButtons* __fastcall CreateButtons(void);
virtual TcxSchedulerNavigatorButtons* __fastcall CreateStandardButtons(void);
virtual bool __fastcall DoCustomDrawButton(TcxSchedulerNavigatorButton* AButton);
virtual bool __fastcall DoOnClick(TcxSchedulerNavigatorButton* Sender);
virtual void __fastcall DoPaint(void);
void __fastcall FirstVisibleResourceChanged(void);
virtual TcxSchedulerNavigatorButtonClass __fastcall GetCustomButtonClass(void);
System::UnicodeString __fastcall GetScrollerHint(void);
virtual void __fastcall InitScrollBarsParameters(void);
void __fastcall InvalidateButton(TcxSchedulerNavigatorButton* AButton);
virtual void __fastcall Scroll(System::Uitypes::TScrollCode AScrollCode, int &AScrollPos);
int __fastcall ActualCountPerPage(void);
int __fastcall ActualFirstResourceIndex(void);
System::Types::TSize __fastcall ButtonSize(void);
virtual int __fastcall MeasureHeight(void);
virtual int __fastcall MeasureWidth(void);
__property int FirstVisibleResourceIndex = {read=GetFirstVisibleResourceIndex, write=SetFirstVisibleResourceIndex, nodefault};
__property TcxSchedulerResourceNavigatorHitTest* HitTest = {read=GetHitTest};
__property int ResourcesPerPage = {read=GetResourcesPerPage, write=SetResourcesPerPage, nodefault};
__property Vcl::Extctrls::TTimer* Timer = {read=FTimer};
public:
__fastcall virtual TcxSchedulerResourceNavigator(TcxCustomScheduler* AOwner);
__fastcall virtual ~TcxSchedulerResourceNavigator(void);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
virtual bool __fastcall NeedScrollBar(void);
__property int ItemCount = {read=GetItemCount, nodefault};
__property TcxSchedulerNavigatorButton* Items[int Index] = {read=GetItem};
__property int ResourceCount = {read=GetResourceCount, nodefault};
__property Scheduler;
__property Vcl::Forms::TScrollBarKind ScrollBarKind = {read=FScrollBarKind, nodefault};
__property int VisibleButtonCount = {read=FVisibleButtonCount, nodefault};
__published:
__property Vcl::Imglist::TCustomImageList* ButtonImages = {read=FButtonImages, write=SetButtonImages};
__property TcxSchedulerNavigatorButtons* Buttons = {read=FButtons, write=SetButtons};
__property TcxSchedulerNavigatorCustomButtons* CustomButtons = {read=FCustomButtons, write=SetCustomButtons, stored=IsCustomButtonsStored};
__property bool ShowButtons = {read=FShowButtons, write=SetShowButtons, default=1};
__property TcxSchedulerNavigatorVisibilityMode Visibility = {read=FVisibility, write=SetVisibility, default=2};
__property TcxSchedulerNavigatorButtonClickEvent OnButtonClick = {read=FOnButtonClick, write=FOnButtonClick};
__property TcxSchedulerNavigatorCustomDrawButtonEvent OnCustomDrawButton = {read=FOnCustomDrawButton, write=FOnCustomDrawButton};
};
class DELPHICLASS TcxSchedulerEventOperations;
class PASCALIMPLEMENTATION TcxSchedulerEventOperations : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
TcxCustomScheduler* FScheduler;
bool FCreating;
bool FDeleting;
bool FDialogEditing;
bool FDialogShowing;
bool FInplaceEditing;
bool FIntersection;
bool FMoving;
bool FMovingBetweenResources;
bool FReadOnly;
bool FRecurrence;
bool FSharingBetweenResources;
bool FSizing;
bool __fastcall GetCreating(void);
bool __fastcall GetCreatingStored(void);
bool __fastcall GetDeleting(void);
bool __fastcall GetDeletingStored(void);
bool __fastcall GetDialogEditing(void);
bool __fastcall GetDialogEditingStored(void);
bool __fastcall GetInplaceEditing(void);
bool __fastcall GetInplaceEditingStored(void);
bool __fastcall GetMoving(void);
bool __fastcall GetMovingBetweenResources(void);
bool __fastcall GetMovingBetweenResourcesStored(void);
bool __fastcall GetMovingStored(void);
bool __fastcall GetSizing(void);
bool __fastcall GetSizingStored(void);
protected:
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
public:
__fastcall virtual TcxSchedulerEventOperations(TcxCustomScheduler* AOwner);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__published:
__property bool Creating = {read=GetCreating, write=FCreating, stored=GetCreatingStored, nodefault};
__property bool Deleting = {read=GetDeleting, write=FDeleting, stored=GetDeletingStored, nodefault};
__property bool DialogEditing = {read=GetDialogEditing, write=FDialogEditing, stored=GetDialogEditingStored, nodefault};
__property bool DialogShowing = {read=FDialogShowing, write=FDialogShowing, default=1};
__property bool InplaceEditing = {read=GetInplaceEditing, write=FInplaceEditing, stored=GetInplaceEditingStored, nodefault};
__property bool Intersection = {read=FIntersection, write=FIntersection, default=1};
__property bool MovingBetweenResources = {read=GetMovingBetweenResources, write=FMovingBetweenResources, stored=GetMovingBetweenResourcesStored, nodefault};
__property bool Moving = {read=GetMoving, write=FMoving, stored=GetMovingStored, nodefault};
__property bool ReadOnly = {read=FReadOnly, write=FReadOnly, default=0};
__property bool Recurrence = {read=FRecurrence, write=FRecurrence, default=1};
__property bool SharingBetweenResources = {read=FSharingBetweenResources, write=FSharingBetweenResources, default=0};
__property bool Sizing = {read=GetSizing, write=FSizing, stored=GetSizingStored, nodefault};
public:
/* TPersistent.Destroy */ inline __fastcall virtual ~TcxSchedulerEventOperations(void) { }
};
class DELPHICLASS TcxSchedulerOptionsCustomize;
class PASCALIMPLEMENTATION TcxSchedulerOptionsCustomize : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
bool FControlsSizing;
bool FDynamicSizing;
bool FIntegralSizing;
TcxCustomScheduler* FScheduler;
void __fastcall SetControlsSizing(bool AValue);
void __fastcall SetIntegralSizing(bool AValue);
protected:
virtual void __fastcall Changed(void);
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
public:
__fastcall virtual TcxSchedulerOptionsCustomize(TcxCustomScheduler* AOwner);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
__published:
__property bool ControlsSizing = {read=FControlsSizing, write=SetControlsSizing, default=1};
__property bool DynamicSizing = {read=FDynamicSizing, write=FDynamicSizing, default=0};
__property bool IntegralSizing = {read=FIntegralSizing, write=SetIntegralSizing, default=1};
public:
/* TPersistent.Destroy */ inline __fastcall virtual ~TcxSchedulerOptionsCustomize(void) { }
};
enum TcxSchedulerHeaderImagePosition : unsigned char { ipLeft, ipTop, ipRight, ipBottom };
class DELPHICLASS TcxSchedulerResourceHeaders;
class DELPHICLASS TcxSchedulerOptionsView;
class PASCALIMPLEMENTATION TcxSchedulerResourceHeaders : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
int FHeight;
TcxSchedulerHeaderImagePosition FImagePosition;
bool FMultilineCaptions;
TcxSchedulerOptionsView* FOwner;
bool FRotateCaptions;
void __fastcall SetHeight(int AValue);
void __fastcall SetImagePosition(TcxSchedulerHeaderImagePosition AValue);
void __fastcall SetMultilineCaptions(bool AValue);
void __fastcall SetRotateCations(bool AValue);
bool __fastcall IsImagePositionStored(void);
protected:
void __fastcall Changed(void);
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
__property TcxSchedulerOptionsView* Owner = {read=FOwner};
public:
__fastcall virtual TcxSchedulerResourceHeaders(TcxSchedulerOptionsView* AOwner);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__published:
__property int Height = {read=FHeight, write=SetHeight, default=0};
__property bool MultilineCaptions = {read=FMultilineCaptions, write=SetMultilineCaptions, default=0};
__property TcxSchedulerHeaderImagePosition ImagePosition = {read=FImagePosition, write=SetImagePosition, stored=IsImagePositionStored, nodefault};
__property bool RotateCaptions = {read=FRotateCaptions, write=SetRotateCations, default=1};
public:
/* TPersistent.Destroy */ inline __fastcall virtual ~TcxSchedulerResourceHeaders(void) { }
};
class PASCALIMPLEMENTATION TcxSchedulerOptionsView : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
typedef System::StaticArray<System::UnicodeString, 2> _TcxSchedulerOptionsView__1;
private:
Cxdateutils::TDay FActualStartOfWeek;
bool FAdditionalTimeZoneDaylightSaving;
bool FCurrentTimeZoneDaylightSaving;
System::Uitypes::TColor FDayBorderColor;
System::Uitypes::TColor FEventBorderColor;
int FEventHeight;
TcxSchedulerGroupingKind FGroupingKind;
int FGroupSeparatorWidth;
bool FHideSelection;
int FHorzSplitterWidth;
bool FHotTrack;
TcxSchedulerResourceHeaders* FResourceHeaders;
int FResourcesPerPage;
TcxCustomScheduler* FScheduler;
bool FShowAdditionalTimeZone;
bool FShowEventsWithoutResource;
bool FShowHints;
bool FShowNavigationButtons;
Cxschedulerutils::TcxStartOfWeek FStartOfWeek;
_TcxSchedulerOptionsView__1 FTimeZoneLabels;
System::StaticArray<int, 2> FTimeZones;
int FVertSplitterWidth;
TcxSchedulerViewPosition FViewPosition;
Cxdateutils::TDays FWorkDays;
System::TTime FWorkFinish;
bool FWorkFinishAssigned;
System::TTime FWorkStart;
bool FWorkStartAssigned;
Cxschedulerutils::TcxSchedulerDateTimeHelperClass __fastcall GetDateTimeHelperClass(void);
bool __fastcall GetRotateResourceCaptions(void);
int __fastcall GetTimeZone(int AIndex);
System::UnicodeString __fastcall GetTimeZoneLabel(int AIndex);
bool __fastcall IsTimeZoneLabelStored(int AIndex);
void __fastcall SetATZDaylightSaving(bool AValue);
void __fastcall SetCTZDaylightSaving(bool AValue);
void __fastcall SetDayBorderColor(System::Uitypes::TColor AValue);
void __fastcall SetEventBorderColor(System::Uitypes::TColor AValue);
void __fastcall SetEventHeight(int AValue);
void __fastcall SetGroupingKind(TcxSchedulerGroupingKind AValue);
void __fastcall SetGroupSeparatorWidth(int AValue);
void __fastcall SetHideSelection(bool AValue);
void __fastcall SetHorzSplitterWidth(int AValue);
void __fastcall SetResourceHeaders(TcxSchedulerResourceHeaders* AValue);
void __fastcall SetResourcesPerPage(int AValue);
void __fastcall SetRotateResourceCaptions(bool AValue);
void __fastcall SetShowAdditionalTimeZone(bool AValue);
void __fastcall SetShowEventsWithoutResource(bool AValue);
void __fastcall SetShowNavigationButtons(bool AValue);
void __fastcall SetSplitterWidth(int AValue, int &AWidth);
void __fastcall SetStartOfWeek(Cxschedulerutils::TcxStartOfWeek AValue);
void __fastcall SetTimeZone(int AIndex, int AValue);
void __fastcall SetTimeZoneLabel(int AIndex, const System::UnicodeString AValue);
void __fastcall SetVertSplitterWidth(int AValue);
void __fastcall SetViewPosition(TcxSchedulerViewPosition AValue);
void __fastcall SetWorkDays(Cxdateutils::TDays AValue);
void __fastcall SetWorkFinish(System::TTime AValue);
void __fastcall SetWorkStart(System::TTime AValue);
void __fastcall ReadWorkFinish(System::Classes::TReader* AReader);
void __fastcall ReadWorkStart(System::Classes::TReader* AReader);
void __fastcall WriteWorkFinish(System::Classes::TWriter* AWriter);
void __fastcall WriteWorkStart(System::Classes::TWriter* AWriter);
protected:
void __fastcall CalculateActualStartOfWeek(void);
virtual void __fastcall Changed(void);
virtual void __fastcall DefineProperties(System::Classes::TFiler* Filer);
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
bool __fastcall IsWorkDaysStored(void);
bool __fastcall IsWorkTime(Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResourceItem, const System::TDateTime ADateTime);
__property Cxschedulerutils::TcxSchedulerDateTimeHelperClass DateTimeHelper = {read=GetDateTimeHelperClass};
__property bool HotTrack = {read=FHotTrack, write=FHotTrack, default=0};
public:
__fastcall virtual TcxSchedulerOptionsView(TcxCustomScheduler* AOwner);
__fastcall virtual ~TcxSchedulerOptionsView(void);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__property Cxdateutils::TDay ActualStartOfWeek = {read=FActualStartOfWeek, nodefault};
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
__published:
__property int AdditionalTimeZone = {read=GetTimeZone, write=SetTimeZone, index=0, default=-1};
__property bool AdditionalTimeZoneDaylightSaving = {read=FAdditionalTimeZoneDaylightSaving, write=SetATZDaylightSaving, default=0};
__property System::UnicodeString AdditionalTimeZoneLabel = {read=GetTimeZoneLabel, write=SetTimeZoneLabel, stored=IsTimeZoneLabelStored, index=0};
__property int CurrentTimeZone = {read=GetTimeZone, write=SetTimeZone, index=1, default=-1};
__property bool CurrentTimeZoneDaylightSaving = {read=FCurrentTimeZoneDaylightSaving, write=SetCTZDaylightSaving, default=0};
__property System::UnicodeString CurrentTimeZoneLabel = {read=GetTimeZoneLabel, write=SetTimeZoneLabel, stored=IsTimeZoneLabelStored, index=1};
__property System::Uitypes::TColor DayBorderColor = {read=FDayBorderColor, write=SetDayBorderColor, default=536870912};
__property System::Uitypes::TColor EventBorderColor = {read=FEventBorderColor, write=SetEventBorderColor, default=0};
__property int EventHeight = {read=FEventHeight, write=SetEventHeight, default=0};
__property TcxSchedulerGroupingKind GroupingKind = {read=FGroupingKind, write=SetGroupingKind, default=0};
__property int GroupSeparatorWidth = {read=FGroupSeparatorWidth, write=SetGroupSeparatorWidth, default=11};
__property bool HideSelection = {read=FHideSelection, write=SetHideSelection, default=0};
__property int HorzSplitterWidth = {read=FHorzSplitterWidth, write=SetHorzSplitterWidth, default=5};
__property TcxSchedulerResourceHeaders* ResourceHeaders = {read=FResourceHeaders, write=SetResourceHeaders};
__property int ResourcesPerPage = {read=FResourcesPerPage, write=SetResourcesPerPage, default=0};
__property bool RotateResourceCaptions = {read=GetRotateResourceCaptions, write=SetRotateResourceCaptions, default=1};
__property bool ShowAdditionalTimeZone = {read=FShowAdditionalTimeZone, write=SetShowAdditionalTimeZone, default=0};
__property bool ShowEventsWithoutResource = {read=FShowEventsWithoutResource, write=SetShowEventsWithoutResource, default=0};
__property bool ShowHints = {read=FShowHints, write=FShowHints, default=1};
__property bool ShowNavigationButtons = {read=FShowNavigationButtons, write=SetShowNavigationButtons, default=1};
__property Cxschedulerutils::TcxStartOfWeek StartOfWeek = {read=FStartOfWeek, write=SetStartOfWeek, default=0};
__property int VertSplitterWidth = {read=FVertSplitterWidth, write=SetVertSplitterWidth, default=5};
__property TcxSchedulerViewPosition ViewPosition = {read=FViewPosition, write=SetViewPosition, default=1};
__property Cxdateutils::TDays WorkDays = {read=FWorkDays, write=SetWorkDays, stored=IsWorkDaysStored, nodefault};
__property System::TTime WorkFinish = {read=FWorkFinish, write=SetWorkFinish, stored=false};
__property System::TTime WorkStart = {read=FWorkStart, write=SetWorkStart, stored=false};
};
enum TcxEventDragKind : unsigned char { edkNone, edkEventDragRect, edkMoveEvent, edkResizeStart, edkResizeEnd };
class DELPHICLASS TcxSchedulerViewHitTest;
class PASCALIMPLEMENTATION TcxSchedulerViewHitTest : public TcxSchedulerSubControlHitTest
{
typedef TcxSchedulerSubControlHitTest inherited;
private:
bool __fastcall GetHitAtEvent(void);
bool __fastcall GetNeedShowHint(void);
protected:
bool FNeedShowHint;
System::Types::TRect FEventBounds;
Cxschedulerstorage::TcxSchedulerStorageResourceItem* FResource;
virtual void __fastcall Clear(void);
virtual Cxschedulerstorage::TcxSchedulerControlEvent* __fastcall GetHitEvent(void);
__property bool NeedShowHint = {read=GetNeedShowHint, nodefault};
public:
virtual TcxEventDragKind __fastcall GetDragKind(void);
__property bool HitAtEvent = {read=GetHitAtEvent, nodefault};
__property bool HitAtResource = {read=GetBitState, index=2, nodefault};
__property Cxschedulerstorage::TcxSchedulerControlEvent* Event = {read=GetHitEvent};
__property Cxschedulerstorage::TcxSchedulerStorageResourceItem* Resource = {read=FResource};
public:
/* TcxSchedulerSubControlHitTest.Create */ inline __fastcall virtual TcxSchedulerViewHitTest(TcxSchedulerSubControl* AOwner) : TcxSchedulerSubControlHitTest(AOwner) { }
/* TcxSchedulerSubControlHitTest.Destroy */ inline __fastcall virtual ~TcxSchedulerViewHitTest(void) { }
};
class DELPHICLASS TcxSchedulerEditController;
class DELPHICLASS TcxSchedulerViewController;
class DELPHICLASS TcxSchedulerCustomView;
class PASCALIMPLEMENTATION TcxSchedulerEditController : public System::TObject
{
typedef System::TObject inherited;
private:
Cxedit::TcxCustomEdit* FEdit;
Cxedit::TcxCustomEditData* FEditData;
System::TDateTime FEditDate;
Cxedit::TcxInplaceEditList* FEditList;
Cxedit::TcxCustomEditProperties* FEditProperties;
Cxschedulerstorage::TcxSchedulerStorageResourceItem* FEditResource;
Cxschedulerstorage::TcxSchedulerControlEvent* FEvent;
bool FFocused;
bool FIsEditing;
bool FIsNewEvent;
TcxCustomScheduler* FOwner;
bool __fastcall CanAccept(void);
TcxSchedulerViewController* __fastcall GetController(void);
bool __fastcall GetEditVisible(void);
TcxSchedulerCustomView* __fastcall GetView(void);
void __fastcall SetEditVisible(bool Value);
protected:
virtual bool __fastcall GetEditRect(System::Types::TRect &R, const System::TDateTime ADate, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource, bool AMakeVisible = false);
virtual void __fastcall EditAfterKeyDown(System::TObject* Sender, System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall EditExit(System::TObject* Sender);
virtual void __fastcall EditKeyDown(System::TObject* Sender, System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall EditKeyPress(System::TObject* Sender, System::WideChar &Key);
virtual void __fastcall EditKeyUp(System::TObject* Sender, System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall EditPostEditValue(System::TObject* Sender);
virtual bool __fastcall InitEdit(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual bool __fastcall IsKeyForControl(System::Word &AKey, System::Classes::TShiftState Shift);
virtual void __fastcall PrepareEdit(Cxedit::TcxCustomEdit* AEdit);
__property Cxedit::TcxCustomEditProperties* EditProperties = {read=FEditProperties};
__property Cxedit::TcxCustomEditData* EditData = {read=FEditData};
__property Cxschedulerstorage::TcxSchedulerControlEvent* Event = {read=FEvent};
public:
__fastcall virtual TcxSchedulerEditController(TcxCustomScheduler* AOwner);
__fastcall virtual ~TcxSchedulerEditController(void);
void __fastcall Activate(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent)/* overload */;
void __fastcall Activate(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, const System::Types::TPoint APos, System::Classes::TShiftState AShift)/* overload */;
void __fastcall Activate(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::WideChar Key)/* overload */;
virtual void __fastcall CloseEdit(bool Accepted);
void __fastcall DeleteEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
void __fastcall Init(const System::TDateTime AEditDate, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource, bool AIsNewEvent = false);
virtual void __fastcall UpdateEdit(void);
virtual void __fastcall UpdateValue(void);
__property TcxSchedulerViewController* Controller = {read=GetController};
__property Cxedit::TcxCustomEdit* Edit = {read=FEdit};
__property bool EditVisible = {read=GetEditVisible, write=SetEditVisible, nodefault};
__property bool Focused = {read=FFocused, write=FFocused, nodefault};
__property bool IsEditing = {read=FIsEditing, nodefault};
__property TcxCustomScheduler* Scheduler = {read=FOwner};
__property TcxSchedulerCustomView* View = {read=GetView};
};
class DELPHICLASS TcxSchedulerViewNavigation;
class PASCALIMPLEMENTATION TcxSchedulerViewNavigation : public System::TObject
{
typedef System::TObject inherited;
private:
TcxSchedulerCustomView* FView;
TcxSchedulerResourceNavigator* __fastcall GetResourceNavigator(void);
TcxCustomScheduler* __fastcall GetScheduler(void);
System::TDateTime __fastcall GetSelAnchor(void);
System::TDateTime __fastcall GetSelRealStart(void);
System::TDateTime __fastcall GetSelFinish(void);
Cxschedulerstorage::TcxSchedulerStorageResourceItem* __fastcall GetSelResource(void);
System::TDateTime __fastcall GetSelStart(void);
System::TDateTime __fastcall GetTimeIncrement(void);
Cxschedulerstorage::TcxSchedulerStorageResourceItem* __fastcall GetVisibleResource(int AIndex);
int __fastcall GetVisibleResourceCount(void);
protected:
System::TDateTime FCurrentAnchor;
Cxschedulerstorage::TcxSchedulerStorageResourceItem* FCurrentResource;
System::Classes::TShiftState FShift;
virtual void __fastcall DoKeyDown(System::Word &AKey, System::Classes::TShiftState AShift);
virtual bool __fastcall IsKeyNavigation(System::Word &AKey, System::Classes::TShiftState AShift);
bool __fastcall IsSingleLine(void);
virtual Cxschedulerstorage::TcxSchedulerStorageResourceItem* __fastcall GetResourceItem(void);
virtual void __fastcall KeyDown(System::Word &AKey, System::Classes::TShiftState AShift);
void __fastcall ReplaceDate(System::TDateTime ADate, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource = (Cxschedulerstorage::TcxSchedulerStorageResourceItem*)(0x0));
public:
__fastcall TcxSchedulerViewNavigation(TcxSchedulerCustomView* AView);
void __fastcall CheckSelection(void);
void __fastcall ReplaceSelParams(const System::TDateTime ASelStart, const System::TDateTime ASelFinish)/* overload */;
void __fastcall ReplaceSelParams(const System::TDateTime ASelStart, const System::TDateTime ASelFinish, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource)/* overload */;
void __fastcall ReplaceSelParams(Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource)/* overload */;
bool __fastcall ScrollResources(bool AGoForward);
bool __fastcall ScrollResourcesCycled(bool AGoForward, Cxschedulerstorage::TcxSchedulerStorageResourceItem* &AResource);
virtual bool __fastcall ScrollResourcesEx(bool AGoForward, Cxschedulerstorage::TcxSchedulerStorageResourceItem* &AResource);
void __fastcall SetSelAnchor(const System::TDateTime Anchor, System::Classes::TShiftState AShift)/* overload */;
void __fastcall SetSelAnchor(const System::TDateTime Anchor, System::Classes::TShiftState AShift, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource)/* overload */;
virtual void __fastcall ValidateSelection(System::TDateTime &ASelStart, System::TDateTime &ASelFinish, Cxschedulerstorage::TcxSchedulerStorageResourceItem* &AResource);
__property TcxSchedulerResourceNavigator* ResourceNavigator = {read=GetResourceNavigator};
__property System::TDateTime SelAnchor = {read=GetSelAnchor};
__property System::TDateTime SelFinish = {read=GetSelFinish};
__property System::TDateTime SelRealStart = {read=GetSelRealStart};
__property Cxschedulerstorage::TcxSchedulerStorageResourceItem* SelResource = {read=GetSelResource};
__property System::TDateTime SelStart = {read=GetSelStart};
__property TcxCustomScheduler* Scheduler = {read=GetScheduler};
__property System::TDateTime TimeIncrement = {read=GetTimeIncrement};
__property TcxSchedulerCustomView* View = {read=FView};
__property int VisibleResourceCount = {read=GetVisibleResourceCount, nodefault};
__property Cxschedulerstorage::TcxSchedulerStorageResourceItem* VisibleResources[int AIndex] = {read=GetVisibleResource};
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerViewNavigation(void) { }
};
class DELPHICLASS TcxDragEventHelper;
class DELPHICLASS TcxSchedulerDragAndDropObject;
class DELPHICLASS TcxEventSizingHelper;
class PASCALIMPLEMENTATION TcxSchedulerViewController : public TcxSchedulerSubControlController
{
typedef TcxSchedulerSubControlController inherited;
private:
Vcl::Extctrls::TTimer* FEditShowingTimer;
Cxschedulerstorage::TcxSchedulerControlEvent* FEditShowingTimerItem;
TcxDragEventHelper* FDragEventHelper;
Cxschedulerstorage::TcxSchedulerControlEvent* FDragEvent;
TcxEventDragKind FDragKind;
TcxSchedulerViewNavigation* FNavigation;
__int64 FStartDragFlags;
System::TDateTime FStartDragHitTime;
Cxschedulerstorage::TcxSchedulerStorageResourceItem* FStartDragResource;
void __fastcall EditShowingTimerHandler(System::TObject* Sender);
TcxSchedulerEditController* __fastcall GetEditController(void);
HIDESBASE TcxSchedulerViewHitTest* __fastcall GetHitTest(void);
bool __fastcall GetIsEditing(void);
Vcl::Extctrls::TTimer* __fastcall GetNavigatorTimer(void);
TcxCustomScheduler* __fastcall GetScheduler(void);
TcxSchedulerCustomView* __fastcall GetView(void);
void __fastcall ShowEventEditor(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
void __fastcall StartEditShowingTimer(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
void __fastcall StopEditShowingTimer(void);
protected:
TcxSchedulerDragAndDropObject* DragAndDropObject;
System::Types::TRect FDownScrollArea;
Cxschedulerstorage::TcxSchedulerControlEvent* FBeforeFocusedEvent;
System::TDateTime FStartSelAnchor;
System::Types::TRect FUpScrollArea;
virtual void __fastcall BeforeMouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall CancelScroll(void);
virtual bool __fastcall CanDrag(int X, int Y);
virtual void __fastcall CheckOpenInplaceEditorOnMouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall CheckScrolling(const System::Types::TPoint APos);
void __fastcall CheckScrollOnDragOver(const System::Types::TPoint P, System::Uitypes::TDragState State);
void __fastcall CheckUpdateEventBounds(void);
void __fastcall CloseInplaceEdit(void);
virtual bool __fastcall ConsiderHiddenEvents(void);
virtual TcxDragEventHelper* __fastcall CreateDragEventHelper(void);
virtual TcxSchedulerViewNavigation* __fastcall CreateNavigation(void);
virtual TcxEventSizingHelper* __fastcall CreateResizeEventHelper(void);
void __fastcall DoSchedulerDragOver(const System::Types::TPoint P, System::Uitypes::TDragState AState, bool &AAccept);
virtual void __fastcall DragOver(System::TObject* Source, int X, int Y, System::Uitypes::TDragState State, bool &Accept);
virtual void __fastcall EndDrag(System::TObject* Target, int X, int Y);
virtual Cxcontrols::TcxDragAndDropObjectClass __fastcall GetDragAndDropObjectClass(void);
bool __fastcall GetResourceReadOnly(void);
bool __fastcall IsCaptionAvailable(void);
bool __fastcall IsCopyDragDrop(void);
bool __fastcall IsDragOperation(void);
virtual void __fastcall KeyDown(System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall KeyPress(System::WideChar &Key);
virtual void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseMove(System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
void __fastcall RecreateNavigation(void);
virtual void __fastcall SelectNextEvent(bool AForward);
virtual void __fastcall StartDrag(Vcl::Controls::TDragObject* &DragObject);
virtual bool __fastcall StartDragAndDrop(const System::Types::TPoint P);
virtual void __fastcall SyncEventSelection(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
void __fastcall UnselectEvents(void);
void __fastcall UpdateEventSelection(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift);
virtual void __fastcall CheckNavigatorScrollArea(const System::Types::TPoint APoint);
virtual void __fastcall DoneNavigatorScrollArea(void);
virtual void __fastcall InitNavigatorScrollArea(void);
virtual void __fastcall NavigatorTimerHandler(System::TObject* Sender);
bool __fastcall PtInArea(const System::Types::TRect &ARect, const System::Types::TPoint P, bool IsUpArea);
__property TcxSchedulerEditController* EditController = {read=GetEditController};
__property TcxDragEventHelper* DragEventHelper = {read=FDragEventHelper};
__property TcxSchedulerViewHitTest* HitTest = {read=GetHitTest};
__property Vcl::Extctrls::TTimer* NavigatorTimer = {read=GetNavigatorTimer};
__property TcxSchedulerCustomView* View = {read=GetView};
public:
__fastcall virtual TcxSchedulerViewController(TcxSchedulerSubControl* AOwner);
__fastcall virtual ~TcxSchedulerViewController(void);
virtual bool __fastcall CanCreateEventUsingDialog(void);
virtual bool __fastcall CanCreateEventUsingInplaceEdit(void);
virtual bool __fastcall CanEditEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool AInplace);
virtual bool __fastcall CanShowEventDialog(void);
void __fastcall DeleteSelectedEvents(void);
bool __fastcall IsEventEditing(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
void __fastcall SelectSingleEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::TDateTime ADate, bool AMakeVisible = true);
__property Cxschedulerstorage::TcxSchedulerControlEvent* DragEvent = {read=FDragEvent};
__property TcxEventDragKind DragKind = {read=FDragKind, nodefault};
__property bool IsEditing = {read=GetIsEditing, nodefault};
__property TcxSchedulerViewNavigation* Navigation = {read=FNavigation};
__property TcxCustomScheduler* Scheduler = {read=GetScheduler};
__property __int64 StartDragFlags = {read=FStartDragFlags};
__property System::TDateTime StartDragHitTime = {read=FStartDragHitTime};
__property Cxschedulerstorage::TcxSchedulerStorageResourceItem* StartDragResource = {read=FStartDragResource};
};
enum TcxSchedulerDragOverDestination : unsigned char { dodView, dodControlBox, dodDateNavigator, dodOther };
class DELPHICLASS TcxDragHelper;
class DELPHICLASS TcxSchedulerCustomDateNavigator;
class PASCALIMPLEMENTATION TcxDragHelper : public System::TObject
{
typedef System::TObject inherited;
private:
System::TDateTime FActualHitTime;
bool FAcceptedChanged;
TcxSchedulerDragOverDestination FDestination;
System::Uitypes::TCursor FSaveCursor;
TcxCustomScheduler* FScheduler;
System::TDateTime __fastcall GetActualHitTime(void);
TcxSchedulerViewController* __fastcall GetController(void);
TcxSchedulerCustomDateNavigator* __fastcall GetDateNavigator(void);
Cxschedulerstorage::TcxSchedulerCachedEventList* __fastcall GetEvents(void);
TcxSchedulerViewHitTest* __fastcall GetHitTest(void);
protected:
bool FHasConflicts;
bool FPrevAccepted;
__int64 FPrevHitFlags;
System::TDateTime FPrevHitTime;
Cxschedulerstorage::TcxSchedulerStorageResourceItem* FPrevHitResource;
System::TDateTime FStartHitTime;
__int64 FStartHitFlags;
Cxschedulerstorage::TcxSchedulerStorageResourceItem* FStartResource;
virtual void __fastcall BeginDrag(void);
void __fastcall CalculateConflicts(void);
void __fastcall CalculateDestination(void);
bool __fastcall CanUpdateEventState(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual void __fastcall CheckAccepted(bool &Accepted);
void __fastcall CheckEventState(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual void __fastcall DragOver(const System::Types::TPoint P, System::Uitypes::TDragState State, bool &Accepted);
virtual void __fastcall EndDrag(bool Accepted);
virtual __int64 __fastcall GetOriginHitTestMask(void);
virtual void __fastcall GetOriginState(void);
virtual bool __fastcall HasChangedState(void);
virtual bool __fastcall IsAtOrigin(void);
bool __fastcall IsShowResources(void);
virtual bool __fastcall IsValidTime(void);
virtual void __fastcall RefreshCurrentView(void);
virtual void __fastcall SetSelection(void);
virtual void __fastcall UpdateHelperState(bool Accepted);
__property System::Uitypes::TCursor SaveCursor = {read=FSaveCursor, nodefault};
public:
__fastcall virtual TcxDragHelper(TcxCustomScheduler* AScheduler);
__property System::TDateTime ActualHitTime = {read=FActualHitTime};
__property TcxSchedulerViewController* Controller = {read=GetController};
__property TcxSchedulerCustomDateNavigator* DateNavigator = {read=GetDateNavigator};
__property TcxSchedulerDragOverDestination Destination = {read=FDestination, nodefault};
__property Cxschedulerstorage::TcxSchedulerCachedEventList* Events = {read=GetEvents};
__property bool HasConflicts = {read=FHasConflicts, nodefault};
__property TcxSchedulerViewHitTest* HitTest = {read=GetHitTest};
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxDragHelper(void) { }
};
class DELPHICLASS TcxSchedulerDragObject;
class PASCALIMPLEMENTATION TcxSchedulerDragObject : public Cxcontrols::TcxDragControlObject
{
typedef Cxcontrols::TcxDragControlObject inherited;
private:
bool FUseInternalCursors;
TcxDragEventHelper* __fastcall GetDragEventHelper(void);
Cxschedulerstorage::TcxSchedulerFilteredEventList* __fastcall GetDragEvents(void);
bool __fastcall GetHasConflicts(void);
TcxCustomScheduler* __fastcall GetScheduler(void);
protected:
virtual void __fastcall Finished(System::TObject* Target, int X, int Y, bool Accepted);
virtual System::Uitypes::TCursor __fastcall GetDragCursor(bool Accepted, int X, int Y);
public:
__fastcall virtual TcxSchedulerDragObject(Vcl::Controls::TControl* AControl);
void __fastcall CalculateConflictsForDateNavigator(TcxSchedulerCustomDateNavigator* ADateNavigator);
void __fastcall DropToDateNavigator(TcxSchedulerCustomDateNavigator* ADateNavigator);
__property TcxDragEventHelper* DragEventHelper = {read=GetDragEventHelper};
__property Cxschedulerstorage::TcxSchedulerFilteredEventList* DragEvents = {read=GetDragEvents};
__property bool HasConflicts = {read=GetHasConflicts, nodefault};
__property TcxCustomScheduler* Scheduler = {read=GetScheduler};
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerDragObject(void) { }
};
class DELPHICLASS TcxSchedulerCustomViewViewInfo;
class PASCALIMPLEMENTATION TcxDragEventHelper : public TcxDragHelper
{
typedef TcxDragHelper inherited;
private:
Vcl::Controls::TDragObject* FDragObject;
Cxschedulerstorage::TcxSchedulerFilteredEventList* __fastcall GetClones(void);
TcxSchedulerCustomViewViewInfo* __fastcall GetViewInfo(void);
protected:
bool FPrevIsDragCopy;
System::TObject* FTarget;
virtual void __fastcall ApplyChanges(void);
virtual void __fastcall BeginDrag(void);
virtual void __fastcall CheckAccepted(bool &Accepted);
void __fastcall CheckVisibility(bool Accepted);
virtual void __fastcall DragOver(const System::Types::TPoint P, System::Uitypes::TDragState State, bool &Accepted);
virtual void __fastcall EndDrag(bool Accepted);
void __fastcall DateNavigatorEndDrag(void);
virtual bool __fastcall GetClonesVisible(bool Accepted);
virtual bool __fastcall GetIsDragCopy(void);
virtual void __fastcall GetOriginState(void);
virtual bool __fastcall GetSourcesVisible(bool Accepted);
virtual bool __fastcall HasChangedState(void);
virtual bool __fastcall IsValidNavigatorDate(void);
virtual bool __fastcall IsValidTime(void);
void __fastcall PrepareClones(void);
void __fastcall ProcessDateNavigator(TcxSchedulerCustomDateNavigator* ADateNavigator);
virtual void __fastcall SetSelection(void);
void __fastcall Update(bool Accepted = true);
void __fastcall UpdateClones(void);
virtual void __fastcall UpdateHelperState(bool Accepted);
virtual void __fastcall UpdateDateNavigatorClones(TcxSchedulerCustomDateNavigator* ADateNavigator);
virtual void __fastcall UpdateDateNavigator(bool &Accepted);
virtual void __fastcall UpdateViewClones(void);
void __fastcall UpdateViewClonesResources(void);
virtual void __fastcall UpdateViewClonesTime(void);
__property Cxschedulerstorage::TcxSchedulerFilteredEventList* Clones = {read=GetClones};
__property Vcl::Controls::TDragObject* DragObject = {read=FDragObject};
__property bool IsDragCopy = {read=GetIsDragCopy, nodefault};
__property TcxSchedulerCustomViewViewInfo* ViewInfo = {read=GetViewInfo};
public:
/* TcxDragHelper.Create */ inline __fastcall virtual TcxDragEventHelper(TcxCustomScheduler* AScheduler) : TcxDragHelper(AScheduler) { }
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxDragEventHelper(void) { }
};
class PASCALIMPLEMENTATION TcxEventSizingHelper : public TcxDragHelper
{
typedef TcxDragHelper inherited;
private:
Cxschedulerstorage::TcxSchedulerControlEvent* __fastcall GetEvent(void);
HIDESBASE TcxSchedulerViewHitTest* __fastcall GetHitTest(void);
protected:
virtual void __fastcall BeginDrag(void);
virtual void __fastcall DragOver(const System::Types::TPoint P, System::Uitypes::TDragState State, bool &Accepted);
virtual void __fastcall EndDrag(bool Accepted);
virtual System::Uitypes::TCursor __fastcall GetDragCursor(bool Accepted);
virtual bool __fastcall IsValidTime(void);
virtual void __fastcall CalcAllDayEvent(void);
virtual System::TDateTime __fastcall GetFinishTime(void);
virtual System::TDateTime __fastcall GetStartTime(void);
virtual void __fastcall UpdateEventBounds(void);
__property Cxschedulerstorage::TcxSchedulerControlEvent* Event = {read=GetEvent};
__property TcxSchedulerViewHitTest* HitTest = {read=GetHitTest};
public:
/* TcxDragHelper.Create */ inline __fastcall virtual TcxEventSizingHelper(TcxCustomScheduler* AScheduler) : TcxDragHelper(AScheduler) { }
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxEventSizingHelper(void) { }
};
class PASCALIMPLEMENTATION TcxSchedulerDragAndDropObject : public Cxcontrols::TcxDragAndDropObject
{
typedef Cxcontrols::TcxDragAndDropObject inherited;
private:
TcxEventSizingHelper* FSizingHelper;
TcxCustomScheduler* FScheduler;
TcxSchedulerViewController* __fastcall GetController(void);
TcxSchedulerViewHitTest* __fastcall GetHitTest(void);
protected:
virtual void __fastcall BeginDragAndDrop(void);
virtual void __fastcall DragAndDrop(const System::Types::TPoint P, bool &Accepted);
virtual void __fastcall EndDragAndDrop(bool Accepted);
virtual System::Uitypes::TCursor __fastcall GetDragAndDropCursor(bool Accepted);
public:
__fastcall virtual TcxSchedulerDragAndDropObject(Cxcontrols::TcxControl* AControl);
__fastcall virtual ~TcxSchedulerDragAndDropObject(void);
__property TcxSchedulerViewController* Controller = {read=GetController};
__property TcxEventSizingHelper* SizingHelper = {read=FSizingHelper};
__property TcxSchedulerViewHitTest* HitTest = {read=GetHitTest};
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
};
class PASCALIMPLEMENTATION TcxSchedulerHintController : public Dxcoreclasses::TcxIUnknownObject
{
typedef Dxcoreclasses::TcxIUnknownObject inherited;
protected:
bool FAutoHide;
Vcl::Controls::THintWindow* FHintWindow;
TcxCustomScheduler* FOwner;
int FHintFlags;
System::Types::TRect FHintRect;
System::UnicodeString FHintText;
bool FLockHint;
bool FShowing;
Vcl::Extctrls::TTimer* FTimer;
bool FViewMode;
void __fastcall MouseLeave(void);
virtual bool __fastcall CanShowHint(void);
void __fastcall CheckHintClass(void);
virtual void __fastcall HideHint(void);
virtual void __fastcall ShowHint(void);
void __fastcall StartHideHintTimer(void);
void __fastcall StartShowHintTimer(void);
void __fastcall StopTimer(void);
void __fastcall TimerHandler(System::TObject* Sender);
int HintWindowAnchor;
public:
__fastcall virtual TcxSchedulerHintController(TcxCustomScheduler* AOwner);
__fastcall virtual ~TcxSchedulerHintController(void);
virtual void __fastcall Activate(const System::Types::TRect &AHintRect, const System::UnicodeString AHintText, bool AImmediateHint = false, bool AAutoHide = true);
System::Types::TRect __fastcall CalcHintRect(int AMaxWidth, const System::UnicodeString AHintText, int AFlags);
void __fastcall Hide(void);
void __fastcall Reset(void);
__property TcxCustomScheduler* Scheduler = {read=FOwner};
__property bool ViewMode = {read=FViewMode, write=FViewMode, nodefault};
__property bool Showing = {read=FShowing, nodefault};
private:
void *__IcxMouseTrackingCaller; /* Cxcontrols::IcxMouseTrackingCaller */
public:
#if defined(MANAGED_INTERFACE_OPERATORS)
// {84A4BCBE-E001-4D60-B7A6-75E2B0DCD3E9}
operator Cxcontrols::_di_IcxMouseTrackingCaller()
{
Cxcontrols::_di_IcxMouseTrackingCaller intf;
GetInterface(intf);
return intf;
}
#else
operator Cxcontrols::IcxMouseTrackingCaller*(void) { return (Cxcontrols::IcxMouseTrackingCaller*)&__IcxMouseTrackingCaller; }
#endif
#if defined(MANAGED_INTERFACE_OPERATORS)
// {00000000-0000-0000-C000-000000000046}
operator System::_di_IInterface()
{
System::_di_IInterface intf;
GetInterface(intf);
return intf;
}
#else
operator System::IInterface*(void) { return (System::IInterface*)&__IcxMouseTrackingCaller; }
#endif
};
class DELPHICLASS TcxSchedulerEventHitTestController;
class PASCALIMPLEMENTATION TcxSchedulerEventHitTestController : public System::TObject
{
typedef System::TObject inherited;
private:
TcxSchedulerHintController* __fastcall GetHintController(void);
TcxSchedulerViewHitTest* __fastcall GetHitTest(void);
protected:
TcxCustomScheduler* FOwner;
Cxschedulerstorage::TcxSchedulerControlEvent* FPrevHintEvent;
public:
__fastcall virtual TcxSchedulerEventHitTestController(TcxCustomScheduler* AOwner);
void __fastcall HideEventHint(void);
virtual void __fastcall MouseMove(int X, int Y, System::Classes::TShiftState AShift);
__property TcxSchedulerViewHitTest* HitTest = {read=GetHitTest};
__property TcxSchedulerHintController* HintController = {read=GetHintController};
__property TcxCustomScheduler* Scheduler = {read=FOwner};
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerEventHitTestController(void) { }
};
class PASCALIMPLEMENTATION TcxSchedulerCustomView : public TcxSchedulerSubControl
{
typedef TcxSchedulerSubControl inherited;
private:
bool FCalculatedHintBounds;
bool FCanShow;
bool __fastcall GetActive(void);
bool __fastcall GetCanShow(void);
TcxSchedulerViewController* __fastcall GetController(void);
Cxschedulerstorage::TcxSchedulerFilteredEventList* __fastcall GetDragCloneEventList(void);
Cxschedulerstorage::TcxSchedulerCachedEventList* __fastcall GetEventList(void);
TcxSchedulerViewHitTest* __fastcall GetHitTest(void);
TcxSchedulerOptionsView* __fastcall GetOptionsView(void);
Cxschedulerstorage::TcxSchedulerStorageResourceItems* __fastcall GetResources(void);
Cxschedulerutils::TcxSchedulerDateList* __fastcall GetSelectedDays(void);
Cxdateutils::TDays __fastcall GetWorkDays(void);
System::TDateTime __fastcall GetWorkFinish(void);
System::TDateTime __fastcall GetWorkStart(void);
void __fastcall SetActive(bool AValue);
void __fastcall SetCanShow(bool AValue);
protected:
virtual bool __fastcall CanDeactivateOnDateNavigatorSelectionChange(void);
virtual bool __fastcall CanEventEdit(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool AInplace);
virtual bool __fastcall CanSelectPeriod(void);
virtual bool __fastcall CheckEventsVisibility(void);
virtual TcxSchedulerSubControlController* __fastcall CreateController(void);
virtual TcxSchedulerSubControlHitTest* __fastcall CreateHitTest(void);
virtual void __fastcall DateChanged(void);
virtual void __fastcall DeactivateView(void);
virtual void __fastcall DoLayoutChanged(void);
virtual bool __fastcall DoShowPopupMenu(int X, int Y);
virtual bool __fastcall EventContentSelected(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual void __fastcall EventsListChanged(void);
virtual System::Types::TRect __fastcall GetClientRect(void);
virtual Cxgraphics::TcxCanvas* __fastcall GetControlCanvas(void);
int __fastcall GetDateOffset(void);
virtual Cxcontrols::TDragControlObjectClass __fastcall GetDragObjectClass(void);
virtual Dxtouch::_di_IdxGestureClient __fastcall GetGestureClient(const System::Types::TPoint APoint);
virtual TcxSchedulerGroupingKind __fastcall GetGroupingKind(void);
virtual System::Types::TRect __fastcall GetHScrollBarBounds(void);
virtual System::Types::TRect __fastcall GetEditRectForEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, const System::TDateTime ADate, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
virtual Cxedit::TcxCustomEditStyle* __fastcall GetEditStyle(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual Cxedit::TcxCustomEditProperties* __fastcall GetEditProperties(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual bool __fastcall GetEditWithSingleLineEditor(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual System::UnicodeString __fastcall GetEventHintText(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual bool __fastcall GetEventVisibility(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual System::TDateTime __fastcall GetFirstVisibleDate(void);
virtual System::TDateTime __fastcall GetFirstVisibleTime(void);
virtual System::TDateTime __fastcall GetLastVisibleDate(void);
virtual System::TDateTime __fastcall GetLastVisibleTime(void);
Cxlookandfeels::TcxLookAndFeel* __fastcall GetSchedulerLookAndFeel(bool ADialogs = false);
virtual System::UnicodeString __fastcall GetScrollTimeHint(void);
virtual bool __fastcall GetShowEventsWithoutResource(void);
virtual System::Types::TRect __fastcall GetSizeGripBounds(void);
virtual System::TDateTime __fastcall GetTimeIncrement(void);
virtual System::Types::TRect __fastcall GetVScrollBarBounds(void);
virtual System::Types::TRect __fastcall GetViewContentRect(void);
virtual int __fastcall GetVisibleDaysRange(void);
virtual void __fastcall InitEventBySelectedTime(Cxschedulerstorage::TcxSchedulerEvent* AEvent, bool AllDay, bool ARecurrence, bool AInplaceEditing);
bool __fastcall IsAllDaySelection(void);
virtual bool __fastcall IsDayView(void);
virtual bool __fastcall IsInplaceEditingEnabled(void);
virtual bool __fastcall IsShowResources(void);
bool __fastcall IsWorkTime(Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResourceItem, const System::TDateTime ADateTime);
virtual void __fastcall MakeEventVisible(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, const System::TDateTime ADate, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
virtual bool __fastcall NeedPanningFeedback(Vcl::Forms::TScrollBarKind AScrollKind);
virtual void __fastcall PeriodChanged(void);
virtual void __fastcall Scroll(Vcl::Forms::TScrollBarKind AScrollBarKind, System::Uitypes::TScrollCode AScrollCode, int &AScrollPos);
virtual void __fastcall ScrollSelectedDays(int AScrollDelta)/* overload */;
virtual void __fastcall ScrollSelectedDays(bool AForward, System::TDateTime ANeedDate, bool AIsByPage)/* overload */;
virtual void __fastcall ScrollVisibleDays(bool AScrollUp);
virtual void __fastcall SelectedDaysChanged(void);
virtual bool __fastcall ShowTaskComplete(void);
virtual void __fastcall TimeChanged(void);
void __fastcall UpdateDateNavigatorSelection(void);
virtual void __fastcall ValidateContentPopupMenuItems(TcxSchedulerContentPopupMenuItems &AItems);
virtual void __fastcall ValidateSelectionFinishTime(System::TDateTime &ADateTime);
virtual void __fastcall VisibleChanged(void);
virtual void __fastcall HideHintOnScroll(System::Uitypes::TScrollCode AScrollCode);
virtual void __fastcall ShowHintOnScroll(const System::TDateTime ADate)/* overload */;
virtual void __fastcall ShowHintOnScroll(const System::UnicodeString AHintText, Vcl::Forms::TScrollBarKind AScrollBarKind)/* overload */;
__property bool CalculatedHintBounds = {read=FCalculatedHintBounds, nodefault};
__property TcxSchedulerViewController* Controller = {read=GetController};
__property Cxschedulerstorage::TcxSchedulerCachedEventList* EventList = {read=GetEventList};
__property System::TDateTime FirstVisibleTime = {read=GetFirstVisibleTime};
__property System::TDateTime LastVisibleTime = {read=GetLastVisibleTime};
__property TcxSchedulerOptionsView* OptionsView = {read=GetOptionsView};
__property Cxschedulerstorage::TcxSchedulerStorageResourceItems* Resources = {read=GetResources};
__property Cxdateutils::TDays WorkDays = {read=GetWorkDays, nodefault};
__property System::TDateTime WorkStart = {read=GetWorkStart};
__property System::TDateTime WorkFinish = {read=GetWorkFinish};
public:
__fastcall virtual TcxSchedulerCustomView(TcxCustomScheduler* AOwner);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__property bool Active = {read=GetActive, write=SetActive, default=0};
__property bool CanShow = {read=GetCanShow, write=SetCanShow, default=1};
__property Cxschedulerstorage::TcxSchedulerFilteredEventList* DragCloneEventList = {read=GetDragCloneEventList};
__property System::TDateTime FirstVisibleDate = {read=GetFirstVisibleDate};
__property TcxSchedulerViewHitTest* HitTest = {read=GetHitTest};
__property System::TDateTime LastVisibleDate = {read=GetLastVisibleDate};
__property Cxschedulerutils::TcxSchedulerDateList* SelectedDays = {read=GetSelectedDays};
__property StartOfWeek;
public:
/* TcxSchedulerSubControl.Destroy */ inline __fastcall virtual ~TcxSchedulerCustomView(void) { }
};
class PASCALIMPLEMENTATION TcxSchedulerCustomViewViewInfo : public TcxSchedulerSubControlViewInfo
{
typedef TcxSchedulerSubControlViewInfo inherited;
private:
TcxSchedulerResourceNavigator* __fastcall GetResourceNavigator(void);
TcxCustomScheduler* __fastcall GetScheduler(void);
protected:
Cxschedulerstorage::TcxSchedulerCachedEventList* FEvents;
Cxschedulerutils::TcxSchedulerDateList* FSelectedDays;
virtual void __fastcall CheckResourceNavigator(void);
virtual System::UnicodeString __fastcall DoGetEventDisplayText(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
bool __fastcall DoSchedulerMoreEventsButtonClick(void);
bool __fastcall DoSchedulerNavigationButtonClick(System::TDateTime AnInterval, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
System::UnicodeString __fastcall GetEventHint(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual Vcl::Forms::TScrollBarKind __fastcall GetResourceScrollBarKind(void);
Cxschedulerstorage::TcxSchedulerCachedEventList* __fastcall GetSchedulerEventsList(void);
virtual void __fastcall SetEventsVisibility(bool AShowSources, bool AShowClones, bool AForceRepaint = false);
__property Cxschedulerstorage::TcxSchedulerCachedEventList* Events = {read=FEvents};
__property TcxSchedulerResourceNavigator* ResourceNavigator = {read=GetResourceNavigator};
__property TcxCustomScheduler* Scheduler = {read=GetScheduler};
__property Cxschedulerutils::TcxSchedulerDateList* SelectedDays = {read=FSelectedDays};
public:
/* TcxSchedulerSubControlViewInfo.Create */ inline __fastcall virtual TcxSchedulerCustomViewViewInfo(TcxSchedulerSubControl* AOwner) : TcxSchedulerSubControlViewInfo(AOwner) { }
public:
/* TObject.Destroy */ inline __fastcall virtual ~TcxSchedulerCustomViewViewInfo(void) { }
};
__interface IcxExternalDateNavigatorListener;
typedef System::DelphiInterface<IcxExternalDateNavigatorListener> _di_IcxExternalDateNavigatorListener;
__interface INTERFACE_UUID("{32293211-4D89-4383-A95C-23B95C3A783D}") IcxExternalDateNavigatorListener : public System::IInterface
{
public:
virtual void __fastcall StorageChanged(void) = 0 ;
virtual void __fastcall SchedulerChanged(void) = 0 ;
virtual void __fastcall SchedulerRemoved(void) = 0 ;
};
class PASCALIMPLEMENTATION TcxSchedulerCustomDateNavigator : public TcxSchedulerSubControl
{
typedef TcxSchedulerSubControl inherited;
private:
int FLockCount;
int FPrevColCount;
int FPrevRowCount;
System::TDateTime FSaveRealFirstDate;
System::TDateTime FSaveRealLastDate;
Cxschedulerutils::TcxSchedulerDateList* FSaveSelectionList;
Cxschedulerutils::TcxSchedulerDateList* __fastcall GetEventDays(void);
TcxSchedulerHintController* __fastcall GetHintController(void);
Cxschedulerutils::TcxSchedulerDateList* __fastcall GetHolidayDays(void);
protected:
System::Types::TSize FSavedSize;
virtual void __fastcall BoundsChanging(void);
virtual void __fastcall BoundsChanged(void);
virtual bool __fastcall CanMultiSelect(void);
virtual void __fastcall CheckSizes(void) = 0 ;
virtual void __fastcall CheckChanges(void);
virtual void __fastcall CheckCurrentDate(void);
virtual void __fastcall ClearDragging(void) = 0 ;
virtual void __fastcall DoPeriodChangedEvent(void) = 0 ;
virtual void __fastcall DoSelectionChangedEvent(void) = 0 ;
virtual void __fastcall DoScrollSelection(bool AForward, System::TDateTime ANeedDate, bool AIsByPage) = 0 /* overload */;
virtual void __fastcall DoScrollSelection(int AScrollDelta) = 0 /* overload */;
virtual void __fastcall GetCalendarDimension(/* out */ int &AColCount, /* out */ int &ARowCount) = 0 ;
virtual System::Types::TSize __fastcall GetMonthSize(void);
virtual Cxschedulerutils::TcxSchedulerDateList* __fastcall GetSelection(void);
virtual bool __fastcall GetShowDatesContainingEventsInBold(void) = 0 ;
virtual bool __fastcall GetShowDatesContainingHolidaysInColor(void) = 0 ;
virtual System::TDateTime __fastcall GetRealFirstDate(void) = 0 ;
virtual System::TDateTime __fastcall GetRealLastDate(void) = 0 ;
bool __fastcall IsSchedulerLocked(void);
virtual void __fastcall Loaded(void);
virtual void __fastcall MakeSelectionVisible(void) = 0 ;
virtual void __fastcall PeriodChanged(void);
virtual void __fastcall RefreshDays(void) = 0 ;
void __fastcall SaveSize(void);
virtual void __fastcall SaveState(void);
void __fastcall ScrollSelection(bool AForward, System::TDateTime ANeedDate, bool AIsByPage)/* overload */;
void __fastcall ScrollSelection(int AScrollDelta)/* overload */;
virtual void __fastcall SetIntegralSizes(void) = 0 ;
virtual void __fastcall UpdateDragging(void) = 0 ;
virtual void __fastcall UpdateSelection(void) = 0 ;
__property Cxschedulerutils::TcxSchedulerDateList* EventDays = {read=GetEventDays};
__property TcxSchedulerHintController* HintController = {read=GetHintController};
__property Cxschedulerutils::TcxSchedulerDateList* HolidayDays = {read=GetHolidayDays};
public:
__fastcall virtual TcxSchedulerCustomDateNavigator(TcxCustomScheduler* AOwner);
__fastcall virtual ~TcxSchedulerCustomDateNavigator(void);
void __fastcall BeginUpdate(void);
void __fastcall CancelUpdates(void);
void __fastcall EndUpdate(void);
};
class DELPHICLASS TcxSchedulerClipboardController;
class PASCALIMPLEMENTATION TcxSchedulerClipboardController : public System::TObject
{
typedef System::TObject inherited;
private:
TcxCustomScheduler* FScheduler;
System::Classes::TMemoryStream* FStream;
Cxvariants::TcxReader* FStreamReader;
Cxvariants::TcxWriter* FStreamWriter;
Cxschedulerstorage::TcxCustomSchedulerStorage* __fastcall GetStorage(void);
void __fastcall RegisterClipboardFormat(void);
protected:
void __fastcall CalculateAnchorForResource(Cxschedulerstorage::TcxSchedulerFilteredEventList* AEvents, const System::Variant &AResourceID, System::TDateTime &Anchor);
virtual void __fastcall DeleteSelectedEvents(void);
virtual Vcl::Clipbrd::TClipboard* __fastcall GetClipboard(void);
bool __fastcall GetClipboardToStream(void);
bool __fastcall GetSelectionAsStream(void);
bool __fastcall GetStreamAsEvents(Cxschedulerstorage::TcxSchedulerFilteredEventList* AEvents, System::TDateTime &Anchor);
bool __fastcall IsClipboardBusy(void);
void __fastcall InsertEvents(Cxschedulerstorage::TcxSchedulerFilteredEventList* AEvents, System::TDateTime Anchor);
bool __fastcall KeyDown(System::Word &AKey, System::Classes::TShiftState AShift);
bool __fastcall KeyPress(System::WideChar &AKey);
void __fastcall RestoreEvent(Cxschedulerstorage::TcxSchedulerControlEvent* &AEvent);
void __fastcall SaveEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
void __fastcall SetStreamToClipboard(void);
bool __fastcall ValidateStream(void);
__property System::Classes::TMemoryStream* Stream = {read=FStream};
__property Cxvariants::TcxReader* StreamReader = {read=FStreamReader};
__property Cxvariants::TcxWriter* StreamWriter = {read=FStreamWriter};
public:
__fastcall virtual TcxSchedulerClipboardController(TcxCustomScheduler* AScheduler);
__fastcall virtual ~TcxSchedulerClipboardController(void);
virtual bool __fastcall CanCopy(void);
virtual bool __fastcall CanPaste(void);
void __fastcall Copy(void);
void __fastcall Cut(void);
void __fastcall Paste(void);
__property Vcl::Clipbrd::TClipboard* Clipboard = {read=GetClipboard};
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
__property Cxschedulerstorage::TcxCustomSchedulerStorage* Storage = {read=GetStorage};
};
__interface IcxSchedulerStylesAdapter;
typedef System::DelphiInterface<IcxSchedulerStylesAdapter> _di_IcxSchedulerStylesAdapter;
__interface INTERFACE_UUID("{0BFEA90D-0CE8-4ED1-88E8-71A3396186F3}") IcxSchedulerStylesAdapter : public System::IInterface
{
public:
virtual Cxgraphics::TcxViewParams __fastcall GetContentParams(const System::TDateTime ADateTime, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource) = 0 /* overload */;
virtual Cxgraphics::TcxViewParams __fastcall GetContentParams(const System::TDateTime ADateTime, bool ALightColor, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource) = 0 /* overload */;
virtual Cxgraphics::TcxViewParams __fastcall GetDayHeaderParams(const System::TDateTime ADateTime) = 0 ;
virtual Cxgraphics::TcxViewParams __fastcall GetEventParams(Cxschedulerstorage::TcxSchedulerEvent* AEvent) = 0 ;
virtual Cxgraphics::TcxViewParams __fastcall GetResourceHeaderParams(Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource) = 0 ;
virtual Cxstyles::TcxStyle* __fastcall GetDayHeaderStyle(void) = 0 ;
virtual Cxstyles::TcxStyle* __fastcall GetResourceHeaderStyle(void) = 0 ;
};
typedef void __fastcall (__closure *TcxSchedulerOnGetDayHeaderStyleEvent)(System::TObject* Sender, const System::TDateTime ADate, Cxstyles::TcxStyle* &AStyle);
typedef void __fastcall (__closure *TcxSchedulerOnGetResourceHeaderStyleEvent)(System::TObject* Sender, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource, Cxstyles::TcxStyle* &AStyle);
typedef void __fastcall (__closure *TcxSchedulerOnGetContentStyleEvent)(System::TObject* Sender, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource, const System::TDateTime ADateTime, Cxstyles::TcxStyle* &AStyle);
typedef void __fastcall (__closure *TcxSchedulerOnGetEventStyleEvent)(System::TObject* Sender, Cxschedulerstorage::TcxSchedulerEvent* AEvent, Cxstyles::TcxStyle* &AStyle);
class PASCALIMPLEMENTATION TcxSchedulerStyles : public Cxstyles::TcxStyles
{
typedef Cxstyles::TcxStyles inherited;
private:
TcxCustomScheduler* FScheduler;
TcxSchedulerOnGetContentStyleEvent FOnGetContentStyle;
TcxSchedulerOnGetDayHeaderStyleEvent FOnGetDayHeaderStyle;
TcxSchedulerOnGetEventStyleEvent FOnGetEventStyle;
TcxSchedulerOnGetResourceHeaderStyleEvent FOnGetResourceHeaderStyle;
Cxlookandfeelpainters::TcxCustomLookAndFeelPainter* __fastcall GetPainter(void);
Cxschedulerutils::TcxSchedulerPainterHelperClass __fastcall GetPainterHelperClass(void);
Cxschedulerstorage::TcxSchedulerStorageResourceItems* __fastcall GetResources(void);
protected:
virtual void __fastcall Changed(int AIndex);
bool __fastcall EventContentSelected(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
System::Uitypes::TColor __fastcall GetDefaultContentColor(int AResourceIndex);
virtual void __fastcall GetDefaultViewParams(int Index, System::TObject* AData, /* out */ Cxgraphics::TcxViewParams &AParams);
Cxstyles::TcxStyle* __fastcall GetDayHeaderStyle(void);
Cxgraphics::TcxViewParams __fastcall GetEventParams(Cxschedulerstorage::TcxSchedulerEvent* AEvent);
Cxstyles::TcxStyle* __fastcall GetResourceHeaderStyle(void);
__property Cxlookandfeelpainters::TcxCustomLookAndFeelPainter* Painter = {read=GetPainter};
__property Cxschedulerutils::TcxSchedulerPainterHelperClass PainterHelper = {read=GetPainterHelperClass};
__property Cxschedulerstorage::TcxSchedulerStorageResourceItems* Resources = {read=GetResources};
public:
__fastcall virtual TcxSchedulerStyles(System::Classes::TPersistent* AOwner);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
Cxgraphics::TcxViewParams __fastcall GetBackgroundParams(void);
Cxgraphics::TcxViewParams __fastcall GetContentParams(const System::TDateTime ADateTime, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource = (Cxschedulerstorage::TcxSchedulerStorageResourceItem*)(0x0))/* overload */;
Cxgraphics::TcxViewParams __fastcall GetContentParams(const System::TDateTime ADateTime, bool ALightColor, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource = (Cxschedulerstorage::TcxSchedulerStorageResourceItem*)(0x0))/* overload */;
Cxgraphics::TcxViewParams __fastcall GetDayHeaderParams(const System::TDateTime ADate);
Cxgraphics::TcxViewParams __fastcall GetGroupSeparatorParams(void);
Cxgraphics::TcxViewParams __fastcall GetResourceHeaderParams(Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
Cxgraphics::TcxViewParams __fastcall GetSelectionParams(void);
Cxgraphics::TcxViewParams __fastcall GetSplitterParams(TcxSchedulerSplitterKind AKind);
Cxgraphics::TcxViewParams __fastcall GetEventContentParams(Cxschedulerstorage::TcxSchedulerEvent* AEvent);
bool __fastcall IsEventStyleAssigned(Cxschedulerstorage::TcxSchedulerEvent* AEvent);
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
__published:
__property Cxstyles::TcxStyle* Background = {read=GetValue, write=SetValue, index=0};
__property Cxstyles::TcxStyle* Content = {read=GetValue, write=SetValue, index=1};
__property Cxstyles::TcxStyle* Event = {read=GetValue, write=SetValue, index=2};
__property Cxstyles::TcxStyle* GroupSeparator = {read=GetValue, write=SetValue, index=3};
__property Cxstyles::TcxStyle* DayHeader = {read=GetValue, write=SetValue, index=4};
__property Cxstyles::TcxStyle* HorzSplitter = {read=GetValue, write=SetValue, index=6};
__property Cxstyles::TcxStyle* ResourceHeader = {read=GetValue, write=SetValue, index=8};
__property Cxstyles::TcxStyle* Selection = {read=GetValue, write=SetValue, index=5};
__property Cxstyles::TcxStyle* VertSplitter = {read=GetValue, write=SetValue, index=7};
__property TcxSchedulerOnGetContentStyleEvent OnGetContentStyle = {read=FOnGetContentStyle, write=FOnGetContentStyle};
__property TcxSchedulerOnGetDayHeaderStyleEvent OnGetDayHeaderStyle = {read=FOnGetDayHeaderStyle, write=FOnGetDayHeaderStyle};
__property TcxSchedulerOnGetEventStyleEvent OnGetEventStyle = {read=FOnGetEventStyle, write=FOnGetEventStyle};
__property TcxSchedulerOnGetResourceHeaderStyleEvent OnGetResourceHeaderStyle = {read=FOnGetResourceHeaderStyle, write=FOnGetResourceHeaderStyle};
public:
/* TcxCustomStyles.Destroy */ inline __fastcall virtual ~TcxSchedulerStyles(void) { }
private:
void *__IcxSchedulerStylesAdapter; /* IcxSchedulerStylesAdapter */
public:
#if defined(MANAGED_INTERFACE_OPERATORS)
// {0BFEA90D-0CE8-4ED1-88E8-71A3396186F3}
operator _di_IcxSchedulerStylesAdapter()
{
_di_IcxSchedulerStylesAdapter intf;
GetInterface(intf);
return intf;
}
#else
operator IcxSchedulerStylesAdapter*(void) { return (IcxSchedulerStylesAdapter*)&__IcxSchedulerStylesAdapter; }
#endif
};
class DELPHICLASS TcxSchedulerOptionsBehavior;
class PASCALIMPLEMENTATION TcxSchedulerOptionsBehavior : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
bool FHotTrack;
TcxCustomScheduler* FOwner;
bool FSelectOnRightClick;
protected:
DYNAMIC System::Classes::TPersistent* __fastcall GetOwner(void);
public:
__fastcall TcxSchedulerOptionsBehavior(TcxCustomScheduler* AOwner);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
__published:
__property bool SelectOnRightClick = {read=FSelectOnRightClick, write=FSelectOnRightClick, default=0};
__property bool HotTrack = {read=FHotTrack, write=FHotTrack, default=1};
public:
/* TPersistent.Destroy */ inline __fastcall virtual ~TcxSchedulerOptionsBehavior(void) { }
};
typedef void __fastcall (__closure *TcxSchedulerCanShowViewEvent)(System::TObject* Sender, TcxSchedulerCustomView* AView, bool &Allow);
typedef void __fastcall (__closure *TcxSchedulerGetEventEditPropertiesEvent)(System::TObject* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, Cxedit::TcxCustomEditProperties* &AProperties);
typedef void __fastcall (__closure *TcxSchedulerGetEventText)(System::TObject* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::UnicodeString &AText);
typedef void __fastcall (__closure *TcxSchedulerInitEditEvent)(System::TObject* Sender, Cxedit::TcxCustomEdit* AEdit);
typedef void __fastcall (__closure *TcxSchedulerViewTypeChangedEvent)(System::TObject* Sender, TcxSchedulerCustomView* APrevView, TcxSchedulerCustomView* ANewView);
typedef void __fastcall (__closure *TcxSchedulerIsWorkTimeEvent)(System::TObject* Sender, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource, const System::TDateTime ATime, bool &AIsWork);
typedef void __fastcall (__closure *TcxSchedulerBeforeDeleting)(TcxCustomScheduler* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool &Allow);
typedef void __fastcall (__closure *TcxSchedulerBeforeDragEvent)(TcxCustomScheduler* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, int X, int Y, bool &Allow);
typedef void __fastcall (__closure *TcxSchedulerBeforeEditing)(TcxCustomScheduler* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool AInplace, bool &Allow);
typedef void __fastcall (__closure *TcxSchedulerAfterDragEvent)(TcxCustomScheduler* Sender, System::TObject* Target, int X, int Y, bool &Accept);
typedef void __fastcall (__closure *TcxSchedulerBeforeSizingEvent)(TcxCustomScheduler* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, int X, int Y, bool &Allow);
typedef void __fastcall (__closure *TcxSchedulerAfterSizingEvent)(TcxCustomScheduler* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, int X, int Y, bool &Accept);
typedef void __fastcall (__closure *TcxSchedulerAfterEditing)(TcxCustomScheduler* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
typedef void __fastcall (__closure *TcxSchedulerMoreEventsButtonClickEvent)(TcxCustomScheduler* Sender, bool &AHandled);
typedef void __fastcall (__closure *TcxSchedulerNavigationButtonClickEvent)(TcxCustomScheduler* Sender, System::TDateTime AnInterval, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource, bool &AHandled);
typedef void __fastcall (__closure *TcxSchedulerScaleScrollEvent)(TcxCustomScheduler* Sender, System::TDateTime AStartDateTime, System::TDateTime AFinishDateTime);
typedef void __fastcall (__closure *TcxSchedulerEventSelectionChangedEvent)(TcxCustomScheduler* Sender, Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
typedef void __fastcall (__closure *TcxSchedulerShowDateHintEvent)(System::TObject* Sender, const System::TDateTime ADate, System::UnicodeString &AHintText, bool &AAllow);
class DELPHICLASS TcxSchedulerContentPopupMenu;
class DELPHICLASS TcxSchedulerEventPopupMenu;
class PASCALIMPLEMENTATION TcxCustomScheduler : public Cxcontrols::TcxControl
{
typedef Cxcontrols::TcxControl inherited;
private:
TcxSchedulerSubControl* FActiveControl;
bool FAligningSubControls;
TcxSchedulerSubControl* FBackground;
bool FBoundsChanging;
bool FCanModified;
TcxSchedulerSubControl* FCaptureControl;
TcxSchedulerClipboardController* FClipboardController;
TcxSchedulerContentPopupMenu* FContentPopupMenu;
System::Classes::TNotifyEvent FContentPopupMenuEvents;
TcxSchedulerControlBox* FControlBox;
TcxControlFlags FControlFlags;
TcxSchedulerCustomView* FCurrentView;
TcxSchedulerCustomDateNavigator* FDateNavigator;
Cxedit::TcxCustomEditProperties* FDefaultProperties;
Cxlookandfeels::TcxLookAndFeel* FDialogsLookAndFeel;
TcxSchedulerEditController* FEditController;
Cxedit::TcxCustomEditStyle* FEditStyle;
Cxschedulerutils::TcxSchedulerDateList* FEventDays;
TcxSchedulerEventEditInfo* FEventEditInfo;
TcxSchedulerEventHitTestController* FEventHitTestController;
Vcl::Imglist::TCustomImageList* FEventImages;
Cxschedulerstorage::TcxSchedulerCachedEventList* FEventList;
TcxSchedulerEventOperations* FEventOperations;
TcxSchedulerEventPopupMenu* FEventPopupMenu;
System::Classes::TNotifyEvent FEventPopupMenuEvents;
int FFirstVisibleResourceIndex;
TcxSchedulerHintController* FHintController;
Cxschedulerutils::TcxSchedulerDateList* FHolidayDays;
TcxSchedulerSplitter* FHorzSplitter;
bool FHorzSplitterShowing;
bool FIsDragCanceled;
TcxSchedulerSubControl* FKeyboardListener;
System::Classes::TInterfaceList* FListeners;
int FLockCount;
int FLockRefresh;
TcxSchedulerInitEditEvent FOnInitEdit;
TcxSchedulerOptionsBehavior* FOptionsBehavior;
TcxSchedulerOptionsCustomize* FOptionsCustomize;
TcxSchedulerOptionsView* FOptionsView;
System::Types::TRect FPrevBounds;
bool FPrevCopyDragDrop;
System::Types::TPoint FPrevMousePos;
TcxSchedulerResourceNavigator* FResourceNavigator;
System::Classes::TNotifyEvent FResourceNavigatorEvents;
Cxschedulerutils::TcxSchedulerDateList* FSelectedDays;
System::TDateTime FSelFinish;
Cxschedulerstorage::TcxSchedulerStorageResourceItem* FSelResource;
System::TDateTime FSelStart;
Cxschedulerstorage::TcxCustomSchedulerStorage* FStorage;
System::UnicodeString FStoringName;
TcxSchedulerStyles* FStyles;
System::Classes::TNotifyEvent FStylesEvents;
System::Classes::TList* FSubControls;
bool FSubControlsCreated;
Cxschedulerstorage::TcxSchedulerEventList* FTabOrdersList;
Cxtextedit::TcxTextEditProperties* FTextEditProperties;
TcxSchedulerSplitter* FVertSplitter;
bool FVertSplitterShowing;
int FVisibleChangedCount;
Vcl::Extctrls::TTimer* FUpdateTimeTimer;
TcxSchedulerAfterDragEvent FOnAfterDragEvent;
TcxSchedulerAfterEditing FOnAfterEditing;
TcxSchedulerAfterSizingEvent FOnAfterSizingEvent;
TcxSchedulerBeforeDeleting FOnBeforeDeleting;
TcxSchedulerBeforeDragEvent FOnBeforeDragEvent;
TcxSchedulerBeforeEditing FOnBeforeEditing;
TcxSchedulerBeforeSizingEvent FOnBeforeSizingEvent;
TcxSchedulerCanShowViewEvent FOnCanShowView;
TcxSchedulerEventSelectionChangedEvent FOnEventSelectionChanged;
System::Classes::TNotifyEvent FOnFirstVisibleResourceChanged;
TcxSchedulerGetEventText FOnGetEventDisplayText;
TcxSchedulerGetEventEditPropertiesEvent FOnGetEventEditProperties;
TcxSchedulerGetEventText FOnGetEventHintText;
TcxSchedulerIsWorkTimeEvent FOnIsWorkTime;
System::Classes::TNotifyEvent FOnLayoutChanged;
TcxSchedulerMoreEventsButtonClickEvent FOnMoreEventsButtonClick;
TcxSchedulerNavigationButtonClickEvent FOnNavigationButtonClick;
System::Classes::TNotifyEvent FOnSelectionChanged;
TcxSchedulerScaleScrollEvent FOnScaleScroll;
TcxSchedulerShowDateHintEvent FOnShowDateHint;
TcxSchedulerViewTypeChangedEvent FOnViewTypeChanged;
void __fastcall CreateUpdateTimeTimer(void);
TcxSchedulerSubControlHitTest* __fastcall GetActiveHitTest(void);
TcxSchedulerSubControl* __fastcall GetCaptureControl(void);
TcxSchedulerSubControlController* __fastcall GetCaptureController(void);
int __fastcall GetSelectedEventCount(void);
Cxschedulerstorage::TcxSchedulerControlEvent* __fastcall GetSelectedEvent(int AIndex);
System::TDateTime __fastcall GetSelFinish(void);
System::TDateTime __fastcall GetSelStart(void);
bool __fastcall GetIsDynamicUpdate(void);
Cxdateutils::TDay __fastcall GetStartOfWeek(void);
bool __fastcall GetStorageActive(void);
bool __fastcall GetStorageValid(void);
TcxSchedulerSubControl* __fastcall GetSubControl(int AIndex);
int __fastcall GetSubControlCount(void);
int __fastcall GetVisibleEventCount(void);
Cxschedulerstorage::TcxSchedulerControlEvent* __fastcall GetVisibleEvent(int AIndex);
void __fastcall InitEventBySelection(Cxschedulerstorage::TcxSchedulerEvent* AEvent, bool AllDay, bool ARecurrence, bool AInplaceEditing);
void __fastcall SetCaptureControl(TcxSchedulerSubControl* AValue);
void __fastcall SetContentPopupMenu(TcxSchedulerContentPopupMenu* AValue);
void __fastcall SetControlBox(TcxSchedulerControlBox* AValue);
void __fastcall SetDialogsLookAndFeel(Cxlookandfeels::TcxLookAndFeel* AValue);
void __fastcall SetEventImages(Vcl::Imglist::TCustomImageList* AValue);
void __fastcall SetEventOperations(TcxSchedulerEventOperations* AValue);
void __fastcall SetEventPopupMenu(TcxSchedulerEventPopupMenu* AValue);
void __fastcall SetFirstVisibleResourceIndex(int AValue);
void __fastcall SetOptionsBehavior(TcxSchedulerOptionsBehavior* AValue);
void __fastcall SetOptionsCustomize(TcxSchedulerOptionsCustomize* AValue);
void __fastcall SetOptionsView(TcxSchedulerOptionsView* AValue);
void __fastcall SetResourceNavigator(TcxSchedulerResourceNavigator* AValue);
void __fastcall SetStyles(TcxSchedulerStyles* AValue);
void __fastcall SetStorage(Cxschedulerstorage::TcxCustomSchedulerStorage* AValue);
void __fastcall UpdateTimeHandler(System::TObject* Sender);
HIDESBASE MESSAGE void __fastcall WMCancelMode(Winapi::Messages::TWMNoParams &Message);
HIDESBASE MESSAGE void __fastcall WMSetCursor(Winapi::Messages::TWMSetCursor &Message);
HIDESBASE MESSAGE void __fastcall WMTimeChange(Winapi::Messages::TWMNoParams &Message);
void __fastcall ReadSelectionData(System::Classes::TReader* AReader);
void __fastcall WriteSelectionData(System::Classes::TWriter* AWriter);
protected:
System::Types::TRect FStoredClientBounds;
void __fastcall StorageChanged(System::TObject* Sender);
void __fastcall StorageRemoved(System::TObject* Sender);
virtual void __fastcall DoStartOfWeekChanged(Cxdateutils::TDay AOldStartOfWeek, Cxdateutils::TDay ANewStartOfWeek);
virtual void __fastcall FormatChanged(void);
void __fastcall TimeChanged(void);
virtual System::UnicodeString __fastcall GetObjectName(void);
virtual bool __fastcall GetProperties(System::Classes::TStrings* AProperties);
virtual void __fastcall GetPropertyValue(const System::UnicodeString AName, System::Variant &AValue);
virtual void __fastcall SetPropertyValue(const System::UnicodeString AName, const System::Variant &AValue);
virtual void __fastcall AlignControls(Vcl::Controls::TControl* AControl, System::Types::TRect &Rect);
virtual void __fastcall DefineProperties(System::Classes::TFiler* Filer);
virtual void __fastcall Notification(System::Classes::TComponent* AComponent, System::Classes::TOperation Operation);
void __fastcall AddListener(_di_IcxExternalDateNavigatorListener AListener);
void __fastcall NotififySchedulerChanged(void);
void __fastcall NotififySchedulerRemoved(void);
void __fastcall NotififyStorageChanged(void);
void __fastcall RemoveListener(_di_IcxExternalDateNavigatorListener AListener);
virtual bool __fastcall AllowCompositionPainting(void);
virtual bool __fastcall IsDoubleBufferedNeeded(void);
virtual void __fastcall AlignSubControls(TcxSchedulerSubControl* Sender = (TcxSchedulerSubControl*)(0x0));
DYNAMIC void __fastcall BoundsChanged(void);
virtual void __fastcall CalcHorizontalSplitterBounds(void);
virtual void __fastcall CalcVerticalSplitterBounds(void);
virtual void __fastcall CalcLayout(void);
virtual void __fastcall CalcLayoutViewRight(void);
virtual void __fastcall CalcLayoutViewLeft(void);
virtual void __fastcall CalcLayoutViewTop(void);
virtual void __fastcall CalcLayoutViewBottom(void);
void __fastcall CalcSplittersBounds(void);
void __fastcall CheckHorzSplitterBounds(void);
virtual void __fastcall CheckSplittersVisibilityChanging(void);
virtual void __fastcall ClearAllCachedData(void);
virtual bool __fastcall IsHorzSplitterVisible(void);
virtual bool __fastcall IsVertSplitterVisible(void);
void __fastcall UpdateControlsBoundsOnHorzSplitterShowing(void);
void __fastcall UpdateControlsBoundsOnVertSplitterShowing(void);
virtual bool __fastcall CanDeactivateOnSelectionChanged(TcxSchedulerCustomView* AView);
virtual bool __fastcall CanIntersect(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual bool __fastcall CanModified(void);
virtual bool __fastcall CanSelectPeriod(void);
bool __fastcall CanShowEventDialog(void);
virtual TcxSchedulerSubControl* __fastcall CreateBackground(void);
virtual TcxSchedulerClipboardController* __fastcall CreateClipboardController(void);
virtual TcxSchedulerContentPopupMenu* __fastcall CreateContentPopupMenu(void);
virtual TcxSchedulerControlBox* __fastcall CreateControlBox(void);
virtual TcxSchedulerCustomDateNavigator* __fastcall CreateDateNavigator(void);
virtual TcxSchedulerCustomView* __fastcall CreateDefaultView(void);
virtual Cxedit::TcxCustomEditProperties* __fastcall CreateDefaultEditProperties(void);
virtual TcxSchedulerEditController* __fastcall CreateEditController(void);
virtual TcxSchedulerEventHitTestController* __fastcall CreateEventHitTestController(void);
virtual Cxschedulerstorage::TcxSchedulerCachedEventList* __fastcall CreateEventList(void);
virtual TcxSchedulerEventOperations* __fastcall CreateEventOperations(void);
virtual TcxSchedulerEventPopupMenu* __fastcall CreateEventPopupMenu(void);
virtual TcxSchedulerHintController* __fastcall CreateHintController(void);
virtual TcxSchedulerOptionsCustomize* __fastcall CreateOptionsCustomize(void);
virtual TcxSchedulerOptionsView* __fastcall CreateOptionsView(void);
virtual TcxSchedulerResourceNavigator* __fastcall CreateResourceNavigator(void);
virtual TcxSchedulerSplitter* __fastcall CreateSplitter(TcxSchedulerSplitterKind AKind);
virtual TcxSchedulerStyles* __fastcall CreateStyles(void);
virtual void __fastcall CreateSubClasses(void);
virtual void __fastcall DateNavigatorSelectionChanged(void);
DYNAMIC void __fastcall DblClick(void);
virtual void __fastcall DestroySubClasses(void);
virtual void __fastcall DoAfterDragEvent(System::TObject* Target, int X, int Y, bool &Accept);
virtual void __fastcall DoAfterEditing(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual void __fastcall DoAfterSizingEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, int X, int Y, bool &Accept);
virtual bool __fastcall DoBeforeDeleting(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual bool __fastcall DoBeforeDragEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, int X, int Y);
virtual bool __fastcall DoBeforeEditing(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool AInplace);
virtual bool __fastcall DoBeforeSizingEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, int X, int Y);
virtual void __fastcall DoCalculateLayout(TcxSchedulerSubControl* AControl);
DYNAMIC void __fastcall DoCancelMode(void);
virtual void __fastcall DoControllerReset(TcxSchedulerSubControl* AControl);
virtual void __fastcall DoCreateEventUsingInplaceEdit(System::WideChar AKey = (System::WideChar)(0x0));
void __fastcall DoEventSelectionChanged(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual void __fastcall DoFirstVisibleResourceChanged(void);
virtual void __fastcall DoGestureScroll(Vcl::Forms::TScrollBarKind AScrollKind, int ANewScrollPos);
virtual void __fastcall DoGetEventDisplayText(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::UnicodeString &AText);
virtual void __fastcall DoGetEventEditProperties(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, Cxedit::TcxCustomEditProperties* &AProperties);
virtual void __fastcall DoHitTestRecalculate(TcxSchedulerSubControl* AControl);
virtual void __fastcall DoInitEdit(Cxedit::TcxCustomEdit* AEdit);
bool __fastcall DoIsWorkTime(Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResourceItem, const System::TDateTime ADateTime);
virtual void __fastcall DoCanShowView(TcxSchedulerCustomView* AView, bool &Allow);
virtual void __fastcall DoLayoutChanged(void);
virtual void __fastcall DoLayoutChangedEvent(void);
virtual bool __fastcall DoMoreEventsButtonClick(void);
virtual bool __fastcall DoNavigationButtonClick(System::TDateTime AnInterval, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
virtual void __fastcall DoSelectionChanged(void);
virtual void __fastcall DoScaleScroll(void);
virtual bool __fastcall DoShowDateHint(const System::TDateTime ADate, System::UnicodeString &AHintText);
virtual bool __fastcall DoShowPopupMenu(System::Classes::TComponent* AMenu, int X, int Y);
virtual void __fastcall DoViewTypeChanged(TcxSchedulerCustomView* ANewView);
virtual void __fastcall DoUpdateTime(void);
DYNAMIC void __fastcall DragCanceled(void);
virtual void __fastcall DrawSplitters(void);
virtual void __fastcall FirstVisibleResourceChanged(void);
DYNAMIC void __fastcall FontChanged(void);
DYNAMIC void __fastcall FocusChanged(void);
virtual System::Types::TRect __fastcall GetClientBounds(void);
virtual TcxSchedulerSubControl* __fastcall GetControlFromPoint(const System::Types::TPoint APoint);
virtual System::Uitypes::TCursor __fastcall GetCurrentCursor(int X, int Y);
virtual Cxschedulerutils::TcxSchedulerDateTimeHelperClass __fastcall GetDateTimeHelper(void);
System::Types::TSize __fastcall GetDateNavigatorLoadedSize(void);
DYNAMIC bool __fastcall GetDesignHitTest(int X, int Y, System::Classes::TShiftState Shift);
TcxSchedulerEventEditInfo* __fastcall GetEventEditInfo(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool ARecurrence = false, bool AReadOnly = false);
virtual System::UnicodeString __fastcall GetEventHintText(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
virtual bool __fastcall GetEventUserHintText(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::UnicodeString &AText);
virtual System::Types::TRect __fastcall GetHScrollBarBounds(void);
virtual Cxgraphics::TcxCanvas* __fastcall GetInternalCanvas(void);
virtual bool __fastcall GetIsLocked(void);
virtual Cxcontrols::TcxControlCustomScrollBarsClass __fastcall GetMainScrollBarsClass(void);
virtual TcxSchedulerCustomView* __fastcall GetNextView(TcxSchedulerCustomView* AView);
virtual TcxSchedulerShowDateHintEvent __fastcall GetOnShowDateHint(void);
virtual Cxschedulerutils::TcxSchedulerPainterHelperClass __fastcall GetPainterHelper(void);
virtual System::Types::TRect __fastcall GetSizeGripBounds(void);
virtual double __fastcall GetTimeBias(System::TDateTime AStart);
virtual System::Types::TRect __fastcall GetVScrollBarBounds(void);
bool __fastcall HasConflict(bool AStartDrag);
bool __fastcall HasResources(void);
virtual void __fastcall InitControl(void);
virtual void __fastcall InitScrollBarsParameters(void);
void __fastcall InternalDeleteEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool AIgnoreRecurring);
void __fastcall InternalDeleteSelectedEvents(bool AForceDelete, bool ACheckReadOnly);
bool __fastcall IsDaysIntervalChanged(System::TDateTime &AStart, System::TDateTime &AFinish);
bool __fastcall IsViewAtLeft(void);
DYNAMIC void __fastcall KeyDown(System::Word &Key, System::Classes::TShiftState Shift);
DYNAMIC void __fastcall KeyPress(System::WideChar &Key);
DYNAMIC void __fastcall KeyUp(System::Word &Key, System::Classes::TShiftState Shift);
virtual void __fastcall Loaded(void);
virtual void __fastcall LookAndFeelChanged(Cxlookandfeels::TcxLookAndFeel* Sender, Cxlookandfeels::TcxLookAndFeelValues AChangedValues);
virtual void __fastcall LockUpdateChanged(bool ALocking);
virtual void __fastcall Modified(void);
DYNAMIC void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseLeave(Vcl::Controls::TControl* AControl);
DYNAMIC void __fastcall MouseMove(System::Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual bool __fastcall NeedPanningFeedback(Vcl::Forms::TScrollBarKind AScrollKind);
virtual bool __fastcall NeedShowHint(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::UnicodeString &AHintText, bool AllowShow);
virtual void __fastcall DoPaint(void);
virtual void __fastcall PaintControl(TcxSchedulerSubControl* AControl, bool ASpecialPaint = false);
virtual void __fastcall PeriodChanged(void);
void __fastcall RemoveSubControl(TcxSchedulerSubControl* AControl);
virtual void __fastcall ReplaceSelParams(System::TDateTime ASelStart, System::TDateTime ASelFinish, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
virtual void __fastcall Scroll(Vcl::Forms::TScrollBarKind AScrollBarKind, System::Uitypes::TScrollCode AScrollCode, int &AScrollPos);
void __fastcall SelectedDaysChanged(TcxSchedulerCustomView* AView);
virtual void __fastcall SetCurrentView(TcxSchedulerCustomView* AView);
void __fastcall SubControlAdd(TcxSchedulerSubControl* AControl);
void __fastcall SubControlRemove(TcxSchedulerSubControl* AControl);
virtual void __fastcall SynchronizeVisibleDays(void);
void __fastcall UpdateDateNavigatorDragging(bool Accept);
void __fastcall UpdateHolidayDays(System::TDate ABegin, System::TDate AEnd);
virtual void __fastcall UpdateEventsCache(bool ACheckDaysInterval);
virtual void __fastcall ValidateSelection(Cxschedulerutils::TcxSchedulerDateList* ASelection);
void __fastcall ValidateState(void);
virtual void __fastcall ViewVisibleChanged(TcxSchedulerCustomView* AView);
TcxSchedulerGroupingKind __fastcall VisibleGroupingKind(void);
DYNAMIC bool __fastcall CanDrag(int X, int Y);
DYNAMIC void __fastcall DoEndDrag(System::TObject* Target, int X, int Y);
DYNAMIC void __fastcall DoStartDrag(Vcl::Controls::TDragObject* &DragObject);
DYNAMIC void __fastcall DragAndDrop(const System::Types::TPoint P, bool &Accepted);
DYNAMIC void __fastcall DragOver(System::TObject* Source, int X, int Y, System::Uitypes::TDragState State, bool &Accept);
DYNAMIC void __fastcall EndDragAndDrop(bool Accepted);
virtual Cxcontrols::TcxDragAndDropObjectClass __fastcall GetDragAndDropObjectClass(void);
DYNAMIC Cxcontrols::TDragControlObjectClass __fastcall GetDragObjectClass(void);
DYNAMIC bool __fastcall StartDragAndDrop(const System::Types::TPoint P);
virtual Dxtouch::_di_IdxGestureClient __fastcall GetGestureClient(const System::Types::TPoint APoint);
__property TcxSchedulerSubControl* Background = {read=FBackground};
__property bool AligningSubControls = {read=FAligningSubControls, nodefault};
__property bool BoundsChanging = {read=FBoundsChanging, nodefault};
__property TcxSchedulerSubControl* Capture = {read=GetCaptureControl, write=SetCaptureControl};
__property TcxSchedulerSubControlController* CaptureController = {read=GetCaptureController};
__property TcxSchedulerClipboardController* ClipboardController = {read=FClipboardController};
__property TcxControlFlags ControlFlags = {read=FControlFlags, write=FControlFlags, nodefault};
__property Cxedit::TcxCustomEditProperties* DefaultProperties = {read=FDefaultProperties};
__property TcxSchedulerEditController* EditController = {read=FEditController};
__property Cxedit::TcxCustomEditStyle* EditStyle = {read=FEditStyle};
__property TcxSchedulerEventHitTestController* EventHitTestController = {read=FEventHitTestController, write=FEventHitTestController};
__property Cxschedulerstorage::TcxSchedulerCachedEventList* EventList = {read=FEventList};
__property TcxSchedulerHintController* HintController = {read=FHintController};
__property TcxSchedulerSplitter* HorzSplitter = {read=FHorzSplitter};
__property bool IsDragCanceled = {read=FIsDragCanceled, nodefault};
__property bool IsDynamicUpdate = {read=GetIsDynamicUpdate, nodefault};
__property bool IsLocked = {read=GetIsLocked, nodefault};
__property TcxSchedulerSubControl* KeyboardListener = {read=FKeyboardListener, write=FKeyboardListener};
__property int LockCount = {read=FLockCount, nodefault};
__property Cxschedulerutils::TcxSchedulerPainterHelperClass PainterHelper = {read=GetPainterHelper};
__property ParentFont = {default=0};
__property Cxdateutils::TDay StartOfWeek = {read=GetStartOfWeek, nodefault};
__property bool StorageActive = {read=GetStorageActive, nodefault};
__property bool StorageValid = {read=GetStorageValid, nodefault};
__property int SubControlCount = {read=GetSubControlCount, nodefault};
__property bool SubControlsCreated = {read=FSubControlsCreated, nodefault};
__property TcxSchedulerSubControl* SubControls[int Index] = {read=GetSubControl};
__property Cxschedulerstorage::TcxSchedulerEventList* TabOrdersList = {read=FTabOrdersList};
__property TcxSchedulerSplitter* VertSplitter = {read=FVertSplitter};
__property DragMode = {default=1};
__property BorderStyle = {default=1};
__property TcxSchedulerAfterDragEvent OnAfterDragEvent = {read=FOnAfterDragEvent, write=FOnAfterDragEvent};
__property TcxSchedulerAfterEditing OnAfterEditing = {read=FOnAfterEditing, write=FOnAfterEditing};
__property TcxSchedulerAfterSizingEvent OnAfterSizingEvent = {read=FOnAfterSizingEvent, write=FOnAfterSizingEvent};
__property TcxSchedulerBeforeDeleting OnBeforeDeleting = {read=FOnBeforeDeleting, write=FOnBeforeDeleting};
__property TcxSchedulerBeforeDragEvent OnBeforeDragEvent = {read=FOnBeforeDragEvent, write=FOnBeforeDragEvent};
__property TcxSchedulerBeforeEditing OnBeforeEditing = {read=FOnBeforeEditing, write=FOnBeforeEditing};
__property TcxSchedulerBeforeSizingEvent OnBeforeSizingEvent = {read=FOnBeforeSizingEvent, write=FOnBeforeSizingEvent};
__property TcxSchedulerCanShowViewEvent OnCanShowView = {read=FOnCanShowView, write=FOnCanShowView};
__property TcxSchedulerEventSelectionChangedEvent OnEventSelectionChanged = {read=FOnEventSelectionChanged, write=FOnEventSelectionChanged};
__property System::Classes::TNotifyEvent OnFirstVisibleResourceChanged = {read=FOnFirstVisibleResourceChanged, write=FOnFirstVisibleResourceChanged};
__property TcxSchedulerGetEventText OnGetEventDisplayText = {read=FOnGetEventDisplayText, write=FOnGetEventDisplayText};
__property TcxSchedulerGetEventText OnGetEventHintText = {read=FOnGetEventHintText, write=FOnGetEventHintText};
__property TcxSchedulerGetEventEditPropertiesEvent OnGetEventEditProperties = {read=FOnGetEventEditProperties, write=FOnGetEventEditProperties};
__property TcxSchedulerInitEditEvent OnInitEdit = {read=FOnInitEdit, write=FOnInitEdit};
__property TcxSchedulerIsWorkTimeEvent OnIsWorkTime = {read=FOnIsWorkTime, write=FOnIsWorkTime};
__property System::Classes::TNotifyEvent OnLayoutChanged = {read=FOnLayoutChanged, write=FOnLayoutChanged};
__property TcxSchedulerMoreEventsButtonClickEvent OnMoreEventsButtonClick = {read=FOnMoreEventsButtonClick, write=FOnMoreEventsButtonClick};
__property TcxSchedulerNavigationButtonClickEvent OnNavigationButtonClick = {read=FOnNavigationButtonClick, write=FOnNavigationButtonClick};
__property TcxSchedulerScaleScrollEvent OnScaleScroll = {read=FOnScaleScroll, write=FOnScaleScroll};
__property System::Classes::TNotifyEvent OnSelectionChanged = {read=FOnSelectionChanged, write=FOnSelectionChanged};
__property TcxSchedulerShowDateHintEvent OnShowDateHint = {read=GetOnShowDateHint, write=FOnShowDateHint};
__property TcxSchedulerViewTypeChangedEvent OnViewTypeChanged = {read=FOnViewTypeChanged, write=FOnViewTypeChanged};
public:
__fastcall virtual TcxCustomScheduler(System::Classes::TComponent* AOwner);
__fastcall virtual ~TcxCustomScheduler(void);
void __fastcall BeginUpdate(void);
void __fastcall CopyToClipboard(void);
virtual void __fastcall CreateEventUsingDialog(bool AllDay = false, bool ARecurrence = false);
void __fastcall CreateEventUsingInplaceEdit(void);
void __fastcall CutToClipboard(void);
virtual void __fastcall DeleteEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
void __fastcall DeleteSelectedEvents(bool ACheckReadOnly = true);
DYNAMIC void __fastcall DragDrop(System::TObject* Source, int X, int Y);
void __fastcall EditEventUsingDialog(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, bool ACheckReadOnly = true, bool AForcePatternEditing = false);
void __fastcall EditEventUsingInplaceEdit(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent);
void __fastcall EndUpdate(void);
virtual void __fastcall FullRefresh(void);
DYNAMIC void __fastcall GetChildren(System::Classes::TGetChildProc Proc, System::Classes::TComponent* Root);
virtual bool __fastcall GoToDate(System::TDateTime ADate)/* overload */;
virtual bool __fastcall GoToDate(System::TDateTime ADate, TcxSchedulerViewMode AViewMode)/* overload */;
void __fastcall LayoutChanged(void);
void __fastcall MakeEventVisible(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, const System::TDateTime ADate = -7.000000E+05, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource = (Cxschedulerstorage::TcxSchedulerStorageResourceItem*)(0x0));
void __fastcall MakeResourceVisible(Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
void __fastcall PasteFromClipboard(void);
void __fastcall SelectEvent(Cxschedulerstorage::TcxSchedulerControlEvent* AEvent, System::Classes::TShiftState AShift = System::Classes::TShiftState() );
void __fastcall SelectTime(const System::TDateTime ASelStart, const System::TDateTime ASelFinish, Cxschedulerstorage::TcxSchedulerStorageResourceItem* AResource);
void __fastcall UnselectEvents(void);
void __fastcall ValidateFirstVisibleResourceIndex(void);
void __fastcall RestoreFromIniFile(const System::UnicodeString AStorageName, bool ARestoreResources = true);
void __fastcall RestoreFromRegistry(const System::UnicodeString AStorageName, bool ARestoreResources = true);
void __fastcall RestoreFromStream(System::Classes::TStream* AStream, bool ARestoreResources = true);
void __fastcall StoreToIniFile(const System::UnicodeString AStorageName, bool AReCreate = true, bool AStoreResources = true);
void __fastcall StoreToRegistry(const System::UnicodeString AStorageName, bool AReCreate = true, bool AStoreResources = true);
void __fastcall StoreToStream(System::Classes::TStream* AStream, bool AStoreResources = true);
virtual void __fastcall TranslationChanged(void);
__property TcxSchedulerSubControlHitTest* ActiveHitTest = {read=GetActiveHitTest};
__property Color = {default=-16777211};
__property TcxSchedulerContentPopupMenu* ContentPopupMenu = {read=FContentPopupMenu, write=SetContentPopupMenu};
__property TcxSchedulerControlBox* ControlBox = {read=FControlBox, write=SetControlBox};
__property TcxSchedulerCustomView* CurrentView = {read=FCurrentView, write=SetCurrentView};
__property TcxSchedulerCustomDateNavigator* DateNavigator = {read=FDateNavigator};
__property Cxschedulerutils::TcxSchedulerDateTimeHelperClass DateTimeHelper = {read=GetDateTimeHelper};
__property Cxlookandfeels::TcxLookAndFeel* DialogsLookAndFeel = {read=FDialogsLookAndFeel, write=SetDialogsLookAndFeel};
__property Cxschedulerutils::TcxSchedulerDateList* EventDays = {read=FEventDays};
__property Vcl::Imglist::TCustomImageList* EventImages = {read=FEventImages, write=SetEventImages};
__property TcxSchedulerEventOperations* EventOperations = {read=FEventOperations, write=SetEventOperations};
__property TcxSchedulerEventPopupMenu* EventPopupMenu = {read=FEventPopupMenu, write=SetEventPopupMenu};
__property int FirstVisibleResourceIndex = {read=FFirstVisibleResourceIndex, write=SetFirstVisibleResourceIndex, default=0};
__property Cxschedulerutils::TcxSchedulerDateList* HolidayDays = {read=FHolidayDays};
__property TcxSchedulerOptionsBehavior* OptionsBehavior = {read=FOptionsBehavior, write=SetOptionsBehavior};
__property TcxSchedulerOptionsCustomize* OptionsCustomize = {read=FOptionsCustomize, write=SetOptionsCustomize};
__property TcxSchedulerOptionsView* OptionsView = {read=FOptionsView, write=SetOptionsView};
__property TcxSchedulerResourceNavigator* ResourceNavigator = {read=FResourceNavigator, write=SetResourceNavigator};
__property Cxschedulerutils::TcxSchedulerDateList* SelectedDays = {read=FSelectedDays};
__property int SelectedEventCount = {read=GetSelectedEventCount, nodefault};
__property Cxschedulerstorage::TcxSchedulerControlEvent* SelectedEvents[int Index] = {read=GetSelectedEvent};
__property System::TDateTime SelFinish = {read=GetSelFinish};
__property Cxschedulerstorage::TcxSchedulerStorageResourceItem* SelResource = {read=FSelResource};
__property System::TDateTime SelStart = {read=GetSelStart};
__property Cxschedulerstorage::TcxCustomSchedulerStorage* Storage = {read=FStorage, write=SetStorage};
__property System::UnicodeString StoringName = {read=FStoringName, write=FStoringName};
__property TcxSchedulerStyles* Styles = {read=FStyles, write=SetStyles};
__property int VisibleEventCount = {read=GetVisibleEventCount, nodefault};
__property Cxschedulerstorage::TcxSchedulerControlEvent* VisibleEvents[int AIndex] = {read=GetVisibleEvent};
__property TabStop = {default=1};
__property Font;
__published:
__property System::Classes::TNotifyEvent StylesEvents = {read=FStylesEvents, write=FStylesEvents};
__property System::Classes::TNotifyEvent ResourceNavigatorEvents = {read=FResourceNavigatorEvents, write=FResourceNavigatorEvents};
__property System::Classes::TNotifyEvent ContentPopupMenuEvents = {read=FContentPopupMenuEvents, write=FContentPopupMenuEvents};
__property System::Classes::TNotifyEvent EventPopupMenuEvents = {read=FEventPopupMenuEvents, write=FEventPopupMenuEvents};
public:
/* TWinControl.CreateParented */ inline __fastcall TcxCustomScheduler(HWND ParentWindow) : Cxcontrols::TcxControl(ParentWindow) { }
private:
void *__IdxSkinSupport; /* Cxlookandfeels::IdxSkinSupport */
void *__IcxStoredObject; /* Cxstorage::IcxStoredObject */
void *__IcxFormatControllerListener2; /* Cxformats::IcxFormatControllerListener2 */
void *__IcxFormatControllerListener; /* Cxformats::IcxFormatControllerListener */
void *__IcxSchedulerStorageListener; /* Cxschedulerstorage::IcxSchedulerStorageListener */
public:
#if defined(MANAGED_INTERFACE_OPERATORS)
// {EF3FF483-9B69-46DF-95A4-D3A3810F63A5}
operator Cxlookandfeels::_di_IdxSkinSupport()
{
Cxlookandfeels::_di_IdxSkinSupport intf;
GetInterface(intf);
return intf;
}
#else
operator Cxlookandfeels::IdxSkinSupport*(void) { return (Cxlookandfeels::IdxSkinSupport*)&__IdxSkinSupport; }
#endif
#if defined(MANAGED_INTERFACE_OPERATORS)
// {79A05009-CAC3-47E8-B454-F6F3D91F495D}
operator Cxstorage::_di_IcxStoredObject()
{
Cxstorage::_di_IcxStoredObject intf;
GetInterface(intf);
return intf;
}
#else
operator Cxstorage::IcxStoredObject*(void) { return (Cxstorage::IcxStoredObject*)&__IcxStoredObject; }
#endif
#if defined(MANAGED_INTERFACE_OPERATORS)
// {5E33A2A7-0C77-415F-A359-112103E54937}
operator Cxformats::_di_IcxFormatControllerListener2()
{
Cxformats::_di_IcxFormatControllerListener2 intf;
GetInterface(intf);
return intf;
}
#else
operator Cxformats::IcxFormatControllerListener2*(void) { return (Cxformats::IcxFormatControllerListener2*)&__IcxFormatControllerListener2; }
#endif
#if defined(MANAGED_INTERFACE_OPERATORS)
// {A7F2F6D3-1A7D-4295-A6E6-9297BD83D0DE}
operator Cxformats::_di_IcxFormatControllerListener()
{
Cxformats::_di_IcxFormatControllerListener intf;
GetInterface(intf);
return intf;
}
#else
operator Cxformats::IcxFormatControllerListener*(void) { return (Cxformats::IcxFormatControllerListener*)&__IcxFormatControllerListener; }
#endif
#if defined(MANAGED_INTERFACE_OPERATORS)
// {87E0EBF3-F68A-4A51-8EA3-850D3819FBAB}
operator Cxschedulerstorage::_di_IcxSchedulerStorageListener()
{
Cxschedulerstorage::_di_IcxSchedulerStorageListener intf;
GetInterface(intf);
return intf;
}
#else
operator Cxschedulerstorage::IcxSchedulerStorageListener*(void) { return (Cxschedulerstorage::IcxSchedulerStorageListener*)&__IcxSchedulerStorageListener; }
#endif
};
class DELPHICLASS TcxSchedulerPopupMenu;
class PASCALIMPLEMENTATION TcxSchedulerPopupMenu : public System::Classes::TPersistent
{
typedef System::Classes::TPersistent inherited;
private:
TcxCustomScheduler* FScheduler;
System::Classes::TComponent* FPopupMenu;
Vcl::Menus::TPopupMenu* FInternalMenu;
bool FUseBuiltInPopupMenu;
Vcl::Menus::TMenuItem* __fastcall GetRoot(void);
void __fastcall SetPopupMenu(System::Classes::TComponent* const Value);
protected:
Vcl::Menus::TMenuItem* __fastcall AddValidSeparator(Vcl::Menus::TMenuItem* AOwner);
void __fastcall CreateInternalMenu(void);
virtual void __fastcall CreateItems(void);
Vcl::Menus::TMenuItem* __fastcall CreateSeparator(Vcl::Menus::TMenuItem* AOwner);
Vcl::Menus::TMenuItem* __fastcall CreateSubItem(Vcl::Menus::TMenuItem* AOwner, const System::UnicodeString ACaption, int ACommand = 0xffffffff, int AImageIndex = 0xffffffff, bool AEnabled = true, bool AChecked = false);
virtual void __fastcall DoExecute(int ACommand);
virtual bool __fastcall DoOnClick(int ACommand);
virtual bool __fastcall DoOnPopup(void);
void __fastcall ExecuteCommand(int ACommand);
Vcl::Menus::TMenuItem* __fastcall FindItemByCommand(Vcl::Menus::TMenuItem* AOwnerItem, int ACommand);
virtual bool __fastcall IsValidCommand(int ACommand);
void __fastcall Notification(System::Classes::TComponent* AComponent, System::Classes::TOperation Operation);
void __fastcall OnItemClickHandler(System::TObject* Sender);
Cxschedulerstorage::TcxCustomSchedulerStorage* __fastcall Storage(void);
__property Vcl::Menus::TPopupMenu* InternalMenu = {read=FInternalMenu};
__property Vcl::Menus::TMenuItem* Root = {read=GetRoot};
public:
__fastcall virtual TcxSchedulerPopupMenu(TcxCustomScheduler* AScheduler);
__fastcall virtual ~TcxSchedulerPopupMenu(void);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
virtual bool __fastcall Popup(int X, int Y);
__property TcxCustomScheduler* Scheduler = {read=FScheduler};
__published:
__property System::Classes::TComponent* PopupMenu = {read=FPopupMenu, write=SetPopupMenu};
__property bool UseBuiltInPopupMenu = {read=FUseBuiltInPopupMenu, write=FUseBuiltInPopupMenu, default=1};
};
class DELPHICLASS TcxSchedulerCustomContentPopupMenu;
class PASCALIMPLEMENTATION TcxSchedulerCustomContentPopupMenu : public TcxSchedulerPopupMenu
{
typedef TcxSchedulerPopupMenu inherited;
private:
int FNewID;
int FAllDayID;
int FReccurenceID;
protected:
bool __fastcall CanCreateEvent(void);
void __fastcall CreateNewEventItems(bool ANew, bool AllDay, bool AReccurence, int ANewID, int AllDayID, int AReccurenceID);
virtual void __fastcall DoExecute(int ACommand);
public:
__fastcall virtual TcxSchedulerCustomContentPopupMenu(TcxCustomScheduler* AScheduler);
public:
/* TcxSchedulerPopupMenu.Destroy */ inline __fastcall virtual ~TcxSchedulerCustomContentPopupMenu(void) { }
};
typedef void __fastcall (__closure *TcxSchedulerContentPopupMenuPopupEvent)(TcxSchedulerContentPopupMenu* Sender, Vcl::Menus::TPopupMenu* ABuiltInMenu, bool &AHandled);
typedef void __fastcall (__closure *TcxSchedulerContentPopupMenuClickEvent)(TcxSchedulerContentPopupMenu* Sender, TcxSchedulerContentPopupMenuItem AItem, bool &AHandled);
class PASCALIMPLEMENTATION TcxSchedulerContentPopupMenu : public TcxSchedulerCustomContentPopupMenu
{
typedef TcxSchedulerCustomContentPopupMenu inherited;
private:
TcxSchedulerContentPopupMenuItems FActualItems;
TcxSchedulerContentPopupMenuItems FItems;
System::TDateTime FSavedDate;
TcxSchedulerContentPopupMenuPopupEvent FOnPopup;
TcxSchedulerContentPopupMenuClickEvent FOnClick;
void __fastcall CreateGoToThisDayItem(void);
protected:
virtual void __fastcall CreateItems(void);
virtual void __fastcall DoExecute(int ACommand);
virtual bool __fastcall DoOnClick(int ACommand);
virtual bool __fastcall DoOnPopup(void);
virtual bool __fastcall IsValidCommand(int ACommand);
__property TcxSchedulerContentPopupMenuItems ActualItems = {read=FActualItems, nodefault};
public:
__fastcall virtual TcxSchedulerContentPopupMenu(TcxCustomScheduler* AScheduler);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
void __fastcall Execute(TcxSchedulerContentPopupMenuItem AItem);
Vcl::Menus::TMenuItem* __fastcall GetMenuItem(TcxSchedulerContentPopupMenuItem AItem);
__published:
__property TcxSchedulerContentPopupMenuItems Items = {read=FItems, write=FItems, default=127};
__property PopupMenu;
__property UseBuiltInPopupMenu = {default=1};
__property TcxSchedulerContentPopupMenuClickEvent OnClick = {read=FOnClick, write=FOnClick};
__property TcxSchedulerContentPopupMenuPopupEvent OnPopup = {read=FOnPopup, write=FOnPopup};
public:
/* TcxSchedulerPopupMenu.Destroy */ inline __fastcall virtual ~TcxSchedulerContentPopupMenu(void) { }
};
enum TcxSchedulerEventPopupMenuItem : unsigned char { epmiOpen, epmiEditSeries, epmiShowTimeAs, epmiLabel, epmiDelete };
typedef System::Set<TcxSchedulerEventPopupMenuItem, TcxSchedulerEventPopupMenuItem::epmiOpen, TcxSchedulerEventPopupMenuItem::epmiDelete> TcxSchedulerEventPopupMenuItems;
typedef void __fastcall (__closure *TcxSchedulerEventPopupMenuPopupEvent)(TcxSchedulerEventPopupMenu* Sender, Vcl::Menus::TPopupMenu* ABuiltInMenu, bool &AHandled);
typedef void __fastcall (__closure *TcxSchedulerEventPopupMenuClickEvent)(TcxSchedulerEventPopupMenu* Sender, TcxSchedulerEventPopupMenuItem AItem, int ASubItemIndex, bool &AHandled);
class PASCALIMPLEMENTATION TcxSchedulerEventPopupMenu : public TcxSchedulerPopupMenu
{
typedef TcxSchedulerPopupMenu inherited;
private:
Cxschedulerstorage::TcxSchedulerControlEvent* FEvent;
TcxSchedulerEventPopupMenuItems FItems;
TcxSchedulerEventPopupMenuPopupEvent FOnPopup;
TcxSchedulerEventPopupMenuClickEvent FOnClick;
void __fastcall CreateDeleteItem(void);
void __fastcall CreateLabelItems(void);
void __fastcall CreateTimeItems(void);
int __fastcall GetCommand(TcxSchedulerEventPopupMenuItem AItem, int ASubItemIndex);
bool __fastcall CanEdit(void);
Cxschedulerstorage::TcxSchedulerControlEvent* __fastcall GetEvent(void);
void __fastcall UnpackCommand(int ACommand, /* out */ TcxSchedulerEventPopupMenuItem &AItem, /* out */ int &ASubItemIndex);
protected:
virtual void __fastcall CreateItems(void);
virtual void __fastcall DoExecute(int ACommand);
virtual bool __fastcall DoOnClick(int ACommand);
virtual bool __fastcall DoOnPopup(void);
virtual bool __fastcall IsValidCommand(int ACommand);
void __fastcall SetEventLabelColor(int AColor);
void __fastcall SetEventState(int AState);
public:
__fastcall virtual TcxSchedulerEventPopupMenu(TcxCustomScheduler* AScheduler);
virtual void __fastcall Assign(System::Classes::TPersistent* Source);
Vcl::Menus::TMenuItem* __fastcall GetMenuItem(TcxSchedulerEventPopupMenuItem AItem, int ASubItemIndex = 0xffffffff);
__property Cxschedulerstorage::TcxSchedulerControlEvent* Event = {read=FEvent};
__published:
__property TcxSchedulerEventPopupMenuItems Items = {read=FItems, write=FItems, default=31};
__property PopupMenu;
__property UseBuiltInPopupMenu = {default=1};
__property TcxSchedulerEventPopupMenuClickEvent OnClick = {read=FOnClick, write=FOnClick};
__property TcxSchedulerEventPopupMenuPopupEvent OnPopup = {read=FOnPopup, write=FOnPopup};
public:
/* TcxSchedulerPopupMenu.Destroy */ inline __fastcall virtual ~TcxSchedulerEventPopupMenu(void) { }
};
//-- var, const, procedure ---------------------------------------------------
static const int LastAvailableDate = int(0x2d2462);
static const System::Int8 cxDefaultTimeScale = System::Int8(0x1e);
static const System::Int8 htcControl = System::Int8(0x0);
static const System::Int8 htcTime = System::Int8(0x1);
static const System::Int8 htcResource = System::Int8(0x2);
static const System::Int8 cxcsBackground = System::Int8(0x0);
static const System::Int8 cxcsContent = System::Int8(0x1);
static const System::Int8 cxcsEvent = System::Int8(0x2);
static const System::Int8 cxcsGroupSeparator = System::Int8(0x3);
static const System::Int8 cxcsDayHeader = System::Int8(0x4);
static const System::Int8 cxcsSelection = System::Int8(0x5);
static const System::Int8 cxcsHSplitter = System::Int8(0x6);
static const System::Int8 cxcsVSplitter = System::Int8(0x7);
static const System::Int8 cxcsResourceHeader = System::Int8(0x8);
static const System::Int8 cxcsMaxValue = System::Int8(0x8);
static const System::Int8 cxcsSchedulerStyleFirst = System::Int8(0x0);
static const System::Int8 cxcsSchedulerStyleLast = System::Int8(0x8);
static const System::Byte cxDefaultSchedulerHeight = System::Byte(0xfa);
static const System::Word cxDefaultSchedulerWidth = System::Word(0x15e);
static const System::Int8 cxDefaultSplitterWidth = System::Int8(0x5);
static const System::Int8 cxDefaultGroupSeparatorWidth = System::Int8(0xb);
static const System::Int8 cxDefaultResourcesPerPage = System::Int8(0x0);
static const System::Int8 cxMinSplitterWidth = System::Int8(0x3);
extern PACKAGE int cxscMinHintWidth;
extern PACKAGE int cxscMaxHintWidth;
static const System::Int8 cxScrollInterval = System::Int8(0x19);
static const System::Int8 cxScrollZoneSize = System::Int8(0xa);
static const System::Word cxNavigatorStartTimer = System::Word(0x12c);
static const System::Int8 cxSchedulerFirstButton = System::Int8(0x0);
static const System::Int8 cxSchedulerPrevPageButton = System::Int8(0x1);
static const System::Int8 cxSchedulerPrevButton = System::Int8(0x2);
static const System::Int8 cxSchedulerNextButton = System::Int8(0x3);
static const System::Int8 cxSchedulerNextPageButton = System::Int8(0x4);
static const System::Int8 cxSchedulerLastButton = System::Int8(0x5);
static const System::Int8 cxSchedulerShowMoreResourcesButton = System::Int8(0x6);
static const System::Int8 cxSchedulerShowFewerResourcesButton = System::Int8(0x7);
extern PACKAGE System::StaticArray<bool, 8> cxSchedulerNavigatorVisibility;
#define SCF_SCHEDULERCLIPBOARDFORMAT L"ExpressScheduler 2.0"
extern PACKAGE int CF_SCHEDULERDATA;
extern PACKAGE bool __fastcall IsHeaderEvent(Cxschedulerstorage::TcxSchedulerEvent* AEvent);
} /* namespace Cxschedulercustomcontrols */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_CXSCHEDULERCUSTOMCONTROLS)
using namespace Cxschedulercustomcontrols;
#endif
#pragma pack(pop)
#pragma option pop
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // CxschedulercustomcontrolsHPP
|
4deae1f5e061cbf910e1dab789d898a3c04b1849 | bc84c328d1cc2a318160d42ed1faa1961bdf1e87 | /windows/VC++/DLL/DLL_Add/call_add.cpp | 67e5bc7398d642ad07dbcc2d10ab791bd0c6df96 | [
"MIT"
] | permissive | liangjisheng/C-Cpp | 25d07580b5dd1ff364087c3cf8e13cebdc9280a5 | 8b33ba1f43580a7bdded8bb4ce3d92983ccedb81 | refs/heads/master | 2021-07-10T14:40:20.006051 | 2019-01-26T09:24:04 | 2019-01-26T09:24:04 | 136,299,205 | 7 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 354 | cpp | call_add.cpp | #include"stdio.h"
#include"windows.h"
typedef int(*lpAddFun)(int,int);
int main()
{
HINSTANCE hDll; // DLL句柄
lpAddFun addFun;
hDll=LoadLibrary("..\\Debug\\1073.dll");
if(hDll!=NULL) {
addFun=(lpAddFun)GetProcAddress(hDll,"add");
if(addFun!=NULL) {
int result=addFun(2,3);
printf("%d\n",result);
}
}
FreeLibrary(hDll);
return 0;
} |
37425a307bb36c66051c2e1be0ffd495472d9313 | a462312d4b02adf64532a52425df1adf5a40d687 | /UWPLessons/Lesson 2/Program.cpp | 2069e736f7e7a53a9b7baf6f42b11c1328774689 | [] | no_license | AstreyRize/DirectXLessons | 3f0b3e9fd323b57c816505c20d9e007ca00c5958 | 8d89f3c65b5c18ada6d014d33a21b670633b7639 | refs/heads/master | 2020-03-31T03:41:21.893862 | 2019-10-13T15:41:17 | 2019-10-13T15:41:17 | 151,873,998 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 455 | cpp | Program.cpp | #include "pch.h"
#include "Window.h"
#include "Direct3DApplicationSource.h"
using namespace Lesson_2;
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^)
{
auto direct3DApplicationSource = ref new Direct3DApplicationSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
} |
28caf396e299b03663f38110c194a48a18763caf | 1bb34d582ec78fbf8e30f80b8efea85ba2b65d23 | /Term2/CXX/comm-iliayar/include/comm.h | 241abb1fe23753817b70f5f977b1c1b087e04f1e | [] | no_license | iliayar/ITMO | 41187c292dd5a9f72d62ebe81b5e42c664020bd1 | 6194a511384f6243b7c43c3b6fd2c03a0d089e92 | refs/heads/master | 2023-09-03T06:54:32.742264 | 2023-08-19T17:00:08 | 2023-08-19T17:00:08 | 216,113,996 | 12 | 1 | null | 2023-04-18T13:21:54 | 2019-10-18T22:11:01 | Jupyter Notebook | UTF-8 | C++ | false | false | 3,522 | h | comm.h | #include <iostream>
#include <string_view>
#include <vector>
class Comm
{
public:
Comm(std::pair<std::istream&, std::istream&> inputs)
: m_eof({ inputs.first.eof(), inputs.second.eof() })
, m_lines({ "", "" })
, m_inputs(inputs)
, m_excluded(3, false)
{
read_next({ true, true });
}
void exclude(int n) { m_excluded[n] = true; }
std::pair<std::string, bool> next()
{
if (empty())
return { "", true };
std::pair<bool, bool> to_read = { false, false };
int column;
if (m_eof.first) {
to_read = { false, true };
} else if (m_eof.second) {
to_read = { true, false };
} else if (m_lines.first < m_lines.second) {
to_read = { true, false };
} else if (m_lines.first > m_lines.second) {
to_read = { false, true };
} else {
to_read = { true, true };
}
column = get_column_imp(to_read);
std::string res = "";
bool empty = true;
for (int i = 0, j = 0; i < 3; ++i) {
if (!m_excluded[i]) {
if (j > 0)
res += "\t";
if (i == column) {
if (column == 0) {
res += m_lines.first;
} else {
res += m_lines.second;
}
empty = false;
break;
}
j++;
}
}
read_next(to_read);
return { std::move(res), empty };
}
bool empty() { return m_eof.first && m_eof.second; }
friend std::ostream& operator<<(std::ostream& o, Comm& comm)
{
while (!comm.empty()) {
auto l = comm.next();
if (l.second)
continue;
o << l.first << std::endl;
}
return o;
}
static constexpr std::string_view USAGE =
"Usage: comm [OPTION] FILE1 FILE2\n\
Options:\n \
-1 \t suppress column 1 (lines unique to FILE1)\n \
-2 \t suppress column 2 (lines unique to FILE2)\n \
-3 \t suppress column 3 (lines that appear in both files)";
private:
void read_next(const std::pair<bool, bool>& to_read)
{
if (to_read.first) {
if (m_inputs.first.eof()) {
m_eof.first = true;
} else {
std::getline(m_inputs.first, m_lines.first);
if (m_lines.first == "" && m_inputs.first.eof()) {
m_eof.first = true;
}
}
}
if (to_read.second) {
if (m_inputs.second.eof()) {
m_eof.second = true;
} else {
std::getline(m_inputs.second, m_lines.second);
if (m_lines.second == "" && m_inputs.second.eof()) {
m_eof.second = true;
}
}
}
}
int get_column_imp(const std::pair<bool, bool>& p)
{
if (p.first && !p.second) {
return 0;
} else if (!p.first && p.second) {
return 1;
} else if (p.first && p.second) {
return 2;
}
return -1;
}
std::pair<bool, bool> m_eof;
std::pair<std::string, std::string> m_lines;
std::pair<std::istream&, std::istream&> m_inputs;
std::vector<bool> m_excluded;
};
|
bf405c15eece2a5bee56d66859f25dfdba1c8c7a | ca0b8d79fbce09ecbab4b9279fb230c2a7ad370a | /Esercizi assegnati/2013-2014/20140303/esercizio1-3-3.cpp | 67c8e9a23ea21471840599904db96f777dd86a0e | [] | no_license | FIUP/Programmazione-1 | 6523e4d7a5c64370eef5b7ac8e6c5687b620ffd8 | a897af997a5ded0d6e167f9f03d846d54a161add | refs/heads/master | 2021-06-03T16:22:01.190618 | 2020-09-30T20:57:12 | 2020-09-30T20:57:12 | 80,129,830 | 23 | 39 | null | 2020-09-30T20:57:13 | 2017-01-26T16:01:07 | C++ | UTF-8 | C++ | false | false | 2,550 | cpp | esercizio1-3-3.cpp | #include<iostream>
#include<fstream>
using namespace std;
struct nodo{
int info1, info2;
nodo* next;
nodo(int a=0, int c=0, nodo* b=0) {info1=a; info2=c; next=b;}
};
//PRE_F1=(L è una lista corretta, y e v sono interi qualsiasi, mentre k>0, L=vL)
nodo* F1(nodo*&L, int y, int k, int & v){
if(!L){
return 0;
}
if(L->info1==y){
v=v+1;
nodo *x=new nodo(L->info1, L->info2, F1(L->next, y, k, v));
if(v<k && !x->next)
return 0;
if(v>k)
v=k;
if(v>0){
v=v-1;
L=L->next;
return x;
}
return x->next;
}
return F1(L->next, y, k, v);
}//POST_F1=(se vL contiene meno di k nodi con campo info=y, allora L=vL e F1 restituisce 0, altrimenti, L è la lista ottenuta da vL togliendo da vL gli ultimi (per posizione) k nodi con campo info1=y, mentre F1 restituisce la lista dei nodi tolti da vL in ordine di posizione in vL.....è possibile che sia anche necessario aggiungere qualcosa su v)
//PRE_F2=(L è una lista corretta, y e v sono interi qualsiasi, mentre k>0, L=vL)
nodo* F2(nodo*&L, int y, int k, int & v){
if(!L){
return 0;
}
if(L->info1==y){
v=v+1;
nodo *x=new nodo(L->info1, L->info2, F2(L->next, y, k, v));
if(v==k){
L=L->next;
return x;
}
if(v>k)
v=v-1;
return 0;
}
return F2(L->next, y, k, v);
}//POST_F2==(se vL contiene meno di k nodi con campo info=y, allora L=vL e F2 restituisce 0, altrimenti, L è la lista ottenuta da vL togliendo da vL gli i primi (per posizione) k nodi con campo info1=y, mentre F2 restituisce la lista dei nodi tolti da vL in ordine di posizione in vL.....è possibile che sia anche necessario aggiungere qualcosa su v)
nodo* copia(nodo*L){
if(L)
return new nodo(L->info1, L->info2, copia(L->next));
else return 0;
}
void crea(nodo*&L, int dim, ifstream & INP, int n){
if(dim){
int x;
INP>>x;
L=new nodo(x, n);
crea(L->next, dim-1, INP, n+1);
} else L=0;
}
void stampa(nodo* x, ofstream & OUT){
if(x){
OUT<< x->info1<<' '<<x->info2<<' ';
stampa(x->next, OUT);
} else OUT<<endl;
}
main(){
try{
ifstream INP("input");
ofstream OUT("output");
if(!INP) throw(0);
if(!OUT) throw(1);
int dim, k, y, v;
INP>>k>>y>>dim;
nodo*L1=0;
crea(L1,dim,INP,0);
nodo*L2=0;
L2=copia(L1);
v=0;
nodo* x1=F1(L1,y,k,v);
stampa(x1,OUT);
stampa(L1,OUT);
v=0; //va rifatta
nodo* x2=F2(L2,y,k,v);
stampa(x2,OUT);
stampa(L2,OUT);
OUT<<endl;
} catch(int x) {
switch(x){
case 0: cout<<"problemi con input"<<endl; break;
case 1: cout<<"problemi con output"<<endl; break;
}
}
}
|
5746b99656e54bf3e7eeab8fdd4eecf0cc787fee | 09a5f628f61aa97be79f67e8d2dfb920fcc8f894 | /Projects/FrameWork/FrameWork/Systems/Renderer/ObjectRenderer.cpp | 3d922b1e99bb70d4b41f2f0a6160e9c93b14d3ee | [] | no_license | tozawa0406/SpriteMeshEditer | daafdedb9b5957263553d65107357a6bbdac3c76 | e8c02aa73045ba4cdfb45443ad7d5f96091e968e | refs/heads/master | 2020-04-24T17:38:46.367375 | 2019-11-13T12:04:49 | 2019-11-13T12:04:49 | 172,154,914 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 864 | cpp | ObjectRenderer.cpp | #include "ObjectRenderer.h"
ObjectRenderer::ObjectRenderer(RendererType type) :
manager_(nullptr)
, wrapper_(nullptr)
, transform_(nullptr)
, flag_(FLAG_ENABLE | FLAG_SORT)
, type_(type)
, shader_(Shader::ENUM::UNKOUWN)
{
material_.diffuse = COLOR(1, 1, 1, 1);
material_.ambient = COLOR(0.3f, 0.3f, 0.3f, 1);
material_.emission = COLOR(0, 0, 0, 0);
material_.specular = COLOR(0, 0, 0, 0);
material_.power = 0;
}
ObjectRenderer::~ObjectRenderer(void)
{
if (manager_)
{
manager_->Remove(this);
}
}
void ObjectRenderer::Init(ObjectRendererManager* manager, const Transform* transform)
{
if (!manager) { return; }
manager_ = manager;
transform_ = transform;
manager->Add(this);
if (const auto& systems = manager->GetSystems())
{
if (const auto& graphics = systems->GetGraphics())
{
wrapper_ = graphics->GetWrapper();
}
}
}
|
8e98b1686077b0b92fb7c50637120318d52d3c8b | 707ee180c9ddf29458b42a754d9c102097c7a385 | /Лаба 3 Вариант Б5/owner.cpp | 1b2abc3d7295d58c2da9ac6935f40333fbabd12b | [] | no_license | staskond/-Third-Lab-OOP-vB5 | 0c89d886a7cdb672ddcb8627aeb3947122eb8470 | bd116128694a5e2eca197be3d827eccde7550b5c | refs/heads/master | 2021-01-10T03:26:02.971086 | 2015-12-21T13:57:35 | 2015-12-21T13:57:35 | 47,631,704 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,599 | cpp | owner.cpp | // (C) 2013-2015, Sergei Zaychenko, KNURE, Kharkiv, Ukraine
#include "owner.hpp"
#include <algorithm>
/*****************************************************************************/
// TODO
/*****************************************************************************/
Owner::Owner(const std::string & _FullNameOwner)
:m_FullNameOwner(_FullNameOwner)
{
if (m_FullNameOwner.empty())
throw std::logic_error(Messages::OwnerNameEmpty);
}
Asset * Owner::UniqueAsset(std::string const & _assetName) const
{
auto it = std::find_if(
m_assets.begin(), m_assets.end(),
[&](auto const & _Asset)
{
return _Asset->GetFullNameProperty() == _assetName;
}
);
if (it == m_assets.end())
return nullptr;
else
throw std::logic_error(Messages::AssetNameNotUniqueWithinOwner);
}
Asset * Owner::findAsset(std::string const & _name) const
{
auto it = std::find_if(
m_assets.begin(), m_assets.end(),
[&](auto const & _asset)
{
return _asset->GetFullNameProperty() == _name;
}
);
if (it == m_assets.end())
return nullptr;
else
return it->get();
}
void Owner::addProperty(std::unique_ptr<Asset> _assets)
{
if (findAsset(_assets->GetFullNameProperty()))
throw std::logic_error(Messages::AssetNameNotUniqueWithinOwner);
m_assets.push_back(std::move(_assets));
}
/*
void Owner::addProperty(Asset & _property)
{
for (auto const & pAsset : m_assets)
if (_property.GetFullNameProperty() == pAsset->GetFullNameProperty())
throw std::logic_error(Messages::AssetNameNotUniqueWithinOwner);
m_assets.push_back(std::make_unique<Asset>(std::move(_property)));
}*/
|
1f3441fb387d52d1e67d517e64d8a6c855448f3d | 01167b048623538b7121c1dcacaf22fad82b5fb8 | /tests/Switch.System.Windows.Forms.UnitTests/Switch/System/Windows/Forms/BootModeTest.cpp | 8133015118fef438bb74d608d62f9031d489b622 | [
"MIT"
] | permissive | victor-timoshin/Switch | 8cd250c55027f6c8ef3dd54822490411ffbe2453 | 8e8e687a8bdc4f79d482680da3968e9b3e464b8b | refs/heads/master | 2020-03-20T22:46:57.904445 | 2018-06-18T21:54:51 | 2018-06-18T21:54:51 | 137,815,096 | 5 | 3 | null | 2018-06-18T22:56:15 | 2018-06-18T22:56:15 | null | UTF-8 | C++ | false | false | 890 | cpp | BootModeTest.cpp | #include <Switch/System/Windows/Forms/BootMode.hpp>
#include <Switch/System/String.hpp>
#include <gtest/gtest.h>
namespace SwitchUnitTests {
TEST(BootModeTest, Normal) {
ASSERT_EQ(0, (int32)System::Windows::Forms::BootMode::Normal);
ASSERT_EQ("Normal", System::Enum<System::Windows::Forms::BootMode>(System::Windows::Forms::BootMode::Normal).ToString());
}
TEST(BootModeTest, FailSafe) {
ASSERT_EQ(1, (int32)System::Windows::Forms::BootMode::FailSafe);
ASSERT_EQ("FailSafe", System::Enum<System::Windows::Forms::BootMode>(System::Windows::Forms::BootMode::FailSafe).ToString());
}
TEST(BootModeTest, FailSafeWithNetwork) {
ASSERT_EQ(2, (int32)System::Windows::Forms::BootMode::FailSafeWithNetwork);
ASSERT_EQ("FailSafeWithNetwork", System::Enum<System::Windows::Forms::BootMode>(System::Windows::Forms::BootMode::FailSafeWithNetwork).ToString());
}
}
|
2003b8cf37741b024b96d09815934feb6f756edd | 82bf2730e87b2304305f781f996a4c87de0e32ac | /Chess/Test/Bishop.h | 53ef9e6d803adf86f8ce6df3460b318c1dcb1aab | [] | no_license | AndrewSavchuk1410/Chess-with-AI | 761dbd2d271ccc3ad963ce15cddac50d750260cf | 9c2f0b366dbeb43b1dbdb4ebdffd26bb0cb0c2ae | refs/heads/master | 2023-01-08T20:18:38.678438 | 2020-11-09T12:27:20 | 2020-11-09T12:27:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 245 | h | Bishop.h | #pragma once
#include "Figure.h"
#include "Board.h"
#include <SFML/Graphics.hpp>
class Bishop : public Figure
{
public:
Bishop();
Bishop(int x, int y, FIGURES figureType, int team, sf::Sprite sprite);
virtual void findAvaliableCells();
}; |
13549ea6e9a638be8e07fba5528912f097bb70e8 | 3f4e1ac1b83cf5c41a505ef67c099ecd422f985a | /main.cpp | 58de3d35f5b2e050fb308342091c61dc72f900fa | [] | no_license | hvanruys/EumetcastDirUpdate | ba7f3cdf872d42d607424e471d12be98479213e2 | a43fb5187b1c40994fb916a4565de0ad4ea2a452 | refs/heads/master | 2022-11-22T01:31:14.998466 | 2020-07-22T09:15:29 | 2020-07-22T09:15:29 | 281,412,365 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,967 | cpp | main.cpp | #include <QtCore>
#include <QCoreApplication>
#include <QSettings>
#include <QDir>
#include <QDate>
#include <QDebug>
#include <QRegularExpression>
#include <QBasicTimer>
#include <QTimer>
#include <iostream>
using namespace std;
struct FileTemplate {
QString filetemplate;
int startdate;
};
QList<FileTemplate> filetemplates;
QList<QString> segmentdirectories;
QStringList completelist;
QList<bool> complete_todelete;
QList<int> complete_startdate;
void CleanupDirectories(bool bListfiles);
void MoveTheFiles(const QString &thedir, bool bListfiles);
void MoveToDirectory(QString filename, int thestartdate, QDir dir);
void MyRun()
{
CleanupDirectories(true);
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSettings settings("EumetcastWatcherOut.ini", QSettings::IniFormat);
int size = settings.beginReadArray("filetemplates");
for (int i = 0; i < size; ++i) {
settings.setArrayIndex(i);
FileTemplate mytemplate;
mytemplate.filetemplate = settings.value("template").toString();
mytemplate.startdate = settings.value("startdate").toInt();
filetemplates.append(mytemplate);
}
settings.endArray();
// for(int i = 0; i < filetemplates.size(); i++)
// {
// printf("%d - %s\n", filetemplates.at(i).startdate, filetemplates.at(i).filetemplate.toStdString().c_str());
// }
size = settings.beginReadArray("segmentdirectories");
for (int i = 0; i < size; ++i) {
settings.setArrayIndex(i);
QString mydirectory;
mydirectory = settings.value("directory").toString();
segmentdirectories.append(mydirectory);
}
settings.endArray();
// for(int i = 0; i < segmentdirectories.size(); i++)
// {
// printf("%s\n", segmentdirectories.at(i).toStdString().c_str());
// }
CleanupDirectories(false);
QTimer *timer = new QTimer(&a);
QObject::connect(timer, &QTimer::timeout, &a, MyRun);
timer->start(5000);
return a.exec();
}
void CleanupDirectories(bool bListfiles)
{
if (segmentdirectories.count() > 0)
{
QStringList::Iterator its = segmentdirectories.begin();
while( its != segmentdirectories.end() )
{
QString stits = *its;
MoveTheFiles(stits, bListfiles);
++its;
}
}
}
void MoveTheFiles(const QString &thedir, bool bListfiles)
{
QString filename;
QString restfile;
QDir dir( thedir );
QString fileyear;
QString filemonth;
QString fileday;
int thecount = 0;
completelist.clear();
complete_todelete.clear();
complete_startdate.clear();
dir.setFilter(QDir::Files | QDir::NoSymLinks);
completelist = dir.entryList();
for(int i = 0; i < completelist.count(); i++)
{
complete_todelete.append(true);
complete_startdate.append(0);
}
if (filetemplates.count() > 0)
{
QList<FileTemplate>::Iterator itfile = filetemplates.begin();
while( itfile != filetemplates.end() )
{
thecount = 0;
QString wildcard = QRegularExpression::wildcardToRegularExpression((*itfile).filetemplate);
QRegularExpression re(wildcard);
int intfrom = 0;
intfrom = completelist.indexOf(re, intfrom);
while(intfrom != -1)
{
filename = completelist.at(intfrom);
complete_todelete[intfrom] = false;
complete_startdate[intfrom] = (*itfile).startdate;
thecount++;
intfrom = completelist.indexOf(re, intfrom + 1);
}
++itfile;
}
for(int i = 0; i < completelist.count(); i++)
{
if(complete_todelete.at(i) == false)
{
filename = completelist.at(i);
if(bListfiles)
cout << "File " << filename.toStdString() << " moved" << endl;
MoveToDirectory(filename, complete_startdate.at(i), dir);
}
else
{
filename = completelist.at(i);
if(bListfiles)
cout << "File " << filename.toStdString() << " deleted" << endl;
dir.remove(filename);
}
}
}
}
void MoveToDirectory(QString filename, int thestartdate, QDir dir)
{
QString fileyear;
QString filemonth;
QString fileday;
bool gelukt;
if(filename.mid(0, 6) == "OR_ABI")
{
int nyear = filename.mid( thestartdate, 4).toInt();
int ndayofyear = filename.mid( thestartdate + 4, 3).toInt();
QDate filedate = QDate(nyear, 1, 1).addDays(ndayofyear - 1);
fileyear = filedate.toString("yyyy");
filemonth = filedate.toString("MM");
fileday = filedate.toString("dd");
}
else
{
fileyear = filename.mid( thestartdate, 4);
filemonth = filename.mid( thestartdate + 4, 2);
fileday = filename.mid( thestartdate + 6, 2);
}
QDir dirdateyear(dir.absolutePath() + "/" + fileyear);
QDir dirdatemonth(dir.absolutePath() + "/" + fileyear + "/" + filemonth);
QDir dirdateday(dir.absolutePath() + "/" + fileyear + "/" + filemonth + "/" + fileday);
gelukt = false;
if (!dirdateyear.exists())
{
gelukt = dir.mkdir(dir.absolutePath() + "/" + fileyear);
}
if (!dirdatemonth.exists())
{
gelukt = dir.mkdir(dir.absolutePath() + "/" + fileyear + "/" + filemonth);
}
if (!dirdateday.exists())
{
gelukt = dir.mkdir(dir.absolutePath() + "/" + fileyear + "/" + filemonth + "/" + fileday);
}
if (!dirdateday.exists(filename))
{
gelukt = dir.rename(dir.absolutePath() + "/" + filename,
dir.absolutePath() + "/" + fileyear + "/" + filemonth + "/" + fileday + "/" + filename);
}
else
dir.remove(filename);
}
|
6568c6e8cbbc74ff296185d377b012d91bd68c04 | 03666e5f961946fc1a0ac67781ac1425562ef0d7 | /src/common/parser/VisItParser.h | eb38b4ecacae7599a6f6f96efe2b48aff1192629 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | visit-dav/visit | e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e | 601ae46e0bef2e18425b482a755d03490ade0493 | refs/heads/develop | 2023-09-06T08:19:38.397058 | 2023-09-05T21:29:32 | 2023-09-05T21:29:32 | 165,565,988 | 335 | 120 | BSD-3-Clause | 2023-09-14T00:53:37 | 2019-01-13T23:27:26 | C | UTF-8 | C++ | false | false | 3,894 | h | VisItParser.h | // Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers. See the top-level LICENSE file for dates and other
// details. No copyright assignment is required to contribute to VisIt.
#ifndef VISIT_PARSER_H
#define VISIT_PARSER_H
#include <parser_exports.h>
#include <vector>
#include <visitstream.h>
#include <VisItToken.h>
#include <ParseTreeNode.h>
#include <Symbol.h>
#include <State.h>
#include <VisItGrammar.h>
// ****************************************************************************
// Class: ParseElem
//
// Purpose:
// An element of a parse stack.
//
// Programmer: Jeremy Meredith
// Creation: April 5, 2002
//
// Modifications:
// Jeremy Meredith, Wed Nov 24 11:59:11 PST 2004
// Major refactoring. Added storage of Token here because it no longer
// derives directly from a parse tree node.
//
// Jeremy Meredith, Wed Jun 8 16:32:35 PDT 2005
// Changed token based constructor to take the symbol as passed in.
// This was to remove all static data and have the Parser look up
// the symbol in a dictionary.
//
// Jeremy Meredith, Mon Jun 13 15:59:20 PDT 2005
// Removed TokenParseTreeNode -- it had become superfluous and was keeping
// an extra pointer to Tokens around, preventing good memory management.
// Added pos here to prevent having to look in the node or token members.
//
// ****************************************************************************
struct PARSER_API ParseElem
{
const Symbol *sym;
ParseTreeNode *node;
Token *token;
Pos pos;
ParseElem(const Symbol *s, Token * t)
{
sym = s;
node = NULL;
token = t;
pos = t->GetPos();
}
ParseElem(const Symbol *s, ParseTreeNode *n)
{
sym = s;
node = n;
token = NULL;
pos = n->GetPos();
}
};
// ****************************************************************************
// Class: Parser
//
// Purpose:
// Abstract base for a parser.
//
// Programmer: Jeremy Meredith
// Creation: April 5, 2002
//
// Modifications:
// Jeremy Meredith, Wed Nov 24 11:59:55 PST 2004
// Removed the ParserInterface base class (it wasn't doing much good).
// Renamed this class Parser for consistency. Added list of tokens
// to the rule reduction method to make life easier for the implementor.
//
// Jeremy Meredith, Mon Nov 17 17:04:43 EST 2008
// Don't use the element stack to store the final parse tree; it's not
// really a parse element, because there's not really a lhs other than
// START, which doesn't make much sense. Instead, we just store it in
// a new data member, which is more direct and more clear.
//
// Tom Fogal, Wed Apr 29 15:36:42 MDT 2009
// Check for empty `elems' so we don't deref an empty vector.
//
// Kathleen Bonnell, Tue May 5 17:23:42 PDT 2009
// Revert GetParseTree changes back to Jeremy's fix from Nov 17, 2008.
//
// ****************************************************************************
class PARSER_API Parser
{
public:
Parser();
virtual ~Parser();
void Init();
void ParseOneToken(Token *);
bool Accept() { return accept; }
virtual ParseTreeNode *Parse(const std::string &) = 0;
ParseTreeNode *GetParseTree() { return parseTree; }
void SetGrammar(Grammar * g) { G = g; }
protected:
Grammar *G;
std::vector<int> states;
std::vector<ParseElem> elems;
bool accept;
ParseTreeNode *parseTree;
protected:
void Shift(Token *, int);
void Reduce(int);
virtual ParseTreeNode *ApplyRule(const Symbol &, const Rule *,
std::vector<ParseTreeNode*>&,
std::vector<Token*>&,
Pos) = 0;
void PrintState(ostream &);
};
#endif
|
f0e7a8f7cd7352924b9a6b98be973d19a1831669 | f5f5a0b8a4726f4f97abbf49c4a9abc44d900da9 | /Codeforces/hit-the-lottery.cpp | dd6a9580fa9d04d1b11bb34a2dff3e4e5955c302 | [] | no_license | tapixhx/CPP | c96b87019000057096c2d33f5a2366c496cb6ed3 | 7271870738c75ef92c3fdb7aa019e78fbe1b5bfc | refs/heads/main | 2023-08-22T09:44:28.956406 | 2021-09-15T17:37:24 | 2021-09-15T17:37:24 | 334,462,809 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,522 | cpp | hit-the-lottery.cpp | //#include <bits/stdc++.h>
//
//#define ll long long int
//#define vii vector<int>
//#define vll vector<ll>
//#define mii map<int, int>
//#define mll map<ll, ll>
//#define sii set<int>
//#define sll set<ll>
//#define umi unordered_map<int, int>
//#define uml unordered_map<ll, ll>
//#define usi unordered_set<int>
//#define usl unordered_set<ll>
//#define pii pair<int, int>
//#define pll pair<ll, ll>
//#define pb push_back
//#define pf push_front
//#define mk make_pair
//#define endl "\n"
//#define desc greater<int>()
//#define F first
//#define S second
//#define mod 1000000007
//#define pi 3.141592653589793238
//#define lcm(a,b) (a/(__gcd(a,b)))*b
//#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed;cout.precision(10);
//
//using namespace std;
//
//int main() {
// FASTIO
// int n, min, ans=0, q, num;
// int a[] = {1, 5, 10, 20, 100};
// cin >> n;
// while(n!=0) {
// min = INT_MAX;
// for(int i=4; i>=0; i--) {
// q=n/a[i];
// if(q!=0 && q<min) {
// min = q;
// num=a[i];
// }
// }
// if(min != INT_MAX)
// ans+=min;
// n%=num;
// }
// cout << ans;
// return 0;
//} |
81adbf142bead17af1d7fa0be0eda0779f17aec1 | 8a45330c15b091b3603955137e36567dddb674ab | /hr_edl/src/hr_edl/samplers.h | c6b7b06f37113d0f6db7c422dd48d065745d8174 | [
"MIT"
] | permissive | dmorrill10/hr_edl_experiments | a73704f353754293fd0e3dd9c1adab4713a003fe | 9bedae2ce0e8950e6e6c158d450bb8a47d103d5d | refs/heads/master | 2023-05-25T18:09:07.230426 | 2021-06-10T23:57:16 | 2021-06-10T23:57:16 | 289,053,795 | 3 | 2 | MIT | 2021-06-08T04:11:54 | 2020-08-20T16:21:17 | Jupyter Notebook | UTF-8 | C++ | false | false | 8,777 | h | samplers.h | #ifndef HR_EDL_SAMPLERS_H_
#define HR_EDL_SAMPLERS_H_
#include <functional>
#include <memory>
#include <random>
#include <vector>
#include "absl/strings/match.h"
#include "open_spiel/spiel.h"
#include "hr_edl/types.h"
namespace hr_edl {
int SampleActionIndex(const std::vector<double>& policy, double random_number,
double epsilon = 0);
int SampleActionIndex(const open_spiel::ActionsAndProbs& actions_and_probs,
double random_number);
void SampleAllChanceOutcomes(
const open_spiel::State& state,
const std::function<void(const ActionAndProb&, double)>& f);
void SampleOneChanceOutcome(
double random_number, const open_spiel::State& state,
const std::function<void(const ActionAndProb&, double)>& f);
void SampleAllTargetPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f);
void SampleOneTargetPlayerAction(
double random_number, const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f,
double epsilon = 0);
void SampleAllExternalPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f);
void SampleOneExternalPlayerAction(
double random_number, const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f);
class /* interface */ MccfrSampler {
public:
virtual ~MccfrSampler() = default;
virtual void SampleChanceOutcomes(
const open_spiel::State& state,
const std::function<void(const ActionAndProb&, double)>& f) = 0;
virtual void SampleChanceOutcomes(
const std::vector<double>& outcome_probs,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) = 0;
virtual void SampleTargetPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) = 0;
virtual void SampleExternalPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) = 0;
};
using MccfrSamplerPtr = std::unique_ptr<MccfrSampler>;
class NullSampler : public MccfrSampler {
public:
NullSampler() {}
void SampleChanceOutcomes(
const open_spiel::State& state,
const std::function<void(const ActionAndProb&, double)>& f)
override final {
SampleAllChanceOutcomes(state, f);
}
void SampleChanceOutcomes(
const std::vector<double>& outcome_probs,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleAllExternalPlayerActions(outcome_probs, f);
}
void SampleTargetPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleAllTargetPlayerActions(policy, f);
}
void SampleExternalPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleAllExternalPlayerActions(policy, f);
}
};
class ChanceSampler : public MccfrSampler {
public:
ChanceSampler(std::shared_ptr<std::mt19937_64> random_engine)
: random_engine_(std::move(random_engine)), uniform_dist_(0, 1) {}
void SampleChanceOutcomes(
const open_spiel::State& state,
const std::function<void(const ActionAndProb&, double)>& f)
override final {
SampleOneChanceOutcome(uniform_dist_(*random_engine_), state, f);
}
void SampleChanceOutcomes(
const std::vector<double>& outcome_probs,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleOneExternalPlayerAction(uniform_dist_(*random_engine_), outcome_probs,
f);
}
void SampleTargetPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleAllTargetPlayerActions(policy, f);
}
void SampleExternalPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleAllExternalPlayerActions(policy, f);
}
private:
std::shared_ptr<std::mt19937_64> random_engine_;
std::uniform_real_distribution<double> uniform_dist_;
};
class ExternalSampler : public MccfrSampler {
public:
ExternalSampler(std::shared_ptr<std::mt19937_64> random_engine)
: random_engine_(std::move(random_engine)), uniform_dist_(0, 1) {}
void SampleChanceOutcomes(
const open_spiel::State& state,
const std::function<void(const ActionAndProb&, double)>& f)
override final {
SampleOneChanceOutcome(uniform_dist_(*random_engine_), state, f);
}
void SampleChanceOutcomes(
const std::vector<double>& outcome_probs,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleOneExternalPlayerAction(uniform_dist_(*random_engine_), outcome_probs,
f);
}
void SampleTargetPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleAllTargetPlayerActions(policy, f);
}
void SampleExternalPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleOneExternalPlayerAction(uniform_dist_(*random_engine_), policy, f);
}
private:
std::shared_ptr<std::mt19937_64> random_engine_;
std::uniform_real_distribution<double> uniform_dist_;
};
class OutcomeSampler : public MccfrSampler {
public:
OutcomeSampler(std::shared_ptr<std::mt19937_64> random_engine,
double epsilon = 0)
: random_engine_(std::move(random_engine)),
epsilon_(epsilon),
uniform_dist_(0, 1) {}
void SampleChanceOutcomes(
const open_spiel::State& state,
const std::function<void(const ActionAndProb&, double)>& f)
override final {
SampleOneChanceOutcome(uniform_dist_(*random_engine_), state, f);
}
void SampleChanceOutcomes(
const std::vector<double>& outcome_probs,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleOneExternalPlayerAction(uniform_dist_(*random_engine_), outcome_probs,
f);
}
void SampleTargetPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleOneTargetPlayerAction(uniform_dist_(*random_engine_), policy, f,
epsilon_);
}
void SampleExternalPlayerActions(
const std::vector<double>& policy,
const std::function<void(int action_idx, double policy_prob,
double sampling_prob)>& f) override final {
SampleOneExternalPlayerAction(uniform_dist_(*random_engine_), policy, f);
}
private:
std::shared_ptr<std::mt19937_64> random_engine_;
double epsilon_;
std::uniform_real_distribution<double> uniform_dist_;
};
inline MccfrSamplerPtr NewSampler(const std::string& sampler, int random_seed) {
if (absl::StrContains("null", sampler)) {
return MccfrSamplerPtr(new NullSampler());
}
auto rng = std::make_shared<std::mt19937_64>(random_seed);
if (absl::StrContains("chance", sampler)) {
return MccfrSamplerPtr(new ChanceSampler(rng));
} else if (absl::StrContains("external", sampler)) {
return MccfrSamplerPtr(new ExternalSampler(rng));
} else if (absl::StrContains("outcome", sampler)) {
return MccfrSamplerPtr(new OutcomeSampler(rng, 0.6));
}
return nullptr;
}
} // namespace hr_edl
#endif // HR_EDL_SAMPLERS_H_
|
ea34255c98b6e8a34d7ef4b1f1fa81ab2722cffa | 78823bb7d0c6bc5ac982f124b2e0ca0deaad548c | /ccp4/safe_mtz.h | f228817635dfa1ac172a558b15f4c835b4569c9a | [
"MIT"
] | permissive | Oeffner/MtzExtInfoTip | c4513d39be35d5d66f49fa3f0c76cc2cf430b24b | a9940f61b1b646691da3c55c88aec9b6b6945538 | refs/heads/master | 2021-12-28T08:43:52.037707 | 2021-11-23T23:56:00 | 2021-11-23T23:56:00 | 97,144,076 | 2 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 334 | h | safe_mtz.h |
// Modified version of phaser\codebase\phaser\lib\safe_mtz.h
// for reading column data into array of floats
#include <string>
#include <vector>
#include "cmtzlib.h"
#include "mtzdata.h"
int MtzReadRefl(CMtz::MTZ *mtz, std::vector< std::vector<float> > &columns,
int logmss[], CMtz::MTZCOL *lookup[], int ncols, int nrefs);
|
b73d53a80ca4e5a378cc44b7346c035a400dba09 | 6f99f5e2a30d30648360196d391c18718f7e412c | /Config.cpp | 34556e1e8612491d0b38c78027e24574109669b2 | [] | no_license | zenwong/tagu | f077b3018e55901123a3207fd344242ec4349fc1 | 0b1f6c3bd94f636929f69b8a43438ec1ecc0f8c1 | refs/heads/master | 2021-01-17T11:01:14.445800 | 2016-07-15T07:44:01 | 2016-07-15T07:44:01 | 16,742,319 | 12 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 46 | cpp | Config.cpp | #include "Config.hpp"
Config::Config()
{
}
|
2f761ae8474b4da3cebb423ad9125ecd78ee7bf2 | ae9df4db0dc16065b53030e39d1325d0c81e0221 | /include/FalconEngine/Graphics/Renderer/State/WireframeState.h | feab1b4c664d88ead756f478d8098506f524ea32 | [
"MIT"
] | permissive | LiuYiZhou95/FalconEngine | c0895dba8c2a86a8dcdf156da1537d4f2e9724c3 | b798f20e9dbd01334a4e4cdbbd9a5bec74966418 | refs/heads/master | 2021-10-25T18:40:42.868445 | 2017-07-30T10:23:26 | 2017-07-30T10:23:26 | 285,249,037 | 0 | 1 | null | 2020-08-05T09:58:53 | 2020-08-05T09:58:52 | null | UTF-8 | C++ | false | false | 225 | h | WireframeState.h | #pragma once
#include <FalconEngine/Graphics/Common.h>
namespace FalconEngine
{
class FALCON_ENGINE_API WireframeState final
{
public:
WireframeState();
~WireframeState();
public:
bool mEnabled = false;
};
}
|
6bdab79caf350358573ba4c13d04db1cad53acbe | 4cd0cbfb4f5b54ad8530ce06e218edb4b9a151ba | /signed_zero_behavior.hpp | f6c953ab2abf6a402bc6bc5879b0dda09335afc6 | [] | no_license | ariana-bruno/ECE4960-PA1 | f97329f291eed8f639f002857dc3210785c2ce64 | 75d4ab893f7391aa926cef59075e9616226f2eaf | refs/heads/master | 2021-09-07T16:15:24.193487 | 2018-02-25T23:17:26 | 2018-02-25T23:17:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 522 | hpp | signed_zero_behavior.hpp | //
// signed_zero_behavior.hpp
// Program1
//
// Created by Ariana Bruno on 2/12/18.
// Copyright © 2018 Ariana Bruno. All rights reserved.
//
#ifndef signed_zero_behavior_hpp
#define signed_zero_behavior_hpp
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
void signed_zero_log( float signed_zero );
void signed_zero_sine_inverse( float signed_zero );
void signed_zero_sine_abs_inverse( float signed_zero );
#endif /* signed_zero_behavior_hpp */
|
103112979281f416c5a7236685eadfe0dd4718d0 | d056776b25c9e93e7ed97695419e14e5732301d1 | /project2D/Application2D.cpp | a6e01498507d64828bb903ad41e80e5197508615 | [
"MIT"
] | permissive | regireed89/aieBoostrap | d53f9066d178a7ec80da819d7ae2101f6e062e55 | 811f7147ae3f3aad4d90620c96d5b44e9afe679e | refs/heads/master | 2020-06-15T03:41:02.213612 | 2016-12-16T20:22:55 | 2016-12-16T20:22:55 | 75,333,723 | 0 | 0 | null | 2016-12-01T21:19:34 | 2016-12-01T21:19:34 | null | UTF-8 | C++ | false | false | 4,561 | cpp | Application2D.cpp | #include "Application2D.h"
#include "Texture.h"
#include "Font.h"
#include "Input.h"
using namespace std;
Application2D::Application2D() {
}
Application2D::~Application2D() {
}
bool Application2D::startup() {
Shiruken = Player(Vector2(600, 400), Vector2(1,0));
Regi = Agent(Vector2(600, 400), Vector2(1, 0));
m_2dRenderer = new aie::Renderer2D();
m_texture = new aie::Texture("./textures/numbered_grid.tga");
m_shipTexture = new aie::Texture("./textures/genji.png");
m_shuriken = new aie::Texture("./textures/ninja.png");
m_backGround = new aie::Texture("./textures/original.png");
m_font = new aie::Font("./font/consolas.ttf", 32);
m_cameraX = 0;
m_cameraY = 0;
m_timer = 0;
return true;
}
void Application2D::shutdown() {
delete m_font;
delete m_texture;
delete m_shipTexture;
delete m_2dRenderer;
delete m_backGround;
}
void Application2D::update(float deltaTime) {
m_timer += deltaTime;
// input example
aie::Input* input = aie::Input::getInstance();
// use arrow keys to move player
if (input->isKeyDown(aie::INPUT_KEY_UP))
{
Shiruken.position.y += 500.0f*deltaTime;
Regi.position.y += 500.0f*deltaTime;
}
if (input->isKeyDown(aie::INPUT_KEY_DOWN))
{
Shiruken.position.y -= 500.0f * deltaTime;
Regi.position.y -= 500.0f*deltaTime;
}
if (input->isKeyDown(aie::INPUT_KEY_LEFT))
{
Shiruken.position.x -= 500.0f * deltaTime;
Regi.position.x -= 500.0f*deltaTime;
}
if (input->isKeyDown(aie::INPUT_KEY_RIGHT))
{
Shiruken.position.x += 500.0f * deltaTime;
Regi.position.x += 500.0f*deltaTime;
}
// example of audio
if (input->wasKeyPressed(aie::INPUT_KEY_SPACE))
{
Shiruken.bullets[Shiruken.m_amao].position = Shiruken.position;
Shiruken.m_amao--;
Shiruken.bullets[Shiruken.m_amao].isFired = true;
Shiruken.position.x;
}
if (input->wasKeyPressed(aie::INPUT_KEY_F))
{
}
// exit the application
if (input->isKeyDown(aie::INPUT_KEY_ESCAPE))
quit();
}
void Application2D::draw() {
;
// wipe the screen to the background colour
clearScreen();
m_2dRenderer->setUVRect(0, 0, 1, 1);
m_2dRenderer->drawSprite(m_backGround, 630, 300, 0, 0, 0, 1);
// set the camera position before we begin rendering
m_2dRenderer->setCameraPos(m_cameraX, m_cameraY);
// begin drawing sprites
m_2dRenderer->begin();
// demonstrate animation
m_2dRenderer->setUVRect(int(m_timer) % 8 / 8.0f, 0, 1.f / 8, 1.f / 8);
m_2dRenderer->drawSprite(m_texture, 200, 200, 50, 50);
//draw shuriken
for (int i = 0; i < 100; i++)
{
if (Shiruken.bullets[i].isFired)
{
m_2dRenderer->setUVRect(0, 0, 1, 1);
m_2dRenderer->drawSprite(m_shuriken, Regi.position.x, Regi.position.y, 100, 100, 0);
Shiruken.Throw(Vector2(1, 0), 1);
}
}
// demonstrate spinning sprite
m_2dRenderer->setUVRect(0, 0, 1, 1);
m_2dRenderer->drawSprite(m_shipTexture,Regi.position.x, Regi.position.y, 0, 0, 0, 1);
// draw a thin line
//m_2dRenderer->drawLine(600, 400, position2.x, position2.y, 2, 1);
// draw a moving purple circle
m_2dRenderer->setRenderColour(1, 0, 1, 1);
//m_2dRenderer->drawCircle(sin(m_timer) * 100 + 600, 150, 50);
// draw a rotating red box
m_2dRenderer->setRenderColour(1, 0, 0, 1);
//m_2dRenderer->drawBox(600, 500, 60, 20, m_timer);
// draw a slightly rotated sprite with no texture, coloured yellow
m_2dRenderer->setRenderColour(1, 1, 0, 1);
//m_2dRenderer->drawSprite(nullptr, 400, 400, 50, 50, 3.14159f * 0.25f, 1);
// output some text, uses the last used colour
char fps[32];
sprintf_s(fps, 32, "FPS: %i", getFPS());
m_2dRenderer->drawText(m_font, fps, 0, 720 - 32);
m_2dRenderer->drawText(m_font, "Press Space to WHOOP SOME ASS!!!!!", 0, 720 - 64);
// done drawing sprites
m_2dRenderer->end();
}
#include <fstream>
void Application2D::playerState()
{
fstream *file = new fstream();
file->open("GameState.yaboy", ios_base::out);
if (file->is_open())
{
*file << "its yaboy" << endl;
}
file->close();
}
//void Application2D::getPlayer()
//{
// char data2;
// string data;
// fstream*file = new fstream("GameState.yaboy");
// file->close();
// if (file->is_open())
// {
// file >> data;
// file->get(data);
// }
// while (getline(file, data))
// {
// cout << data << endl;
// }
// file->close();
//}
bool Agent::AddForce(Vector2 force, float dt)
{
position = (position + velocity)*dt;
velocity = (velocity + force)*dt;
return false;
}
bool Player::Throw(Vector2 force, float dt)
{
position = (position + velocity)*dt;
velocity = (velocity + force)*dt;
return false;
}
|
b23a2d501ea6dd2e9538a634d490d5a033f76c38 | d09945668f19bb4bc17087c0cb8ccbab2b2dd688 | /srm/701-720/703/TreeDiameters.cpp | f4ab43cb82753ac477f88597f90a3d3fe0d8ea27 | [] | no_license | kmjp/procon | 27270f605f3ae5d80fbdb28708318a6557273a57 | 8083028ece4be1460150aa3f0e69bdb57e510b53 | refs/heads/master | 2023-09-04T11:01:09.452170 | 2023-09-03T15:25:21 | 2023-09-03T15:25:21 | 30,825,508 | 23 | 2 | null | 2023-08-18T14:02:07 | 2015-02-15T11:25:23 | C++ | UTF-8 | C++ | false | false | 3,230 | cpp | TreeDiameters.cpp | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
class TreeDiameters {
public:
int N;
vector<int> E[1010];
int ma,md;
int num[1010];
int sum[1010];
int count[1010];
void dfs(int cur,int pre,int d) {
md=max(md,d);
count[d]++;
FORR(r,E[cur]) if(r!=pre) dfs(r,cur,d+1);
}
int getMax(vector <int> p) {
int N=p.size()+1;
int i,j;
FOR(i,N) E[i].clear();
FOR(i,p.size()) E[i+1].push_back(p[i]),E[p[i]].push_back(i+1);
ma=0;
FOR(i,N) {
ZERO(num);
ZERO(sum);
FORR(r,E[i]) {
md=0;
dfs(r,i,1);
for(j=0;j<=md;j++) {
sum[j] += num[j]*count[j];
ma=max(ma,sum[j]);
num[j] += count[j];
count[j]=0;
}
}
}
FOR(i,N) FORR(r,E[i]) if(r>i) {
ZERO(num);
ZERO(sum);
md=0;
dfs(i,r,0);
for(j=0;j<=md;j++) num[j]=count[j], count[j]=0;
md=0;
dfs(r,i,0);
for(j=0;j<=md;j++) ma=max(ma,num[j]*count[j]),count[j]=0;
}
return ma;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arr0[] = {0,1,2,2}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 3; verify_case(0, Arg1, getMax(Arg0)); }
void test_case_1() { int Arr0[] = {0,0,0,0}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 6; verify_case(1, Arg1, getMax(Arg0)); }
void test_case_2() { int Arr0[] = {0,1,2,3,4,5,6,7}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 1; verify_case(2, Arg1, getMax(Arg0)); }
void test_case_3() { int Arr0[] = {0,0,0,2,3,4}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 3; verify_case(3, Arg1, getMax(Arg0)); }
void test_case_4() { int Arr0[] = {0}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 1; verify_case(4, Arg1, getMax(Arg0)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main(int argc,char** argv) {
TreeDiameters ___test;
___test.run_test((argc==1)?-1:atoi(argv[1]));
}
|
d627317f3ec410ad27e143f542c7b36a821a3d5a | a597d2732a92c6f69e931810ffe8e70841e16f35 | /include/btree_node_page.h | 14f963513d2a386f10a214975681dd67f4bb1fb6 | [] | no_license | skyitachi/yedis | d28a5c9494acfc5a47fc032046abf0604ebfbc2a | a644515739157f4afb43ac0ea6fc2b3891ffbff8 | refs/heads/master | 2023-05-12T09:38:35.821445 | 2023-05-02T03:41:10 | 2023-05-02T03:41:10 | 286,519,651 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,802 | h | btree_node_page.h | //
// Created by admin on 2020/9/17.
//
#ifndef YEDIS_INCLUDE_BTREE_NODE_PAGE_H_
#define YEDIS_INCLUDE_BTREE_NODE_PAGE_H_
#include <spdlog/spdlog.h>
#include <initializer_list>
#include <common/status.h>
#include "page.hpp"
#include "btree.hpp"
namespace yedis {
class BufferPoolManager;
class BTreeNodePage: public Page {
public:
// page_id
inline page_id_t GetPageID() {
return *reinterpret_cast<page_id_t*>(GetData());
}
// n_current_entry_
inline int GetCurrentEntries() { return *reinterpret_cast<int *>(GetData() + ENTRY_COUNT_OFFSET); }
inline void SetCurrentEntries(uint32_t n) { EncodeFixed32(GetData() + ENTRY_COUNT_OFFSET, n); }
// degree t
inline int GetDegree() { return *reinterpret_cast<int *>(GetData() + DEGREE_OFFSET); }
inline void SetDegree(uint32_t degree) { EncodeFixed32(GetData() + DEGREE_OFFSET, degree); }
// set available
inline uint32_t GetAvailable() {
auto av = *reinterpret_cast<uint32_t*>(GetData() + AVAILABLE_OFFSET);
assert(av <= options_.page_size);
return av;
}
inline void SetAvailable(uint32_t available) {
assert(available <= options_.page_size);
EncodeFixed32(GetData() + AVAILABLE_OFFSET, available);
}
// is leaf node
inline bool IsLeafNode() {
return *reinterpret_cast<byte *>(GetData() + FLAG_OFFSET) == 0;
}
inline void SetLeafNode(bool is_leaf = true) {
if (is_leaf) {
*(GetData() + FLAG_OFFSET) = 0;
} else {
*(GetData() + FLAG_OFFSET) = 1;
}
}
inline bool IsFull(size_t sz = 0) {
if (!IsLeafNode()) {
return GetCurrentEntries() >= GetDegree();
}
return GetAvailable() < sz;
}
// get parent id
inline page_id_t GetParentPageID() {
return *reinterpret_cast<page_id_t*>(GetData() + PARENT_OFFSET);
}
// set parent id
inline void SetParentPageID(page_id_t parent) {
SPDLOG_INFO("current page {} set to to parent {}", GetPageID(), parent);
EncodeFixed32(GetData() + PARENT_OFFSET, parent);
}
inline int64_t* KeyPosStart() {
return reinterpret_cast<int64_t *>(GetData() + KEY_POS_OFFSET);
}
// index node
inline int64_t GetKey(int idx) {
assert(idx < GetCurrentEntries());
return KeyPosStart()[idx];
}
inline page_id_t * ChildPosStart() {
return reinterpret_cast<page_id_t *>(GetData() + KEY_POS_OFFSET + (2 * GetDegree() - 1) * sizeof(int64_t));
}
inline page_id_t GetChild(int idx) {
// NOTE: len(children) = len(entries) + 1
assert(idx <= GetCurrentEntries());
return ChildPosStart()[idx];
}
// get and set prev page_id
inline page_id_t GetPrevPageID() {
return *reinterpret_cast<page_id_t*>(GetData() + PREV_NODE_PAGE_ID_OFFSET);
}
inline void SetPrevPageID(page_id_t page_id) {
EncodeFixed32(GetData() + PREV_NODE_PAGE_ID_OFFSET, page_id);
}
inline page_id_t GetNextPageID() {
return *reinterpret_cast<page_id_t*>(GetData() + NEXT_NODE_PAGE_ID_OFFSET);
}
inline void SetNextPageID(page_id_t page_id) {
SPDLOG_INFO("current page_id {}, next_page_id {}", GetPageID(), page_id);
assert(page_id != 0);
EncodeFixed32(GetData() + NEXT_NODE_PAGE_ID_OFFSET, page_id);
}
// entries pointer
inline byte* EntryPosStart() {
auto entryStart = reinterpret_cast<byte *>(GetData() + ENTRY_OFFSET);
return reinterpret_cast<byte*>(entryStart);
}
// only leaf node needs
inline size_t GetEntryTail() {
return options_.page_size - GetAvailable() - LEAF_HEADER_SIZE;
}
inline uint32_t MaxAvailable() {
return options_.page_size - LEAF_HEADER_SIZE;
}
inline int lower_bound_index(int64_t key) {
assert(!IsLeafNode());
auto key_start = KeyPosStart();
auto entries = GetCurrentEntries();
auto it = std::lower_bound(key_start, key_start + entries, key);
return it - key_start;
}
// interface
Status add(const byte *key, size_t k_len, const byte *value, size_t v_len, BTreeNodePage** root);
Status add(BufferPoolManager* buffer_pool_manager, int64_t key, const byte *value, size_t v_len, BTreeNodePage** root);
Status read(const byte *key, std::string *result);
// 必须是root结点出发
Status read(int64_t key, std::string* result);
Status read(BufferPoolManager*, int64_t, std::string *result);
// 带分裂的搜索
BTreeNodePage * search(BufferPoolManager* buffer_pool_manager, int64_t key, const byte* value, size_t v_len, BTreeNodePage** root);
// virtual void init(int degree, page_id_t page_id);
void init(int degree, page_id_t page_id);
void init(BTreeNodePage* dst, int degree, int n, page_id_t page_id, bool is_leaf);
// TODO: 这里的degree不能为0
// TODO: 静态方法
inline void leaf_init(BTreeNodePage* dst, int n, page_id_t page_id) {
return init(dst, 0, n, page_id, true);
}
// insert kv pair to leaf node
Status leaf_insert(int64_t key, const byte* value, int32_t v_len);
// leaf node search key
Status leaf_search(int64_t key, std::string *dst);
// check key exists
bool leaf_exists(int64_t key);
Status leaf_remove(BufferPoolManager* buffer_pool_manager, int64_t key, BTreeNodePage** root);
// index_page remove maybe recursive
Status index_remove(BufferPoolManager*, int key_idx, int child_idx, BTreeNodePage** root);
Status remove(BufferPoolManager* buffer_pool_manager, int64_t key, BTreeNodePage** root);
// leaf node find child_page_id
Status find_child_index(int child_page_id, int* result);
bool need_merge(int , int) const;
bool can_redistribute(int, int) const;
static Status redistribute(BTreeNodePage *left, BTreeNodePage* right, BTreeNodePage *parent, int key_idx);
static Status merge(BTreeNodePage*left, BTreeNodePage* right, BTreeNodePage* parent, int borrowed_key_idx);
static int get_redistribute_cnt(int, int);
// test utils
void debug_available(BufferPoolManager*);
void debug_page(BTreeNodePage* page);
bool keys_equals(std::initializer_list<page_id_t> results);
bool child_equals(std::initializer_list<page_id_t>);
class EntryIterator {
public:
EntryIterator(char *ptr): data_(ptr) {}
EntryIterator& operator = (const EntryIterator& iter) = default;
bool operator != (const EntryIterator& iter) const;
EntryIterator& operator ++();
EntryIterator& operator ++(int);
int64_t key() const;
int32_t size() const;
int32_t value_size() const;
Slice value() const;
bool ValueLessThan(const byte* value, int32_t v_len);
char *data_;
};
BTreeNodePage* NewLeafPage(BufferPoolManager*, int cnt, const EntryIterator& start, const EntryIterator& end);
BTreeNodePage* NewIndexPage(BufferPoolManager*, int cnt, int64_t key, page_id_t left, page_id_t right);
BTreeNodePage* NewIndexPage(BufferPoolManager*, const std::vector<int64_t>& keys, const std::vector<page_id_t>& children);
// 迁移start到末尾的key和child到新的index page上
BTreeNodePage* NewIndexPageFrom(BufferPoolManager*, BTreeNodePage* src, int start);
size_t available() {
return GetAvailable();
}
BTreeNodePage* index_split(BufferPoolManager*, BTreeNodePage* parent, int child_idx);
BTreeNodePage* leaf_split(BufferPoolManager*, int64_t new_key, uint32_t total_size, BTreeNodePage* parent, int child_key_idx, int *ret_child_pos, BTreeNodePage** result);
void index_node_add_child(int key_pos, int64_t key, int child_pos, page_id_t child, BTreeNodePage* parent = nullptr);
void index_node_add_child(int64_t key, page_id_t child);
};
}
#endif //YEDIS_INCLUDE_BTREE_NODE_PAGE_H_
|
3211333c720126c1ab3798c275bffdb246228405 | 8dfb00484889b3f601ff930afccdc723aff541d4 | /fish.h | 4889d00d025dcd0df644cb7870bfb2319831c5eb | [] | no_license | alenakulyakhtina/HW1-ABC | 5483635069a8f41f22c0a38c345f82e77d1a1cf4 | dd218cd24bf987f516de3748819b09e8551b07a0 | refs/heads/main | 2023-08-18T09:25:36.064259 | 2021-10-05T13:14:22 | 2021-10-05T13:14:22 | 413,823,580 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 935 | h | fish.h | #ifndef __fish__
#define __fish__
//------------------------------------------------------------------------------
// fish.h - содержит описание треугольника
//------------------------------------------------------------------------------
#include <fstream>
using namespace std;
#include "rnd.h"
// рыба
struct fish {
string name;// название
int weight;// вес
};
// Ввод параметров рыбы из файла
void In(fish& f, ifstream& ifst);
// Случайный ввод параметров рыбы
void InRnd(fish& f);
// Вывод параметров рыбы в форматируемый поток
void Out(fish& f, ofstream& ofst);
// Вычисление частного от деления суммы кодов незашифрованной строки на вес
double Division(fish& f);
#endif //__fish__
|
d8ba36ba882c3748e153447d4957c94be90c9c35 | cfd66fb49f5856f9c862038a628e160e6fa0a18d | /berlinunited/src/services.cpp | dc081dac279d3eb95e29b13498b78aebb83b018f | [] | no_license | sergiyvan/robotic_vl | c977fea8503ea2a10c319759ed1727301e6472bd | 1d3b66819e37a58e0ab752ea86aa2d8522643e1e | refs/heads/master | 2021-01-20T12:04:01.507082 | 2014-11-03T15:41:42 | 2014-11-03T15:41:42 | 25,864,171 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 161 | cpp | services.cpp | #ifdef BERLINUNITEDSTANDALONE
#include "services.h"
Services &services = Services::getInstance();
Services::Services() {
}
Services::~Services() {
}
#endif
|
99907669bf0b55cbadb1d5a8be98f79c94c48a79 | b621ba41c02e6da82d3aa7869c7740e52acdd740 | /Snake/Game.h | 5d071c8b719e4ab7a8cfd2f0891705acf4572972 | [] | no_license | ivansachkovski/Snake | 651144f95e550bffacad540483b5a332b61fa06d | b8e4383165982437c1df1cc9cfa756c3f8853bc4 | refs/heads/master | 2020-04-19T10:37:04.991291 | 2019-02-11T14:14:34 | 2019-02-11T14:14:34 | 168,145,361 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 374 | h | Game.h | #pragma once
class CSnakeGame :
public IGame
{
public:
static constexpr int m_exitCharacterCode = '.';
private:
std::atomic_bool m_bStop;
std::atomic_int m_inputCode;
std::unique_ptr<ISnake> m_pSnake;
std::unique_ptr<IField> m_pField;
std::thread m_inputThread;
public:
CSnakeGame(size_t, size_t);
void Run() override;
private:
void InputThreadHandler();
}; |
2d817caad76ae595fcaa7115bbb53cc477bdc719 | ab2eef9283ea9ffaac2152cde390a11ec2a6f636 | /习题/第三章/repeating_decimals.cpp | 24481cc54baf435e7e9ade96257262e8afbe4e97 | [
"MIT"
] | permissive | iuming/Classic_Algorithm | 6b0b8350a05454b74906f0ec7d32affdee8733c4 | bc0bba50e75cdfc80deba2f69fbeb438c935e912 | refs/heads/master | 2022-11-12T17:54:16.029169 | 2020-07-05T09:50:54 | 2020-07-05T09:50:54 | 275,477,874 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,040 | cpp | repeating_decimals.cpp | #include <iostream>
#include <cstring>
#define ll long long
using namespace std;
int n, m;
int r[3003], u[3003], s[3003];
int main()
{
while (cin >> n >> m)
{
int t = n;
memset(r, 0, sizeof(r));
memset(u, 0, sizeof(u));
int count = 0;
r[count++] = n / m;
n = n % m;
while (!u[n] && n)
{
u[n] = count;
s[count] = n;
r[count++] = 10 * n / m;
n = 10 * n % m;
}
cout << t << '/' << m << '=' << r[0] << '.';
for (int i = 1; i < count && i <= 50; i++)
{
if (n && s[i] == n)
cout << '(';
cout << r[i];
}
if (!n)
cout << "(0";
if (count > 50)
cout << "...";
cout << ")";
int num = !n ? 1 : count - u[n];
cout << " " << num << " = number of digits in repeating cycle" << endl
<< endl;
}
return 0;
} |
7ae4d874a33cdd669893028a7dad074cfb5bc1e3 | 0d3960bf9f417945ba897fb3230a25fb2af325a9 | /数据结构/课本习题答案/Programs Folder/GRTSBL.CPP | 83ff9d6100b07544263c5511408b39bb356834e1 | [] | no_license | JsthcitPizifly/SCU_Review- | 0ca32ec1c2738dd66c5cbc4e077b381f8dda398d | a5a420d135ddbc41d00fff0c883d8b47ccabb374 | refs/heads/master | 2020-06-11T15:32:25.927491 | 2019-10-12T02:35:54 | 2019-10-12T02:35:54 | 194,011,518 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,437 | cpp | GRTSBL.CPP | #include <iostream.h>
#include <stdlib.h>
#include "book.h"
#include "grlist.h"
#include "aqueue.h"
void printout(int v) {
cout << v << " ";
}
// Topological sort: Queue
void topsort(Graph* G, Queue<int>* Q) {
int Count[G->n()];
int v, w;
for (v=0; v<G->n(); v++) Count[v] = 0; // Initialize
for (v=0; v<G->n(); v++) // Process every edge
for (w=G->first(v); w<G->n(); w = G->next(v,w))
Count[w]++; // Add to v2's prereq count
for (v=0; v<G->n(); v++) // Initialize Queue
if (Count[v] == 0) // Vertex has no prerequisites
Q->enqueue(v);
while (Q->length() != 0) { // Process the vertices
Q->dequeue(v);
printout(v); // PreVisit for Vertex V
for (w=G->first(v); w<G->n(); w = G->next(v,w)) {
Count[w]--; // One less prerequisite
if (Count[w] == 0) // This vertex is now free
Q->enqueue(w);
}
}
}
// Test Depth First Search:
// Version for Adjancency Matrix representation
main(int argc, char** argv) {
Graph* G;
FILE *fid;
if (argc != 2) {
cout << "Usage: grdfsm <file>\n";
exit(-1);
}
if ((fid = fopen(argv[1], "rt")) == NULL) {
cout << "Unable to open file |" << argv[1] << "|\n";
exit(-1);
}
G = createGraph<Graphl>(fid);
if (G == NULL) {
cout << "Unable to create graph\n";
exit(-1);
}
Queue<int>* Q = new AQueue<int>(G->n());
topsort(G, Q);
cout << endl;
return 0;
}
|
097afdcc794139c131f8cf56cf5aafe7a3fa51d8 | d951266432e2b15b5a9e9b0f156a82c0aaf37af8 | /src/models/projectitem_model.cpp | 059f8fe5e65583b366987914cfa1c9ad48d85c68 | [] | no_license | winzlebee/mtrack | e09704481099221935ceec05540d3b2a15123393 | e3be57d874f23c5535674e4f2718cb3c661adfaf | refs/heads/master | 2021-06-14T13:05:33.601363 | 2021-03-23T11:57:18 | 2021-03-23T11:57:18 | 174,473,203 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 133 | cpp | projectitem_model.cpp | #include "projectitem_model.h"
ProjectItemModel::ProjectItemModel() {
add(m_col_id);
add(m_col_name);
add(m_col_icon);
} |
7bef6aa0fa7d24d800908790df6b41b2e84f1e84 | d96ebf4dac46404a46253afba5ba5fc985d5f6fc | /toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_object.h | eb735dc444916bd565fdca3d6573fda676aca7d1 | [
"LicenseRef-scancode-unicode-mappings",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | marco-c/gecko-dev-wordified-and-comments-removed | f9de100d716661bd67a3e7e3d4578df48c87733d | 74cb3d31740be3ea5aba5cb7b3f91244977ea350 | refs/heads/master | 2023-08-04T23:19:13.836981 | 2023-08-01T00:33:54 | 2023-08-01T00:33:54 | 211,297,165 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 256 | h | dump_object.h | #
ifndef
GOOGLE_BREAKPAD_PROCESSOR_DUMP_OBJECT_H__
#
define
GOOGLE_BREAKPAD_PROCESSOR_DUMP_OBJECT_H__
namespace
google_breakpad
{
class
DumpObject
{
public
:
DumpObject
(
)
;
bool
valid
(
)
const
{
return
valid_
;
}
protected
:
bool
valid_
;
}
;
}
#
endif
|
a8136b859c6ad6e824d05d3c820f892b91a0f441 | 2fd1f2a568ac21e636be169aa44fdf642b33bb17 | /ospray/common/Managed.cpp | 63a84673a903b863845fb84f09dcf8891cdaa930 | [
"Apache-2.0"
] | permissive | BlueBrain/OSPRay | c95720947135bf974252198e5f047f02cc07fc2d | 561eadfe21334ef1d33161947ead416a09040266 | refs/heads/master | 2023-06-25T08:57:45.906096 | 2017-10-20T12:45:50 | 2017-10-23T13:49:39 | 45,674,921 | 1 | 2 | Apache-2.0 | 2018-09-28T15:32:41 | 2015-11-06T10:15:04 | C++ | UTF-8 | C++ | false | false | 6,874 | cpp | Managed.cpp | // ======================================================================== //
// Copyright 2009-2017 Intel 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 "Managed.h"
#include "OSPCommon_ispc.h"
namespace ospray {
/*! \brief destructor */
ManagedObject::~ManagedObject()
{
// it is OK to potentially delete nullptr, nothing bad happens ==> no need to check
ispc::delete_uniform(ispcEquivalent);
ispcEquivalent = nullptr;
}
/*! \brief commit the object's outstanding changes (i.e. changed parameters etc) */
void ManagedObject::commit()
{
}
//! \brief common function to help printf-debugging
/*! \detailed Every derived class should overrride this! */
std::string ManagedObject::toString() const
{
return "ospray::ManagedObject";
}
//! \brief register a new listener for given object
/*! \detailed this object will now get update notifications from us */
void ManagedObject::registerListener(ManagedObject *newListener)
{
objectsListeningForChanges.insert(newListener);
}
//! \brief un-register a listener
/*! \detailed this object will no longer get update notifications from us */
void ManagedObject::unregisterListener(ManagedObject *noLongerListening)
{
objectsListeningForChanges.erase(noLongerListening);
}
/*! \brief gets called whenever any of this node's dependencies got changed */
void ManagedObject::dependencyGotChanged(ManagedObject *object)
{
UNUSED(object);
}
void ManagedObject::Param::set(ManagedObject *object)
{
Assert2(this,"trying to set null parameter");
clear();
if (object) object->refInc();
ptr = object;
type = OSP_OBJECT;
}
void ManagedObject::Param::set(const char *str)
{
Assert2(this,"trying to set null parameter");
clear();
s = new std::string;
*s = strdup(str);
type = OSP_STRING;
}
void ManagedObject::Param::set(void *ptr)
{
Assert2(this,"trying to set null parameter");
clear();
(void*&)this->ptr = ptr;
type = OSP_VOID_PTR;
}
void ManagedObject::Param::clear()
{
Assert2(this,"trying to clear null parameter");
if (type == OSP_OBJECT && ptr)
ptr->refDec();
if (type == OSP_STRING && s)
delete s;
type = OSP_OBJECT;
ptr = nullptr;
}
ManagedObject::Param::Param(const char *_name)
: ptr(nullptr), type(OSP_FLOAT), name(strdup(_name))
{
Assert(_name);
}
void *ManagedObject::getVoidPtr(const char *name, void *valIfNotFound)
{
Param *param = findParam(name);
if (!param) return valIfNotFound;
if (param->type != OSP_VOID_PTR) return valIfNotFound;
return (void*)param->ptr;
}
ManagedObject::Param *ManagedObject::findParam(const char *name,
bool addIfNotExist)
{
auto foundParam =
std::find_if(paramList.begin(), paramList.end(),
[&](const std::shared_ptr<Param> &p) {
return p->name == name;
});
if (foundParam != paramList.end())
return foundParam->get();
else if (addIfNotExist) {
paramList.push_back(std::make_shared<Param>(name));
return paramList[paramList.size()-1].get();
}
else
return nullptr;
}
#define define_getparam(T,ABB,TARGETTYPE,FIELD) \
T ManagedObject::getParam##ABB(const char *name, T valIfNotFound) \
{ \
Param *param = findParam(name); \
if (!param) return valIfNotFound; \
if (param->type != TARGETTYPE) return valIfNotFound; \
return (T&)param->FIELD; \
}
define_getparam(ManagedObject *, Object, OSP_OBJECT, ptr)
define_getparam(int32, 1i, OSP_INT, u_int)
define_getparam(vec3i, 3i, OSP_INT3, u_vec3i)
define_getparam(vec3f, 3f, OSP_FLOAT3, u_vec3f)
define_getparam(vec3fa, 3f, OSP_FLOAT3A, u_vec3fa)
define_getparam(vec4f, 4f, OSP_FLOAT4, u_vec4f)
define_getparam(vec2f, 2f, OSP_FLOAT2, u_vec2f)
define_getparam(float, 1f, OSP_FLOAT, u_float)
define_getparam(float, f, OSP_FLOAT, u_float)
#undef define_getparam
const char *ManagedObject::getParamString(const char *name,
const char *valIfNotFound)
{
Param *param = findParam(name);
if (!param) return valIfNotFound;
if (param->type != OSP_STRING) return valIfNotFound;
return param->s->c_str();
}
void ManagedObject::removeParam(const char *name)
{
auto foundParam =
std::find_if(paramList.begin(), paramList.end(),
[&](const std::shared_ptr<Param> &p) {
return p->name == name;
});
if (foundParam != paramList.end()) {
paramList.erase(foundParam);
}
}
void ManagedObject::notifyListenersThatObjectGotChanged()
{
for (auto *object : objectsListeningForChanges)
object->dependencyGotChanged(this);
}
void ManagedObject::emitMessage(const std::string &kind,
const std::string &message) const
{
postStatusMsg() << " " << toString()
<< " " << kind << ": " << message + '.';
}
void ManagedObject::exitOnCondition(bool condition,
const std::string &message) const
{
if (!condition)
return;
emitMessage("ERROR", message);
exit(1);
}
void ManagedObject::warnOnCondition(bool condition,
const std::string &message) const
{
if (!condition)
return;
emitMessage("WARNING", message);
}
} // ::ospray
|
24153c280c0b1043ade23cedc089e9b7ed648eb1 | c3bbdbbbc5f47577e332a280f81bd905617423c9 | /Source/AllProjects/WndUtils/CIDCtrls/CIDCtrls_ScrollArea.cpp | d10e33aefbdc1b06c479c4bec6b4097aa2f62590 | [
"MIT"
] | permissive | DeanRoddey/CIDLib | 65850f56cb60b16a63bbe7d6d67e4fddd3ecce57 | 82014e064eef51cad998bf2c694ed9c1c8cceac6 | refs/heads/develop | 2023-03-11T03:08:59.207530 | 2021-11-06T16:40:44 | 2021-11-06T16:40:44 | 174,652,391 | 227 | 33 | MIT | 2020-09-16T11:33:26 | 2019-03-09T05:26:26 | C++ | UTF-8 | C++ | false | false | 16,350 | cpp | CIDCtrls_ScrollArea.cpp | //
// FILE NAME: CIDCtrls_ScrollArea.cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 05/11/2015
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2019
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// This file implements the scrollable area control.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// $_CIDLib_Log_$
//
// ---------------------------------------------------------------------------
// Facility specific includes
// ---------------------------------------------------------------------------
#include "CIDCtrls_.hpp"
// ---------------------------------------------------------------------------
// Do our RTTI macros
// ---------------------------------------------------------------------------
AdvRTTIDecls(TScrollArea, TStdCtrlWnd)
// ---------------------------------------------------------------------------
// Local types and constants
// ---------------------------------------------------------------------------
namespace
{
namespace CIDCtrls_ScrollArea
{
constexpr tCIDLib::TInt4 i4LnSz = 16;
}
}
// ---------------------------------------------------------------------------
// CLASS: TScrollArea
// PREFIX: wnd
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// TScrollArea: Constructors and Destructor
// ---------------------------------------------------------------------------
TScrollArea::TScrollArea() :
TStdCtrlWnd()
, m_c4Margin(0)
, m_eScrAStyles(tCIDCtrls::EScrAStyles::None)
, m_pwndChild(0)
{
}
TScrollArea::~TScrollArea()
{
}
// ---------------------------------------------------------------------------
// TScrollArea: Public, inherited methods
// ---------------------------------------------------------------------------
// If we have a child, pass on the accel table handler in case he has one
tCIDLib::TBoolean TScrollArea::bProcessAccel(const tCIDLib::TVoid* const pMsgData) const
{
if (m_pwndChild && m_pwndChild->bProcessAccel(pMsgData))
return kCIDLib::True;
return kCIDLib::False;
}
tCIDLib::TVoid
TScrollArea::InitFromDesc( const TWindow& wndParent
, const TDlgItem& dlgiSrc
, const tCIDCtrls::EWndThemes eTheme)
{
tCIDCtrls::EScrAStyles eScrAStyles = tCIDCtrls::EScrAStyles::None;
tCIDCtrls::EWndStyles eStyles = tCIDCtrls::EWndStyles
(
tCIDCtrls::EWndStyles::VisTabChild
);
tCIDCtrls::EExWndStyles eExStyles = tCIDCtrls::EExWndStyles::None;
if (eTheme == tCIDCtrls::EWndThemes::MainWnd)
{
// Set a border unless asked not to
if (!dlgiSrc.bHasHint(kCIDCtrls::strHint_NoBorder))
eStyles |= tCIDCtrls::EWndStyles::Border;
}
else if (eTheme == tCIDCtrls::EWndThemes::DialogBox)
{
// Set a border unless asked not to
if (!dlgiSrc.bHasHint(kCIDCtrls::strHint_NoBorder))
{
eExStyles |= tCIDCtrls::EExWndStyles::StaticEdge;
SetBgnColor(facCIDCtrls().rgbSysClr(tCIDCtrls::ESysColors::DlgCtrlFill), kCIDLib::True);
}
}
Create
(
wndParent
, dlgiSrc.ridChild()
, dlgiSrc.areaPos()
, eStyles
, eScrAStyles
, eExStyles
);
}
tCIDLib::TVoid TScrollArea::QueryHints(tCIDLib::TStrCollect& colToFill) const
{
TParent::QueryHints(colToFill);
}
// ---------------------------------------------------------------------------
// TScrollArea: Public, non-virtual methods
// ---------------------------------------------------------------------------
//
// Get the current size of the child window being managed. If none, we throw. It
// really returns the size, since it's at zero origin relative to us.
//
TArea TScrollArea::areaGetChildSize() const
{
CheckHaveChild(CID_LINE);
return m_pwndChild->areaWndSize();
}
tCIDLib::TBoolean TScrollArea::bAtBottom(const tCIDLib::TBoolean bHorz) const
{
return (c4CurScrollPos(bHorz) == c4MaxScrollPos(bHorz));
}
tCIDLib::TBoolean TScrollArea::bAtTop(const tCIDLib::TBoolean bHorz) const
{
return (c4CurScrollPos(bHorz) == 0);
}
// Get or set a margin that will be used to indent the child window inwards.
tCIDLib::TCard4 TScrollArea::c4Margin() const
{
return m_c4Margin;
}
tCIDLib::TCard4 TScrollArea::c4Margin(const tCIDLib::TCard4 c4ToSet)
{
m_c4Margin = c4ToSet;
return m_c4Margin;
}
// Just set up the styles and call our parent to create the control
tCIDLib::TVoid
TScrollArea::Create(const TWindow& wndParent
, const tCIDCtrls::TWndId widThis
, const TArea& areaInit
, const tCIDCtrls::EWndStyles eStyles
, const tCIDCtrls::EScrAStyles eScrAStyles
, const tCIDCtrls::EExWndStyles eExStyles)
{
// If we haven't registered our window class, then do that
static const tCIDLib::TCh* pszClass = L"CIDScrollArea";
static TAtomicFlag atomInitDone;
if (!atomInitDone)
{
// Lock while we do this
TBaseLock lockInit;
if (!atomInitDone)
{
const TRGBClr rgbBgn = facCIDCtrls().rgbSysClr(tCIDCtrls::ESysColors::Window);
RegWndClass
(
pszClass
, kCIDLib::False
, kCIDLib::False
, 0
, rgbBgn
, kCIDLib::False
);
atomInitDone.Set();
}
}
// Store away our class specific styles
m_eScrAStyles = eScrAStyles;
// Force on the H/V scroll bars, since it makes no sense otherwise
CreateWnd
(
wndParent.hwndSafe()
, pszClass
, kCIDLib::pszEmptyZStr
, areaInit
, eStyles | tCIDCtrls::EWndStyles(WS_HSCROLL | WS_VSCROLL | WS_CLIPCHILDREN)
, eExStyles | tCIDCtrls::EExWndStyles::ControlParent
, widThis
);
}
// Move us to the end of the scrollable area
tCIDLib::TVoid TScrollArea::GoToEnd(const tCIDLib::TBoolean bHorz)
{
SetScrollPos(bHorz, c4MaxScrollPos(bHorz));
}
// Move us to the start of the scrollable area
tCIDLib::TVoid TScrollArea::GoToStart(const tCIDLib::TBoolean bHorz)
{
SetScrollPos(bHorz, 0);
}
//
// Set a new child window. Any existing child is destroyed.
//
tCIDLib::TVoid TScrollArea::SetChild(TWindow* const pwndToAdopt)
{
// If we hvae a current child, delete it
if (m_pwndChild)
CleanupChild();
// And let's take the new one
pwndToAdopt->SetParent(*this);
m_pwndChild = pwndToAdopt;
// Set the child window's position bsaed on our margin
TPoint pntOrg(m_c4Margin, m_c4Margin);
pwndToAdopt->SetPos(pntOrg);
// Do an initial adjustment of the scroll bars for this new child
AdjustBars();
}
//
// We update our contained window's size, which causes us to get a size change
// notification and we'll adjust the scroll bars.
//
tCIDLib::TVoid TScrollArea::SetChildSize(const TSize& szToSet)
{
if (!m_pwndChild)
return;
m_pwndChild->SetSize(szToSet, kCIDLib::True);
}
// ---------------------------------------------------------------------------
// TScrollArea: Protected, inherited methods
// ---------------------------------------------------------------------------
//
// If we are in restored state and the size has changed, we update our scroll bars
// to reflect the new size relationship.
//
tCIDLib::TVoid
TScrollArea::AreaChanged(const TArea& areaPrev
, const TArea& areaNew
, const tCIDCtrls::EPosStates ePosState
, const tCIDLib::TBoolean bOrgChanged
, const tCIDLib::TBoolean bSizeChanged
, const tCIDLib::TBoolean bStateChanged)
{
TParent::AreaChanged(areaPrev, areaNew, ePosState, bOrgChanged, bSizeChanged, bStateChanged);
if ((ePosState != tCIDCtrls::EPosStates::Minimized) && bSizeChanged)
AdjustBars();
}
// Do it all in the paint, where we are clipped to our children
tCIDLib::TBoolean TScrollArea::bEraseBgn(TGraphDrawDev&)
{
return kCIDLib::True;
}
tCIDLib::TBoolean TScrollArea::bMouseWheel(const tCIDLib::TInt4 i4Clicks)
{
// We send two next/previous scroll events to ourself for each click
tCIDCtrls::EScrollEvs eEvent = tCIDCtrls::EScrollEvs::None;
tCIDLib::TCard4 c4Count;
if (i4Clicks > 0)
{
c4Count = tCIDLib::TCard4(i4Clicks);
eEvent = tCIDCtrls::EScrollEvs::PrevLn;
}
else
{
c4Count = tCIDLib::TCard4(i4Clicks * -1);
eEvent = tCIDCtrls::EScrollEvs::NextLn;
}
if (c4Count)
{
for (tCIDLib::TCard4 c4Index = 0; c4Index < c4Count; c4Index++)
{
ScrollEvent(eEvent, kCIDLib::False);
ScrollEvent(eEvent, kCIDLib::False);
}
}
return kCIDLib::True;
}
tCIDLib::TBoolean TScrollArea::bPaint(TGraphDrawDev& gdevToUse, const TArea& areaUpdate)
{
gdevToUse.Fill(areaUpdate, rgbBgnFill());
return kCIDLib::True;
}
// A child changed size, so update our scroll bars
tCIDLib::TVoid
TScrollArea::ChildAreaChanged( const tCIDCtrls::TWndId widChild
, const TArea& areaNew)
{
AdjustBars();
}
// Clean up any child we were assigned, then pass it on to our parent
tCIDLib::TVoid TScrollArea::Destroyed()
{
// Destroy any child window
CleanupChild();
TParent::Destroyed();
}
//
// Handle scroll events and move our client window appropriately, updating the
// scroll bar to match our calculated position. AreaChanged above keeps the
// bars updated, so if we get called here, it's because some amount of movement
// is legal.
//
tCIDLib::TVoid
TScrollArea::ScrollDrag(const tCIDLib::TBoolean bHorz
, const tCIDLib::TCard4 c4Position
, const tCIDLib::TBoolean bFinal)
{
if (m_pwndChild)
{
// Update the scroll bar
SetSBarPos(bHorz, c4Position);
//
// We set our controlled window's position to be the negation of the passed
// position. The scroll bar positions are in terms of i4LnSz units, so
// multiply it to get the actual value.
//
TPoint pntNew;
tCIDLib::TInt4 i4NewPos(c4Position);
i4NewPos *= CIDCtrls_ScrollArea::i4LnSz;
if (bHorz)
pntNew.i4X(i4NewPos * -1);
else
pntNew.i4Y(i4NewPos * -1);
// Add any margin to the calculated position
pntNew.Adjust(m_c4Margin, m_c4Margin);
m_pwndChild->SetPos(pntNew);
}
}
tCIDLib::TVoid
TScrollArea::ScrollEvent(const tCIDCtrls::EScrollEvs eEvent
, const tCIDLib::TBoolean bHorz)
{
if (!m_pwndChild)
return;
// We need to get the current info
SCROLLINFO Info = {0};
Info.cbSize = sizeof(SCROLLINFO);
Info.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
if (!GetScrollInfo(hwndSafe(), bHorz ? SB_HORZ : SB_VERT, &Info))
{
facCIDCtrls().ThrowKrnlErr
(
CID_FILE
, CID_LINE
, kCtrlsErrs::errcSBar_GetScrollPos
, TKrnlError::kerrLast()
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::CantDo
);
}
// Decide the new position based on the event
tCIDLib::TInt4 i4NewPos = Info.nPos;
switch(eEvent)
{
case tCIDCtrls::EScrollEvs::End :
i4NewPos = Info.nMax - Info.nPage + 1;
break;
case tCIDCtrls::EScrollEvs::Home :
i4NewPos = 0;
break;
case tCIDCtrls::EScrollEvs::NextLn :
i4NewPos++;
break;
case tCIDCtrls::EScrollEvs::NextPg :
i4NewPos += Info.nPage;
break;
case tCIDCtrls::EScrollEvs::PrevLn :
i4NewPos--;
break;
case tCIDCtrls::EScrollEvs::PrevPg :
i4NewPos -= Info.nPage;
break;
default :
return;
};
// Clip the value back to valid range
if (i4NewPos < 0)
i4NewPos = 0;
else if (i4NewPos > (Info.nMax - int(Info.nPage) + 1))
i4NewPos = (Info.nMax - Info.nPage + 1);
// Update the scroll bar
SetSBarPos(bHorz, i4NewPos);
//
// We set our controlled window's position to be the negation of the passed
// position. The scroll bars are in terms of i4LnSz units, so multiply it by
// that.
//
i4NewPos *= CIDCtrls_ScrollArea::i4LnSz;
TPoint pntNew;
if (bHorz)
pntNew.i4X(i4NewPos * -1);
else
pntNew.i4Y(i4NewPos * -1);
// Add any margin to it
pntNew.Adjust(m_c4Margin, m_c4Margin);
m_pwndChild->SetPos(pntNew);
}
// ---------------------------------------------------------------------------
// TScrollArea: Private, non-virtual methods
// ---------------------------------------------------------------------------
//
// This is called any time a new client is set, or the client size is changed. We
// get the horz/vert size of the client relative to ours and set the scroll bars
// to reflect that.
//
tCIDLib::TVoid TScrollArea::AdjustBars()
{
if (!m_pwndChild)
return;
//
// Get the two relative areas. Make the client area larger by any margin that
// we have, so that at the end we can take it's original size and place it
// within the scroll area centered.
//
TArea areaClient = m_pwndChild->areaWndSize();
areaClient.Inflate(m_c4Margin, m_c4Margin);
TArea areaUs = areaWndSize();
// We'll get info on both scroll bars
SCROLLINFO Info = {0};
Info.cbSize = sizeof(SCROLLINFO);
// Do the horizontal one
Info.fMask = SIF_PAGE | SIF_RANGE;
Info.nMin = 0;
Info.nPage = areaUs.c4Width() / CIDCtrls_ScrollArea::i4LnSz;
Info.nMax = (areaClient.c4Width() / CIDCtrls_ScrollArea::i4LnSz) + 1;
::SetScrollInfo(hwndSafe(), SB_HORZ, &Info, TRUE);
// Do the vertical one
Info.fMask = SIF_PAGE | SIF_RANGE;
Info.nMin = 0;
Info.nPage = areaUs.c4Height() / CIDCtrls_ScrollArea::i4LnSz;
Info.nMax = (areaClient.c4Height() / CIDCtrls_ScrollArea::i4LnSz) + 1;
::SetScrollInfo(hwndSafe(), SB_VERT, &Info, TRUE);
//
// If we got bigger, then this could have affected our position as well, so
// deal with that. We have to turn around and get the new positions.
//
int iXPos = 0;
int iYPos = 0;
Info.fMask = SIF_POS;
if (GetScrollInfo(hwndSafe(), SB_HORZ, &Info))
iXPos = Info.nPos;
if (GetScrollInfo(hwndSafe(), SB_VERT, &Info))
iYPos = Info.nPos;
TPoint pntNew
(
(iXPos * CIDCtrls_ScrollArea::i4LnSz) * -1
, (iYPos * CIDCtrls_ScrollArea::i4LnSz) * -1
);
// Add in any argin
pntNew.Adjust(m_c4Margin, m_c4Margin);
m_pwndChild->SetPos(pntNew);
}
// Called to check if we have a child and throw if not
tCIDLib::TVoid TScrollArea::CheckHaveChild(const tCIDLib::TCard4 c4Line) const
{
if (!m_pwndChild)
{
facCIDCtrls().ThrowErr
(
CID_FILE
, CID_LINE
, kCtrlsErrs::errcScrA_NoChild
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::NotReady
, TCardinal(widThis())
);
}
}
tCIDLib::TVoid TScrollArea::CleanupChild()
{
// If we have a child window, then destroy it
if (m_pwndChild)
{
try
{
m_pwndChild->Destroy();
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
}
// And clean up the actual object
try
{
delete m_pwndChild;
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
}
}
m_pwndChild = 0;
}
|
7a9c69fc25556172232a2afed4b91212eabb50b5 | 3eeca45d89f633406a9d032ad252c16bfdaaa0ef | /ngram.cpp | fdc593215392e7efd2a37c2ffce5ea5e2a4c1e11 | [] | no_license | twahlfeld/tgram | 6a53fbde8e05358f5dd142ddf59a1e07d298e338 | 2dc54373c6eb37848dca95bbaebe7d075af7a40f | refs/heads/master | 2016-09-12T02:58:01.641159 | 2016-04-15T14:48:19 | 2016-04-15T14:48:19 | 55,182,693 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,693 | cpp | ngram.cpp | /*******************************************************************************
* *
* Filename: ngram.cpp *
* *
* Description: N-Gram analyzer for arbitrary files *
* *
* Version: 1.0 *
* Created: 02/19/2016 03:30:40 PM *
* Revision: none *
* Author: Theodore Ahlfeld (twa2108) *
* Compiler: gcc *
* *
* Organization: *
* *
******************************************************************************/
#include <iostream>
#include <unordered_map>
#include <vector>
static const int BUFSIZE = 4096;
void die_with_err(const char *s)
{
perror(s);
exit(1);
}
void print_help(const char *s)
{
printf("Usage:\n\t"
"%s ngram_size sliding_window_size input_file output_file\n"
"\tExample:\n\t"
"%s 3 2 inputfile.ext outputfile.ext\n", s, s);
}
int add_item_to_map(std::unordered_map<int, size_t> *map, const int val)
{
int count;
auto it = map->find(val);
if(it == map->end()) {
map->insert(std::pair<int, size_t>(val, 1));
count = 1;
} else {
count = ++(it->second);
}
return count;
}
void read_ngrams_from_file(std::unordered_map<int, size_t> *map,
const size_t n, const size_t slide, FILE *fp)
{
char buffer[BUFSIZE];
size_t len = 0, offset = 0;
while((len = fread(buffer+offset, 1, sizeof(buffer)-offset, fp))) {
const char *s = buffer;
len += offset;
while(len >= n) {
int val = 0;
for(int i = 0; i < n; ++i) {
val <<= 8;
val |= s[i]&0xff;
}
add_item_to_map(map, val);
s+=slide;
len-=slide;
}
memcpy(buffer, s, offset=len);
}
}
void print_val(const int val, const size_t n, FILE *fp)
{
size_t size = n*2;
fprintf(fp, "0x");
for (int i = (int)(n-1); i>=0; i--) {
fprintf(fp, "%02X", ((val&(0xff<<(8*i)))>>(8*i)));
}
for(;size > 0; size--) {
fprintf(fp, " ");
}
}
void write_ngrams_to_file(std::unordered_map<int,size_t>*map, FILE *fp,size_t n)
{
size_t total = 0;
int i = 0;
std::vector<std::pair<size_t, int> > v =
std::vector<std::pair<size_t, int> >(map->size());
for(auto it = map->begin(); it!=map->end(); ++it) {
total += it->second;
v[i++] = std::pair<size_t, int>(it->second,it->first);
}
struct {
bool operator() (const std::pair<size_t, int>& lhs,
const std::pair<size_t, int>& rhs) const{
if(lhs.first == rhs.first) return lhs.second < rhs.second;
return lhs.first > rhs.first;
}
} comp;
std::sort(v.begin(), v.end(), comp);
for(auto it = v.begin(); it != v.end(); ++it) {
size_t amt = it->first;
fprintf(fp, "%d:\t", i);
print_val(it->second, n, fp);
fprintf(fp,"\t\t%lu\t\t%f%%\n",amt,(((float)amt)/((float)total))*100.0);
}
}
int main(int argc, char *argv[])
{
if(argc<5) {
print_help(argv[0]);
exit(1);
}
int n = atoi(argv[1]);
if(n<=0) {
printf("Invalid ngram_size\n");
print_help(argv[0]);
}
int s = atoi(argv[2]);
if(s<=0 || s>n) {
printf("Invalid sliding_window_size\n");
print_help(argv[0]);
}
FILE *input_file = fopen(argv[3], "rb");
if(input_file== nullptr) {
die_with_err("fopen() failed on input file");
}
FILE *output_file = fopen(argv[4], "wb");
if(output_file== nullptr) {
die_with_err("fopen() failed on output file");
}
std::unordered_map<int, size_t> ngram_map =
std::unordered_map<int, size_t>();
read_ngrams_from_file(&ngram_map, (size_t)n, (size_t)s, input_file);
fclose(input_file);
write_ngrams_to_file(&ngram_map, output_file, (size_t)n);
fclose(output_file);
return 0;
}
|
53aa445b15b1151fe3b92fd01b7aabb086e0d6e0 | 3224a53b3b25f8b537e1b7ad3e1685fb431922c2 | /ConsoleApplication11/Source.cpp | f68d0bda341ce307e18c7e0640136ad7c03c18f8 | [] | no_license | Skan9/var15-z4 | 28a38d2201017e1651e856df5c5bb0ab657ad45a | 18317da4de0510a4a55fd1e70374b72996c5c564 | refs/heads/master | 2016-09-06T03:55:13.595795 | 2014-12-01T18:34:05 | 2014-12-01T18:34:05 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 939 | cpp | Source.cpp | #include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
setlocale(LC_ALL, "rus");
int n, m, max;
ifstream in("in.txt");
if (!in.is_open())
{
cout << "Не удалось создать файл in.txt" << endl;
return -4;
}
in >> n >> m;
int** A = new int*[m];
for (int i = 0; i<n; i++)
{
A[i] = new int[m];
for (int j = 0; j<m; j++)
{
in >> A[i][j];
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
max = A[i][j];
for (int k = i; k < n; k++)
{
for (int g = j; g < m; g++)
{
if (A[k][g] > max)
{
max = A[k][g];
}
}
}
A[i][j] = max;
}
}
ofstream out("out.txt");
if (!out.is_open())
{
cout << "Не удалось создать файл out.txt" << endl;
return -4;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
out << A[i][j] << ' ';
}
out << endl;
}
system("pause");
return 0;
} |
bfb860414a5e852a8bbf8390792a1e6aac184867 | 5d85f37ac448403cfa78acf70f657421a47cdc2c | /.programm1.cpp | 46e7ffda81b93bb804a7551a1e1c5ea1b7ff6512 | [] | no_license | RomanPolishukov/practice | 84486c085757b5801e5bfca2af3f9170901d4716 | 1e39c41f1cb7b6d9e512f519fc727ec093230daf | refs/heads/master | 2021-01-21T08:02:23.681221 | 2015-07-24T07:38:24 | 2015-07-24T07:38:24 | 39,585,698 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,623 | cpp | .programm1.cpp | #include <stdio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <conio.h>
using namespace std;
int file_massive()
{
srand(time(NULL));
int a[10][2],i,j;
FILE *f = fopen("p.txt", "wt");
for (i = 0; i < 10; i++)
{
for ( j = 0; j < 2; j++)
{
a[i][j] = rand() % 10;
printf(" %d", a[i][j]);
fprintf(f, " %d", a[i][j]);
}
printf("\n");
fprintf(f, "\n");
}
fclose(f);
}
int main()
{
file_massive();
int a,b;
float x,y;
std::vector<int> v1;
std::vector<int> v2;
fstream F;
F.open("p.txt");
if (F)
{
printf("file found.\n");
while (!F.eof())
{
F>>a;
v1.push_back(a);
}
F.close();
int vector1_size = v1.size();
vector1_size=vector1_size-1;
printf("massiv points:\n");
for (int i = 0; i < vector1_size; i=i+2)
{
printf(" x=%d y=%d\n",v1[i],v1[i+1]);
}
printf("radius.\n");
scanf("%d",&b);
printf("receiv massiv points:\n");
for(int i = 0; i < vector1_size; i=i+2)
{
if(pow((pow(v1[i],2)+pow(v1[i+1],2)),0.5)<=b)
{
v2.push_back(v1[i]);
v2.push_back(v1[i+1]);
printf(" x=%d y=%d\n",v1[i],v1[i+1]);
x=x+v1[i];
y=y+v1[i+1];
}
}
printf("mass center:\n");
int vector2_size = v2.size();
vector2_size=vector2_size*0.5;
x=x/vector2_size;
y=y/vector2_size;
printf(" x=%f y=%f\n",x,y);
}
else{
printf("file not found!\n");
}
getch();
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.