text:
//  Copyright (c) 2007-2014 Hartmut Kaiser
//  Copyright (c)      2011 Bryce Lelbach
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#if !defined(HPX_COMPONENTS_STUBS_RUNTIME_SUPPORT_JUN_09_2008_0503PM)
#define HPX_COMPONENTS_STUBS_RUNTIME_SUPPORT_JUN_09_2008_0503PM

#include <hpx/hpx_fwd.hpp>
#include <hpx/runtime/naming/name.hpp>
#include <hpx/runtime/components/component_type.hpp>
#include <hpx/runtime/actions/manage_object_action.hpp>
#include <hpx/runtime/components/server/runtime_support.hpp>
#include <hpx/util/ini.hpp>
#include <hpx/util/move.hpp>
#include <hpx/util/decay.hpp>
#include <hpx/runtime/applier/apply_colocated.hpp>
#include <hpx/lcos/future.hpp>
#include <hpx/async.hpp>

#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/type_traits/remove_reference.hpp>

#include <boost/serialization/vector.hpp>

namespace hpx { namespace components { namespace stubs
{
    ///////////////////////////////////////////////////////////////////////////
    // The \a runtime_support class is the client side representation of a
    // \a server#runtime_support component
    struct HPX_EXPORT runtime_support
    {
        ///////////////////////////////////////////////////////////////////////
        /// \brief  The function \a get_factory_properties is used to
        ///         determine, whether instances of the derived component can
        ///         be created in blocks (i.e. more than one instance at once).
        ///         This function is used by the \a distributing_factory to
        ///         determine a correct allocation strategy
        static lcos::future<int> get_factory_properties_async(
            naming::id_type const& targetgid, components::component_type type);

        static int get_factory_properties(naming::id_type const& targetgid,
            components::component_type type);

        ///////////////////////////////////////////////////////////////////////
        /// Create a new component \a type using the runtime_support with the
        /// given \a targetgid. This is a non-blocking call. The caller needs
        /// to call \a future#get on the result of this function
        /// to obtain the global id of the newly created object.
        template <typename Component>
        static lcos::future<naming::id_type>
        create_component_async(naming::id_type const& gid)
        {
            if (!naming::is_locality(gid))
            {
                HPX_THROW_EXCEPTION(bad_parameter,
                    "stubs::runtime_support::create_component_async",
                    "The id passed as the first argument is not representing"
                        " a locality");
                return lcos::make_ready_future(naming::invalid_id);
            }

            // Create a future, execute the required action,
            // we simply return the initialized future, the caller needs
            // to call get() on the return value to obtain the result
            typedef typename server::create_component_action0<Component>
                action_type;
            return hpx::async<action_type>(gid);
        }

        /// Create a new component \a type using the runtime_support with the
        /// given \a targetgid. Block for the creation to finish.
        template <typename Component>
        static naming::id_type create_component(naming::id_type const& gid)
        {
            // The following get yields control while the action above
            // is executed and the result is returned to the future
            return create_component_async<Component>(gid).get();
        }

        template <typename Component>
        static lcos::future<std::vector<naming::id_type> >
        bulk_create_component_async(naming::id_type const& gid,
            std::size_t count)
        {
            if (!naming::is_locality(gid))
            {
                HPX_THROW_EXCEPTION(bad_parameter,
                    "stubs::runtime_support::bulk_create_component_async",
                    "The id passed as the first argument is not representing"
                        " a locality");
                return lcos::make_ready_future(std::vector<naming::id_type>());
            }

            // Create a future, execute the required action,
            // we simply return the initialized future, the caller needs
            // to call get() on the return value to obtain the result
            typedef typename server::bulk_create_component_action1<Component>
                action_type;
            return hpx::async<action_type>(gid, count);
        }

        /// Create a new component \a type using the runtime_support with the
        /// given \a targetgid. Block for the creation to finish.
        template <typename Component>
        static std::vector<naming::id_type>
        bulk_create_component(naming::id_type const& gid, std::size_t count)
        {
            // The following get yields control while the action above
            // is executed and the result is returned to the future
            return bulk_create_component_async<Component>(gid, count).get();
        }

        /// Create a new component \a type using the runtime_support with the
        /// given \a targetgid. This is a non-blocking call. The caller needs
        /// to call \a future#get on the result of this function
        /// to obtain the global id of the newly created object.
        template <typename Component>
        static lcos::future<naming::id_type>
        create_component_colocated_async(naming::id_type const& gid)
        {
            if (!naming::is_locality(gid))
            {
                HPX_THROW_EXCEPTION(bad_parameter,
                    "stubs::runtime_support::create_component_async",
                    "The id passed as the first argument is not representing"
                        " a locality");
                return lcos::make_ready_future(naming::invalid_id);
            }

            // Create a future, execute the required action,
            // we simply return the initialized future, the caller needs
            // to call get() on the return value to obtain the result
            typedef typename server::create_component_action0<Component>
                action_type;
            return hpx::async_colocated<action_type>(gid);
        }

        template <typename Component>
        static naming::id_type create_component_colocated(
            naming::id_type const& gid)
        {
            // The following get yields control while the action above
            // is executed and the result is returned to the future
            return create_component_colocated_async<Component>(gid).get();
        }

#define HPX_RUNTIME_SUPPORT_STUB_DECAY(Z, N, D)                               \
        typename hpx::util::decay<BOOST_PP_CAT(D, N)>::type                   \
/**/
#define HPX_RUNTIME_SUPPORT_STUB_CREATE(Z, N, D)                              \
        template <typename Component, BOOST_PP_ENUM_PARAMS(N, typename Arg)>  \
        static lcos::future<naming::id_type>                                  \
        create_component_async(naming::id_type const& gid,                    \
            HPX_ENUM_FWD_ARGS(N, Arg, arg))                                   \
        {                                                                     \
            if (!naming::is_locality(gid))                                    \
            {                                                                 \
                HPX_THROW_EXCEPTION(bad_parameter,                            \
                    "stubs::runtime_support::create_component_async",         \
                    "The id passed as the first argument is not representing" \
                        " a locality");                                       \
                return lcos::make_ready_future(naming::invalid_id);           \
            }                                                                 \
                                                                              \
            typedef typename                                                  \
                server::BOOST_PP_CAT(create_component_action, N)<             \
                    Component, BOOST_PP_ENUM(N,                               \
                        HPX_RUNTIME_SUPPORT_STUB_DECAY, Arg)>                 \
                action_type;                                                  \
            return hpx::async<action_type>(gid,                               \
                HPX_ENUM_FORWARD_ARGS(N , Arg, arg));                         \
        }                                                                     \
                                                                              \
        template <typename Component, BOOST_PP_ENUM_PARAMS(N, typename Arg)>  \
        static naming::id_type create_component(                              \
            naming::id_type const& gid, HPX_ENUM_FWD_ARGS(N, Arg, arg))       \
        {                                                                     \
            return create_component_async<Component>(                         \
                gid, HPX_ENUM_FORWARD_ARGS(N , Arg, arg)).get();              \
        }                                                                     \
                                                                              \
        template <typename Component, BOOST_PP_ENUM_PARAMS(N, typename Arg)>  \
        static lcos::future<naming::id_type>                                  \
        create_component_colocated_async(naming::id_type const& gid,          \
            HPX_ENUM_FWD_ARGS(N, Arg, arg))                                   \
        {                                                                     \
            typedef typename                                                  \
                server::BOOST_PP_CAT(create_component_action, N)<             \
                    Component, BOOST_PP_ENUM(N,                               \
                        HPX_RUNTIME_SUPPORT_STUB_DECAY, Arg)>                 \
                action_type;                                                  \
            return hpx::async_colocated<action_type>(gid,                     \
                HPX_ENUM_FORWARD_ARGS(N , Arg, arg));                         \
        }                                                                     \
                                                                              \
        template <typename Component, BOOST_PP_ENUM_PARAMS(N, typename Arg)>  \
        static naming::id_type create_component_colocated(                    \
            naming::id_type const& gid, HPX_ENUM_FWD_ARGS(N, Arg, arg))       \
        {                                                                     \
            return create_component_colocated_async<Component>(               \
                gid, HPX_ENUM_FORWARD_ARGS(N , Arg, arg)).get();              \
        }                                                                     \
    /**/

