2012-11-24 10:01:53 +00:00
|
|
|
#ifndef CSM_WOLRD_UNIVERSALID_H
|
|
|
|
#define CSM_WOLRD_UNIVERSALID_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <iosfwd>
|
2013-07-29 14:21:42 +00:00
|
|
|
#include <vector>
|
2012-11-24 10:01:53 +00:00
|
|
|
|
2012-12-12 21:36:20 +00:00
|
|
|
#include <QMetaType>
|
|
|
|
|
2012-11-24 10:01:53 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class UniversalId
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum Class
|
|
|
|
{
|
2013-07-29 14:21:42 +00:00
|
|
|
Class_None = 0,
|
|
|
|
Class_Record,
|
|
|
|
Class_RefRecord, // referenceable record
|
|
|
|
Class_SubRecord,
|
|
|
|
Class_RecordList,
|
|
|
|
Class_Collection, // multiple types of records combined
|
|
|
|
Class_Transient, // not part of the world data or the project data
|
|
|
|
Class_NonRecord // record like data that is not part of the world
|
2012-11-24 10:01:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ArgumentType
|
|
|
|
{
|
|
|
|
ArgumentType_None,
|
|
|
|
ArgumentType_Id,
|
|
|
|
ArgumentType_Index
|
|
|
|
};
|
|
|
|
|
2014-06-06 12:25:06 +00:00
|
|
|
/// \note A record list type must always be immediately followed by the matching
|
|
|
|
/// record type, if this type is of class SubRecord or Record.
|
2012-11-24 10:01:53 +00:00
|
|
|
enum Type
|
|
|
|
{
|
2013-09-05 11:58:36 +00:00
|
|
|
Type_None = 0,
|
2012-12-11 14:35:47 +00:00
|
|
|
Type_Globals,
|
2012-12-13 12:35:08 +00:00
|
|
|
Type_Global,
|
2013-02-08 08:58:19 +00:00
|
|
|
Type_VerificationResults,
|
|
|
|
Type_Gmsts,
|
2013-03-21 12:40:55 +00:00
|
|
|
Type_Gmst,
|
|
|
|
Type_Skills,
|
2013-03-25 12:22:06 +00:00
|
|
|
Type_Skill,
|
|
|
|
Type_Classes,
|
2013-04-02 10:00:45 +00:00
|
|
|
Type_Class,
|
|
|
|
Type_Factions,
|
2013-04-04 12:34:39 +00:00
|
|
|
Type_Faction,
|
|
|
|
Type_Races,
|
2013-04-06 19:21:10 +00:00
|
|
|
Type_Race,
|
|
|
|
Type_Sounds,
|
2013-04-07 13:17:35 +00:00
|
|
|
Type_Sound,
|
|
|
|
Type_Scripts,
|
2013-04-07 14:32:06 +00:00
|
|
|
Type_Script,
|
|
|
|
Type_Regions,
|
2013-04-07 18:26:39 +00:00
|
|
|
Type_Region,
|
|
|
|
Type_Birthsigns,
|
2013-04-09 09:40:36 +00:00
|
|
|
Type_Birthsign,
|
|
|
|
Type_Spells,
|
2013-04-14 15:04:55 +00:00
|
|
|
Type_Spell,
|
|
|
|
Type_Cells,
|
2013-04-23 09:21:21 +00:00
|
|
|
Type_Cell,
|
2014-04-29 13:46:36 +00:00
|
|
|
Type_Cell_Missing, //For cells that does not exist yet.
|
2013-04-23 09:21:21 +00:00
|
|
|
Type_Referenceables,
|
|
|
|
Type_Referenceable,
|
|
|
|
Type_Activator,
|
|
|
|
Type_Potion,
|
|
|
|
Type_Apparatus,
|
|
|
|
Type_Armor,
|
|
|
|
Type_Book,
|
|
|
|
Type_Clothing,
|
|
|
|
Type_Container,
|
|
|
|
Type_Creature,
|
|
|
|
Type_Door,
|
|
|
|
Type_Ingredient,
|
|
|
|
Type_CreatureLevelledList,
|
|
|
|
Type_ItemLevelledList,
|
|
|
|
Type_Light,
|
|
|
|
Type_Lockpick,
|
|
|
|
Type_Miscellaneous,
|
|
|
|
Type_Npc,
|
|
|
|
Type_Probe,
|
|
|
|
Type_Repair,
|
|
|
|
Type_Static,
|
2013-07-06 15:03:18 +00:00
|
|
|
Type_Weapon,
|
|
|
|
Type_References,
|
2013-07-08 11:12:50 +00:00
|
|
|
Type_Reference,
|
2013-07-22 19:18:47 +00:00
|
|
|
Type_RegionMap,
|
2013-09-28 07:25:54 +00:00
|
|
|
Type_Filters,
|
2014-06-06 12:25:06 +00:00
|
|
|
Type_Filter,
|
2013-10-20 15:13:31 +00:00
|
|
|
Type_Topics,
|
|
|
|
Type_Topic,
|
|
|
|
Type_Journals,
|
|
|
|
Type_Journal,
|
2013-10-29 12:18:22 +00:00
|
|
|
Type_TopicInfos,
|
|
|
|
Type_TopicInfo,
|
|
|
|
Type_JournalInfos,
|
|
|
|
Type_JournalInfo,
|
2014-03-10 11:44:34 +00:00
|
|
|
Type_Scene,
|
2014-05-10 10:04:36 +00:00
|
|
|
Type_Preview,
|
|
|
|
Type_LoadErrorLog
|
2012-11-24 10:01:53 +00:00
|
|
|
};
|
|
|
|
|
2014-05-10 10:04:36 +00:00
|
|
|
enum { NumberOfTypes = Type_LoadErrorLog+1 };
|
2013-09-05 11:58:36 +00:00
|
|
|
|
2012-11-24 10:01:53 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
Class mClass;
|
|
|
|
ArgumentType mArgumentType;
|
|
|
|
Type mType;
|
|
|
|
std::string mId;
|
|
|
|
int mIndex;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-12-08 22:27:59 +00:00
|
|
|
UniversalId (const std::string& universalId);
|
|
|
|
|
2012-11-24 10:01:53 +00:00
|
|
|
UniversalId (Type type = Type_None);
|
|
|
|
|
|
|
|
UniversalId (Type type, const std::string& id);
|
|
|
|
///< Using a type for a non-ID-argument UniversalId will throw an exception.
|
|
|
|
|
|
|
|
UniversalId (Type type, int index);
|
|
|
|
///< Using a type for a non-index-argument UniversalId will throw an exception.
|
|
|
|
|
|
|
|
Class getClass() const;
|
|
|
|
|
|
|
|
ArgumentType getArgumentType() const;
|
|
|
|
|
|
|
|
Type getType() const;
|
|
|
|
|
|
|
|
const std::string& getId() const;
|
|
|
|
///< Calling this function for a non-ID type will throw an exception.
|
|
|
|
|
|
|
|
int getIndex() const;
|
|
|
|
///< Calling this function for a non-index type will throw an exception.
|
|
|
|
|
|
|
|
bool isEqual (const UniversalId& universalId) const;
|
|
|
|
|
2012-11-26 11:29:22 +00:00
|
|
|
bool isLess (const UniversalId& universalId) const;
|
|
|
|
|
2012-11-24 10:01:53 +00:00
|
|
|
std::string getTypeName() const;
|
|
|
|
|
|
|
|
std::string toString() const;
|
2013-06-30 12:43:58 +00:00
|
|
|
|
2013-07-29 14:21:42 +00:00
|
|
|
std::string getIcon() const;
|
|
|
|
///< Will return an empty string, if no icon is available.
|
|
|
|
|
|
|
|
static std::vector<Type> listReferenceableTypes();
|
2014-06-06 12:25:06 +00:00
|
|
|
|
|
|
|
/// If \a type is a SubRecord, RefRecord or Record type return the type of the table
|
|
|
|
/// that contains records of type \a type.
|
|
|
|
/// Otherwise return Type_None.
|
|
|
|
static Type getParentType (Type type);
|
2012-11-24 10:01:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool operator== (const UniversalId& left, const UniversalId& right);
|
|
|
|
bool operator!= (const UniversalId& left, const UniversalId& right);
|
|
|
|
|
2012-11-26 11:29:22 +00:00
|
|
|
bool operator< (const UniversalId& left, const UniversalId& right);
|
|
|
|
|
2012-11-24 10:01:53 +00:00
|
|
|
std::ostream& operator< (std::ostream& stream, const UniversalId& universalId);
|
|
|
|
}
|
|
|
|
|
2012-12-12 21:36:20 +00:00
|
|
|
Q_DECLARE_METATYPE (CSMWorld::UniversalId)
|
|
|
|
|
2012-11-24 10:01:53 +00:00
|
|
|
#endif
|