1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // http://redmine.teslayout.com/projects/anna-suite
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of the copyright holder nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_core_util_TextManager_hpp
38 #define anna_core_util_TextManager_hpp
42 #include <anna/core/functions.hpp>
43 #include <anna/core/mt/Mutex.hpp>
50 Gestor de textos con formato.
52 class TextManager : public Mutex {
57 TextManager(const char* name);
62 virtual ~TextManager() { clear(); }
65 Operador de acceso. El compositor solicitado deberia estar creado mediate #create.
66 \param composer Indica el numero de compositor al que deseamos acceder.
67 \return El compositor de textos.
69 TextComposer& operator [](const int composer) throw(RuntimeException) { return find(composer); }
72 Operador de acceso. El compositor solicitado deberia estar creado mediate #create.
73 \param composer Indica el numero de compositor al que deseamos acceder.
74 \return El compositor de textos.
76 const TextComposer& operator [](const int composer) const throw(RuntimeException) { return find(composer); }
79 Crea un nuevo compositor de textos.
80 \param composer Índice del compositor.
81 \param expression Expresion asociada al compositor que vamos a crear. El numero de variables que hay que
82 establecer antes de invocar a TextComposer::apply dependera de este texto.
84 void create(const int composer, const char* expression) throw(RuntimeException);
87 Devuelve el compositor de textos asociado al numero recibido como parametro.
88 El compositor solicitado deberia estar creado mediate #create.
89 \param composer Indica el numero de compositor al que deseamos acceder.
90 \return El compositor de textos.
92 TextComposer& find(const int composer) throw(RuntimeException);
95 Devuelve el compositor de textos asociado al numero recibido como parametro.
96 El compositor solicitado deberia estar creado mediate #create.
97 \param composer Indica el numero de compositor al que deseamos acceder.
98 \return El compositor de textos.
100 const TextComposer& find(const int composer) const throw(RuntimeException);
103 Elimina todos los compositores de texto creados hasta el momento.
105 void clear() throw();
108 Metodo que podemos reescribir para crear cualquier clase heredada de TextComposer.
109 Por defecto la impletacion sera:
111 return new util::TextComposer (composer, expression);
113 \warning La reimplementacion de este metodo nunca deberia devolver NULL.
115 virtual TextComposer* createTextComposer(const int composer, const char* expression) throw();
118 typedef std::vector <TextComposer*> TextComposerVector;
121 TextComposerVector a_composers;
123 TextManager(const TextManager&);
125 TextComposer* xfind(const int composer) throw();