        BOOST_PP_REPEAT_FROM_TO(
            1
          , HPX_ACTION_ARGUMENT_LIMIT
          , HPX_RUNTIME_SUPPORT_STUB_CREATE
          , _
        )

#undef HPX_RUNTIME_SUPPORT_STUB_CREATE

#define HPX_RUNTIME_SUPPORT_STUB_BULK_CREATE(Z, N, D)                         \
        template <typename Component,                                         \
            BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), typename Arg)>              \
        static lcos::future<std::vector<naming::id_type> >                    \
        bulk_create_component_async(naming::id_type const& gid,               \
            std::size_t count, HPX_ENUM_FWD_ARGS(BOOST_PP_DEC(N), Arg, arg))  \
        {                                                                     \
            if (!naming::is_locality(gid))                                    \
            {                                                                 \
                HPX_THROW_EXCEPTION(bad_parameter,                            \
                    "stubs::runtime_support::bulk_create_component_async",    \
                    "The id passed as the first argument is not representing" \
                        " a locality");                                       \
                return lcos::make_ready_future(std::vector<naming::id_type>());\
            }                                                                 \
                                                                              \
            typedef typename                                                  \
                server::BOOST_PP_CAT(bulk_create_component_action, N)<        \
                    Component, BOOST_PP_ENUM(BOOST_PP_DEC(N),                 \
                        HPX_RUNTIME_SUPPORT_STUB_DECAY, Arg)>                 \
                action_type;                                                  \
            return hpx::async<action_type>(gid, count,                        \
                HPX_ENUM_FORWARD_ARGS(BOOST_PP_DEC(N), Arg, arg));            \
        }                                                                     \
                                                                              \
        template <typename Component,                                         \
            BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), typename Arg)>              \
        static std::vector<naming::id_type> bulk_create_component(            \
            naming::id_type const& gid, std::size_t count,                    \
                HPX_ENUM_FWD_ARGS(BOOST_PP_DEC(N), Arg, arg))                 \
        {                                                                     \
            return bulk_create_component_async<Component>(gid, count,         \
                HPX_ENUM_FORWARD_ARGS(BOOST_PP_DEC(N), Arg, arg)).get();      \
        }                                                                     \
    /**/

        BOOST_PP_REPEAT_FROM_TO(
            2
          , HPX_ACTION_ARGUMENT_LIMIT
          , HPX_RUNTIME_SUPPORT_STUB_BULK_CREATE
          , _
        )

#undef HPX_RUNTIME_SUPPORT_STUB_BULK_CREATE
#undef HPX_RUNTIME_SUPPORT_STUB_DECAY

        ///////////////////////////////////////////////////////////////////////
        // copy construct a component
        template <typename Component>
        static lcos::future<naming::id_type>
        copy_create_component_async(naming::id_type const& gid,
            boost::shared_ptr<Component> const& p, bool local_op)
        {
            if (!naming::is_locality(gid))
            {
                HPX_THROW_EXCEPTION(bad_parameter,
                    "stubs::runtime_support::copy_create_component_async",
                    "The id passed as the first argument is not representing"
                        " a locality");
                return lcos::make_ready_future(naming::invalid_id);
            }

            typedef typename server::copy_create_component_action<Component>
                action_type;
            return hpx::async<action_type>(gid, p, local_op);
        }

        template <typename Component>
        static naming::id_type copy_create_component(naming::id_type const& gid,
            boost::shared_ptr<Component> const& p, bool local_op)
        {
            // The following get yields control while the action above
            // is executed and the result is returned to the future
            return copy_create_component_async<Component>(gid, p, local_op).get();
        }

        ///////////////////////////////////////////////////////////////////////
        // copy construct a component
        template <typename Component>
        static lcos::future<naming::id_type>
        migrate_component_async(naming::id_type const& target_locality,
            boost::shared_ptr<Component> const& p,
            naming::id_type const& to_migrate)
        {
            if (!naming::is_locality(target_locality))
            {
                HPX_THROW_EXCEPTION(bad_parameter,
                    "stubs::runtime_support::migrate_component_async",
                    "The id passed as the first argument is not representing"
                        " a locality");
                return lcos::make_ready_future(naming::invalid_id);
            }

            typedef typename server::migrate_component_here_action<Component>
                action_type;
            return hpx::async<action_type>(target_locality, p, to_migrate);
        }

        template <typename Component>
        static naming::id_type migrate_component(
            naming::id_type const& target_locality,
            naming::id_type const& to_migrate,
            boost::shared_ptr<Component> const& p)
        {
            // The following get yields control while the action above
            // is executed and the result is returned to the future
            return migrate_component_async<Component>(
                target_locality, p, to_migrate).get();
        }

        ///////////////////////////////////////////////////////////////////////
        static lcos::future<std::vector<naming::id_type> >
        bulk_create_components_async(
            naming::id_type const& gid, components::component_type type,
            std::size_t count = 1);

        /// Create a new component \a type using the runtime_support with the
        /// given \a targetgid. Block for the creation to finish.
        static std::vector<naming::id_type> bulk_create_components(
            naming::id_type const& gid, components::component_type type,
            std::size_t count = 1);

        ///////////////////////////////////////////////////////////////////////
        /// Create a new memory block using the runtime_support with the
        /// given \a targetgid. This is a non-blocking call. The caller needs
        /// to call \a future#get on the result of this function
        /// to obtain the global id of the newly created object.
        template <typename T, typename Config>
        static lcos::future<naming::id_type>
        create_memory_block_async(
            naming::id_type const& id, std::size_t count,
            hpx::actions::manage_object_action<T, Config> const& act);

        /// Create a new memory block using the runtime_support with the
        /// given \a targetgid. Block for the creation to finish.
        template <typename T, typename Config>
        static naming::id_type create_memory_block(
            naming::id_type const& id, std::size_t count,
            hpx::actions::manage_object_action<T, Config> const& act)
        {
            // The following get yields control while the action above
            // is executed and the result is returned to the future
            return create_memory_block_async(id, count, act).get();
        }

        static lcos::future<bool>
        load_components_async(naming::id_type const& gid);
        static bool load_components(naming::id_type const& gid);

        static lcos::future<void>
        call_startup_functions_async(naming::id_type const& gid,
            bool pre_startup);
        static void call_startup_functions(naming::id_type const& gid,
            bool pre_startup);

        static lcos::future<void>
        call_shutdown_functions_async(naming::id_type const& gid,
            bool pre_shutdown);

        static void call_shutdown_functions(naming::id_type const& gid,
            bool pre_shutdown);
        static void free_component_sync(agas::gva const& g,
            naming::gid_type const& gid, boost::uint64_t count = 1);
        static void free_component_locally(agas::gva const& g,
            naming::gid_type const& gid);

        /// \brief Shutdown the given runtime system
        static lcos::future<void>
        shutdown_async(naming::id_type const& targetgid, double timeout = -1);
        static void shutdown(naming::id_type const& targetgid,
            double timeout = - 1);

        /// \brief Shutdown the runtime systems of all localities
        static void
        shutdown_all(naming::id_type const& targetgid, double timeout = -1);

        static void shutdown_all(double timeout = -1);

        ///////////////////////////////////////////////////////////////////////
        /// \brief Retrieve configuration information
        /// \brief Terminate the given runtime system
        static lcos::future<void>
        terminate_async(naming::id_type const& targetgid);

        static void terminate(naming::id_type const& targetgid);

        /// \brief Terminate the runtime systems of all localities
        static void terminate_all(naming::id_type const& targetgid);

        static void terminate_all();

        ///////////////////////////////////////////////////////////////////////
        static void
        update_agas_cache_entry(naming::id_type const& targetgid,
            naming::gid_type const& gid, naming::address const& g,
            boost::uint64_t count, boost::uint64_t offset);

        static void
        update_agas_cache_entry_colocated(naming::id_type const& targetgid,
            naming::gid_type const& gid, naming::address const& g,
            boost::uint64_t count, boost::uint64_t offset);

        ///////////////////////////////////////////////////////////////////////
        static void
        garbage_collect_non_blocking(naming::id_type const& targetgid);

        static lcos::future<void>
        garbage_collect_async(naming::id_type const& targetgid);

        static void
        garbage_collect(naming::id_type const& targetgid);

        ///////////////////////////////////////////////////////////////////////
        static lcos::future<naming::id_type>
        create_performance_counter_async(naming::id_type targetgid,
            performance_counters::counter_info const& info);
        static naming::id_type
        create_performance_counter(naming::id_type targetgid,
            performance_counters::counter_info const& info,
            error_code& ec = throws);

        ///////////////////////////////////////////////////////////////////////
        /// \brief Retrieve configuration information
        static lcos::future<util::section> get_config_async(
            naming::id_type const& targetgid);
        static void get_config(naming::id_type const& targetgid, util::section& ini);

        ///////////////////////////////////////////////////////////////////////
        /// \brief Retrieve instance count for given component type
        static lcos::future<boost::int32_t > get_instance_count_async(
            naming::id_type const& targetgid, components::component_type type);
        static boost::int32_t  get_instance_count(naming::id_type const& targetgid,
            components::component_type type);

        ///////////////////////////////////////////////////////////////////////
        static void
        call_shutdown_functions_async(naming::id_type const& gid,
            parcelset::endpoints_type const& endpoints);
    };
}}}

