void COptionTreeWrapper::SerializeStaticItemString(IArchive &ar, COptionTreeItem *item, bool read) { StdString szString; COptionTreeItemStatic *otiStatic = dynamic_cast<COptionTreeItemStatic*>(item); CString szItem; if(otiStatic == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemStatic: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } if(read) { ar.Read(szString); otiStatic->SetStaticText(szString.c_str()); } else { szItem = otiStatic->GetStaticText(); ar.Write(szItem); } }
void COptionTreeWrapper::SerializeStaticItemBool(IArchive &ar, COptionTreeItem *item, bool read) { bool bVal; COptionTreeItemStatic *otiStatic; CString text; otiStatic = dynamic_cast<COptionTreeItemStatic*>(item); if(otiStatic == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemStatic: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } if(read) { ar.Read(bVal); otiStatic->SetStaticText( bVal ? _T("true") : _T("false") ); } else { text = otiStatic->GetStaticText(); if (_tcscmp( text, _T("true") ) == 0) ar.Write(true); else ar.Write(false); } }
void COptionTreeWrapper::SerializeStaticItemInt(IArchive &ar, COptionTreeItem *item, bool read) { int iVal; COptionTreeItemStatic *otiStatic; TCHAR buffer[50]; CString text; otiStatic = dynamic_cast<COptionTreeItemStatic*>(item); if(otiStatic == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemStatic: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } if(read) { ar.Read(iVal); _itot(iVal, buffer, 10); otiStatic->SetStaticText(buffer); } else { text = otiStatic->GetStaticText(); iVal = _tstoi(text); ar.Write(iVal); } }
void COptionTreeWrapper::SerializeStaticItemDouble(IArchive &ar, COptionTreeItem *item, bool read) { double dVal; COptionTreeItemStatic *otiStatic; TCHAR buff[50]; CString text; otiStatic = dynamic_cast<COptionTreeItemStatic*>(item); if(otiStatic == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemStatic: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } if(read) { ar.Read(dVal); _stprintf(buff, "%g", dVal); otiStatic->SetStaticText(buff); } else { text = otiStatic->GetStaticText(); dVal = _tstof(text); ar.Write(dVal); } }
void COptionTreeWrapper::SerializeEditItemDouble(IArchive &ar, COptionTreeItem *item, bool read) { double dVal; COptionTreeItemEdit *otiEdit; otiEdit = dynamic_cast<COptionTreeItemEdit*>(item); if(otiEdit == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemEdit: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } otiEdit->CreateEditItem(OT_EDIT_NUMERICAL, NULL); if(read) { ar.Read(dVal); otiEdit->SetEditDouble(dVal); } else { otiEdit->GetEditDouble(dVal); ar.Write(dVal); } }
void COptionTreeWrapper::SerializeEditItemString(IArchive &ar, COptionTreeItem *item, bool read) { StdString szString; COptionTreeItemEdit *otiEdit; CString szItem; otiEdit = dynamic_cast<COptionTreeItemEdit*>(item); if(otiEdit == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemEdit: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } otiEdit->CreateEditItem(0, NULL); if (read) { ar.Read(szString); otiEdit->SetEditText(szString.c_str()); } else { otiEdit->GetWindowText(szItem); ar.Write(szItem); } }
void serialize(IArchive& ar, pfemp1_antibody_t& antibodies) { ar.startObject(); ar.labelElement("minor") & antibodies.minor; ar.labelElement("major") & antibodies.major; ar.endObject(); }
void COptionTreeWrapper::SerializeCheckBoxItem(IArchive &ar, COptionTreeItem *item, bool read) { bool bVal; COptionTreeItemCheckBox *otiCheckBox; otiCheckBox = dynamic_cast<COptionTreeItemCheckBox*>(item); if(otiCheckBox == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemCheckBox: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } if(read) { ar.Read(bVal); otiCheckBox->SetCheck(bVal); } else { bVal = (otiCheckBox->GetCheck() != 0); ar.Write(bVal); } }
void BaseIntervention::serialize(IArchive& ar, BaseIntervention* obj) { BaseIntervention& intervention = *obj; ar.labelElement("cost_per_unit" ) & intervention.cost_per_unit; ar.labelElement("expired" ) & intervention.expired; ar.labelElement("dont_allow_duplicates") & intervention.dont_allow_duplicates; }
bool NetSystem::Send(const UI32 nSocket, const IArchive & msg) { if (nSocket >= 65335) { //如何控制这个端口的范围 LOG_ERROR("NetSystem::Send nSocket : %d", nSocket); Assert(false); return false; } LinkInfo * pLinkInfo = m_linkmanage.FindLinkBySocket(nSocket); if (NULL == pLinkInfo) { LOG_ERROR("NetSystem::Send LinkInfo is NULL"); Assert(false); return false; } pLinkInfo->m_sendstream.WriteBuff(msg.GetStream(), msg.Length()); struct epoll_event ev; ev.data.ptr = pLinkInfo; ev.events = EPOLLIN | EPOLLOUT | EPOLLET; epoll_ctl(m_epfd, EPOLL_CTL_MOD, pLinkInfo->m_socket, &ev); return true; }
DWORD CGUIStaticText::OnUpdateLanguageEntryParams(DWORD size, void *param) { VERIFY_MESSAGE_SIZE(size, sizeof(IArchive*)); IArchive* ar = (IArchive*) param; if (ar) { if (m_LanguageTextParams != NULL) { delete [] m_LanguageTextParams; m_LanguageTextParams = NULL; } // do deep copy of archive params UINT archiveSize = ar->SeekTo(0, SEEK_END); if (archiveSize > 0) { ar->SeekTo(0, SEEK_SET); ar->SetIsWriting(false); m_LanguageTextParams = new BYTE[archiveSize]; ar->Read(m_LanguageTextParams, archiveSize); m_iLangTextParamSize = archiveSize; } } UpdateLanguageEntryText(); return MSG_HANDLED_STOP; }
IArchive* CGUIStaticText::CreateAndFillArchive() { if (m_LanguageTextParams) { CREATEARCHIVE ca; static CHashString memType(_T("Memory")); ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ; ca.streamData = NULL; ca.streamSize = 0; ca.streamType = &memType; static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca); IArchive *ar = ca.archive; if (ar) { ar->SetIsWriting(true); ar->SeekTo(0); ar->Write(m_LanguageTextParams, m_iLangTextParamSize); } return ar; } else { return NULL; } }
void CGUIStaticText::UpdateLanguageEntryText() { CHashString hszLangKey(m_szLangEntryKey); CHashString hszLangTextOut(_T("")); static DWORD dwZeroString = CHashString(_T("")).GetUniqueID(); if (hszLangKey.GetUniqueID() != dwZeroString) { IArchive *ar = CreateAndFillArchive(); GETLANGUAGETEXTPARAMS gltp; gltp.arParams = ar; gltp.hszKeyString = &hszLangKey; gltp.hszTranslatedText = &hszLangTextOut; static DWORD msgGetLanguageText = CHashString(_T("GetLanguageText")).GetUniqueID(); m_ToolBox->SendMessage(msgGetLanguageText, sizeof(GETLANGUAGETEXTPARAMS), &gltp); if (m_pStaticText) { m_pStaticText->SetText(m_szFont, "", hszLangTextOut.GetString(), hszLangTextOut.GetString(), hszLangTextOut.GetString(), hszLangTextOut.GetString(), m_iFontsize); } if (ar) { ar->Close(); } } }
bool CGUIStaticText::LoadTextFile(const TCHAR *szFilename) { if (_tcscmp(szFilename, "") != 0) { CREATEARCHIVE ca; ca.mode = 0x00000001; static CHashString type = _T("File"); ca.streamType = &type; ca.streamData = (void*) szFilename; static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID(); DWORD retval = EngineGetToolBox()->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca); if ((retval == MSG_NOT_HANDLED) || (retval == MSG_ERROR) || (retval == MSG_WARNING)) { return false; } IArchive *ar = ca.archive; StdString szTemp; unsigned int numBytes = ar->Read(szTemp); ar->Close(); if (numBytes > 0) { m_szText = szTemp; return true; } else { return false; } } else { return false; } }
DWORD CSchemaItem::GetType( DATABASEATTRIBUTEPARAMS *databaseAttributeParams ) { DWORD retVal = MSG_NOT_HANDLED; if( databaseAttributeParams != NULL ) { if( databaseAttributeParams->m_AttributeTypeArchive != NULL ) { IArchive *ar = databaseAttributeParams->m_AttributeTypeArchive; ar->SetIsWriting( true ); ar->SeekTo( 0 ); ar->Write( m_hszType.GetString() ); } else { m_ToolBox->Log( LOGWARNING, _T("No archive specified for GetAttributeType.\n") ); } retVal = MSG_HANDLED_STOP; } else { m_ToolBox->Log( LOGWARNING, _T("Attribute parameters not defined.\n") ); } return retVal; }
void COptionTreeWrapper::SerializeRadioItem(IArchive &ar, COptionTreeItem *item, bool read) { StdString szVal; COptionTreeItemRadio *otiRadio; OT_RADIO_NODE *node; int index; otiRadio = dynamic_cast<COptionTreeItemRadio*>(item); if (item == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemRadio: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } if (read) { ar.Read(szVal); node = otiRadio->Node_FindNode(szVal.c_str()); if (node != NULL) { otiRadio->Node_UnCheckAll(); node->m_bChecked = true; } } else { index = otiRadio->Node_GetChecked(); node = otiRadio->Node_FindNode(index); ar.Write(node->m_strText); } }
void COptionTreeWrapper::SerializeSpinnerItemDouble(IArchive &ar, COptionTreeItem *item, bool read) { double dVal; COptionTreeItemSpinner *otiSpinner; otiSpinner = dynamic_cast<COptionTreeItemSpinner*>(item); if (otiSpinner == NULL) { //error StdString error = _T("Could not cast item to COptionTreeItemSpinner: "); error += item->GetLabelText(); ::MessageBox(NULL, error, _T("Invalid Command"), MB_OK); return; } if (read) { ar.Read(dVal); otiSpinner->SetEditDouble(dVal); } else { otiSpinner->GetEditDouble(dVal); ar.Write(dVal); } }
//-***************************************************************************** void getABCTimeSpan(IArchive archive, chrono_t& first, chrono_t& last) { // TO DO: Is the childBounds property reliable to get the full archive's span? if (!archive.valid()) return; IObject archiveTop = archive.getTop(); if ( archiveTop.getProperties().getPropertyHeader( ".childBnds" ) != NULL ) { // Try to get timing from childBounds first IBox3dProperty childbnds = Alembic::Abc::IBox3dProperty( archive.getTop().getProperties(), ".childBnds", ErrorHandler::kQuietNoopPolicy); TimeSamplingPtr ts = childbnds.getTimeSampling(); first = std::min(first, ts->getSampleTime(0) ); last = std::max(last, ts->getSampleTime(childbnds.getNumSamples()-1) ); return; } unsigned int numChildren = archiveTop.getNumChildren(); for (unsigned i=0; i<numChildren; ++i) // Visit every object to get its first and last sample { IObject obj( archiveTop.getChild( i )); getObjectTimeSpan(obj, first, last, true); } }
void ABCReadGeo::updateTableKnob() { p_tableKnobI->deleteAllItems(); p_tableKnobI->reset(); if (filename()[0] == '\0') { return; } IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(), filename(), Abc::ErrorHandler::kQuietNoopPolicy ); if (!archive.valid()) { return; } IObject archiveTop = archive.getTop(); std::vector<Alembic::AbcGeom::IObject> _objs; getABCGeos(archiveTop, _objs); int obj = 0; for( std::vector<Alembic::AbcGeom::IObject>::const_iterator iObj( _objs.begin() ); iObj != _objs.end(); ++iObj ) { p_tableKnobI->addRow(obj); p_tableKnobI->setCellString(obj,0,iObj->getName()); p_tableKnobI->setCellBool(obj,1,true); obj++; } }
void readDeepHierarchy(const std::string &archiveName) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const unsigned int numChildren = archiveTop.getNumChildren(); std::cout << "The archive has " << numChildren << " children:" << std::endl; ABCA_ASSERT( numChildren == 2, "Expected 2 children, found " << numChildren ); // Iterate through them, print out their names for (unsigned int ii=0; ii<numChildren; ii++) { IObject child( archiveTop, archiveTop.getChildHeader(ii).getName() ); std::cout << " " << child.getName(); recursivelyReadChildren( child ); } // do it again to make sure we clean up after ourselves properly IArchive archive2 = factory.getArchive(archiveName, coreType); IObject archiveTop2 = archive2.getTop(); // Done - the archive closes itself }
void readEmptyCompoundProperties(const std::string &archiveName) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const int numChildren = archiveTop.getNumChildren(); ABCA_ASSERT( numChildren == 2, "Wrong number of children (expected 2)"); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names for (int ii=0; ii<numChildren; ii++) { IObject child( archiveTop, archiveTop.getChildHeader(ii).getName() ); std::cout << " " << child.getName(); std::cout << " has " << child.getNumChildren() << " children" << std::endl; // Properties ICompoundProperty props = child.getProperties(); int numProperties = props.getNumProperties(); std::cout << " ..and " << numProperties << " properties" << std::endl; std::vector<std::string> propNames; for (int pp=0; pp<numProperties; pp++) propNames.push_back( props.getPropertyHeader(pp).getName() ); for (int jj=0; jj<numProperties; jj++) { std::cout << " ..named " << propNames[jj] << std::endl; std::cout << " ..with type: "; PropertyType pType = props.getPropertyHeader(jj).getPropertyType(); if (pType == kCompoundProperty) { std::cout << "compound" << std::endl; } else if (pType == kScalarProperty) { std::cout << "scalar" << std::endl; } else if (pType == kArrayProperty) { std::cout << "array" << std::endl; } } } // Done - the archive closes itself }
int GameComponent::DeductCredits( int credits ) { #ifdef _SHELL // deduct hardware credits return ::DeductCredits( credits ); #else // deduct software credits IArchive *archive = CreateMemoryArchive(); if (archive) { archive->SetIsWriting(true); CHashString hsAttribName(_T("Credits")); GetGlobalAttribute(&hsAttribName, archive); archive->SetIsWriting(false); int currCredits = 0; archive->Read(currCredits, _T("Credits")); currCredits -= credits; SetGlobalAttribute(&hsAttribName, currCredits); archive->Close(); } return 0; #endif }
void CSinglePlayerInfo::Serialize( IArchive& ar, const unsigned int version ) { if( ar.GetMode() == IArchive::MODE_INPUT ) { m_pCurrentPlayerBaseEntity = NULL; // m_pWeaponSystem; m_TaskID = -1; m_vecpItem.resize( 0 ); size_t i, num_item_categories = CItemCategory::NUM_CATEGORIES; for( i=0; i<num_item_categories; i++ ) m_vecpCategoryItem[i].resize(0); m_vecpActiveItem.resize(0); m_pCurrentAircraft.reset(); } GameItemObjectFactory factory; ar.Polymorphic( m_vecpItem, factory ); ar & m_Money; ar & m_KeyBind; // ar & m_PlayTime; if( ar.GetMode() == IArchive::MODE_INPUT ) { // register items to m_vecpCategoryItem } }
CFileSystem::~CFileSystem() { LogTrace("[Shutdown] Shutting down file system"); // Zero out all non-archives for (TResourceMap::iterator it = mResourceMap.begin(); it != mResourceMap.end() ; ++it) { IArchive* pArch; interface_cast<IArchive>(it->second, &pArch); if(pArch) pArch->Release(); else it->second = 0; } TResourceMap::iterator it = mResourceMap.begin(); while(it != mResourceMap.end()) { if(it->second) { IResource *arch = it->second; it->second = 0; LogWarningAlways("Releasing cached archive: %s", arch->FullPath().c_str()); arch->Release(); // iterator now invalid - start over it = mResourceMap.begin(); continue; } ++it; } }
int GameComponent::GetCreditCount() { #ifdef _SHELL // get hardware credits return ::GetCreditCount(); #else // get software credits IArchive *archive = CreateMemoryArchive(); if (archive) { archive->SetIsWriting(true); CHashString hsAttribName(_T("Credits")); GetGlobalAttribute(&hsAttribName, archive); archive->SetIsWriting(false); int credits = 0; archive->Read(credits, _T("Credits")); archive->Close(); return credits; } return 0; #endif }
void SusceptibilityVector::serialize(IArchive& ar, SusceptibilityVector* obj) { SusceptibilityVector& susceptibility = *obj; Susceptibility::serialize(ar, obj); ar.labelElement("m_relative_biting_rate") & susceptibility.m_relative_biting_rate; ar.labelElement("m_age_dependent_biting_risk") & susceptibility.m_age_dependent_biting_risk; }
void AbstractBednet::serialize( IArchive& ar, AbstractBednet* obj ) { BaseIntervention::serialize( ar, obj ); AbstractBednet& bednet = *obj; ar.labelElement( "m_pEffectBlocking" ) & bednet.m_pEffectBlocking; ar.labelElement( "m_pEffectKilling" ) & bednet.m_pEffectKilling; }
void HIVARTStagingByCD4Diagnostic::serialize(IArchive& ar, HIVARTStagingByCD4Diagnostic* obj) { HIVARTStagingAbstract::serialize( ar, obj ); HIVARTStagingByCD4Diagnostic& diag = *obj; ar.labelElement("threshold" ) & diag.threshold; ar.labelElement("ifActiveTB") & diag.ifActiveTB; ar.labelElement("ifPregnant") & diag.ifPregnant; }
void InterventionsContainer::serialize(IArchive& ar, InterventionsContainer* obj) { InterventionsContainer& container = *obj; ar.labelElement("drugVaccineReducedAcquire") & container.drugVaccineReducedAcquire; ar.labelElement("drugVaccineReducedTransmit") & container.drugVaccineReducedTransmit; ar.labelElement("drugVaccineReducedMortality") & container.drugVaccineReducedMortality; ar.labelElement("interventions") & container.interventions; }
void archiveInfoTest(bool useOgawa) { std::string appWriter = "Alembic unit tests"; std::string userStr = "abcdefg"; { Alembic::AbcCoreAbstract::MetaData md; md.set("potato", "salad"); md.set("taco", "bar"); OArchive archive; if (useOgawa) { archive = CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), "archiveInfo.abc", appWriter, userStr, md ); } else { archive = CreateArchiveWithInfo( Alembic::AbcCoreHDF5::WriteArchive(), "archiveInfo.abc", appWriter, userStr, md ); } TESTING_ASSERT( archive.getPtr()->getMetaData().get("taco") == "bar" ); } { AbcF::IFactory factory; AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive("archiveInfo.abc", coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); TESTING_ASSERT( archive.getPtr()->getMetaData().get("taco") == "bar" ); TESTING_ASSERT( archive.getPtr()->getMetaData().get("potato") == "salad" ); TESTING_ASSERT( archive.getArchiveVersion() == ALEMBIC_LIBRARY_VERSION ); std::string appInfo; std::string abcVersionStr; Alembic::Util::uint32_t abcVersion = 0; std::string dateWritten; std::string userInfo; GetArchiveInfo( archive, appInfo, abcVersionStr, abcVersion, dateWritten, userInfo ); TESTING_ASSERT( appWriter == appInfo ); TESTING_ASSERT( userStr == userInfo ); TESTING_ASSERT( abcVersion == ALEMBIC_LIBRARY_VERSION ); std::cout << "Alembic version: " << abcVersionStr << std::endl; std::cout << "Date written: " << dateWritten << std::endl; TESTING_ASSERT( dateWritten != "" ); TESTING_ASSERT( abcVersionStr != "" ); double start, end; GetArchiveStartAndEndTime( archive, start, end ); TESTING_ASSERT( start == DBL_MAX && end == -DBL_MAX ); } }