示例#1
0
std::size_t descriptor_hasher::hash(const descriptor& v) {
    std::size_t seed(0);

    combine(seed, hash_boost_filesystem_path(v.path()));
    combine(seed, v.extension());
    combine(seed, v.is_target());

    return seed;
}
bool polymorphic_feature::isParentClass(const descriptor& childClass) const
{
    const polymorphic_feature* pcf = dynamic_cast<const polymorphic_feature*>(childClass.feature(Feature::POLYMORPHIC));
    if (!pcf)
        return false;

    if (!pcf->has_parent())
        return false;

    return ( (pcf->parent().name()) == this->desc().name()) ? true : this->isParentClass(pcf->parent());
}
示例#3
0
intermediate_model
intermediate_model_factory::intermediate_model_for_descriptor(
    const annotations::annotation_groups_factory& agf,
    const annotations::type_repository& atrp,
    frontend_registrar& rg, const descriptor& d) const {
    BOOST_LOG_SEV(lg, debug) << "Creating intermediate model. "
                             << "Descriptor: " << d;

    auto& f(rg.frontend_for_extension(d.extension()));
    auto r(f.read(d));
    post_process(agf, atrp, r);

    BOOST_LOG_SEV(lg, debug) << "Created intermediate model.";
    return r;
}
示例#4
0
    int bind(descriptor const& desc, Endpoint const& endpoint)
    {
        error_code ec;

        system::call(::bind, desc.c_descriptor(), 
                     static_cast<sockaddr const*>(endpoint.address().first), 
                     endpoint.address().second,
                     ec,
                     -1
                    );
        if(ec)
        {
            report_error re;
            return re("socket::bind", ec);
        }

        return error_code::success;
    }
