Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Message / Message_Messenger.cxx
CommitLineData
7fd59977 1// File: Message_Messenger.cxx
2// Created: Sat Jan 6 19:47:14 2001
3// Author: OCC Team
4// Copyright: Open CASCADE S.A. 2005
5
6#include <Message_Messenger.ixx>
7#include <Message_PrinterOStream.hxx>
8
9//=======================================================================
10//function : Message_Messenger
11//purpose :
12//=======================================================================
13
14Message_Messenger::Message_Messenger ()
15{
16 AddPrinter ( new Message_PrinterOStream );
17}
18
19//=======================================================================
20//function : Message_Messenger
21//purpose :
22//=======================================================================
23
24Message_Messenger::Message_Messenger (const Handle(Message_Printer)& thePrinter)
25{
26 AddPrinter (thePrinter);
27}
28
29//=======================================================================
30//function : AddPrinter
31//purpose :
32//=======================================================================
33
34Standard_Boolean Message_Messenger::AddPrinter (const Handle(Message_Printer)& thePrinter)
35{
36 // check whether printer is already in the list
37 for (Standard_Integer i=1; i <= myPrinters.Length(); i++)
38 if ( myPrinters(i) == thePrinter )
39 return Standard_False;
40 // add to the list
41 myPrinters.Append (thePrinter);
42 return Standard_True;
43}
44
45//=======================================================================
46//function : RemovePrinter
47//purpose :
48//=======================================================================
49
50Standard_Boolean Message_Messenger::RemovePrinter (const Handle(Message_Printer)& thePrinter)
51{
52 // find printer in the list
53 for (Standard_Integer i=1; i <= myPrinters.Length(); i++)
54 if ( myPrinters(i) == thePrinter )
55 {
56 myPrinters.Remove (i);
57 return Standard_True;
58 }
59 return Standard_False;
60}
61
62//=======================================================================
63//function : RemovePrinters
64//purpose :
65//=======================================================================
66
67Standard_Integer Message_Messenger::RemovePrinters (const Handle(Standard_Type)& theType)
68{
69 // remove printers from the list
70 Standard_Integer nb = 0;
71 for (Standard_Integer i=1; i <= myPrinters.Length(); i++)
72 if ( myPrinters(i)->IsKind(theType) )
73 {
74 myPrinters.Remove (i--);
75 nb++;
76 }
77 return nb;
78}
79
80//=======================================================================
81//function : Send
82//purpose :
83//=======================================================================
84
85void Message_Messenger::Send (const Standard_CString theString,
86 const Message_Gravity theGravity,
87 const Standard_Boolean putEndl) const
88{
89 Standard_Integer nb = myPrinters.Length();
90 for (Standard_Integer i = 1; i <= nb; i++)
91 {
92 Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) );
93 if ( ! aPrinter.IsNull() )
94 aPrinter->Send ( theString, theGravity, putEndl );
95 }
96}
97
98//=======================================================================
99//function : Send
100//purpose :
101//=======================================================================
102
103void Message_Messenger::Send (const TCollection_AsciiString& theString,
104 const Message_Gravity theGravity,
105 const Standard_Boolean putEndl) const
106{
107 Standard_Integer nb = myPrinters.Length();
108 for (Standard_Integer i = 1; i <= nb; i++)
109 {
110 Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) );
111 if ( ! aPrinter.IsNull() )
112 aPrinter->Send ( theString, theGravity, putEndl );
113 }
114}
115
116//=======================================================================
117//function : Send
118//purpose :
119//=======================================================================
120
121void Message_Messenger::Send (const TCollection_ExtendedString& theString,
122 const Message_Gravity theGravity,
123 const Standard_Boolean putEndl) const
124{
125 Standard_Integer nb = myPrinters.Length();
126 for (Standard_Integer i = 1; i <= nb; i++)
127 {
128 Handle(Message_Printer) aPrinter = Handle(Message_Printer)::DownCast ( myPrinters(i) );
129 if ( ! aPrinter.IsNull() )
130 aPrinter->Send ( theString, theGravity, putEndl );
131 }
132}