<commit_before>#ifndef _1af7690b_7fca_4464_9e14_c71bc5a29ee9
#define _1af7690b_7fca_4464_9e14_c71bc5a29ee9

namespace fn{

namespace _ {

template<typename C>
struct noconst{ typedef C T; };
template<typename B>
struct noconst<B const&>{ typedef B T; };

template<typename T>
struct IsTrue{ bool operator()(T i)const {return static_cast<bool>(i);} };

template<typename T>
constexpr bool is_void() {return false;}
template<>
constexpr bool is_void<void>() {return true;}

template<typename T>
class Range
{
    class IT
    {
    public:
        IT(T const& position): position(position) {}
        IT(T const& position, T const& step): position(position),step(step) {}
        bool operator!=(IT const& other)const {return position!=other.position;}
        IT const& operator++() {position+=step;return *this;}
        T const& operator*()const {return position;}
    private:
        T position;
        T step = 1;
    };

    IT from;
    IT const to;
public:
    Range(T const& to): from(0), to(to) {}
    IT const& begin()const { return from; }
    IT const& end()const { return to; }
};};

template<typename T,typename ...Args>
auto range(T const& t,Args const& ...args) -> _::Range<T>{
    return _::Range<T>(t,args...);
}

namespace _ {
template<typename FN,typename G, typename OtherIT>
class Map
{
    class IT
    {
    private:
        FN const& fn;
        OtherIT other_it;
    public:
        IT(FN fn,OtherIT other_it): fn(fn), other_it(other_it) {}
        bool operator!=(IT& other){return other_it!=other.other_it;}
        IT const& operator++() {++other_it;return *this;}
        auto operator*()const -> decltype(fn(*other_it)) {return fn(*other_it);}
    };

    IT const from;
    IT const to;

public:
    Map(FN fn, G const& g): from(fn,g.begin()), to(fn,g.end()) {}
    IT const& begin() const { return from; }
    IT const& end() const { return to; }
};};

template<typename FN,typename G>
auto map(FN const& fn,G const& g) -> _::Map<FN,G,
    typename _::noconst<decltype(g.begin())>::T>{
    return _::Map<FN,G,typename _::noconst<decltype(g.begin())>::T>(fn,g);
}

namespace _ {
template<
    template<typename,typename> class PairT,
    typename A,
    typename B,
    typename OtherIT1,
    typename OtherIT2
>
class Zip
{
    class IT
    {
    private:
        OtherIT1 other_it1;
        OtherIT2 other_it2;
        typedef PairT<decltype(*other_it1),decltype(*other_it2)> Pair;

    public:
        IT(OtherIT1 other_it1,OtherIT2 other_it2):
            other_it1(other_it1),other_it2(other_it2) {}
        bool operator!=(IT& other){
            return (
                (other_it1!=other.other_it1) && (other_it2 != other.other_it2)
            );
        }
        IT const& operator++() {++other_it1;++other_it2;return *this;}
        auto operator*()const -> decltype(Pair{*other_it1,*other_it2}) {
            return Pair{*other_it1,*other_it2};
        }
    };

    IT const from;
    IT const to;

public:
    Zip(A const& a, B const& b):
        from(a.begin(),b.begin()), to(a.end(),b.end()) {}
    IT const& begin() const { return from; }
    IT const& end() const { return to; }
};};

namespace _ {
template<typename A, typename B>
struct Pair
{
    Pair(A&& a, B&& b):
        first(a),second(b),
        key(a),value(b),
        nr(a),item(b)
    {}

    A&& first;
    B&& second;

    A&& key;
    B&& value;

    A&& nr;
    B&& item;
};};

template<template<typename,typename> class PairT=_::Pair, typename A,typename B>
auto zip(A const& a,B const& b) -> _::Zip<PairT,A,B,
        typename _::noconst<decltype(a.begin())>::T,
        typename _::noconst<decltype(b.begin())>::T
    >{
    return _::Zip<PairT,A,B,
        typename _::noconst<decltype(a.begin())>::T,
        typename _::noconst<decltype(b.begin())>::T
    >(a,b);
}

template<typename A>
auto enumerate(A const& a)
     ->decltype(zip(range(-1),a))
{
    return zip(range(-1),a);
}

namespace _ {
template<typename FN,typename G, typename OtherIT>
class Filter
{
    class IT
    {
    private:
        FN const& fn;
        OtherIT other_it;
    public:
        IT(FN fn,OtherIT other_it): fn(fn), other_it(other_it){}
        bool operator!=(IT& other){
            while(other_it!=other.other_it && !fn(*other_it)){ ++other_it; }
            return other_it!=other.other_it;
        }
        IT const& operator++() { ++other_it; return *this; }
        auto operator*()const -> decltype(*other_it) { return *other_it; }
    };

    IT const from;
    IT const to;

public:
    Filter(FN fn, G const& g): from(fn,g.begin()), to(fn,g.end()) {}
    IT const& begin() const { return from; }
    IT const& end() const { return to; }
};};

template<typename FN,typename G>
auto filter(FN const& fn,G const& g) -> _::Filter<FN,G,
    typename _::noconst<decltype(g.begin())>::T>
{
    return _::Filter<FN,G,typename _::noconst<decltype(g.begin())>::T>(fn,g);
}

template<typename G>
auto filter(G const& g)
     -> decltype(filter(_::IsTrue<decltype(*g.begin())>{},(*g.begin(),g)))
{
    return filter(_::IsTrue<decltype(*g.begin())>{},g);
}

template<typename T>
class optional
{
public:
    typedef T Type;
    optional(optional const&) = delete;
    inline optional(optional const&& original):
        has_value(original.has_value),
        value(original.value){}

    inline optional(): has_value(false){}
    inline optional(T const& value): has_value(true), value(value){}

    inline T const& operator||(T const& fallback) const
    {
        return (*this)(
            [](T const& v)->T const& {return v;},
            [&]()->T const& {return fallback;}
        );
    }

    template<typename ValueF>
    inline optional const& operator()(
        ValueF const& handle_value) const
    {
        static_assert(_::is_void<
            decltype(handle_value(const_cast<T const&>(value)))>() == true,
            "this function must not have a return value"
        );
        if(has_value) {handle_value(const_cast<T const&>(value));}
        return *this;
    }

    template<typename ValueF, typename EmptyF>
    inline auto operator()(
        ValueF const& handle_value,
        EmptyF const& handle_no_value) const
        ->decltype(handle_value(*reinterpret_cast<T*>(0)))
    {
        return has_value ?
                    handle_value(const_cast<T const&>(value))
                  : handle_no_value();
    }

    explicit operator bool() const& { return has_value; };

private:
    bool const has_value;
    T value;
};

};

#endif
<commit_msg>Visual C++ fixes<commit_after>#ifndef _1af7690b_7fca_4464_9e14_c71bc5a29ee9
#define _1af7690b_7fca_4464_9e14_c71bc5a29ee9

namespace fn{

namespace _ {

template<typename C>
struct noconst{ typedef C T; };
template<typename B>
struct noconst<B const&>{ typedef B T; };

template<typename T>
struct IsTrue{ bool operator()(T i)const {return static_cast<bool>(i);} };

#ifndef _MSC_VER
template<typename T>
constexpr bool is_void() {return false;}
template<>
constexpr bool is_void<void>() {return true;}
#else
#define or ||
#endif

template<typename T>
class Range
{
    class IT
    {
    public:
        typedef T value_type;
        IT(T const& position): position(position) {}
        IT(T const& position, T const& step): position(position),step(step) {}
        bool operator!=(IT const& other)const {return position!=other.position;}
        IT const& operator++() {position+=step;return *this;}
        T const& operator*()const {return position;}
    private:
        T position;
        T step = 1;
    };

    IT from;
    IT const to;
public:
    Range(T const& to): from(0), to(to) {}
    IT const& begin()const { return from; }
    IT const& end()const { return to; }
};};

template<typename T,typename ...Args>
auto range(T const& t,Args const& ...args) -> _::Range<T>{
    return _::Range<T>(t,args...);
}

namespace _ {
template<typename FN,typename G, typename OtherIT>
class Map
{
    class IT
    {
    private:
        FN const& fn;
        OtherIT other_it;
    public:
        typedef decltype(fn(*other_it)) value_type;
        IT(FN fn,OtherIT other_it): fn(fn), other_it(other_it) {}
        bool operator!=(IT& other){return other_it!=other.other_it;}
        IT const& operator++() {++other_it;return *this;}
        auto operator*()const -> value_type {return fn(*other_it);}
    };

    IT const from;
    IT const to;

public:
    Map(FN fn, G const& g): from(fn,g.begin()), to(fn,g.end()) {}
    IT const& begin() const { return from; }
    IT const& end() const { return to; }
};};

template<typename FN,typename G>
auto map(FN const& fn,G const& g) -> _::Map<FN,G,
    typename _::noconst<decltype(g.begin())>::T>{
    return _::Map<FN,G,typename _::noconst<decltype(g.begin())>::T>(fn,g);
}

namespace _ {
template<
    template<typename,typename> class PairT,
    typename A,
    typename B,
    typename OtherIT1,
    typename OtherIT2
>
class Zip
{
    class IT
    {
    private:
        OtherIT1 other_it1;
        OtherIT2 other_it2;
        typedef typename OtherIT1::value_type const OtherVal1;
        typedef typename OtherIT2::value_type const OtherVal2;
        typedef PairT<OtherVal1,OtherVal2> Pair;

    public:
        typedef Pair value_type;

        IT(OtherIT1 other_it1,OtherIT2 other_it2):
            other_it1(other_it1),other_it2(other_it2) {}
        bool operator!=(IT& other){
            return (
                (other_it1!=other.other_it1) && (other_it2 != other.other_it2)
            );
        }
        IT const& operator++() {++other_it1;++other_it2;return *this;}

        Pair operator*() {
            return Pair(*other_it1,*other_it2);
        }
    };

    IT const from;
    IT const to;

public:
    Zip(A const& a, B const& b):
        from(a.begin(),b.begin()), to(a.end(),b.end()) {}
    IT const& begin() const { return from; }
    IT const& end() const { return to; }
};};

namespace _ {
template<typename A, typename B>
struct Pair
{
    Pair(A& a, B& b):
        first(a),second(b),
        key(a),value(b),
        nr(a),item(b)
    {}

    A& first;
    B& second;

    A& key;
    B& value;

    A& nr;
    B& item;
};};

template<template<typename,typename> class PairT=_::Pair, typename A,typename B>
auto zip(A const& a,B const& b) -> _::Zip<PairT,A,B,
        typename _::noconst<decltype(a.begin())>::T,
        typename _::noconst<decltype(b.begin())>::T
    >{
    return _::Zip<PairT,A,B,
        typename _::noconst<decltype(a.begin())>::T,
        typename _::noconst<decltype(b.begin())>::T
    >(a,b);
}

template<typename A>
auto enumerate(A const& a)
     ->decltype(zip(range(-1),a))
{
    return zip(range(-1),a);
}

namespace _ {
template<typename FN,typename G, typename OtherIT>
class Filter
{
    class IT
    {
    private:
        FN const& fn;
        OtherIT other_it;
    public:
        typedef typename OtherIT::value_type value_type;

        IT(FN fn,OtherIT other_it): fn(fn), other_it(other_it){}
        bool operator!=(IT& other){
            while(other_it!=other.other_it && !fn(*other_it)){ ++other_it; }
            return other_it!=other.other_it;
        }
        IT const& operator++() { ++other_it; return *this; }
        auto operator*()const -> decltype(*other_it) { return *other_it; }
    };

    IT const from;
    IT const to;

public:
    Filter(FN fn, G const& g): from(fn,g.begin()), to(fn,g.end()) {}
    IT const& begin() const { return from; }
    IT const& end() const { return to; }
};};

template<typename FN,typename G>
auto filter(FN const& fn,G const& g) -> _::Filter<FN,G,
    typename _::noconst<decltype(g.begin())>::T>
{
    return _::Filter<FN,G,typename _::noconst<decltype(g.begin())>::T>(fn,g);
}

template<typename G>
auto filter(G const& g)
     -> decltype(filter(_::IsTrue<decltype(*g.begin())>{},(*g.begin(),g)))
{
    return filter(_::IsTrue<decltype(*g.begin())>{},g);
}

template<typename T>
class optional
{
public:
    typedef T Type;
    optional(optional const&) = delete;
    inline optional(optional const&& original):
        has_value(original.has_value),
        value(original.value){}

    inline optional(): has_value(false){}
    inline optional(T const& value): has_value(true), value(value){}

    inline T const& operator||(T const& fallback) const
    {
        return (*this)(
            [](T const& v)->T const& {return v;},
            [&]()->T const& {return fallback;}
        );
    }

    template<typename ValueF>
    inline optional const& operator()(
        ValueF const& handle_value) const
    {
#ifndef _MSC_VER
        static_assert(_::is_void<
            decltype(handle_value(const_cast<T const&>(value)))>() == true,
            "this function must not have a return value"
        );
#endif
        if(has_value) {handle_value(const_cast<T const&>(value));}
        return *this;
    }

    template<typename ValueF, typename EmptyF>
    inline auto operator()(
        ValueF const& handle_value,
        EmptyF const& handle_no_value) const
        ->decltype(handle_value(*reinterpret_cast<T*>(0)))
    {
        return has_value ?
                    handle_value(const_cast<T const&>(value))
                  : handle_no_value();
    }

    explicit operator bool() const { return has_value; };

private:
    bool const has_value;
    T value;
};

};

#endif
<|endoftext|>


<commit_before>#include "game.hpp"
#include "exception.hpp"

namespace Quoridor {

// order in which pawns are adding
// pawns rotates according to their indexes: 0 -> 1 -> 2 -> 3 -> 0 -> ...
static const std::vector<int> pawn_idx_list = {0, 2, 1, 3};

Game::Game(int board_size) : board_size_(board_size), pawn_data_list_(),
    cur_pawn_idx_(-1), bg_(board_size_, board_size_), wg_(board_size_ + 1)
{
}

Game::~Game()
{
}

void Game::set_pawns(std::vector<std::shared_ptr<Pawn>> &pawn_list)
{
    size_t pawn_num = pawn_list.size();
    if ((pawn_num != 2) && (pawn_num != 4)) {
        throw Exception("Invalid number of players: " + std::to_string(pawn_num));
    }

    for (size_t i = 0; i < pawn_list.size(); ++i) {
        pawn_data_t pawn_data;
        pawn_data.pawn = pawn_list[i];

        pawn_data.idx = pawn_idx_list[i];
        switch (pawn_data.idx) {
        case 0:
            pawn_data.node.set_row(0);
            pawn_data.node.set_col(board_size_ / 2);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(board_size_ - 1, j);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        case 1:
            pawn_data.node.set_row(board_size_ / 2);
            pawn_data.node.set_col(0);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(j, board_size_ - 1);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        case 2:
            pawn_data.node.set_row(board_size_ - 1);
            pawn_data.node.set_col(board_size_ / 2);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(0, j);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        case 3:
            pawn_data.node.set_row(board_size_ / 2);
            pawn_data.node.set_col(board_size_ - 1);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(j, 0);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        }

        pawn_data_list_.insert(pawn_data);
    }
}

void Game::switch_pawn()
{
    auto it = pawn_data_list_.upper_bound(cur_pawn_idx_);
    if (it == pawn_data_list_.end()) {
        it = pawn_data_list_.begin();
    }
    cur_pawn_idx_ = it->idx;
}

const pawn_data_t &Game::cur_pawn_data() const
{
    return *pawn_data_list_.find(cur_pawn_idx_);
}

const pawn_data_list_t &Game::pawn_data_list() const
{
    return pawn_data_list_;
}

const pawn_data_t &Game::pawn_data(std::shared_ptr<Pawn> &pawn) const
{
    return *pawn_data_list_.get<by_pawn>().find(pawn);
}

int Game::move_pawn(const Node &node)
{
    const Node &cur_node = pawn_data_list_.find(cur_pawn_idx_)->node;

    if (bg_.is_adjacent(cur_node, node)) {
        bg_.unblock_node(cur_node);
        pawn_data_list_t::iterator it = pawn_data_list_.find(cur_pawn_idx_);
        pawn_data_list_.modify(it, [=](pawn_data_t &e){ e.node = node; });
        bg_.block_node(node);
        return 0;
    }
    else {
        return -1;
    }
}

int Game::add_wall(const Wall &wall)
{
    std::vector<std::pair<Node, Node>> edges;

    if (try_add_wall(wall, &edges) < 0) {
        return -1;
    }

    wg_.apply_tmp_wall();
    for (auto edge : edges) {
        bg_.remove_edges(edge.first, edge.second);
    }

    return 0;
}

bool Game::is_finished() const
{
    Node cur_node = pawn_data_list_.find(cur_pawn_idx_)->node;
    if (pawn_data_list_.find(cur_pawn_idx_)->goal_nodes.count(cur_node) != 0) {
        return true;
    }
    return false;
}

bool Game::get_path(std::shared_ptr<Pawn> pawn, const Node &node,
        std::list<Node> *path) const
{
    return bg_.find_path(pawn_data(pawn).node, node, path);
}

int Game::try_add_wall(const Wall &wall,
        std::vector<std::pair<Node, Node>> *edges)
{
    if (wg_.add_tmp_wall(wall) < 0) {
        return -1;
    }

    bg_.reset_filters();

    Node node1;
    Node node2;
    Node node_tmp;
    if (wall.orientation() == Wall::kHorizontal) {
        for (int i = 0; i < wall.cnt(); ++i) {
            node1 = Node(wall.row() - 1, wall.col() + i);
            node2 = Node(wall.row(), wall.col() + i);
            bg_.filter_edges(node1, node2);
            edges->push_back(std::make_pair(node1, node2));

            node_tmp = Node(wall.row() + 1, wall.col() + i);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                bg_.filter_edges(node1, node_tmp);
                edges->push_back(std::make_pair(node1, node_tmp));
            }

            node_tmp = Node(wall.row() - 2, wall.col() + i);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                bg_.filter_edges(node_tmp, node2);
                edges->push_back(std::make_pair(node_tmp, node2));
            }

            for (int j = i - 1; j <= i + 1; j += 2) {
                node_tmp = Node(wall.row(), wall.col() + j);
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    bg_.filter_edges(node1, node_tmp);
                    edges->push_back(std::make_pair(node1, node_tmp));
                }

                node_tmp = Node(wall.row() - 1, wall.col() + j);
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    bg_.filter_edges(node_tmp, node2);
                    edges->push_back(std::make_pair(node_tmp, node2));
                }
            }
        }
    }
    else if (wall.orientation() == Wall::kVertical) {
        for (int i = 0; i < wall.cnt(); ++i) {
            node1 = Node(wall.row() + i, wall.col() - 1);
            node2 = Node(wall.row() + i, wall.col());
            bg_.filter_edges(node1, node2);
            edges->push_back(std::make_pair(node1, node2));

            node_tmp = Node(wall.row() + i, wall.col() + 1);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                bg_.filter_edges(node1, node_tmp);
                edges->push_back(std::make_pair(node1, node_tmp));
            }

            node_tmp = Node(wall.row() + i, wall.col() - 2);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                bg_.filter_edges(node_tmp, node2);
                edges->push_back(std::make_pair(node_tmp, node2));
            }

            for (int j = i - 1; j <= i + 1; j += 2) {
                node_tmp = Node(wall.row() + j, wall.col());
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    bg_.filter_edges(node1, node_tmp);
                    edges->push_back(std::make_pair(node1, node_tmp));
                }

                node_tmp = Node(wall.row() + j, wall.col() - 1);
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    bg_.filter_edges(node_tmp, node2);
                    edges->push_back(std::make_pair(node_tmp, node2));
                }
            }
        }
    }
    else {
        return -1;
    }

    bool path_blocked = false;

    for (auto pawn_data : pawn_data_list_) {
        path_blocked = true;
        for (auto goal_node : pawn_data.goal_nodes) {
            if (bg_.is_path_exists(pawn_data.node, goal_node)) {
                path_blocked = false;
                break;
            }
        }

        // wall blocks all pathes to the opposite side for one of pawns
        if (path_blocked) {
            break;
        }
    }

    if (path_blocked) {
        return -1;
    }

    return 0;
}

}  // namespace Quoridor
<commit_msg>Fix BoardGraph usage in Game<commit_after>#include "game.hpp"
#include "exception.hpp"