void win8centralplugin::write_descriptor(device& dev, const service& srv, const characteristic& chr, descriptor& desc, bool notify)
{
    switch( desc.type() )
    {
        case CLIENT_CHARACTERISTIC_CONFIGURATION:
        {
            // TODO
            break;
        }
        case SERVER_CHARACTERISTIC_CONFIGURATION:
        {
            // TODO
            break;
        }
        default:
            break; // TODO throw not_implemented
    }
}
示例#6
0
std::size_t send_to(descriptor const& desc, mutable_buffer_container buffer, Endpoint const& endpoint)
{
    error_code ec;
    std::size_t ret;

    ret = system::call(::sendto, desc.c_descriptor(),
                       buffer_cast<char const*>(buffer),
                       buffer_size(buffer),
                       0,
                       static_cast<sockaddr const*>(endpoint.address().first), 
                       endpoint.address().second,
                       ec,
                       -1
                      );
    if(ec)
    {
        report_error re;
        return re("socket::send_to", ec);
    }

    return ret;
}
示例#7
0
void frontend::write(const intermediate_model& im, const descriptor& d) {
    dehydrator dh;
    dh.dehydrate(im, d.path());
}
示例#8
0
void oarchive_json::serializeFields(const descriptor& cd, const any& value)
{
std::string s;
const polymorphic_feature* pcf = dynamic_cast<const polymorphic_feature*>(cd.feature(Feature::POLYMORPHIC));
const any_feature* acf = NULL;

    if (pcf && pcf->has_parent())
        this->serializeFields(pcf->parent(),value);

    if (cd.has(descriptor::Flags::FIELDS) == false) 
        return;

    void* ptrObject = value.ptr();
    any fieldValue;

    for (const std::unique_ptr<field>& patt : cd.get_fields())
    {                
		const field& att = *patt;
		if (att.need_support())
			continue;

        this->completeLastLine();      
        att.get(value,fieldValue);       

		const format* fieldFormat = dynamic_cast<const format*>(att.annotations().get(JSON::ANNOTATION_NAME, ANNOTATION_FORMAT_ALL));
        if ( fieldFormat )
        {                
			this->printFieldName(att);
			this->_data << "\"";
            fieldFormat->write(this->_data , fieldValue);               
			this->_data << "\"";
            continue;
        }

        const format* typeFormat = dynamic_cast<const format*>(att.desc().annotations().get(JSON::ANNOTATION_NAME, ANNOTATION_FORMAT_ALL));
        if (typeFormat)
        {               
			this->printFieldName(att);
			this->_data << "\"";
            typeFormat->write(this->_data,fieldValue);                
			this->_data << "\"";
            continue;            
        }

        const descriptor& acd = att.desc();
     
        void* vptr = att.ptr(ptrObject);

        if (acd.has(descriptor::Flags::FIELDS))
        {            
			this->printFieldName(att);
			if (!this->_compact)
				this->_data << std::endl;
            this->serializeObject(fieldValue);
        }
		else if (acd.hasFeature(Feature::CONTAINER)) 
		{
			this->printFieldName(att);
			if (!this->_compact)
				this->_data << std::endl;
			this->serializeObject(fieldValue);
		}
        else                
        {
            if ( att.ignore_if_default_value())
            {
                if (acd.equals(att.default_value(),fieldValue))
                    continue;
            }

			this->printFieldName(att);
            bool isString = false;
            

            att.tos(value,s);
            if (acd.type() == typeid(std::string))
                isString = true;
            else
            {
                if (acd.has(descriptor::Flags::NUMERIC_VALUE) == false)
                    isString |= !is_integer(s);				
				else
					isString = true;
            }


            if (isString)
                this->_data << "\"";

            this->_data << s;

            if (isString)
                this->_data << "\"";
      
        }
    }
    
}
示例#9
0
void oarchive_json::serializeElements(const descriptor& cd, const any& value)
{

const container_feature* ccf = dynamic_cast<const container_feature*>(cd.feature(Feature::CONTAINER));

    if (!ccf)
        return;

    bool hasKey = ccf->hasKey();

    const descriptor* ecd = ccf->elementDescriptor();
    const descriptor* kcd = hasKey ? ccf->keyDescriptor() : NULL;

    any element, key, mapped;
    std::string keystr, elementstr;

    ccf->begin(value);
    
    for (literator it = ccf->begin(value); it != ccf->end(value); ++it)
    {

		this->completeLastLine();

        // get key 
        if ( hasKey )
        {

            key = it.key();        
            keystr = std::move (kcd->atos(key));            
        }
        else
        {
            keystr = ecd->name();
        }

        element = *it;
       
        const format* typeFormat = dynamic_cast<const format*>(ecd->annotations().get(JSON::ANNOTATION_NAME));
        if (typeFormat)
        {
			if ( hasKey )
				this->_data << this->_tab << keystr << " = " ;

            typeFormat->write(this->_data,element);
            continue;
        }

        if (ecd->has(descriptor::Flags::FIELDS))
        {
			if (ccf->areElementsPointers())
			{
                if (element.empty())
                    continue;

				this->serializeObject(element);
			}
			else
			{
	
				this->serializeObject(element);
			}
        }
        else
        {            

			if ( hasKey )
				this->_data << this->_tab << keystr << " = " ;
                    
            elementstr = std::move (ecd->atos(element));
            bool isString = false;
            if (ecd->type() == typeid(std::string))
                isString = true;
            else
                isString |= !is_integer(elementstr);
            

            if (isString)
                this->_data << "\"";

            this->_data << elementstr;

            if (isString)
                this->_data << "\"";

			if (!this->_compact)
            this->_data << std::endl;  
        }   
         
    }

}
#include "catch.hpp"

#include "gpio_alt_fn.h"
#include <algorithm>

using namespace dibase::rpi::peripherals;
using namespace dibase::rpi::peripherals::internal::pin_alt_fn;
using dibase::rpi::peripherals::internal::gpio_pin_fn;

TEST_CASE( "Unit-tests/pin_alt_fn::descriptor/0000/construct valid arguments"
         , "Can create pin_alt_fn_descriptor from valid pin id, gpio_pin_fn, "
           " and gpio_special_fn"
         )
{
  descriptor pafd{pin_id{4}, gpio_pin_fn::alt5, gpio_special_fn::gpclk2};
  CHECK(pafd.pin()==4U);
  CHECK(pafd.alt_fn()==gpio_pin_fn::alt5);
  CHECK(pafd.special_fn()==gpio_special_fn::gpclk2);
}

