Remove dead code

This commit is contained in:
Nedko Arnaudov 2009-08-19 23:18:36 +03:00
parent 81a5afe4f1
commit b71fc82c9c
9 changed files with 0 additions and 809 deletions

View File

@ -1,115 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
*
**************************************************************************
* This file contains implementation of the canvas class
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "common.h"
#include "PatchageCanvas.hpp"
#include "Patchage.hpp"
#include "PatchageModule.hpp"
#include "PatchagePort.hpp"
PatchageCanvas::PatchageCanvas(Patchage* app, int width, int height) : _app(app)
{
canvas_create(width, height, &_canvas);
}
#if 0
boost::shared_ptr<PatchageModule>
PatchageCanvas::find_module(const string& name, ModuleType type)
{
for (ItemList::iterator m = _items.begin(); m != _items.end(); ++m) {
boost::shared_ptr<PatchageModule> pm = boost::dynamic_pointer_cast<PatchageModule>(*m);
if (pm && pm->identify(name, type)) {
return pm;
}
}
return boost::shared_ptr<PatchageModule>();
}
void
PatchageCanvas::connect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2)
{
_app->connect(boost::dynamic_pointer_cast<PatchagePort>(port1), boost::dynamic_pointer_cast<PatchagePort>(port2));
}
void
PatchageCanvas::disconnect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2)
{
_app->disconnect(boost::dynamic_pointer_cast<PatchagePort>(port1), boost::dynamic_pointer_cast<PatchagePort>(port2));
}
void
PatchageCanvas::status_message(const string& msg)
{
_app->status_msg(string("[Canvas] ").append(msg));
}
boost::shared_ptr<PatchagePort>
PatchageCanvas::get_port(const string& node_name, const string& port_name)
{
for (ItemList::iterator i = _items.begin(); i != _items.end(); ++i) {
const boost::shared_ptr<Item> item = *i;
const boost::shared_ptr<Module> module
= boost::dynamic_pointer_cast<Module>(item);
if (!module)
continue;
const boost::shared_ptr<Port> port = module->get_port(port_name);
if (module->name() == node_name && port)
return dynamic_pointer_cast<PatchagePort>(port);
}
return boost::shared_ptr<PatchagePort>();
}
boost::shared_ptr<PatchagePort>
PatchageCanvas::lookup_port_by_a2j_jack_port_name(
const char * a2j_jack_port_name)
{
for (ItemList::iterator i = _items.begin(); i != _items.end(); ++i)
{
const boost::shared_ptr<Item> item = *i;
const boost::shared_ptr<Module> module = boost::dynamic_pointer_cast<Module>(item);
if (!module)
continue;
PortVector ports = module->ports(); // copy
for (PortVector::iterator p = ports.begin(); p != ports.end(); ++p)
{
boost::shared_ptr<PatchagePort> port = boost::dynamic_pointer_cast<PatchagePort>(*p);
if (port->is_a2j_mapped && port->a2j_jack_port_name == a2j_jack_port_name)
{
return dynamic_pointer_cast<PatchagePort>(port);
}
}
}
return boost::shared_ptr<PatchagePort>();
}
#endif

View File

@ -1,63 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
*
**************************************************************************
* This file contains interface of the canvas class
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PATCHAGE_PATCHAGECANVAS_HPP
#define PATCHAGE_PATCHAGECANVAS_HPP
#include "common.h"
class Patchage;
class PatchageModule;
class PatchagePort;
class PatchageCanvas
{
public:
PatchageCanvas(Patchage* _app, int width, int height);
boost::shared_ptr<PatchageModule> find_module(const std::string& name, ModuleType type);
void connect(boost::shared_ptr<PatchagePort> port1, boost::shared_ptr<PatchagePort> port2);
void disconnect(boost::shared_ptr<PatchagePort> port1, boost::shared_ptr<PatchagePort> port2);
void status_message(const std::string& msg);
boost::shared_ptr<PatchagePort>
get_port(
const std::string& module_name,
const std::string& port_name);
boost::shared_ptr<PatchagePort>
lookup_port_by_a2j_jack_port_name(
const char * a2j_jack_port_name);
private:
Patchage* _app;
canvas_handle _canvas;
};
#endif // PATCHAGE_PATCHAGECANVAS_HPP

