reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ConfigStore.cxx
Go to the documentation of this file.
1
2#include "rutil/Logger.hxx"
4#include "rutil/Lock.hxx"
5#include "resip/stack/Uri.hxx"
6
8
9
10using namespace resip;
11using namespace repro;
12using namespace std;
13
14
15#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
16
17
19 mDb(db)
20{
22 for (AbstractDb::ConfigRecordList::const_iterator it = input.begin();
23 it != input.end(); it++)
24 {
25 mCachedConfigData[it->mDomain] = *it;
26 }
27}
28
29
33
34
35bool
37 const int tlsPort )
38{
39 InfoLog( << "Add domain " << domain << " to config." );
40
42 rec.mDomain = domain;
43 rec.mTlsPort = tlsPort;
44
45 if(!mDb.addConfig(buildKey(domain), rec))
46 {
47 return false;
48 }
49
50 {
51 WriteLock lock(mMutex);
52 mCachedConfigData[domain] = rec;
53 }
54 return true;
55}
56
57
60{
61 // LOCKING NOTE: From an API perspective this method dangerous, but we know that the WebAdmin Thread is currently
62 // the only thread requiring a WRITE lock and is the only thread calling this function, so
63 // locking is not required
64 return mCachedConfigData;
65}
66
67
68int
70{
71 ReadLock lock(mMutex);
72 ConfigData::const_iterator it = mCachedConfigData.find(domain);
73 if(it != mCachedConfigData.end())
74 {
75 return it->second.mTlsPort;
76 }
77
78 return 0;
79}
80
81
82void
84{
85 mDb.eraseConfig( buildKey(domain) );
86 {
87 WriteLock lock(mMutex);
88 mCachedConfigData.erase(domain);
89 }
90}
91
92
94ConfigStore::buildKey(const resip::Data& domain ) const
95{
96 return domain;
97}
98
99
100/* ====================================================================
101 * The Vovida Software License, Version 1.0
102 *
103 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
104 *
105 * Redistribution and use in source and binary forms, with or without
106 * modification, are permitted provided that the following conditions
107 * are met:
108 *
109 * 1. Redistributions of source code must retain the above copyright
110 * notice, this list of conditions and the following disclaimer.
111 *
112 * 2. Redistributions in binary form must reproduce the above copyright
113 * notice, this list of conditions and the following disclaimer in
114 * the documentation and/or other materials provided with the
115 * distribution.
116 *
117 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
118 * and "Vovida Open Communication Application Library (VOCAL)" must
119 * not be used to endorse or promote products derived from this
120 * software without prior written permission. For written
121 * permission, please contact vocal@vovida.org.
122 *
123 * 4. Products derived from this software may not be called "VOCAL", nor
124 * may "VOCAL" appear in their name, without prior written
125 * permission of Vovida Networks, Inc.
126 *
127 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
128 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
129 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
130 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
131 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
132 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
133 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
134 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
135 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
136 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
137 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
138 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
139 * DAMAGE.
140 *
141 * ====================================================================
142 */
#define InfoLog(args_)
Definition Logger.hxx:131
std::vector< ConfigRecord > ConfigRecordList
virtual ConfigRecordList getAllConfigs()
virtual void eraseConfig(const Key &key)
virtual bool addConfig(const Key &key, const ConfigRecord &rec)
int getTlsPort(const resip::Data &domain)
bool addDomain(const resip::Data &domain, const int tlsPort)
std::map< resip::Data, AbstractDb::ConfigRecord > ConfigData
void eraseDomain(const resip::Data &domain)
const ConfigData & getConfigs() const
ConfigStore(AbstractDb &db)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;