Skip to content

Commit

Permalink
Log|libcore|libgui: Set names for individual bank classes
Browse files Browse the repository at this point in the history
The log entries are more informative when it is clear that which bank is
doing the loading.
  • Loading branch information
skyjake committed May 16, 2014
1 parent 7adf9d8 commit 6f4f231
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 21 deletions.
5 changes: 4 additions & 1 deletion doomsday/libcore/include/de/data/bank.h
Expand Up @@ -192,10 +192,13 @@ class DENG2_PUBLIC Bank
/**
* Constructs a data bank.
*
* @param bankNameForLog Name to identify the bank in log entries (latin1).
* @param flags Flags that determine the behavior of the bank.
* @param hotStorageLocation Location where the hot storage files are kept.
*/
Bank(Flags const &flags = DefaultFlags, String const &hotStorageLocation = "/home/cache");
Bank(char const *nameForLog = "Bank",
Flags const &flags = DefaultFlags,
String const &hotStorageLocation = "/home/cache");

virtual ~Bank();

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libcore/include/de/data/info.h
Expand Up @@ -298,7 +298,7 @@ class DENG2_PUBLIC Info
/**
* Parses a file containing Info source.
*
* @param source Info source text.
* @param file Info source text.
*/
Info(File const &file);

Expand Down
3 changes: 2 additions & 1 deletion doomsday/libcore/include/de/data/infobank.h
Expand Up @@ -41,7 +41,8 @@ class File;
class DENG2_PUBLIC InfoBank : public Bank
{
public:
InfoBank(Bank::Flags const &flags = Bank::DefaultFlags,
InfoBank(char const *nameForLog = "InfoBank",
Bank::Flags const &flags = Bank::DefaultFlags,
String const &hotStorageLocation = "/home/cache");

void parse(String const &infoSource);
Expand Down
19 changes: 10 additions & 9 deletions doomsday/libcore/src/data/bank.cpp
Expand Up @@ -111,7 +111,6 @@ class Cache : public Lockable

} // namespace internal


DENG2_PIMPL(Bank),
DENG2_OBSERVES(Loop, Iteration) // notifications from other threads sent via main Loop
{
Expand Down Expand Up @@ -525,6 +524,7 @@ DENG2_OBSERVES(Loop, Iteration) // notifications from other threads sent via mai

typedef FIFO<Notification> NotifyQueue;

char const *nameForLog;
Flags flags;
SourceCache sourceCache;
ObjectCache memoryCache;
Expand All @@ -533,10 +533,11 @@ DENG2_OBSERVES(Loop, Iteration) // notifications from other threads sent via mai
TaskPool jobs;
NotifyQueue notifications;

Instance(Public *i, Flags const &flg)
: Base(i),
flags(flg),
serialCache(0)
Instance(Public *i, char const *name, Flags const &flg)
: Base(i)
, nameForLog(name)
, flags(flg)
, serialCache(0)
{
if(!flags.testFlag(DisableHotStorage))
{
Expand Down Expand Up @@ -723,8 +724,8 @@ DENG2_OBSERVES(Loop, Iteration) // notifications from other threads sent via mai
DENG2_AUDIENCE_METHOD(Bank, Load)
DENG2_AUDIENCE_METHOD(Bank, CacheLevel)

Bank::Bank(Flags const &flags, String const &hotStorageLocation)
: d(new Instance(this, flags))
Bank::Bank(char const *nameForLog, Flags const &flags, String const &hotStorageLocation)
: d(new Instance(this, nameForLog, flags))
{
d->setSerialLocation(hotStorageLocation);
}
Expand Down Expand Up @@ -785,7 +786,7 @@ void Bank::clear()

void Bank::add(DotPath const &path, ISource *source)
{
LOG_AS("Bank");
LOG_AS(d->nameForLog);

QScopedPointer<ISource> src(source);
Instance::Data &item = d->items.insert(path);
Expand Down Expand Up @@ -842,7 +843,7 @@ void Bank::loadAll()

Bank::IData &Bank::data(DotPath const &path) const
{
LOG_AS("Bank");
LOG_AS(d->nameForLog);

// First check if the item is already in memory.
Instance::Data &item = d->items.find(path, PathTree::MatchFull | PathTree::NoBranch);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libcore/src/data/infobank.cpp
Expand Up @@ -30,8 +30,8 @@ DENG2_PIMPL_NOREF(InfoBank)
String relativeToPath;
};

InfoBank::InfoBank(Bank::Flags const &flags, String const &hotStorageLocation)
: Bank(flags, hotStorageLocation), d(new Instance)
InfoBank::InfoBank(char const *nameForLog, Bank::Flags const &flags, String const &hotStorageLocation)
: Bank(nameForLog, flags, hotStorageLocation), d(new Instance)
{}

void InfoBank::parse(String const &source)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libcore/src/widgets/rulebank.cpp
Expand Up @@ -60,7 +60,7 @@ DENG2_PIMPL(RuleBank)
}
};

RuleBank::RuleBank() : InfoBank(DisableHotStorage), d(new Instance(this))
RuleBank::RuleBank() : InfoBank("RuleBank", DisableHotStorage), d(new Instance(this))
{}

void RuleBank::addFromInfo(File const &file)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/src/audio/waveformbank.cpp
Expand Up @@ -58,7 +58,7 @@ DENG2_PIMPL_NOREF(WaveformBank)
};
};

WaveformBank::WaveformBank(Flags const &flags) : InfoBank(flags), d(new Instance)
WaveformBank::WaveformBank(Flags const &flags) : InfoBank("WaveformBank", flags), d(new Instance)
{}

void WaveformBank::add(DotPath const &id, String const &waveformFilePath)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/src/graphics/colorbank.cpp
Expand Up @@ -69,7 +69,7 @@ DENG2_PIMPL(ColorBank)
{}
};

