예제 #1
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;
}