View File

@ -1,110 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
*
**************************************************************************
* This file implements the canvas module class
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PATCHAGE_PATCHAGEMODULE_HPP
#define PATCHAGE_PATCHAGEMODULE_HPP
#include "common.h"
#include "PatchageCanvas.hpp"
class PatchageModule
{
public:
PatchageModule(Patchage* app, const std::string& name, ModuleType type, double x=0, double y=0);
virtual ~PatchageModule();
bool
identify(const std::string& name, ModuleType type)
{
return _name == name && (_type == type || _type == InputOutput);
}
#if 0
void create_menu() {
_menu = new Gtk::Menu();
Gtk::Menu::MenuList& items = _menu->items();
if (_type == InputOutput) {
items.push_back(Gtk::Menu_Helpers::MenuElem("Split",
sigc::mem_fun(this, &PatchageModule::split)));
} else {
items.push_back(Gtk::Menu_Helpers::MenuElem("Join",
sigc::mem_fun(this, &PatchageModule::join)));
}
items.push_back(Gtk::Menu_Helpers::MenuElem("Disconnect All",
sigc::mem_fun(this, &PatchageModule::menu_disconnect_all)));
}
void move(double dx, double dy) {
FlowCanvas::Module::move(dx, dy);
store_location();
}
void load_location() {
boost::shared_ptr<Canvas> canvas = _canvas.lock();
if (!canvas)
return;
Coord loc;
if (_app->state_manager()->get_module_location(_name, _type, loc))
move_to(loc.x, loc.y);
else
move_to((canvas->width()/2) - 100 + rand() % 400,
(canvas->height()/2) - 100 + rand() % 400);
}
virtual void store_location() {
Coord loc(property_x().get_value(), property_y().get_value());
_app->state_manager()->set_module_location(_name, _type, loc);
}
void split() {
assert(_type == InputOutput);
_app->state_manager()->set_module_split(_name, true);
_app->refresh();
}
void join() {
assert(_type != InputOutput);
_app->state_manager()->set_module_split(_name, false);
_app->refresh();
}
virtual void show_dialog() {}
virtual void menu_disconnect_all() {
for (PortVector::iterator p = _ports.begin(); p != _ports.end(); ++p)
(*p)->disconnect_all();
}
#endif
protected:
Patchage* _app;
ModuleType _type;
std::string _name;
};
#endif // PATCHAGE_PATCHAGEMODULE_HPP

View File

@ -1,53 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
*
**************************************************************************
* This file implements the canvas port class
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PATCHAGE_PATCHAGEPORT_HPP
#define PATCHAGE_PATCHAGEPORT_HPP
#include "common.h"
enum PortType { JACK_AUDIO, JACK_MIDI };
/** A Port on a PatchageModule
*
* \ingroup OmGtk
*/
struct PatchagePort
{
PatchagePort(
canvas_module_handle module,
const std::string& name,
bool is_input,
int color);
virtual ~PatchagePort();
PortType type;
bool is_a2j_mapped;
std::string a2j_jack_port_name; // valid only if is_a2j_mapped is true
};
#endif // PATCHAGE_PATCHAGEPORT_HPP

View File

