void HField::saveAChannel(const std::string& name, TypedBuffer * chan) { HBase grp(childPath(name)); int ne = chan->numElements(); if(!grp.hasNamedAttr(".nelm")) grp.addIntAttr(".nelm"); grp.writeIntAttr(".nelm", &ne); if(!grp.hasNamedAttr(".typ")) grp.addIntAttr(".typ"); int t = chan->valueType(); grp.writeIntAttr(".typ", &t); if(chan->valueType() == TypedBuffer::TFlt) { if(!grp.hasNamedData(".def")) grp.addFloatData(".def", ne); grp.writeFloatData(".def", ne, chan->typedData<float>()); } else if(chan->valueType() == TypedBuffer::TVec3) { if(!grp.hasNamedData(".def")) grp.addVector3Data(".def", ne); grp.writeVector3Data(".def", ne, chan->typedData<Vector3F>()); } grp.close(); HBase gbake(grp.childPath(".bake")); gbake.close(); }
void HField::loadAChannel(const std::string& name, AField * fld) { if(!hasNamedChild(name.c_str())) { std::cout<<"\n has no child "<<name; return; } HBase grp(childPath(name)); int ne = 1; grp.readIntAttr(".nelm", &ne); int t = 1; grp.readIntAttr(".typ", &t); if(t==TypedBuffer::TFlt) { fld->addFloatChannel(name, ne); } else if(t==TypedBuffer::TVec3) { fld->addVec3Channel(name, ne); } TypedBuffer * chan = fld->namedChannel(name); if(t==TypedBuffer::TFlt) { grp.readFloatData(".def", ne, chan->typedData<float>()); } else if(t==TypedBuffer::TVec3) { grp.readVector3Data(".def", ne, chan->typedData<Vector3F>()); } grp.close(); }
AAnimationKey HAnimationCurve::loadKey(int i) { std::string keyPath = childPath(i); HBase keyGrp(keyPath); AAnimationKey key; int itwo[2]; keyGrp.readIntAttr(".tangent", itwo); key._inTangentType = itwo[0]; key._outTangentType = itwo[1]; float ftwo[2]; keyGrp.readFloatAttr(".weight", ftwo); key._inWeight = ftwo[0]; key._outWeight = ftwo[1]; keyGrp.readFloatAttr(".angle", ftwo); key._inAngle = ftwo[0]; key._outAngle = ftwo[1]; keyGrp.readFloatAttr(".key_val", ftwo); key._key = ftwo[0]; key._value = ftwo[1]; keyGrp.close(); return key; }
void HAttributeGroup::writeCompound(ACompoundAttribute * data) { short n = data->numChild(); short i=0; for(;i<n;i++) { HAttributeGroup g(childPath(data->shortName())); g.save(data->child(i)); g.close(); } }
void EndpointServiceProxy::updateConfig(boost::shared_ptr<ZKManager> zkManagerPtr){ vector<string> serverNameList; vector<ServerNode> serverList; if(!zkManagerPtr->getChildren(zkPath_, serverNameList)){ LOG_ERROR("EndpointServiceProxy::updateConfig => get serverName failure : path = " << zkPath_); initProxy(serverList); return; } std::vector<int> indexList; std::map<int, std::string> serverMap; for(size_t i = 0; i < serverNameList.size(); ++i){ size_t p = serverNameList[i].find('-'); if(p == string::npos){ LOG_ERROR("EndpointServiceProxy::updateConfig => serverName format error : name = [" << serverNameList[i] << "]"); continue; } int index = 0; try{ index = boost::lexical_cast<int>(serverNameList[i].substr(p + 1)); } catch (boost::bad_lexical_cast &){ LOG_ERROR("EndpointServiceProxy::updateConfig => convert server index failure : index = [" << serverNameList[i].substr(p + 1) << "]"); continue; } std::string childPath(zkPath_); childPath.append("/"); childPath.append(serverNameList[i]); std::string server; if(zkManagerPtr->get(childPath, server)){ indexList.push_back(index); serverMap[index] = server; } else { LOG_ERROR("EndpointServiceProxy::updateConfig => get server node failure : path = " << childPath); } } sort(indexList.begin(), indexList.end()); for(size_t i = 0; i < indexList.size(); ++i){ ServerNode node; node.index = indexList[i]; node.address = serverMap[node.index]; serverList.push_back(node); } initProxy(serverList); }
// Find the child that matches the first part of 'path'. // E.g. if a child path is "/usr" and 'path' is "/usr/include" // then the child for /usr is returned. wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString& path, bool& done) { wxString path2(path); // Make sure all separators are as per the current platform path2.Replace(wxT("\\"), wxString(wxFILE_SEP_PATH)); path2.Replace(wxT("/"), wxString(wxFILE_SEP_PATH)); // Append a separator to foil bogus substring matching path2 += wxString(wxFILE_SEP_PATH); // In MSW or PM, case is not significant #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__) path2.MakeLower(); #endif wxTreeItemIdValue cookie; wxTreeItemId childId = m_treeCtrl->GetFirstChild(parentId, cookie); while (childId.IsOk()) { wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(childId); if (data && !data->m_path.empty()) { wxString childPath(data->m_path); if (!wxEndsWithPathSeparator(childPath)) childPath += wxString(wxFILE_SEP_PATH); // In MSW and PM, case is not significant #if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__) childPath.MakeLower(); #endif if (childPath.length() <= path2.length()) { wxString path3 = path2.Mid(0, childPath.length()); if (childPath == path3) { if (path3.length() == path2.length()) done = true; else done = false; return childId; } } } childId = m_treeCtrl->GetNextChild(parentId, cookie); } wxTreeItemId invalid; return invalid; }
void HAnimationCurve::saveKey(unsigned i, const AAnimationKey & key) { std::stringstream sst; sst<<"key_"<<i; std::string keyPath = childPath(sst.str()); HBase keyGrp(keyPath); float ftwo[2]; ftwo[0] = key._key; ftwo[1] = key._value; if(!keyGrp.hasNamedAttr(".key_val")) keyGrp.addFloatAttr(".key_val", 2); keyGrp.writeFloatAttr(".key_val", ftwo); if(!keyGrp.hasNamedAttr(".angle")) keyGrp.addFloatAttr(".angle", 2); ftwo[0] = key._inAngle; ftwo[1] = key._outAngle; keyGrp.writeFloatAttr(".angle", ftwo); if(!keyGrp.hasNamedAttr(".weight")) keyGrp.addFloatAttr(".weight", 2); ftwo[0] = key._inWeight; ftwo[1] = key._outWeight; keyGrp.writeFloatAttr(".weight", ftwo); int itwo[2]; itwo[0] = key._inTangentType; itwo[1] = key._outTangentType; if(!keyGrp.hasNamedAttr(".tangent")) keyGrp.addIntAttr(".tangent", 2); keyGrp.writeIntAttr(".tangent", itwo); keyGrp.close(); }
void HField::saveAChannelFrame(const std::string & frame, const std::string& channelName, TypedBuffer * chan) { HBase grp(childPath(channelName)); int ne = chan->numElements(); HBase gbake(grp.childPath(".bake")); if(chan->valueType() == TypedBuffer::TFlt) { if(!gbake.hasNamedData(frame.c_str())) gbake.addFloatData(frame.c_str(), ne); gbake.writeFloatData(frame.c_str(), ne, chan->typedData<float>()); } else if(chan->valueType() == TypedBuffer::TVec3) { if(!gbake.hasNamedData(frame.c_str())) gbake.addVector3Data(frame.c_str(), ne); gbake.writeVector3Data(frame.c_str(), ne, chan->typedData<Vector3F>()); } gbake.close(); grp.close(); }
bool HField::loadAChannelFrame(const std::string & frame, const std::string& channelName, TypedBuffer * chan) { HBase grp(childPath(channelName)); int ne = chan->numElements(); HBase gbake(grp.childPath(".bake")); if(chan->valueType() == TypedBuffer::TFlt) { if(!gbake.hasNamedData(frame.c_str())) return false; gbake.readFloatData(frame.c_str(), ne, chan->typedData<float>()); } else if(chan->valueType() == TypedBuffer::TVec3) { if(!gbake.hasNamedData(frame.c_str())) return false; gbake.readVector3Data(frame.c_str(), ne, chan->typedData<Vector3F>()); } gbake.close(); grp.close(); return true; }