1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #include <anna/core/tracing/TraceMethod.hpp>
10 #include <anna/core/tracing/Logger.hpp>
11 #include <anna/core/mt/Guard.hpp>
13 #include <anna/core/util/TextManager.hpp>
14 #include <anna/core/util/TextComposer.hpp>
20 TextManager::TextManager(const char* name) :
24 void TextManager::clear()
26 Guard guard(*this, "TextManager::clear");
28 for(TextComposerVector::iterator ii = a_composers.begin(), maxii = a_composers.end(); ii != maxii; ii ++)
34 void TextManager::create(const int composer, const char* expression)
36 TextComposer* result = NULL;
37 Guard guard(*this, "TextManager::create");
39 if((result = xfind(composer)) != NULL) {
41 msg += functions::asString(composer);
42 msg += " | Id already used in ";
43 msg += result->asString();
44 throw RuntimeException(msg, ANNA_FILE_LOCATION);
48 if((result = createTextComposer(composer, expression)) == NULL) {
50 msg += "::createTextComposer must not return NULL";
51 throw RuntimeException(msg, ANNA_FILE_LOCATION);
55 string msg("Compositor created | ");
56 msg += result->asString();
57 Logger::write(Logger::Debug, msg, ANNA_FILE_LOCATION);
60 a_composers.push_back(result);
61 } catch(RuntimeException&) {
67 TextComposer& TextManager::find(const int composer)
70 Guard guard(*this, "TextManager::find");
72 if((result = xfind(composer)) == NULL) {
74 msg += functions::asString(composer);
75 msg += " | Was not created";
76 throw RuntimeException(msg, ANNA_FILE_LOCATION);
82 const TextComposer& TextManager::find(const int composer) const
84 const TextComposer& result = const_cast <TextManager*>(this)->find(composer);
88 TextComposer* TextManager::createTextComposer(const int composer, const char* expression)
90 return new TextComposer(composer, expression);
93 TextComposer* TextManager::xfind(const int composer)
95 for(TextComposerVector::iterator ii = a_composers.begin(), maxii = a_composers.end(); ii != maxii; ii ++)
96 if((*ii)->getId() == composer) {