namespace Quoridor {

// order in which pawns are adding
// pawns rotates according to their indexes: 0 -> 1 -> 2 -> 3 -> 0 -> ...
static const std::vector<int> pawn_idx_list = {0, 2, 1, 3};

Game::Game(int board_size) : board_size_(board_size), pawn_data_list_(),
    cur_pawn_idx_(-1), bg_(board_size_, board_size_), wg_(board_size_ + 1)
{
}

Game::~Game()
{
}

void Game::set_pawns(std::vector<std::shared_ptr<Pawn>> &pawn_list)
{
    size_t pawn_num = pawn_list.size();
    if ((pawn_num != 2) && (pawn_num != 4)) {
        throw Exception("Invalid number of players: " + std::to_string(pawn_num));
    }

    for (size_t i = 0; i < pawn_list.size(); ++i) {
        pawn_data_t pawn_data;
        pawn_data.pawn = pawn_list[i];

        pawn_data.idx = pawn_idx_list[i];
        switch (pawn_data.idx) {
        case 0:
            pawn_data.node.set_row(0);
            pawn_data.node.set_col(board_size_ / 2);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(board_size_ - 1, j);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        case 1:
            pawn_data.node.set_row(board_size_ / 2);
            pawn_data.node.set_col(0);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(j, board_size_ - 1);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        case 2:
            pawn_data.node.set_row(board_size_ - 1);
            pawn_data.node.set_col(board_size_ / 2);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(0, j);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        case 3:
            pawn_data.node.set_row(board_size_ / 2);
            pawn_data.node.set_col(board_size_ - 1);
            bg_.block_node(pawn_data.node);
            for (int j = 0; j < board_size_; ++j) {
                Node gn(j, 0);
                pawn_data.goal_nodes.insert(gn);
            }
            break;
        }

        pawn_data_list_.insert(pawn_data);
    }
}

void Game::switch_pawn()
{
    auto it = pawn_data_list_.upper_bound(cur_pawn_idx_);
    if (it == pawn_data_list_.end()) {
        it = pawn_data_list_.begin();
    }
    cur_pawn_idx_ = it->idx;
}

const pawn_data_t &Game::cur_pawn_data() const
{
    return *pawn_data_list_.find(cur_pawn_idx_);
}

const pawn_data_list_t &Game::pawn_data_list() const
{
    return pawn_data_list_;
}

const pawn_data_t &Game::pawn_data(std::shared_ptr<Pawn> &pawn) const
{
    return *pawn_data_list_.get<by_pawn>().find(pawn);
}

int Game::move_pawn(const Node &node)
{
    const Node &cur_node = pawn_data_list_.find(cur_pawn_idx_)->node;

    if (bg_.is_adjacent(cur_node, node)) {
        bg_.unblock_node(cur_node);
        pawn_data_list_t::iterator it = pawn_data_list_.find(cur_pawn_idx_);
        pawn_data_list_.modify(it, [=](pawn_data_t &e){ e.node = node; });
        bg_.block_node(node);
        return 0;
    }
    else {
        return -1;
    }
}

int Game::add_wall(const Wall &wall)
{
    std::vector<std::pair<Node, Node>> edges;

    if (try_add_wall(wall, &edges) < 0) {
        return -1;
    }

    wg_.apply_tmp_wall();
    for (auto edge : edges) {
        bg_.remove_edges(edge.first, edge.second);
    }

    return 0;
}

bool Game::is_finished() const
{
    Node cur_node = pawn_data_list_.find(cur_pawn_idx_)->node;
    if (pawn_data_list_.find(cur_pawn_idx_)->goal_nodes.count(cur_node) != 0) {
        return true;
    }
    return false;
}

bool Game::get_path(std::shared_ptr<Pawn> pawn, const Node &node,
        std::list<Node> *path) const
{
    return bg_.find_path(pawn_data(pawn).node, node, path);
}

int Game::try_add_wall(const Wall &wall,
        std::vector<std::pair<Node, Node>> *edges)
{
    if (wg_.add_tmp_wall(wall) < 0) {
        return -1;
    }

    std::vector<std::pair<Node, Node>> edge_list;

    Node node1;
    Node node2;
    Node node_tmp;
    if (wall.orientation() == Wall::kHorizontal) {
        for (int i = 0; i < wall.cnt(); ++i) {
            node1 = Node(wall.row() - 1, wall.col() + i);
            node2 = Node(wall.row(), wall.col() + i);
            edge_list.push_back(std::make_pair(node1, node2));
            edges->push_back(std::make_pair(node1, node2));

            node_tmp = Node(wall.row() + 1, wall.col() + i);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                edge_list.push_back(std::make_pair(node1, node_tmp));
                edges->push_back(std::make_pair(node1, node_tmp));
            }

            node_tmp = Node(wall.row() - 2, wall.col() + i);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                edge_list.push_back(std::make_pair(node_tmp, node2));
                edges->push_back(std::make_pair(node_tmp, node2));
            }

            for (int j = i - 1; j <= i + 1; j += 2) {
                node_tmp = Node(wall.row(), wall.col() + j);
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    edge_list.push_back(std::make_pair(node1, node_tmp));
                    edges->push_back(std::make_pair(node1, node_tmp));
                }

                node_tmp = Node(wall.row() - 1, wall.col() + j);
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    edge_list.push_back(std::make_pair(node_tmp, node2));
                    edges->push_back(std::make_pair(node_tmp, node2));
                }
            }
        }
    }
    else if (wall.orientation() == Wall::kVertical) {
        for (int i = 0; i < wall.cnt(); ++i) {
            node1 = Node(wall.row() + i, wall.col() - 1);
            node2 = Node(wall.row() + i, wall.col());
            edge_list.push_back(std::make_pair(node1, node2));
            edges->push_back(std::make_pair(node1, node2));

            node_tmp = Node(wall.row() + i, wall.col() + 1);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                edge_list.push_back(std::make_pair(node1, node_tmp));
                edges->push_back(std::make_pair(node1, node_tmp));
            }

            node_tmp = Node(wall.row() + i, wall.col() - 2);
            if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                    && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                edge_list.push_back(std::make_pair(node_tmp, node2));
                edges->push_back(std::make_pair(node_tmp, node2));
            }

            for (int j = i - 1; j <= i + 1; j += 2) {
                node_tmp = Node(wall.row() + j, wall.col());
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    edge_list.push_back(std::make_pair(node1, node_tmp));
                    edges->push_back(std::make_pair(node1, node_tmp));
                }

                node_tmp = Node(wall.row() + j, wall.col() - 1);
                if ((node_tmp.row() >= 0) && (node_tmp.row() < board_size_)
                        && (node_tmp.col() >= 0) && (node_tmp.col() < board_size_)) {
                    edge_list.push_back(std::make_pair(node_tmp, node2));
                    edges->push_back(std::make_pair(node_tmp, node2));
                }
            }
        }
    }
    else {
        return -1;
    }

    bool path_blocked = false;

    for (auto pawn_data : pawn_data_list_) {
        path_blocked = true;
        for (auto goal_node : pawn_data.goal_nodes) {
            if (bg_.is_path_exists(pawn_data.node, goal_node, edge_list)) {
                path_blocked = false;
                break;
            }
        }

        // wall blocks all pathes to the opposite side for one of pawns
        if (path_blocked) {
            break;
        }
    }

    if (path_blocked) {
        return -1;
    }

    return 0;
}

}  // namespace Quoridor
<|endoftext|>


<commit_before>/*-------------------------------------------------------------------------
 *
 * ddl.cpp
 * file description
 *
 * Copyright(c) 2015, CMU
 *
 * /peloton/src/backend/bridge/ddl.cpp
 *
 *-------------------------------------------------------------------------
 */

#include <cassert>
#include <iostream>

#include "backend/bridge/ddl/ddl_table.h"
#include "backend/bridge/ddl/ddl_database.h"
#include "backend/bridge/ddl/ddl_index.h"
#include "backend/bridge/ddl/ddl_transaction.h"
#include "backend/bridge/ddl/ddl.h"
#include "backend/common/logger.h"

#include "postgres.h"
#include "miscadmin.h"
#include "c.h"

