void FieldConnectorFactoryBase::registerConnector(
    const FieldType           &oSrcType,
    const FieldType           &oDstType,
    BasicFieldConnector *pSrcToDst,
    BasicFieldConnector *pDstToSrc)
{
    // src -> dst
    {
        EntryMapConstIt srcIt = mConnectorMap.find(oSrcType.getId());

        if(srcIt != mConnectorMap.end())
        {
            ConnectorMapConstIt dstIt =
                srcIt->second->find(oDstType.getId());

            if(dstIt != srcIt->second->end())
            {
                fprintf(stderr,
                        "error conversion already registered for %s -> %s\n",
                        oSrcType.getCName(),
                        oDstType.getCName());

                delete pSrcToDst;
            }
            else
            {
                (*(srcIt->second))[oDstType.getId()] = pSrcToDst;
            }
        }
        else
        {
            ConnectorMap *tmpMap = new ConnectorMap;

            (*tmpMap)[oDstType.getId()] = pSrcToDst;

            mConnectorMap[oSrcType.getId()] = tmpMap;
        }
    }

    // src -> dst
    {
        EntryMapConstIt dstIt = mConnectorMap.find(oDstType.getId());

        if(dstIt != mConnectorMap.end())
        {
            ConnectorMapConstIt srcIt =
                dstIt->second->find(oSrcType.getId());

            if(srcIt != dstIt->second->end())
            {
                fprintf(stderr,
                        "error conversion already registered for %s -> %s\n",
                        oDstType.getCName(),
                        oSrcType.getCName());

                delete pDstToSrc;
            }
            else
            {
                (*(dstIt->second))[oSrcType.getId()] = pDstToSrc;
            }
        }
        else
        {
            ConnectorMap *tmpMap = new ConnectorMap;

            (*tmpMap)[oSrcType.getId()] = pDstToSrc;

            mConnectorMap[oDstType.getId()] = tmpMap;
        }
    }
}
예제 #2
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;
}