当前位置: 首页>>代码示例>>C++>>正文


C++ DataPtr::ReferencesObject方法代码示例

本文整理汇总了C++中DataPtr::ReferencesObject方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::ReferencesObject方法的具体用法?C++ DataPtr::ReferencesObject怎么用?C++ DataPtr::ReferencesObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataPtr的用法示例。


在下文中一共展示了DataPtr::ReferencesObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ShouldSerialize

DataPtr Field::ShouldSerialize( void* instance ) const
{
    // never write discard fields
    if ( m_Flags & FieldFlags::Discard )
    {
        return NULL;
    }

    ObjectPtr object = Registry::GetInstance()->CreateInstance( m_DataClass );
    DataPtr data = ThrowCast< Data >( object );
    data->ConnectField( instance, this );

    // always write force fields
    if ( m_Flags & FieldFlags::Force )
    {
        return data;
    }

    // check for empty/null/invalid state
    if ( !data->ShouldSerialize() )
    {
        return NULL;
    }

    // don't write field at the default value
    DataPtr defaultData = CreateDefaultData();
    if ( defaultData.ReferencesObject() && defaultData->Equals(data) )
    {
        return NULL;
    }

    return data;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: CreateData

DataPtr Field::CreateData(void* instance) const
{
    DataPtr data = CreateData();

    if ( data.ReferencesObject() )
    {
        if ( instance )
        {
            data->ConnectField( instance, this );
        }
    }

    return data;
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例3: Bind

void Control::Bind(const DataPtr& data)
{
  if ( !m_BoundData.ReferencesObject() || !data.ReferencesObject() )
  {
    if ( m_BoundData.ReferencesObject() )
    {
      m_BoundData->RemoveChangedListener( DataChangedSignature::Delegate ( this, &Control::DataChanged ) );
    }

    m_BoundData = data;

    if ( m_BoundData.ReferencesObject() )
    {
      m_BoundData->AddChangedListener( DataChangedSignature::Delegate ( this, &Control::DataChanged ) );
    }
  }
}
开发者ID:pthiben,项目名称:Helium,代码行数:17,代码来源:Control.cpp

示例4: InterpretField

void ReflectValueInterpreter::InterpretField(const Field* field, const std::vector<Reflect::Object*>& instances, Container* parent)
{
    if (field->m_Flags & FieldFlags::Hide)
    {
        return;
    }

    //
    // Create the ui we are generating
    //

    ContainerPtr container = CreateControl<Container>();

    bool readOnly = ( field->m_Flags & FieldFlags::ReadOnly ) == FieldFlags::ReadOnly;

    //
    // Parse
    //

    tstring fieldUI;
    field->GetProperty( TXT( "UIScript" ), fieldUI );
    bool result = Script::Parse(fieldUI, this, parent->GetCanvas(), container, field->m_Flags);

    if (!result)
    {
        if ( field->m_DataClass == Reflect::GetClass<EnumerationData>() )
        {
            ChoicePtr choice = CreateControl<Choice>();

            const Reflect::Enumeration* enumeration = Reflect::ReflectionCast< Enumeration >( field->m_Type );

            std::vector< ChoiceItem > items;
            items.resize( enumeration->m_Elements.GetSize() );

            DynArray< EnumerationElement >::ConstIterator itr = enumeration->m_Elements.Begin();
            DynArray< EnumerationElement >::ConstIterator end = enumeration->m_Elements.End();
            for ( size_t index=0; itr != end; ++itr, ++index )
            {
                ChoiceItem& item = items[index];

                item.m_Key = itr->m_Name;
                item.m_Data = itr->m_Name;
            }

            choice->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
            choice->a_Items.Set( items );
            choice->a_IsDropDown.Set( true );
            choice->a_IsReadOnly.Set( readOnly );

            container->AddChild(choice);
        }
        else
        {
            if ( field->m_DataClass == Reflect::GetClass<BoolData>() )
            {
                CheckBoxPtr checkBox = CreateControl<CheckBox>();
                checkBox->a_IsReadOnly.Set( readOnly );
                checkBox->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
                container->AddChild( checkBox );
            }
            else
            {
                ValuePtr value = CreateControl<Value>();
                value->a_IsReadOnly.Set( readOnly );
                value->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
                container->AddChild( value );
            }
        }
    }

    //
    // Setup label
    //

    LabelPtr label = NULL;

    {
        V_Control::const_iterator itr = container->GetChildren().begin();
        V_Control::const_iterator end = container->GetChildren().end();
        for( ; itr != end; ++itr )
        {
            Label* label = Reflect::SafeCast<Label>( *itr );
            if (label)
            {
                break;
            }
        }
    }

    if (!label.ReferencesObject())
    {
        label = CreateControl<Label>();

        tstring temp;
        field->GetProperty( TXT( "UIName" ), temp );
        if ( temp.empty() )
        {
            bool converted = Helium::ConvertString( field->m_Name, temp );
            HELIUM_ASSERT( converted );
        }
//.........这里部分代码省略.........
开发者ID:euler0,项目名称:Helium,代码行数:101,代码来源:ReflectValueInterpreter.cpp

示例5: DeserializeFields

void ArchiveXML::DeserializeFields( void* structure, const Structure* type )
{
    if ( m_Iterator.GetCurrent()->GetFirstChild() )
    {
        // advance to the first child
        m_Iterator.Advance();

        for ( XMLElement* sibling = m_Iterator.GetCurrent(); sibling != NULL; sibling = sibling->GetNextSibling() )
        {
            HELIUM_ASSERT( m_Iterator.GetCurrent() == sibling );

            const String* fieldNameStr = sibling->GetAttributeValue( Name( TXT("Name") ) );
            uint32_t fieldNameCrc = fieldNameStr ? Crc32( fieldNameStr->GetData() ) : 0x0;

            const Field* field = type->FindFieldByName(fieldNameCrc);
            if ( field )
            {
#ifdef REFLECT_ARCHIVE_VERBOSE
                m_Indent.Get(stdout);
                Log::Debug(TXT("Deserializing field %s\n"), field->m_Name);
                m_Indent.Push();
#endif

                // pull and structure and downcast to data
                DataPtr latentData = SafeCast<Data>( Allocate() );
                if (!latentData.ReferencesObject())
                {
                    // this should never happen, the type id read from the file is bogus
                    throw Reflect::TypeInformationException( TXT( "Unknown data for field %s (%s)" ), field->m_Name, m_Path.c_str() );
#pragma TODO("Support blind data")
                }

                // if the types match we are a natural fit to just deserialize directly into the field data
                if ( field->m_DataClass == field->m_DataClass )
                {
                    // set data pointer
                    latentData->ConnectField( structure, field );

                    // process natively
                    DeserializeInstance( (ObjectPtr&)latentData );

                    // disconnect
                    latentData->Disconnect();
                }
                else // else the type does not match, deserialize it into temp data then attempt to cast it into the field data
                {
                    REFLECT_SCOPE_TIMER(("Casting"));

                    // construct current serialization structure
                    ObjectPtr currentObject = Registry::GetInstance()->CreateInstance( field->m_DataClass );

                    // downcast to data
                    DataPtr currentData = SafeCast<Data>(currentObject);
                    if (!currentData.ReferencesObject())
                    {
                        // this should never happen, the type id in the rtti data is bogus
                        throw Reflect::TypeInformationException( TXT( "Invalid type id for field %s (%s)" ), field->m_Name, m_Path.c_str() );
                    }

                    // process into temporary memory
                    currentData->ConnectField(structure, field);

                    // process natively
                    DeserializeInstance( (ObjectPtr&)latentData );

                    // attempt cast data into new definition
                    Data::CastValue( latentData, currentData, DataFlags::Shallow );

                    // disconnect
                    currentData->Disconnect();
                }
            }

#ifdef REFLECT_ARCHIVE_VERBOSE
            m_Indent.Pop();
#endif
        }
    }
    else
    {
        // advance to the next element
        m_Iterator.Advance();
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:84,代码来源:ArchiveXML.cpp

示例6: DeserializeFields

void ArchiveBinary::DeserializeFields( void* structure, const Structure* type )
{
    int32_t fieldCount = -1;
    m_Stream->Read(&fieldCount); 

    for (int i=0; i<fieldCount; i++)
    {
        uint32_t fieldNameCrc = BeginCrc32();
        m_Stream->Read( &fieldNameCrc );

        const Field* field = type->FindFieldByName(fieldNameCrc);
        if ( field )
        {
#ifdef REFLECT_ARCHIVE_VERBOSE
            m_Indent.Get(stdout);
            Log::Print(TXT("Deserializing field %s\n"), field->m_Name);
            m_Indent.Push();
#endif

            // pull and structure and downcast to data
            DataPtr latentData = SafeCast<Data>( Allocate() );
            if (!latentData.ReferencesObject())
            {
                // this should never happen, the type id read from the file is bogus
                throw Reflect::TypeInformationException( TXT( "Unknown data for field %s (%s)" ), field->m_Name, m_Path.c_str() );
#pragma TODO("Support blind data")
            }

            // if the types match we are a natural fit to just deserialize directly into the field data
            if ( field->m_DataClass == field->m_DataClass )
            {
                // set data pointer
                latentData->ConnectField( structure, field );

                // process natively
                DeserializeInstance( (ObjectPtr&)latentData );

                // disconnect
                latentData->Disconnect();
            }
            else // else the type does not match, deserialize it into temp data then attempt to cast it into the field data
            {
                REFLECT_SCOPE_TIMER(("Casting"));

                // construct current serialization structure
                ObjectPtr currentObject = Registry::GetInstance()->CreateInstance( field->m_DataClass );

                // downcast to data
                DataPtr currentData = SafeCast<Data>(currentObject);
                if (!currentData.ReferencesObject())
                {
                    // this should never happen, the type id in the rtti data is bogus
                    throw Reflect::TypeInformationException( TXT( "Invalid type id for field %s (%s)" ), field->m_Name, m_Path.c_str() );
                }

                // process into temporary memory
                currentData->ConnectField(structure, field);

                // process natively
                DeserializeInstance( (ObjectPtr&)latentData );

                // attempt cast data into new definition
                Data::CastValue( latentData, currentData, DataFlags::Shallow );

                // disconnect
                currentData->Disconnect();
            }
        }

#ifdef REFLECT_ARCHIVE_VERBOSE
        m_Indent.Pop();
#endif
    }

    int32_t terminator = -1;
    m_Stream->Read(&terminator); 
    if (terminator != -1)
    {
        throw Reflect::DataFormatException( TXT( "Unterminated field array block (%s)" ), m_Path.c_str() );
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:81,代码来源:ArchiveBinary.cpp

示例7: InterpretField


//.........这里部分代码省略.........
                editButton->a_HelpText.Set( TXT( "Attempt to edit the file using its associated default application." ) );
                container->AddChild( editButton );
            }
        }
    }
    else
    {
        ValuePtr value = CreateControl< Value >();
        value->a_IsReadOnly.Set( readOnly );
        value->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );
        container->AddChild( value );
    }


    //
    // Setup label
    //

    LabelPtr label = NULL;

    {
        V_Control::const_iterator itr = container->GetChildren().begin();
        V_Control::const_iterator end = container->GetChildren().end();
        for( ; itr != end; ++itr )
        {
            Label* label = Reflect::SafeCast<Label>( *itr );
            if (label)
            {
                break;
            }
        }
    }

    if (!label.ReferencesObject())
    {
        label = CreateControl< Label >();

        tstring temp;
        field->GetProperty( TXT( "UIName" ), temp );
        if ( temp.empty() )
        {
            bool converted = Helium::ConvertString( field->m_Name, temp );
            HELIUM_ASSERT( converted );
        }

        label->BindText( temp );
        label->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) );

        container->InsertChild(0, label);
    }

    //
    // Create type m_FinderSpecific data bound to this and additional instances
    //

    std::vector<Data*> ser;

    {
        std::vector<Reflect::Object*>::const_iterator itr = instances.begin();
        std::vector<Reflect::Object*>::const_iterator end = instances.end();
        for ( ; itr != end; ++itr )
        {
            DataPtr s = field->CreateData();

            if (s->IsClass(Reflect::GetClass<ContainerData>()))
            {
开发者ID:,项目名称:,代码行数:67,代码来源:


注:本文中的DataPtr::ReferencesObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。