namespace peloton {
namespace bridge {

//===--------------------------------------------------------------------===//
// Utilities.
//===--------------------------------------------------------------------===//

/**
 * @brief Process utility statement.
 * @param parsetree Parse tree
 */
void DDL::ProcessUtility(Node *parsetree,
                         const char *queryString,
                         TransactionId txn_id){
  assert(parsetree != nullptr);
  assert(queryString != nullptr);

  static std::vector<IndexInfo> index_infos;

  /* When we call a backend function from different thread, the thread's stack
   * is at a different location than the main thread's stack. so it sets up
   * reference point for stack depth checking
   */
  set_stack_base();

  // Process depending on type of utility statement
  switch (nodeTag(parsetree))
  {
    StartTransactionCommand();

    case T_CreatedbStmt:
    {
      DDLDatabase::ExecCreatedbStmt(parsetree);
      break;
    }

    case T_DropdbStmt:
    {
      DDLDatabase::ExecDropdbStmt(parsetree);
      break;
    }

    case T_CreateStmt:
    case T_CreateForeignTableStmt:
    {
      DDLTable::ExecCreateStmt(parsetree, index_infos);
      break;
    }

    case T_AlterTableStmt:
    {
      DDLTable::ExecAlterTableStmt(parsetree, queryString);
      break;
    }

    case T_DropStmt:
    {
      DDLTable::ExecDropStmt(parsetree);
      break;
    }

    case T_IndexStmt:
    {
      DDLIndex::ExecIndexStmt(parsetree, index_infos);
      break;
    }

    case T_VacuumStmt:
    {
      DDLDatabase::ExecVacuumStmt(parsetree);
      break;
    }

    CommitTransactionCommand();

    case T_TransactionStmt: {
      TransactionStmt *stmt = (TransactionStmt *) parsetree;

      DDLTransaction::ExecTransactionStmt(stmt, txn_id);
    }
    break;

    default: {
      LOG_WARN("unrecognized node type: %d", (int) nodeTag(parsetree));
    }
    break;
  }

}

} // namespace bridge
} // namespace peloton

<commit_msg>Minor fix<commit_after>/*-------------------------------------------------------------------------
 *
 * ddl.cpp
 * file description
 *
 * Copyright(c) 2015, CMU
 *
 * /peloton/src/backend/bridge/ddl.cpp
 *
 *-------------------------------------------------------------------------
 */

#include <cassert>
#include <iostream>

#include "backend/bridge/ddl/ddl_table.h"
#include "backend/bridge/ddl/ddl_database.h"
#include "backend/bridge/ddl/ddl_index.h"
#include "backend/bridge/ddl/ddl_transaction.h"
#include "backend/bridge/ddl/ddl.h"
#include "backend/common/logger.h"

#include "postgres.h"
#include "miscadmin.h"
#include "c.h"
#include "access/xact.h"

namespace peloton {
namespace bridge {

//===--------------------------------------------------------------------===//
// Utilities.
//===--------------------------------------------------------------------===//

/**
 * @brief Process utility statement.
 * @param parsetree Parse tree
 */
void DDL::ProcessUtility(Node *parsetree,
                         const char *queryString,
                         TransactionId txn_id){
  assert(parsetree != nullptr);
  assert(queryString != nullptr);

  static std::vector<IndexInfo> index_infos;

  /* When we call a backend function from different thread, the thread's stack
   * is at a different location than the main thread's stack. so it sets up
   * reference point for stack depth checking
   */
  set_stack_base();

  // Process depending on type of utility statement
  switch (nodeTag(parsetree))
  {
    StartTransactionCommand();

    case T_CreatedbStmt:
    {
      DDLDatabase::ExecCreatedbStmt(parsetree);
      break;
    }

    case T_DropdbStmt:
    {
      DDLDatabase::ExecDropdbStmt(parsetree);
      break;
    }

    case T_CreateStmt:
    case T_CreateForeignTableStmt:
    {
      DDLTable::ExecCreateStmt(parsetree, index_infos);
      break;
    }

    case T_AlterTableStmt:
    {
      DDLTable::ExecAlterTableStmt(parsetree, queryString);
      break;
    }

    case T_DropStmt:
    {
      DDLTable::ExecDropStmt(parsetree);
      break;
    }

    case T_IndexStmt:
    {
      DDLIndex::ExecIndexStmt(parsetree, index_infos);
      break;
    }

    case T_VacuumStmt:
    {
      DDLDatabase::ExecVacuumStmt(parsetree);
      break;
    }

    CommitTransactionCommand();

    case T_TransactionStmt: {
      TransactionStmt *stmt = (TransactionStmt *) parsetree;

      DDLTransaction::ExecTransactionStmt(stmt, txn_id);
    }
    break;

    default: {
      LOG_WARN("unrecognized node type: %d", (int) nodeTag(parsetree));
    }
    break;
  }

}

} // namespace bridge
} // namespace peloton

<|endoftext|>


<commit_before>#include <iostream>
#include <string>

#include "common/ann_util.h"

namespace ann {
namespace util {

ProgBar::ProgBar(size_t total): pv_(1), total_(total), percent_(0) {
    system("setterm -cursor off");
}

ProgBar::~ProgBar() {
    std::cerr << std::endl;
    system("setterm -cursor on");
}

void ProgBar::update(size_t count) {

    // with changes after
    // https://nakkaya.com/2009/11/08/command-line-progress-bar/
    //
    auto percent = (pv_ * 100) / total_;
    pv_ += count;

    if (percent == percent_) {
        return;
    }

    percent_ = percent;
    std::string bar;

    for (size_t i = 0; i < 50; i++) {
        if (i < (percent / 2)) {
            bar.replace(i, 1, "=");
        } else if (i == (percent / 2)) {
            bar.replace(i, 1, ">");
        } else {
            bar.replace(i, 1, " ");
        }
    }

    std::cerr << "\r" "[" << bar << "] ";
    std::cerr.width(3);
    std::cerr << percent << "%     " << std::flush;
}
}
}
<commit_msg>use c++ version of system<commit_after>#include <cstdlib>
#include <iostream>
#include <string>

#include "common/ann_util.h"

namespace ann {
namespace util {

ProgBar::ProgBar(size_t total): pv_(1), total_(total), percent_(0) {
    std::system("setterm -cursor off");
}

ProgBar::~ProgBar() {
    std::cerr << std::endl;
    std::system("setterm -cursor on");
}

void ProgBar::update(size_t count) {

    // with changes after
    // https://nakkaya.com/2009/11/08/command-line-progress-bar/
    //
    auto percent = (pv_ * 100) / total_;
    pv_ += count;

    if (percent == percent_) {
        return;
    }

    percent_ = percent;
    std::string bar;

    for (size_t i = 0; i < 50; i++) {
        if (i < (percent / 2)) {
            bar.replace(i, 1, "=");
        } else if (i == (percent / 2)) {
            bar.replace(i, 1, ">");
        } else {
            bar.replace(i, 1, " ");
        }
    }

    std::cerr << "\r" "[" << bar << "] ";
    std::cerr.width(3);
    std::cerr << percent << "%     " << std::flush;
}
}
}
<|endoftext|>


<commit_before>// Copyright 2013 Yangqing Jia

#include <cstring>

#include "cuda_runtime.h"
#include "gtest/gtest.h"
#include "caffe/common.hpp"
#include "caffe/syncedmem.hpp"

#include "caffe/test/test_caffe_main.hpp"

namespace caffe {

class CommonTest : public ::testing::Test {};

TEST_F(CommonTest, TestCublasHandler) {
  int cuda_device_id;
  CUDA_CHECK(cudaGetDevice(&cuda_device_id));
  EXPECT_TRUE(Caffe::cublas_handle());
}

TEST_F(CommonTest, TestVslStream) {
  EXPECT_TRUE(Caffe::vsl_stream());
}

TEST_F(CommonTest, TestBrewMode) {
  EXPECT_EQ(Caffe::mode(), Caffe::CPU);
  Caffe::set_mode(Caffe::GPU);
  EXPECT_EQ(Caffe::mode(), Caffe::GPU);
}

TEST_F(CommonTest, TestPhase) {
  EXPECT_EQ(Caffe::phase(), Caffe::TRAIN);
  Caffe::set_phase(Caffe::TEST);
  EXPECT_EQ(Caffe::phase(), Caffe::TEST);
}

TEST_F(CommonTest, TestRandSeedCPU) {
  SyncedMemory data_a(10 * sizeof(int));
  SyncedMemory data_b(10 * sizeof(int));
  Caffe::set_random_seed(1701);
  viRngBernoulli(VSL_RNG_METHOD_BERNOULLI_ICDF, Caffe::vsl_stream(),
        10, reinterpret_cast<int*>(data_a.mutable_cpu_data()), 0.5);
  Caffe::set_random_seed(1701);
  viRngBernoulli(VSL_RNG_METHOD_BERNOULLI_ICDF, Caffe::vsl_stream(),
        10, reinterpret_cast<int*>(data_b.mutable_cpu_data()), 0.5);
  for (int i = 0; i < 10; ++i) {
    EXPECT_EQ(((const int*)(data_a.cpu_data()))[i],
        ((const int*)(data_b.cpu_data()))[i]);
  }
}

TEST_F(CommonTest, TestRandSeedGPU) {
  SyncedMemory data_a(10 * sizeof(unsigned int));
  SyncedMemory data_b(10 * sizeof(unsigned int));
  Caffe::set_random_seed(1701);
  CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
        reinterpret_cast<unsigned int*>(data_a.mutable_gpu_data()), 10));
  Caffe::set_random_seed(1701);
  CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
        reinterpret_cast<unsigned int*>(data_b.mutable_gpu_data()), 10));
  for (int i = 0; i < 10; ++i) {
    EXPECT_EQ(((const unsigned int*)(data_a.cpu_data()))[i],
        ((const unsigned int*)(data_b.cpu_data()))[i]);
  }
}

}  // namespace caffe
<commit_msg>Fix a test assuming CPU mode without explicitly setting it.<commit_after>// Copyright 2013 Yangqing Jia

#include <cstring>

#include "cuda_runtime.h"
#include "gtest/gtest.h"
#include "caffe/common.hpp"
#include "caffe/syncedmem.hpp"

#include "caffe/test/test_caffe_main.hpp"

