Limo
A simple mod manager
Loading...
Searching...
No Matches
AutoTag Class Reference

Tag which is automatically added to a mod when its files fulfill the tags conditions. Conditions are managed by a TagConditionNode object. More...

#include <autotag.h>

Inheritance diagram for AutoTag:
Collaboration diagram for AutoTag:

Public Member Functions

 AutoTag (const std::string &name, const std::string &expression, const std::vector< TagCondition > &conditions)
 Constructor.
 
 AutoTag (const Json::Value &json)
 Deserializes an AutoTag from the given json object.
 
template<typename View>
void reapplyMods (const std::map< int, std::vector< std::pair< std::string, std::string > > > &files, const View &mods, std::optional< ProgressNode * > progress_node={})
 Removes this tag from all mods, then applies it to all given mods which fulfill its conditions.
 
template<typename View>
void reapplyMods (const std::filesystem::path &staging_dir, const View &mods, std::optional< ProgressNode * > progress_node={})
 Removes this tag from all mods, then applies it to all given mods which fulfill its conditions.
 
template<typename View>
void updateMods (const std::map< int, std::vector< std::pair< std::string, std::string > > > &files, const View &mods, std::optional< ProgressNode * > progress_node={})
 Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed.
 
template<typename View>
void updateMods (const std::filesystem::path &staging_dir, const View &mods, std::optional< ProgressNode * > progress_node={})
 Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed.
 
void setEvaluator (const std::string &expression, const std::vector< TagCondition > &conditions)
 Changes the conditions and expression used by this tag.
 
Json::Value toJson () const
 Serializes this tag to a json object.
 
bool operator== (const std::string &name) const
 Compares this tag by name to the given name.
 
std::string getExpression () const
 Getter for this tags expression.
 
std::vector< TagConditiongetConditions () const
 Getter for this tags conditions.
 
int getNumConditions () const
 Returns the number of conditions for this tag.
 
- Public Member Functions inherited from Tag
std::string getName () const
 Getter for the tags name.
 
void setName (const std::string &name)
 Setter for the tags name.
 
std::vector< int > getMods () const
 Returns all mods to which this tag has been added.
 
int getNumMods () const
 Returns the number of mods to which this tag has been added.
 
bool hasMod (int mod_id) const
 Checks if this tag has been added to the given mod.
 

Static Public Member Functions

template<typename View>
static std::map< int, std::vector< std::pair< std::string, std::string > > > readModFiles (const std::filesystem::path &staging_dir, View mods, std::optional< ProgressNode * > progress_node={})
 Recursively iterates over all files for all mods with given ids and creates a a map of mod ids to a vector containing pairs of path and file name. This vector is used as input for the reapplyMods and updateMods functions.
 

Private Attributes

std::string expression_
 Expression used by the TagConditionNode.
 
std::vector< TagConditionconditions_
 Conditions used by the TagConditionNode.
 
TagConditionNode evaluator_
 This tag is applied to a mod if this nodes evaluate function returns true for the mods installation directory.
 

Additional Inherited Members

- Protected Attributes inherited from Tag
std::string name_
 Name of this tag.
 
std::vector< int > mods_ {}
 Contains ids of all mods to which this tag has been added.
 

Detailed Description

Tag which is automatically added to a mod when its files fulfill the tags conditions. Conditions are managed by a TagConditionNode object.

Constructor & Destructor Documentation

◆ AutoTag() [1/2]

AutoTag::AutoTag ( const std::string & name,
const std::string & expression,
const std::vector< TagCondition > & conditions )

Constructor.

Parameters
nameName of the new tag.
expressionBoolean expression used to combine the given conditions. The tag is applied to a mod when this evaluates to true.
conditionsVector of conditions used to decide if this tag is to be applied. These act as variables in the tags expression.

◆ AutoTag() [2/2]

AutoTag::AutoTag ( const Json::Value & json)

Deserializes an AutoTag from the given json object.

Parameters
jsonSource json object.
Exceptions
ParseErrorwhen the json object is invalid.

Member Function Documentation

◆ getConditions()

std::vector< TagCondition > AutoTag::getConditions ( ) const

Getter for this tags conditions.

Returns
The conditions.

◆ getExpression()

std::string AutoTag::getExpression ( ) const

Getter for this tags expression.

Returns
The expression.

◆ getNumConditions()

int AutoTag::getNumConditions ( ) const

Returns the number of conditions for this tag.

Returns
The number of conditions.

◆ operator==()

bool AutoTag::operator== ( const std::string & name) const

Compares this tag by name to the given name.

Parameters
nameName to compare to.
Returns
True if the names are identical.

◆ readModFiles()

template<typename View>
static std::map< int, std::vector< std::pair< std::string, std::string > > > AutoTag::readModFiles ( const std::filesystem::path & staging_dir,
View mods,
std::optional< ProgressNode * > progress_node = {} )
inlinestatic

Recursively iterates over all files for all mods with given ids and creates a a map of mod ids to a vector containing pairs of path and file name. This vector is used as input for the reapplyMods and updateMods functions.

Parameters
staging_dirStaging directory for the given mods.
modsIterable container containing int ids of all mods to be checked.
progress_nodeUsed to inform about progress.
Returns
The map.

◆ reapplyMods() [1/2]

template<typename View>
void AutoTag::reapplyMods ( const std::filesystem::path & staging_dir,
const View & mods,
std::optional< ProgressNode * > progress_node = {} )
inline

Removes this tag from all mods, then applies it to all given mods which fulfill its conditions.

Parameters
staging_dirDirectory containing the mods.
modsIterable container containing int ids of all mods to be checked.
progress_nodeUsed to inform about progress.

◆ reapplyMods() [2/2]

template<typename View>
void AutoTag::reapplyMods ( const std::map< int, std::vector< std::pair< std::string, std::string > > > & files,
const View & mods,
std::optional< ProgressNode * > progress_node = {} )
inline

Removes this tag from all mods, then applies it to all given mods which fulfill its conditions.

Parameters
filesMaps mod ids to a vector of pairs of paths and file names for that mod.
modsIterable container containing int ids of all mods to be checked.
progress_nodeUsed to inform about progress.

◆ setEvaluator()

void AutoTag::setEvaluator ( const std::string & expression,
const std::vector< TagCondition > & conditions )

Changes the conditions and expression used by this tag.

Parameters
expressionThe new expression.
conditionsThe new conditions.

◆ toJson()

Json::Value AutoTag::toJson ( ) const
virtual

Serializes this tag to a json object.

Returns
The json object.

Implements Tag.

◆ updateMods() [1/2]

template<typename View>
void AutoTag::updateMods ( const std::filesystem::path & staging_dir,
const View & mods,
std::optional< ProgressNode * > progress_node = {} )
inline

Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed.

Parameters
staging_dirDirectory containing the mods.
modsIterable container containing int ids of all mods to be checked.
progress_nodeUsed to inform about progress.

◆ updateMods() [2/2]

template<typename View>
void AutoTag::updateMods ( const std::map< int, std::vector< std::pair< std::string, std::string > > > & files,
const View & mods,
std::optional< ProgressNode * > progress_node = {} )
inline

Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed.

Parameters
filesMaps mod ids to a vector of pairs of paths and file names for that mod.
modsIterable container containing int ids of all mods to be checked.
progress_nodeUsed to inform about progress.

The documentation for this class was generated from the following files: