text:
#ifndef SHARED_FRAME_H_
#define SHARED_FRAME_H_

#ifdef _MSC_VER
#include <windows.h>
#endif

#include <stdio.h>
#include <time.h>

#include <boost/thread.hpp>

#include <chrono>

#include <vector>
#include <exception>

#include <DepthSense.hxx>

#include "AcquisitionParameters.hxx"

using namespace DepthSense;
using namespace std;

struct FrameCorrespondence {
    int indexFrame;
    int timestamp;
    int correspFrame;
};

typedef vector<FrameCorrespondence> Report;

class Frame {
    protected:
        int m_width;
        int m_height;
        int m_timestamp;
        int m_indexFrame;
        int m_correspFrame;

    public:
        Frame(int width, int height);

        void setWidth(int width);
        void setHeight(int height);
        void setTimestamp(int timestamp);
        void setIndexFrame(int indexFrame);
        void setCorrespFrame(int correspFrame);

        int getWidth() { return m_width; }
        int getHeight() { return m_height; }
        int getTimestamp() { return m_timestamp; }
        int getIndexFrame() { return m_indexFrame; }
        int getCorrespFrame() { return m_correspFrame; }

        void updateReport(string pathReport);

        static string formatFilenameFrame(int indexFrame, string prefix);
        static string formatFilenamePNM(int indexFrame, string prefix);
        static string formatFilenameReport(string prefix);
        static void importReport(string pathReport,
                                 Report* p_report);

};

class FrameColor: public Frame {
    protected:
        static const string m_prefix;
        uint8_t* m_rgb; // RGB format

    public:
        FrameColor(int width, int height);
        FrameColor(string pathFrame);
        ~FrameColor();

        uint8_t* getRGB() { return m_rgb; }
        static const string getPrefix() { return m_prefix; }

        void importColorMap(ColorNode::NewSampleReceivedData data);
        void writeFrame(string pathFrame);

        static string formatFilenameFrame(int indexFrame);
        static string formatFilenameReport();
};

class FrameDepth: public Frame {
    protected:
        static const string m_prefix;
        uint16_t* m_depth;
        uint16_t* m_confidence;
        float* m_uv;

    public:
        FrameDepth(int width, int height);
        FrameDepth(string pathFrame);
        ~FrameDepth();

        static const string getPrefix() { return m_prefix; }
        uint16_t* getDepth() { return m_depth; }
        uint16_t* getConfidence() { return m_confidence; }
        float* getUV() { return m_uv; }
        void importDepthMap(DepthNode::NewSampleReceivedData data);
        void writeFrame(string pathFrame);

        static string formatFilenameFrame(int indexFrame);
        static string formatFilenameReport();
};

#endif

ext: hxx


text:
#ifndef COLORMIXERHPP
#define COLORMIXERHPP

#include <boost/array.hpp>

class ColorInfo
{
public:
  enum Color { WHITE,YELLOW,BLUE,RED,GREEN,VIOLET,ORANGE,QUICKSILVER,BROWN };
  static char GetColorChar(Color c);
  static Color GetColorForChar(char c);

  static Color Mix(Color c1,Color c2);
private:
  static boost::array<boost::array<char,9>,9> s_mixes;
};

#endif

ext: hpp

max_stars_repo_name: chiendarrendor/AlbertsMisc

max_issues_repo_name: chiendarrendor/AlbertsMisc

max_forks_repo_name: chiendarrendor/AlbertsMisc


text:
#pragma once

#include <vector>

#include <boost/graph/astar_search.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/adjacency_iterator.hpp>
#include <boost/graph/filtered_graph.hpp>

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/tag.hpp>

#include <boost/optional.hpp>

#include "node.hpp"

struct edge_info_t {
    int weight;
    bool is_tmp;
    int interm_inode;
};

typedef boost::adjacency_list<
        boost::listS,
        boost::vecS,
        boost::bidirectionalS,
        boost::no_property,
        edge_info_t
> graph_t;
typedef boost::property_map<graph_t, int edge_info_t::*>::type edge_info_map_t;
typedef boost::property_map<graph_t, int edge_info_t::*>::const_type const_edge_info_map_t;
typedef graph_t::vertex_descriptor vertex_descriptor;
typedef graph_t::edge_descriptor edge_descriptor;

typedef boost::property_map<graph_t, boost::vertex_index_t>::type IndexMap;
typedef boost::graph_traits<graph_t>::adjacency_iterator adjacency_iterator;
typedef boost::graph_traits<graph_t>::out_edge_iterator out_edge_iterator;
typedef boost::graph_traits<graph_t>::in_edge_iterator in_edge_iterator;

class FilterEdges {
public:
    void add_edge(const edge_descriptor &e);
    void rm_edge(const edge_descriptor &e);
    bool exists(const edge_descriptor &e) const;
    template <typename EdgeDesc>
    bool operator()(const EdgeDesc &e) const;

private:
    std::set<edge_descriptor> edges_;
};

struct found_goal {}; // exception for termination

template <class Graph, class CostType>
class astar_heuristic : public boost::astar_heuristic<Graph, CostType> {
public:
    typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex;

    astar_heuristic(int col_num, Node goal_node);
    CostType operator()(vertex u);

private:
    int col_num_;
    Node goal_node_;
};

// visitor that terminates when we find the goal
template <class Vertex>
class astar_goal_visitor : public boost::default_astar_visitor {
public:
    astar_goal_visitor(Vertex goal);
    template<class Graph> void examine_vertex(Vertex u, Graph& /* g */);
private:
    Vertex m_goal;
};

#ifdef USE_BOARD_GRAPH_CACHE
struct by_node {};
typedef boost::multi_index_container<
    Node,
    boost::multi_index::indexed_by<
        boost::multi_index::random_access<>,
        boost::multi_index::ordered_unique<
            boost::multi_index::tag<by_node>,
            boost::multi_index::identity<Node>>
    >
> path_t;

struct cached_path_data_t {
    Node start_node;
    Node end_node;
    path_t path;
    size_t len;
    bool is_exists;
};

struct by_node_len {};
struct by_node_node {};
typedef boost::multi_index_container<
    cached_path_data_t,
    boost::multi_index::indexed_by<
        boost::multi_index::ordered_non_unique<
            boost::multi_index::tag<by_node_len>,
            boost::multi_index::composite_key<
                cached_path_data_t,
                boost::multi_index::member<
                    cached_path_data_t, Node, &cached_path_data_t::start_node>,
                boost::multi_index::member<
                    cached_path_data_t, size_t, &cached_path_data_t::len>
            >
        >,
        boost::multi_index::ordered_non_unique<
            boost::multi_index::tag<by_node_node>,
            boost::multi_index::composite_key<
                cached_path_data_t,
                boost::multi_index::member<
                    cached_path_data_t, Node, &cached_path_data_t::start_node>,
                boost::multi_index::member<
                    cached_path_data_t, Node, &cached_path_data_t::end_node>
            >
        >
    >
> path_data_list_t;
#endif

struct goal_nodes_t {
    Node node;
    const std::set<Node> *goal_nodes;
};

class BoardGraph {
public:
    BoardGraph(int row_num, int col_num);

    bool remove_edges(const std::vector<std::pair<Node, Node>> &node_pair_list,
            const std::vector<goal_nodes_t> &goal_nodes_list, bool check_only);

    void block_node(const Node &node);
    void unblock_node(const Node &node);
    std::list<Node> adjacent_nodes(const Node &node) const;

    size_t shortest_path(const Node &start_node,
            const std::set<Node> &goal_nodes, std::list<Node> *path) const;
    boost::optional<std::list<Node>> find_path(const Node &start_node,
            const Node &end_node) const;
    bool is_adjacent(const Node &from_node, const Node &to_node) const;

private:
    bool check_paths_to_goal_nodes(
            const std::vector<goal_nodes_t> &goal_nodes_list,
            const std::vector<std::pair<int, int>> &removed_edges) const;
    bool is_adjacent(int from_inode, int to_inode, bool check_tmp_edges) const;
    void block_inode(int inode);
    void unblock_inode(int inode);
    bool block_edge(int from_inode, int to_inode, bool is_tmp);
    void block_edge(edge_descriptor e, bool is_tmp);
    bool unblock_edge(int from_inode, int to_inode, bool is_tmp, int interm_inode = -1);
    bool is_inode_valid(int inode) const;
    std::vector<edge_descriptor> find_tmp_edges(int inode) const;

#ifdef USE_BOARD_GRAPH_CACHE
private:
    void add_path_to_cache(const Node &start_node, const Node &end_node,
            const std::list<Node> &path, bool is_exists) const;
    size_t cached_shortest_path(const Node &start_node,
            const std::set<Node> &goal_nodes, std::list<Node> *path) const;
    boost::optional<std::list<Node>> cached_path(const Node &start_node,
            const Node &end_node) const;
    void update_cached_path(const Node &node) const;
    void remove_cached_path(const Node &node) const;
#endif

private:
    graph_t g_;
    int row_num_;
    int col_num_;
    FilterEdges fe_;
    std::map<int, std::set<std::pair<int, int>>> tmp_edges_;
#ifdef USE_BOARD_GRAPH_CACHE
    mutable path_data_list_t path_data_list_;
#endif
};

max_stars_repo_name: sfod/quoridor

max_issues_repo_name: sfod/quoridor

max_forks_repo_name: sfod/quoridor


text:
//
// Variable for Scheme
//
// Author: Zhang Zhenghao (zhangzhenghao@hotmail.com)
//
#pragma once

#include <string>
#include <memory>
#include <sstream>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <boost/multiprecision/cpp_int.hpp>
#include "exception.hpp"
#include "environment.hpp"
#include "garbage.hpp"

class Variable: public GarbageObject
{
public:

	// Type of variable
	enum Type {
		TYPE_RATIONAL 	= 0x01,
		TYPE_FLOAT 		= 0x02,
		TYPE_STRING 	= 0x04,
		TYPE_SYMBOL  	= 0x08,
		TYPE_SPEC     	= 0x10,
		TYPE_PAIR 	 	= 0x20,
		TYPE_PRIM 	 	= 0x40,
		TYPE_COMP 	 	= 0x80,
		// Type class
		TYPE_TEXT		= 0x0C,
		TYPE_NUMBER		= 0x03,
		TYPE_PROCEDURE	= 0xC0,
		// Sub type
		TYPE_INTEGER	= 0x100
	};

private:

	// Indent class
	struct Primitive;
	struct Compound;
	friend Environment;

	// Type alias
	using string = std::string;
	using ostream = std::ostream;
	using istream = std::istream;
	using ostringstream = std::ostringstream;
	using pair = std::pair<Variable, Variable>;
	using cpp_rational = boost::multiprecision::cpp_rational;
	using function = std::function<Variable(const Variable&, Environment&)>;

	// Optimization: constant pool
	static std::unordered_map<std::string, Variable> pool;

	// Type of variable
	Type type;

	// Reference count
	int* refCount = nullptr;

	// Value of variable
	union {
		cpp_rational*	rationalPtr;
		double*		doublePtr;
		string*		stringPtr;
		pair*		pairPtr;
		void*		voidPtr;
		Primitive*	primPtr;
		Compound*	compPtr;
	};

public:

	// Constructor for special
	Variable();

	// Constructor for rational
	Variable(const cpp_rational& rational);

	// Constructor for double
	Variable(double value);

	// Constructor for rational, double, string and symbol
	Variable(const string &str, Type type);

	// Constructor for pairs
	Variable(const Variable& lhs, const Variable& rhs);

	// Constructor for primitive procedure
	Variable(const string& name, const function& func);

	// Constructor for compound procedure
	Variable(const string& name, const Variable& args, const Variable& body, const Environment& env);

	// Copy constructor
	Variable(const Variable& var);

	// Destructor
	~Variable();

	// Swap two variables
	friend void swap(Variable& lhs, Variable& rhs);

	// Assignment
	Variable& operator=(Variable var);

	// Optimization: constant pool
	static Variable createSymbol(const std::string& str);

	// Finalize value
	void finalize() const override;

	// Scan and tag value in using
	void scan(int tag) const override;

	// Standard I/O
	friend ostream& operator<<(ostream& out, const Variable& var);
	friend istream& operator>>(istream& in, Variable& var);

	// Require type, throw exception if type is wrong
	void requireType(const string &caller, Type type) const;

	// Get type name
	static string getTypeName(Type type);

	// Convert operations
	string toString() const;
	double toDouble() const;

	// Check operations
	bool isNull() const;
	bool isVoid() const;
	bool isPair() const;
	bool isNumber() const;
	bool isInteger() const;
	bool isSymbol() const;
	bool isString() const;
	bool isPrim() const;
	bool isComp() const;
	bool isProcedure() const;

	// Arithmetic operations
	friend Variable operator+(const Variable& lhs, const Variable& rhs);
	friend Variable operator-(const Variable& lhs, const Variable& rhs);
	friend Variable operator*(const Variable& lhs, const Variable& rhs);
	friend Variable operator/(const Variable& lhs, const Variable& rhs);
	friend Variable operator-(const Variable& var);
	friend Variable remainder(const Variable& lhs, const Variable& rhs);
	friend Variable quotient(const Variable& lhs, const Variable& rhs);
	friend Variable gcd(const Variable& lhs, const Variable& rhs);
	bool isEven() const;
	bool isOdd() const;

	// Compare operations
	friend bool operator<(const Variable& lhs, const Variable& rhs);
	friend bool operator>(const Variable& lhs, const Variable& rhs);
	friend bool operator<=(const Variable& lhs, const Variable& rhs);
	friend bool operator>=(const Variable& lhs, const Variable& rhs);
	friend bool operator==(const Variable& lhs, const Variable& rhs);
	friend bool operator!=(const Variable& lhs, const Variable& rhs);

	// Pair operations
	Variable& car() const;
	Variable& cdr() const;
	Variable setCar(const Variable& var) const;
	Variable setCdr(const Variable& var) const;

	// Procedure operations
	Variable operator()(const Variable& arg, Environment& env) const;
	Variable& getProcedureArgs() const;
	Variable& getProcedureBody() const;
	string getProcedureName() const;
	Environment getProcedureEnv() const;
};

// Primitive procedure

struct Variable::Primitive
{
	string name;	// Name of procedure
	function func;	// Function object
	Primitive(const string& name, const function& func): name(name), func(func) {}
};

// Compound procedure

struct Variable::Compound
{
	string name;		// Name of procedure
	Variable args, body;// Argument and body
	Environment env;	// Closure
	Compound(const string& name, const Variable& args, const Variable& body, const Environment& env):
		name(name), args(args), body(body), env(env) {}
};

// Constant values

extern const Variable VAR_NULL;
extern const Variable VAR_VOID;
extern const Variable VAR_TRUE;
extern const Variable VAR_FALSE;

max_stars_repo_name: ZhangZhenghao/SimpleScheme

max_issues_repo_name: ZhangZhenghao/SimpleScheme

max_forks_repo_name: ZhangZhenghao/SimpleScheme


text:
#ifndef LIVEODR_DETECTORS_FRONTAL_FACE_DETECTOR_HPP
#define LIVEODR_DETECTORS_FRONTAL_FACE_DETECTOR_HPP

#include "detector.hpp"
#include "../utils.hpp"

#include <opencv2/imgproc.hpp>
#include <dlib/opencv.h>
#include <dlib/image_processing/frontal_face_detector.h>

#include <vector>

namespace liveodr {
    class FrontalFaceDetector : virtual public IDetector {
    public:
        FrontalFaceDetector() {
            detector = dlib::get_frontal_face_detector();
        }

        const std::vector<cv::Rect> process(cv::Mat input) override {
            cv::Mat input_grey;
            cv::cvtColor(input, input_grey, cv::COLOR_BGR2GRAY);
            //cv::equalizeHist(input_grey, input_grey);

            dlib::cv_image<unsigned char> converted_input(input_grey);

            std::vector<cv::Rect> faces;
            for(auto&& r : detector(converted_input))
                faces.emplace_back(liveodr::utils::dlib_to_opencv_rect(r));
            return faces;
        };

    private:
        dlib::frontal_face_detector detector;
    };
}

#endif /* ifndef LIVEODR_DETECTORS_FRONTAL_FACE_DETECTOR_HPP */

max_stars_repo_name: YashasSamaga/liveodr

max_issues_repo_name: YashasSamaga/liveodr

max_forks_repo_name: YashasSamaga/liveodr


text:
/*=========================================================================
 *
 *  Copyright David Doria 2012 daviddoria@gmail.com
 *
 *  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.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/

#ifndef ScoreThresholdAcceptanceVisitor_HPP
#define ScoreThresholdAcceptanceVisitor_HPP

#include <boost/graph/graph_traits.hpp>

// Parent class
#include "Visitors/AcceptanceVisitors/AcceptanceVisitorParent.h"

// Custom
#include "ITKHelpers/ITKHelpers.h"

// ITK
#include "itkImageRegion.h"

/**

 */
template <typename TGraph, typename TPropertyMap, typename TDifferenceFunction>
struct ScoreThresholdAcceptanceVisitor : public AcceptanceVisitorParent<TGraph>
{
  Mask* MaskImage;

  const unsigned int HalfWidth;

  TPropertyMap PropertyMap;

  float Threshold;

  typedef typename boost::graph_traits<TGraph>::vertex_descriptor VertexDescriptorType;

  ScoreThresholdAcceptanceVisitor(Mask* const mask, const unsigned int halfWidth, TPropertyMap propertyMap,
                                  const float threshold, const std::string& visitorName = "HoleSizeAcceptanceVisitor") :
  AcceptanceVisitorParent<TGraph>(visitorName), MaskImage(mask), HalfWidth(halfWidth), PropertyMap(propertyMap),
  Threshold(threshold)
  {

  }

  bool AcceptMatch(VertexDescriptorType target, VertexDescriptorType source, float& computedEnergy) const override
  {
    itk::Index<2> targetPixel = ITKHelpers::CreateIndex(target);
    itk::ImageRegion<2> targetRegion = ITKHelpers::GetRegionInRadiusAroundPixel(targetPixel, this->HalfWidth);

    TDifferenceFunction differenceFunction;
    float difference = differenceFunction(get(this->PropertyMap, target), get(this->PropertyMap, source));

    std::cout << "ScoreThresholdAcceptanceVisitor difference: " << difference << std::endl;
    if(difference < this->Threshold)
    {
      return true;
    }
    else
    {
      return false;
    }
  }

};

#endif

max_stars_repo_name: jingtangliao/ff

max_issues_repo_name: jingtangliao/ff

max_forks_repo_name: jingtangliao/ff


text:
#include <boost/asio.hpp>
#include <memory>
#include <iostream>

int main( int argc, char * argv[] )
{
	boost::asio::io_service io_service;
	std::shared_ptr< boost::asio::io_service::work > work(
		new boost::asio::io_service::work( io_service )
		);

	work.reset();

	io_service.run();

	std::cout << "Do you reckon this line displays?" << std::endl;

	return 0;
}

ext: cpp

max_stars_repo_name: steelwil/homepage

max_issues_repo_name: steelwil/homepage

max_forks_repo_name: steelwil/homepage


text:
#include <boost/test/unit_test.hpp>

#include <scorum/app/api_context.hpp>

#include <scorum/app/chain_api.hpp>

#include <scorum/chain/services/dynamic_global_property.hpp>
#include <scorum/chain/services/hardfork_property.hpp>
#include <scorum/chain/services/reward_funds.hpp>
#include <scorum/chain/services/registration_pool.hpp>
#include <scorum/chain/services/budgets.hpp>
#include <scorum/chain/services/reward_balancer.hpp>
#include <scorum/chain/services/witness_reward_in_sp_migration.hpp>
#include <scorum/chain/schema/budget_objects.hpp>
#include <scorum/chain/schema/scorum_objects.hpp>
#include <scorum/chain/schema/reward_balancer_objects.hpp>
#include <scorum/chain/schema/dev_committee_object.hpp>
#include <scorum/chain/services/development_committee.hpp>
#include <scorum/chain/services/account.hpp>

#include <scorum/chain/schema/account_objects.hpp>

#include "database_trx_integration.hpp"

namespace chain_api_tests {

using namespace scorum;
using namespace scorum::app;
using namespace scorum::protocol;
using namespace scorum::chain;

struct chain_api_database_fixture : public database_fixture::database_integration_fixture
{
    api_context _api_ctx;
    chain_api _api_call;

    chain_api_database_fixture()
        : _api_ctx(app, API_CHAIN, std::make_shared<api_session_data>())
        , _api_call(_api_ctx)
        , account_service(db.account_service())
    {
        static const asset registration_bonus = ASSET_SCR(100);
        genesis_state_type::registration_schedule_item single_stage{ 1u, 1u, 100u };
        genesis_state_type genesis = database_integration_fixture::default_genesis_state()
                                         .registration_supply(registration_bonus * 100)
                                         .registration_bonus(registration_bonus)
                                         .registration_schedule(single_stage)
                                         .committee(initdelegate.name)
                                         .generate();

        open_database(genesis);

        generate_block();
        validate_database();
    }

    account_service_i& account_service;
};

} // namespace chain_api_tests

BOOST_FIXTURE_TEST_SUITE(chain_api_tests, chain_api_tests::chain_api_database_fixture)

SCORUM_TEST_CASE(total_scr_does_not_change_per_block)
{
    generate_blocks(5);

    auto old_total_scr = _api_call.get_chain_capital().total_scr;
    auto old_circulating_capital = _api_call.get_chain_capital().circulating_capital;
    auto old_total_scorumpower = _api_call.get_chain_capital().total_scorumpower;

    generate_blocks(5);

    auto total_scr = _api_call.get_chain_capital().total_scr;
    auto circulating_capital = _api_call.get_chain_capital().circulating_capital;
    auto total_scorumpower = _api_call.get_chain_capital().total_scorumpower;

    BOOST_CHECK_EQUAL(total_scr, old_total_scr);
    BOOST_CHECK_GT(circulating_capital, old_circulating_capital);
    BOOST_CHECK_GT(total_scorumpower, old_total_scorumpower);
    BOOST_CHECK_EQUAL(circulating_capital.amount - old_circulating_capital.amount,
                      total_scorumpower.amount - old_total_scorumpower.amount);
}

SCORUM_TEST_CASE(total_sp_changes_per_block)
{
    generate_blocks(5);

    auto total_sp = _api_call.get_chain_capital().total_scorumpower;

    generate_blocks(5);

    BOOST_CHECK_GT(_api_call.get_chain_capital().total_scorumpower, total_sp);
}

SCORUM_TEST_CASE(total_scr_equal_scr_on_accounts_balance)
{
    generate_blocks(5);

    auto total_scr = _api_call.get_chain_capital().total_scr;
    auto expected_total_scr = ASSET_NULL_SCR;
    account_service.foreach_account([&](const account_object& a) { expected_total_scr += a.balance; });

    BOOST_CHECK_EQUAL(total_scr, expected_total_scr);
}

SCORUM_TEST_CASE(total_sp_equal_sp_on_accounts_balance)
{
    generate_blocks(5);

    auto total_sp = _api_call.get_chain_capital().total_scorumpower;
    auto expected_total_sp = ASSET_NULL_SP;
    account_service.foreach_account([&](const account_object& a) { expected_total_sp += a.scorumpower; });

    BOOST_CHECK_EQUAL(total_sp, expected_total_sp);
}

SCORUM_TEST_CASE(chain_properties_getter_test)
{
    const auto& dpo = db.obtain_service<chain::dbs_dynamic_global_property>().get();

    auto props = _api_call.get_chain_properties();

    BOOST_REQUIRE_EQUAL(props.chain_id, db.get_chain_id());
    BOOST_REQUIRE_EQUAL(props.head_block_id, dpo.head_block_id);
    BOOST_REQUIRE_EQUAL(props.head_block_number, dpo.head_block_number);
    BOOST_REQUIRE_EQUAL(props.last_irreversible_block_number, dpo.last_irreversible_block_num);
    BOOST_REQUIRE_EQUAL(props.current_aslot, dpo.current_aslot);
    BOOST_REQUIRE_EQUAL(props.current_witness, initdelegate.name);
    BOOST_REQUIRE_EQUAL(props.median_chain_props.account_creation_fee, dpo.median_chain_props.account_creation_fee);
    BOOST_REQUIRE_EQUAL(props.median_chain_props.maximum_block_size, dpo.median_chain_props.maximum_block_size);
    BOOST_REQUIRE(props.time == dpo.time);
    BOOST_REQUIRE(props.majority_version == dpo.majority_version);
    BOOST_REQUIRE(props.hf_version == db.obtain_service<chain::dbs_hardfork_property>().get().current_hardfork_version);
}

SCORUM_TEST_CASE(chain_properties_getter_after_generate_block_test)
{
    wdump((db.head_block_num()));

    auto props = _api_call.get_chain_properties();

    generate_block();

    wdump((db.head_block_num()));

    auto props_new = _api_call.get_chain_properties();

    BOOST_REQUIRE_EQUAL(props_new.chain_id, props.chain_id);
    BOOST_REQUIRE_EQUAL(props_new.head_block_number, props.head_block_number + 1);
    BOOST_REQUIRE_EQUAL(props_new.last_irreversible_block_number, props.last_irreversible_block_number);
    BOOST_REQUIRE_EQUAL(props_new.current_aslot, props.current_aslot + 1);
    BOOST_REQUIRE_EQUAL(props_new.current_witness, initdelegate.name);
    BOOST_REQUIRE_EQUAL(props_new.median_chain_props.account_creation_fee,
                        props.median_chain_props.account_creation_fee);
    BOOST_REQUIRE_EQUAL(props_new.median_chain_props.maximum_block_size, props.median_chain_props.maximum_block_size);
    BOOST_REQUIRE_EQUAL(props_new.time.sec_since_epoch(), props.time.sec_since_epoch() + SCORUM_BLOCK_INTERVAL);
    BOOST_REQUIRE(props_new.majority_version == props.majority_version);
    BOOST_REQUIRE(props_new.hf_version == props.hf_version);
}

SCORUM_TEST_CASE(get_chain_capital_test)
{
    auto capital = _api_call.get_chain_capital();

    const auto& dpo = db.obtain_service<chain::dbs_dynamic_global_property>().get();

    BOOST_REQUIRE_EQUAL(capital.head_block_number, dpo.head_block_number);
    BOOST_REQUIRE_EQUAL(capital.head_block_id, dpo.head_block_id);
    BOOST_REQUIRE(capital.head_block_time == dpo.time);
    BOOST_REQUIRE_EQUAL(capital.current_witness, dpo.current_witness);

    BOOST_REQUIRE_EQUAL(capital.total_supply.amount, capital.circulating_scr.amount + capital.circulating_sp.amount);

    BOOST_REQUIRE_EQUAL(capital.total_supply, dpo.total_supply);
    BOOST_REQUIRE_EQUAL(capital.circulating_capital, dpo.circulating_capital);
    BOOST_REQUIRE_EQUAL(capital.total_scorumpower, dpo.total_scorumpower);
    BOOST_REQUIRE_EQUAL(capital.total_witness_reward_scr, dpo.total_witness_reward_scr);
    BOOST_REQUIRE_EQUAL(capital.total_witness_reward_sp, dpo.total_witness_reward_sp);

    BOOST_REQUIRE_EQUAL(capital.registration_pool_balance,
                        db.obtain_service<chain::dbs_registration_pool>().get().balance);
    BOOST_REQUIRE_EQUAL(capital.fund_budget_balance, db.obtain_service<chain::dbs_fund_budget>().get().balance);

    BOOST_REQUIRE_EQUAL(capital.dev_pool_scr_balance,
                        db.obtain_service<chain::dbs_development_committee>().get().scr_balance);
    BOOST_REQUIRE_EQUAL(capital.dev_pool_sp_balance,
                        db.obtain_service<chain::dbs_development_committee>().get().sp_balance);

    BOOST_REQUIRE_EQUAL(capital.content_balancer_scr, db.obtain_service<chain::dbs_content_reward_scr>().get().balance);
    BOOST_REQUIRE_EQUAL(capital.active_voters_balancer_scr,
                        db.obtain_service<chain::dbs_voters_reward_scr>().get().balance);
    BOOST_REQUIRE_EQUAL(capital.active_voters_balancer_sp,
                        db.obtain_service<chain::dbs_voters_reward_sp>().get().balance);

    BOOST_REQUIRE_EQUAL(capital.content_reward_fund_scr_balance,
                        db.obtain_service<chain::dbs_content_reward_fund_scr>().get().activity_reward_balance);
    BOOST_REQUIRE_EQUAL(capital.content_reward_fund_sp_balance,
                        db.obtain_service<chain::dbs_content_reward_fund_sp>().get().activity_reward_balance);
    BOOST_REQUIRE_EQUAL(capital.content_reward_fifa_world_cup_2018_bounty_fund_sp_balance, asset(0, SP_SYMBOL));

    BOOST_REQUIRE_EQUAL(capital.witness_reward_in_sp_migration_fund.amount,
                        db.obtain_service<chain::dbs_witness_reward_in_sp_migration>().get().balance);
}

SCORUM_TEST_CASE(get_reward_fund_test)
{
    auto reward = _api_call.get_reward_fund(reward_fund_type::content_reward_fund_sp);

    const auto& fund = db.obtain_service<chain::dbs_content_reward_fund_sp>().get();

    BOOST_REQUIRE_EQUAL(reward.activity_reward_balance, fund.activity_reward_balance);
    BOOST_REQUIRE(reward.recent_claims == fund.recent_claims);
    BOOST_REQUIRE(reward.last_update == fund.last_update);
    BOOST_REQUIRE(reward.author_reward_curve == fund.author_reward_curve);
    BOOST_REQUIRE(reward.curation_reward_curve == fund.curation_reward_curve);
}

BOOST_AUTO_TEST_SUITE_END()

max_stars_repo_name: scorum/scorum

max_issues_repo_name: Scorum/Scorum

max_forks_repo_name: Scorum/Scorum


text:
/*
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or copy at
 * http://www.boost.org/LICENSE_1_0.txt)
 *
 * Copyright (c) 2020 Andrey Semashev
 */
/*!
 * \file   atomic/detail/core_arch_operations_fwd.hpp
 *
 * This header contains forward declaration of the \c core_arch_operations template.
 */

#ifndef BOOST_ATOMIC_DETAIL_CORE_ARCH_OPERATIONS_FWD_HPP_INCLUDED_
#define BOOST_ATOMIC_DETAIL_CORE_ARCH_OPERATIONS_FWD_HPP_INCLUDED_

#include <cstddef>
#include <boost/atomic/detail/config.hpp>
#include <boost/atomic/detail/header.hpp>

#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif

namespace boost {
namespace atomics {
namespace detail {

template< std::size_t Size, bool Signed, bool Interprocess >
struct core_arch_operations;

} // namespace detail
} // namespace atomics
} // namespace boost

#include <boost/atomic/detail/footer.hpp>

#endif // BOOST_ATOMIC_DETAIL_CORE_ARCH_OPERATIONS_FWD_HPP_INCLUDED_

max_stars_repo_name: kindlychung/mediasoup-sfu-cpp

max_issues_repo_name: kindlychung/mediasoup-sfu-cpp

max_forks_repo_name: kindlychung/mediasoup-sfu-cpp


text:
//
// Copyright 2010 Scott McMurray.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef BOOST_HASH_CUBEHASH_HPP
#define BOOST_HASH_CUBEHASH_HPP

#include <boost/hash/detail/cubehash_policy.hpp>
#include <boost/hash/merkle_damgard_block_hash.hpp>
#include <boost/hash/stream_preprocessor.hpp>

// As of 2009-07-15, the submission to NIST for SHA-3 is CubeHash16/32
// http://cubehash.cr.yp.to/submission/tweak.pdf
#ifndef BOOST_HASH_CUBEHASH_DEFAULT_R
#define BOOST_HASH_CUBEHASH_DEFAULT_R 16
#endif
#ifndef BOOST_HASH_CUBEHASH_DEFAULT_B
#define BOOST_HASH_CUBEHASH_DEFAULT_B 32
#endif

namespace boost {
namespace hashes {

template <unsigned r, unsigned b, unsigned h>
struct cubehash_compressor {
  public:
    typedef detail::cubehash_policy<r, b, h> policy_type;

    static unsigned const word_bits = policy_type::word_bits;
    typedef typename policy_type::word_type word_type;

    static unsigned const state_bits = policy_type::state_bits;
    static unsigned const state_words = policy_type::state_words;
    typedef typename policy_type::state_type state_type;

    static unsigned const block_bits = policy_type::block_bits;
    static unsigned const block_words = policy_type::block_words;
    typedef typename policy_type::block_type block_type;

  public:
    void
    operator()(state_type &state,
               block_type const &block) {
        process_block(state, block);
    }

  private:
    static void
    process_block(state_type &state,
                  block_type const &block) {
#ifdef BOOST_HASH_SHOW_PROGRESS
        printf("Xoring the following block to the state:\n");
        for (unsigned i = 0; i < block.size(); ++i) {
            printf("%.8x%c", block[i], (i+1) != block.size() ? ' ' : '\n');
        }
#endif
        for (unsigned i = 0; i < block_words; ++i) {
            state[i] ^= block[i];
        }
        policy_type::transform_r(state);
    }

};

template <unsigned r, unsigned b, unsigned h>
struct cubehash_finalizer {
    typedef detail::cubehash_policy<r, b, h> policy_type;
    typedef typename policy_type::state_type state_type;
    void operator()(state_type &state) const {
        state[31] ^= 1;
        policy_type::transform_10r(state);
    }
};

//
// If the second and third parameters are unspecified (or left 0), then
// the first parameter is the number of bits in the digest, and
// r and b will be set to defaults.
//
// Otherwise the three parameters are r, b, and h respectively.
//

template <unsigned, unsigned = 0, unsigned = 0>
struct cubehash;

template <unsigned r, unsigned b, unsigned h>
struct cubehash {
  private:
    typedef detail::cubehash_policy<r, b, h> policy_type;
  public:
    typedef merkle_damgard_block_hash<
                stream_endian::little_octet_big_bit,
                policy_type::digest_bits,
                typename policy_type::iv_generator,
                cubehash_compressor<r, b, h>,
                cubehash_finalizer<r, b, h>
            > block_hash_type_;
#ifdef BOOST_HASH_NO_HIDE_INTERNAL_TYPES
    typedef block_hash_type_ block_hash_type;
#else
    struct block_hash_type : block_hash_type_ {};
#endif
    template <unsigned value_bits>
    struct stream_hash {
        typedef stream_preprocessor<
                    stream_endian::little_octet_big_bit,
                    value_bits,
                    0, // No length padding!
                    block_hash_type
                > type_;
#ifdef BOOST_HASH_NO_HIDE_INTERNAL_TYPES
        typedef type_ type;
#else
        struct type : type_ {};
#endif
    };
    typedef typename block_hash_type::digest_type digest_type;
};

template <unsigned h>
struct cubehash<h, 0, 0>
 : cubehash<BOOST_HASH_CUBEHASH_DEFAULT_R,
            BOOST_HASH_CUBEHASH_DEFAULT_B,
            h> {};

} // namespace hashes
} // namespace boost

#endif // BOOST_HASH_CUBEHASH_HPP

max_stars_repo_name: dillonl/boost-cmake

max_issues_repo_name: dillonl/boost-cmake

max_forks_repo_name: dillonl/boost-cmake


text:
/* transfer_function.cc
   Jeremy Barnes, 4 November 2009
   Copyright (c) 2009 Jeremy Barnes.  All rights reserved.

   Transfer function implementation.
*/

#include "transfer_function.h"
#include <cmath>
#include "jml/db/persistent.h"
#include "jml/boosting/registry.h"
#include "jml/utils/smart_ptr_utils.h"

#include <boost/static_assert.hpp>

using namespace ML::DB;
using namespace std;