namespace caffe {

class CommonTest : public ::testing::Test {};

TEST_F(CommonTest, TestCublasHandler) {
  int cuda_device_id;
  CUDA_CHECK(cudaGetDevice(&cuda_device_id));
  EXPECT_TRUE(Caffe::cublas_handle());
}

TEST_F(CommonTest, TestVslStream) {
  EXPECT_TRUE(Caffe::vsl_stream());
}

TEST_F(CommonTest, TestBrewMode) {
  Caffe::set_mode(Caffe::CPU);
  EXPECT_EQ(Caffe::mode(), Caffe::CPU);
  Caffe::set_mode(Caffe::GPU);
  EXPECT_EQ(Caffe::mode(), Caffe::GPU);
}

TEST_F(CommonTest, TestPhase) {
  EXPECT_EQ(Caffe::phase(), Caffe::TRAIN);
  Caffe::set_phase(Caffe::TEST);
  EXPECT_EQ(Caffe::phase(), Caffe::TEST);
}

TEST_F(CommonTest, TestRandSeedCPU) {
  SyncedMemory data_a(10 * sizeof(int));
  SyncedMemory data_b(10 * sizeof(int));
  Caffe::set_random_seed(1701);
  viRngBernoulli(VSL_RNG_METHOD_BERNOULLI_ICDF, Caffe::vsl_stream(),
        10, reinterpret_cast<int*>(data_a.mutable_cpu_data()), 0.5);
  Caffe::set_random_seed(1701);
  viRngBernoulli(VSL_RNG_METHOD_BERNOULLI_ICDF, Caffe::vsl_stream(),
        10, reinterpret_cast<int*>(data_b.mutable_cpu_data()), 0.5);
  for (int i = 0; i < 10; ++i) {
    EXPECT_EQ(((const int*)(data_a.cpu_data()))[i],
        ((const int*)(data_b.cpu_data()))[i]);
  }
}

TEST_F(CommonTest, TestRandSeedGPU) {
  SyncedMemory data_a(10 * sizeof(unsigned int));
  SyncedMemory data_b(10 * sizeof(unsigned int));
  Caffe::set_random_seed(1701);
  CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
        reinterpret_cast<unsigned int*>(data_a.mutable_gpu_data()), 10));
  Caffe::set_random_seed(1701);
  CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
        reinterpret_cast<unsigned int*>(data_b.mutable_gpu_data()), 10));
  for (int i = 0; i < 10; ++i) {
    EXPECT_EQ(((const unsigned int*)(data_a.cpu_data()))[i],
        ((const unsigned int*)(data_b.cpu_data()))[i]);
  }
}

}  // namespace caffe
<|endoftext|>


<commit_before>/******************************************************************************\

          This file is part of the C! library.  A.K.A the cbang library.

              Copyright (c) 2003-2014, Cauldron Development LLC
                 Copyright (c) 2003-2014, Stanford University
                             All rights reserved.

        The C! library is free software: you can redistribute it and/or
        modify it under the terms of the GNU Lesser General Public License
        as published by the Free Software Foundation, either version 2.1 of
        the License, or (at your option) any later version.

        The C! library is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        Lesser General Public License for more details.

        You should have received a copy of the GNU Lesser General Public
        License along with the C! library.  If not, see
        <http://www.gnu.org/licenses/>.

        In addition, BSD licensing may be granted on a case by case basis
        by written permission from at least one of the copyright holders.
        You may request written permission by emailing the authors.

                For information regarding this software email:
                               Joseph Coffland
                        joseph@cauldrondevelopment.com

\******************************************************************************/

#include "Revoked.h"
#include "SSL.h"
#include "Extension.h"

#include <openssl/x509.h>

#include <cbang/Exception.h>

using namespace std;
using namespace cb;

Revoked::Revoked() : rev(X509_REVOKED_new()), deallocate(true) {}

Revoked::~Revoked() {
  if (deallocate) X509_REVOKED_free(rev);
}

void Revoked::setDate(uint64_t ts) {
  ASN1_TIME *tm = ASN1_TIME_new();
  X509_gmtime_adj(tm, ts);

  if (!X509_REVOKED_set_revocationDate(rev, tm)) {
    ASN1_TIME_free(tm);
    THROWS("Failed to set revocation date: " << SSL::getErrorStr());
  }

  ASN1_TIME_free(tm);
}

void Revoked::setReason(const string &reason) {
  if (reason == "unspecified") return;

  const char *reasons[] = {
	"unspecified",
	"keyCompromise",
	"CACompromise",
	"affiliationChanged",
	"superseded",
	"cessationOfOperation",
	"certificateHold",
    "removeFromCRL",
    "privilegeWithdrawn",
    "aACompromise",
    0
  };

  ASN1_ENUMERATED *a = ASN1_ENUMERATED_new();

  for (int i = 0; reasons[i]; i++)
    if (reason == reasons[i]) {
      ASN1_ENUMERATED_set(a, i);
      break;
    }

  if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, a, 0, 0)) {
    THROWS("Failed to add extension 'CRLReason'='" << reason
           << "': " << SSL::getErrorStr());
   	ASN1_ENUMERATED_free(a);
  }

  ASN1_ENUMERATED_free(a);
}

void Revoked::setSerial(int number) {
  ASN1_INTEGER *serial = ASN1_INTEGER_new();
  ASN1_INTEGER_set(serial, number);

  if (!X509_REVOKED_set_serialNumber(rev, serial))
    THROWS("Failed to set revoked serial number: " << SSL::getErrorStr());

  ASN1_INTEGER_free(serial);
}
<commit_msg>testing web hook<commit_after>/******************************************************************************\

          This file is part of the C! library.  A.K.A the cbang library.

              Copyright (c) 2003-2014, Cauldron Development LLC
                 Copyright (c) 2003-2014, Stanford University
                             All rights reserved.

        The C! library is free software: you can redistribute it and/or
        modify it under the terms of the GNU Lesser General Public License
        as published by the Free Software Foundation, either version 2.1 of
        the License, or (at your option) any later version.

        The C! library is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        Lesser General Public License for more details.

        You should have received a copy of the GNU Lesser General Public
        License along with the C! library.  If not, see
        <http://www.gnu.org/licenses/>.

        In addition, BSD licensing may be granted on a case by case basis
        by written permission from at least one of the copyright holders.
        You may request written permission by emailing the authors.

                For information regarding this software email:
                               Joseph Coffland
                        joseph@cauldrondevelopment.com

\******************************************************************************/

#include "Revoked.h"
#include "SSL.h"
#include "Extension.h"

#include <openssl/x509.h>

#include <cbang/Exception.h>

using namespace std;
using namespace cb;

Revoked::Revoked() : rev(X509_REVOKED_new()), deallocate(true) {}

Revoked::~Revoked() {
  if (deallocate) X509_REVOKED_free(rev);
}

void Revoked::setDate(uint64_t ts) {
  ASN1_TIME *tm = ASN1_TIME_new();
  X509_gmtime_adj(tm, ts);

  if (!X509_REVOKED_set_revocationDate(rev, tm)) {
    ASN1_TIME_free(tm);
    THROWS("Failed to set revocation date: " << SSL::getErrorStr());
  }

  ASN1_TIME_free(tm);
}

void Revoked::setReason(const string &reason) {
  if (reason == "unspecified") return;

  const char *reasons[] = {
	"unspecified",
	"keyCompromise",
	"CACompromise",
	"affiliationChanged",
	"superseded",
	"cessationOfOperation",
	"certificateHold",
    "removeFromCRL",
    "privilegeWithdrawn",
    "aACompromise",
    0
  };

  ASN1_ENUMERATED *a = ASN1_ENUMERATED_new();

  for (int i = 0; reasons[i]; i++)
    if (reason == reasons[i]) {
      ASN1_ENUMERATED_set(a, i);
      break;
    }

  if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, a, 0, 0)) {
    THROWS("Failed to add extension 'CRLReason'='" << reason
           << "': " << SSL::getErrorStr());
   	ASN1_ENUMERATED_free(a);
  }

  ASN1_ENUMERATED_free(a);
}

void Revoked::setSerial(int number) {
  ASN1_INTEGER *serial = ASN1_INTEGER_new();
  ASN1_INTEGER_set(serial, number);

  if (!X509_REVOKED_set_serialNumber(rev, serial))
    THROWS("Failed to set revoked serial number: " << SSL::getErrorStr());

  ASN1_INTEGER_free(serial);
}
<|endoftext|>


<commit_before>// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "rendersystems/GL/indexbufferGL.h"
#include <glad/glad.h>

namespace CodeHero {

IndexBufferGL::IndexBufferGL() {
    glGenBuffers(1, &_GetGPUObjectHandle()->intHandle);
}

IndexBufferGL::~IndexBufferGL() {
    glDeleteBuffers(1, &_GetGPUObjectHandle()->intHandle);
}

void IndexBufferGL::Use() {
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetGPUObject().intHandle);
}

void IndexBufferGL::Unuse() {
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}

void IndexBufferGL::_SetDataImpl(const void* iData) {
    Use();

    glBufferData(
            GL_ELEMENT_ARRAY_BUFFER,
            m_IndexSize,
            iData,
            m_IsDynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
}

} // namespace CodeHero

<commit_msg>Fix wrong size for index buffer<commit_after>// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "rendersystems/GL/indexbufferGL.h"
#include <glad/glad.h>

namespace CodeHero {

IndexBufferGL::IndexBufferGL() {
    glGenBuffers(1, &_GetGPUObjectHandle()->intHandle);
}

IndexBufferGL::~IndexBufferGL() {
    glDeleteBuffers(1, &_GetGPUObjectHandle()->intHandle);
}

void IndexBufferGL::Use() {
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetGPUObject().intHandle);
}

void IndexBufferGL::Unuse() {
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}

void IndexBufferGL::_SetDataImpl(const void* iData) {
    Use();

    // TODO(pierre) The sizeof should be more abstracted
    glBufferData(
            GL_ELEMENT_ARRAY_BUFFER,
            m_IndexSize * sizeof(unsigned int),
            iData,
            m_IsDynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
}

} // namespace CodeHero