HPX_REGISTER_APPLY_COLOCATED_DECLARATION(
    hpx::components::server::runtime_support::update_agas_cache_entry_action
  , hpx_apply_colocated_update_agas_cache_entry_action
)

#endif


text:
#include "Lab.h"

#include <iostream>
#include <boost/exception/all.hpp>

#define FUSE_USE_VERSION 30
#include <fuse/fuse.h>

std::string labFilePath;

lab_fuse::Lab lab;

static int lab_flush() {
    try {
        lab_fuse::saveLabFile(labFilePath, lab);
        return 0;
    } catch (...) {
        std::cerr << boost::current_exception_diagnostic_information(true) << std::endl;
        return -EFAULT;
    }
}

static int xmp_getattr(const char *path, struct FUSE_STAT *stbuf)
{
    memset(stbuf, 0, sizeof(struct FUSE_STAT));
    if (strcmp(path, "/") == 0) {
        stbuf->st_mode = S_IFDIR | 0755;
        stbuf->st_nlink = 2;
        return 0;
    }

    std::string fileName(path + 1);

    auto position = lab.files.find(fileName);
    if (position == lab.files.end())
        return -ENOENT;

    const auto& labFile = position->second;

    stbuf->st_mode = S_IFREG | 0666;
    stbuf->st_nlink = 1;
    stbuf->st_size = labFile.data.size();
    return 0;
}

static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler, FUSE_OFF_T offset, struct fuse_file_info *fi)
{
    (void) offset;
    (void) fi;

    if (strcmp(path, "/") != 0)
        return -ENOENT;

    if (filler(buf, ".", NULL, 0) != 0)
        return -ENOMEM;
    if (filler(buf, "..", NULL, 0))
        return -ENOMEM;

    for (const auto& fileName : lab.filesOrder) {
        if (filler(buf, fileName.c_str(), NULL, 0))
            return -ENOMEM;
    }

    return 0;
}

static int xmp_open(const char *path, struct fuse_file_info *fi)
{
    std::string fileName(path + 1);

    auto position = lab.files.find(fileName);
    if (position == lab.files.end())
        return -ENOENT;

    if (fi->flags & O_TRUNC) {
        auto& labFile = position->second;
        labFile.data.clear();
    }

    return 0;
}

static int xmp_read(const char *path, char *buf, size_t size, FUSE_OFF_T offset, struct fuse_file_info *fi)
{
    (void) fi;

    std::string fileName(path + 1);

    auto position = lab.files.find(fileName);
    if (position == lab.files.end())
        return -ENOENT;

    const auto& labFile = position->second;

    if (offset < 0) {
        return -EINVAL;
    }

    size_t len = labFile.data.size();
    size_t ofs = static_cast<size_t>(offset);
    if (ofs > len) {
        return 0;
    }

    if (ofs + size > len)
        size = len - ofs;

    memcpy(buf, labFile.data.data() + ofs, size);

    return static_cast<int>(size);
}

static int xmp_write(const char *path, const char *buf, size_t size, FUSE_OFF_T offset, struct fuse_file_info *fi)
{
    (void) fi;

    std::string fileName(path + 1);

    auto position = lab.files.find(fileName);
    if (position == lab.files.end())
        return -ENOENT;

    auto& labFile = position->second;

    if (offset < 0) {
        return -EINVAL;
    }

    size_t len = labFile.data.size();
    size_t ofs = static_cast<size_t>(offset);

    if (ofs + size > len) {
        try {
            labFile.data.resize(ofs + size);
        } catch (...) {
            std::cerr << boost::current_exception_diagnostic_information(true) << std::endl;
            return -ENOMEM;
        }
    }

    memcpy(labFile.data.data() + ofs, buf, size);

    return static_cast<int>(size);
}

