mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-12 16:58:39 +00:00
NodeDefManager: Improve const-correctness of interfaces
- Add ability to explicitly reset NodeResolve state (useful for unittesting) - Remove non-essential NodeResolve methods modifying state from INodeDefManager - Add const qualifier to NodeDefManager and ContentFeatures serialize
This commit is contained in:
parent
b785577f03
commit
633af58a05
3 changed files with 46 additions and 48 deletions
|
@ -265,9 +265,9 @@ struct ContentFeatures
|
|||
ContentFeatures();
|
||||
~ContentFeatures();
|
||||
void reset();
|
||||
void serialize(std::ostream &os, u16 protocol_version);
|
||||
void serialize(std::ostream &os, u16 protocol_version) const;
|
||||
void deSerialize(std::istream &is);
|
||||
void serializeOld(std::ostream &os, u16 protocol_version);
|
||||
void serializeOld(std::ostream &os, u16 protocol_version) const;
|
||||
void deSerializeOld(std::istream &is, int version);
|
||||
|
||||
/*
|
||||
|
@ -288,48 +288,44 @@ enum NodeResolveMethod {
|
|||
NODE_RESOLVE_DEFERRED,
|
||||
};
|
||||
|
||||
class INodeDefManager
|
||||
{
|
||||
class INodeDefManager {
|
||||
public:
|
||||
INodeDefManager(){}
|
||||
virtual ~INodeDefManager(){}
|
||||
// Get node definition
|
||||
virtual const ContentFeatures& get(content_t c) const=0;
|
||||
virtual const ContentFeatures& get(const MapNode &n) const=0;
|
||||
virtual const ContentFeatures &get(content_t c) const=0;
|
||||
virtual const ContentFeatures &get(const MapNode &n) const=0;
|
||||
virtual bool getId(const std::string &name, content_t &result) const=0;
|
||||
virtual content_t getId(const std::string &name) const=0;
|
||||
// Allows "group:name" in addition to regular node names
|
||||
virtual void getIds(const std::string &name, std::set<content_t> &result)
|
||||
const=0;
|
||||
virtual const ContentFeatures& get(const std::string &name) const=0;
|
||||
virtual const ContentFeatures &get(const std::string &name) const=0;
|
||||
|
||||
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
|
||||
virtual void serialize(std::ostream &os, u16 protocol_version) const=0;
|
||||
|
||||
virtual bool getNodeRegistrationStatus() const=0;
|
||||
virtual void setNodeRegistrationStatus(bool completed)=0;
|
||||
|
||||
virtual void pendNodeResolve(NodeResolver *nr, NodeResolveMethod how)=0;
|
||||
virtual bool cancelNodeResolveCallback(NodeResolver *nr)=0;
|
||||
virtual void runNodeResolveCallbacks()=0;
|
||||
};
|
||||
|
||||
class IWritableNodeDefManager : public INodeDefManager
|
||||
{
|
||||
class IWritableNodeDefManager : public INodeDefManager {
|
||||
public:
|
||||
IWritableNodeDefManager(){}
|
||||
virtual ~IWritableNodeDefManager(){}
|
||||
virtual IWritableNodeDefManager* clone()=0;
|
||||
// Get node definition
|
||||
virtual const ContentFeatures& get(content_t c) const=0;
|
||||
virtual const ContentFeatures& get(const MapNode &n) const=0;
|
||||
virtual const ContentFeatures &get(content_t c) const=0;
|
||||
virtual const ContentFeatures &get(const MapNode &n) const=0;
|
||||
virtual bool getId(const std::string &name, content_t &result) const=0;
|
||||
// If not found, returns CONTENT_IGNORE
|
||||
virtual content_t getId(const std::string &name) const=0;
|
||||
// Allows "group:name" in addition to regular node names
|
||||
virtual void getIds(const std::string &name, std::set<content_t> &result)
|
||||
const=0;
|
||||
const=0;
|
||||
// If not found, returns the features of CONTENT_UNKNOWN
|
||||
virtual const ContentFeatures& get(const std::string &name) const=0;
|
||||
virtual const ContentFeatures &get(const std::string &name) const=0;
|
||||
|
||||
// Register node definition by name (allocate an id)
|
||||
// If returns CONTENT_IGNORE, could not allocate id
|
||||
|
@ -348,10 +344,10 @@ public:
|
|||
Update tile textures to latest return values of TextueSource.
|
||||
*/
|
||||
virtual void updateTextures(IGameDef *gamedef,
|
||||
/*argument: */void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress),
|
||||
/*argument: */void *progress_callback_args)=0;
|
||||
void (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress),
|
||||
void *progress_cbk_args)=0;
|
||||
|
||||
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
|
||||
virtual void serialize(std::ostream &os, u16 protocol_version) const=0;
|
||||
virtual void deSerialize(std::istream &is)=0;
|
||||
|
||||
virtual bool getNodeRegistrationStatus() const=0;
|
||||
|
@ -360,6 +356,7 @@ public:
|
|||
virtual void pendNodeResolve(NodeResolver *nr, NodeResolveMethod how)=0;
|
||||
virtual bool cancelNodeResolveCallback(NodeResolver *nr)=0;
|
||||
virtual void runNodeResolveCallbacks()=0;
|
||||
virtual void resetNodeResolveState()=0;
|
||||
};
|
||||
|
||||
IWritableNodeDefManager *createNodeDefManager();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue