コード例 #1
0
ファイル: CreateTypeInfo.hpp プロジェクト: kanbang/myexercise
        void execute ()
        {
            namespace bmpl = boost::mpl;
            typedef StaticTypeInfo<Base> StaticBaseInfo;

            TypeManager& f = TypeManager::GetInst();

            TypeInfo const& baseInfo =  f.GetInfoFromId( StaticBaseInfo::GetTypeId() );

            info->AddInterface( baseInfo );
            f.AddTypeImplementation( baseInfo.GetId(), info->GetId() );

            // "from" info	 to type id	,	anyStaticCast<ToType, FromType>
            info->AddCast( baseInfo.GetId(), &AnyStaticCast<Base, D> );

            baseInfo.AddCast( info->GetId(), &AnyStaticCast<D, Base> );

            for_each_type< typename StaticBaseInfo::BaseTypes >( AddBase<D>(*info) );
        }
コード例 #2
0
ファイル: TypeManager.cpp プロジェクト: kanbang/myexercise
    TypeId TypeManager::registerType( std::type_info const& typeId, TypeInfo info )
    {
        const TypeId id = info.GetId();

        assert( id <= impl_->nextTypeId_ ); // no funny business! can't make up your own ids!

        // grow list
        if( impl_->infos_.size() <= static_cast<size_t>( id ) )
            impl_->infos_.resize( id + 1, TypeInfo( INVALID_TYPE ) );

        impl_->infos_[id] = info;

        impl_->allTypes_[ typeId ] = id;

        assert( impl_->typeNames_.find( info.GetName() ) == impl_->typeNames_.end() \
                && "Re-registering type not supported" );

        impl_->typeNames_[info.GetName()] = id;

        return info.GetId();
    }
コード例 #3
0
ファイル: CreateTypeInfo.hpp プロジェクト: kanbang/myexercise
    TypeInfo CreateTypeInfo(char const* typeName)
    {
        TypeInfo newInfo = TypeManager::GetInst().CreateTypeInfo();

        newInfo.SetSize(sizeof(T));
        newInfo.SetName(typeName);

        newInfo.SetReferenceType( !boost::is_pointer<T>::value ?
                                  newInfo.GetId()	:
                                  StaticTypeInfo< typename boost::remove_pointer<
                                  typename boost::remove_pointer<T>::type>::type >::GetTypeId() );

        for_each_type< BaseTypes >( AddBase<T> (newInfo) );

        newInfo.SetCreationFunctions(&Alloc::create, &Alloc::clone, &Alloc::destruct, &Alloc::destroy );

        newInfo.SetVariables( MemberVariableList<T>::GetVariablePtrs() );

        return newInfo;
    }
コード例 #4
0
ファイル: GenAreaWayIndex.cpp プロジェクト: fingon/osmscout
  bool AreaWayIndexGenerator::FitsIndexCriteria(const ImportParameter& parameter,
                                                Progress& progress,
                                                const TypeInfo& typeInfo,
                                                const TypeData& typeData,
                                                const CoordCountMap& cellFillCount)
  {
    if (typeData.indexCells==0) {
      return true;
    }

    size_t entryCount=0;
    size_t max=0;

    for (CoordCountMap::const_iterator cell=cellFillCount.begin();
         cell!=cellFillCount.end();
         ++cell) {
      entryCount+=cell->second;
      max=std::max(max,cell->second);
    }

    // Average number of entries per tile cell
    double average=entryCount*1.0/cellFillCount.size();

    // If the fill rate of the index is too low, we use this index level anyway
    if (typeData.indexCells/(1.0*typeData.cellXCount*typeData.cellYCount)<=
        parameter.GetAreaWayIndexMinFillRate()) {
      progress.Warning(typeInfo.GetName()+" ("+NumberToString(typeInfo.GetId())+") is not well distributed");
      return true;
    }

    // If average fill size and max fill size for tile cells
    // is within limits, store it now.
    if (max<=parameter.GetAreaWayIndexCellSizeMax() &&
        average<=parameter.GetAreaWayIndexCellSizeAverage()) {
      return true;
    }

    return false;
  }