static int xmp_rename(const char *from, const char *to)
{
    std::string oldName(from + 1);
    std::string newName(to + 1);

    if (lab.files.count(newName) > 0) {
        std::cerr << "File with name '" << newName << "' already exists." << std::endl;
        return -EINVAL; // Cannot use the same name as existing file.
    }

    auto position = lab.files.find(oldName);
    if (position == lab.files.end())
        return -ENOENT;

    auto namePosition = std::find(lab.filesOrder.begin(), lab.filesOrder.end(), oldName);
    if (namePosition == lab.filesOrder.end()) {
        std::cerr << "Internal structure inconsistent. File '" << oldName << "' not found in filesOrder." << std::endl;
        return -EFAULT;
    }

    // Rename file.
    lab_fuse::LabFile labFile = std::move(position->second);
    lab.files.erase(position);
    lab.files[newName] = std::move(labFile);
    *namePosition = newName;

    return lab_flush();
}

static int xmp_create(const char* path, mode_t, struct fuse_file_info *)
{
    std::string fileName(path + 1);
    if (lab.files.count(fileName) > 0) {
        std::cerr << "File with name '" << fileName << "' already exists." << std::endl;
        return -EINVAL;
    }

    // Create new file.
    lab.filesOrder.push_back(fileName);
    lab_fuse::LabFile labFile;
    labFile.typeAndExtension = std::string(4, '\0');
    lab.files[fileName] = labFile;

    return 0;
}

static int xmp_unlink(const char *path)
{
    std::string fileName(path + 1);

    auto position = lab.files.find(fileName);
    if (position == lab.files.end())
        return -ENOENT;

    auto namePosition = std::find(lab.filesOrder.begin(), lab.filesOrder.end(), fileName);
    if (namePosition == lab.filesOrder.end()) {
        std::cerr << "Internal structure inconsistent. File '" << fileName << "' not found in filesOrder." << std::endl;
        return -EFAULT;
    }

    // Remove the file.
    lab.files.erase(position);
    lab.filesOrder.erase(namePosition);

    return 0;
}

static int xmp_flush(const char *, struct fuse_file_info *) {
    return lab_flush();
}

static int xmp_fsync(const char *, int, struct fuse_file_info *) {
    return lab_flush();
}

static int xmp_truncate(const char * path, FUSE_OFF_T size) {
    std::string fileName(path + 1);

    auto position = lab.files.find(fileName);
    if (position == lab.files.end())
        return -ENOENT;

    auto& labFile = position->second;
    try {
        labFile.data.resize(size);
    } catch (...) {
        std::cerr << boost::current_exception_diagnostic_information(true) << std::endl;
        return -ENOMEM;
    }

    return 0;
}

static struct fuse_operations xmp_oper = { 0 };

int main(int argc, char *argv[])
{
    if (argc < 2) {
        std::cout << "Usage: lab-fuse <path-to-file.lab> <drive-letter> [fuse options]" << std::endl;
        return 1;
    }

    labFilePath = argv[1];

    try {
        lab = lab_fuse::loadLabFile(labFilePath);
    } catch (...) {
        std::cerr << boost::current_exception_diagnostic_information(true) << std::endl;
        return 1;
    }

    xmp_oper.getattr = &xmp_getattr;
    xmp_oper.readdir = &xmp_readdir;
    xmp_oper.open = &xmp_open;
    xmp_oper.read = &xmp_read;
    xmp_oper.write = &xmp_write;
    xmp_oper.rename = &xmp_rename;
    xmp_oper.create = &xmp_create;
    xmp_oper.unlink = &xmp_unlink;
    xmp_oper.flush = &xmp_flush;
    xmp_oper.fsync = &xmp_fsync;
    xmp_oper.truncate = &xmp_truncate;

    return fuse_main(argc - 1, argv + 1, &xmp_oper, NULL);
}

ext: cpp

max_stars_repo_name: Zbyl/OutlawsX

max_issues_repo_name: Zbyl/OutlawsX

max_forks_repo_name: Zbyl/OutlawsX


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

#ifndef BOOST_HASH_MERKLE_DAMGARD_BLOCK_HASH_HPP
#define BOOST_HASH_MERKLE_DAMGARD_BLOCK_HASH_HPP

#include <boost/hash/digest.hpp>
#include <boost/hash/pack.hpp>

namespace boost {
namespace hashes {

//
// The Merkle-Damgård construction builds a block hash from a
// one-way compressor.  As this version operated on the block
// level, it doesn't contain any padding or other strengthening.
// For a Wide Pipe construction, use a digest_type that will
// truncate the internal state.
//

struct nop_finalizer {
    template <typename T>
    void
    operator()(T &) {}
};

template <typename digest_endian,
          int digest_bits,
          typename iv_G,
          typename compressor_F,
          typename finalizer_F = nop_finalizer>
class merkle_damgard_block_hash {
  public:
    typedef hashes::digest<digest_bits> digest_type;

    typedef iv_G iv_generator;
    typedef compressor_F compressor_functor;
    typedef finalizer_F finalizer_functor;

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

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

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

  public:
    merkle_damgard_block_hash &update(block_type const &block) {
        compressor_functor compressor;
        compressor(state_, block);
        return *this;
    }
    digest_type end_message() {
        finalizer_functor finalizer;
        finalizer(state_);
        digest_type d;
        pack_n<digest_endian,
               word_bits,
               octet_bits>(state_.data(), digest_bits/word_bits,
                           d.data(), digest_bits/octet_bits);
        reset();
        return d;
    }
    digest_type digest() const {
        return merkle_damgard_block_hash(*this).end_message();
    }

  public:
    merkle_damgard_block_hash() { reset(); }
    void reset(state_type const &s) { state_ = s; }
    void reset() {
        iv_generator iv;
        reset(iv());
    }
    state_type const &state() const { return state_; }
  private:
    state_type state_;
};

} // namespace hashes
} // namespace boost

#endif // BOOST_HASH_MERKLE_DAMGARD_BLOCK_HASH_HPP

ext: hpp

max_stars_repo_name: dillonl/boost-cmake

max_issues_repo_name: dillonl/boost-cmake

max_forks_repo_name: dillonl/boost-cmake


text:
//////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 KDE Laboratory, University of Tsukuba, Tsukuba, Japan.            //
//                                                                                //
// The JsSpinnerSPE/StreamingCube and the accompanying materials are made available     //
// under the terms of Eclipse Public License v1.0 which accompanies this distribution   //
// and is available at <https://eclipse.org/org/documents/epl-v10.php>                  //
//////////////////////////////////////////////////////////////////////////////////////////

#include "../Common/stdafx.h"
#include "../BinaryJson/json.h"
#include "../Common/Types.h"
#include "../Internal/Element/Element.h"
#include "../Query/QueryIntermediateRepresentation.h"
#include "../Server/JsonStreamServer.h"
#include "../Schema/JsonSchema.h"
#include "../IO/SocketStreamOutput.h"
#include "../IO/csvOutput.h"
#include "../IO/IOManager.h"
#include "../IO/IStreamOutput.h"
#include "../Parser/ParserManager.h"
#include "../Configure/ConfigureManager.h"
#include "../Query/GetJaqlQuery.h"
#include "../Utility/TimeCounterUtility.h"
#include "../OLAP/MaterializedLattice.h"
#include "../OLAP/OLAPManager.h"
#include "../Operator/CubifyOperator.h"

#include <boost/asio.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/regex.hpp>
#include <iostream>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <sys/types.h>
#include <fstream>

#ifdef PROFILER
#include  <google/profiler.h>
#endif

int main()
{
// Saving own PID
ofstream PIDFile;
PIDFile.open ("myPID.txt");
PIDFile << getpid();
PIDFile.close();

#ifdef PROFILER
	 ProfilerStart("MyProfile.prof");
#endif
	JsonStreamServer* server = JsonStreamServer::getInstance();

    std::string streamWindowSize = ConfigureManager::getInstance()->getConfigureValue("streamWindowSize");
	std::string stream1WindowSize = ConfigureManager::getInstance()->getConfigureValue("stream1_window_size");
	std::string stream2WindowSize = ConfigureManager::getInstance()->getConfigureValue("stream2_window_size");
	std::string stream3WindowSize = ConfigureManager::getInstance()->getConfigureValue("stream3_window_size");
	std::string stream4WindowSize = ConfigureManager::getInstance()->getConfigureValue("stream4_window_size");
	std::string activateDuration = ConfigureManager::getInstance()->getConfigureValue("activate_duration");

	std::string nodeType = ConfigureManager::getInstance()->getConfigureValue("node_type");
	std::string queryIndex = ConfigureManager::getInstance()->getConfigureValue("query_index");
	std::string querySource = ConfigureManager::getInstance()->getConfigureValue("query_source");
	std::string jaqlQuery = GetJaqlQuery::getInstance()->getJaqlQuery("Q1");

    std::string query0 =
	"stream1 = readFromWrapper (\"performanceTestStream2\", true) ;\
	tmp1 = stream1 -> window[range "+ stream2WindowSize +" seconds] ;\
	tmp1 -> istream;";

    std::string query1 =
	"stream1 = readFromWrapper (\"performanceTestStream1\", true) ;\
	stream2 = readFromWrapper (\"performanceTestStream2\", false) ;\
	tmp1 = stream1 -> window[range "+ stream1WindowSize +" seconds] ;\
	tmp2 = stream2 -> window[rows "+ stream2WindowSize +"] ; \
	j = join s in tmp1,\
           	d in tmp2\
		where s.A == d.A\
		into {s.B, d.C};\
	j -> istream;";

    // Simple join query
    //std::string queryIntermediateRepresentation1 = "{\"type\":\"root\",\"input\":{\"type\":\"istream\",\"input\":{\"type\":\"join\",\"left_join_attribute\":[\"A\"],\"right_join_attribute\":[\"A\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"B\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"C\"],\"attribute_source\":\"right\"}}]},\"left_input\":{\"type\":\"rangewindow\",\"windowsize\":\"" + stream1WindowSize + " milliseconds\",\"input\":{\"type\":\"leaf\",\"stream_source\":\"performanceTestStream1\",\"is_master\":true}},\"right_input\":{\"type\":\"rowwindow\",\"windowsize\":"+ stream2WindowSize +",\"input\":{\"type\":\"leaf\",\"stream_source\":\"performanceTestStream2\",\"is_master\":false}}}}}";

    // Synthetic data (StreamOLAP Query)
    //Query with 3 dimension and a fact join with 5 dimension ID and names
    //std::string queryIntermediateRepresentation1 = "{\"type\":\"root\",\"input\":{\"type\":\"cubify\",\"input\":{\"type\":\"join\",\"left_join_attribute\":[\"promoID\"],\"right_join_attribute\":[\"promoID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"suppID\"],\"right_join_attribute\":[\"suppID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"prodID\"],\"right_join_attribute\":[\"prodID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"rowwindow\",\"windowsize\":100000,\"input\":{\"type\":\"leaf\",\"stream_source\":\"salesFact5DimWNamesWrapper\",\"is_master\":true}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"productDimension\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"supplierDimension\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"promotionDimension\"}}}}";

    //Query with 3 dimension and a fact join with 6 dimension ID and names
    //std::string queryIntermediateRepresentation1 = "{\"type\":\"root\",\"input\":{\"type\":\"cubify\",\"input\":{\"type\":\"join\",\"left_join_attribute\":[\"promoID\"],\"right_join_attribute\":[\"promoID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"suppID\"],\"right_join_attribute\":[\"suppID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"prodID\"],\"right_join_attribute\":[\"prodID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"rowwindow\",\"windowsize\":" + stream1WindowSize + ",\"input\":{\"type\":\"leaf\",\"stream_source\":\"salesFact6DimWNamesWrapper\",\"is_master\":true}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"productDimension\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"supplierDimension\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"promotionDimension\"}}}}";

    //Query with pre-joined 6 dimensions with a fact table
    std::string queryIntermediateRepresentation1 = "{\"type\":\"root\",\"input\":{\"type\":\"cubify\",\"input\":{\"type\":\"rowwindow\",\"windowsize\":\" + streamWindowSize + \",\"input\":{\"type\":\"leaf\",\"stream_source\":\"salesFactPreJoined6DWrapper\",\"is_master\":true}}}}";

    //Send out through socket - Query with 3 dimension and a fact join with 6 dimension ID and names without cubify operator
    //std::string queryIntermediateRepresentation1 = "{\"type\":\"root\",\"input\":{\"type\":\"istream\",\"input\":{\"type\":\"join\",\"left_join_attribute\":[\"promoID\"],\"right_join_attribute\":[\"promoID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"suppID\"],\"right_join_attribute\":[\"suppID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"prodID\"],\"right_join_attribute\":[\"prodID\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"prodName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"promoID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonID\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesPersonName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesAmountFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"rowwindow\",\"windowsize\":" + IoI + ",\"input\":{\"type\":\"leaf\",\"stream_source\":\"salesFact6DimWNamesWrapper\",\"is_master\":true}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"productDimension\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"supplierDimension\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"promotionDimension\"}}}}";

    //Send out through socket - TPCH query with 4 dimensions
    //std::string queryIntermediateRepresentation1 = "{\"type\":\"root\",\"input\":{\"type\":\"istream\",\"input\":{\"type\":\"join\",\"left_join_attribute\":[\"custKey\"],\"right_join_attribute\":[\"custKey\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesQtyFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"suppKey\"],\"right_join_attribute\":[\"suppKey\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesQtyFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"partKey\"],\"right_join_attribute\":[\"partKey\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesQtyFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"rowwindow\",\"windowsize\":" + IoI + ",\"input\":{\"type\":\"leaf\",\"stream_source\":\"salesFact4DimTPCH\",\"is_master\":true}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"PartDimensionTPCH\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"SupplierDimensionTPCH\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"CustomerDimensionTPCH\"}}}}";

    //Unified StreamingCube - TPCH query with 4 dimensions
    //std::string queryIntermediateRepresentation1 = "{\"type\":\"root\",\"input\":{\"type\":\"cubify\",\"input\":{\"type\":\"join\",\"left_join_attribute\":[\"custKey\"],\"right_join_attribute\":[\"custKey\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesQtyFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"suppKey\"],\"right_join_attribute\":[\"suppKey\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partName\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesQtyFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"join\",\"left_join_attribute\":[\"partKey\"],\"right_join_attribute\":[\"partKey\"],\"left_outer\":false,\"right_outer\":false,\"projection\":{\"type\":\"projection_obj\",\"projection_type\":\"object\",\"fields\":[{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"partName\"],\"attribute_source\":\"right\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"suppKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"custKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeKey\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"storeArea\"],\"attribute_source\":\"left\"}},{\"type\":\"projection_obj\",\"need_rename\":false,\"projection_type\":\"direct\",\"expression\":{\"type\":\"expression_obj\",\"expression_type\":\"id\",\"id_name\":[\"salesQtyFACT\"],\"attribute_source\":\"left\"}}]},\"left_input\":{\"type\":\"rowwindow\",\"windowsize\":" + IoI + ",\"input\":{\"type\":\"leaf\",\"stream_source\":\"salesFact4DimTPCH\",\"is_master\":true}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"PartDimensionTPCH\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"SupplierDimensionTPCH\"}},\"right_input\":{\"type\":\"csv_leaf\",\"csv_source\":\"CustomerDimensionTPCH\"}}}}";

	Document queryIntermediateDocument = fromjson(queryIntermediateRepresentation1);
    boost::shared_ptr<QueryIntermediateRepresentation> queryIntermediateRepresentation(new QueryIntermediateRepresentation(queryIntermediateDocument));

    // Output mode
    // show result on screen mode
    boost::shared_ptr<IStreamOutput> streamOutput(new ShowResultStreamOutput());

    // socket output mode
    std::string ip = "192.168.0.107";
    //std::string ip = "192.168.0.150";
	std::string port = "8042";
	//boost::shared_ptr<IStreamOutput> streamOutput(new SocketStreamOutput(ip,port));

    // Registering intermediate query
    server->registerQuery(queryIntermediateRepresentation,streamOutput,activateDuration);

    // Register JSON query
    //server->registerQuery(query0, streamOutput, activateDuration);

    server->execute();    //exeute the query

#ifdef PROFILER
	ProfilerStop();
#endif
}


text:
// Copyright (c) 2017-2018 The Infinex Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "userbalance.h"
#include <boost/lexical_cast.hpp>

class CUserBalance;
class CUserBalanceManager;
class CGlobalUserSetting;

std::map<std::string, mapUserBalanceWithCoinID> mapUserBalanceByPubKey;
std::map<int, mapUserBalanceWithPubKey> mapUserBalanceByCoinID;
std::map<int, CUserBalanceSetting> mapUserBalanceSetting;
CGlobalUserBalanceHandler globalUserBalanceHandler;
CUserBalanceManager userBalanceManager;
std::map<char, CGlobalUserSetting> mapGlobalUserSetting;

bool CUserBalance::VerifySignature()
{
	return true;
}

void CUserBalanceManager::InitCoin(int CoinID)
{
	if (mapUserBalanceByCoinID.count(CoinID))
		return;

	mapUserBalanceSetting.insert(std::make_pair(CoinID, CUserBalanceSetting(CoinID)));
	mapUserBalanceByCoinID.insert(std::make_pair(CoinID, mapUserBalanceWithPubKey()));
}

void CUserBalanceManager::InitGlobalUserSetting(char Char)
{
	if (mapGlobalUserSetting.count(Char))
		return;

	mapGlobalUserSetting.insert(std::make_pair(Char, CGlobalUserSetting(Char)));
}

bool CUserBalanceManager::AssignUserBalanceRole(char Char, bool toAssign)
{
	InitGlobalUserSetting(Char);
	auto& a = mapGlobalUserSetting[Char];
	a.nInChargeUserBalance = toAssign;
	return true;
}

bool CUserBalanceManager::AssignBackupRole(char Char, bool toAssign)
{
	InitGlobalUserSetting(Char);
	auto& a = mapGlobalUserSetting[Char];
	a.nInChargeBackup = toAssign;
	return true;
}

bool CUserBalanceManager::UpdateUserBalance(CUserBalance UserBalance)
{
	if (!UserBalance.VerifySignature())
		return false;

	if (!InChargeOfUserBalance(UserBalance.nUserPubKey))
		return false;

	std::shared_ptr<CUserBalance> ub1;
	InitUserBalance(UserBalance.nCoinID, UserBalance.nUserPubKey, ub1);

	std::shared_ptr<CUserBalance> ub = std::make_shared<CUserBalance>(UserBalance);
	if (ub1->nLastUpdateTime < ub->nLastUpdateTime)
		ub1 = ub;

	return true;
}

void CUserBalanceManager::InitUserBalance(int CoinID, std::string UserPubKey, std::shared_ptr<CUserBalance>& UserBalance)
{
	if (!mapUserBalanceByPubKey.count(UserPubKey))
		mapUserBalanceByPubKey.insert(std::make_pair(UserPubKey, mapUserBalanceWithCoinID()));

	mapUserBalanceWithCoinID& temp = mapUserBalanceByPubKey[UserPubKey];
	if (!temp.count(CoinID))
	{
		UserBalance = std::make_shared<CUserBalance>(UserPubKey, CoinID);
		temp.insert(std::make_pair(CoinID, UserBalance));
	}

	if (!mapUserBalanceByCoinID.count(CoinID))
		mapUserBalanceByCoinID.insert(std::make_pair(CoinID, mapUserBalanceWithPubKey()));

	mapUserBalanceWithPubKey& temp2 = mapUserBalanceByCoinID[CoinID];
	if (!temp2.count(UserPubKey))
		temp2.insert(std::make_pair(UserPubKey, UserBalance));

	UserBalance = temp[CoinID];
}

int CUserBalanceManager::GetLastDepositID(int CoinID, std::string UserPubKey)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	return ub->nLastDepositID;
}

bool CUserBalanceManager::InChargeOfUserBalance(std::string pubKey)
{
	char c = pubKey[2];
	auto a = mapGlobalUserSetting[c];
	if (a.nInChargeUserBalance)
		return true;
	return false;
}

bool CUserBalanceManager::InChargeOfBackup(std::string pubKey)
{
	char c = pubKey[2];
	auto a = mapGlobalUserSetting[c];
	if (a.nInChargeBackup)
		return true;
	return false;
}

bool CUserBalanceManager::IsInChargeOfCoinBalance(int CoinID)
{
	return mapUserBalanceSetting[CoinID].nIsInChargeOfUserBalance;
}

bool CUserBalanceManager::VerifyUserBalance(int CoinID)
{
	return mapUserBalanceSetting[CoinID].nVerifyUserBalance;
}

bool CUserBalanceManager::IsCoinInList(int CoinID)
{
	return mapUserBalanceByCoinID.count(CoinID);
}

bool CUserBalanceManager::IsUserBalanceExist(int CoinID, std::string UserPubKey)
{
	return (mapUserBalanceByCoinID[CoinID].count(UserPubKey));
}

userbalance_to_exchange_enum_t CUserBalanceManager::BalanceToExchange(int CoinID, std::string UserPubKey, uint64_t amount)
{
	CUserBalanceSetting& setting = mapUserBalanceSetting[CoinID];
	if (setting.nCoinID != CoinID)
		return USER_BALANCE_INVALID_NODE;

	mapUserBalanceWithPubKey& temp = mapUserBalanceByCoinID[CoinID];
	if (!temp.count(UserPubKey))
		return USER_ACCOUNT_NOT_FOUND;

	auto& temp2 = temp[UserPubKey];

	if (setting.nVerifyUserBalance)
	{
		if (temp2->nAvailableBalance < amount)
			return USER_BALANCE_NOT_ENOUGH;
	}

	temp2->nAvailableBalance -= amount;
	temp2->nInExchangeBalance += amount;
	return USER_BALANCE_DEDUCTED;
}