<|endoftext|>


<commit_before>/*
 * THE NEW CHRONOTEXT TOOLKIT: https://github.com/arielm/new-chronotext-toolkit
 * COPYRIGHT (C) 2012, ARIEL MALKA ALL RIGHTS RESERVED.
 *
 * THE FOLLOWING SOURCE-CODE IS DISTRIBUTED UNDER THE MODIFIED BSD LICENSE:
 * https://github.com/arielm/new-chronotext-toolkit/blob/master/LICENSE.md
 */

#include "chronotext/InputSource.h"

#include "cinder/app/App.h"
#include "cinder/Utilities.h"

using namespace std;
using namespace ci;
using namespace app;

namespace chronotext
{
    InputSourceRef InputSource::getResource(const std::string &resourceName)
    {
        InputSource *source = new InputSource(TYPE_RESOURCE);
        source->resourceName = source->filePathHint = resourceName;

#if defined(CINDER_COCOA)
        source->filePath = getResourcePath(resourceName);
#endif

        return InputSourceRef(source);
    }

    DataSourceRef InputSource::loadResource(const std::string &resourceName)
    {
        return InputSource::getResource(resourceName)->loadDataSource();
    }

    InputSourceRef InputSource::getResource(const string &resourceName, int mswID, const std::string &mswType)
    {
        InputSource *source = new InputSource(TYPE_RESOURCE_MSW);
        source->mswID = mswID;
        source->mswType = mswType;
        source->resourceName = source->filePathHint = resourceName;

        return InputSourceRef(source);
    }

    DataSourceRef InputSource::loadResource(const string &resourceName, int mswID, const std::string &mswType)
    {
        return InputSource::getResource(resourceName, mswID, mswType)->loadDataSource();
    }

    InputSourceRef InputSource::getFileInDocuments(const std::string &relativePath)
    {
        return InputSource::getFile(getDocumentsDirectory() / relativePath);
    }

    DataSourceRef InputSource::loadFileInDocuments(const std::string &relativePath)
    {
        return DataSourcePath::create(getDocumentsDirectory() / relativePath);
    }

    InputSourceRef InputSource::getFile(const fs::path &filePath)
    {
        InputSource *source = new InputSource(TYPE_FILE);
        source->filePath = filePath;
        source->filePathHint = filePath.string();

        return InputSourceRef(source);
    }

    DataSourceRef InputSource::loadFile(const fs::path &filePath)
    {
        return DataSourcePath::create(filePath);
    }

    DataSourceRef InputSource::loadDataSource()
    {
        switch (type)
        {
            case TYPE_RESOURCE:
            {
#if defined(CHR_COMPLEX) && defined(CINDER_ANDROID)
                AAsset* asset = AAssetManager_open(gAssetManager, resourceName.c_str(), AASSET_MODE_STREAMING);

                if (asset)
                {
                    AAsset_close(asset);
                    return DataSourceAsset::create(gAssetManager, resourceName);
                }
                else
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
#elif defined(CINDER_ANDROID)
                try
                {
                    return app::loadResource(resourceName);
                }
                catch (exception &e)
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
#else
                if (fs::exists(filePath))
                {
                    return DataSourcePath::create(filePath);
                }
                else
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
#endif
            }

            case TYPE_RESOURCE_MSW:
            {
                try
                {
                    return app::loadResource(resourceName, mswID, mswType);
                }
                catch (exception &e)
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
            }

            case TYPE_FILE:
            {
                if (fs::exists(filePath))
                {
                    return DataSourcePath::create(filePath);
                }
                else
                {
                    throw Exception("FILE NOT FOUND: " + filePathHint);
                }
            }
        }

        return DataSourceRef();
    }

    bool InputSource::isFile() const
    {
        return !filePath.empty();
    }

    fs::path InputSource::getFilePath() const
    {
        return filePath;
    }

    string InputSource::getFilePathHint() const
    {
        return filePathHint;
    }

    string InputSource::getUniqueName() const
    {
        switch (type)
        {
            case TYPE_RESOURCE:
                return "res://" + resourceName;

            case TYPE_RESOURCE_MSW:
                return "res_msw://" + boost::lexical_cast<string>(mswID) + "/" + mswType;

            case TYPE_FILE:
                if (fs::exists(filePath))
                {
                    return "file://" + fs::canonical(filePath).string();
                }
                else
                {
                    return "file:://undefined";
                }
        }

        return "";
    }

    void InputSource::setFilePathHint(const string &hint)
    {
        filePathHint = hint;
    }

#if defined(CINDER_COCOA)
    fs::path InputSource::getResourcePath()
    {
#if defined(CHR_COMPLEX)
        CFBundleRef bundle = CFBundleGetMainBundle();
        CFURLRef url = CFBundleCopyBundleURL(bundle);
        CFStringRef tmp = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);

        CFIndex length = CFStringGetLength(tmp);
        CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
        char *buffer = (char*)malloc(maxSize);
        CFStringGetCString(tmp, buffer, maxSize, kCFStringEncodingUTF8);

        fs::path path(buffer);

        CFRelease(url);
        CFRelease(tmp);
        free(buffer);

        return path;
#else
        return App::getResourcePath();
#endif
    }
#endif

#if defined(CINDER_COCOA)
    fs::path InputSource::getResourcePath(const string &resourceName)
    {
#if defined(CHR_COMPLEX)
        return getResourcePath() / resourceName;
#else
        return App::getResourcePath(resourceName);
#endif
    }
#endif

#if defined(CHR_COMPLEX) && defined(CINDER_ANDROID)

    void InputSource::setAndroidAssetManager(AAssetManager *assetManager)
    {
        gAssetManager = assetManager;
    }

    AAssetManager* InputSource::getAndroidAssetManager()
    {
        return gAssetManager;
    }

    void InputSource::setAndroidInternalDataPath(const string &internalDataPath)
    {
        gInternalDataPath = fs::path(internalDataPath);
    }

    fs::path InputSource::getAndroidInternalDataPath()
    {
        return gInternalDataPath;
    }

    void InputSource::setAndroidApkPath(const string &apkPath)
    {
        gApkPath = fs::path(apkPath);
    }

    fs::path InputSource::getAndroidApkPath()
    {
        return gApkPath;
    }

#endif
}
<commit_msg>InputSource: TWEAKS, IN ADDITION TO PREVIOUS Exception ENHANCEMENT<commit_after>/*
 * THE NEW CHRONOTEXT TOOLKIT: https://github.com/arielm/new-chronotext-toolkit
 * COPYRIGHT (C) 2012, ARIEL MALKA ALL RIGHTS RESERVED.
 *
 * THE FOLLOWING SOURCE-CODE IS DISTRIBUTED UNDER THE MODIFIED BSD LICENSE:
 * https://github.com/arielm/new-chronotext-toolkit/blob/master/LICENSE.md
 */

#include "chronotext/InputSource.h"

#include "cinder/app/App.h"
#include "cinder/Utilities.h"

using namespace std;
using namespace ci;
using namespace app;

namespace chronotext
{
    InputSourceRef InputSource::getResource(const std::string &resourceName)
    {
        InputSource *source = new InputSource(TYPE_RESOURCE);
        source->resourceName = source->filePathHint = resourceName;

#if defined(CINDER_COCOA)
        source->filePath = getResourcePath(resourceName);
#endif

        return InputSourceRef(source);
    }

    DataSourceRef InputSource::loadResource(const std::string &resourceName)
    {
        return InputSource::getResource(resourceName)->loadDataSource();
    }

    InputSourceRef InputSource::getResource(const string &resourceName, int mswID, const std::string &mswType)
    {
        InputSource *source = new InputSource(TYPE_RESOURCE_MSW);
        source->mswID = mswID;
        source->mswType = mswType;
        source->resourceName = source->filePathHint = resourceName;

        return InputSourceRef(source);
    }

    DataSourceRef InputSource::loadResource(const string &resourceName, int mswID, const std::string &mswType)
    {
        return InputSource::getResource(resourceName, mswID, mswType)->loadDataSource();
    }

    InputSourceRef InputSource::getFileInDocuments(const std::string &relativePath)
    {
        return InputSource::getFile(getDocumentsDirectory() / relativePath);
    }

    DataSourceRef InputSource::loadFileInDocuments(const std::string &relativePath)
    {
        return DataSourcePath::create(getDocumentsDirectory() / relativePath);
    }

    InputSourceRef InputSource::getFile(const fs::path &filePath)
    {
        InputSource *source = new InputSource(TYPE_FILE);
        source->filePath = filePath;
        source->filePathHint = filePath.string();

        return InputSourceRef(source);
    }

    DataSourceRef InputSource::loadFile(const fs::path &filePath)
    {
        return DataSourcePath::create(filePath);
    }

    DataSourceRef InputSource::loadDataSource()
    {
        switch (type)
        {
            case TYPE_RESOURCE:
            {
#if defined(CHR_COMPLEX) && defined(CINDER_ANDROID)
                AAsset* asset = AAssetManager_open(gAssetManager, resourceName.c_str(), AASSET_MODE_STREAMING);

                if (asset)
                {
                    AAsset_close(asset);
                    return DataSourceAsset::create(gAssetManager, resourceName);
                }
                else
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
#elif defined(CINDER_ANDROID)
                try
                {
                    return app::loadResource(resourceName);
                }
                catch (exception &e)
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
#else
                if (fs::exists(filePath))
                {
                    return DataSourcePath::create(filePath);
                }
                else
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
#endif
            }

            case TYPE_RESOURCE_MSW:
            {
                try
                {
                    return app::loadResource(resourceName, mswID, mswType);
                }
                catch (exception &e)
                {
                    throw Exception("RESOURCE NOT FOUND: " + filePathHint);
                }
            }

            case TYPE_FILE:
            {
                if (fs::exists(filePath))
                {
                    return DataSourcePath::create(filePath);
                }
                else
                {
                    throw Exception("FILE NOT FOUND: " + filePathHint);
                }
            }
        }

        return DataSourceRef();
    }

