|
From: <fli...@li...> - 2026-04-27 12:49:49
|
unknown user pushed a commit to branch next
in repository simgear.
The following commit(s) were added to refs/heads/next by this push:
new adbc5631 Devops/remove dead code
adbc5631 is described below
SF URL: http://sourceforge.net/p/flightgear/simgear/ci/adbc5631906ec521ae03d77073a5b579fd9a7d73/
Commit: adbc5631906ec521ae03d77073a5b579fd9a7d73
Author: James Turner
Committer: James Turner
AuthorDate: Thu Apr 23 13:15:21 2026 +0100
Devops/remove dead code
---
simgear/misc/CMakeLists.txt | 6 ---
simgear/misc/interpolator.cxx | 100 -----------------------------------
simgear/misc/interpolator.hxx | 58 --------------------
simgear/misc/stopwatch.hxx | 102 ------------------------------------
simgear/misc/tabbed_values.cxx | 88 -------------------------------
simgear/misc/tabbed_values.hxx | 44 ----------------
simgear/misc/tabbed_values_test.cxx | 79 ----------------------------
7 files changed, 477 deletions(-)
diff --git a/simgear/misc/CMakeLists.txt b/simgear/misc/CMakeLists.txt
index 12f77750..a21ebc71 100644
--- a/simgear/misc/CMakeLists.txt
+++ b/simgear/misc/CMakeLists.txt
@@ -24,12 +24,10 @@ set(SOURCES
argparse.cxx
inputvalue.cxx
inputcolor.cxx
- interpolator.cxx
sg_dir.cxx
sg_path.cxx
sg_hash.cxx
strutils.cxx
- tabbed_values.cxx
texcoord.cxx
)
@@ -42,10 +40,7 @@ if (APPLE)
endif()
target_sources(SimGearCore PRIVATE ${SOURCES}
- interpolator.hxx
sg_hash.hxx
- stopwatch.hxx
- tabbed_values.hxx
texcoord.hxx
lru_cache.hxx
${HEADERS})
@@ -55,7 +50,6 @@ if(ENABLE_TESTS)
add_simgear_autotest(test_argparse argparse_test.cxx)
add_simgear_autotest(test_CSSBorder CSSBorder_test.cxx)
-add_simgear_autotest(test_tabbed_values tabbed_values_test.cxx)
add_simgear_autotest(test_strutils strutils_test.cxx)
add_simgear_autotest(test_path path_test.cxx )
add_simgear_autotest(test_sg_dir sg_dir_test.cxx)
diff --git a/simgear/misc/interpolator.cxx b/simgear/misc/interpolator.cxx
deleted file mode 100644
index 9223ced5..00000000
--- a/simgear/misc/interpolator.cxx
+++ /dev/null
@@ -1,100 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1-or-later
-// SPDX-FileCopyrightText: 2003 Andrew J. Ross - an...@pl...
-
-/**
- * @file
- * @brief Subsystem that manages smooth linear interpolation of property values across multiple data points and arbitrary time intervals.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <simgear_config.h>
-#endif
-
-#include "interpolator.hxx"
-
-void SGInterpolator::addNew(SGPropertyNode* prop, int nPoints)
-{
- // Set the property type to a double, if it isn't already, and
- // make sure we aren't already managing this node.
- prop->setDoubleValue(prop->getDoubleValue());
- cancel(prop);
-
- Interp* iterp = new Interp();
- iterp->target = prop;
- iterp->nPoints = nPoints;
- iterp->curve = new double[2*nPoints];
-
- // Dirty trick: leave the new value sitting in _list to avoid
- // having to return a pointer to a private type.
- iterp->next = _list;
- _list = iterp;
-}
-
-void SGInterpolator::interpolate(SGPropertyNode* prop, int nPoints,
- double* values, double* deltas)
-{
- addNew(prop, nPoints);
- for(int i=0; i<nPoints; i++) {
- _list->dt(i) = deltas[i];
- _list->val(i) = values[i];
- }
-}
-
-void SGInterpolator::interpolate(SGPropertyNode* prop, double val, double dt)
-{
- addNew(prop, 1);
- _list->dt(0) = dt;
- _list->val(0) = val;
-}
-
-//
-// Delete all the list elements where "expr" is true.
-//
-// Silly preprocessor hack to avoid writing the linked list code in
-// two places. You would think that an STL set would be the way to
-// go, but I had terrible trouble getting it to work with the
-// dynamically allocated "curve" member. Frankly, this is easier to
-// write, and the code is smaller to boot...
-//
-#define DELETE_WHERE(EXPR)\
-Interp *p = _list, **last = &_list; \
-while(p) { \
- if(EXPR) { \
- *last = p->next; \
- delete p; \
- p = (*last) ? (*last)->next : 0; \
- } else { \
- last = &(p->next); \
- p = p->next; } }
-
-void SGInterpolator::cancel(SGPropertyNode* prop)
-{
- DELETE_WHERE(p->target == prop)
-}
-
-void SGInterpolator::update(double dt)
-{
- DELETE_WHERE(interp(p, dt))
-}
-
-// This is the where the only "real" work happens. Walk through the
-// data points until we find one with some time left, slurp it up and
-// repeat until we run out of dt.
-bool SGInterpolator::interp(Interp* rec, double dt)
-{
- double val = rec->target->getDoubleValue();
- int i;
- for(i=0; i < rec->nPoints; i++) {
- if(rec->dt(i) > 0 && dt < rec->dt(i)) {
- val += (dt / rec->dt(i)) * (rec->val(i) - val);
- rec->dt(i) -= dt;
- break;
- }
- dt -= rec->dt(i);
- val = rec->val(i);
- }
- rec->target->setDoubleValue(val);
-
- // Return true if this one is done
- return i == rec->nPoints;
-}
diff --git a/simgear/misc/interpolator.hxx b/simgear/misc/interpolator.hxx
deleted file mode 100644
index 56b70593..00000000
--- a/simgear/misc/interpolator.hxx
+++ /dev/null
@@ -1,58 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1-or-later
-// SPDX-FileCopyrightText: 2003 Andrew J. Ross <an...@pl...>
-
-/**
- * @file
- * @brief Subsystem that manages smooth linear interpolation of property values across multiple data points and arbitrary time intervals.
- */
-
-#pragma once
-
-#include <simgear/props/props.hxx>
-#include <simgear/structure/subsystem_mgr.hxx>
-
-// TODO: support a callback upon interpolation completion so that user
-// code can register another one immediately without worrying about
-// timer aliasing.
-
-class SGInterpolator : public SGSubsystem
-{
-public:
- SGInterpolator() { _list = 0; }
-
- // Subsystem API.
- void update(double delta_time_sec) override;
-
- // Subsystem identification.
- static const char* staticSubsystemClassId() { return "interpolator"; }
-
- // Simple method that interpolates a double property value from
- // its current value (default of zero) to the specified target
- // over the specified time.
- void interpolate(SGPropertyNode* prop, double value, double dt_sec);
-
- // More elaborate version that takes a pointer to lists of
- // arbitrary size.
- void interpolate(SGPropertyNode* prop, int nPoints,
- double* values, double* deltas);
-
- // Cancels any interpolation of the specified property, leaving
- // its value at the current (mid-interpolation) state.
- void cancel(SGPropertyNode* prop);
-
-private:
- struct Interp {
- SGPropertyNode_ptr target;
- int nPoints;
- double* curve; // time0, val0, time1, val1, ...
- Interp* next;
-
- virtual ~Interp() { delete[] curve; }
- double& dt(int i) { return curve[2*i]; }
- double& val(int i) { return curve[2*i + 1]; }
- };
- Interp* _list;
-
- bool interp(Interp* rec, double dt);
- void addNew(SGPropertyNode* prop, int nPoints);
-};
diff --git a/simgear/misc/stopwatch.hxx b/simgear/misc/stopwatch.hxx
deleted file mode 100644
index 59405a5d..00000000
--- a/simgear/misc/stopwatch.hxx
+++ /dev/null
@@ -1,102 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1-or-later
-// SPDX-FileCopyrightText: 1997-1998 Todd Veldhuizen <tve...@se...>
-
-/**
- * @file
- * @brief Timer class, for use in benchmarking
- */
-
-// This class is not portable to non System V platforms.
-// It will need to be rewritten for Windows, NT, Mac.
-// NEEDS_WORK
-
-#ifndef _STOPWATCH_HXX
-#define _STOPWATCH_HXX
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#if defined(__linux__) && ! defined(HAVE_GETRUSAGE)
-# define HAVE_GETRUSAGE
-#endif
-
-#if defined( WIN32 ) && defined( HAVE_GETRUSAGE )
-# undef HAVE_GETRUSAGE
-#endif // WIN32
-
-#if defined( HAVE_GETRUSAGE )
-# if defined( __FreeBSD__ )
-# include <sys/types.h>
-# endif
-# include <sys/time.h>
-# include <sys/resource.h>
-# include <unistd.h>
-#elif defined( WIN32 )
-# include <windows.h>
-#else
-# include <time.h>
-#endif
-
-/**
- * A high resolutions timing class
- */
-class StopWatch {
-
-public:
- /** Constructor */
- StopWatch() {
- // state_ = uninitialized;
- }
-
- /** Start counting time */
- void start() {
- // state_ = running;
- t1_ = systemTime();
- }
-
- /** Stop counting time */
- void stop() {
- t2_ = systemTime();
- // BZPRECONDITION(state_ == running);
- // state_ = stopped;
- }
-
- /** @return the elapsed time between start and stop */
- double elapsedSeconds()
- {
- // BZPRECONDITION(state_ == stopped);
- return t2_ - t1_;
- }
-
-private:
- StopWatch(StopWatch&) { }
- void operator=(StopWatch&) { }
-
- double systemTime()
- {
-#if defined( HAVE_GETRUSAGE )
- getrusage(RUSAGE_SELF, &resourceUsage_);
- double seconds = resourceUsage_.ru_utime.tv_sec
- + resourceUsage_.ru_stime.tv_sec;
- double micros = resourceUsage_.ru_utime.tv_usec
- + resourceUsage_.ru_stime.tv_usec;
- return seconds + micros/1.0e6;
-#elif defined( WIN32 )
- return double(GetTickCount()) * double(1e-3);
-#else
- return clock() / (double) CLOCKS_PER_SEC;
-#endif
- }
-
-// enum { uninitialized, running, stopped } state_;
-
-#if defined( HAVE_GETRUSAGE )
- struct rusage resourceUsage_;
-#endif
-
- double t1_, t2_;
-};
-
-#endif // _STOPWATCH_HXX
-
diff --git a/simgear/misc/tabbed_values.cxx b/simgear/misc/tabbed_values.cxx
deleted file mode 100644
index 2ba2bc56..00000000
--- a/simgear/misc/tabbed_values.cxx
+++ /dev/null
@@ -1,88 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1-or-later
-// SPDX-FileCopyrightText: 2003 James Turner
-
-/**
- * @file
- * @brief parse tab separated strings into fields
- */
-
-// $Id$
-
-#include <cstdlib>
-#include <assert.h>
-
-#include "tabbed_values.hxx"
-
-
-SGTabbedValues::SGTabbedValues(const char *line)
-{
- assert(line);
- _fields.push_back(const_cast<char*>(line));
-}
-
-const char* SGTabbedValues::fieldAt(const unsigned int index) const
-{
- // we already computed that offset, cool
- if (_fields.size() > index)
- return _fields[index];
-
- while (_fields.size() <= index) {
- char* nextField = _fields.back();
- if (*nextField=='\0') return NULL; // we went off the end
-
- while (*nextField != '\t') {
- if (*nextField=='\0') return NULL; // we went off the end
- ++nextField;
- }
- _fields.push_back(++nextField);
- }
-
- return _fields.back();
-}
-
-string SGTabbedValues::operator[](const unsigned int offset) const
-{
- const char *data = fieldAt(offset);
- char* endPtr = const_cast<char*>(data);
- int len = 0;
- while ((*endPtr != '\0') && (*endPtr != '\t')) {
- ++len;
- ++endPtr;
- }
- return string(fieldAt(offset), len);
-}
-
-bool SGTabbedValues::isValueAt(const unsigned int offset) const
-{
- const char *data = fieldAt(offset);
- return data && (*data != '\t'); // must be non-NULL and non-tab
-}
-
-char SGTabbedValues::getCharAt(const unsigned int offset) const
-{
- const char *data = fieldAt(offset);
- if (!data || (*data == '\t'))
- return 0;
-
- return *data;
-}
-
-double SGTabbedValues::getDoubleAt(const unsigned int offset) const
-{
- const char *data = fieldAt(offset);
- if (!data || (*data == '\t'))
- return 0;
-
- /* this is safe because strtod will stop parsing when it sees an unrecogznied
- character, which includes tab. */
- return std::strtod(data, NULL);
-}
-
-long SGTabbedValues::getLongAt(const unsigned int offset) const
-{
- const char *data = fieldAt(offset);
- if (!data || (*data == '\t'))
- return 0;
-
- return std::strtol(data, NULL, 0);
-}
diff --git a/simgear/misc/tabbed_values.hxx b/simgear/misc/tabbed_values.hxx
deleted file mode 100644
index 1eb60a47..00000000
--- a/simgear/misc/tabbed_values.hxx
+++ /dev/null
@@ -1,44 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1-or-later
-// SPDX-FileCopyrightText: 2003 James Turner
-
-/**
- * @file
- * @brief parse tab separated strings into fields
- */
-
-// $Id$
-
-#ifndef SG_TABBED_VALUES_HXX
-#define SG_TABBED_VALUES_HXX
-
-#include <simgear/compiler.h>
-
-#include <vector>
-#include <string>
-
-using std::vector;
-using std::string;
-
-class SGTabbedValues
-{
-public:
- SGTabbedValues(const char* line);
-
- string operator[](const unsigned int) const;
-
- bool isValueAt(const unsigned int) const;
-
- double getDoubleAt(const unsigned int) const;
- char getCharAt(const unsigned int) const;
- long getLongAt(const unsigned int) const;
-private:
- const char* fieldAt(const unsigned int offset) const;
-
- /** this is first character of each field, if the field is empty
- it will be the tab character. It is lazily built as needed, so
- if only the first field is accessed (which is a common case) we
- don't iterative over the whole line. */
- mutable vector<char*> _fields;
-};
-
-#endif
diff --git a/simgear/misc/tabbed_values_test.cxx b/simgear/misc/tabbed_values_test.cxx
deleted file mode 100644
index 1926776a..00000000
--- a/simgear/misc/tabbed_values_test.cxx
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1-or-later
-// SPDX-FileCopyrightText: 2003 James Turner
-
-/**
- * @file
- * @brief Unit Test parse tab separated strings into fields
- */
-
-////////////////////////////////////////////////////////////////////////
-// Test harness.
-////////////////////////////////////////////////////////////////////////
-
-#include <simgear/compiler.h>
-
-#include <iostream>
-#include "tabbed_values.hxx"
-
-using std::cout;
-using std::cerr;
-using std::endl;
-
-
-int main (int ac, char ** av)
-{
- const char* string1 = "Hello\tWorld\t34\tZ\t\tThere Is No Spoon";
-
- SGTabbedValues tv(string1);
-
- if (tv[0] != "Hello") {
- cerr << "failed to read string at index 0" << endl;
- return 1;
- }
-
- if (tv[1] != "World") {
- cerr << "failed to read string at index 1" << endl;
- return 1;
- }
-
- if (tv[2] != "34") {
- cerr << "failed to read string at index 2" << endl;
- return 1;
- }
-
- double dval = tv.getDoubleAt(2);
- if (dval != 34.0) {
- cerr << "failed to read double at index 2" << endl;
- return 2;
- }
-
- char cval = tv.getCharAt(3);
- if (cval != 'Z') {
- cerr << "failed to read char at index 3" << endl;
- return 1;
- }
-
- cval = tv.getCharAt(0);
- if (cval != 'H') {
- cerr << "failed to read char at index 0" << endl;
- return 1;
- }
-
- if (tv.isValueAt(4)) {
- cerr << "didn't identify skipped value correctly" << endl;
- return 3;
- }
-
- if (!tv.isValueAt(3)) {
- cerr << "didn't identify present value correctly" << endl;
- return 3;
- }
-
- if (tv[5] != "There Is No Spoon") {
- cerr << "failed to read string at index 5 (got [" << tv[5] << "]" << endl;
- return 1;
- }
-
- cout << "all tests passed successfully!" << endl;
- return 0;
-}
|