exchange_to_userbalance_enum_t CUserBalanceManager::ExchangeToBalance(int CoinID, std::string UserPubKey, uint64_t amount)
{
	CUserBalanceSetting& setting = mapUserBalanceSetting[CoinID];
	if (setting.nCoinID != CoinID)
		return EXCHANGE_INVALID_NODE;

	mapUserBalanceWithPubKey& temp = mapUserBalanceByCoinID[CoinID];
	if (!temp.count(UserPubKey))
		return EXCHANGE_ACCOUNT_NOT_FOUND;

	auto& temp2 = temp[UserPubKey];

	if (setting.nVerifyUserBalance)
	{
		if (temp2->nInExchangeBalance < amount)
			return EXCHANGE_BALANCE_NOT_ENOUGH;
	}

	temp2->nAvailableBalance += amount;
	temp2->nInExchangeBalance -= amount;
	return EXCHANGE_BALANCE_RETURNED;
}

int64_t CUserBalanceManager::GetUserAvailableBalance(int CoinID, std::string UserPubKey)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	return ub->nAvailableBalance;
}

int64_t CUserBalanceManager::GetUserInExchangeBalance(int CoinID, std::string UserPubKey)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	return ub->nInExchangeBalance;
}

int64_t CUserBalanceManager::GetUserPendingDepositBalance(int CoinID, std::string UserPubKey)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	return ub->nPendingDepositBalance;
}

int64_t CUserBalanceManager::GetUserPendingWithdrawalBalance(int CoinID, std::string UserPubKey)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	return ub->nPendingWithdrawalBalance;
}

void CUserBalanceManager::AdjustUserAvailableBalance(int CoinID, std::string UserPubKey, int64_t amount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	ub->nAvailableBalance += amount;
}

void CUserBalanceManager::AdjustUserInExchangeBalance(int CoinID, std::string UserPubKey, int64_t amount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	ub->nInExchangeBalance += amount;
}

void CUserBalanceManager::AdjustUserPendingDepositBalance(int CoinID, std::string UserPubKey, int64_t amount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	ub->nPendingDepositBalance += amount;
}

void CUserBalanceManager::AdjustUserPendingWithdrawalBalance(int CoinID, std::string UserPubKey, int64_t amount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	ub->nPendingWithdrawalBalance += amount;
}

bool CUserBalanceManager::UpdateAfterTradeBalance(std::string User1PubKey, std::string User2PubKey, int CoinID1, int CoinID2, int64_t User1EAdjDown, int64_t User1BAdjUp, int64_t User2EAdjDown, int64_t User2BAdjUp)
{
	if (!IsInChargeOfCoinBalance(CoinID1) || !IsInChargeOfCoinBalance(CoinID2))
		return false;

	auto& temp1 = mapUserBalanceByCoinID[CoinID1];
	auto& temp2 = mapUserBalanceByCoinID[CoinID2];

	if (!temp1.count(User1PubKey) || !temp1.count(User2PubKey) || !temp2.count(User1PubKey) || !temp2.count(User2PubKey))
		return false;

	temp1[User1PubKey]->nAvailableBalance += User1BAdjUp;
	temp1[User2PubKey]->nInExchangeBalance -= User2EAdjDown;
	temp2[User1PubKey]->nInExchangeBalance -= User1EAdjDown;
	temp2[User2PubKey]->nAvailableBalance += User2BAdjUp;
	return true;
}

bool CUserBalanceManager::UpdateAfterTradeBalance(std::string UserPubKey, int ExchangeCoinID, int BalanceCoinID, int64_t ExchangeAdjDown, int64_t BalanceAdjUp)
{
	auto& a = mapUserBalanceByPubKey[UserPubKey];
	if (!a.count(ExchangeCoinID))
	{
		std::shared_ptr<CUserBalance> temp = std::make_shared<CUserBalance>(UserPubKey, BalanceCoinID);
		temp->nAvailableBalance += BalanceAdjUp;
		a.insert(std::make_pair(BalanceCoinID, temp));
	}
	else
		a[BalanceCoinID]->nAvailableBalance += BalanceAdjUp;
	a[ExchangeCoinID]->nInExchangeBalance -= ExchangeAdjDown;
}

bool CUserBalanceManager::BalanceToExchangeV2(int CoinID, std::string UserPubKey, uint64_t amount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	if (ub->nAvailableBalance < amount)
		return false;

	ub->nAvailableBalance -= amount;
	ub->nInExchangeBalance += amount;
	return true;
}

bool CUserBalanceManager::ExchangeToBalanceV2(int CoinID, std::string UserPubKey, uint64_t amount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	if (ub->nInExchangeBalance < amount)
		return false;

	ub->nInExchangeBalance -= amount;
	ub->nAvailableBalance += amount;
	return true;
}

bool CUserBalanceManager::PendingToAvailable(int CoinID, std::string UserPubKey, uint64_t PendingAmount, uint64_t AvailableAmount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	if (ub->nPendingDepositBalance < PendingAmount)
		return false;

	ub->nPendingDepositBalance -= PendingAmount;
	ub->nAvailableBalance += AvailableAmount;
	return true;
}

bool CUserBalanceManager::AvailableToPending(int CoinID, std::string UserPubKey, uint64_t AvailableAmount, uint64_t PendingAmount)
{
	std::shared_ptr<CUserBalance> ub;
	InitUserBalance(CoinID, UserPubKey, ub);
	if (ub->nAvailableBalance < AvailableAmount)
		return false;

	ub->nAvailableBalance -= AvailableAmount;
	ub->nPendingDepositBalance += PendingAmount;
	return true;
}