namespace ML {

/*****************************************************************************/
/* RANGE_TYPE                                                                */
/*****************************************************************************/

/*****************************************************************************/
/* RANGE                                                                     */
/*****************************************************************************/

/*****************************************************************************/
/* TRANSFER_FUNCTION                                                         */
/*****************************************************************************/

void
Transfer_Function::
poly_serialize(DB::Store_Writer & store) const
{
    Registry<Transfer_Function>::singleton().serialize(store, this);
}

std::shared_ptr<Transfer_Function>
Transfer_Function::
poly_reconstitute(DB::Store_Reader & store)
{
    return Registry<Transfer_Function>::singleton().reconstitute(store);
}

distribution<float>
Transfer_Function::
transfer(const distribution<float> & activation) const
{
    int no = activation.size();
    distribution<float> output(no);
    transfer(&activation[0], &output[0], no);
    return output;
}

distribution<double>
Transfer_Function::
transfer(const distribution<double> & activation) const
{
    int no = activation.size();
    distribution<double> output(no);
    transfer(&activation[0], &output[0], no);
    return output;
}

distribution<float>
Transfer_Function::
derivative(const distribution<float> & outputs) const
{
    int no = outputs.size();
    distribution<float> result(no);
    derivative(&outputs[0], &result[0], no);
    return result;
}

distribution<double>
Transfer_Function::
derivative(const distribution<double> & outputs) const
{
    int no = outputs.size();
    distribution<double> result(no);
    derivative(&outputs[0], &result[0], no);
    return result;
}

distribution<float>
Transfer_Function::
second_derivative(const distribution<float> & outputs) const
{
    int no = outputs.size();
    distribution<float> result(no);
    second_derivative(&outputs[0], &result[0], no);
    return result;
}

distribution<double>
Transfer_Function::
second_derivative(const distribution<double> & outputs) const
{
    int no = outputs.size();
    distribution<double> result(no);
    second_derivative(&outputs[0], &result[0], no);
    return result;
}

/*****************************************************************************/
/* STANDARD_TRANSFER_FUNCTION                                                */
/*****************************************************************************/

Standard_Transfer_Function::
Standard_Transfer_Function(Transfer_Function_Type transfer_function)
    : transfer_function(transfer_function)
{
}

std::string
Standard_Transfer_Function::
print() const
{
    return ML::print(transfer_function);
}

Range
Standard_Transfer_Function::
range() const
{
    static Range ranges[5] = {
        { -INFINITY, INFINITY, 0.0, false, false, RT_PM_INF },  /* TF_LOGSIG */
        { -1.0,      1.0,      0.0, true,  true,  RT_PM_ONE },  /* TF_TANH */
        { -1.7159,   1.7159,   0.0, true,  true,  RT_OTHER  },  /* TF_TANHS */
        { -INFINITY, INFINITY, 0.0, false, false, RT_PM_INF }, /* TF_IDENTITY */
        { 0.0,       1.0,      0.5, true,  true,  RT_PROB   }  /* TF_SOFTMAX */};

    BOOST_STATIC_ASSERT(TF_LOGSIG   == 0);
    BOOST_STATIC_ASSERT(TF_TANH     == 1);
    BOOST_STATIC_ASSERT(TF_TANHS    == 2);
    BOOST_STATIC_ASSERT(TF_IDENTITY == 3);
    BOOST_STATIC_ASSERT(TF_SOFTMAX  == 4);

    if (transfer_function <= TF_SOFTMAX)
        return ranges[transfer_function];

    throw Exception("Standard_Transfer_Function::range(): non-standard");
}

std::pair<float, float>
Standard_Transfer_Function::
targets(float maximum) const
{
    switch (transfer_function) {
    case TF_TANH:
    case TF_IDENTITY: return std::make_pair(-maximum, maximum);
    case TF_TANHS: return make_pair(-1.0, 1.0);
    case TF_SOFTMAX:
    case TF_LOGSIG: return std::make_pair(0.0f, maximum);
    default:
        throw Exception("Layer::targets(): invalid transfer_function");
    }
}

void
Standard_Transfer_Function::
serialize(DB::Store_Writer & store) const
{
    store << (char)0 // version
          << transfer_function;
}

void
Standard_Transfer_Function::
reconstitute(DB::Store_Reader & store)
{
    char version;
    store >> version;
    if (version != 0)
        throw Exception("Standard_Transfer_Function::reconstitute(): "
                        "unknown version");
    store >> transfer_function;
}

std::string
Standard_Transfer_Function::
class_id() const
{
    return "Standard";
}

bool
Standard_Transfer_Function::
equal(const Transfer_Function & other) const
{
    const Standard_Transfer_Function * other_cast
        = dynamic_cast<const Standard_Transfer_Function *>(&other);
    if (!other_cast)
        return false;  // not a standard transfer function...

    return transfer_function == other_cast->transfer_function;
}

template<typename FloatIn>
void
Standard_Transfer_Function::
transfer(const FloatIn * activation, FloatIn * outputs, int nvals,
         Transfer_Function_Type transfer_function)
{
    switch (transfer_function) {
    case TF_IDENTITY:
        std::copy(activation, activation + nvals, outputs);
        return;

    case TF_LOGSIG:
        for (unsigned i = 0;  i < nvals;  ++i) {
            // See https://bugzilla.redhat.com/show_bug.cgi?id=521190
            // for why we use double version of exp
            outputs[i] = 1.0 / (1.0 + exp((double)-activation[i]));
        }
        break;

    case TF_TANH:
        for (unsigned i = 0;  i < nvals;  ++i)
            outputs[i] = tanh(activation[i]);
        break;

    case TF_TANHS:
        for (unsigned i = 0;  i < nvals;  ++i)
            outputs[i] = 1.7159 * tanh(0.66666666666666666666 * activation[i]);
        break;

    case TF_SOFTMAX: {
        double total = 0.0;

        for (unsigned i = 0;  i < nvals;  ++i) {
            // See https://bugzilla.redhat.com/show_bug.cgi?id=521190
            // for why we use double version of exp
            total += (outputs[i] = exp((double)activation[i]));
        }

        double factor = 1.0 / total;

        for (unsigned i = 0;  i < nvals;  ++i)
            outputs[i] *= factor;

        break;
    }

    default:
        throw Exception("Standard_Transfer_Function::transfer(): invalid transfer_function");
    }
}

void
Standard_Transfer_Function::
transfer(const float * activation, float * outputs, size_t n) const
{
    transfer(activation, outputs, n, transfer_function);
}

void
Standard_Transfer_Function::
transfer(const double * activation, double * outputs, size_t n) const
{
    transfer(activation, outputs, n, transfer_function);
}

template<typename FloatIn>
void
Standard_Transfer_Function::
derivative(const FloatIn * outputs, FloatIn * deriv, int nvals,
           Transfer_Function_Type transfer_function)
{
    switch (transfer_function) {

    case TF_IDENTITY:
        std::fill(deriv, deriv + nvals, 1.0);
        break;

    case TF_LOGSIG:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = outputs[i] * (1.0 - outputs[i]);
        break;

    case TF_TANH:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = 1.0 - (outputs[i] * outputs[i]);
        break;

    case TF_TANHS:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = 1.7159 * 0.6666666666666
                * (1.0 - (outputs[i] * outputs[i]));
        break;

    case TF_SOFTMAX:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = 1.0 / outputs[i];
        break;

    default:
        throw Exception("Standard_Transfer_Function::transfer(): invalid transfer_function");
    }
}

void
Standard_Transfer_Function::
derivative(const float * outputs, float * derivatives, size_t n) const
{
    derivative(outputs, derivatives, n, transfer_function);
}

void
Standard_Transfer_Function::
derivative(const double * outputs, double * derivatives, size_t n) const
{
    derivative(outputs, derivatives, n, transfer_function);
}

template<typename FloatIn>
void
Standard_Transfer_Function::
second_derivative(const FloatIn * outputs, FloatIn * deriv, int nvals,
                  Transfer_Function_Type transfer_function)
{
    switch (transfer_function) {

    case TF_IDENTITY:
        std::fill(deriv, deriv + nvals, 0.0);
        break;

    case TF_TANH:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = -2.0 * outputs[i] * (1.0 - (outputs[i] * outputs[i]));
        break;

    case TF_TANHS:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = 1.7159 * 0.6666666666666 * 0.6666666666666
                * -2.0 * outputs[i] * (1.0 - (outputs[i] * outputs[i]));
        break;

    case TF_LOGSIG:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = outputs[i] * (1 - outputs[i]) * (1 - 2 * outputs[i]);
        break;

#if 0
    case TF_SOFTMAX:
        for (unsigned i = 0;  i < nvals;  ++i)
            deriv[i] = ...;
        break;
#endif

    default:
        throw Exception("Standard_Transfer_Function::transfer(): second derivative not implemented "
                        "for this transfer_function "
                        + ML::print(transfer_function));
    }
}

void
Standard_Transfer_Function::
second_derivative(const float * outputs, float * second_derivatives,
                  size_t n) const
{
    second_derivative(outputs, second_derivatives, n, transfer_function);
}

void
Standard_Transfer_Function::
second_derivative(const double * outputs, double * second_derivatives,
                  size_t n) const
{
    second_derivative(outputs, second_derivatives, n, transfer_function);
}

namespace {

Register_Factory<Transfer_Function, Standard_Transfer_Function>
    STF_REGISTER("Standard");

} // file scope

/*****************************************************************************/
/* FACTORY                                                                   */
/*****************************************************************************/

std::shared_ptr<Transfer_Function>
create_transfer_function(const Transfer_Function_Type & function)
{
    return make_sp(new Standard_Transfer_Function(function));
}

std::shared_ptr<Transfer_Function>
create_transfer_function(const std::string & name)
{
    throw Exception("create_transfer_function(name): not implemented");
}

} // namespace ML

ext: cc

max_stars_repo_name: etnrlz/rtbkit

max_issues_repo_name: TuanTranEngineer/rtbkit

max_forks_repo_name: TuanTranEngineer/rtbkit


text:
// Copyright (c) 2012, Yahoo! Inc.  All rights reserved.
// Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.

#include <gearbox/core/TempFile.h>
#include <gearbox/core/Errors.h>

#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <boost/filesystem/operations.hpp>
namespace bfs=boost::filesystem;

namespace Gearbox {

    TempFile::TempFile(const std::string & prefix) : name_(prefix + "XXXXXX") {
        mode_t prev = umask(0077);
        this->fd_ = mkstemp( const_cast<char*>(name_.data()) );
        umask(prev);
        if (this->fd_ < 0) {
            gbTHROW( ERR_LIBC("failed to create tempfile") );
        }
    }

    TempFile::~TempFile() {
        this->unlink();
    }

    void TempFile::release() {
        this->fd_ = -1;
        this->name_.clear();
    }

    void TempFile::unlink() const {
        if( !name_.empty() && bfs::exists(name_) ) {
            bfs::remove(name_);
        }
    }

    const std::string & TempFile::name() const {
        return name_;
    }
}

max_stars_repo_name: coryb/gearbox

max_issues_repo_name: coryb/gearbox

max_forks_repo_name: coryb/gearbox


text:
/***********************************************************************
 *    created:    5/7/2011
 *    author:     Martin Preisler
 *************************************************************************/
/***************************************************************************
 *   Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
 *
 *   Permission is hereby granted, free of charge, to any person obtaining
 *   a copy of this software and associated documentation files (the
 *   "Software"), to deal in the Software without restriction, including
 *   without limitation the rights to use, copy, modify, merge, publish,
 *   distribute, sublicense, and/or sell copies of the Software, and to
 *   permit persons to whom the Software is furnished to do so, subject to
 *   the following conditions:
 *
 *   The above copyright notice and this permission notice shall be
 *   included in all copies or substantial portions of the Software.
 *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *   OTHER DEALINGS IN THE SOFTWARE.
 ***************************************************************************/

#include "CEGUI/Vector.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(Vector)

BOOST_AUTO_TEST_CASE(ConstructionAssignment2)
{
    CEGUI::Vector2f a(1, 0);
    CEGUI::Vector2f b(0, 1);
    CEGUI::Vector2f c(2, 2);
    CEGUI::Vector2f d(2, 1);
    CEGUI::Vector2f e(1, 2);

    BOOST_CHECK_EQUAL(a + b, CEGUI::Vector2f(1, 1));
    BOOST_CHECK_EQUAL(a - b, CEGUI::Vector2f(1, -1));

    BOOST_CHECK_EQUAL(a * c, CEGUI::Vector2f(2, 0));
    BOOST_CHECK_EQUAL(b * c, CEGUI::Vector2f(0, 2));
    BOOST_CHECK_EQUAL(c * d, CEGUI::Vector2f(4, 2));
    BOOST_CHECK_EQUAL(c * e, CEGUI::Vector2f(2, 4));

    BOOST_CHECK_EQUAL(a * 2, CEGUI::Vector2f(2, 0));
    BOOST_CHECK_EQUAL(b * 2, CEGUI::Vector2f(0, 2));
}

BOOST_AUTO_TEST_CASE(ConstructionAssignment3)
{
    CEGUI::Vector3f a(1, 0, 0);
    CEGUI::Vector3f b(0, 1, 0);
    CEGUI::Vector3f c(0, 0, 1);

    BOOST_CHECK_EQUAL(a + b, CEGUI::Vector3f(1, 1, 0));
    BOOST_CHECK_EQUAL(a - b, CEGUI::Vector3f(1, -1, 0));

    BOOST_CHECK_EQUAL(a * 2, CEGUI::Vector3f(2, 0, 0));
    BOOST_CHECK_EQUAL(b * 2, CEGUI::Vector3f(0, 2, 0));
    BOOST_CHECK_EQUAL(c * 2, CEGUI::Vector3f(0, 0, 2));

    BOOST_CHECK_EQUAL(CEGUI::Vector3f::one(), CEGUI::Vector3f::one_x() + CEGUI::Vector3f::one_y() + CEGUI::Vector3f::one_z());
}

