载入中...
搜索中...
未找到
SocialGraph.cpp
浏览该文件的文档.
22void SocialGraph::emit(std::string action, EntityId source, EntityId target, std::string type, double oldValue,
24 events_.push_back({nextSequence_++, std::move(action), std::move(source), std::move(target), std::move(type),
111std::vector<EntityId> SocialGraph::targetsOf(const EntityId& source, const std::string& role) const {
116std::vector<EntityId> SocialGraph::assigneesOf(const EntityId& target, const std::string& role) const {
121bool SocialGraph::setRelation(const EntityId& source, const EntityId& target, const std::string& type, double value) {
166std::vector<EntityId> SocialGraph::relationTargets(const EntityId& source, const std::string& type,
177std::vector<EntityId> SocialGraph::relationSources(const EntityId& target, const std::string& type,
200 if (key.first == entity || target == entity) assignments.emplace_back(key.first, key.second, target);
203 for (const auto& [source, role, target] : assignments) changed = unassign(source, role, target) || changed;
bool assign(const EntityId &source, const std::string &role, const EntityId &target)
Adds a role-based source-to-target assignment.
Definition SocialGraph.cpp:86
EntityId controllerOf(const EntityId &entity) const
Returns an entity's controller, or an empty string when absent.
Definition SocialGraph.cpp:76
bool link(const EntityId &source, const EntityId &target, const std::string &type)
Creates a directed typed relation with weight 1.
Definition SocialGraph.cpp:140
std::vector< EntityId > ownedBy(const EntityId &owner) const
Returns entities owned by owner in deterministic ID order.
Definition SocialGraph.cpp:56
bool setOwner(const EntityId &entity, const EntityId &owner)
Sets an entity's owner; an empty owner removes ownership.
Definition SocialGraph.cpp:36
static EntityId integerId(std::int64_t id)
Converts a stable integer ID to its canonical graph key.
Definition SocialGraph.cpp:20
double addRelation(const EntityId &source, const EntityId &target, const std::string &type, double delta)
Adds delta to a directed typed relation and returns its new weight.
Definition SocialGraph.cpp:134
std::vector< EntityId > controlledBy(const EntityId &controller) const
Returns entities controlled by controller in deterministic ID order.
Definition SocialGraph.cpp:81
bool setRelation(const EntityId &source, const EntityId &target, const std::string &type, double value)
Sets a directed typed relation weight, creating the edge if needed.
Definition SocialGraph.cpp:121
bool unassign(const EntityId &source, const std::string &role, const EntityId &target)
Removes a role-based source-to-target assignment.
Definition SocialGraph.cpp:96
bool setController(const EntityId &entity, const EntityId &controller)
Sets an entity's controller; an empty controller removes control.
Definition SocialGraph.cpp:61
std::vector< EntityId > targetsOf(const EntityId &source, const std::string &role) const
Returns targets assigned from source with role in deterministic order.
Definition SocialGraph.cpp:111
bool removeEntity(const EntityId &entity)
Removes an entity and every incoming/outgoing graph reference to it.
Definition SocialGraph.cpp:188
std::vector< EntityId > assigneesOf(const EntityId &target, const std::string &role) const
Returns sources assigned to target with role in deterministic order.
Definition SocialGraph.cpp:116
EntityId ownerOf(const EntityId &entity) const
Returns an entity's owner, or an empty string when absent.
Definition SocialGraph.cpp:51
bool removeRelation(const EntityId &source, const EntityId &target, const std::string &type)
Removes an exact directed typed relation.
Definition SocialGraph.cpp:144
bool isAssigned(const EntityId &source, const std::string &role, const EntityId &target) const
Tests whether an exact assignment exists.
Definition SocialGraph.cpp:106
double relation(const EntityId &source, const EntityId &target, const std::string &type, double fallback=0.0) const
Gets an exact relation weight, or fallback when absent.
Definition SocialGraph.cpp:160
std::vector< EntityId > relationTargets(const EntityId &source, const std::string &type, double minimum=0.0) const
Returns outgoing relation targets filtered by type and minimum weight.
Definition SocialGraph.cpp:166
bool hasRelation(const EntityId &source, const EntityId &target, const std::string &type) const
Tests whether an exact directed typed relation exists.
Definition SocialGraph.cpp:156
std::vector< EntityId > relationSources(const EntityId &target, const std::string &type, double minimum=0.0) const
Returns incoming relation sources filtered by type and minimum weight.
Definition SocialGraph.cpp:177
Definition SocialDocument.h:13
std::string EntityId
Stable, game-defined identifier used by the social graph.
Definition SocialGraph.h:15