void
QFCItem::setup(void)
{
    FieldContainer *pFCAsp = getFC().getAspectCPtr(getAspect());

    if(!pFCAsp)
        return;

    UInt32 uiNumFields = pFCAsp->getType().getNumFieldDescs();
    
    for(UInt32  fieldId = 1; fieldId <= uiNumFields; ++fieldId)
    {
        FieldDescription *pDesc     = 
            pFCAsp->getType().getFieldDescription     (fieldId);
        Field            *pField    = pFCAsp->getField(fieldId);
        
        if(isSFFieldContainerPtr(pField))
        {
            if(stringcmp(pDesc->getCName(), "parent" ) == 0)
                continue;

            SFFieldContainerPtr *pSFFCPtr = 
                reinterpret_cast<SFFieldContainerPtr *>(pField);

            if(pSFFCPtr->getValue() != NullFC)
            {
                setExpandable(this);
                break;
            }
        }
        else if(isMFFieldContainerPtr(pField))
        {
            MFFieldContainerPtr *pMFFCPtr =
                reinterpret_cast<MFFieldContainerPtr *>(pField);

            if(stringcmp(pDesc->getCName(), "parents") == 0)
            {
                if(pMFFCPtr->size() > 1)
                {
                    setExpandable(this);
                    break;
                }
            }
            else
            {
                if(pMFFCPtr->size() > 0)
                {
                    setExpandable(this);
                    break;
                }
            }
        }
    }

    Inherited::setup();
}
Exemple #2
0
void UnionMetaClass::walk_referenced_meta_classes(MetaClassApplier *x) {
    AggregateMetaClass::walk_referenced_meta_classes(x);
    suif_vector<FieldDescription*>::iterator it = _union_fields->begin(), end = _union_fields->end();
    FieldDescription* fieldDescription;
    for ( ; it != end ; it++ ) {
        fieldDescription = *it;
        const MetaClass* currentType = fieldDescription->get_meta_class();
	(*x)(const_cast<MetaClass*>(currentType));
        }
    }
void
QFCItem::expand(void)
{
    if(childCount() != 0)
        return;

    FieldContainer *pFCAsp = getFC().getAspectCPtr(getAspect());

    if(!pFCAsp)
        return;

    FieldContainerType &fcType      = pFCAsp->getType();
    UInt32              uiNumFields = fcType.getNumFieldDescs();

    for(UInt32 fieldId = 1; fieldId <= uiNumFields; ++fieldId)
    {
        FieldDescription *pFieldDesc = fcType.getFieldDescription(fieldId);
        Field            *pField     = pFCAsp->getField          (fieldId);
        
        //add Items for all referenced containers (except parents)
        if(isSFFieldContainerPtr(pField))
        {
            if(stringcmp(pFieldDesc->getCName(), "parent" ) == 0)
                continue;

            addRefedContainer(
                reinterpret_cast<SFFieldContainerPtr *>(pField));
        }
        else if(isMFFieldContainerPtr(pField))
        {
            if(stringcmp(pFieldDesc->getCName(), "parents") == 0)
            {
                addParents(
                    reinterpret_cast<MFFieldContainerPtr *>(pField));
            }
            else
            {
                addRefedContainer(
                    reinterpret_cast<MFFieldContainerPtr *>(pField), 
                    pFieldDesc   );
            }
        }

        //add attachments
        if(stringcmp(pFieldDesc->getCName(), "attachments") == 0)
        {
            addAttachments(dynamic_cast<SFAttachmentMap *>(pField));
        }
    }

    PNOTICE << endLog;
}
Exemple #4
0
Address UnionIterator::current() const {
  if (!_is_valid) return(0);
  AggregateWrapper agg_obj(_address, _metaClass);
  ObjectWrapper obj = _current_field_description->build_object(agg_obj);
  return(obj.get_address());
  //  return _is_valid ?  (((Byte*) _address)+_current_field_description->offset)
  //                  : 0;
}
void PrintFileContents10::printStlFunction(const std::string& name, const std::string& parameters, const std::string& call, std::ostream& ostream, FieldDescription& fieldDescription, ClassValues& classValues) {
    const std::string typeName = fieldDescription.getTypeName();
    const std::string functionName = name + "_stl";
    ostream << "void " << functionName << "_" << classValues.getFullyQualifiedMangledTypeName("__") << "_" << sanitize(fieldDescription.getName())
            << "(" << parameters << ") {" << std::endl
            << "    " << typeName << "* stl = reinterpret_cast<" << typeName << "*>(start_address);" << std::endl
            << "    " << call << ";" << std::endl
            << "}" << std::endl ;
}
Exemple #6
0
RecordSet* UAKGQueryBase::get_parameters(const StringSeq& fieldNames)
               throw(UAKGQuery2::QueryProcessingError,
                     UAKGQuery2::InvalidParameterName,
                     CORBA::SystemException)
{
 checkExecuted();
 RecordSet_var retval = new RecordSetImpl();
 Field fd;
 FieldDescription fdesc;
 CORBA::ULong col;
 try {
   // create RecordSet corresponding to fieldNames.
   for(CORBA::ULong i=0; i<fieldNames.length(); ++i) {
      CORBA::ULong j = paramsBindSet_p_->getFieldIndex(fieldNames[i]);
      fdesc = paramsBindSet_p_->getFieldDescription(j);
      retval->addColumn(fdesc.name,fdesc.type);
      if (fdesc.haveFieldSize()) {
         retval->setFieldSizeAt(i,fdesc.size);
      }
      if ((fdesc.type == TypeNumeric) || (fdesc.type == TypeDecimal)) {
         retval->setNumericFieldPropertiesAt(i,fdesc.precision,fdesc.scale);
      }
   }
   for(CORBA::ULong row=0; row<paramsBindSet_p_->getNRows(); ++row){
    retval->addRow();
    for(CORBA::ULong i=0; i<fieldNames.length(); ++i) {
      CORBA::ULong j = paramsBindSet_p_->getFieldIndex(fieldNames[i]);
      paramsBindSet_p_->getField(row,j,fd,*this);
      setField(retval,row,i,fd);
    }
   }
 }catch(InvalidFieldName){
     throw InvalidParameterName();  
 }catch(InvalidDate){
     throwQueryProcessingError(403,"invalid date field is passed to query",false);
 }
 return retval._retn();
}
osg::Real32 FieldAnimationAdvancer::getValue(void) const
{
   if(getFieldId() == 0)
   {
      //Check if the Field Container is defined
      if(getContainer() == osg::NullFC)
      {
         SWARNING << "There is no Field Container defined to get Field Advancer"  << std::endl;
         return 0.0f;
      }
      //Check if the field in this container is defined
      FieldDescription * f = getContainer()->getType().findFieldDescription(getFieldName().c_str());
      if( f == NULL )
      {
         SWARNING << "Could not find Field "<< getFieldName() << " in Field Container " << getContainer()->getTypeName()  << std::endl;
         return 0.0f;
      }
      //Found the Field so set my Field Id
      beginEditCP(FieldAnimationAdvancerPtr(this), FieldIdFieldMask);
         const_cast<SFUInt32*>(&_sfFieldId)->setValue(f->getFieldId());
      endEditCP(FieldAnimationAdvancerPtr(this), FieldIdFieldMask);
      //The Field was not found
      if(getFieldId() == 0)
      {
         SWARNING << "Could not find Field "<< getFieldName() << " in Field Container " << getContainer()->getTypeName()  << std::endl;
         return 0.0f;
      }
      //Check if the field is a Real32
      if(getContainer()->getField( getFieldId() )->getType() != SFReal32::getClassType())
      {
         SWARNING << "Field "<< getFieldName() << " in Field Container " << getContainer()->getTypeName() << "Is not a SFReal32 Field."  << std::endl;
         return 0.0f;
      }
   }
   
   return static_cast<SFReal32*>(getContainer()->getField( getFieldId() ))->getValue();
}
/** Prints attributes for a field */
void PrintFileContents10::print_field_attr(std::ostream & ostream ,  FieldDescription & fdes ) {
    int array_dim ;

    ostream << "{\"" << fdes.getName() << "\""                               // name
            << ", \"" << fdes.getFullyQualifiedMangledTypeName("__") << "\"" // type_name
            << ", \"" << fdes.getUnits() << "\""                             // units
            << ", \"\", \"\"," << std::endl                                   // alias, user_defined
            << "  \"" << fdes.getDescription() << "\"," << std::endl         // description
            << "  " << fdes.getIO()                                          // io
            << "," << fdes.getEnumString() ;                                 // type
    // There are several cases when printing the size of a variable.
    if ( fdes.isBitField() ) {
        // bitfields are handled in 4 byte (32 bit) chunks
        ostream << ", 4" ;
    } else if (  fdes.isRecord() or fdes.isEnum() or fdes.getTypeName().empty() ) {
        // records enums use io_src_get_size. The sentinel has no typename
        ostream << ", 0" ;
    } else {
        // print size of the underlying type
        ostream << ", sizeof(" << fdes.getTypeName() << ")" ;
    }
    ostream << ", 0, 0, Language_CPP" ; // range_min, range_max, language
    ostream << ", " << (fdes.isStatic() << 1) + (fdes.isDashDashUnits() << 2) << "," << std::endl ; // mods
    if ( fdes.isBitField() ) {
        // For bitfields we need the offset to start on 4 byte boundaries because that is what our
        // insert and extract bitfield routines work with.
        ostream << "  " << (fdes.getFieldOffset() - (fdes.getFieldOffset() % 32)) / 8 ; // offset
    } else {
        ostream << "  " << (fdes.getFieldOffset() / 8) ; // offset
    }
    ostream << ", NULL" ; // attr
    ostream << ", " << fdes.getNumDims() ;                // num_index

    ostream << ", {" ;
    if ( fdes.isBitField() ) {
        ostream << "{" << fdes.getBitFieldWidth() ; // size of bitfield
        ostream << ", " << 32 - (fdes.getFieldOffset() % 32) - fdes.getBitFieldWidth() << "}" ; // start bit
    } else {
        array_dim = fdes.getArrayDim(0) ;
        if ( array_dim < 0 ) array_dim = 0 ;
        ostream << "{" << array_dim << ", 0}" ; // index 0
    }
    unsigned int ii ;
    for ( ii = 1 ; ii < 8 ; ii++ ) {
        array_dim = fdes.getArrayDim(ii) ;
        if ( array_dim < 0 ) array_dim = 0 ;
        ostream << ", {" << array_dim << ", 0}" ; // indexes 1 through 7
    }
    ostream << "}," << std::endl ;
    ostream << "  NULL, NULL, NULL, NULL" ;
    ostream << "}" ;
}
Exemple #9
0
Action::ResultE NFIOBase::clearAttachmentParent(NodePtr &node)
{
    if(node == NullFC)
        return Action::Continue;

    FieldContainerPtr fc = node->getCore();

    if(fc == NullFC)
        return Action::Continue;

    // the core could be shared this would lead to duplicated parent entries.
    if(_added_cores.count(fc) == 1)
        return Action::Continue;

    _added_cores.insert(fc);

    FieldContainerType  &fcType = fc->getType();

    //go through all fields
    for(UInt32 i = 1; i <= fcType.getNumFieldDescs(); ++i)
    {
        FieldDescription    *fDesc = fcType.getFieldDescription(i);
        Field               *fieldPtr = fc->getField(i);
        const FieldType     &fType = fieldPtr->getType();
        std::string         fieldType = fType.getCName();
        BitVector           mask = fDesc->getFieldMask();

        if(fDesc->isInternal())
        {
            continue;
        }

        if(strstr(fieldType.c_str(), "Ptr") != NULL)
        {
            if(fieldType[0] == 'S' && fieldType[1] == 'F') // single field
            {
                AttachmentPtr attachment =
                    AttachmentPtr::
                    dcast(static_cast<SFFieldContainerPtr *>(fieldPtr)
                          ->getValue());
                if(attachment != NullFC)
                {
                    fc.setParentFieldPos(fDesc->getFieldId());
                    beginEditCP(attachment, Attachment::ParentsFieldMask);
                        attachment->getParents().clear();
                    endEditCP(attachment, Attachment::ParentsFieldMask);
                }
            }
            else if(fieldType[0] == 'M' && fieldType[1] == 'F') // multi field
            {
                MFFieldContainerPtr *mfield = static_cast<MFFieldContainerPtr *>(fieldPtr);
                UInt32 noe = mfield->size();
                for(UInt32 j = 0; j < noe; ++j)
                {
                    AttachmentPtr attachment =
                        AttachmentPtr::dcast((*(mfield))[j]);
                    if(attachment != NullFC)
                    {
                        fc.setParentFieldPos(fDesc->getFieldId());
                        beginEditCP(attachment, Attachment::ParentsFieldMask);
                            attachment->getParents().clear();
                        endEditCP(attachment, Attachment::ParentsFieldMask);
                    }
                }
            }
        }
    }

    return Action::Continue;
}
Exemple #10
0
void NFIOBase::writeFCFields(const FieldContainerPtr &fc,
                             const std::string &exclude,
                             bool endMarker)
{
    FieldContainerType  &fcType = fc->getType();
    
    //go through all fields
    for(UInt32 i = 1; i <= fcType.getNumFieldDescs(); ++i)
    {
        FieldDescription    *fDesc = fcType.getFieldDescription(i);
        Field               *fieldPtr = fc->getField(i);
        const FieldType     &fType = fieldPtr->getType();
        BitVector           mask = fDesc->getFieldMask();

        if(!fDesc->isInternal())
        {
            // ignore node volume
            if(fcType == Node::getClassType() &&
               fDesc->getFieldMask() == Node::VolumeFieldMask)
            {
                continue;
            }

            // ignore parents field.
            if(!strcmp(fDesc->getCName(), "parents"))
            {
                continue;
            }

            FDEBUG(("NFIOBase::writeFCPtr: field: '%s' '%s'\n",
                    fDesc->getCName(), fType.getCName()));
            std::string fieldName = fDesc->getCName();
            std::string fieldType = fType.getCName();

            if(!exclude.empty() && exclude.find("'" + fieldName + "'") != std::string::npos)
            {
                FDEBUG(("NFIOBase::writeFields: skipping field: '%s'.\n",
                        fieldName.c_str()));
                continue;
            }
            
            if(strstr(fType.getCName(), "Ptr") != NULL)
            {
                if(fieldPtr->getCardinality() == FieldType::SINGLE_FIELD)
                {
                    _out->putValue(fieldName);
                    _out->putValue(fieldType);
                    _out->putValue(fc->getBinSize(mask));
                    writeSFFieldContainerPtr(static_cast<SFFieldContainerPtr *>(fieldPtr));
                }
                else if(fieldPtr->getCardinality() == FieldType::MULTI_FIELD)
                {
                    MFFieldContainerPtr *mfield = static_cast<MFFieldContainerPtr *>(fieldPtr);
                    if(!mfield->empty())
                    {
                        UInt32 size = sizeof(UInt32) + sizeof(UInt32) * mfield->size();
                        _out->putValue(fieldName);
                        _out->putValue(fieldType);
                        _out->putValue(size);
                        
                        writeMFFieldContainerPtr(mfield);
                    }
                }
                
            }
            else if(!strcmp(fDesc->getCName(), "attachments"))
            {
                SFAttachmentMap *amap = static_cast<SFAttachmentMap *>(fieldPtr);
                
                if(!amap->getValue().empty())
                {
                    // number of attachments
                    UInt32 size = sizeof(UInt32);
                    UInt32 noe  = 0;

                    // check for non zero bindings
                    AttachmentMap::const_iterator mapIt  = amap->getValue().begin();
                    AttachmentMap::const_iterator mapEnd = amap->getValue().end();

                    bool hasBinding = false;

                    for(; mapIt != mapEnd; ++mapIt)
                    {
                        if((mapIt->first &  0x0000ffff) != 0)
                            hasBinding = true;

                        // skip internal attachments
                        if(mapIt->second                              != NullFC &&
                           mapIt->second->getSFInternal()->getValue() == true     )
                        {
                            continue;
                        }

                        // count attachments that get written
                        ++noe;
                    }

                    if(hasBinding == true)
                    {
                        // for each attachment write id and binding
                        size += noe * (sizeof(UInt32) + sizeof(UInt16));
                    }
                    else
                    {
                        // for each attachment write id
                        size += noe * sizeof(UInt32);
                    }

                    _out->putValue(fieldName);
                    _out->putValue(fieldType);
                    _out->putValue(size);
                    writeSFAttachmentMap(amap, noe, hasBinding);
                }
            }
            else
            {
                _out->putValue(fieldName);
                _out->putValue(fieldType);
                _out->putValue(fc->getBinSize(mask));
                fc->copyToBin(*_out, mask);
            }
            
        }
    }
    
    if(endMarker)
    {
        // write fieldcontainer end marker
        writeEndMarker();
    }
}
Exemple #11
0
void NFIOBase::getFCCount(const FieldContainerPtr &fc, UInt32 &count)
{
    if(fc == NullFC)
        return;

    if(_fcSet.count(getContainerId(fc)) > 0)
        return;

    _fcSet.insert(getContainerId(fc));
    ++count;

    FieldContainerType  &fcType = fc->getType();
    
    //go through all fields
    for(UInt32 i = 1; i <= fcType.getNumFieldDescs(); ++i)
    {
        FieldDescription    *fDesc = fcType.getFieldDescription(i);
        Field               *fieldPtr = fc->getField(i);
        const FieldType     &fType = fieldPtr->getType();

        if(!fDesc->isInternal())
        {
            // ignore node volume
            if(fcType == Node::getClassType() &&
               fDesc->getFieldMask() == Node::VolumeFieldMask)
            {
                continue;
            }

            // ignore parents field.
            if(!strcmp(fDesc->getCName(), "parents"))
            {
                continue;
            }

            FDEBUG(("NFIOBase::getFCCount: field: '%s' '%s'\n",
                    fDesc->getCName(), fType.getCName()));

            if(strstr(fType.getCName(), "Ptr") != NULL)
            {
                if(fieldPtr->getCardinality() == FieldType::SINGLE_FIELD)
                {
                    getFCCount(static_cast<SFFieldContainerPtr *>(fieldPtr)->getValue(), count);
                }
                else if(fieldPtr->getCardinality() == FieldType::MULTI_FIELD)
                {
                    MFFieldContainerPtr *mfield = static_cast<MFFieldContainerPtr *>(fieldPtr);
                    UInt32 noe = mfield->size();
                    for(UInt32 i = 0; i < noe; ++i)
                    {
                        getFCCount((*(mfield))[i], count);
                    }
                }
                
            }
            else if(!strcmp(fDesc->getCName(), "attachments"))
            {
                SFAttachmentMap *amap = static_cast<SFAttachmentMap *>(fieldPtr);
                
                AttachmentMap::const_iterator   mapIt = amap->getValue().begin();
                AttachmentMap::const_iterator   mapEnd = amap->getValue().end();
                
                UInt32 noe = amap->getValue().size();
                for(; mapIt != mapEnd; ++mapIt)
                {
                    getFCCount(mapIt->second, count);
                }
            }
        }
    }
}
Exemple #12
0
std::string NFIOBase::readFCFields(const FieldContainerPtr &fc,
                                   const std::string &exclude,
                                   const std::string &endMarkers)
{
    FieldContainerType  &fcType = fc->getType();

    std::string fieldName;
    while(true)
    {
        _in->getValue(fieldName);
        // check for fieldcontainer end marker.
        if(fieldName.empty() || (!endMarkers.empty() &&
                                 endMarkers.find("'" + fieldName + "'") != std::string::npos))
        {
            FDEBUG(("NFIOBase::readFCPtr: found fieldcontainer end marker.\n"));
            break;
        }
        
        std::string fieldType;
        _in->getValue(fieldType);
        UInt32 size;
        _in->getValue(size);
        
        FDEBUG(("NFIOBase::readFCPtr: field: '%s' '%s' %u\n",
                fieldName.c_str(), fieldType.c_str(), size));
        
        Field *field = fc->getField(fieldName.c_str());
        FieldDescription *fDesc = fcType.findFieldDescription(fieldName.c_str());
        BitVector mask;
        if(fDesc != NULL)
        {
            mask = fDesc->getFieldMask();
            // now check for the same type, ok nobody should change a field type but ...
            if(fieldType != field->getType().getCName())
            {
                // for equal sizes try to read it, could be a type change from UInt32 to Int32
                // and that's tolerable.
                FWARNING(("NFIOBase::readFCPtr: found conflicting field types field '%s' with "
                            "types '%s' and '%s'!\n", fieldName.c_str(),
                            fieldType.c_str(), field->getType().getCName()));

                if(size != fc->getBinSize(mask))
                {
                    // ok in this case we skip the field!
                    FFATAL(("NFIOBase::readFCPtr: found conflicting field types with different sizes skipping field '%s' with "
                            "types '%s' and '%s'!\n", fieldName.c_str(),
                            fieldType.c_str(), field->getType().getCName()));
                    _in->skip(size);
                    continue;
                }
            }
        }
        else
        {
            FNOTICE(("NFIOBase::readFCPtr: skipping unknown field '%s' with "
                      "type '%s'!\n", fieldName.c_str(),
                      fieldType.c_str()));
            _in->skip(size);
            continue;
        }

        if(!exclude.empty() && exclude.find("'" + fieldName + "'") != std::string::npos)
        {
            FDEBUG(("NFIOBase::readFCPtr: skipping field '%s'!\n",
                    fieldName.c_str()));
            _in->skip(size);
            continue;
        }

        // ignore parents field.
        if(!strcmp(fieldName.c_str(), "parents"))
        {
            _in->skip(size);
            continue;
        }

        if(strstr(fieldType.c_str(), "Ptr") != NULL)
        {
            if(fieldType[0] == 'S' && fieldType[1] == 'F') // single field
            {
                readSFFieldContainerPtr(fc, mask, field);
            }
            else if(fieldType[0] == 'M' && fieldType[1] == 'F') // multi field
            {
                UInt32 noe;
                _in->getValue(noe);
                readMFFieldContainerPtr(fc, mask, field, noe);
            }
        }
        else if(!strcmp(fieldName.c_str(), "attachments"))
        {
            UInt32 noe;
            _in->getValue(noe);
            // old buggy format without binding info but we want to keep the
            // osb format backward and forward compatible!
            if(size == sizeof(UInt32) + sizeof(UInt32) * noe)
                readMFFieldContainerPtr(fc, mask, field, noe);
            else
                readSFAttachmentMap(fc, mask, field, noe);
        }
        else
        {
            beginEditCP(fc, mask);
                fc->copyFromBin(*_in, mask);
            endEditCP(fc, mask);
        }
    }
    return fieldName;
}
Exemple #13
0
const LString& UnionIterator::current_name() const {
  return _is_valid ? _current_field_description->get_member_name() : emptyLString;
}
Exemple #14
0
const MetaClass* UnionIterator::current_meta_class() const {
  return  _is_valid ? _current_field_description->get_meta_class() : 0;
}