Model *ResourceManager::loadModel(const Json::Value& value, const std::unordered_map<std::string, ResPtr<Resource> >& externalResources) { Json::Value lods = getMember(value, "lods"); if (not lods.isArray()) { throw std::runtime_error("Unable to get the LODs."); } Model *model = NEW(Model); if (value.isMember("stippledLODs")) { model->mStippledLODs = value["stippledLODs"].asBool(); } for (Json::Value::iterator it = lods.begin(); it != lods.end(); ++it) { Json::Value lod = *it; std::string mesh = getMember(lod, "mesh").asString(); std::string material = getMember(lod, "material").asString(); float distance = getMember(lod, "distance").asFloat(); model->mLODs.push_back(LOD(externalResources.at(mesh).cast<Mesh>(), externalResources.at(material).cast<Material>(), distance)); } model->sortLODs(); return model; }
static Value classNew(Context *ctx, const List<Value>& args) { if (args.getCount() < 1) { ctx->throwException(createException(ExcType::ValueError, "__new__/__call__ takes at least 1 argument.")); } Value class_ = args[0]; Value __base__ = createString("__base__"); Value base = getMember(ctx, class_, __base__); destroy(ctx, __base__); Value __typeID__ = createString("__typeID__"); Value typeID = getMember(ctx, class_, __typeID__); destroy(ctx, __typeID__); if (base.type != ValueType::Object) { ctx->throwException(createException(ExcType::TypeError, "Class base must be an object.")); } if (typeID.type != ValueType::Int) { ctx->throwException(createException(ExcType::TypeError, "Class type ID must be an integer.")); } Value resultHead = createObject(); HashMap<Str, Value>& resultMembers = ((ObjectData *)resultHead.p)->members; HashMap<Str, Value>& baseMembers = ((ObjectData *)base.p)->members; for (auto kv : baseMembers) { resultMembers.set(kv.first, createCopy(kv.second)); } resultMembers.set("__classTypeID__", createInt(typeID.i)); resultMembers.set("__class__", createCopy(args[0])); auto pos = resultMembers.find("__init__"); if (pos != resultMembers.end()) { destroy(ctx, callMethod(ctx, resultHead, "__init__", List<Value>(args.getCount()-1, args.getData()+1))); } else { if (args.getCount() != 1) { ctx->throwException(createException(ExcType::ValueError, "__new__/__call__ takes 1 argument.")); } } destroy(ctx, typeID); destroy(ctx, base); return resultHead; }
virtual base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, const std::string& name) const { // the only thing we do is to check for an integer in name, otherwise, assume a part (size/capacity) is accessed: try { unsigned int indx = boost::lexical_cast<unsigned int>(name); // @todo could also return a direct reference to item indx using another DS type that respects updated(). return getMember( item, new internal::ConstantDataSource<int>(indx)); } catch(...) {} return getMember( item, new internal::ConstantDataSource<std::string>(name) ); }
bool Library::authenticateMember(int aMemberId, string aUsername, string aPassword) { Member *aMember = getMember(aMemberId); if (aMember == NULL) { return false; } return getMember(aMemberId)->authenticate(aUsername, aPassword); }
Resource *ResourceManager::_load(std::string filename) { Json::Reader reader(Json::Features::strictMode()); Json::Value root; if (not reader.parse(readFile(filename), root)) { std::cout << reader.getFormattedErrorMessages() << std::endl; return NULL; } std::unordered_map<std::string, ResPtr<Resource> > externalResources; if (root.isMember("external resources")) { Json::Value externResVal = root["external resources"]; Json::Value::Members members = externResVal.getMemberNames(); for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it) { std::string name = *it; ResPtr<Resource> resource = load(externResVal[name].asString()); externalResources[name] = resource; } } std::string resourceType = root["type"].asString(); if (resourceType == "texture") { return loadTexture(getMember(root, "texture"), externalResources); } else if (resourceType == "model") { return loadModel(getMember(root, "model"), externalResources); } else if (resourceType == "mesh") { return loadMesh(getMember(root, "mesh"), externalResources); } else if (resourceType == "shader") { return loadShader(getMember(root, "shader"), externalResources); } else if (resourceType == "material") { return loadMaterial(getMember(root, "material"), externalResources); } else { throw std::runtime_error("Unknown resource type."); } }
std::string NetworkMessage::serialize() { std::string serializedMessage; ptree pt; std::string strMsg=""; switch(argumentType) { case ArgumentTypes::BookType: strMsg=getBook().serialize(); break; case ArgumentTypes::BorrowType: strMsg=getBorrow().serialize(); break; case ArgumentTypes::MemberType: strMsg=getMember().serialize(); } pt.put ("networkMessage", strMsg); pt.put ("command",getCommadStr()); std::ostringstream buf; write_json (buf, pt, false); serializedMessage = buf.str(); return serializedMessage; }
SILInstruction *ConstantTracker::getDef(SILValue val, ProjectionPath &projStack) { // Track the value up the dominator tree. for (;;) { if (SILInstruction *inst = dyn_cast<SILInstruction>(val)) { if (Projection::isObjectProjection(inst)) { // Extract a member from a struct/tuple/enum. projStack.push_back(Projection(inst)); val = inst->getOperand(0); continue; } else if (SILValue member = getMember(inst, projStack)) { // The opposite of a projection instruction: composing a struct/tuple. projStack.pop_back(); val = member; continue; } else if (SILValue loadedVal = getStoredValue(inst, projStack)) { // A value loaded from memory. val = loadedVal; continue; } else if (isa<ThinToThickFunctionInst>(inst)) { val = inst->getOperand(0); continue; } return inst; } else if (SILValue param = getParam(val)) { // Continue in the caller. val = param; continue; } return nullptr; } }
void registerBitmapClass(as_object& where, Global_as::ASFunction ctor, Global_as::Properties p, const ObjectURI& uri) { Global_as& gl = getGlobal(where); VM& vm = getVM(where); // We should be looking for flash.filters.BitmapFilter, but as this // triggers a lookup of the flash.filters package while we are creating // it, so entering infinite recursion, we'll cheat and assume that // the object 'where' is the filters package. as_function* constructor = getMember(where, getURI(vm, "BitmapFilter")).to_function(); as_object* proto; if (constructor) { fn_call::Args args; VM& vm = getVM(where); proto = constructInstance(*constructor, as_environment(vm), args); } else proto = 0; as_object* cl = gl.createClass(ctor, createObject(gl)); if (proto) p(*proto); // The startup script overwrites the prototype assigned by ASconstructor, // so the new prototype doesn't have a constructor property. We do the // same here. cl->set_member(NSV::PROP_PROTOTYPE, proto); where.init_member(uri , cl, as_object::DefaultFlags); }
int LangFilter::listMembers(Common::ArchiveMemberList &list) const { if (!_arc) return false; Common::ArchiveMemberList orgList; Common::String orgName, name; _arc->listMembers(orgList); int num = 0; //Search only files with the right language and create a list with their basenames for (Common::ArchiveMemberList::const_iterator it = orgList.begin(); it != orgList.end(); it++) { orgName = (*it)->getName(); if (orgName.hasPrefix(kLanguages1[_lang]) ||orgName.hasPrefix(kLanguages1[kCommon])) name = Common::String(orgName.c_str() + 3); else if (orgName.hasPrefix(kLanguages2[_lang]) || orgName.hasPrefix(kLanguages2[kCommon])) { int i = 0; while (orgName[i++] != '/') {;} name = Common::String(orgName.c_str() + i); //If the file is a subfolder, reject it if (name.contains('/')) continue; } else continue; name.toLowercase(); list.push_back(getMember(name)); ++num; } return num; }
/// Convert an AS object to an XML string. std::string ExternalInterface::_objectToXML(as_object *obj) { // GNASH_REPORT_FUNCTION; if ( ! _visited.insert(obj).second ) { return "<circular/>"; } std::stringstream ss; ss << "<object>"; if (obj) { // Get all the properties VM& vm = getVM(*obj); string_table& st = vm.getStringTable(); typedef std::vector<ObjectURI> URIs; URIs uris; Enumerator en(uris); obj->visitKeys(en); for (URIs::const_reverse_iterator i = uris.rbegin(), e = uris.rend(); i != e; ++i) { as_value val = getMember(*obj, *i); const std::string& id = i->toString(st); ss << "<property id=\"" << id << "\">"; ss << _toXML(val); ss << "</property>"; } } ss << "</object>"; return ss.str(); }
/* **************************************************************** * Return the status pointer for a communication Member * allocated by this object. **************************************************************** */ SAMRAI_MPI::Status * AsyncCommStage::lookupStatusPointer( const size_t imember) const { TBOX_ASSERT(imember < numManagedMembers()); TBOX_ASSERT(getMember(imember) != 0); return &d_stat[d_member_to_req[imember]]; }
void ArrayVariant::Value::writeMember(std::ostream& stream, int index) const { if (!getMember(index).getType().isBuiltin()) { stream << boost::lexical_cast<std::string>(index) << ":"; std::stringstream memberStream; std::string line; memberStream << getMember(index); while (std::getline(memberStream, line)) stream << "\n " << line; } else stream << boost::lexical_cast<std::string>(index) << ": " << getMember(index); }
bool Guild::canInvite(int playerId) const { // Guild members with permissions above NONE can invite // Check that guild members permissions are not NONE GuildMember *member = getMember(playerId); if (member->mPermissions & GAL_INVITE) return true; return false; }
/// Construct an Array. // /// This uses the _global Array class to initialize the "constructor" and /// "__proto__" properties. If Array.prototype is undefined, those properties /// are not added. as_object* Global_as::createArray() { as_object* array = new as_object(*this); as_value ctor = getMember(*this, NSV::CLASS_ARRAY); as_object* obj = toObject(ctor, gnash::getVM(*this)); if (obj) { as_value proto; if (obj->get_member(NSV::PROP_PROTOTYPE, &proto)) { array->init_member(NSV::PROP_CONSTRUCTOR, ctor); array->set_prototype(getMember(*obj, NSV::PROP_PROTOTYPE)); } } array->init_member(NSV::PROP_LENGTH, 0.0); array->setArray(); return array; }
size_t AsyncCommStage::numberOfRequests( size_t index_on_stage) const { TBOX_ASSERT(index_on_stage < numManagedMembers()); TBOX_ASSERT(getMember(index_on_stage) != 0); const int init_req = static_cast<int>(d_member_to_req[index_on_stage]); const int term_req = static_cast<int>(d_member_to_req[index_on_stage + 1]); return term_req - init_req; }
/* ******************************************************************* * Remove mutual reference between Member and the stage. * 1. Confirm that the Member is currently on the stage * (or else it is an illegal operation). * 2. Remove mutual references. * 3. Reduce the stage data size by skimming unused space * off the ends of arrays, if possible. ******************************************************************* */ void AsyncCommStage::privateDestageMember( Member* member) { if (member->hasPendingRequests()) { TBOX_ERROR("Cannot clear a Member with pending communications.\n" << "It would corrupt message passing algorithms.\n"); } #ifdef DEBUG_CHECK_ASSERTIONS assertDataConsistency(); #endif if (getMember(member->d_index_on_stage) != member) { /* * Member was not staged with this AsyncCommStage. Since staging * and destaging are private methods, there must be some logic * bug in the library. */ TBOX_ERROR("Library error: An AsyncCommStage cannot destage a Member\n" << "that was not staged with it." << std::endl); } d_members[member->d_index_on_stage] = 0; --d_member_count; /* * Remove the ends of the arrays as much as possible without * shifting arrays. (This is only possible if member is at the * end.) */ size_t min_required_len = d_members.size(); while (min_required_len > 0 && d_members[min_required_len - 1] == 0) { --min_required_len; } if (min_required_len != d_members.size()) { d_members.resize(min_required_len, 0); d_member_to_req.resize(d_members.size() + 1, size_t(MathUtilities<int>::getMax())); const size_t new_num_req = d_member_to_req[d_member_to_req.size() - 1]; d_req_to_member.resize(new_num_req, size_t(MathUtilities<int>::getMax())); d_req.resize(new_num_req, MPI_REQUEST_NULL); } member->d_nreq = member->d_index_on_stage = size_t( MathUtilities<int>::getMax()); member->d_stage = 0; member->d_handler = 0; #ifdef DEBUG_CHECK_ASSERTIONS assertDataConsistency(); #endif }
GuildMember *Guild::addMember(const std::string &name) { GuildMember *m = getMember(name); if (m) return m; m = new GuildMember(this, name); mMembers.push_back(m); return m; }
PartyMember *Party::addMember(const int id, const std::string &name) { PartyMember *m; if ((m = getMember(id))) return m; m = new PartyMember(this, id, name); mMembers.push_back(m); return m; }
int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) { JNIEnv *env = JNI::getEnv(); Common::List<Common::String> dirlist; dirlist.push_back(""); int count = 0; while (!dirlist.empty()) { const Common::String dir = dirlist.back(); dirlist.pop_back(); jstring jpath = env->NewStringUTF(dir.c_str()); jobjectArray jpathlist = (jobjectArray)env->CallObjectMethod(_am, MID_list, jpath); if (env->ExceptionCheck()) { warning("Error while calling AssetManager->list(%s). Ignoring.", dir.c_str()); env->ExceptionDescribe(); env->ExceptionClear(); // May as well keep going ... continue; } env->DeleteLocalRef(jpath); for (jsize i = 0; i < env->GetArrayLength(jpathlist); ++i) { jstring elem = (jstring)env->GetObjectArrayElement(jpathlist, i); const char *p = env->GetStringUTFChars(elem, 0); Common::String thispath = dir; if (!thispath.empty()) thispath += "/"; thispath += p; // Assume files have a . in them, and directories don't if (strchr(p, '.')) { member_list.push_back(getMember(thispath)); ++count; } else { dirlist.push_back(thispath); } env->ReleaseStringUTFChars(elem, p); env->DeleteLocalRef(elem); } env->DeleteLocalRef(jpathlist); } return count; }
/** * Provide a pointer to a Member class to add it to the Library. * This pointer can be either a Staff or a Student object. * * Returns: an Integer which is the member ID. */ void Library::updateMember(int memberId, string name, string email, string address, string phone, string password) { Member *member = getMember(memberId); member->setName(name); member->setEmail(email); member->setAddress(address); member->setContactNumber(phone); member->setPassword(password); cout<<endl<<"Member profile has been updated!"<<endl<<endl; }
Variant ArrayVariant::Value::getMember(const std::string& name) const { int index; try { index = boost::lexical_cast<int>(name); } catch (...) { throw NoSuchMemberException(name); } return getMember(index); }
GuildMember *Guild::addMember(const int accountId, const int charId, const std::string &name) { GuildMember *m = getMember(accountId, charId); if (m) return m; m = new GuildMember(this, accountId, charId, name); mMembers.push_back(m); return m; }
void Library::resetPassword(int aMemberId, string newPassword) { Member *member = getMember(aMemberId); if (member !=NULL) { member->setPassword(newPassword); } else { cout <<endl<< "Given member ID not found!" << endl; } }
void checkForMemberClashes( IMember* m ) { const std::string& name = m->getName(); if( m->getKind() == MK_METHOD ) { handleMemberClash( "method", m, getMember( name ) ); } else { assert( m->getKind() == MK_FIELD ); handleMemberClash( "field", m, getMember( name ) ); std::string accessor; LexicalUtils::formatAccessor( name, LexicalUtils::Getter, accessor ); handleMemberClash( "the getter of field", m, getMember( accessor ) ); if( static_cast<IField*>( m )->getIsReadOnly() == false ) { LexicalUtils::formatAccessor( name, LexicalUtils::Setter, accessor ); handleMemberClash( "the setter of field", m, getMember( accessor ) ); } } }
DWORD WINAPI threadProc(LPVOID par) { int threadIndex = *((int *)par); sums[threadIndex] = 0; for(int i=threadIndex; i<SERIES_MEMBER_COUNT;i+=NUMTHREADS) sums[threadIndex] += getMember(i+1, x); //Signal Master thread that one more processing thread is done EnterCriticalSection(&countCS); threadCount++; LeaveCriticalSection(&countCS); delete par; return 0; }
// extern (used by Global.cpp) void color_class_init(as_object& where, const ObjectURI& uri) { as_object* cl = registerBuiltinClass(where, color_ctor, attachColorInterface, 0, uri); as_object* proto = toObject( getMember(*cl, NSV::PROP_PROTOTYPE), getVM(where)); if (!proto) return; const int protect = as_object::DefaultFlags | PropFlags::readOnly; proto->set_member_flags(NSV::PROP_uuPROTOuu, protect); proto->set_member_flags(NSV::PROP_CONSTRUCTOR, protect); }
int main(){ //input value from permintaan anda persediaan int order,stock; printf("\tBerapa jumlah permintaan : ");scanf("%d",&order); printf("\n\tBerpa jumlah persediaan : ");scanf("%d",&stock); getMember(order,stock); display(); ruleFuzzy(); printf("permintaan input key %s\n",permintaan); printf("persediaan input key %s\n",persediaan); printf("Maka, Jumlah produksi harus : %s , sejumlah : %.2f\n",isProduksi,defuzification(produksi)); printf("Drajat keanggotaan produksi : %.3f\n\n",produksi); return 0; }
void MembershipTableMgr::handleMemberStatusEvent(const std::shared_ptr<ActorMessage>& actor_msg_ptr) { function_footprint(); if (members.empty() || !getLocalMember()) { return; } auto payload = dynamic_cast<MemberStatusEvent*>(actor_msg_ptr->getPayload().get()); uint32_t pos = payload->member_id(); auto status = payload->status(); auto member = getMember(pos); if (!member) { return; } setMemberStatus(member, status); if(member->isPrepared()) { DVLOG(0) << toSimpleString(); joining.store(false); } }
// extern (used by Global.cpp) void accessibility_class_init(as_object& where, const ObjectURI& uri) { Global_as& gl = getGlobal(where); const int flags = as_object::DefaultFlags | PropFlags::readOnly; // This object has unusual properties. as_object* obj = createObject(gl); obj->set_member_flags(NSV::PROP_uuPROTOuu, flags); obj->init_member(NSV::PROP_CONSTRUCTOR, getMember(gl, NSV::CLASS_OBJECT), flags); attachAccessibilityStaticInterface(*obj); // Register _global.Accessibility where.init_member(uri, obj, as_object::DefaultFlags); }
void Guild::removeMember(int playerId) { if (getOwner() == playerId) { // if the leader is leaving, assign next member as leader for (std::list<GuildMember*>::iterator it = mMembers.begin(), it_end = mMembers.end(); it != it_end; ++it) { GuildMember *member = *it; if (member->mId != playerId) { setOwner(member->mId); break; } } } GuildMember *member = getMember(playerId); if (member) mMembers.remove(member); }