[PATCH] osmo-trx[master]: CommonLibs: Remove unused files.

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Alexander Chemeris gerrit-no-reply at lists.osmocom.org
Sat Mar 18 03:09:02 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/2125

to look at the new patch set (#2).

CommonLibs: Remove unused files.

Change-Id: I2bfb45a1c7d01785bdb30204dba38c683a4288a9
---
M CommonLibs/Configuration.cpp
D CommonLibs/F16.h
D CommonLibs/F16Test.cpp
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
M CommonLibs/Makefile.am
D CommonLibs/MemoryLeak.h
D CommonLibs/Regexp.h
D CommonLibs/RegexpTest.cpp
D CommonLibs/Reporting.cpp
D CommonLibs/Reporting.h
D CommonLibs/ScalarTypes.h
D CommonLibs/URLEncode.cpp
D CommonLibs/URLEncode.h
D CommonLibs/URLEncodeTest.cpp
D CommonLibs/Utils.cpp
D CommonLibs/Utils.h
17 files changed, 49 insertions(+), 1,313 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/25/2125/2

diff --git a/CommonLibs/Configuration.cpp b/CommonLibs/Configuration.cpp
index 8cbfcb0..bfff893 100644
--- a/CommonLibs/Configuration.cpp
+++ b/CommonLibs/Configuration.cpp
@@ -53,6 +53,23 @@
 	")"
 };
 
+static std::string replaceAll(const std::string input, const std::string search, const std::string replace)
+{
+	std::string output = input;
+ 	int index = 0;
+
+	while (true) {
+		index = output.find(search, index);
+		if (index == std::string::npos) {
+			break;
+		}
+
+		output.replace(index, replace.length(), replace);
+		index += replace.length();
+	}
+
+	return output;
+}
 
 
 float ConfigurationRecord::floatNumber() const
@@ -259,8 +276,8 @@
 	ss << "% END AUTO-GENERATED CONTENT" << endl;
 	ss << endl;
 
-	string tmp = Utils::replaceAll(ss.str(), "^", "\\^");
-	return Utils::replaceAll(tmp, "_", "\\_");
+	string tmp = replaceAll(ss.str(), "^", "\\^");
+	return replaceAll(tmp, "_", "\\_");
 }
 
 bool ConfigurationTable::defines(const string& key)
diff --git a/CommonLibs/F16.h b/CommonLibs/F16.h
deleted file mode 100644
index aa292f0..0000000
--- a/CommonLibs/F16.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
-* Copyright 2009 Free Software Foundation, Inc.
-*
-* This software is distributed under the terms of the GNU Affero Public License.
-* See the COPYING file in the main directory for details.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published by
-	the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#ifndef F16_H
-#define F16_H
-
-#include <stdint.h>
-#include <ostream>
-
-
-
-/** Round a float to the appropriate F16 value. */
-inline int32_t _f16_round(float f)
-{
-	if (f>0.0F) return (int32_t)(f+0.5F);
-	if (f<0.0F) return (int32_t)(f-0.5F);
-	return 0;
-}
-
-
-
-/** A class for F15.16 fixed point arithmetic with saturation.  */
-class F16 {
-
-
-	private:
-
-	int32_t mV;
-
-
-	public:
-
-	F16() {}
-
-	F16(int i) { mV = i<<16; }
-	F16(float f) { mV = _f16_round(f*65536.0F); }
-	F16(double f) { mV = _f16_round((float)f*65536.0F); }
-
-	int32_t& raw() { return mV; }
-	const int32_t& raw() const { return mV; }
-
-	float f() const { return mV/65536.0F; }
-
-	//operator float() const { return mV/65536.0F; }
-	//operator int() const { return mV>>16; }
-
-	F16 operator=(float f)
-	{
-		mV = _f16_round(f*65536.0F);
-		return *this;
-	}
-
-	F16 operator=(int i)
-	{
-		mV = i<<16;
-		return *this;
-	}
-
-	F16 operator=(const F16& other)
-	{
-		mV = other.mV;
-		return mV;
-	}
-
-	F16 operator+(const F16& other) const
-	{
-		F16 retVal;
-		retVal.mV = mV + other.mV;
-		return retVal;
-	}
-
-	F16& operator+=(const F16& other)
-	{
-		mV += other.mV;
-		return *this;
-	}
-
-	F16 operator-(const F16& other) const
-	{
-		F16 retVal;
-		retVal.mV = mV - other.mV;
-		return retVal;
-	}
-
-	F16& operator-=(const F16& other)
-	{
-		mV -= other.mV;
-		return *this;
-	}
-
-	F16 operator*(const F16& other) const
-	{
-		F16 retVal;
-		int64_t p = (int64_t)mV * (int64_t)other.mV;
-		retVal.mV = p>>16;
-		return retVal;
-	}
-
-	F16& operator*=(const F16& other)
-	{
-		int64_t p = (int64_t)mV * (int64_t)other.mV;
-		mV = p>>16;
-		return *this;
-	}
-
-	F16 operator*(float f) const
-	{
-		F16 retVal;
-		retVal.mV = mV * f;
-		return retVal;
-	}
-
-	F16& operator*=(float f)
-	{
-		mV *= f;
-		return *this;
-	}
-
-	F16 operator/(const F16& other) const
-	{
-		F16 retVal;
-		int64_t pV = (int64_t)mV << 16;
-		retVal.mV = pV / other.mV;
-		return retVal;
-	}
-
-	F16& operator/=(const F16& other)
-	{
-		int64_t pV = (int64_t)mV << 16;
-		mV = pV / other.mV;
-		return *this;
-	}
-
-	F16 operator/(float f) const
-	{
-		F16 retVal;
-		retVal.mV = mV / f;
-		return retVal;
-	}
-
-	F16& operator/=(float f)
-	{
-		mV /= f;
-		return *this;
-	}
-
-	bool operator>(const F16& other) const
-	{
-		return mV>other.mV;
-	}
-
-	bool operator<(const F16& other) const
-	{
-		return mV<other.mV;
-	}
-
-	bool operator==(const F16& other) const
-	{
-		return mV==other.mV;
-	}
-
-	bool operator>(float f) const
-	{
-		return (mV/65536.0F) > f;
-	}
-
-	bool operator<(float f) const
-	{
-		return (mV/65536.0F) < f;
-	}
-
-	bool operator==(float f) const
-	{
-		return (mV/65536.0F) == f;
-	}
-
-};
-
-
-
-inline std::ostream& operator<<(std::ostream& os, const F16& v)
-{
-	os << v.f();
-	return os;
-}
-
-#endif
-
diff --git a/CommonLibs/F16Test.cpp b/CommonLibs/F16Test.cpp
deleted file mode 100644
index 7f3c84d..0000000
--- a/CommonLibs/F16Test.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Copyright 2009 Free Software Foundation, Inc.
-*
-*
-* This software is distributed under the terms of the GNU Affero Public License.
-* See the COPYING file in the main directory for details.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published by
-	the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "F16.h"
-
-
-#include <iostream>
-
-using namespace std;
-
-int main(int argc, char **argv)
-{
-
-	F16 a = 2.5;
-	F16 b = 1.5;
-	F16 c = 2.5 * 1.5;
-	F16 d = c + a;
-	F16 e = 10;
-	cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << endl;
-
-	a *= 3;
-	b *= 0.3;
-	c *= e;
-	cout << a << ' ' << b << ' ' << c << ' ' << d << endl;
-
-	a /= 3;
-	b /= 0.3;
-	c = d * 0.05;
-	cout << a << ' ' << b << ' ' << c << ' ' << d << endl;
-
-	F16 f = a/d;
-	cout << f << ' ' << f+0.5 << endl;
-}
diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 82391cc..4e4dbbc 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -30,6 +30,7 @@
 #include <fstream>
 #include <string>
 #include <stdarg.h>
