DMFlagsSection Class Reference

A group of DMFlag objects that can be safely OR'ed together to form a meaningful value. More...

#include <serverstructs.h>

Public Member Functions

 DMFlagsSection (const QString &internalName)
 Creates DMFlags section with same user-displayable and internal names.
 
 DMFlagsSection (const QString &internalName, const QString &name)
 Creates DMFlags section with different user-displayable and internal names.
 
 DMFlagsSection (const DMFlagsSection &other)
 
void add (const DMFlag &flag)
 Append a new DMFlag to this section.
 
unsigned combineValues () const
 Logical OR of all DMFlag::value() results in this collection.
 
DMFlagsSection copyEmpty () const
 Copies section maintaining its properties but removing all flags.
 
int count () const
 Number of DMFlag objects inside the collection.
 
const QString & internalName () const
 
bool isEmpty () const
 Does this section contain any dmflag?
 
const QString & name () const
 User-displayable name of this section, ex. "Compatibility flags".
 
DMFlagsSectionoperator<< (const DMFlag &flag)
 Stream input operator that appends DMFlag to the collection, same as add().
 
DMFlagsSectionoperator= (const DMFlagsSection &other)
 
const DMFlagoperator[] (int index) const
 Access DMFlag at specific index with '[]' operator.
 
DMFlagoperator[] (int index)
 
DMFlagsSection removed (const DMFlagsSection &removals) const
 Returns a copy of this list with specified DMFlags removed.
 

Static Public Member Functions

static QList< DMFlagsSectionremovedBySection (const QList< DMFlagsSection > &original, const QList< DMFlagsSection > &removals)
 Matches sections by internalName() and calls removed() on them.
 

Detailed Description

A group of DMFlag objects that can be safely OR'ed together to form a meaningful value.

This object is safe to copy. If you need to clone the section but omit the DMFlag definitions stored within it, use copyEmpty() method instead.

DMFlagsSection uses two names - name() for human-readable purposes and internalName() for identification within the system. name() should normally be wrapped in a QObject::tr() call. It's also allowed to only specify the 'internal' name and the human-readable name will be the same. The 'internal' name is expected to stay the same between versions of Doomseeker as it will be used in configuration files that should be usable for extended period of time (years) without being resaved. The human-readable name can be changed at whim.

Each section in a plugin should have an unique internalName().

The 'internal' name should be as friendly to any underlying Operating System as possible. Using only lower-case letters and digits is enforced. If plugin specifies invalid characters in the 'internal' name, the proper format will be coerced; all invalid characters will be removed and all letters lowercased. The human-readable name(), when not specified explicitly, will use the specified 'internal' name, but will have all original characters intact. What's forbidden is wrapping the 'internal' name in a QObject::tr() call. Unfortunately, Doomseeker has no means to detect whether string is translated or not, so the responsibility to ensure that it isn't falls on the author of the plugin. It is very important to pay attention to this as the plugin may appear to work correctly at first but break in certain cases only, for example when user saves game configurations while using one language translation and tries to load them when using another.

Some call examples:

DMFlagsSection dmflags("dmflags");
DMFlagsSection compatFlags("compatflags", tr("Compat. Flags"));

Definition at line 142 of file serverstructs.h.

Constructor & Destructor Documentation

DMFlagsSection::DMFlagsSection ( const QString &  internalName)

Creates DMFlags section with same user-displayable and internal names.

Warning
Don't tr() this name!

Definition at line 128 of file serverstructs.cpp.

DMFlagsSection::DMFlagsSection ( const QString &  internalName,
const QString &  name 
)

Creates DMFlags section with different user-displayable and internal names.

Warning
Don't tr() the internalName!

Definition at line 134 of file serverstructs.cpp.

Member Function Documentation

void DMFlagsSection::add ( const DMFlag flag)

Append a new DMFlag to this section.

Note that conflicting DMFlags will still be accepted here, as no check are performed. Objects added here affect results of combineValues().

Definition at line 156 of file serverstructs.cpp.

unsigned DMFlagsSection::combineValues ( ) const

Logical OR of all DMFlag::value() results in this collection.

Invalid DMFlag objects, if present in the collection, do not affect the output of this operation.

Definition at line 161 of file serverstructs.cpp.

DMFlagsSection DMFlagsSection::copyEmpty ( ) const

Copies section maintaining its properties but removing all flags.

Definition at line 171 of file serverstructs.cpp.

int DMFlagsSection::count ( ) const

Number of DMFlag objects inside the collection.

Definition at line 178 of file serverstructs.cpp.

const QString & DMFlagsSection::internalName ( ) const
Parameters
Nameused for internal identification purposes.

This name must be unique within given plugin.

Definition at line 183 of file serverstructs.cpp.

bool DMFlagsSection::isEmpty ( ) const

Does this section contain any dmflag?

Definition at line 188 of file serverstructs.cpp.

const QString & DMFlagsSection::name ( ) const

User-displayable name of this section, ex. "Compatibility flags".

Definition at line 193 of file serverstructs.cpp.

DMFlagsSection& DMFlagsSection::operator<< ( const DMFlag flag)
inline

Stream input operator that appends DMFlag to the collection, same as add().

Definition at line 231 of file serverstructs.h.

const DMFlag & DMFlagsSection::operator[] ( int  index) const

Access DMFlag at specific index with '[]' operator.

Definition at line 198 of file serverstructs.cpp.

DMFlagsSection DMFlagsSection::removed ( const DMFlagsSection removals) const

Returns a copy of this list with specified DMFlags removed.

Removal is determined basing on DMFlag::value() comparison.

Parameters
removalsList of DMFlags to remove.

Definition at line 233 of file serverstructs.cpp.

QList< DMFlagsSection > DMFlagsSection::removedBySection ( const QList< DMFlagsSection > &  original,
const QList< DMFlagsSection > &  removals 
)
static

Matches sections by internalName() and calls removed() on them.

Sections that are emptied are also returned as empty sections.

Definition at line 208 of file serverstructs.cpp.


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