0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / Message / Message_Messenger.cxx
CommitLineData
b311480e 1// Created on: 2001-01-06
2// Created by: OCC Team
973c2be1 3// Copyright (c) 2001-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <Message_Messenger.ixx>
17#include <Message_PrinterOStream.hxx>
18
19//=======================================================================
20//function : Message_Messenger
21//purpose :
22//=======================================================================
23
24Message_Messenger::Message_Messenger ()
25{
26 AddPrinter ( new Message_PrinterOStream );
27}
28
29//=======================================================================
30//function : Message_Messenger
31//purpose :
32//=======================================================================
33
34Message_Messenger::Message_Messenger (const Handle(Message_Printer)& thePrinter)
35{
36 AddPrinter (thePrinter);
37}
38
39//=======================================================================
40//function : AddPrinter
41//purpose :
42//=======================================================================
43
44Standard_Boolean Message_Messenger::AddPrinter (const Handle(Message_Printer)& thePrinter)
45{
46 // check whether printer is already in the list
47 for (Standard_Integer i=1; i <= myPrinters.Length(); i++)
48 if ( myPrinters(i) == thePrinter )
49 return Standard_False;
50 // add to the list
51 myPrinters.Append (thePrinter);
52 return Standard_True;
53}
54
55//=======================================================================
56//function : RemovePrinter
57//purpose :
58//=======================================================================
59
60Standard_Boolean Message_Messenger::RemovePrinter (const Handle(Message_Printer)& thePrinter)
61{
62 // find printer in the list
63 for (Standard_Integer i=1; i <= myPrinters.Length(); i++)
64 if ( myPrinters(i) == thePrinter )
65 {
66 myPrinters.Remove (i);
67 return Standard_True;
68 }
69 return Standard_False;
70}
71
72//=======================================================================
73//function : RemovePrinters
74//purpose :
75//=======================================================================
76
77Standard_Integer Message_Messenger::RemovePrinters (const Handle(Standard_Type)& theType)
78{
79 // remove printers from the list
80 Standard_Integer nb = 0;
81 for (Standard_Integer i=1; i <= myPrinters.Length(); i++)
82 if ( myPrinters(i)->IsKind(theType) )
83 {
84 myPrinters.Remove (i--);
85 nb++;
86 }
87 return nb;
88}
89
90//=======================================================================
91//function : Send
92//purpose :
93//=======================================================================
94
95void Message_Messenger::Send (const Standard_CString theString,
96 const Message_Gravity theGravity,
97 const Standard_Boolean putEndl) const
98{
99 Standard_Integer nb = myPrinters.Length();
100 for (Standard_Integer i = 1; i <= nb; i++)
101 {
102 Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) );
103 if ( ! aPrinter.IsNull() )
104 aPrinter->Send ( theString, theGravity, putEndl );
105 }
106}
107
108//=======================================================================
109//function : Send
110//purpose :
111//=======================================================================
112
113void Message_Messenger::Send (const TCollection_AsciiString& theString,
114 const Message_Gravity theGravity,
115 const Standard_Boolean putEndl) const
116{
117 Standard_Integer nb = myPrinters.Length();
118 for (Standard_Integer i = 1; i <= nb; i++)
119 {
120 Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) );
121 if ( ! aPrinter.IsNull() )
122 aPrinter->Send ( theString, theGravity, putEndl );
123 }
124}
125
126//=======================================================================
127//function : Send
128//purpose :
129//=======================================================================
130
131void Message_Messenger::Send (const TCollection_ExtendedString& theString,
132 const Message_Gravity theGravity,
133 const Standard_Boolean putEndl) const
134{
135 Standard_Integer nb = myPrinters.Length();
136 for (Standard_Integer i = 1; i <= nb; i++)
137 {
138 Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) );
139 if ( ! aPrinter.IsNull() )
140 aPrinter->Send ( theString, theGravity, putEndl );
141 }
142}