+#include <sys/time.h>	// For gettimeofday
 
 #include "Configuration.h"
 #include "Logger.h"
@@ -111,6 +112,31 @@
 	return level;
 }
 
+static std::string format(const char *fmt, ...)
+{
+	va_list ap;
+	char buf[300];
+	va_start(ap,fmt);
+	int n = vsnprintf(buf,300,fmt,ap);
+	va_end(ap);
+	if (n >= (300-4)) { strcpy(&buf[(300-4)],"..."); }
+	return std::string(buf);
+}
+
+const std::string timestr()
+{
+	struct timeval tv;
+	struct tm tm;
+	gettimeofday(&tv,NULL);
+	localtime_r(&tv.tv_sec,&tm);
+	unsigned tenths = tv.tv_usec / 100000;	// Rounding down is ok.
+	return format(" %02d:%02d:%02d.%1d",tm.tm_hour,tm.tm_min,tm.tm_sec,tenths);
+}
+
+std::ostream& operator<<(std::ostream& os, std::ostringstream& ss)
+{
+	return os << ss.str();
+}
 
 int getLoggingLevel(const char* filename)
 {
diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h
index 9667f36..68c5a9b 100644
--- a/CommonLibs/Logger.h
+++ b/CommonLibs/Logger.h
@@ -83,7 +83,6 @@
 
 
 #include "Threads.h"		// must be after defines above, if these files are to be allowed to use LOG()
-#include "Utils.h"
 
 /**
 	A C++ stream-based thread-safe logger.
@@ -123,6 +122,8 @@
 
 std::list<std::string> gGetLoggerAlarms();		///< Get a copy of the recent alarm list.
 
+const std::string timestr();		// A timestamp to print in messages.
+std::ostream& operator<<(std::ostream& os, std::ostringstream& ss);
 
 /**@ Global control and initialization of the logging system. */
 //@{
diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am
index ed9cf29..f0f1061 100644
--- a/CommonLibs/Makefile.am
+++ b/CommonLibs/Makefile.am
@@ -36,24 +36,18 @@
 	Sockets.cpp \
 	Threads.cpp \
 	Timeval.cpp \
-	Reporting.cpp \
 	Logger.cpp \
 	Configuration.cpp \
-	sqlite3util.cpp \
-	URLEncode.cpp \
-	Utils.cpp
+	sqlite3util.cpp
 
 noinst_PROGRAMS = \
 	BitVectorTest \
 	InterthreadTest \
 	SocketsTest \
 	TimevalTest \
-	RegexpTest \
 	VectorTest \
 	ConfigurationTest \
-	LogTest \
-	URLEncodeTest \
-	F16Test
+	LogTest
 
 #	ReportingTest 
 
@@ -64,18 +58,10 @@
 	Sockets.h \
 	Threads.h \
 	Timeval.h \
-	Regexp.h \
 	Vector.h \
 	Configuration.h \
-	Reporting.h \
-	F16.h \
-	URLEncode.h \
-	Utils.h \
 	Logger.h \
 	sqlite3util.h
-
-URLEncodeTest_SOURCES = URLEncodeTest.cpp
-URLEncodeTest_LDADD = libcommon.la
 
 BitVectorTest_SOURCES = BitVectorTest.cpp
 BitVectorTest_LDADD = libcommon.la $(SQLITE3_LIBS)
@@ -94,9 +80,6 @@
 VectorTest_SOURCES = VectorTest.cpp
 VectorTest_LDADD = libcommon.la $(SQLITE3_LIBS)
 
-RegexpTest_SOURCES = RegexpTest.cpp
-RegexpTest_LDADD = libcommon.la
-
 ConfigurationTest_SOURCES = ConfigurationTest.cpp
 ConfigurationTest_LDADD = libcommon.la 	$(SQLITE3_LIBS)
 
@@ -105,8 +88,6 @@
 
 LogTest_SOURCES = LogTest.cpp
 LogTest_LDADD = libcommon.la $(SQLITE3_LIBS)
-
-F16Test_SOURCES = F16Test.cpp
 
 MOSTLYCLEANFILES += testSource testDestination
 
diff --git a/CommonLibs/MemoryLeak.h b/CommonLibs/MemoryLeak.h
deleted file mode 100644
index 4948534..0000000
--- a/CommonLibs/MemoryLeak.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-* Copyright 2011 Range Networks, Inc.
-* All Rights Reserved.
-*
-* This software is distributed under multiple licenses;
-* see the COPYING file in the main directory for licensing
-* information for this specific distribuion.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-*/
-#ifndef _MEMORYLEAK_
-#define _MEMORYLEAK_ 1
-#include <map>
-#include "ScalarTypes.h"
-#include "Logger.h"
-
-namespace Utils {
-
-struct MemStats {
-	// Enumerates the classes that are checked.
-	// Redundancies are ok, for example, we check BitVector and also
-	// several descendants of BitVector.
-	enum MemoryNames {
-		mZeroIsUnused,
-		mVector,
-		mVectorData,
-		mBitVector,
-		mByteVector,
-		mByteVectorData,
-		mRLCRawBlock,
-		mRLCUplinkDataBlock,
-		mRLCMessage,
-		mRLCMsgPacketDownlinkDummyControlBlock,	// Redundant with RLCMessage
-		mTBF,
-		mLlcEngine,
-		mSgsnDownlinkMsg,
-		mRachInfo,
-		mPdpPdu,
-		mFECDispatchInfo,
-		mL3Frame,
-		msignalVector,
-		mSoftVector,
-		mScramblingCode,
-		mURlcDownSdu,
-		mURlcPdu,
-		// Must be last:
-		mMax,
-	};
-	int mMemTotal[mMax];	// In elements, not bytes.
-	int mMemNow[mMax];
-	const char *mMemName[mMax];
-	MemStats();
-	void memChkNew(MemoryNames memIndex, const char *id);
-	void memChkDel(MemoryNames memIndex, const char *id);
-	void text(std::ostream &os);
-	// We would prefer to use an unordered_map, but that requires special compile switches.
-	// What a super great language.
-	typedef std::map<std::string,Int_z> MemMapType;
-	MemMapType mMemMap;
-};
-extern struct MemStats gMemStats;
-extern int gMemLeakDebug;
-
-// This is a memory leak detector.
-// Use by putting RN_MEMCHKNEW and RN_MEMCHKDEL in class constructors/destructors,
-// or use the DEFINE_MEMORY_LEAK_DETECTOR class and add the defined class
-// as an ancestor to the class to be memory leak checked.
-
-struct MemLabel {
-	std::string mccKey;
-	virtual ~MemLabel() {
-		Int_z &tmp = Utils::gMemStats.mMemMap[mccKey]; tmp = tmp - 1;
-	}
-};
-
-#if RN_DISABLE_MEMORY_LEAK_TEST
-#define RN_MEMCHKNEW(type)
-#define RN_MEMCHKDEL(type)
-#define RN_MEMLOG(type,ptr)
-#define DEFINE_MEMORY_LEAK_DETECTOR_CLASS(subClass,checkerClass) \
-	struct checkerClass {};
-#else
-
-#define RN_MEMCHKNEW(type) { Utils::gMemStats.memChkNew(Utils::MemStats::m##type,#type); }
-#define RN_MEMCHKDEL(type) { Utils::gMemStats.memChkDel(Utils::MemStats::m##type,#type); }
-
-#define RN_MEMLOG(type,ptr) { \
-	static std::string key = format("%s_%s:%d",#type,__FILE__,__LINE__); \
-	(ptr)->/* MemCheck##type:: */ mccKey = key; \
-	Utils::gMemStats.mMemMap[key]++; \
-	}
-
-// TODO: The above assumes that checkclass is MemCheck ## subClass
-#define DEFINE_MEMORY_LEAK_DETECTOR_CLASS(subClass,checkerClass) \
-	struct checkerClass : public virtual Utils::MemLabel { \
-	    checkerClass() { RN_MEMCHKNEW(subClass); } \
-		virtual ~checkerClass() { \
-			RN_MEMCHKDEL(subClass); \
-		} \
-	};
-
-#endif
-
-}	// namespace Utils
-
-#endif
diff --git a/CommonLibs/Regexp.h b/CommonLibs/Regexp.h
deleted file mode 100644
index 3ff1e97..0000000
--- a/CommonLibs/Regexp.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright 2008 Free Software Foundation, Inc.
-*
-* This software is distributed under the terms of the GNU Affero Public License.
-* See the COPYING file in the main directory for details.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published by
-	the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#ifndef REGEXPW_H
-#define REGEXPW_H
-
-#include <regex.h>
-#include <iostream>
-#include <stdlib.h>
-
-
-
-class Regexp {
-
-	private:
-
-	regex_t mRegex;
-
-
-	public:
-
-	Regexp(const char* regexp, int flags=REG_EXTENDED)
-	{
-		int result = regcomp(&mRegex, regexp, flags);
-		if (result) {
-			char msg[256];
-			regerror(result,&mRegex,msg,255);
-			std::cerr << "Regexp compilation of " << regexp << " failed: " << msg << std::endl;
-			abort();
-		}
-	}
-
-	~Regexp()
-		{ regfree(&mRegex); }
-
-	bool match(const char *text, int flags=0) const
-		{ return regexec(&mRegex, text, 0, NULL, flags)==0; }
-
-};
-
-
-#endif
diff --git a/CommonLibs/RegexpTest.cpp b/CommonLibs/RegexpTest.cpp
deleted file mode 100644
index 748be49..0000000
--- a/CommonLibs/RegexpTest.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-* Copyright 2008 Free Software Foundation, Inc.
-*
-*
-* This software is distributed under the terms of the GNU Affero Public License.
-* See the COPYING file in the main directory for details.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published by
-	the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-
-#include "Regexp.h"
-#include <iostream>
-
-using namespace std;
-
-
-int main(int argc, char *argv[])
-{
-
-	Regexp email("^[[:graph:]]+@[[:graph:]]+ ");
-	Regexp simple("^dburgess@");
-
-	const char text1[] = "dburgess at jcis.net test message";
-	const char text2[] = "no address text message";
-
-	cout << email.match(text1) << " " << text1 << endl;
-	cout << email.match(text2) << " " << text2 << endl;
-
-	cout << simple.match(text1) << " " << text1 << endl;
-	cout << simple.match(text2) << " " << text2 << endl;
-}
diff --git a/CommonLibs/Reporting.cpp b/CommonLibs/Reporting.cpp
deleted file mode 100644
index 3ea7eed..0000000
--- a/CommonLibs/Reporting.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/**@file Module for performance-reporting mechanisms. */
-/*
-* Copyright 2012 Range Networks, Inc.
-*
-* This software is distributed under the terms of the GNU Affero Public License.
-* See the COPYING file in the main directory for details.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published by
-	the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "Reporting.h"
-#include "Logger.h"
-#include <stdio.h>
-#include <string.h>
-
-static const char* createReportingTable = {
-	"CREATE TABLE IF NOT EXISTS REPORTING ("
-		"NAME TEXT UNIQUE NOT NULL, "
-		"VALUE INTEGER DEFAULT 0, "
-		"CLEAREDTIME INTEGER NOT NULL, "
-		"UPDATETIME INTEGER DEFAULT 0 "
-	")"
-};
-
-
-ReportingTable::ReportingTable(const char* filename)
-{
-	gLogEarly(LOG_INFO | mFacility, "opening reporting table from path %s", filename);
-	// Connect to the database.
-	int rc = sqlite3_open(filename,&mDB);
-	if (rc) {
-		gLogEarly(LOG_EMERG | mFacility, "cannot open reporting database at %s, error message: %s", filename, sqlite3_errmsg(mDB));
-		sqlite3_close(mDB);
-		mDB = NULL;
-		return;
-	}
-	// Create the table, if needed.
-	if (!sqlite3_command(mDB,createReportingTable)) {
-		gLogEarly(LOG_EMERG | mFacility, "cannot create reporting table in database at %s, error message: %s", filename, sqlite3_errmsg(mDB));
-	}
-}
-
-
-bool ReportingTable::create(const char* paramName)
-{
-	char cmd[200];
-	sprintf(cmd,"INSERT OR IGNORE INTO REPORTING (NAME,CLEAREDTIME) VALUES (\"%s\",%ld)", paramName, time(NULL));
-	if (!sqlite3_command(mDB,cmd)) {
-		gLogEarly(LOG_CRIT|mFacility, "cannot create reporting parameter %s, error message: %s", paramName, sqlite3_errmsg(mDB));
-		return false;
-	}
-	return true;
-}
-
-
-
-bool ReportingTable::incr(const char* paramName)
-{
-	char cmd[200];
-	sprintf(cmd,"UPDATE REPORTING SET VALUE=VALUE+1, UPDATETIME=%ld WHERE NAME=\"%s\"", time(NULL), paramName);
-	if (!sqlite3_command(mDB,cmd)) {
-		gLogEarly(LOG_CRIT|mFacility, "cannot increment reporting parameter %s, error message: %s", paramName, sqlite3_errmsg(mDB));
-		return false;
-	}
-	return true;
-}
-
-
-
-bool ReportingTable::max(const char* paramName, unsigned newVal)
-{
-	char cmd[200];
-	sprintf(cmd,"UPDATE REPORTING SET VALUE=MAX(VALUE,%u), UPDATETIME=%ld WHERE NAME=\"%s\"", newVal, time(NULL), paramName);
-	if (!sqlite3_command(mDB,cmd)) {
-		gLogEarly(LOG_CRIT|mFacility, "cannot maximize reporting parameter %s, error message: %s", paramName, sqlite3_errmsg(mDB));
-		return false;
-	}
-	return true;
-}
-
-
-bool ReportingTable::clear(const char* paramName)
-{
-	char cmd[200];
-	sprintf(cmd,"UPDATE REPORTING SET VALUE=0, UPDATETIME=0, CLEAREDTIME=%ld WHERE NAME=\"%s\"", time(NULL), paramName);
-	if (!sqlite3_command(mDB,cmd)) {
-		gLogEarly(LOG_CRIT|mFacility, "cannot clear reporting parameter %s, error message: %s", paramName, sqlite3_errmsg(mDB));
-		return false;
-	}
-	return true;
-}
-
-
-bool ReportingTable::create(const char* baseName, unsigned minIndex, unsigned maxIndex)
-{
-	size_t sz = strlen(baseName);
-	for (unsigned i = minIndex; i<=maxIndex; i++) {
-		char name[sz+10];
-		sprintf(name,"%s.%u",baseName,i);
-		if (!create(name)) return false;
-	}
-	return true;
-}
-
-bool ReportingTable::incr(const char* baseName, unsigned index)
-{
-	char name[strlen(baseName)+10];
-	sprintf(name,"%s.%u",baseName,index);
-	return incr(name);
-}
-
-
-bool ReportingTable::max(const char* baseName, unsigned index, unsigned newVal)
-{
-	char name[strlen(baseName)+10];
-	sprintf(name,"%s.%u",baseName,index);
-	return max(name,newVal);
-}
-
-
-bool ReportingTable::clear(const char* baseName, unsigned index)
-{
-	char name[strlen(baseName)+10];
-	sprintf(name,"%s.%u",baseName,index);
-	return clear(name);
-}
-
-
-
-
diff --git a/CommonLibs/Reporting.h b/CommonLibs/Reporting.h
deleted file mode 100644
index 1878618..0000000
--- a/CommonLibs/Reporting.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/**@file Module for performance-reporting mechanisms. */
-/*
-* Copyright 2012 Range Networks, Inc.
-*
-* This software is distributed under the terms of the GNU Affero Public License.
-* See the COPYING file in the main directory for details.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published by
-	the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef REPORTING_H
-#define REPORTING_H
-
-#include <sqlite3util.h>
-#include <ostream>
-
-
-/**
-	Collect performance statistics into a database.
-	Parameters are counters or max/min trackers, all integer.
-*/
-class ReportingTable {
-
-	private:
-
-	sqlite3* mDB;				///< database connection
-	int mFacility;				///< rsyslogd facility
-
-
-
-	public:
-
-	/**
-		Open the database connection;
-		create the table if it does not exist yet.
-	*/
-	ReportingTable(const char* filename);
-
-	/** Create a new parameter. */
-	bool create(const char* paramName);
-
-	/** Create an indexed parameter set. */
-	bool create(const char* baseBame, unsigned minIndex, unsigned maxIndex);
-
-	/** Increment a counter. */
-	bool incr(const char* paramName);
-
-	/** Increment an indexed counter. */
-	bool incr(const char* baseName, unsigned index);
-
-	/** Take a max of a parameter. */
-	bool max(const char* paramName, unsigned newVal);
-
-	/** Take a max of an indexed parameter. */
-	bool max(const char* paramName, unsigned index, unsigned newVal);
-
-	/** Clear a value.  */
-	bool clear(const char* paramName);
-
-	/** Clear an indexed value.  */
-	bool clear(const char* paramName, unsigned index);
-
-	/** Dump the database to a stream. */
-	void dump(std::ostream&) const;
-
-};
-
-#endif
-
-
-// vim: ts=4 sw=4
diff --git a/CommonLibs/ScalarTypes.h b/CommonLibs/ScalarTypes.h
deleted file mode 100644
index 077d889..0000000
--- a/CommonLibs/ScalarTypes.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
-* Copyright 2011 Range Networks, Inc.
-* All Rights Reserved.
-*
-* This software is distributed under multiple licenses;
-* see the COPYING file in the main directory for licensing
-* information for this specific distribuion.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-*/
-
-#ifndef SCALARTYPES_H
-#define SCALARTYPES_H
-#include <iostream>	// For size_t
-#include <stdint.h>
-//#include "GSMCommon.h"	// Was included for Z100Timer
-
-// We dont bother to define *= /= etc.; you'll have to convert: a*=b; to: a=a*b;
-#define _INITIALIZED_SCALAR_BASE_FUNCS(Classname,Basetype,Init) \
-	Classname() : value(Init) {} \
-	Classname(Basetype wvalue) { value = wvalue; } /* Can set from basetype. */ \
-	operator Basetype(void) const { return value; }		/* Converts from basetype. */ \
-	Basetype operator=(Basetype wvalue) { return value = wvalue; } \
-	Basetype* operator&() { return &value; }
-
-#define _INITIALIZED_SCALAR_ARITH_FUNCS(Basetype) \
-	Basetype operator++() { return ++value; } \
-	Basetype operator++(int) { return value++; } \
-	Basetype operator--() { return --value; } \
-	Basetype operator--(int) { return value--; } \
-	Basetype operator+=(Basetype wvalue) { return value = value + wvalue; } \
-	Basetype operator-=(Basetype wvalue) { return value = value - wvalue; }
-
-#define _INITIALIZED_SCALAR_FUNCS(Classname,Basetype,Init) \
-	_INITIALIZED_SCALAR_BASE_FUNCS(Classname,Basetype,Init) \
-	_INITIALIZED_SCALAR_ARITH_FUNCS(Basetype)
-
-
-#define _DECLARE_SCALAR_TYPE(Classname_i,Classname_z,Basetype) \
-	template <Basetype Init> \
-	struct Classname_i { \
-		Basetype value; \
-		_INITIALIZED_SCALAR_FUNCS(Classname_i,Basetype,Init) \
-	}; \
-	typedef Classname_i<0> Classname_z;
-
-
-// Usage:
-// Where 'classname' is one of the types listed below, then:
-// 		classname_z specifies a zero initialized type;
-// 		classname_i<value> initializes the type to the specified value.
-// We also define Float_z.
-_DECLARE_SCALAR_TYPE(Int_i, 	Int_z,  	int)
-_DECLARE_SCALAR_TYPE(Char_i,	Char_z, 	signed char)
-_DECLARE_SCALAR_TYPE(Int16_i,	Int16_z,	int16_t)
-_DECLARE_SCALAR_TYPE(Int32_i,	Int32_z,	int32_t)
-_DECLARE_SCALAR_TYPE(UInt_i,  	UInt_z,  	unsigned)
-_DECLARE_SCALAR_TYPE(UChar_i,  	UChar_z,  	unsigned char)
-_DECLARE_SCALAR_TYPE(UInt16_i,	UInt16_z,	uint16_t)
-_DECLARE_SCALAR_TYPE(UInt32_i,	UInt32_z,	uint32_t)
-_DECLARE_SCALAR_TYPE(Size_t_i,	Size_t_z,	size_t)
-
-// Bool is special because it cannot accept some arithmetic funcs
-//_DECLARE_SCALAR_TYPE(Bool_i,  	Bool_z, 	bool)
-template <bool Init>
-struct Bool_i {
-	bool value;
-	_INITIALIZED_SCALAR_BASE_FUNCS(Bool_i,bool,Init)
-};
-typedef Bool_i<0> Bool_z;
-
-// float is special, because C++ does not permit the template initalization:
-struct Float_z {
-	float value;
-	_INITIALIZED_SCALAR_FUNCS(Float_z,float,0)
-};
-struct Double_z {
-	double value;
-	_INITIALIZED_SCALAR_FUNCS(Double_z,double,0)
-};
-
-
-class ItemWithValueAndWidth {
-	public:
-	virtual unsigned getValue() const = 0;
-	virtual unsigned getWidth() const = 0;
-};
-
-// A Range Networks Field with a specified width.
-// See RLCMessages.h for examples.
-template <int Width=32, unsigned Init=0>
-class Field_i : public ItemWithValueAndWidth
-{
-	public:
-	unsigned value;
-	_INITIALIZED_SCALAR_FUNCS(Field_i,unsigned,Init)
-	unsigned getWidth() const { return Width; }
-	unsigned getValue() const { return value; }
-};
-
-// Synonym for Field_i, but no way to do it.
-template <int Width, unsigned Init=0>
-class Field_z : public ItemWithValueAndWidth
-{
-	public:
-	unsigned value;
-	_INITIALIZED_SCALAR_FUNCS(Field_z,unsigned,Init)
-	unsigned getWidth() const { return Width; }
-	unsigned getValue() const { return value; }
-};
-
-// This is an uninitialized field.
-template <int Width=32, unsigned Init=0>
-class Field : public ItemWithValueAndWidth
-{
-	public:
-	unsigned value;
-	_INITIALIZED_SCALAR_FUNCS(Field,unsigned,Init)
-	unsigned getWidth() const { return Width; }
-	unsigned getValue() const { return value; }
-};
-
-
-// A Z100Timer with an initial value specified.
-//template <int Init>
-//class Z100Timer_i : public GSM::Z100Timer {
-//	public:
-//	Z100Timer_i() : GSM::Z100Timer(Init) {}
-//};
-
-#endif
diff --git a/CommonLibs/URLEncode.cpp b/CommonLibs/URLEncode.cpp
deleted file mode 100644
index cdf38dd..0000000
--- a/CommonLibs/URLEncode.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2011, Range Networks, Inc. */
-
-#include <URLEncode.h>
-#include <string>
-#include <string.h>
-#include <ctype.h>
-
-using namespace std;
-
-//based on javascript encodeURIComponent()
-string URLEncode(const string &c)
-{
-	static const char *digits = "01234567890ABCDEF";
-	string retVal="";
-	for (size_t i=0; i<c.length(); i++)
-	{
-		const char ch = c[i];
-		if (isalnum(ch) || strchr("-_.!~'()",ch)) {
-			retVal += ch;
-		} else {
-			retVal += '%';
-			retVal += digits[(ch>>4) & 0x0f];
-			retVal += digits[ch & 0x0f];
-		}
-	}
-	return retVal;
-}
-
diff --git a/CommonLibs/URLEncode.h b/CommonLibs/URLEncode.h
deleted file mode 100644
index 558ced9..0000000
--- a/CommonLibs/URLEncode.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-* Copyright 2011 Free Software Foundation, Inc.
-*
-*
-* This software is distributed under the terms of the GNU Affero Public License.
-* See the COPYING file in the main directory for details.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published by
-	the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-
-# include <string>
-
-std::string URLEncode(const std::string&);
diff --git a/CommonLibs/URLEncodeTest.cpp b/CommonLibs/URLEncodeTest.cpp
deleted file mode 100644
index dbc4630..0000000
--- a/CommonLibs/URLEncodeTest.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#include "URLEncode.h"
-#include <string>
-#include <iostream>
-
-
-using namespace std;
-
-
-int main(int argc, char *argv[])
-{
-
-	string test = string("Testing: !@#$%^&*() " __DATE__ " " __TIME__);
-	cout << test << endl;
-	cout << URLEncode(test) << endl;
-}
-
diff --git a/CommonLibs/Utils.cpp b/CommonLibs/Utils.cpp
deleted file mode 100644
index 1da95fa..0000000
--- a/CommonLibs/Utils.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-* Copyright 2011 Range Networks, Inc.
-* All Rights Reserved.
-*
-* This software is distributed under multiple licenses;
-* see the COPYING file in the main directory for licensing
-* information for this specific distribuion.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-*/
-
-#include <unistd.h>		// For usleep
-#include <sys/time.h>	// For gettimeofday
-#include <stdio.h>		// For vsnprintf
-#include <ostream>		// For ostream
-#include <sstream>		// For ostringstream
-#include <string.h>		// For strcpy
-//#include "GSMCommon.h"
-#include "Utils.h"
-#include "MemoryLeak.h"
-
-namespace Utils {
-
-MemStats gMemStats;
-int gMemLeakDebug = 0;
-
-MemStats::MemStats()
-{
-	memset(mMemNow,0,sizeof(mMemNow));
-	memset(mMemTotal,0,sizeof(mMemTotal));
-	memset(mMemName,0,sizeof(mMemName));
-}
-
-void MemStats::text(std::ostream &os)
-{
-	os << "Structs current total:\n";
-	for (int i = 0; i < mMax; i++) {
-		os << "\t" << (mMemName[i] ? mMemName[i] : "unknown") << " " << mMemNow[i] << " " << mMemTotal[i] << "\n";
-	}
-}
-
-void MemStats::memChkNew(MemoryNames memIndex, const char *id)
-{
-	/*std::cout << "new " #type "\n";*/
-	mMemNow[memIndex]++;
-	mMemTotal[memIndex]++;
-	mMemName[memIndex] = id;
-}
-
-void MemStats::memChkDel(MemoryNames memIndex, const char *id)
-{
-	/*std::cout << "del " #type "\n";*/
-	mMemNow[memIndex]--;
-	if (mMemNow[memIndex] < 0) {
-		LOG(ERR) << "Memory underflow on type "<<id;
-		if (gMemLeakDebug) assert(0);
-		mMemNow[memIndex] += 100;	// Prevent another message for a while.
-	}
-}
-
-std::ostream& operator<<(std::ostream& os, std::ostringstream& ss)
-{
-	return os << ss.str();
-}
-
-std::ostream &osprintf(std::ostream &os, const char *fmt, ...)
-{
-	va_list ap;
-	char buf[300];
-	va_start(ap,fmt);
-	int n = vsnprintf(buf,300,fmt,ap);
-	va_end(ap);
-	if (n >= (300-4)) { strcpy(&buf[(300-4)],"..."); }
-	os << buf;
-	return os;
-}
-
-std::string format(const char *fmt, ...)
-{
-	va_list ap;
-	char buf[300];
-	va_start(ap,fmt);
-	int n = vsnprintf(buf,300,fmt,ap);
-	va_end(ap);
-	if (n >= (300-4)) { strcpy(&buf[(300-4)],"..."); }
-	return std::string(buf);
-}
-
-// Return time in seconds with high resolution.
-// Note: In the past I found this to be a surprisingly expensive system call in linux.
-double timef()
-{
-	struct timeval tv;
-	gettimeofday(&tv,NULL);
-	return tv.tv_usec / 1000000.0 + tv.tv_sec;
-}
-
-const std::string timestr()
-{
-	struct timeval tv;
-	struct tm tm;
-	gettimeofday(&tv,NULL);
-	localtime_r(&tv.tv_sec,&tm);
-	unsigned tenths = tv.tv_usec / 100000;	// Rounding down is ok.
-	return format(" %02d:%02d:%02d.%1d",tm.tm_hour,tm.tm_min,tm.tm_sec,tenths);
-}
-
-// High resolution sleep for the specified time.
-// Return FALSE if time is already past.
-void sleepf(double howlong)
-{
-	if (howlong <= 0.00001) return;		// Less than 10 usecs, forget it.
-	usleep((useconds_t) (1000000.0 * howlong));
-}
-
-//bool sleepuntil(double untilwhen)
-//{
-	//double now = timef();
-	//double howlong = untilwhen - now;		// Fractional time in seconds.
-	// We are not worrying about overflow because all times should be in the near future.
-	//if (howlong <= 0.00001) return false;		// Less than 10 usecs, forget it.
-	//sleepf(sleeptime);
-//}
-
-std::string Text2Str::str() const
-{
-	std::ostringstream ss;
-	text(ss);
-	return ss.str();
-}
-
-std::ostream& operator<<(std::ostream& os, const Text2Str *val)
-{
-	std::ostringstream ss;
-	if (val) {
-		val->text(ss);
-		os << ss.str(); 
-	} else {
-		os << "(null)";
-	}
-	return os;
-}
-
-// Greatest Common Denominator.
-// This is by Doug Brown.
-int gcd(int x, int y)
-{
-	if (x > y) {
-		return x % y == 0 ? y : gcd(y, x % y);
-	} else {
-		return y % x == 0 ? x : gcd(x, y % x);
-	}
-}
-
-
-// Split a C string into an argc,argv array in place; the input string is modified.
-// Returns argc, and places results in argv, up to maxargc elements.
-// The final argv receives the rest of the input string from maxargc on,
-// even if it contains additional splitchars.
-// The correct idiom for use is to make a copy of your string, like this:
-// char *copy = strcpy((char*)alloca(the_string.length()+1),the_string.c_str());
-// char *argv[2];
-// int argc = cstrSplit(copy,argv,2,NULL);
-// If you want to detect the error of too many arguments, add 1 to argv, like this:
-// char *argv[3];
-// int argc = cstrSplit(copy,argv,3,NULL);
-// if (argc == 3) { error("too many arguments"; }
-int cstrSplit(char *in, char **pargv,int maxargc, const char *splitchars)
-{
-	if (splitchars == NULL) { splitchars = " \t\r\n"; }	// Default is any space.
-	int argc = 0;
-	while (argc < maxargc) {
-		while (*in && strchr(splitchars,*in)) {in++;}	// scan past any splitchars
-		if (! *in) return argc;					// return if finished.
-		pargv[argc++] = in;						// save ptr to start of arg.
-		in = strpbrk(in,splitchars);			// go to end of arg.
-		if (!in) return	argc;					// return if finished.
-		*in++ = 0;								// zero terminate this arg.
-	}
-	return argc;
-}
-
-std::ostream& operator<<(std::ostream& os, const Statistic<int> &stat) { stat.text(os); return os; }
-std::ostream& operator<<(std::ostream& os, const Statistic<unsigned> &stat) { stat.text(os); return os; }
-std::ostream& operator<<(std::ostream& os, const Statistic<float> &stat) { stat.text(os); return os; }
-std::ostream& operator<<(std::ostream& os, const Statistic<double> &stat) { stat.text(os); return os; }
-
-std::string replaceAll(const std::string input, const std::string search, const std::string replace)
-{
-	std::string output = input;
- 	int index = 0;
-
-	while (true) {
-		index = output.find(search, index);
-		if (index == std::string::npos) {
-			break;
-		}
-
-		output.replace(index, replace.length(), replace);
-		index += replace.length();
-	}
-
-	return output;
-}
-
-};
diff --git a/CommonLibs/Utils.h b/CommonLibs/Utils.h
deleted file mode 100644
index 0bc738e..0000000
--- a/CommonLibs/Utils.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
-* Copyright 2011 Range Networks, Inc.
-* All Rights Reserved.
-*
-* This software is distributed under multiple licenses;
-* see the COPYING file in the main directory for licensing
-* information for this specific distribuion.
-*
-* This use of this software may be subject to additional restrictions.
-* See the LEGAL file in the main directory for details.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-*/
-
-#ifndef GPRSUTILS_H
-#define GPRSUTILS_H
-#include <stdint.h>
-#include <stdarg.h>
-#include <string>
-#include <string.h>
-#include <math.h>		// for sqrtf
-#include "Logger.h"
-
-
-namespace Utils {
-
-extern double timef();					// high resolution time
-extern const std::string timestr();		// A timestamp to print in messages.
-extern void sleepf(double howlong);	// high resolution sleep
-extern int gcd(int x, int y);
-
-// It is irritating to create a string just to interface to the brain-damaged
-// C++ stream class, but this is only used for debug messages.
-std::string format(const char *fmt, ...) __attribute__((format (printf,1,2)));
-
-int cstrSplit(char *in, char **pargv,int maxargc, const char *splitchars=NULL);
-
-// For classes with a text() function, provide a function to return a String,
-// and also a standard << stream function that takes a pointer to the object.
-// We dont provide the function that takes a reference to the object
-// because it is too highly overloaded and generally doesnt work.
-class Text2Str {
-	public:
-	virtual void text(std::ostream &os) const = 0;
-	std::string str() const;
-};
-std::ostream& operator<<(std::ostream& os, const Text2Str *val);
-
-#if 0
-// Generic Activity Timer.  Lots of controls to make everybody happy.
-class ATimer {
-	double mStart;
-	//bool mActive;
-	double mLimitTime;
-	public:
-	ATimer() : mStart(0), mLimitTime(0) { }
-	ATimer(double wLimitTime) : mStart(0), mLimitTime(wLimitTime) { }
-	void start() { mStart=timef(); }
-	void stop() { mStart=0; }
-	bool active() { return !!mStart; }
-	double elapsed() { return timef() - mStart; }
-	bool expired() { return elapsed() > mLimitTime; }
-};
-#endif
-
-
-struct BitSet {
-	unsigned mBits;
-	void setBit(unsigned whichbit) { mBits |= 1<<whichbit; }
-	void clearBit(unsigned whichbit) { mBits &= ~(1<<whichbit); }
-	unsigned getBit(unsigned whichbit) const { return mBits & (1<<whichbit); }
-	bool isSet(unsigned whichbit) const { return mBits & (1<<whichbit); }
-	unsigned bits() const { return mBits; }
-	operator int(void) const { return mBits; }
-	BitSet() { mBits = 0; }
-};
-
-// Store current, min, max and compute running average and standard deviation.
-template<class Type> struct Statistic {
-	Type mCurrent, mMin, mMax;		// min,max optional initialization so you can print before adding any values.
-	unsigned mCnt;
-	double mSum;
-	//double mSum2;	// sum of squares.
-	// (Type) cast needed in case Type is an enum, stupid language.
-	Statistic() : mCurrent((Type)0), mMin((Type)0), mMax((Type)0), mCnt(0), mSum(0) /*,mSum2(0)*/ {}
-	// Set the current value and add a statisical point.
-	void addPoint(Type val) {
-		mCurrent = val;
-		if (mCnt == 0 || val < mMin) {mMin = val;}
-		if (mCnt == 0 || val > mMax) {mMax = val;}
-		mCnt++;
-		mSum += val;
-		//mSum2 += val * val;
-	}
-	Type getCurrent() const {	// Return current value.
-		return mCnt ? mCurrent : 0;
-	}
-	double getAvg() const { 			// Return average.
-		return mCnt==0 ? 0 : mSum/mCnt; 
-	};
-	//float getSD() const { 	// Return standard deviation.  Use low precision square root function.
-	//	return mCnt==0 ? 0 : sqrtf(mCnt * mSum2 - mSum*mSum) / mCnt;
-	//}
-
-	void text(std::ostream &os) const {	// Print everything in parens.
-		os << "("<<mCurrent;
-		if (mMin != mMax) {	// Not point in printing all this stuff if min == max.
-			os <<LOGVAR2("min",mMin)<<LOGVAR2("max",mMax)<<LOGVAR2("avg",getAvg());
-			if (mCnt <= 999999) {
-				os <<LOGVAR2("N",mCnt);
-			} else { // Shorten this up:
-				char buf[10], *ep;
-				sprintf(buf,"%.3g",round(mCnt));
-				if ((ep = strchr(buf,'e')) && ep[1] == '+') { strcpy(ep+1,ep+2); }
-				os << LOGVAR2("N",buf);
-			}
-			// os<<LOGVAR2("sd",getSD())  standard deviation not interesting
-		}
-		os << ")";
-		// " min="<<mMin <<" max="<<mMax <<format(" avg=%4g sd=%3g)",getAvg(),getSD());
-	}
-	// Not sure if this works:
-	//std::string statStr() const {
-	//	return (std::string)mCurrent + " min=" + (std::string) mMin +" max="+(string)mMax+ format(" avg=%4g sd=%3g",getAvg(),getSD());
-	//}
-};
-
-// This I/O mechanism is so dumb:
-std::ostream& operator<<(std::ostream& os, const Statistic<int> &stat);
-std::ostream& operator<<(std::ostream& os, const Statistic<unsigned> &stat);
-std::ostream& operator<<(std::ostream& os, const Statistic<float> &stat);
-std::ostream& operator<<(std::ostream& os, const Statistic<double> &stat);
-
-
-// Yes, they botched and left this out:
-std::ostream& operator<<(std::ostream& os, std::ostringstream& ss);
-
-std::ostream &osprintf(std::ostream &os, const char *fmt, ...) __attribute__((format (printf,2,3)));
-
-std::string replaceAll(const std::string input, const std::string search, const std::string replace);
-
-};	// namespace
-
-using namespace Utils;
-
-#endif

-- 
To view, visit https://gerrit.osmocom.org/2125
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2bfb45a1c7d01785bdb30204dba38c683a4288a9
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Alexander Chemeris <Alexander.Chemeris at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Tom Tsou <tom at tsou.cc>



More information about the gerrit-log mailing list