BOOST_AUTO_TEST_CASE(Constants2)
{
    BOOST_CHECK_EQUAL(CEGUI::Vector2f::zero(), CEGUI::Vector2f(0, 0));
    BOOST_CHECK_EQUAL(CEGUI::Vector2f::one(), CEGUI::Vector2f(1, 1));
    BOOST_CHECK_EQUAL(CEGUI::Vector2f::one_x(), CEGUI::Vector2f(1, 0));
    BOOST_CHECK_EQUAL(CEGUI::Vector2f::one_y(), CEGUI::Vector2f(0, 1));

    BOOST_CHECK_EQUAL(CEGUI::UVector2::zero(), CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
    BOOST_CHECK_EQUAL(CEGUI::UVector2::one(), CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));
    BOOST_CHECK_EQUAL(CEGUI::UVector2::one_x(), CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(0, 0)));
    BOOST_CHECK_EQUAL(CEGUI::UVector2::one_y(), CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(1, 0)));

    // test if it works with the UDim zero and relative
    BOOST_CHECK_EQUAL(CEGUI::UVector2::zero(), CEGUI::UVector2(CEGUI::UDim::zero(), CEGUI::UDim::zero()));
    BOOST_CHECK_EQUAL(CEGUI::UVector2::one(), CEGUI::UVector2(CEGUI::UDim::relative(), CEGUI::UDim::relative()));
    BOOST_CHECK_EQUAL(CEGUI::UVector2::one_x(), CEGUI::UVector2(CEGUI::UDim::relative(), CEGUI::UDim::zero()));
    BOOST_CHECK_EQUAL(CEGUI::UVector2::one_y(), CEGUI::UVector2(CEGUI::UDim::zero(), CEGUI::UDim::relative()));
}

BOOST_AUTO_TEST_CASE(Constants3)
{
    BOOST_CHECK_EQUAL(CEGUI::Vector3f::zero(), CEGUI::Vector3f(0, 0, 0));
    BOOST_CHECK_EQUAL(CEGUI::Vector3f::one(), CEGUI::Vector3f(1, 1, 1));

    BOOST_CHECK_EQUAL(CEGUI::Vector3f::one_x(), CEGUI::Vector3f(1, 0, 0));
    BOOST_CHECK_EQUAL(CEGUI::Vector3f::one_y(), CEGUI::Vector3f(0, 1, 0));
    BOOST_CHECK_EQUAL(CEGUI::Vector3f::one_z(), CEGUI::Vector3f(0, 0, 1));
}

BOOST_AUTO_TEST_SUITE_END()


text:
#ifndef __FS_UTILITY_HPP__
#define __FS_UTILITY_HPP__
#include <boost/filesystem.hpp>
namespace bfs=boost::filesystem;

/* make multi-level directory */
void makedirs(const bfs::path& inpath);

/* walk throuth the directory */
template<typename WalkAction>
bool walk(const bfs::path& inpath, WalkAction action, bool recursive)
{
	if (bfs::is_directory(inpath))
	{
		if (recursive)
		{
			for(auto entry=bfs::recursive_directory_iterator(inpath);entry!=bfs::recursive_directory_iterator();++entry)
			{
				action(entry->path());
			}
		}
		else
		{
			for(auto entry=bfs::directory_iterator(inpath);entry!=bfs::directory_iterator();++entry)
			{
				action(entry->path());
			}
		}
		return true;
	}
	else
	{
		return false;
	}
}

/* find executable file in the environment */
void findInPath(const std::string& filename, std::initializer_list<std::string> additions, std::vector<bfs::path>& result, int count=-1);

#endif /* __FS_UTILITY_HPP__ */


text:
#ifndef INCLUDED_DAL_TABLEDAL
#include "dal_TableDal.h"
#define INCLUDED_DAL_TABLEDAL
#endif

// Library headers.
#ifndef INCLUDED_BOOST_SCOPED_PTR
#include <boost/scoped_ptr.hpp>
#define INCLUDED_BOOST_SCOPED_PTR
#endif

// PCRaster library headers.
#ifndef INCLUDED_QSTRINGLIST
#include <QStringList>
#define INCLUDED_QSTRINGLIST
#endif

#ifndef INCLUDED_QSQLDATABASE
#include <QSqlDatabase>
#define INCLUDED_QSQLDATABASE
#endif

// Module headers.
#ifndef INCLUDED_DAL_GEOEASTABLEDRIVER
#include "dal_GeoEASTableDriver.h"
#define INCLUDED_DAL_GEOEASTABLEDRIVER
#endif

#ifndef INCLUDED_DAL_SQLTABLEDRIVER
#include "dal_SQLTableDriver.h"
#define INCLUDED_DAL_SQLTABLEDRIVER
#endif

#ifndef INCLUDED_DAL_TEXTTABLEDRIVER
#include "dal_TextTableDriver.h"
#define INCLUDED_DAL_TEXTTABLEDRIVER
#endif

#ifndef INCLUDED_DAL_UTILS
#include "dal_Utils.h"
#define INCLUDED_DAL_UTILS
#endif

/*!
  \file
  This file contains the implementation of the TableDal class.
*/

namespace dal {

//------------------------------------------------------------------------------
// DEFINITION OF STATIC TABLEDAL MEMBERS
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// DEFINITION OF TABLEDAL MEMBERS
//------------------------------------------------------------------------------

//! Constructor.
/*!
  \param     addAllDrivers Whether or not to add all available drivers automatically.
*/
TableDal::TableDal(bool addAllDrivers)

  : Dal(false)

{
  if(addAllDrivers) {
    #include "autoAddTableDrivers.cc"
  }
}

//! Destructor.
/*!
*/
TableDal::~TableDal()
{
}

//! Opens the tabular dataset pointed to by name.
/*!
  \param     name Name of table dataset.
  \return    A pointer to a newly created Table object or 0 if no driver could
             open \a name.

  The caller is responsible of deleting the Table object again.
*/
boost::tuple<boost::shared_ptr<Table>, TableDriver*> TableDal::open(
         std::string const& name,
         bool raiseException)
{
  assert(nrDrivers() > 0);
  boost::shared_ptr<Dataset> dataset;
  Driver* driver;
  boost::tie(dataset, driver) = Dal::open(name, TABLE);

  // Table* table = dynamic_cast<Table*>(Dal::open(name, TABLE));

  if(!dataset && raiseException) {
    throwCannotBeOpened(name, TABLE);
  }

  return boost::make_tuple(boost::dynamic_pointer_cast<Table>(dataset),
      dynamic_cast<TableDriver*>(driver));
}

//! Reads the tabular dataset pointed to by \a name.
/*!
  \param     name Name of table dataset.
  \param     typeId Type id of values to use.
  \return    A pointer to a newly created Table object.
  \exception Exception If no driver could read \a name.

  The caller is responsible of deleting the Table object again.
*/
Table* TableDal::read(std::string const& name, TypeId typeId)
{
  assert(nrDrivers() > 0);

  TableDriver* driver;
  boost::tie(boost::tuples::ignore, driver) = open(name, true);
  assert(driver);

  return driver->read(name, typeId);
}

//! Reads the tabular dataset pointed to by \a name into \a table.
/*!
  \param     name Name of table dataset.
  \param     table Table object to fill.
  \exception Exception If no driver could read \a name.
  \warning   The configuration of \a table (nrRows, nrCols, typeId of the
             columns) must be in sync with the information in \a name.
  \sa        TableDriver::read(std::string const&, Table&)
*/
void TableDal::read(
         std::string const& name,
         Table& table)
{
  assert(nrDrivers() > 0);

  TableDriver* driver;
  boost::tie(boost::tuples::ignore, driver) = open(name, true);
  assert(driver);

  driver->read(table, name);
}

TableDriver* TableDal::driverByDataset(
         std::string const& name)
{
  return dynamic_cast<TableDriver*>(Dal::driverByDataset(name, DataSpace()));
}

TableDriver* TableDal::driverByName(
         std::string const& name)
{
  return dynamic_cast<TableDriver*>(Dal::driverByName(name));
}

//------------------------------------------------------------------------------
// DEFINITION OF FREE OPERATORS
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// DEFINITION OF FREE FUNCTIONS
//------------------------------------------------------------------------------

} // namespace dal

max_stars_repo_name: quanpands/wflow

max_issues_repo_name: quanpands/wflow

max_forks_repo_name: quanpands/wflow


text:
#ifdef __cplusplus
extern "C" {
#endif

#include "lauxlib.h"
#include "lua.h"
#include "lualib.h"

#ifdef __cplusplus
}
#endif

#if defined(LUA_BUILD_AS_DLL)
#if defined(LUA_CORE) || defined(LUA_LIB)
#define LUA_API __declspec(dllexport)
#else
#define LUA_API __declspec(dllimport)
#endif
#else
#define LUA_API extern
#endif

#ifdef __cplusplus
extern "C" {
#endif
LUA_API int luaopen_queue(lua_State *L);
#ifdef __cplusplus
};
#endif

#include <boost/lockfree/queue.hpp>
#include <map>
#include <string>

#define MAX_SIZE 65536

static std::map<std::string, boost::lockfree::queue<std::string *> *> queue;

std::string *luaL_getbstring(lua_State *l, size_t index) {
  std::string *s = new std::string();
  size_t size;
  const char *data = luaL_checklstring(l, index, &size);
  s->assign(data, size);
  return s;
};

void luaL_getbstring(lua_State *l, size_t index, std::string &s) {
  size_t size;
  const char *data = luaL_checklstring(l, index, &size);
  s.assign(data, size);
};

void luaL_pushbstring(lua_State *l, const std::string *s) {
  luaL_Buffer b;
  luaL_buffinit(l, &b);
  luaL_addlstring(&b, s->c_str(), s->size());
  luaL_pushresult(&b);
  delete s;
};

void luaL_pushbstring(lua_State *l, const std::string &s) {
  luaL_Buffer b;
  luaL_buffinit(l, &b);
  luaL_addlstring(&b, s.c_str(), s.size());
  luaL_pushresult(&b);
};

static int l_push(lua_State *l) {
  std::string key;
  std::string *content;
  int n = lua_gettop(l);
  if (n >= 1) luaL_getbstring(l, 1, key);
  if (n >= 2) content = luaL_getbstring(l, 2);

  if (queue.find(key) == queue.end()) {
    queue.insert(
        make_pair(key, new boost::lockfree::queue<std::string *>(MAX_SIZE)));
  }

  bool ret = queue[key]->push(content);

  lua_pushboolean(l, ret);

  return 1;
};

static int l_pop(lua_State *l) {
  std::string key;
  std::string *content;
  int n = lua_gettop(l);
  if (n >= 1) luaL_getbstring(l, 1, key);

  if (queue.find(key) == queue.end()) {
    queue.insert(
        make_pair(key, new boost::lockfree::queue<std::string *>(MAX_SIZE)));
  }

  bool ret = queue[key]->pop(content);

  lua_pushboolean(l, ret);
  if (ret) {
    luaL_pushbstring(l, content);
    return 2;
  } else {
    return 1;
  }
};

static const luaL_Reg queue_module[] = {
    {"push", l_push}, {"pop", l_pop}, {NULL, NULL}};

int luaopen_queue(lua_State *L) {
  luaL_register(L, "queue", queue_module);
  return 1;
}

max_stars_repo_name: lizongti/rocks

max_issues_repo_name: lizongti/rocks

max_forks_repo_name: lizongti/rocks


text:
/**************************************************************
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 *************************************************************/

#ifndef _SVX_DRAWITEM_HXX
#define _SVX_DRAWITEM_HXX

// include ---------------------------------------------------------------

#include <svl/poolitem.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/drawing/LineDash.hpp>
#include "svx/svxdllapi.h"
#include <boost/shared_ptr.hpp>

//==================================================================
//	SvxColorTableItem
//==================================================================

class XColorList;
typedef ::boost::shared_ptr< XColorList > XColorListSharedPtr;

class SVX_DLLPUBLIC SvxColorTableItem : public SfxPoolItem
{
	XColorListSharedPtr     maColorTable;

public:
							TYPEINFO();
							SvxColorTableItem();
							SvxColorTableItem( XColorListSharedPtr aTable, sal_uInt16 nWhich );
							SvxColorTableItem( const SvxColorTableItem& );

	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
									SfxMapUnit eCoreMetric,
									SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;

