bool SharePtrGraphOp::traverse(Node *root)
{
    if(!_includeSet.empty() && !_excludeSet.empty())
    {
        FFATAL(("SharePtrGraphOp : Setting both the includes and excludes"
                "is not allowed!\n"));
        return false;
    }

    _typeMap   .clear();
    _shareCount.clear();

    _totalTime   = 0.0f;
    _compareTime = 0.0f;

    Time startTime = getSystemTime();

    shareFC(root);

    _totalTime = getSystemTime() - startTime;

    // DEBUG
    SINFO << "SharePtrGraphOp::traverse: _totalTime: " << _totalTime
          << " _compareTime: " << _compareTime << "\n";
    SINFO << "SharePtrGraphOp::traverse: Unique containers by type:\n";

    FCTypeMapIt tmIt  = _typeMap.begin();
    FCTypeMapIt tmEnd = _typeMap.end  ();

    for(; tmIt != tmEnd; ++tmIt)
    {
        UInt32              typeId = tmIt->first;
        FieldContainerType *fcType = FieldContainerFactory::the()->findType(typeId);

        SINFO << "TypeId [" << typeId << "] [" << (fcType != NULL ? fcType->getCName() : "")
              << "] -- [" << tmIt->second.size() << "]\n";
    }

    SINFO << "SharePtrGraphOp::traverse: Shared containers by type:\n";

    ShareCountIt scIt  = _shareCount.begin();
    ShareCountIt scEnd = _shareCount.end  ();

    for(; scIt != scEnd; ++scIt)
    {
        UInt32              typeId = scIt->first;
        FieldContainerType *fcType = FieldContainerFactory::the()->findType(typeId);

        SINFO << "TypeId [" << typeId << "] [" << (fcType != NULL ? fcType->getCName() : "")
              << "] -- [" << scIt->second << "]\n";
    }

    SINFO << std::flush;

    _typeMap   .clear();
    _shareCount.clear();

    return true;
}
void MemoryConsumption::print(std::ostream &os, bool ignoreProto) const
{
    TypeMemMapConstIt tmIt  = _memMap.begin();
    TypeMemMapConstIt tmEnd = _memMap.end  ();

    SizeT         totalMem   = 0;
    UInt32        totalCount = 0;
    boost::format formatter("%|1$-25| [%|2$8|] Byte [%|3$8.0f|] kByte [%|4$4|]\n");

    for(; tmIt != tmEnd; ++tmIt)
    {
        FieldContainerType *fcType =
            FieldContainerFactory::the()->findType(tmIt->first);

        if(fcType == NULL)
            continue;

        if(ignoreProto && tmIt->second.second == 1)
            continue;

        os << formatter % fcType->getCName()
                        % tmIt->second.first
                        % (tmIt->second.first / 1024.f)
                        % tmIt->second.second;

        totalMem   += tmIt->second.first;
        totalCount += tmIt->second.second;
    }

    os << "--------------------------------------------\n";
    os << formatter % "Total"
                    % totalMem
                    % (totalMem / 1024.f)
                    % totalCount;
}
void RenderAction::registerLeaveDefault(
    const FieldContainerType &type,
    const Action::Functor    &func)
{
    if(_vDefaultLeaveFunctors == NULL)
    {
        _vDefaultLeaveFunctors = new Action::FunctorStore;

        addPostFactoryExitFunction(&RenderAction::terminateLeave);
    }

    while(type.getId() >= _vDefaultLeaveFunctors->size())
    {
        _vDefaultLeaveFunctors->push_back(&Action::_defaultLeaveFunction);
    }

    FDEBUG_GV(("Register rendertrav leave for %s\n", type.getCName()));

    (*_vDefaultLeaveFunctors)[type.getId()] = func;
}
예제 #4
0
void FieldContainerFactory::writeSingleTypeFCD(      std::ostream       &out, 
                                               const FieldContainerType *t  )
{
    FieldContainerType *parent = t->getParent();

    out << "<FieldContainer"                          << std::endl;
    out << "\tname=\""       << t->getCName() << "\"" << std::endl;

    if(parent != NULL)
        out << "\tparent=\"" << parent->getCName() << "\"" << std::endl;
    
    out << "\tlibrary=\""
        << "???"
        << "\"" 
        << std::endl;
    out << "\tstructure=\"" 
        << ( t->isAbstract()?"abstract":"concrete" ) 
        << "\""
        << std::endl;

    // look for pointerfield types
           std::string s;
           Int32       pt        = 0;
    static const Char8 *pftypes[] = {"none", "single", "multi", "both"};

    s  = "SF";
    s += t->getCName();
    s += "Ptr";

    if(FieldFactory::the().getFieldType(s.c_str()) != NULL)
    {
        pt |= 1;
    }

    s  = "MF";
    s += t->getCName();
    s += "Ptr";
    
    if(FieldFactory::the().getFieldType(s.c_str()) != NULL)
    {
        pt |= 2;
    }

    out << "\tpointerfieldtypes=\"" << pftypes[pt] << "\"" << std::endl;
    out << ">"                                             << std::endl;

    // Print the fields in this FC, ignore the parents' fields
    // !!! This should start at 0, FIX ME

    for(UInt32 i  = parent ? parent->getNumFieldDescs() + 1 : 1;
               i <= t->getNumFieldDescs();
               i++)
    {
        const FieldDescription *f  = t->getFieldDescription(i);
              FieldType        *ft = NULL;

        ft = FieldFactory::the().getFieldType(f->getTypeId());

        out << "\t<Field"                             << std::endl;
        out << "\t\tname=\"" << f->getCName() << "\"" << std::endl;

        // Filter the SF/MF from the type
        const Char8 *c = ft->getCName();

        if (! strncmp(c, "SF", 2) || ! strncmp(c, "MF", 2))
        {
            c += 2;
        }

        out << "\t\ttype=\"" << c << "\"" << std::endl;

        out << "\t\tcardinality=\""
            << (ft->getCardinality() ? "multi" : "single")
            << "\"" << std::endl;

        out << "\t\tvisibility=\"" 
            << (f->isInternal() ? "internal" : "external")
            << "\"" 
            << std::endl;
        
        out << "\t>"        << std::endl;
        out << "\t</Field>" << std::endl;
    }

    out << "</FieldContainer>" << std::endl;
}
예제 #5
0
bool FieldContainerFactory::initializePendingTypes(void)
{
    bool                returnValue = true;
    FieldContainerType *pType       = NULL;

    if(_bInitialized == false)
        return false;

    SINFO << "OSGFieldContainerFactory init pending types" << std::endl;

    if(_pUnitTypesStore != NULL)
    {
        if(_pMapLock != NULL)
            _pMapLock->aquire();

        UninitTypeStoreIt uninitIt = _pUnitTypesStore->begin();

        while(uninitIt != _pUnitTypesStore->end())
        {
            pType = *uninitIt;

            if(pType->isInitialized() == true)
            {
                uninitIt = _pUnitTypesStore->erase(uninitIt);

//                (*_pTypeIdMap  )[pType->getId()                 ] = pType;

                TypeIdMap::value_type val(pType->getId(), pType);

                _pTypeIdMap->insert(val);

                (*_pTypeNameMap)[IDStringLink(pType->getCName())] = pType;
            }
            else
            {
                if(pType->initialize() == true)
                {
                    uninitIt = _pUnitTypesStore->erase(uninitIt);

//                  (*_pTypeIdMap  )[pType->getId()                 ] = pType;

                    TypeIdMap::value_type val(pType->getId(), pType);
                    
                    _pTypeIdMap->insert(val);

                    (*_pTypeNameMap)[IDStringLink(pType->getCName())] = pType;
                }
                else
                {
                    returnValue = false;

                    uninitIt++;
                }
            }
        }

        if(_pMapLock != NULL)
            _pMapLock->release();

        PINFO << "("
                 << returnValue
                 << "|"
                 << _pUnitTypesStore->size()
                 << ")"
                 << std::endl;
    }

    return returnValue;
}