TEST_CASE( "Unit-tests/pin_alt_fn::descriptor/0010/construct invalid arguments"
         , "Exception thrown if descriptor constructor passed a non-alt "
           "function gpio_pin_fn value"
         )
{
  CHECK_THROWS_AS( descriptor
                    (pin_id(4), gpio_pin_fn::input, gpio_special_fn::gpclk2)
                 , std::invalid_argument
                 );
  CHECK_THROWS_AS( descriptor
示例#11
0
fruitlib::pp::texture::counted_instance const
fruitlib::pp::texture::manager::query_internal(
	descriptor const &d)
{
	boost::iterator_range<texture_map::iterator> eq_range =
		textures_.equal_range(
			d);

	for(
		texture_map::iterator i = eq_range.begin();
		i != eq_range.end();
		++i)
	{
		// Texture is correct, but it's locked
		if (i->second->locked())
			continue;

		// Texture is correct and not locked!
		i->second->locked(
			true);
		return
			counted_instance(
				*(i->second),
				std::bind(
					static_cast<void (instance::*)(bool)>(
						&instance::locked),
					std::placeholders::_1,
					false));
	}

	sge::renderer::texture::planar_unique_ptr new_texture =
		renderer_.create_planar_texture(
			sge::renderer::texture::planar_parameters(
				d.size(),
				sge::renderer::texture::color_format(
					d.image_format(),
					sge::renderer::texture::emulate_srgb::no),
				sge::renderer::texture::mipmap::off(),
				sge::renderer::resource_flags_field::null(),
				sge::renderer::texture::capabilities_field{
					sge::renderer::texture::capabilities::render_target}));

	sge::renderer::target::offscreen_unique_ptr new_target(
		sge::renderer::target::from_texture(
			renderer_,
			*new_texture));

	fruitlib::pp::texture::optional_depth_stencil_surface new_target_depth_stencil;

	switch (d.depth_stencil())
	{
		case depth_stencil_format::off:
			break;
		case depth_stencil_format::d16:
			new_target_depth_stencil =
				fruitlib::pp::texture::optional_depth_stencil_surface(
					renderer_.create_depth_stencil_surface(
						sge::renderer::depth_stencil_buffer::surface_parameters(
							d.size(),
							sge::image::ds::format::d16)));
			break;
		case depth_stencil_format::d32:
			new_target_depth_stencil =
				fruitlib::pp::texture::optional_depth_stencil_surface(
					renderer_.create_depth_stencil_surface(
						sge::renderer::depth_stencil_buffer::surface_parameters(
							d.size(),
							sge::image::ds::format::d32)));
			break;
		case depth_stencil_format::d24s8:
			new_target_depth_stencil =
				fruitlib::pp::texture::optional_depth_stencil_surface(
					renderer_.create_depth_stencil_surface(
						sge::renderer::depth_stencil_buffer::surface_parameters(
							d.size(),
							sge::image::ds::format::d24s8)));
			break;
	}

	fcppt::optional::maybe_void(
		new_target_depth_stencil,
		[
			&new_target
		](
			sge::renderer::depth_stencil_buffer::surface_unique_ptr const &_surface
		)
		{
			new_target->depth_stencil_surface(
				sge::renderer::depth_stencil_buffer::optional_surface_ref(
					fcppt::make_ref(
						*_surface)));
		}
	);

	// There are no matching textures? Gotta create a new one!
	texture_map::iterator const result(
		textures_.insert(
			std::make_pair(
				d,
				fcppt::make_unique_ptr<fruitlib::pp::texture::instance>(
					d,
					std::move(
						new_texture),
					std::move(
						new_target),
					std::move(
						new_target_depth_stencil),
					fruitlib::pp::texture::is_locked(
						true)))));
	return
		fruitlib::pp::texture::counted_instance(
			*result->second,
			std::bind(
				static_cast<void (instance::*)(bool)>(
					&instance::locked),
				std::placeholders::_1,
				false));
}
bool descriptor::operator == (const descriptor& other) const
{
    return type_ == other.type() && handle_ == other.handle();
}