# Coriolis Core (CRL) Documentation

Banner.h
1 // -*- C++ -*-
2 //
3 // This file is part of the Coriolis Software.
4 // Copyright (c) UPMC 2008-2018, All Rights Reserved
5 //
6 // +-----------------------------------------------------------------+
7 // | C O R I O L I S |
8 // | Alliance / Hurricane Interface |
9 // | |
10 // | Author : Jean-Paul CHAPUT |
11 // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./crlcore/Banner.h" |
14 // +-----------------------------------------------------------------+
15
16
17 #ifndef CRL_BANNER_H
18 #define CRL_BANNER_H
19
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include <ostream>
24 #include <sstream>
25
26 #ifdef __CCORE_INTERNAL__
27 # include "hurricane/CConfig.h"
28 #endif
29 #include "crlcore/Utilities.h"
30
31
32 namespace CRL {
33
34 using std::string;
35 using std::map;
36 using std::vector;
37 using std::ostream;
38 using std::ostringstream;
39
40
41 // -------------------------------------------------------------------
42 // Class : "CRL::BannerFont".
43
44
45 class BannerFont {
46
47 public:
48 // BigChar subclass.
49 class BigChar {
50 public:
51 // Constructor & Destructor.
52 BigChar ( char c, int height, const char* lines[], const BannerFont* font );
53 ~BigChar ();
54 // Methods.
55 inline int getHeight () const;
56 inline const BannerFont* getFont () const;
57 string _getPrint () const;
58 const char* operator[] ( int line ) const;
59
60 private:
61 // Internal: Attributes.
62 char _character;
63 int _height;
64 const char** _lines;
65 const BannerFont* _font;
66
67 // Internal: Constructors.
68 BigChar& operator= ( const BigChar& );
69 BigChar ( const BigChar& );
70 };
71
72 // Static Methods.
73 static const BannerFont* getBannerFont ( const string& name );
74 // Constructor & Destructor.
75 inline BannerFont ( const string& name );
76 // Methods.
77 inline void addChar ( char character, int height, const char *lines[] );
78 inline int getHeight () const;
79 inline const BigChar& operator[] ( char character ) const;
80
81 private:
82 // Internal: FontMap subclass.
83 class FontMap : public map<const string,const BannerFont*> {
84 public:
85 FontMap ();
86 ~FontMap ();
87 const BannerFont* operator[] ( const string& name ) const;
88 };
89
90 // Internal: Types.
91 typedef map<char,BigChar*> CharMap;
92
93 // Internal: Static Attributes.
94 static FontMap _fontMap;
95 // Internal: Attributes.
96 CharMap _table;
97 string _name;
98 int _height;
99
100 // Internal: Constructors.
101 BannerFont ( const BannerFont& );
102 ~BannerFont ();
103 inline BannerFont& operator= ( const BannerFont& );
104
105 };
106
107
108
109
110 // -------------------------------------------------------------------
111 // Class : "CRL::Banner".
112
113
114 class Banner {
115 public:
116 // Constructor & Destructor.
117 Banner ( string name=""
118 , string version=""
119 , string purpose=""
120 , string date=""
121 , string authors=""
122 , string contributors="" );
123 virtual ~Banner ();
124 // Accessors.
125 inline const BannerFont* getFont () const;
126 inline const string& getName () const;
127 inline const string& getVersion () const;
128 inline const string& getPurpose () const;
129 inline const string& getDate () const;
130 inline const string& getAuthors () const;
131 inline const string& getContributors () const;
132 inline unsigned int getScreenWidth () const;
133 // Modifiers.
134 void setFont ( BannerFont* font );
135 void setName ( string name );
136 void setVersion ( string version );
137 void setPurpose ( string purpose );
138 void setDate ( string date );
139 void setAuthors ( string authors );
140 void setContributors ( string contributors );
141 void setScreenWidth ( unsigned screenWidth );
142 // Hurricane Management.
143 virtual const string _getPrint () const { return ( _banner.str() ); };
144
145 // Internal: Attributes.
146 private:
147 string _name;
148 string _version;
149 string _purpose;
150 string _date;
151 string _authors;
152 string _contributors;
153 unsigned int _screenWidth;
154 size_t _cartoucheWidth;
155 const BannerFont* _font;
156 string* _lines;
157 ostringstream _banner;
158
159 // Internal: Constructors.
160 Banner ( const Banner & );
161 Banner& operator= ( const Banner & );
162 // Internal: Methods.
163 void _redraw ();
164 };
165
166
167 // Inline Functions.
168 inline int BannerFont::BigChar::getHeight () const { return _height; }
169 inline const BannerFont* BannerFont::BigChar::getFont () const { return _font; }
170 inline BannerFont::BannerFont ( const string& name ): _table(), _name(name) {}
171 inline int BannerFont::getHeight () const { return _height; }
172 inline const BannerFont* Banner::getFont () const { return _font; }
173 inline const string& Banner::getName () const { return _name; }
174 inline const string& Banner::getVersion () const { return _version; }
175 inline const string& Banner::getPurpose () const { return _purpose; }
176 inline const string& Banner::getDate () const { return _date; }
177 inline const string& Banner::getAuthors () const { return _authors; }
178 inline const string& Banner::getContributors () const { return _contributors; }
179 inline unsigned int Banner::getScreenWidth () const { return _screenWidth; }
180
181
182 } // CRL namespace.
183
184
185 // Hurricane Management.
186
187 inline std::string getPrint ( const CRL::BannerFont::BigChar& c ) { return c._getPrint(); }
188 inline std::string getPrint ( const CRL::Banner& b ) { return b._getPrint(); }
189 inline std::ostream& operator<< ( std::ostream& o, const CRL::BannerFont::BigChar& c ) { return o << getPrint(c); }
190 inline std::ostream& operator<< ( std::ostream& o, const CRL::Banner& b ) { return o << getPrint(b); }
191
192 MSTREAM_R_SUPPORT(CRL::Banner);
193
194
195 #endif // CRL_BANNER_H
CRL::Banner::getScreenWidth
unsigned int getScreenWidth() const
Definition: Banner.h:179
CRL::Banner::setScreenWidth
void setScreenWidth(unsigned screenWidth)
CRL::Banner::getDate
const string & getDate() const
Definition: Banner.h:176
CRL::Banner::setVersion
void setVersion(string version)
CRL::Banner::setAuthors
void setAuthors(string authors)
CRL::Banner::setDate
void setDate(string date)
CRL::Banner::getPurpose
const string & getPurpose() const
Definition: Banner.h:175
CRL::Banner::Banner
Banner(string name="", string version="", string purpose="", string date="", string authors="", string contributors="")
CRL::Banner::setContributors
void setContributors(string contributors)
CRL::Banner::setName
void setName(string name)
CRL::Banner::getVersion
const string & getVersion() const
Definition: Banner.h:174
CRL::Banner::getContributors
const string & getContributors() const
Definition: Banner.h:178
CRL::Banner::getAuthors
const string & getAuthors() const
Definition: Banner.h:177
CRL::Banner
Print Formatted Banners (on ttys).
Definition: Banner.h:114
CRL::Banner::getName
const string & getName() const
Definition: Banner.h:173
CRL
The namespace of Coriolis Core.
Definition: Environment.h:26
CRL::Banner::setPurpose
void setPurpose(string purpose)

Generated by doxygen 1.8.14 on Mon Apr 27 2020 | Return to top of page

Coriolis Core (CRL) | Copyright © 2008-2016 UPMC All rights reserved