    bool InputSource::isFile() const
    {
        return !filePath.empty();
    }

    fs::path InputSource::getFilePath() const
    {
        return filePath;
    }

    string InputSource::getFilePathHint() const
    {
        return filePathHint;
    }

    string InputSource::getUniqueName() const
    {
        switch (type)
        {
            case TYPE_RESOURCE:
                return "res://" + resourceName;

            case TYPE_RESOURCE_MSW:
                return "res_msw://" + boost::lexical_cast<string>(mswID) + "/" + mswType;

            case TYPE_FILE:
                if (fs::exists(filePath))
                {
                    return "file://" + fs::canonical(filePath).string();
                }
                else
                {
                    return "undefined://" + filePathHint;
                }
        }

        return "";
    }

    void InputSource::setFilePathHint(const string &hint)
    {
        filePathHint = hint;
    }

#if defined(CINDER_COCOA)
    fs::path InputSource::getResourcePath()
    {
#if defined(CHR_COMPLEX)
        CFBundleRef bundle = CFBundleGetMainBundle();
        CFURLRef url = CFBundleCopyBundleURL(bundle);
        CFStringRef tmp = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);

        CFIndex length = CFStringGetLength(tmp);
        CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
        char *buffer = (char*)malloc(maxSize);
        CFStringGetCString(tmp, buffer, maxSize, kCFStringEncodingUTF8);

        fs::path path(buffer);

        CFRelease(url);
        CFRelease(tmp);
        free(buffer);

        return path;
#else
        return App::getResourcePath();
#endif
    }
#endif

#if defined(CINDER_COCOA)
    fs::path InputSource::getResourcePath(const string &resourceName)
    {
#if defined(CHR_COMPLEX)
        return getResourcePath() / resourceName;
#else
        return App::getResourcePath(resourceName);
#endif
    }
#endif

#if defined(CHR_COMPLEX) && defined(CINDER_ANDROID)

    void InputSource::setAndroidAssetManager(AAssetManager *assetManager)
    {
        gAssetManager = assetManager;
    }

    AAssetManager* InputSource::getAndroidAssetManager()
    {
        return gAssetManager;
    }

    void InputSource::setAndroidInternalDataPath(const string &internalDataPath)
    {
        gInternalDataPath = fs::path(internalDataPath);
    }

    fs::path InputSource::getAndroidInternalDataPath()
    {
        return gInternalDataPath;
    }

    void InputSource::setAndroidApkPath(const string &apkPath)
    {
        gApkPath = fs::path(apkPath);
    }

    fs::path InputSource::getAndroidApkPath()
    {
        return gApkPath;
    }

#endif
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: propmultiplex.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: obo $ $Date: 2005-06-14 16:46:37 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _COMPHELPER_PROPERTY_MULTIPLEX_HXX_
#define _COMPHELPER_PROPERTY_MULTIPLEX_HXX_

#ifndef _COMPHELPER_PROPERTY_STATE_HXX_
#include <comphelper/propstate.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#ifndef INCLUDED_COMPHELPERDLLAPI_H
#include "comphelper/comphelperdllapi.h"
#endif

//=========================================================================
//= property helper classes
//=========================================================================

//.........................................................................
namespace comphelper
{
//.........................................................................

    class OPropertyChangeMultiplexer;

    //==================================================================
    //= OPropertyChangeListener
    //==================================================================
    /// simple listener adapter for property sets
    class COMPHELPER_DLLPUBLIC OPropertyChangeListener
    {
        friend class OPropertyChangeMultiplexer;

        OPropertyChangeMultiplexer* m_pAdapter;
        ::osl::Mutex&               m_rMutex;

    public:
        OPropertyChangeListener(::osl::Mutex& _rMutex)
            : m_pAdapter(NULL), m_rMutex(_rMutex) { }
        virtual ~OPropertyChangeListener();

        virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException) = 0;
        virtual void _disposing(const ::com::sun::star::lang::EventObject& _rSource) throw( ::com::sun::star::uno::RuntimeException);

    protected:
        /** If the derivee also owns the mutex which we know as reference, then call this within your
            derivee's dtor.
        */
        void    disposeAdapter();

        // pseudo-private. Making it private now could break compatibility
        void    setAdapter( OPropertyChangeMultiplexer* _pAdapter );
    };

    //==================================================================
    //= OPropertyChangeMultiplexer
    //==================================================================
    /// multiplexer for property changes
    class COMPHELPER_DLLPUBLIC OPropertyChangeMultiplexer   :public cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener>
    {
        friend class OPropertyChangeListener;
         ::com::sun::star::uno::Sequence< ::rtl::OUString >     m_aProperties;
         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>   m_xSet;
        OPropertyChangeListener*                    m_pListener;
        sal_Int32                                   m_nLockCount;
        sal_Bool                                    m_bListening        : 1;
        sal_Bool                                    m_bAutoSetRelease   : 1;

        virtual ~OPropertyChangeMultiplexer();
    public:
        OPropertyChangeMultiplexer(OPropertyChangeListener* _pListener, const  ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxSet, sal_Bool _bAutoReleaseSet = sal_True);

    // XEventListener
        virtual void SAL_CALL disposing( const  ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException);

    // XPropertyChangeListener
        virtual void SAL_CALL propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);

        /// incremental lock
        void        lock();
        /// incremental unlock
        void        unlock();
        /// get the lock count
        sal_Int32   locked() const { return m_nLockCount; }

        void addProperty(const ::rtl::OUString& aPropertyName);
        void dispose();
    };

//.........................................................................
}   // namespace comphelper
//.........................................................................

#endif // _COMPHELPER_PROPERTY_MULTIPLEX_HXX_

<commit_msg>INTEGRATION: CWS ooo19126 (1.8.30); FILE MERGED 2005/09/05 15:23:46 rt 1.8.30.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: propmultiplex.hxx,v $
 *
 *  $Revision: 1.9 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 02:37:07 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _COMPHELPER_PROPERTY_MULTIPLEX_HXX_
#define _COMPHELPER_PROPERTY_MULTIPLEX_HXX_

#ifndef _COMPHELPER_PROPERTY_STATE_HXX_
#include <comphelper/propstate.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#ifndef INCLUDED_COMPHELPERDLLAPI_H
#include "comphelper/comphelperdllapi.h"
#endif

//=========================================================================
//= property helper classes
//=========================================================================

//.........................................................................
namespace comphelper
{
//.........................................................................

    class OPropertyChangeMultiplexer;

    //==================================================================
    //= OPropertyChangeListener
    //==================================================================
    /// simple listener adapter for property sets
    class COMPHELPER_DLLPUBLIC OPropertyChangeListener
    {
        friend class OPropertyChangeMultiplexer;

        OPropertyChangeMultiplexer* m_pAdapter;
        ::osl::Mutex&               m_rMutex;

    public:
        OPropertyChangeListener(::osl::Mutex& _rMutex)
            : m_pAdapter(NULL), m_rMutex(_rMutex) { }
        virtual ~OPropertyChangeListener();

        virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException) = 0;
        virtual void _disposing(const ::com::sun::star::lang::EventObject& _rSource) throw( ::com::sun::star::uno::RuntimeException);

    protected:
        /** If the derivee also owns the mutex which we know as reference, then call this within your
            derivee's dtor.
        */
        void    disposeAdapter();

        // pseudo-private. Making it private now could break compatibility
        void    setAdapter( OPropertyChangeMultiplexer* _pAdapter );
    };

    //==================================================================
    //= OPropertyChangeMultiplexer
    //==================================================================
    /// multiplexer for property changes
    class COMPHELPER_DLLPUBLIC OPropertyChangeMultiplexer   :public cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener>
    {
        friend class OPropertyChangeListener;
         ::com::sun::star::uno::Sequence< ::rtl::OUString >     m_aProperties;
         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>   m_xSet;
        OPropertyChangeListener*                    m_pListener;
        sal_Int32                                   m_nLockCount;
        sal_Bool                                    m_bListening        : 1;
        sal_Bool                                    m_bAutoSetRelease   : 1;

        virtual ~OPropertyChangeMultiplexer();
    public:
        OPropertyChangeMultiplexer(OPropertyChangeListener* _pListener, const  ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxSet, sal_Bool _bAutoReleaseSet = sal_True);

    // XEventListener
        virtual void SAL_CALL disposing( const  ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException);

    // XPropertyChangeListener
        virtual void SAL_CALL propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);

        /// incremental lock
        void        lock();
        /// incremental unlock
        void        unlock();
        /// get the lock count
        sal_Int32   locked() const { return m_nLockCount; }

        void addProperty(const ::rtl::OUString& aPropertyName);
        void dispose();
    };

//.........................................................................
}   // namespace comphelper
//.........................................................................

#endif // _COMPHELPER_PROPERTY_MULTIPLEX_HXX_

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: regpathhelper.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 02:38:04 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _COMPHELPER_REGPATHHELPER_HXX_
#define _COMPHELPER_REGPATHHELPER_HXX_

#ifndef _RTL_OUSTRING_HXX_
#include <rtl/ustring.hxx>
#endif