@ -1,283 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
*
**************************************************************************
* This file contains implementation of the StateManager class
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "common.h"
#include <stdexcept>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include "StateManager.hpp"
#include "Patchage.hpp"
StateManager::StateManager()
: _window_location(0, 0)
, _window_size(640, 480)
, _zoom(1.0)
{
}
bool
StateManager::get_module_location(const std::string& name, ModuleType type, Coord& loc)
{
std::map<std::string, ModuleSettings>::const_iterator i = _module_settings.find(name);
if (i == _module_settings.end())
return false;
const ModuleSettings& settings = (*i).second;
switch (type) {
case Input:
if (settings.input_location) {
loc = *settings.input_location;
return true;
}
break;
case Output:
if (settings.output_location) {
loc = *settings.output_location;
return true;
}
break;
case InputOutput:
if (settings.inout_location) {
loc = *settings.inout_location;
return true;
}
break;
default:
throw std::runtime_error("Invalid module type");
}
return false;
}
void
StateManager::set_module_location(const std::string& name, ModuleType type, Coord loc)
{
retry:
std::map<std::string, ModuleSettings>::iterator i = _module_settings.find(name);
if (i == _module_settings.end()) {
// no mapping exists, insert new element and set its split type, then retry to retrieve reference to it
_module_settings[name].split = type != InputOutput;
goto retry;
}
ModuleSettings& settings_ref = (*i).second;
switch (type) {
case Input:
settings_ref.input_location = loc;
break;
case Output:
settings_ref.output_location = loc;
break;
case InputOutput:
settings_ref.inout_location = loc;
break;
default:
throw std::runtime_error("Invalid module type");
}
}
/** Returns whether or not this module should be split.
*
* If nothing is known about the given module, @a default_val is returned (this is
* to allow driver's to request terminal ports get split by default).
*/
bool
StateManager::get_module_split(const std::string& name, bool default_val) const
{
std::map<std::string, ModuleSettings>::const_iterator i = _module_settings.find(name);
if (i == _module_settings.end())
return default_val;
return (*i).second.split;
}
void
StateManager::set_module_split(const std::string& name, bool split)
{
_module_settings[name].split = split;
}
void
StateManager::load(const std::string& filename)
{
_module_settings.clear();
std::cerr << "Loading configuration file " << filename << std::endl;
std::ifstream is;
is.open(filename.c_str(), std::ios::in);
if ( ! is.good()) {
std::cerr << "Unable to load file " << filename << "!" << std::endl;
return;
}
std::string s;
is >> s;
if (s == "window_location") {
is >> s;
_window_location.x = atoi(s.c_str());
is >> s;
_window_location.y = atoi(s.c_str());
}
is >> s;
if (s == "window_size") {
is >> s;
_window_size.x = atoi(s.c_str());
is >> s;
_window_size.y = atoi(s.c_str());
}
is >> s;
if (s != "zoom_level") {
std::string msg = "Corrupt settings file: expected \"zoom_level\", found \"";
msg.append(s).append("\"");
throw std::runtime_error(msg);
}
is >> s;
_zoom = atof(s.c_str());
Coord loc;
ModuleType type;
std::string name;
while (1) {
is >> s;
if (is.eof()) break;
// Old versions didn't quote, so need to support both :/
if (s[0] == '\"') {
if (s.length() > 1 && s[s.length()-1] == '\"') {
name = s.substr(1, s.length()-2);
} else {
name = s.substr(1);
is >> s;
while (s[s.length()-1] != '\"') {
name.append(" ").append(s);
is >> s;
}
name.append(" ").append(s.substr(0, s.length()-1));
}
} else {
name = s;
}
is >> s;
if (s == "input") type = Input;
else if (s == "output") type = Output;
else if (s == "inputoutput") type = InputOutput;
else throw std::runtime_error("Corrupt settings file.");
is >> s;
loc.x = atoi(s.c_str());
is >> s;
loc.y = atoi(s.c_str());
set_module_location(name, type, loc);
}
is.close();
}
static inline void
write_module_settings_entry(
std::ofstream& os,
const std::string& name,
const char * type,
const Coord& loc)
{
os << "\"" << name << "\"" << " " << type << " " << loc.x << " " << loc.y << std::endl;
}
void
StateManager::save(const std::string& filename)
{
std::ofstream os;
os.open(filename.c_str(), std::ios::out);
os << "window_location " << _window_location.x << " " << _window_location.y << std::endl;
os << "window_size " << _window_size.x << " " << _window_size.y << std::endl;
os << "zoom_level " << _zoom << std::endl;
for (std::map<std::string, ModuleSettings>::iterator i = _module_settings.begin(); i != _module_settings.end(); ++i) {
const ModuleSettings& settings = (*i).second;
const std::string& name = (*i).first;
if (settings.split) {
write_module_settings_entry(os, name, "input", *settings.input_location);
write_module_settings_entry(os, name, "output", *settings.output_location);
} else {
write_module_settings_entry(os, name, "inputoutput", *settings.inout_location);
}
}
os.close();
std::cerr << "Saved configuration file " << filename << std::endl;
}
float
StateManager::get_zoom()
{
return _zoom;
}
void
StateManager::set_zoom(float zoom)
{
_zoom = zoom;
}
int
StateManager::get_port_color(PortType type)
{
// Darkest tango palette colour, with S -= 6, V -= 6, w/ transparency
if (type == JACK_AUDIO)
return 0x244678C0;
else if (type == JACK_MIDI)
return 0x960909C0;
// else if (type == ALSA_MIDI)
// return 0x4A8A0EC0;
else
return 0xFF0000FF;
}

View File

@ -1,80 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
*
**************************************************************************
* This file contains interface of the StateManager class
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PATCHAGE_STATEMANAGER_HPP
#define PATCHAGE_STATEMANAGER_HPP
#include "common.h"
#include "PatchagePort.hpp"
#include <map>
struct Coord {
Coord(double x_=0, double y_=0) : x(x_), y(y_) {}
double x;
double y;
};
class StateManager
{
public:
StateManager();
void load(const std::string& filename);
void save(const std::string& filename);
bool get_module_location(const std::string& name, ModuleType type, Coord& loc);
void set_module_location(const std::string& name, ModuleType type, Coord loc);
void set_module_split(const std::string& name, bool split);
bool get_module_split(const std::string& name, bool default_val) const;
float get_zoom();
void set_zoom(float zoom);
int get_port_color(PortType type);
Coord get_window_location() { return _window_location; }
void set_window_location(Coord loc) { _window_location = loc; }
Coord get_window_size() { return _window_size; }
void set_window_size(Coord size) { _window_size = size; }
private:
struct ModuleSettings {
ModuleSettings() : split(false) {}
bool split;
boost::optional<Coord> input_location;
boost::optional<Coord> output_location;
boost::optional<Coord> inout_location;
};
std::map<std::string,ModuleSettings> _module_settings;
Coord _window_location;
Coord _window_size;
float _zoom;
};
#endif // PATCHAGE_STATEMANAGER_HPP

View File

@ -1,64 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
*
**************************************************************************
* This file contains implementation of the Widget class
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PATCHAGE_WIDGET_HPP
#define PATCHAGE_WIDGET_HPP
#include <libglademm/xml.h>
#include <boost/utility.hpp>
template <typename W>
class Widget : public boost::noncopyable {
public:
Widget(Glib::RefPtr<Gnome::Glade::Xml> xml, const std::string& name) {
init(xml, name);
}
Widget()
{
_me = 0;
}
void init(Glib::RefPtr<Gnome::Glade::Xml> xml, const std::string& name)
{
xml->get_widget(name.c_str(), _me);
}
void destroy() { delete _me; }
W* get() { return _me; }
const W* get() const { return _me; }
W* operator->() { return _me; }
const W* operator->() const { return _me; }
W& operator*() { return *_me; }
const W& operator*() const { return *_me; }
private:
W* _me;
};
#endif // PATCHAGE_WIDGET_HPP

View File

@ -1,38 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains declarations of global variables
**************************************************************************
*
* LADI Session Handler is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LADI Session Handler 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef GLOBALS_HPP__08F1016E_CB85_4758_B5CD_92E0C15F5568__INCLUDED
#define GLOBALS_HPP__08F1016E_CB85_4758_B5CD_92E0C15F5568__INCLUDED
#if defined(PATCHAGE_WIDGET_HPP)
extern Glib::RefPtr<Gnome::Glade::Xml> g_xml;
#endif
#if defined(PATCHAGE_PATCHAGE_HPP)
extern Patchage * g_app;
#endif
#endif // #ifndef GLOBALS_HPP__08F1016E_CB85_4758_B5CD_92E0C15F5568__INCLUDED

View File

@ -266,9 +266,6 @@ def build(bld):
for source in [
'main.c',
#'Patchage.cpp',
#'PatchageCanvas.cpp',
#'StateManager.cpp',
#'lash_client.cpp',
#'lash_proxy.cpp',
#'load_projects_dialog.cpp',