ColorBank::ColorBank() : InfoBank(DisableHotStorage), d(new Instance(this))
ColorBank::ColorBank() : InfoBank("ColorBank", DisableHotStorage), d(new Instance(this))
{}

void ColorBank::addFromInfo(File const &file)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/src/graphics/glshaderbank.cpp
Expand Up @@ -157,7 +157,7 @@ DENG2_PIMPL(GLShaderBank)
}
};

GLShaderBank::GLShaderBank() : d(new Instance(this))
GLShaderBank::GLShaderBank() : InfoBank("GLShaderBank"), d(new Instance(this))
{}

void GLShaderBank::addFromInfo(File const &file)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/src/graphics/imagebank.cpp
Expand Up @@ -63,7 +63,7 @@ DENG2_PIMPL_NOREF(ImageBank)
};
};

ImageBank::ImageBank(Flags const &flags) : InfoBank(flags), d(new Instance)
ImageBank::ImageBank(Flags const &flags) : InfoBank("ImageBank", flags), d(new Instance)
{}

void ImageBank::add(DotPath const &path, String const &imageFilePath)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/src/graphics/texturebank.cpp
Expand Up @@ -60,7 +60,7 @@ DENG2_PIMPL_NOREF(TextureBank)
Instance() : atlas(0) {}
};

TextureBank::TextureBank() : d(new Instance)
TextureBank::TextureBank() : Bank("TextureBank"), d(new Instance)
{}

void TextureBank::setAtlas(AtlasTexture &atlas)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/src/text/fontbank.cpp
Expand Up @@ -82,7 +82,7 @@ DENG2_PIMPL(FontBank)
{}
};

FontBank::FontBank() : InfoBank(DisableHotStorage), d(new Instance(this))
FontBank::FontBank() : InfoBank("FontBank", DisableHotStorage), d(new Instance(this))
{}

void FontBank::addFromInfo(File const &file)
Expand Down

0 comments on commit 6f4f231

Please sign in to comment.