namespace comphelper
{

/**
 * This function returns a path to the user registry file.
 * Search for the user registry using the following rules:
 *

 *
 1. (for further use) search in sversion.ini (.sversionrc) for an entry
 *      REGISTRY_VERSION_STRING (example: UserRegistry 5.0/505=test.rdb) in the section
 *      [Registry]. If found, then take this value instead of the name "user.rdb".
 *
 2. Search in the config directory of the user for a file "user.rdb". If
 *      found return the full path and name of the file. If not found, retry this
 *      step with a dot before ".user.rdb".
 *
 3. If not found a new user registry with name "user.rdb" will be created in the user
 *      config directory.
 *

 *

 * @author Juergen Schmidt
 */
::rtl::OUString getPathToUserRegistry();

/**
 * This function returns a path to the system registry file.
 * The system registry will always be searched in the same directory of the
 * executable. The name of the system registry is "applicat.rdb". If the system
 * registry was not found, then the environment variable STAR_REGISTRY will be checked.
 * If this variable was set, it must contain a full path to a valid system registry.
 * Search for the user registry using the following rules:
 *
 *

 * @author Juergen Schmidt
 */

::rtl::OUString getPathToSystemRegistry();

}

#endif

<commit_msg>INTEGRATION: CWS changefileheader (1.2.246); FILE MERGED 2008/04/01 15:05:23 thb 1.2.246.2: #i85898# Stripping all external header guards 2008/03/31 12:19:29 rt 1.2.246.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: regpathhelper.hxx,v $
 * $Revision: 1.3 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _COMPHELPER_REGPATHHELPER_HXX_
#define _COMPHELPER_REGPATHHELPER_HXX_

#include <rtl/ustring.hxx>

namespace comphelper
{

/**
 * This function returns a path to the user registry file.
 * Search for the user registry using the following rules:
 *

 *
 1. (for further use) search in sversion.ini (.sversionrc) for an entry
 *      REGISTRY_VERSION_STRING (example: UserRegistry 5.0/505=test.rdb) in the section
 *      [Registry]. If found, then take this value instead of the name "user.rdb".
 *
 2. Search in the config directory of the user for a file "user.rdb". If
 *      found return the full path and name of the file. If not found, retry this
 *      step with a dot before ".user.rdb".
 *
 3. If not found a new user registry with name "user.rdb" will be created in the user
 *      config directory.
 *

 *

 * @author Juergen Schmidt
 */
::rtl::OUString getPathToUserRegistry();

/**
 * This function returns a path to the system registry file.
 * The system registry will always be searched in the same directory of the
 * executable. The name of the system registry is "applicat.rdb". If the system
 * registry was not found, then the environment variable STAR_REGISTRY will be checked.
 * If this variable was set, it must contain a full path to a valid system registry.
 * Search for the user registry using the following rules:
 *
 *

 * @author Juergen Schmidt
 */

::rtl::OUString getPathToSystemRegistry();

}

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: propsetaccessimpl.hxx,v $
 *
 *  $Revision: 1.1 $
 *
 *  last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef CONFIGMGR_API_PROPERTYSETIMPL_HXX_
#define CONFIGMGR_API_PROPERTYSETIMPL_HXX_

#ifndef CONFIGMGR_APITYPES_HXX_
#include "apitypes.hxx"
#endif

#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XHIERARCHICALPROPERTYSET_HPP_
#include <com/sun/star/beans/XHierarchicalPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XMULTIHIERARCHICALPROPERTYSET_HPP_
#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif

namespace configmgr
{
    namespace css = ::com::sun::star;
    namespace uno = ::com::sun::star::uno;
    namespace lang = ::com::sun::star::lang;
    namespace beans = ::com::sun::star::beans;

    /* implementations of the interfaces supported by a (parent) node
        within the configuration tree.
        (read-only operation)
    */
    namespace configapi
    {
        class NodeAccess;
        class NodeGroupInfoAccess;
        class NodeGroupAccess;

    // getting Property Metadata
        // XPropertySet & XMultiPropertySet
        uno::Reference< beans::XPropertySetInfo > implGetPropertySetInfo( NodeGroupInfoAccess& rNode )
            throw(uno::RuntimeException);

        // XHierarchicalPropertySet & XHierarchicalMultiPropertySet
        uno::Reference< beans::XHierarchicalPropertySetInfo > implGetHierarchicalPropertySetInfo( NodeGroupInfoAccess& rNode )
            throw(uno::RuntimeException);

    // setting values - may all throw (PropertyVeto)Exceptions on read-only property sets
        // XPropertySet
        void implSetPropertyValue( NodeGroupAccess& rNode, const OUString& aPropertyName, const uno::Any& aValue )
            throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
                      lang::WrappedTargetException, uno::RuntimeException);

         // XMultiPropertySet
       void implSetPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
            throw(beans::PropertyVetoException, lang::IllegalArgumentException,
                      lang::WrappedTargetException, uno::RuntimeException);

        // XHierarchicalPropertySet
        void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const OUString& aPropertyName, const uno::Any& aValue )
            throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
                  lang::WrappedTargetException, uno::RuntimeException);

         // XMultiHierarchicalPropertySet
       void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
            throw(beans::PropertyVetoException, lang::IllegalArgumentException,
                  lang::WrappedTargetException, uno::RuntimeException);

    // getting values
        // XPropertySet
        uno::Any implGetPropertyValue( NodeGroupInfoAccess& rNode,const OUString& PropertyName )
            throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);

         // XMultiPropertySet
        uno::Sequence< uno::Any > implGetPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames )
            throw(uno::RuntimeException);

        // XHierarchicalPropertySet
        uno::Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const OUString& PropertyName )
            throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);

         // XMultiHierarchicalPropertySet
        uno::Sequence< uno::Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames )
            throw(uno::RuntimeException);

    // SPECIAL: firePropertiesChangeEvent
         // XMultiPropertySet
        void implFirePropertiesChangeEvent( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
            throw(uno::RuntimeException);

    // XPropertyState
        beans::PropertyState implGetPropertyState( NodeAccess& rNode, const OUString& PropertyName )
            throw(beans::UnknownPropertyException, uno::RuntimeException);

        uno::Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const uno::Sequence< OUString >& aPropertyName )
            throw(beans::UnknownPropertyException, uno::RuntimeException);

        void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& PropertyName )
            throw(beans::UnknownPropertyException, uno::RuntimeException);

        uno::Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
            throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);

    }

}
#endif // CONFIGMGR_API_PROPERTYSETIMPL_HXX_

<commit_msg>implGetPropertySetInfo takes an additional parameter<commit_after>/*************************************************************************
 *
 *  $RCSfile: propsetaccessimpl.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: fs $ $Date: 2000-11-21 19:19:09 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef CONFIGMGR_API_PROPERTYSETIMPL_HXX_
#define CONFIGMGR_API_PROPERTYSETIMPL_HXX_

#ifndef CONFIGMGR_APITYPES_HXX_
#include "apitypes.hxx"
#endif

#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XHIERARCHICALPROPERTYSET_HPP_
#include <com/sun/star/beans/XHierarchicalPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XMULTIHIERARCHICALPROPERTYSET_HPP_
#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif

namespace configmgr
{
    namespace css = ::com::sun::star;
    namespace uno = ::com::sun::star::uno;
    namespace lang = ::com::sun::star::lang;
    namespace beans = ::com::sun::star::beans;

    /* implementations of the interfaces supported by a (parent) node
        within the configuration tree.
        (read-only operation)
    */
    namespace configapi
    {
        class NodeAccess;
        class NodeGroupInfoAccess;
        class NodeGroupAccess;

    // getting Property Metadata
        // XPropertySet & XMultiPropertySet
        uno::Reference< beans::XPropertySetInfo > implGetPropertySetInfo( NodeGroupInfoAccess& rNode, sal_Bool _bWriteable )
            throw(uno::RuntimeException);

        // XHierarchicalPropertySet & XHierarchicalMultiPropertySet
        uno::Reference< beans::XHierarchicalPropertySetInfo > implGetHierarchicalPropertySetInfo( NodeGroupInfoAccess& rNode )
            throw(uno::RuntimeException);

    // setting values - may all throw (PropertyVeto)Exceptions on read-only property sets
        // XPropertySet
        void implSetPropertyValue( NodeGroupAccess& rNode, const OUString& aPropertyName, const uno::Any& aValue )
            throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
                      lang::WrappedTargetException, uno::RuntimeException);

         // XMultiPropertySet
       void implSetPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
            throw(beans::PropertyVetoException, lang::IllegalArgumentException,
                      lang::WrappedTargetException, uno::RuntimeException);

        // XHierarchicalPropertySet
        void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const OUString& aPropertyName, const uno::Any& aValue )
            throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
                  lang::WrappedTargetException, uno::RuntimeException);

         // XMultiHierarchicalPropertySet
       void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
            throw(beans::PropertyVetoException, lang::IllegalArgumentException,
                  lang::WrappedTargetException, uno::RuntimeException);

    // getting values
        // XPropertySet
        uno::Any implGetPropertyValue( NodeGroupInfoAccess& rNode,const OUString& PropertyName )
            throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);

         // XMultiPropertySet
        uno::Sequence< uno::Any > implGetPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames )
            throw(uno::RuntimeException);

        // XHierarchicalPropertySet
        uno::Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const OUString& PropertyName )
            throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);

         // XMultiHierarchicalPropertySet
        uno::Sequence< uno::Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames )
            throw(uno::RuntimeException);

    // SPECIAL: firePropertiesChangeEvent
         // XMultiPropertySet
        void implFirePropertiesChangeEvent( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
            throw(uno::RuntimeException);

    // XPropertyState
        beans::PropertyState implGetPropertyState( NodeAccess& rNode, const OUString& PropertyName )
            throw(beans::UnknownPropertyException, uno::RuntimeException);

        uno::Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const uno::Sequence< OUString >& aPropertyName )
            throw(beans::UnknownPropertyException, uno::RuntimeException);

        void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& PropertyName )
            throw(beans::UnknownPropertyException, uno::RuntimeException);

        uno::Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
            throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);

    }

}
#endif // CONFIGMGR_API_PROPERTYSETIMPL_HXX_

<|endoftext|>