ObjectPtr CurveExtrudeOp::doOperation( const CompoundObject * operands ) { CurvesPrimitive * curves = m_curvesParameter->getTypedValue<CurvesPrimitive>(); assert( curves ); assert( curves->arePrimitiveVariablesValid() ); GroupPtr group = new Group(); const IntVectorData * verticesPerCurve = curves->verticesPerCurve(); assert( verticesPerCurve ); unsigned numCurves = verticesPerCurve->readable().size(); unsigned vertexOffset = 0; unsigned varyingOffset = 0; for ( unsigned curveIndex = 0; curveIndex < numCurves; curveIndex++ ) { int numVertices = curves->variableSize( PrimitiveVariable::Vertex, curveIndex ); PatchMeshPrimitivePtr patchMesh = buildPatchMesh( curves, curveIndex, vertexOffset, varyingOffset ); assert( patchMesh ); group->addChild( patchMesh ); vertexOffset += numVertices; varyingOffset += curves->variableSize( PrimitiveVariable::Varying, curveIndex ); } assert( group->children().size() == numCurves ); return group; }
/** @brief ReqToBindInnerPort */ bool CFarmServer::ReqToBindInnerPort(farm::ReqToBindInnerPort_Packet &packet) { GroupPtr pGroup = GetServer()->GetRootGroup().GetChildFromPlayer( packet.senderId ); if (!pGroup) {// Error!! clog::Error( log::ERROR_PROBLEM, "ReqToBindInnerPort Error!!, not exist group user id = %d\n", packet.senderId ); m_Protocol.AckToBindOuterPort( packet.senderId, SEND_T, error::ERR_NOT_FOUND_GROUP, packet.bindSubServerSvrType, 0); return false; } SubServerGroupPtr pSubSvrGroup = dynamic_cast<CSubServerGroup*>(pGroup.Get()); if (!pSubSvrGroup) {// Error!! clog::Error( log::ERROR_PROBLEM, "ReqToBindInnerPort Error!!, not convert group user id = %d\n", packet.senderId ); m_Protocol.AckToBindOuterPort( packet.senderId, SEND_T, error::ERR_NOT_FOUND_GROUP, packet.bindSubServerSvrType, 0); return false; } const int bindPort = pSubSvrGroup->GetToBindInnerPort( CServerSessionAccess(GetServer()) ); RemoteSubServerPtr pSubServer = dynamic_cast<CRemoteSubServer*>( GetServer()->GetSession(packet.senderId)); if (!pSubServer) {// Error!! clog::Error( log::ERROR_PROBLEM, "ReqToBindInnerPort Error!!, not found user user id = %d\n", packet.senderId ); m_Protocol.AckToBindOuterPort( packet.senderId, SEND_T, error::ERR_NOT_FOUND_USER, packet.bindSubServerSvrType, 0); return false; } pSubServer->SetInnerBindPort( packet.bindSubServerSvrType, bindPort ); m_Protocol.AckToBindInnerPort( packet.senderId, SEND_T, error::ERR_SUCCESS, packet.bindSubServerSvrType, bindPort ); return true; }
void ViewportViewer::update() { auto widget = dynamic_cast<ViewportWidget*>(getWidget()); auto *viewport = widget->getViewport(); Property data = dataCache.getOutput(getStart()); Property settings = settingsCache.getOutput(_settingsNode->getOutSockets()[0]); PropertyMap properties = settings.getData<PropertyMap>(); GroupPtr grp; if(data.getType() == "GROUPDATA") { grp = data.getData<GroupPtr>(); } else if(data.getType() == "TRANSFORMABLE") { auto obj = data.getData<AbstractTransformablePtr>(); assert(obj); grp = std::make_shared<Group>(); grp->addMember(obj); } else { return; } for(auto prop : properties) { viewport->setOption(prop.first, prop.second); grp->setProperty(prop.first, prop.second); } viewport->setData(grp); widget->setCameras(); }
bool StandardContactList::addGroup(const GroupPtr& newGroup) { GroupPtr g = group(newGroup->id()); if(g) return false; m_groups.insert(newGroup->id(), newGroup); return true; }
//------------------------------------------------------------------------ // delete CGroup Object memory //------------------------------------------------------------------------ bool CGroup::RemoveChild( netid groupId ) { GroupPtr pGroup = GetChild(groupId); if (!pGroup) return false; // not exist // remove group member BOOST_FOREACH(auto playerId, m_Players) { RemovePlayerNApplyParent(pGroup->GetParent(), playerId); }
void StandardLightVisualiser::addBasicLightVisualiser( ConstStringDataPtr type, GroupPtr &output, Color3f multiplier, float coneAngle, float penumbraAngle, const std::string *penumbraType, float lensRadius ) { bool indicatorFaceCamera = false; if( !type || type->readable() == "point" ) { output->addChild( const_pointer_cast<IECoreGL::Renderable>( pointRays() ) ); indicatorFaceCamera = true; } else if( type->readable() == "spot" ) { float innerAngle = 0; float outerAngle = 0; if( !penumbraType || *penumbraType == "inset" ) { outerAngle = coneAngle; innerAngle = coneAngle - 2.0f * penumbraAngle; } else if( *penumbraType == "outset" ) { outerAngle = coneAngle + 2.0f * penumbraAngle; innerAngle = coneAngle ; } else if( *penumbraType == "absolute" ) { outerAngle = coneAngle; innerAngle = penumbraAngle; } output->addChild( const_pointer_cast<IECoreGL::Renderable>( spotlightCone( innerAngle, outerAngle, lensRadius ) ) ); output->addChild( const_pointer_cast<IECoreGL::Renderable>( ray() ) ); } else if( type->readable() == "distant" ) { for ( int i = 0; i < 3; i++ ) { IECoreGL::GroupPtr rayGroup = new IECoreGL::Group(); Imath::M44f trans; trans.rotate( V3f( 0, 0, 2.0 * M_PI / 3.0 * i ) ); trans.translate( V3f( 0, 0.4, 0.5 ) ); rayGroup->addChild( const_pointer_cast<IECoreGL::Renderable>( ray() ) ); rayGroup->setTransform( trans ); output->addChild( rayGroup ); } } output->addChild( const_pointer_cast<IECoreGL::Renderable>( colorIndicator( multiplier, indicatorFaceCamera ) ) ); }
bool StandardContactList::load_groups(const QDomElement& groups) { QDomNodeList list = groups.elementsByTagName("group"); for(int i = 0; i < list.size(); i++) { QDomElement el = list.at(i).toElement(); int id = el.attribute("id").toInt(); GroupPtr gr = createGroup(id); if(!gr->deserialize(el)) return false; addGroup(gr); } return true; }
bool GroupPool::InsertIfAbsent(const GroupPtr& ptr) { WriteLocker locker(m_map_lock); if (FindByName(ptr->GetGroupName())) return false; Insert(ptr); return true; }
void StandardLightVisualiser::addEnvLightVisualiser( GroupPtr &output, Color3f multiplier, const std::string &textureName ) { IECoreGL::GroupPtr sphereGroup = new IECoreGL::Group(); Imath::M44f trans; trans.scale( V3f( 1, 1, -1 ) ); trans.rotate( V3f( -0.5 * M_PI, -0.5 * M_PI, 0 ) ); sphereGroup->setTransform( trans ); IECoreGL::SpherePrimitivePtr sphere = new IECoreGL::SpherePrimitive(); sphereGroup->addChild( sphere ); IECore::CompoundObjectPtr parameters = new CompoundObject; parameters->members()["lightMultiplier"] = new Color3fData( multiplier ); parameters->members()["previewOpacity"] = new FloatData( 1 ); parameters->members()["mapSampler"] = new StringData( textureName ); parameters->members()["defaultColor"] = new Color3fData( Color3f( textureName == "" ? 1.0f : 0.0f ) ); sphereGroup->getState()->add( new IECoreGL::ShaderStateComponent( ShaderLoader::defaultShaderLoader(), TextureLoader::defaultTextureLoader(), IECoreGL::Shader::defaultVertexSource(), "", environmentLightDrawFragSource(), parameters ) ); sphereGroup->getState()->add( new IECoreGL::DoubleSidedStateComponent( false ) ); output->addChild( sphereGroup ); }
void ImmediateRendererImplementation::addInstance( GroupPtr grp ) { bool visible = static_cast<CameraVisibilityStateComponent *>( getState( CameraVisibilityStateComponent::staticTypeId() ) )->value(); if( visible ) { grp->render( m_stateStack.top().get() ); } }
ConstObjectPtr SOP_SceneCacheSource::transformObject( const IECore::Object *object, const Imath::M44d &transform, bool &hasAnimatedTopology, bool &hasAnimatedPrimVars, std::vector<InternedString> &animatedPrimVars ) { if ( const Primitive *primitive = IECore::runTimeCast<const Primitive>( object ) ) { TransformOpPtr transformer = new TransformOp(); transformer->inputParameter()->setValue( const_cast<Primitive*>( primitive ) ); // safe because we set the copy parameter transformer->copyParameter()->setTypedValue( true ); transformer->matrixParameter()->setValue( new M44dData( transform ) ); ObjectPtr result = transformer->operate(); std::vector<std::string> &primVars = transformer->primVarsParameter()->getTypedValue(); for ( std::vector<std::string>::iterator it = primVars.begin(); it != primVars.end(); ++it ) { if ( std::find( animatedPrimVars.begin(), animatedPrimVars.end(), *it ) == animatedPrimVars.end() ) { animatedPrimVars.push_back( *it ); hasAnimatedPrimVars = true; } } return result; } else if ( const Group *group = IECore::runTimeCast<const Group>( object ) ) { GroupPtr result = group->copy(); MatrixTransformPtr matTransform = matrixTransform( transform ); matTransform->matrix *= group->getTransform()->transform(); result->setTransform( matTransform ); return result; } else if ( const CoordinateSystem *coord = IECore::runTimeCast<const CoordinateSystem>( object ) ) { CoordinateSystemPtr result = coord->copy(); MatrixTransformPtr matTransform = matrixTransform( transform ); matTransform->matrix *= coord->getTransform()->transform(); result->setTransform( matTransform ); return result; } return object; }
/** @brief ReqSubServerLogin */ bool CFarmServer::ReqSubServerLogin(farm::ReqSubServerLogin_Packet &packet) { GroupPtr pFromGroup = GetServer()->GetRootGroup().GetChildFromPlayer( packet.senderId ); if (!pFromGroup) {// Error!! clog::Error( log::ERROR_PROBLEM, "ReqSubServerLogin Error!!, not exist group user id = %d\n\n", packet.senderId ); m_Protocol.AckSubServerLogin( packet.senderId, SEND_T, error::ERR_NOT_FOUND_GROUP); return false; } SubServerGroupPtr pSvrGroup = FindGroup(packet.svrType); if (!pSvrGroup) { //SubServerGroupPtr pNewGroup = dynamic_cast<CSubServerGroup*>( // GetServer()->GetRootGroup().AddChild( GetServer()->GetGroupFactory()) ); //if (!pNewGroup) {// Error!! clog::Error( log::ERROR_PROBLEM, "ReqSubServerLogin Error!!, not exist group %s \n\n", packet.svrType.c_str() ); m_Protocol.AckSubServerLogin( packet.senderId, SEND_T, error::ERR_NO_CREATE_GROUP); return false; } //pSvrGroup = pNewGroup; } // Waiting Group -> New Group pFromGroup->RemovePlayer( pFromGroup->GetNetId(), packet.senderId ); if (!pSvrGroup->AddPlayer(pSvrGroup->GetNetId(), packet.senderId)) { // Error!! pFromGroup->AddPlayer(pFromGroup->GetNetId(), packet.senderId); // 복구 clog::Error( log::ERROR_PROBLEM, "ReqSubServerLogin Error!!, not join group\n" ); m_Protocol.AckSubServerLogin( packet.senderId, SEND_T, error::ERR_NOT_JOIN_GROUP); return false; } pSvrGroup->AddViewer( GetServer()->GetRootGroup().GetNetId() ); m_Protocol.AckSubServerLogin( packet.senderId, SEND_T, error::ERR_SUCCESS); return true; }
std::vector<GroupPtr> FileAuthSourceMapper::get_user_groups(Leosac::Auth::IUserPtr u) { assert(u); std::vector<GroupPtr> grps; auto lambda_cmp = [&](IUserPtr user) -> bool { return user->id() == u->id(); }; for (const auto &grp_map : groups_) { GroupPtr grp; std::tie(std::ignore, grp) = grp_map; if (std::find_if(grp->members().begin(), grp->members().end(), lambda_cmp) != grp->members().end()) { grps.push_back(grp); } } return grps; }
//Item is member of group bool AbstractGroupableItem::isGroupMember(const GroupPtr group) const { //kDebug(); if (!group) { //kDebug() << "Null Group Pointer"; return false; } if (!parentGroup()) { return false; } return group->members().contains(const_cast<AbstractGroupableItem*>(this)); }
void FileAuthSourceMapper::permission_group(const std::string &group_name, const boost::property_tree::ptree &node) { GroupPtr group = groups_[group_name]; if (group && group->profile()) WARN("Already had some data for this group. Will override."); else if (!group) { group = groups_[group_name] = GroupPtr(new Group(group_name)); } SimpleAccessProfilePtr profile(new SimpleAccessProfile()); group->profile(profile); for (const auto &schedule : node) { if (schedule.first == "default_schedule") build_schedule(profile, schedule.second, true); if (schedule.first == "schedule") build_schedule(profile, schedule.second, false); } }
void FileAuthSourceMapper::membership_group(const boost::property_tree::ptree &group_mapping) { for (const auto &group_info : group_mapping) { const boost::property_tree::ptree &node = group_info.second; const std::string &group_name = node.get<std::string>("group"); if (group_info.first != "map") throw ConfigException(config_file_, "Invalid config file content"); GroupPtr grp = groups_[group_name] = GroupPtr(new Group(group_name)); for (const auto &membership : node) { if (membership.first != "user") continue; std::string user_name = membership.second.data(); IUserPtr user = users_[user_name]; if (!user) user = users_[user_name] = IUserPtr(new IUser(user_name)); grp->member_add(user); } } }
TaskGroup* AbstractGroupingStrategy::createGroup(ItemList items) { GroupPtr oldGroup; if (!items.isEmpty() && items.first()->isGrouped()) { oldGroup = items.first()->parentGroup(); } else { oldGroup = rootGroup(); } TaskGroup *newGroup = new TaskGroup(d->groupManager); ItemList oldGroupMembers = oldGroup->members(); int index = oldGroupMembers.count(); d->createdGroups.append(newGroup); //kDebug() << "added group" << d->createdGroups.count(); // NOTE: Queued is vital to make sure groups only get removed after their children, for // correct QAbstractItemModel (TasksModel) transaction semantics. connect(newGroup, SIGNAL(itemRemoved(AbstractGroupableItem*)), this, SLOT(checkGroup()), Qt::QueuedConnection); foreach (AbstractGroupableItem * item, items) { int idx = oldGroupMembers.indexOf(item); if (idx >= 0 && idx < index) { index = idx; } newGroup->add(item); }
void FromHoudiniGroupConverter::convertAndAddPrimitive( GU_Detail *geo, GA_PrimitiveGroup *group, GroupPtr &result, const CompoundObject *operands, const std::string &name ) const { GU_Detail childGeo( geo, group ); for ( GA_GroupTable::iterator<GA_ElementGroup> it=childGeo.primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) { it.group()->clear(); } childGeo.destroyAllEmptyGroups(); PrimitivePtr child = IECore::runTimeCast<Primitive>( doDetailConversion( &childGeo, operands ) ); if ( child ) { if ( name != "" ) { child->blindData()->member<StringData>( "name", false, true )->writable() = name; } result->addChild( child ); } }
ObjectPtr FromHoudiniGroupConverter::doConversion( ConstCompoundObjectPtr operands ) const { GroupPtr result = new Group(); if ( operands->member<const IntData>( "groupingMode" )->readable() == NameAttribute ) { DetailSplitterPtr splitter = new DetailSplitter( handle() ); std::vector<std::string> children; splitter->values( children ); if ( children.empty() ) { doUnnamedConversion( GU_DetailHandleAutoReadLock( handle() ).getGdp(), result, operands ); return result; } for ( std::vector<std::string>::iterator it = children.begin(); it != children.end(); ++it ) { const std::string &name = *it; GU_DetailHandle childHandle = splitter->split( name ); if ( childHandle.isNull() ) { continue; } GU_DetailHandleAutoReadLock readHandle( childHandle ); const GU_Detail *childGeo = readHandle.getGdp(); ObjectPtr child = doDetailConversion( childGeo, operands ); if ( !child ) { // this happens when mismatched primitives share the same name doUnnamedConversion( childGeo, result, operands, name ); } else if ( VisibleRenderablePtr renderable = IECore::runTimeCast<VisibleRenderable>( child ) ) { if ( name != "" ) { renderable->blindData()->member<StringData>( "name", false, true )->writable() = name; } result->addChild( renderable ); } } } else { GU_DetailHandleAutoReadLock readHandle( handle() ); const GU_Detail *geo = readHandle.getGdp(); if ( !geo ) { return 0; } size_t numResultPrims = 0; size_t numOrigPrims = geo->getNumPrimitives(); for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) { GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() ); if ( group->getInternal() || group->isEmpty() ) { continue; } VisibleRenderablePtr renderable = 0; numResultPrims += doGroupConversion( geo, group, renderable, operands ); if( !renderable ) { continue; } renderable->blindData()->member<StringData>( "name", false, true )->writable() = group->getName().toStdString(); result->addChild( renderable ); } if ( numOrigPrims == numResultPrims ) { return result; } GU_Detail ungroupedGeo( (GU_Detail*)geo ); GA_PrimitiveGroup *ungrouped = static_cast<GA_PrimitiveGroup*>( ungroupedGeo.createInternalElementGroup( GA_ATTRIB_PRIMITIVE, "FromHoudiniGroupConverter__ungroupedPrimitives" ) ); for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) { *ungrouped |= *static_cast<GA_PrimitiveGroup*>( it.group() ); } ungrouped->toggleRange( ungroupedGeo.getPrimitiveRange() ); if ( ungrouped->isEmpty() ) { return result; } VisibleRenderablePtr renderable = 0; doGroupConversion( &ungroupedGeo, ungrouped, renderable, operands ); if ( renderable ) { result->addChild( renderable ); } } return result; }
// 'lockNow == false' may only be used during unit tests. Normally we // should never call the callback while holding the lock. void Pool::asyncGet(const Options &options, const GetCallback &callback, bool lockNow) { DynamicScopedLock lock(syncher, lockNow); assert(lifeStatus == ALIVE || lifeStatus == PREPARED_FOR_SHUTDOWN); verifyInvariants(); P_TRACE(2, "asyncGet(appGroupName=" << options.getAppGroupName() << ")"); boost::container::vector<Callback> actions; Group *existingGroup = findMatchingGroup(options); if (OXT_LIKELY(existingGroup != NULL)) { /* Best case: the app group is already in the pool. Let's use it. */ P_TRACE(2, "Found existing Group"); existingGroup->verifyInvariants(); SessionPtr session = existingGroup->get(options, callback, actions); existingGroup->verifyInvariants(); verifyInvariants(); P_TRACE(2, "asyncGet() finished"); if (lockNow) { lock.unlock(); } if (session != NULL) { callback(session, ExceptionPtr()); } } else if (!atFullCapacityUnlocked()) { /* The app super group isn't in the pool and we have enough free * resources to make a new one. */ P_DEBUG("Spawning new Group"); GroupPtr group = createGroupAndAsyncGetFromIt(options, callback, actions); group->verifyInvariants(); verifyInvariants(); P_DEBUG("asyncGet() finished"); } else { /* Uh oh, the app super group isn't in the pool but we don't * have the resources to make a new one. The sysadmin should * configure the system to let something like this happen * as least as possible, but let's try to handle it as well * as we can. */ ProcessPtr freedProcess = forceFreeCapacity(NULL, actions); if (freedProcess == NULL) { /* No process is eligible for killing. This could happen if, for example, * all (super)groups are currently initializing/restarting/spawning/etc. * We have no choice but to satisfy this get() action later when resources * become available. */ P_DEBUG("Could not free a process; putting request to top-level getWaitlist"); getWaitlist.push_back(GetWaiter( options.copyAndPersist(), callback)); } else { /* Now that a process has been trashed we can create * the missing Group. */ P_DEBUG("Creating new Group"); GroupPtr group = createGroup(options); SessionPtr session = group->get(options, callback, actions); /* The Group is now spawning a process so the callback * should now have been put on the wait list, * unless something has changed and we forgot to update * some code here or if options.noop... */ if (session != NULL) { assert(options.noop); actions.push_back(boost::bind(GetCallback::call, callback, session, ExceptionPtr())); } freedProcess->getGroup()->verifyInvariants(); group->verifyInvariants(); } assert(atFullCapacityUnlocked()); verifyInvariants(); verifyExpensiveInvariants(); P_TRACE(2, "asyncGet() finished"); } if (!actions.empty()) { if (lockNow) { if (lock.owns_lock()) { lock.unlock(); } runAllActions(actions); } else { // This state is not allowed. If we reach // here then it probably indicates a bug in // the test suite. abort(); } } }
ConstObjectPtr SOP_SceneCacheSource::transformObject( const IECore::Object *object, const Imath::M44d &transform, Parameters ¶ms ) { if ( const Primitive *primitive = IECore::runTimeCast<const Primitive>( object ) ) { TransformOpPtr transformer = new TransformOp(); transformer->inputParameter()->setValue( const_cast<Primitive*>( primitive ) ); // safe because we set the copy parameter transformer->copyParameter()->setTypedValue( true ); transformer->matrixParameter()->setValue( new M44dData( transform ) ); // add all Point and Normal prim vars to the transformation list, except for rest/Pref const PrimitiveVariableMap &variables = primitive->variables; std::vector<std::string> &primVars = transformer->primVarsParameter()->getTypedValue(); primVars.clear(); for ( PrimitiveVariableMap::const_iterator it = variables.begin(); it != variables.end(); ++it ) { if ( despatchTypedData<TransformGeometricData, IECore::TypeTraits::IsGeometricTypedData, DespatchTypedDataIgnoreError>( it->second.data.get() ) ) { // we don't want to alter rest/Pref because Houdini excepts these to be non-transforming prim vars if ( it->first == "rest" || it->first == "Pref" ) { continue; } primVars.push_back( it->first ); // add the transforming prim vars to the animated list if ( std::find( params.animatedPrimVars.begin(), params.animatedPrimVars.end(), it->first ) == params.animatedPrimVars.end() ) { params.animatedPrimVars.push_back( it->first ); params.hasAnimatedPrimVars = true; } } } return transformer->operate(); } else if ( const Group *group = IECore::runTimeCast<const Group>( object ) ) { GroupPtr result = group->copy(); MatrixTransformPtr matTransform = matrixTransform( transform ); if ( const Transform *transform = group->getTransform() ) { matTransform->matrix *= transform->transform(); } result->setTransform( matTransform ); return result; } else if ( const CoordinateSystem *coord = IECore::runTimeCast<const CoordinateSystem>( object ) ) { CoordinateSystemPtr result = coord->copy(); MatrixTransformPtr matTransform = matrixTransform( transform ); if ( const Transform *transform = coord->getTransform() ) { matTransform->matrix *= transform->transform(); } result->setTransform( matTransform ); return result; } return object; }
/** @brief ReqSubServerBindComplete */ bool CFarmServer::ReqSubServerBindComplete(farm::ReqSubServerBindComplete_Packet &packet) { GroupPtr pGroup = GetServer()->GetRootGroup().GetChildFromPlayer( packet.senderId ); if (!pGroup) {// Error!! clog::Error( log::ERROR_PROBLEM, "ReqSubServerBindComplete Error!!, not exist group user id = %d\n", packet.senderId ); m_Protocol.AckSubServerBindComplete( packet.senderId, SEND_T, error::ERR_NOT_FOUND_GROUP, packet.bindSubServerSvrType ); return false; } SubServerGroupPtr pSubSvrGroup = dynamic_cast<CSubServerGroup*>(pGroup.Get()); if (!pSubSvrGroup) {// Error!! clog::Error( log::ERROR_PROBLEM, "ReqSubServerBindComplete Error!!, not convert group user id = %d\n", packet.senderId ); m_Protocol.AckSubServerBindComplete( packet.senderId, SEND_T, error::ERR_NOT_FOUND_GROUP, packet.bindSubServerSvrType ); return false; } RemoteSubServerPtr pClient = dynamic_cast<CRemoteSubServer*>( GetServer()->GetSession(packet.senderId)); if (!pClient) { clog::Error( log::ERROR_PROBLEM, "AckSubServerBindComplete Error!!, not exist user id = %d\n", packet.senderId ); m_Protocol.AckSubServerBindComplete( packet.senderId, SEND_T, error::ERR_NOT_FOUND_USER, packet.bindSubServerSvrType ); return false; } pClient->SetBindComplete(packet.bindSubServerSvrType); m_Protocol.AckSubServerBindComplete( packet.senderId, SEND_T, error::ERR_SUCCESS, packet.bindSubServerSvrType ); if (packet.bindSubServerSvrType == "client") return false; // pClient 에 p2p link 가 있거나, input_link 가 있는 서버에게 메세지를 보낸다. // 다시 해석하면 pClient에게 p2pS link, output_link 인 서버에게 메세지를 보낸다. std::vector<network::SHostInfo> bindInfo; bindInfo.reserve(10); pClient->GetServerInfoCorrespondClientLink(packet.bindSubServerSvrType, bindInfo); if (bindInfo.empty()) { clog::Error( clog::ERROR_PROBLEM, "Not Found Bind Server binSvrType : %s", packet.bindSubServerSvrType.c_str() ); return false; } if (bindInfo.size() > 1) { clog::Error( clog::ERROR_CRITICAL, "Too Many Bind Server Found binSvrType : %s", packet.bindSubServerSvrType.c_str() ); return false; } std::vector<std::string> links; pSubSvrGroup->GetCorrespondClientInfo( CServerSessionAccess(GetServer()), links ); BOOST_FOREACH(auto &svrType, links) { SubServerGroupPtr pGroup = FindGroup(svrType); if (!pGroup) continue; clog::Log( clog::LOG_F_N_O, clog::LOG_MESSAGE, 0, "CorrespondClientInfo %s", svrType.c_str() ); m_Protocol.BindSubServer( pGroup->GetNetId(), SEND_T, pSubSvrGroup->GetSvrType(), bindInfo.front().ip, bindInfo.front().portnum ); }
IECoreGL::ConstRenderablePtr StandardLightVisualiser::visualise( const IECore::InternedString &attributeName, const IECore::ObjectVector *shaderVector, IECoreGL::ConstStatePtr &state ) const { if( !shaderVector || shaderVector->members().size() == 0 ) { return NULL; } IECore::InternedString metadataTarget; const IECore::CompoundData *shaderParameters = NULL; if( const IECore::Shader *shader = IECore::runTimeCast<const IECore::Shader>( shaderVector->members().back().get() ) ) { metadataTarget = attributeName.string() + ":" + shader->getName(); shaderParameters = shader->parametersData(); } else if( const IECore::Light *light = IECore::runTimeCast<const IECore::Light>( shaderVector->members().back().get() ) ) { /// \todo Remove once all Light node derived classes are /// creating only shaders. metadataTarget = attributeName.string() + ":" + light->getName(); shaderParameters = light->parametersData().get(); } if( !shaderParameters ) { return NULL; } ConstStringDataPtr type = Metadata::value<StringData>( metadataTarget, "type" ); ConstM44fDataPtr orientation = Metadata::value<M44fData>( metadataTarget, "visualiserOrientation" ); const Color3f color = parameter<Color3f>( metadataTarget, shaderParameters, "colorParameter", Color3f( 1.0f ) ); const float intensity = parameter<float>( metadataTarget, shaderParameters, "intensityParameter", 1 ); const float exposure = parameter<float>( metadataTarget, shaderParameters, "exposureParameter", 0 ); const Color3f finalColor = color * intensity * pow( 2.0f, exposure ); if( type && type->readable() == "area" ) { const std::string textureName = parameter<std::string>( metadataTarget, shaderParameters, "textureNameParameter", "" ); const bool flipNormal = parameter<bool>( metadataTarget, shaderParameters, "flipNormalParameter", 0 ); const bool doubleSided = parameter<bool>( metadataTarget, shaderParameters, "doubleSidedParameter", 0 ); const bool sphericalProjection = parameter<bool>( metadataTarget, shaderParameters, "sphericalProjectionParameter", 0 ); M44f projectionTransform = parameter<M44f>( metadataTarget, shaderParameters, "projectionTransformParameter", M44f() ); const std::vector<float> projectionTransformVector = parameter<std::vector<float> >( metadataTarget, shaderParameters, "projectionTransformParameter", std::vector<float>() ); if( projectionTransformVector.size() == 16 ) { projectionTransform = M44f( (float(*)[4])(&projectionTransformVector[0]) ); } addAreaLightVisualiser( state, finalColor, textureName, flipNormal, doubleSided, sphericalProjection, projectionTransform ); return NULL; } GroupPtr result = new Group; const float locatorScale = parameter<float>( metadataTarget, shaderParameters, "locatorScaleParameter", 1 ); Imath::M44f topTrans; if( orientation ) { topTrans = orientation->readable(); } topTrans.scale( V3f( locatorScale ) ); result->setTransform( topTrans ); if( type && type->readable() == "environment" ) { const std::string textureName = parameter<std::string>( metadataTarget, shaderParameters, "textureNameParameter", "" ); addEnvLightVisualiser( result, finalColor, textureName ); } else { float coneAngle = parameter<float>( metadataTarget, shaderParameters, "coneAngleParameter", 0.0f ); float penumbraAngle = parameter<float>( metadataTarget, shaderParameters, "penumbraAngleParameter", 0.0f ); if( ConstStringDataPtr angleUnit = Metadata::value<StringData>( metadataTarget, "angleUnit" ) ) { if( angleUnit->readable() == "radians" ) { coneAngle *= 180.0 / M_PI; penumbraAngle *= 180 / M_PI; } } const std::string *penumbraType = NULL; ConstStringDataPtr penumbraTypeData = Metadata::value<StringData>( metadataTarget, "penumbraType" ); if( penumbraTypeData ) { penumbraType = &penumbraTypeData->readable(); } float lensRadius = 0.0f; if( parameter<bool>( metadataTarget, shaderParameters, "lensRadiusEnableParameter", true ) ) { lensRadius = parameter<float>( metadataTarget, shaderParameters, "lensRadiusParameter", 0.0f ); } addBasicLightVisualiser( type, result, finalColor, coneAngle, penumbraAngle, penumbraType, lensRadius / locatorScale ); } return result; }
ObjectPtr FromHoudiniGroupConverter::doConversion( ConstCompoundObjectPtr operands ) const { GU_DetailHandleAutoReadLock readHandle( handle() ); const GU_Detail *geo = readHandle.getGdp(); if ( !geo ) { return 0; } size_t numResultPrims = 0; size_t numOrigPrims = geo->getNumPrimitives(); GroupPtr result = new Group(); if ( operands->member<const IntData>( "groupingMode" )->readable() == NameAttribute ) { GA_ROAttributeRef attributeRef = geo->findPrimitiveAttribute( "name" ); if ( attributeRef.isInvalid() || !attributeRef.isString() ) { GU_Detail ungroupedGeo( (GU_Detail*)geo ); GA_PrimitiveGroup *ungrouped = static_cast<GA_PrimitiveGroup*>( ungroupedGeo.createInternalElementGroup( GA_ATTRIB_PRIMITIVE, "FromHoudiniGroupConverter__ungroupedPrimitives" ) ); ungrouped->toggleRange( ungroupedGeo.getPrimitiveRange() ); VisibleRenderablePtr renderable = 0; doGroupConversion( &ungroupedGeo, ungrouped, renderable, operands ); if ( renderable ) { Group *group = runTimeCast<Group>( renderable ); if ( group ) { const Group::ChildContainer &children = group->children(); for ( Group::ChildContainer::const_iterator it = children.begin(); it != children.end(); ++it ) { result->addChild( *it ); } } else { result->addChild( renderable ); } } return result; } GU_Detail groupGeo( (GU_Detail*)geo ); AttributePrimIdGroupMap groupMap; regroup( &groupGeo, groupMap, attributeRef ); for ( AttributePrimIdGroupMapIterator it=groupMap.begin(); it != groupMap.end(); ++it ) { convertAndAddPrimitive( &groupGeo, it->second, result, operands, it->first.first ); } } else { for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) { GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() ); if ( group->getInternal() || group->isEmpty() ) { continue; } VisibleRenderablePtr renderable = 0; numResultPrims += doGroupConversion( geo, group, renderable, operands ); if( !renderable ) { continue; } renderable->blindData()->member<StringData>( "name", false, true )->writable() = group->getName().toStdString(); result->addChild( renderable ); } if ( numOrigPrims == numResultPrims ) { return result; } GU_Detail ungroupedGeo( (GU_Detail*)geo ); GA_PrimitiveGroup *ungrouped = static_cast<GA_PrimitiveGroup*>( ungroupedGeo.createInternalElementGroup( GA_ATTRIB_PRIMITIVE, "FromHoudiniGroupConverter__ungroupedPrimitives" ) ); for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it ) { *ungrouped |= *static_cast<GA_PrimitiveGroup*>( it.group() ); } ungrouped->toggleRange( ungroupedGeo.getPrimitiveRange() ); if ( ungrouped->isEmpty() ) { return result; } VisibleRenderablePtr renderable = 0; doGroupConversion( &ungroupedGeo, ungrouped, renderable, operands ); if ( renderable ) { result->addChild( renderable ); } } return result; }
void GroupPool::Insert(const GroupPtr& ptr) { m_group_map[ptr->GetGroupName()] = ptr; }
void SuperGroup::realDoInitialize(const Options &options, unsigned int generation) { vector<ComponentInfo> componentInfos; vector<ComponentInfo>::const_iterator it; ExceptionPtr exception; P_TRACE(2, "Initializing SuperGroup " << inspect() << " in the background..."); try { componentInfos = loadComponentInfos(options); } catch (const tracable_exception &e) { exception = copyException(e); } if (componentInfos.empty() && exception == NULL) { string message = "The directory " + options.appRoot + " does not seem to contain a web application."; exception = boost::make_shared<SpawnException>( message, message, false); } PoolPtr pool = getPool(); Pool::DebugSupportPtr debug = pool->debugSupport; vector<Callback> actions; { if (debug != NULL && debug->superGroup) { debug->debugger->send("About to finish SuperGroup initialization"); debug->messages->recv("Proceed with initializing SuperGroup"); } boost::unique_lock<boost::mutex> lock(getPoolSyncher(pool)); this_thread::disable_interruption di; this_thread::disable_syscall_interruption dsi; NOT_EXPECTING_EXCEPTIONS(); if (OXT_UNLIKELY(getPool() == NULL || generation != this->generation)) { return; } P_TRACE(2, "Initialization of SuperGroup " << inspect() << " almost done; grabbed lock"); assert(state == INITIALIZING); verifyInvariants(); if (componentInfos.empty()) { /* Somehow initialization failed. Maybe something has deleted * the supergroup files while we're working. */ assert(exception != NULL); setState(DESTROYED); actions.reserve(getWaitlist.size()); while (!getWaitlist.empty()) { const GetWaiter &waiter = getWaitlist.front(); actions.push_back(boost::bind(waiter.callback, SessionPtr(), exception)); getWaitlist.pop_front(); } } else { for (it = componentInfos.begin(); it != componentInfos.end(); it++) { const ComponentInfo &info = *it; GroupPtr group = boost::make_shared<Group>(shared_from_this(), options, info); groups.push_back(group); if (info.isDefault) { defaultGroup = group.get(); } } setState(READY); assignGetWaitlistToGroups(actions); } verifyInvariants(); P_TRACE(2, "Done initializing SuperGroup " << inspect()); } this_thread::disable_interruption di; this_thread::disable_syscall_interruption dsi; runAllActions(actions); runInitializationHooks(); }
bool GroupPool::Find(const GroupPtr& ptr) { ReadLocker locker(m_map_lock); return FindByName(ptr->GetGroupName()); }
// 'lockNow == false' may only be used during unit tests. Normally we // should never call the callback while holding the lock. void Pool::asyncGet(const Options &options, const GetCallback &callback, bool lockNow, UnionStation::StopwatchLog **stopwatchLog) { DynamicScopedLock lock(syncher, lockNow); assert(lifeStatus == ALIVE || lifeStatus == PREPARED_FOR_SHUTDOWN); verifyInvariants(); P_TRACE(2, "asyncGet(appGroupName=" << options.getAppGroupName() << ")"); boost::container::vector<Callback> actions; Group *existingGroup = findMatchingGroup(options); if (stopwatchLog != NULL) { // Log some essentials stats about what this request is facing in its upcoming journey through the queue: // 1) position in the queue upon entry, and 2) whether spawning activity is occurring (which takes cycles // but also indicates the server has headroom to handle the load). Json::Value data; if (!existingGroup) { data["message"] = "spawning.."; // the first of this group, so keep it simple (also: we don't know maxQ yet) } else { char queueMaxStr[10]; int queueMax = existingGroup->options.maxRequestQueueSize; if (queueMax > 0) { snprintf(queueMaxStr, 10, "%d", queueMax); } char message[50]; snprintf(message, 100, "queue: %zu / %s, spawning: %s", existingGroup->getWaitlist.size(), (queueMax == 0 ? "inf" : queueMaxStr), (existingGroup->processesBeingSpawned == 0 ? "no" : "yes")); data["message"] = message; } Json::Value json; json["data"] = data; json["data_type"] = "generic"; json["name"] = "Await available process"; *stopwatchLog = new UnionStation::StopwatchLog(options.transaction, "Pool::asyncGet", stringifyJson(json).c_str()); } if (OXT_LIKELY(existingGroup != NULL)) { /* Best case: the app group is already in the pool. Let's use it. */ P_TRACE(2, "Found existing Group"); existingGroup->verifyInvariants(); SessionPtr session = existingGroup->get(options, callback, actions); existingGroup->verifyInvariants(); verifyInvariants(); P_TRACE(2, "asyncGet() finished"); if (lockNow) { lock.unlock(); } if (session != NULL) { callback(session, ExceptionPtr()); } } else if (!atFullCapacityUnlocked()) { /* The app super group isn't in the pool and we have enough free * resources to make a new one. */ P_DEBUG("Spawning new Group"); GroupPtr group = createGroupAndAsyncGetFromIt(options, callback, actions); group->verifyInvariants(); verifyInvariants(); P_DEBUG("asyncGet() finished"); } else { /* Uh oh, the app super group isn't in the pool but we don't * have the resources to make a new one. The sysadmin should * configure the system to let something like this happen * as least as possible, but let's try to handle it as well * as we can. */ ProcessPtr freedProcess = forceFreeCapacity(NULL, actions); if (freedProcess == NULL) { /* No process is eligible for killing. This could happen if, for example, * all (super)groups are currently initializing/restarting/spawning/etc. * We have no choice but to satisfy this get() action later when resources * become available. */ P_DEBUG("Could not free a process; putting request to top-level getWaitlist"); getWaitlist.push_back(GetWaiter( options.copyAndPersist().detachFromUnionStationTransaction(), callback)); } else { /* Now that a process has been trashed we can create * the missing Group. */ P_DEBUG("Creating new Group"); GroupPtr group = createGroup(options); SessionPtr session = group->get(options, callback, actions); /* The Group is now spawning a process so the callback * should now have been put on the wait list, * unless something has changed and we forgot to update * some code here or if options.noop... */ if (session != NULL) { assert(options.noop); actions.push_back(boost::bind(GetCallback::call, callback, session, ExceptionPtr())); } freedProcess->getGroup()->verifyInvariants(); group->verifyInvariants(); } assert(atFullCapacityUnlocked()); verifyInvariants(); verifyExpensiveInvariants(); P_TRACE(2, "asyncGet() finished"); } if (!actions.empty()) { if (lockNow) { if (lock.owns_lock()) { lock.unlock(); } runAllActions(actions); } else { // This state is not allowed. If we reach // here then it probably indicates a bug in // the test suite. abort(); } } }
void SuperGroup::realDoRestart(const Options &options, unsigned int generation) { TRACE_POINT(); vector<ComponentInfo> componentInfos = loadComponentInfos(options); vector<ComponentInfo>::const_iterator it; PoolPtr pool = getPool(); Pool::DebugSupportPtr debug = pool->debugSupport; if (debug != NULL && debug->superGroup) { debug->debugger->send("About to finish SuperGroup restart"); debug->messages->recv("Proceed with restarting SuperGroup"); } boost::unique_lock<boost::mutex> lock(getPoolSyncher(pool)); if (OXT_UNLIKELY(this->generation != generation)) { return; } assert(state == RESTARTING); verifyInvariants(); vector<GroupPtr> allGroups; vector<GroupPtr> updatedGroups; vector<GroupPtr> newGroups; vector<GroupPtr>::const_iterator g_it; vector<Callback> actions; this->options = options; // Update the component information for existing groups. UPDATE_TRACE_POINT(); for (it = componentInfos.begin(); it != componentInfos.end(); it++) { const ComponentInfo &info = *it; pair<GroupPtr, unsigned int> result = findGroupCorrespondingToComponent(groups, info); GroupPtr group = result.first; if (group != NULL) { unsigned int index = result.second; group->componentInfo = info; updatedGroups.push_back(group); groups[index].reset(); } else { // This is not an existing group but a new one, // so create it. group = boost::make_shared<Group>(shared_from_this(), options, info); newGroups.push_back(group); } // allGroups must be in the same order as componentInfos. allGroups.push_back(group); } // Some components might have been deleted, so delete the // corresponding groups. detachAllGroups(groups, actions); // Tell all previous existing groups to restart. for (g_it = updatedGroups.begin(); g_it != updatedGroups.end(); g_it++) { GroupPtr group = *g_it; group->restart(options); } groups = allGroups; defaultGroup = findDefaultGroup(allGroups); setState(READY); assignGetWaitlistToGroups(actions); UPDATE_TRACE_POINT(); verifyInvariants(); lock.unlock(); runAllActions(actions); }
TEST(Skeleton, Group) { SkeletonPtr skel = constructLinkageTestSkeleton(); // Make twice as many BodyNodes in the Skeleton SkeletonPtr skel2 = constructLinkageTestSkeleton(); skel2->getRootBodyNode()->moveTo(skel, nullptr); // Test nullptr construction GroupPtr nullGroup = Group::create("null_group", nullptr); EXPECT_EQ(nullGroup->getNumBodyNodes(), 0u); EXPECT_EQ(nullGroup->getNumJoints(), 0u); EXPECT_EQ(nullGroup->getNumDofs(), 0u); // Test conversion from Skeleton GroupPtr skel1Group = Group::create("skel1_group", skel); EXPECT_EQ(skel1Group->getNumBodyNodes(), skel->getNumBodyNodes()); EXPECT_EQ(skel1Group->getNumJoints(), skel->getNumJoints()); EXPECT_EQ(skel1Group->getNumDofs(), skel->getNumDofs()); for(size_t i=0; i < skel1Group->getNumBodyNodes(); ++i) EXPECT_EQ(skel1Group->getBodyNode(i), skel->getBodyNode(i)); for(size_t i=0; i < skel1Group->getNumJoints(); ++i) EXPECT_EQ(skel1Group->getJoint(i), skel->getJoint(i)); for(size_t i=0; i < skel1Group->getNumDofs(); ++i) EXPECT_EQ(skel1Group->getDof(i), skel->getDof(i)); // Test arbitrary Groups by plucking random BodyNodes, Joints, and // DegreesOfFreedom from a Skeleton. GroupPtr group = Group::create(); std::vector<BodyNode*> bodyNodes; std::vector<Joint*> joints; std::vector<DegreeOfFreedom*> dofs; for(size_t i=0; i < 2*skel->getNumBodyNodes(); ++i) { size_t randomIndex = floor(random(0, skel->getNumBodyNodes())); BodyNode* bn = skel->getBodyNode(randomIndex); if(group->addBodyNode(bn, false)) bodyNodes.push_back(bn); randomIndex = floor(random(0, skel->getNumJoints())); Joint* joint = skel->getJoint(randomIndex); if(group->addJoint(joint, false, false)) joints.push_back(joint); randomIndex = floor(random(0, skel->getNumDofs())); DegreeOfFreedom* dof = skel->getDof(randomIndex); if(group->addDof(dof, false, false)) dofs.push_back(dof); } EXPECT_EQ(group->getNumBodyNodes(), bodyNodes.size()); EXPECT_EQ(group->getNumJoints(), joints.size()); EXPECT_EQ(group->getNumDofs(), dofs.size()); for(size_t i=0; i < group->getNumBodyNodes(); ++i) EXPECT_EQ(group->getBodyNode(i), bodyNodes[i]); for(size_t i=0; i < group->getNumJoints(); ++i) EXPECT_EQ(group->getJoint(i), joints[i]); for(size_t i=0; i < group->getNumDofs(); ++i) EXPECT_EQ(group->getDof(i), dofs[i]); }