text: #include <boost/mpl/logical.hpp>

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
/*
    Copyright 2013 <copyright holder> <email>

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#ifndef SUBSCRIBABLE_HPP
#define SUBSCRIBABLE_HPP

#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/signals2/signal.hpp>

template <typename T>
class ChangeGuard{
	T* _data;
	const T _dataCopy;
	const boost::signals2::signal<void (const T&, const T&)>& _signal;
public:
	ChangeGuard(T* data, const boost::signals2::signal<void (const T&, const T&)>& signal)
		: _data(data), _dataCopy(*data), _signal(signal)
	{}
	ChangeGuard(const ChangeGuard& other)
		: _data(other._data), _dataCopy(other._dataCopy), _signal(other._signal)
	{}
	virtual ~ChangeGuard() {
		if (_dataCopy != *_data)
			_signal(_dataCopy, *_data);
	}
	ChangeGuard<T>& operator=(const ChangeGuard<T>& other) {
		_data = other._data;
		_dataCopy = other._dataCopy;
		_signal = other._signal;
		return *this;
	}
	virtual T* get() {
		return _data;
	}
	virtual T* operator->() {
		return _data;
	}
	virtual T& operator*() {
		return *_data;
	}
};

template <typename T>
class Subscribable : boost::noncopyable
{
	T _value;
public:
	boost::signals2::signal<void (const T&, const T&)> onChange;

	virtual ChangeGuard< T > change() {
		return ChangeGuard<T>(&_value, onChange);
	}

	Subscribable& operator=(const T& other) {
		auto guard = change();
		(*guard) = other;
		return *this;
	}

	virtual bool operator==(const T& other) const {
		return (_value) == other;
	}
	virtual bool operator==(const Subscribable< T >& other) const {
		return (_value) == (other._value);
	}

	virtual bool operator!=(const T& other) const {
		return (_value) != other;
	}
	virtual bool operator!=(const Subscribable< T >& other) const {
		return (_value) != (other._value);
	}

	virtual const T* get() const {
		return &_value;
	}

	virtual const T* operator->() const {
		return &_value;
	}

	virtual const T& operator*() const {
		return _value;
	}
};

#endif // SUBSCRIBABLE_HPP

max_stars_repo_name: zidz/bithorde

max_issues_repo_name: zidz/bithorde

max_forks_repo_name: zidz/bithorde


text:
#include <stan/lang/ast_def.cpp>
#include <gtest/gtest.h>
#include <boost/variant/polymorphic_get.hpp>
#include <cmath>

#include <string>

TEST(StanLangAst, MapRect) {
  using stan::lang::int_literal;

  // make sure nullary ctor works
  stan::lang::map_rect mr1;
  EXPECT_TRUE(mr1.call_id_ == -1);

  // test fidelity of storage
  std::string name = "foo";
  stan::lang::expression e1 = int_literal(1);
  stan::lang::expression e2 = int_literal(2);
  stan::lang::expression e3 = int_literal(3);
  stan::lang::expression e4 = int_literal(4);
  stan::lang::map_rect mr(name, e1, e2, e3, e4);
  EXPECT_TRUE(mr.fun_name_ == "foo");
  int_literal lit1 = boost::polymorphic_get<int_literal>(mr.shared_params_.expr_);
  EXPECT_EQ(1, lit1.val_);
  int_literal lit2 = boost::polymorphic_get<int_literal>(mr.job_params_.expr_);
  EXPECT_EQ(2, lit2.val_);
  int_literal lit3 = boost::polymorphic_get<int_literal>(mr.job_data_r_.expr_);
  EXPECT_EQ(3, lit3.val_);
  int_literal lit4 = boost::polymorphic_get<int_literal>(mr.job_data_i_.expr_);
  EXPECT_EQ(4, lit4.val_);
}

max_stars_repo_name: drezap/stan

max_issues_repo_name: drezap/stan

max_forks_repo_name: drezap/stan


text:
#ifndef _MADGWICK_FILTER_H_
#define _MADGWICK_FILTER_H_

#include <iostream>
#include <chrono>
#include <vector>
#include <cmath>

#include <Eigen/Core>
#include <Eigen/Geometry>

#include <boost/math/constants/constants.hpp>

const double pi		= boost::math::constants::pi<double>();
const double eps	= 1e-8;

class MadgwickFilter
{
	public:
		MadgwickFilter(double gyro_error);
		~MadgwickFilter();
		void estimate_pose(Eigen::Vector3d acc, Eigen::Vector3d gyro);
		void reset();
		Eigen::Vector3d get_euler(){return euler;}
		Eigen::VectorXd get_quaternion(){return quaternion;};
	private:
		double beta;
		std::chrono::system_clock::time_point old_time_stamp;
		Eigen::Vector3d euler;
		Eigen::Vector4d quaternion;
};

#endif


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

// Tests that the swap headers work when both are included

#include <boost/swap.hpp>
#include <boost/utility/swap.hpp>

max_stars_repo_name: randolphwong/mcsema

max_issues_repo_name: randolphwong/mcsema

max_forks_repo_name: randolphwong/mcsema


text:
#include "stdafxCore.h"

#include "StringHeplers.h"

#include <locale>
#include <codecvt>

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/join.hpp>

//@see: http://stackoverflow.com/questions/2573834/c-convert-string-or-char-to-wstring-or-wchar-t
// std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
// std::string narrow = converter.to_bytes(L"foo");
// std::wstring wide = converter.from_bytes("bar");

namespace bv {

// *******************************
//
Expected< std::wstring >        StringToWString     ( const std::string & data )
{
    try
    {
        std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
        return converter.from_bytes( data );
    }
    catch( ... )
    {
        return Expected< std::wstring >();
    };

}

// *******************************
//
Expected< std::string >         WStringToString     ( const std::wstring & data )
{
    try
    {
        std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
        return converter.to_bytes( data );
    }
    catch( ... )
    {
        return Expected< std::string >();
    }
}

// *******************************
//
StrVec          Split           ( const std::string & str, const std::string & sep )
{
    StrVec ret;

    boost::split( ret, str, boost::is_any_of( sep ) );

    return ret;
}

// *******************************
//
std::string     Join            ( const StrVec & strVec, const std::string & sep )
{
    return boost::algorithm::join( strVec, sep );
}

// *******************************
//
std::string     Trim            ( const std::string & str, const std::string & mark )
{
    auto ret = str;
    ret.erase( ret.find_last_not_of( mark ) + 1 );
    ret.erase( 0, ret.find_first_not_of( mark ) );
    return ret;
}

} //bv

max_stars_repo_name: black-vision-engine/bv-engine

max_issues_repo_name: black-vision-engine/bv-engine

max_forks_repo_name: black-vision-engine/bv-engine


text:
/* ----------------------------------------------------------------------------
** Copyright (c) 2016 Austin Brunkhorst, All Rights Reserved.
**
** Method.cpp
** --------------------------------------------------------------------------*/

#include "Precompiled.h"

#include "LanguageTypes/Class.h"
#include "LanguageTypes/Method.h"

#include <boost/format.hpp>
#include <boost/algorithm/string/join.hpp>

Method::Method(
    const Cursor &cursor,
    const Namespace &currentNamespace,
    Class *parent
)
    : LanguageType( cursor, currentNamespace )
    , Invokable( cursor )
    , m_isConst( cursor.IsConst( ) )
    , m_parent( parent )
    , m_name( cursor.GetSpelling( ) )
{

}

bool Method::ShouldCompile(void) const
{
    return isAccessible( );
}

TemplateData Method::CompileTemplate(const ReflectionParser *context) const
{
    TemplateData data { TemplateData::Type::Object };

    data[ "name" ] = m_name;

    data[ "parentQualifiedName" ] = m_parent->m_qualifiedName;

    data[ "qualifiedSignature" ] = getQualifiedSignature( );

    m_metaData.CompileTemplateData( data, context );

    return data;
}

bool Method::isAccessible(void) const
{
    if (m_accessModifier != CX_CXXPublic)
        return false;

    // if the parent wants white listed method, then we must have
    // the enable flag
    if (m_parent->GetMetaData( ).GetFlag( native_property::WhiteListMethods ))
        return m_metaData.GetFlag( native_property::Enable );

    // must not be explicitly disabled
    return !m_metaData.GetFlag( native_property::Disable );
}

std::string Method::getQualifiedSignature(void) const
{
    auto argsList = boost::join( m_signature, ", " );

    std::string constNess = m_isConst ? " const" : "";

    return (boost::format( "%1%(%2%::*)(%3%)%4%" ) %
        m_returnType %
        m_parent->m_qualifiedName %
        argsList % constNess
    ).str( );
}

max_stars_repo_name: AustinBrunkhorst/CPP-Reflection

max_issues_repo_name: yangzhengxing/CPP-Reflection

max_forks_repo_name: yangzhengxing/CPP-Reflection