	virtual int 			operator==( const SfxPoolItem& ) const;
	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
	virtual	sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
    virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId );

    XColorListSharedPtr GetColorTable() const { return maColorTable; }
    void SetColorTable( XColorListSharedPtr aTable ) { maColorTable = aTable; }
};

//==================================================================
//	SvxGradientListItem
//==================================================================

class XGradientList;
typedef ::boost::shared_ptr< XGradientList > XGradientListSharedPtr;

class SVX_DLLPUBLIC SvxGradientListItem : public SfxPoolItem
{
	XGradientListSharedPtr  maGradientList;

public:
							TYPEINFO();
							SvxGradientListItem();
							SvxGradientListItem( XGradientListSharedPtr aList, sal_uInt16 nWhich  );
							SvxGradientListItem( const SvxGradientListItem& );

	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
									SfxMapUnit eCoreMetric,
									SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;

	virtual int 			operator==( const SfxPoolItem& ) const;
	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
	virtual	sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
    virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId );

    XGradientListSharedPtr GetGradientList() const { return maGradientList; }
    void SetGradientList(XGradientListSharedPtr aList ) { maGradientList = aList; }
};

//==================================================================
//	SvxHatchListItem
//==================================================================

class XHatchList;
typedef ::boost::shared_ptr< XHatchList > XHatchListSharedPtr;

class SVX_DLLPUBLIC SvxHatchListItem : public SfxPoolItem
{
	XHatchListSharedPtr     maHatchList;

public:
							TYPEINFO();
							SvxHatchListItem();
							SvxHatchListItem( XHatchListSharedPtr aList, sal_uInt16 nWhich  );
							SvxHatchListItem( const SvxHatchListItem& );

	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
									SfxMapUnit eCoreMetric,
									SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;

	virtual int 			operator==( const SfxPoolItem& ) const;
	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
	virtual	sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
    virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId );

    XHatchListSharedPtr GetHatchList() const { return maHatchList; }
    void SetHatchList(XHatchListSharedPtr aList ) { maHatchList = aList; }
};

//==================================================================
//	SvxBitmapListItem
//==================================================================

class XBitmapList;
typedef ::boost::shared_ptr< XBitmapList > XBitmapListSharedPtr;

class SVX_DLLPUBLIC SvxBitmapListItem : public SfxPoolItem
{
	XBitmapListSharedPtr    maBitmapList;

public:
							TYPEINFO();
							SvxBitmapListItem();
							SvxBitmapListItem( XBitmapListSharedPtr aBL, sal_uInt16 nWhich  );
							SvxBitmapListItem( const SvxBitmapListItem& );

	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
									SfxMapUnit eCoreMetric,
									SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;

	virtual int 			operator==( const SfxPoolItem& ) const;
	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
	virtual	sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
    virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId );

    XBitmapListSharedPtr GetBitmapList() const { return maBitmapList; }
    void SetBitmapList(XBitmapListSharedPtr aList ) { maBitmapList = aList; }
};

//==================================================================
//	SvxDashListItem
//==================================================================

class XDashList;
typedef ::boost::shared_ptr< XDashList > XDashListSharedPtr;

class SVX_DLLPUBLIC SvxDashListItem : public SfxPoolItem
{
	XDashListSharedPtr      maDashList;

public:
							TYPEINFO();
							SvxDashListItem();
							SvxDashListItem( XDashListSharedPtr aList, sal_uInt16 nWhich  );
							SvxDashListItem( const SvxDashListItem& );

	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
									SfxMapUnit eCoreMetric,
									SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;

	virtual int 			operator==( const SfxPoolItem& ) const;
	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
	virtual	sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
    virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId );

    XDashListSharedPtr GetDashList() const { return maDashList; }
    void SetDashList(XDashListSharedPtr aList) { maDashList = aList; }
};

//==================================================================
//	SvxLineEndListItem
//==================================================================

class XLineEndList;
typedef ::boost::shared_ptr< XLineEndList > XLineEndListSharedPtr;

class SVX_DLLPUBLIC SvxLineEndListItem : public SfxPoolItem
{
	XLineEndListSharedPtr   maLineEndList;

public:
							TYPEINFO();
							SvxLineEndListItem();
							SvxLineEndListItem( XLineEndListSharedPtr aList, sal_uInt16 nWhich  );
							SvxLineEndListItem( const SvxLineEndListItem& );

	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
									SfxMapUnit eCoreMetric,
									SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;

	virtual int 			operator==( const SfxPoolItem& ) const;
	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
	virtual	sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
    virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId );

    XLineEndListSharedPtr GetLineEndList() const { return maLineEndList; }
    void SetLineEndList(XLineEndListSharedPtr aList ) { maLineEndList = aList; }
};

#endif

max_stars_repo_name: Grosskopf/openoffice

max_issues_repo_name: Grosskopf/openoffice

max_forks_repo_name: Grosskopf/openoffice


text:
/**
 * Mojang Authentication API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * OpenAPI spec version: 2020-06-05
 *
 *
 * NOTE: This class is auto generated by OpenAPI-Generator 3.3.4.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#include "GameProfile.h"

#include <string>
#include <sstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>

using boost::property_tree::ptree;
using boost::property_tree::read_json;
using boost::property_tree::write_json;

namespace com {
namespace github {
namespace asyncmc {
namespace mojang {
namespace authentication {
namespace cpp {
namespace restbed {
namespace server {
namespace model {

GameProfile::GameProfile()
{
    m_Agent = "";
    m_Id = "";
    m_Name = "";
    m_UserId = "";
    m_CreatedAt = 0L;
    m_LegacyProfile = false;
    m_Suspended = false;
    m_Paid = false;
    m_Migrated = false;
    m_Legacy = false;

}

GameProfile::~GameProfile()
{
}

std::string GameProfile::toJsonString()
{
	std::stringstream ss;
	ptree pt;
	pt.put("Agent", m_Agent);
	pt.put("Id", m_Id);
	pt.put("Name", m_Name);
	pt.put("UserId", m_UserId);
	pt.put("CreatedAt", m_CreatedAt);
	pt.put("LegacyProfile", m_LegacyProfile);
	pt.put("Suspended", m_Suspended);
	pt.put("Paid", m_Paid);
	pt.put("Migrated", m_Migrated);
	pt.put("Legacy", m_Legacy);
	write_json(ss, pt, false);
	return ss.str();
}

void GameProfile::fromJsonString(std::string const& jsonString)
{
	std::stringstream ss(jsonString);
	ptree pt;
	read_json(ss,pt);
	m_Agent = pt.get("Agent", "");
	m_Id = pt.get("Id", "");
	m_Name = pt.get("Name", "");
	m_UserId = pt.get("UserId", "");
	m_CreatedAt = pt.get("CreatedAt", 0L);
	m_LegacyProfile = pt.get("LegacyProfile", false);
	m_Suspended = pt.get("Suspended", false);
	m_Paid = pt.get("Paid", false);
	m_Migrated = pt.get("Migrated", false);
	m_Legacy = pt.get("Legacy", false);
}

std::string GameProfile::getAgent() const
{
    return m_Agent;
}
void GameProfile::setAgent(std::string value)
{
    m_Agent = value;
}
std::string GameProfile::getId() const
{
    return m_Id;
}
void GameProfile::setId(std::string value)
{
    m_Id = value;
}
std::string GameProfile::getName() const
{
    return m_Name;
}
void GameProfile::setName(std::string value)
{
    m_Name = value;
}
std::string GameProfile::getUserId() const
{
    return m_UserId;
}
void GameProfile::setUserId(std::string value)
{
    m_UserId = value;
}
int64_t GameProfile::getCreatedAt() const
{
    return m_CreatedAt;
}
void GameProfile::setCreatedAt(int64_t value)
{
    m_CreatedAt = value;
}
bool GameProfile::isLegacyProfile() const
{
    return m_LegacyProfile;
}
void GameProfile::setLegacyProfile(bool value)
{
    m_LegacyProfile = value;
}
bool GameProfile::isSuspended() const
{
    return m_Suspended;
}
void GameProfile::setSuspended(bool value)
{
    m_Suspended = value;
}
bool GameProfile::isPaid() const
{
    return m_Paid;
}
void GameProfile::setPaid(bool value)
{
    m_Paid = value;
}
bool GameProfile::isMigrated() const
{
    return m_Migrated;
}
void GameProfile::setMigrated(bool value)
{
    m_Migrated = value;
}
bool GameProfile::isLegacy() const
{
    return m_Legacy;
}
void GameProfile::setLegacy(bool value)
{
    m_Legacy = value;
}

}
}
}
}
}
}
}
}
}

max_stars_repo_name: AsyncMC/Mojang-API-Libs

max_issues_repo_name: AsyncMC/Mojang-API-Libs

max_forks_repo_name: AsyncMC/Mojang-API-Libs


text:
#include <iostream>
#include <string>
#include <algorithm>
#include <boost/algorithm/string.hpp>

struct Data {
  std::string name;
  int speed;
  int runningTime;
  int restingTime;

  int cycleTime() {
    return runningTime + restingTime;
  }
};

size_t parse_line(const std::string& line);

int main (int argc, char** argv) {
  std::string line;
  std::getline(std::cin, line);
  size_t simulationTime = std::stoi(line);
  std::getline(std::cin, line);

  std::vector<Data> dataList;

  while(!std::cin.eof()) {
    std::vector<std::string> chunks;
    boost::split(chunks, line, boost::is_any_of(" "));
    Data d {chunks[0], std::stoi(chunks[3]), std::stoi(chunks[6]), std::stoi(chunks[13])};
    dataList.push_back(d);
    std::getline(std::cin, line);
  }

  int maxDistance = 0;
  for(Data& d : dataList) {
    size_t cycles = simulationTime / d.cycleTime();
    int distance = cycles * d.speed * d.runningTime;
    if((cycles * d.cycleTime()) < simulationTime) {
      int rest = simulationTime - (cycles * d.cycleTime());
      if(d.runningTime < rest) {
	distance += d.speed * d.runningTime;
      } else {
	distance += d.speed * rest;
      }
    }
    if(distance > maxDistance)
      maxDistance = distance;
    std::cout << d.name << ": " << distance << std::endl;
  }

  std::cout << maxDistance << std::endl;

}


text:
/*********************************************************************
*
* Software License Agreement (BSD License)
*
*  Copyright (c) 2008, Willow Garage, Inc.
*  All rights reserved.
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*   * Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer.
*   * Redistributions in binary form must reproduce the above
*     copyright notice, this list of conditions and the following
*     disclaimer in the documentation and/or other materials provided
*     with the distribution.
*   * Neither the name of the Willow Garage nor the names of its
*     contributors may be used to endorse or promote products derived
*     from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
*  POSSIBILITY OF SUCH DAMAGE.
*
* Author: Eitan Marder-Eppstein
*********************************************************************/

#include <base_local_planner/trajectory_planner_ros.h>

#include <sys/time.h>
#include <boost/tokenizer.hpp>

#include <Eigen/Core>
#include <cmath>

#include <ros/console.h>

#include <pluginlib/class_list_macros.h>

#include <base_local_planner/goal_functions.h>
#include <nav_msgs/Path.h>

#include <nav_core/parameter_magic.h>
#include <tf2/utils.h>

//register this planner as a BaseLocalPlanner plugin
PLUGINLIB_EXPORT_CLASS(base_local_planner::TrajectoryPlannerROS, nav_core::BaseLocalPlanner)

namespace base_local_planner {

  void TrajectoryPlannerROS::reconfigureCB(BaseLocalPlannerConfig &config, uint32_t level) {
      if (setup_ && config.restore_defaults) {
        config = default_config_;
        //Avoid looping
        config.restore_defaults = false;
      }
      if ( ! setup_) {
        default_config_ = config;
        setup_ = true;
      }
      tc_->reconfigure(config);
      reached_goal_ = false;
  }

  TrajectoryPlannerROS::TrajectoryPlannerROS() :
      world_model_(NULL), tc_(NULL), costmap_ros_(NULL), tf_(NULL), setup_(false), initialized_(false), odom_helper_("odom") {}

  TrajectoryPlannerROS::TrajectoryPlannerROS(std::string name, tf2_ros::Buffer* tf, costmap_2d::Costmap2DROS* costmap_ros) :
      world_model_(NULL), tc_(NULL), costmap_ros_(NULL), tf_(NULL), setup_(false), initialized_(false), odom_helper_("odom") {

      //initialize the planner
      initialize(name, tf, costmap_ros);
  }

