Coverage Report

Created: 2023-06-07 06:03

/src/resiprocate/resip/stack/ContentsFactoryBase.cxx
Line
Count
Source (jump to first uncovered line)
1
#include "rutil/ResipAssert.h"
2
3
#include "resip/stack/ContentsFactoryBase.hxx"
4
#include "rutil/WinLeakCheck.hxx"
5
6
using namespace resip;
7
using namespace std;
8
9
HashMap<Mime, ContentsFactoryBase*>* ContentsFactoryBase::FactoryMap = 0;
10
11
ContentsFactoryBase::ContentsFactoryBase(const Mime& contentType)
12
   : mContentType(contentType)
13
38
{
14
   // .amr. Due to multiple static initializers, this can be called more than once for a mimetype
15
   // so gracefully handle it
16
38
   if(ContentsFactoryBase::getFactoryMap().count(contentType) == 0)
17
36
      ContentsFactoryBase::getFactoryMap()[contentType] = this;
18
38
}
19
20
ContentsFactoryBase::~ContentsFactoryBase()
21
0
{
22
0
   if (ContentsFactoryBase::FactoryMap == 0)
23
0
      return;
24
  
25
0
   HashMap<Mime, ContentsFactoryBase*>::iterator i;
26
0
   i = ContentsFactoryBase::getFactoryMap().find(mContentType);
27
   // .amr. Need to check if iterator is valid since on some STL instances erase(i) will crash if i is invalid.
28
0
   if (i != ContentsFactoryBase::getFactoryMap().end())
29
0
      ContentsFactoryBase::getFactoryMap().erase(i);
30
0
   if (ContentsFactoryBase::getFactoryMap().size() == 0)
31
0
   {
32
0
      delete &ContentsFactoryBase::getFactoryMap();
33
0
      ContentsFactoryBase::FactoryMap = 0;
34
0
   }
35
0
}
36
37
HashMap<Mime, ContentsFactoryBase*>& 
38
ContentsFactoryBase::getFactoryMap()
39
74
{
40
74
   if (ContentsFactoryBase::FactoryMap == 0)
41
2
   {
42
2
      ContentsFactoryBase::FactoryMap = new HashMap<Mime, ContentsFactoryBase*>();
43
2
   }
44
74
   return *ContentsFactoryBase::FactoryMap;
45
74
}
46
47
/* ====================================================================
48
 * The Vovida Software License, Version 1.0 
49
 * 
50
 * Copyright (c) 2000-2005
51
 * 
52
 * Redistribution and use in source and binary forms, with or without
53
 * modification, are permitted provided that the following conditions
54
 * are met:
55
 * 
56
 * 1. Redistributions of source code must retain the above copyright
57
 *    notice, this list of conditions and the following disclaimer.
58
 * 
59
 * 2. Redistributions in binary form must reproduce the above copyright
60
 *    notice, this list of conditions and the following disclaimer in
61
 *    the documentation and/or other materials provided with the
62
 *    distribution.
63
 * 
64
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
65
 *    and "Vovida Open Communication Application Library (VOCAL)" must
66
 *    not be used to endorse or promote products derived from this
67
 *    software without prior written permission. For written
68
 *    permission, please contact vocal@vovida.org.
69
 *
70
 * 4. Products derived from this software may not be called "VOCAL", nor
71
 *    may "VOCAL" appear in their name, without prior written
72
 *    permission of Vovida Networks, Inc.
73
 * 
74
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
75
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
76
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
77
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
78
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
79
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
80
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
81
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
82
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
83
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
85
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
86
 * DAMAGE.
87
 * 
88
 * ====================================================================
89
 * 
90
 * This software consists of voluntary contributions made by Vovida
91
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
92
 * Inc.  For more information on Vovida Networks, Inc., please see
93
 * <http://www.vovida.org/>.
94
 *
95
 */