  void TrajectoryPlannerROS::initialize(
      std::string name,
      tf2_ros::Buffer* tf,
      costmap_2d::Costmap2DROS* costmap_ros){
    if (! isInitialized()) {

      ros::NodeHandle private_nh("~/" + name);
      g_plan_pub_ = private_nh.advertise<nav_msgs::Path>("global_plan", 1);
      l_plan_pub_ = private_nh.advertise<nav_msgs::Path>("local_plan", 1);

      tf_ = tf;
      costmap_ros_ = costmap_ros;
      rot_stopped_velocity_ = 1e-2;
      trans_stopped_velocity_ = 1e-2;
      double sim_time, sim_granularity, angular_sim_granularity;
      int vx_samples, vtheta_samples;
      double pdist_scale, gdist_scale, occdist_scale, heading_lookahead, oscillation_reset_dist, escape_reset_dist, escape_reset_theta;
      bool holonomic_robot, dwa, simple_attractor, heading_scoring;
      double heading_scoring_timestep;
      double max_vel_x, min_vel_x;
      double backup_vel;
      double stop_time_buffer;
      std::string world_model_type;
      rotating_to_goal_ = false;

      //initialize the copy of the costmap the controller will use
      costmap_ = costmap_ros_->getCostmap();

      global_frame_ = costmap_ros_->getGlobalFrameID();
      robot_base_frame_ = costmap_ros_->getBaseFrameID();
      private_nh.param("prune_plan", prune_plan_, true);

      private_nh.param("yaw_goal_tolerance", yaw_goal_tolerance_, 0.05);
      private_nh.param("xy_goal_tolerance", xy_goal_tolerance_, 0.10);
      private_nh.param("acc_lim_x", acc_lim_x_, 2.5);
      private_nh.param("acc_lim_y", acc_lim_y_, 2.5);
      private_nh.param("acc_lim_theta", acc_lim_theta_, 3.2);

      private_nh.param("stop_time_buffer", stop_time_buffer, 0.2);

      private_nh.param("latch_xy_goal_tolerance", latch_xy_goal_tolerance_, false);

      //Since I screwed up nicely in my documentation, I'm going to add errors
      //informing the user if they've set one of the wrong parameters
      if(private_nh.hasParam("acc_limit_x"))
        ROS_ERROR("You are using acc_limit_x where you should be using acc_lim_x. Please change your configuration files appropriately. The documentation used to be wrong on this, sorry for any confusion.");

      if(private_nh.hasParam("acc_limit_y"))
        ROS_ERROR("You are using acc_limit_y where you should be using acc_lim_y. Please change your configuration files appropriately. The documentation used to be wrong on this, sorry for any confusion.");

      if(private_nh.hasParam("acc_limit_th"))
        ROS_ERROR("You are using acc_limit_th where you should be using acc_lim_th. Please change your configuration files appropriately. The documentation used to be wrong on this, sorry for any confusion.");

      //Assuming this planner is being run within the navigation stack, we can
      //just do an upward search for the frequency at which its being run. This
      //also allows the frequency to be overwritten locally.
      std::string controller_frequency_param_name;
      if(!private_nh.searchParam("controller_frequency", controller_frequency_param_name))
        sim_period_ = 0.05;
      else
      {
        double controller_frequency = 0;
        private_nh.param(controller_frequency_param_name, controller_frequency, 20.0);
        if(controller_frequency > 0)
          sim_period_ = 1.0 / controller_frequency;
        else
        {
          ROS_WARN("A controller_frequency less than 0 has been set. Ignoring the parameter, assuming a rate of 20Hz");
          sim_period_ = 0.05;
        }
      }
      ROS_INFO("Sim period is set to %.2f", sim_period_);

      private_nh.param("sim_time", sim_time, 1.0);
      private_nh.param("sim_granularity", sim_granularity, 0.025);
      private_nh.param("angular_sim_granularity", angular_sim_granularity, sim_granularity);
      private_nh.param("vx_samples", vx_samples, 3);
      private_nh.param("vtheta_samples", vtheta_samples, 20);

      private_nh.param("path_distance_bias", pdist_scale, 0.6);
      private_nh.param("goal_distance_bias", gdist_scale, 0.8);
      private_nh.param("occdist_scale", occdist_scale, 0.01);

      bool meter_scoring;
      if ( ! private_nh.hasParam("meter_scoring")) {
        ROS_WARN("Trajectory Rollout planner initialized with param meter_scoring not set. Set it to true to make your settings robust against changes of costmap resolution.");
      } else {
        private_nh.param("meter_scoring", meter_scoring, false);

        if(meter_scoring) {
          //if we use meter scoring, then we want to multiply the biases by the resolution of the costmap
          double resolution = costmap_->getResolution();
          gdist_scale *= resolution;
          pdist_scale *= resolution;
          occdist_scale *= resolution;
        } else {
          ROS_WARN("Trajectory Rollout planner initialized with param meter_scoring set to false. Set it to true to make your settings robust against changes of costmap resolution.");
        }
      }

      private_nh.param("heading_lookahead", heading_lookahead, 0.325);
      private_nh.param("oscillation_reset_dist", oscillation_reset_dist, 0.05);
      private_nh.param("escape_reset_dist", escape_reset_dist, 0.10);
      private_nh.param("escape_reset_theta", escape_reset_theta, M_PI_4);
      private_nh.param("holonomic_robot", holonomic_robot, true);
      private_nh.param("max_vel_x", max_vel_x, 0.5);
      private_nh.param("min_vel_x", min_vel_x, 0.1);

      double max_rotational_vel;
      private_nh.param("max_rotational_vel", max_rotational_vel, 1.0);
      max_vel_th_ = max_rotational_vel;
      min_vel_th_ = -1.0 * max_rotational_vel;

      min_in_place_vel_th_ = nav_core::loadParameterWithDeprecation(private_nh,
                                                                    "min_in_place_vel_theta",
                                                                    "min_in_place_rotational_vel", 0.4);
      reached_goal_ = false;
      backup_vel = -0.1;
      if(private_nh.getParam("backup_vel", backup_vel))
        ROS_WARN("The backup_vel parameter has been deprecated in favor of the escape_vel parameter. To switch, just change the parameter name in your configuration files.");

      //if both backup_vel and escape_vel are set... we'll use escape_vel
      private_nh.getParam("escape_vel", backup_vel);

      if(backup_vel >= 0.0)
        ROS_WARN("You've specified a positive escape velocity. This is probably not what you want and will cause the robot to move forward instead of backward. You should probably change your escape_vel parameter to be negative");

      private_nh.param("world_model", world_model_type, std::string("costmap"));
      private_nh.param("dwa", dwa, true);
      private_nh.param("heading_scoring", heading_scoring, false);
      private_nh.param("heading_scoring_timestep", heading_scoring_timestep, 0.8);

      simple_attractor = false;

      //parameters for using the freespace controller
      double min_pt_separation, max_obstacle_height, grid_resolution;
      private_nh.param("point_grid/max_sensor_range", max_sensor_range_, 2.0);
      private_nh.param("point_grid/min_pt_separation", min_pt_separation, 0.01);
      private_nh.param("point_grid/max_obstacle_height", max_obstacle_height, 2.0);
      private_nh.param("point_grid/grid_resolution", grid_resolution, 0.2);

      ROS_ASSERT_MSG(world_model_type == "costmap", "At this time, only costmap world models are supported by this controller");
      world_model_ = new CostmapModel(*costmap_);
      std::vector<double> y_vels = loadYVels(private_nh);

      footprint_spec_ = costmap_ros_->getRobotFootprint();

      tc_ = new TrajectoryPlanner(*world_model_, *costmap_, footprint_spec_,
          acc_lim_x_, acc_lim_y_, acc_lim_theta_, sim_time, sim_granularity, vx_samples, vtheta_samples, pdist_scale,
          gdist_scale, occdist_scale, heading_lookahead, oscillation_reset_dist, escape_reset_dist, escape_reset_theta, holonomic_robot,
          max_vel_x, min_vel_x, max_vel_th_, min_vel_th_, min_in_place_vel_th_, backup_vel,
          dwa, heading_scoring, heading_scoring_timestep, meter_scoring, simple_attractor, y_vels, stop_time_buffer, sim_period_, angular_sim_granularity);

      map_viz_.initialize(name, global_frame_, boost::bind(&TrajectoryPlanner::getCellCosts, tc_, _1, _2, _3, _4, _5, _6));
      initialized_ = true;

      dsrv_ = new dynamic_reconfigure::Server<BaseLocalPlannerConfig>(private_nh);
      dynamic_reconfigure::Server<BaseLocalPlannerConfig>::CallbackType cb = boost::bind(&TrajectoryPlannerROS::reconfigureCB, this, _1, _2);
      dsrv_->setCallback(cb);

    } else {
      ROS_WARN("This planner has already been initialized, doing nothing");
    }
  }

  std::vector<double> TrajectoryPlannerROS::loadYVels(ros::NodeHandle node){
    std::vector<double> y_vels;

    std::string y_vel_list;
    if(node.getParam("y_vels", y_vel_list)){
      typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
      boost::char_separator<char> sep("[], ");
      tokenizer tokens(y_vel_list, sep);

      for(tokenizer::iterator i = tokens.begin(); i != tokens.end(); i++){
        y_vels.push_back(atof((*i).c_str()));
      }
    }
    else{
      //if no values are passed in, we'll provide defaults
      y_vels.push_back(-0.3);
      y_vels.push_back(-0.1);
      y_vels.push_back(0.1);
      y_vels.push_back(0.3);
    }

    return y_vels;
  }

  TrajectoryPlannerROS::~TrajectoryPlannerROS() {
    //make sure to clean things up
    delete dsrv_;

    if(tc_ != NULL)
      delete tc_;

    if(world_model_ != NULL)
      delete world_model_;
  }

  bool TrajectoryPlannerROS::stopWithAccLimits(const geometry_msgs::PoseStamped& global_pose, const geometry_msgs::PoseStamped& robot_vel, geometry_msgs::Twist& cmd_vel){
    //slow down with the maximum possible acceleration... we should really use the frequency that we're running at to determine what is feasible
    //but we'll use a tenth of a second to be consistent with the implementation of the local planner.
    double vx = sign(robot_vel.pose.position.x) * std::max(0.0, (fabs(robot_vel.pose.position.x) - acc_lim_x_ * sim_period_));
    double vy = sign(robot_vel.pose.position.y) * std::max(0.0, (fabs(robot_vel.pose.position.y) - acc_lim_y_ * sim_period_));

    double vel_yaw = tf2::getYaw(robot_vel.pose.orientation);
    double vth = sign(vel_yaw) * std::max(0.0, (fabs(vel_yaw) - acc_lim_theta_ * sim_period_));

    //we do want to check whether or not the command is valid
    double yaw = tf2::getYaw(global_pose.pose.orientation);
    bool valid_cmd = tc_->checkTrajectory(global_pose.pose.position.x, global_pose.pose.position.y, yaw,
        robot_vel.pose.position.x, robot_vel.pose.position.y, vel_yaw, vx, vy, vth);

    //if we have a valid command, we'll pass it on, otherwise we'll command all zeros
    if(valid_cmd){
      ROS_DEBUG("Slowing down... using vx, vy, vth: %.2f, %.2f, %.2f", vx, vy, vth);
      cmd_vel.linear.x = vx;
      cmd_vel.linear.y = vy;
      cmd_vel.angular.z = vth;
      return true;
    }

    cmd_vel.linear.x = 0.0;
    cmd_vel.linear.y = 0.0;
    cmd_vel.angular.z = 0.0;
    return false;
  }

  bool TrajectoryPlannerROS::rotateToGoal(const geometry_msgs::PoseStamped& global_pose, const geometry_msgs::PoseStamped& robot_vel, double goal_th, geometry_msgs::Twist& cmd_vel){
    double yaw = tf2::getYaw(global_pose.pose.orientation);
    double vel_yaw = tf2::getYaw(robot_vel.pose.orientation);
    cmd_vel.linear.x = 0;
    cmd_vel.linear.y = 0;
    double ang_diff = angles::shortest_angular_distance(yaw, goal_th);

    double v_theta_samp = ang_diff > 0.0 ? std::min(max_vel_th_,
        std::max(min_in_place_vel_th_, ang_diff)) : std::max(min_vel_th_,
        std::min(-1.0 * min_in_place_vel_th_, ang_diff));

    //take the acceleration limits of the robot into account
    double max_acc_vel = fabs(vel_yaw) + acc_lim_theta_ * sim_period_;
    double min_acc_vel = fabs(vel_yaw) - acc_lim_theta_ * sim_period_;

    v_theta_samp = sign(v_theta_samp) * std::min(std::max(fabs(v_theta_samp), min_acc_vel), max_acc_vel);

    //we also want to make sure to send a velocity that allows us to stop when we reach the goal given our acceleration limits
    double max_speed_to_stop = sqrt(2 * acc_lim_theta_ * fabs(ang_diff));

    v_theta_samp = sign(v_theta_samp) * std::min(max_speed_to_stop, fabs(v_theta_samp));

    // Re-enforce min_in_place_vel_th_.  It is more important than the acceleration limits.
    v_theta_samp = v_theta_samp > 0.0
      ? std::min( max_vel_th_, std::max( min_in_place_vel_th_, v_theta_samp ))
      : std::max( min_vel_th_, std::min( -1.0 * min_in_place_vel_th_, v_theta_samp ));

    //we still want to lay down the footprint of the robot and check if the action is legal
    bool valid_cmd = tc_->checkTrajectory(global_pose.pose.position.x, global_pose.pose.position.y, yaw,
        robot_vel.pose.position.x, robot_vel.pose.position.y, vel_yaw, 0.0, 0.0, v_theta_samp);

    ROS_DEBUG("Moving to desired goal orientation, th cmd: %.2f, valid_cmd: %d", v_theta_samp, valid_cmd);

    if(valid_cmd){
      cmd_vel.angular.z = v_theta_samp;
      return true;
    }

    cmd_vel.angular.z = 0.0;
    return false;

  }

  bool TrajectoryPlannerROS::setPlan(const std::vector<geometry_msgs::PoseStamped>& orig_global_plan){
    if (! isInitialized()) {
      ROS_ERROR("This planner has not been initialized, please call initialize() before using this planner");
      return false;
    }

    //reset the global plan
    global_plan_.clear();
    global_plan_ = orig_global_plan;

    //when we get a new plan, we also want to clear any latch we may have on goal tolerances
    xy_tolerance_latch_ = false;
    //reset the at goal flag
    reached_goal_ = false;
    return true;
  }

  bool TrajectoryPlannerROS::computeVelocityCommands(geometry_msgs::Twist& cmd_vel){
    if (! isInitialized()) {
      ROS_ERROR("This planner has not been initialized, please call initialize() before using this planner");
      return false;
    }

    std::vector<geometry_msgs::PoseStamped> local_plan;
    geometry_msgs::PoseStamped global_pose;
    if (!costmap_ros_->getRobotPose(global_pose)) {
      return false;
    }

    std::vector<geometry_msgs::PoseStamped> transformed_plan;
    //get the global plan in our frame
    if (!transformGlobalPlan(*tf_, global_plan_, global_pose, *costmap_, global_frame_, transformed_plan)) {
      ROS_WARN("Could not transform the global plan to the frame of the controller");
      return false;
    }

    //now we'll prune the plan based on the position of the robot
    if(prune_plan_)
      prunePlan(global_pose, transformed_plan, global_plan_);

    geometry_msgs::PoseStamped drive_cmds;
    drive_cmds.header.frame_id = robot_base_frame_;

    geometry_msgs::PoseStamped robot_vel;
    odom_helper_.getRobotVel(robot_vel);

    /* For timing uncomment
    struct timeval start, end;
    double start_t, end_t, t_diff;
    gettimeofday(&start, NULL);
    */

    //if the global plan passed in is empty... we won't do anything
    if(transformed_plan.empty())
      return false;

    const geometry_msgs::PoseStamped& goal_point = transformed_plan.back();
    //we assume the global goal is the last point in the global plan
    const double goal_x = goal_point.pose.position.x;
    const double goal_y = goal_point.pose.position.y;

    const double yaw = tf2::getYaw(goal_point.pose.orientation);

    double goal_th = yaw;

    //check to see if we've reached the goal position
    if (xy_tolerance_latch_ || (getGoalPositionDistance(global_pose, goal_x, goal_y) <= xy_goal_tolerance_)) {

      //if the user wants to latch goal tolerance, if we ever reach the goal location, we'll
      //just rotate in place
      if (latch_xy_goal_tolerance_) {
        xy_tolerance_latch_ = true;
      }

      double angle = getGoalOrientationAngleDifference(global_pose, goal_th);
      //check to see if the goal orientation has been reached
      if (fabs(angle) <= yaw_goal_tolerance_) {
        //set the velocity command to zero
        cmd_vel.linear.x = 0.0;
        cmd_vel.linear.y = 0.0;
        cmd_vel.angular.z = 0.0;
        rotating_to_goal_ = false;
        xy_tolerance_latch_ = false;
        reached_goal_ = true;
      } else {
        //we need to call the next two lines to make sure that the trajectory
        //planner updates its path distance and goal distance grids
        tc_->updatePlan(transformed_plan);
        Trajectory path = tc_->findBestPath(global_pose, robot_vel, drive_cmds);
        map_viz_.publishCostCloud(costmap_);

        //copy over the odometry information
        nav_msgs::Odometry base_odom;
        odom_helper_.getOdom(base_odom);

        //if we're not stopped yet... we want to stop... taking into account the acceleration limits of the robot
        if ( ! rotating_to_goal_ && !base_local_planner::stopped(base_odom, rot_stopped_velocity_, trans_stopped_velocity_)) {
          if ( ! stopWithAccLimits(global_pose, robot_vel, cmd_vel)) {
            return false;
          }
        }
        //if we're stopped... then we want to rotate to goal
        else{
          //set this so that we know its OK to be moving
          rotating_to_goal_ = true;
          if(!rotateToGoal(global_pose, robot_vel, goal_th, cmd_vel)) {
            return false;
          }
        }
      }

      //publish an empty plan because we've reached our goal position
      publishPlan(transformed_plan, g_plan_pub_);
      publishPlan(local_plan, l_plan_pub_);

      //we don't actually want to run the controller when we're just rotating to goal
      return true;
    }

    tc_->updatePlan(transformed_plan);

    //compute what trajectory to drive along
    Trajectory path = tc_->findBestPath(global_pose, robot_vel, drive_cmds);

    map_viz_.publishCostCloud(costmap_);
    /* For timing uncomment
    gettimeofday(&end, NULL);
    start_t = start.tv_sec + double(start.tv_usec) / 1e6;
    end_t = end.tv_sec + double(end.tv_usec) / 1e6;
    t_diff = end_t - start_t;
    ROS_INFO("Cycle time: %.9f", t_diff);
    */

    //pass along drive commands
    cmd_vel.linear.x = drive_cmds.pose.position.x;
    cmd_vel.linear.y = drive_cmds.pose.position.y;
    cmd_vel.angular.z = tf2::getYaw(drive_cmds.pose.orientation);

    //if we cannot move... tell someone
    if (path.cost_ < 0) {
      ROS_DEBUG_NAMED("trajectory_planner_ros",
          "The rollout planner failed to find a valid plan. This means that the footprint of the robot was in collision for all simulated trajectories.");
      local_plan.clear();
      publishPlan(transformed_plan, g_plan_pub_);
      publishPlan(local_plan, l_plan_pub_);
      return false;
    }

    ROS_DEBUG_NAMED("trajectory_planner_ros", "A valid velocity command of (%.2f, %.2f, %.2f) was found for this cycle.",
        cmd_vel.linear.x, cmd_vel.linear.y, cmd_vel.angular.z);

    // Fill out the local plan
    for (unsigned int i = 0; i < path.getPointsSize(); ++i) {
      double p_x, p_y, p_th;
      path.getPoint(i, p_x, p_y, p_th);
      geometry_msgs::PoseStamped pose;
      pose.header.frame_id = global_frame_;
      pose.header.stamp = ros::Time::now();
      pose.pose.position.x = p_x;
      pose.pose.position.y = p_y;
      pose.pose.position.z = 0.0;
      tf2::Quaternion q;
      q.setRPY(0, 0, p_th);
      tf2::convert(q, pose.pose.orientation);
      local_plan.push_back(pose);
    }

    //publish information to the visualizer
    publishPlan(transformed_plan, g_plan_pub_);
    publishPlan(local_plan, l_plan_pub_);
    return true;
  }

  bool TrajectoryPlannerROS::checkTrajectory(double vx_samp, double vy_samp, double vtheta_samp, bool update_map){
    geometry_msgs::PoseStamped global_pose;
    if(costmap_ros_->getRobotPose(global_pose)){
      if(update_map){
        //we need to give the planne some sort of global plan, since we're only checking for legality
        //we'll just give the robots current position
        std::vector<geometry_msgs::PoseStamped> plan;
        plan.push_back(global_pose);
        tc_->updatePlan(plan, true);
      }

      //copy over the odometry information
      nav_msgs::Odometry base_odom;
      {
        boost::recursive_mutex::scoped_lock lock(odom_lock_);
        base_odom = base_odom_;
      }

      return tc_->checkTrajectory(global_pose.pose.position.x, global_pose.pose.position.y, tf2::getYaw(global_pose.pose.orientation),
          base_odom.twist.twist.linear.x,
          base_odom.twist.twist.linear.y,
          base_odom.twist.twist.angular.z, vx_samp, vy_samp, vtheta_samp);

    }
    ROS_WARN("Failed to get the pose of the robot. No trajectories will pass as legal in this case.");
    return false;
  }

  double TrajectoryPlannerROS::scoreTrajectory(double vx_samp, double vy_samp, double vtheta_samp, bool update_map){
    // Copy of checkTrajectory that returns a score instead of True / False
    geometry_msgs::PoseStamped global_pose;
    if(costmap_ros_->getRobotPose(global_pose)){
      if(update_map){
        //we need to give the planne some sort of global plan, since we're only checking for legality
        //we'll just give the robots current position
        std::vector<geometry_msgs::PoseStamped> plan;
        plan.push_back(global_pose);
        tc_->updatePlan(plan, true);
      }

      //copy over the odometry information
      nav_msgs::Odometry base_odom;
      {
        boost::recursive_mutex::scoped_lock lock(odom_lock_);
        base_odom = base_odom_;
      }

      return tc_->scoreTrajectory(global_pose.pose.position.x, global_pose.pose.position.y, tf2::getYaw(global_pose.pose.orientation),
          base_odom.twist.twist.linear.x,
          base_odom.twist.twist.linear.y,
          base_odom.twist.twist.angular.z, vx_samp, vy_samp, vtheta_samp);

    }
    ROS_WARN("Failed to get the pose of the robot. No trajectories will pass as legal in this case.");
    return -1.0;
  }

  bool TrajectoryPlannerROS::isGoalReached() {
    if (! isInitialized()) {
      ROS_ERROR("This planner has not been initialized, please call initialize() before using this planner");
      return false;
    }
    //return flag set in controller
    return reached_goal_;
  }
};


text:
// Boost.Geometry

// Copyright (c) 2021, Oracle and/or its affiliates.

// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html

#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DUMMY_GEOMETRIES_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DUMMY_GEOMETRIES_HPP

#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>

namespace boost { namespace geometry
{

#ifndef DOXYGEN_NO_DETAIL
namespace detail
{

struct dummy_point {};
struct dummy_segment {};
struct dummy_box {};
struct dummy_linestring {};
struct dummy_ring {};
struct dummy_polygon {};
struct dummy_multi_point {};
struct dummy_multi_linestring {};
struct dummy_multi_polygon {};

} // namespace detail
#endif // DOXYGEN_NO_DETAIL

namespace traits
{

template <> struct tag<geometry::detail::dummy_point> { typedef point_tag type; };
template <> struct tag<geometry::detail::dummy_segment> { typedef segment_tag type; };
template <> struct tag<geometry::detail::dummy_box> { typedef box_tag type; };
template <> struct tag<geometry::detail::dummy_linestring> { typedef linestring_tag type; };
template <> struct tag<geometry::detail::dummy_ring> { typedef ring_tag type; };
template <> struct tag<geometry::detail::dummy_polygon> { typedef polygon_tag type; };
template <> struct tag<geometry::detail::dummy_multi_point> { typedef multi_point_tag type; };
template <> struct tag<geometry::detail::dummy_multi_linestring> { typedef multi_linestring_tag type; };
template <> struct tag<geometry::detail::dummy_multi_polygon> { typedef multi_polygon_tag type; };

} // namespace traits

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DUMMY_GEOMETRIES_HPP