<commit_before>// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/frame/contents_container.h"

#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"

// static
const char ContentsContainer::kViewClassName[] =
    "browser/ui/views/frame/ContentsContainer";

namespace {

int PreviewHeightInPixels(int parent_height, int preview_height,
                          InstantSizeUnits preview_height_units) {
  preview_height = std::max(0, preview_height);
  switch (preview_height_units) {
    case INSTANT_SIZE_PERCENT:
      return std::min(parent_height, (parent_height * preview_height) / 100);

    case INSTANT_SIZE_PIXELS:
      return std::min(parent_height, preview_height);
  }
  NOTREACHED() << "unknown units: " << preview_height_units;
  return 0;
}

// This class draws the drop shadow below the preview when the non-NTP preview
// doesn't fill up the entire content page.
// This class is owned by ContentsContainer, which:
// - adds it as child when shadow is needed
// - removes it as child when shadow is not needed or when preview is nuked or
//   when preview is removed as child
// - always makes sure it's the 3rd child in the view hierarchy i.e. after
//   active and preview.
class ShadowView : public views::View {
 public:
  ShadowView() {
    drop_shadow_ = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
        IDR_PREVIEW_DROP_SHADOW);

    SetPaintToLayer(true);
    SetFillsBoundsOpaquely(false);
    set_owned_by_client();
  }

  virtual ~ShadowView() {}

  virtual gfx::Size GetPreferredSize() OVERRIDE {
    // Only height really matters, since images will be stretched horizontally
    // across.
    return drop_shadow_.size();
  }

 protected:
  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
    // Stretch drop shadow horizontally across.
    canvas->DrawImageInt(
        drop_shadow_,
        0, 0, drop_shadow_.width(), drop_shadow_.height(),
        0, 0, width(), drop_shadow_.height(),
        true);
  }

 private:
  gfx::ImageSkia drop_shadow_;

  DISALLOW_COPY_AND_ASSIGN(ShadowView);
};

}  // namespace

ContentsContainer::ContentsContainer(views::WebView* active)
    : active_(active),
      preview_(NULL),
      preview_web_contents_(NULL),
      draw_drop_shadow_(false),
      active_top_margin_(0),
      preview_height_(100),
      preview_height_units_(INSTANT_SIZE_PERCENT) {
  AddChildView(active_);
}

ContentsContainer::~ContentsContainer() {
  RemoveShadowView(true);
}

void ContentsContainer::MakePreviewContentsActiveContents() {
  DCHECK(preview_);

  active_ = preview_;
  preview_ = NULL;
  preview_web_contents_ = NULL;
  // Since |preview_| has been nuked, shadow view is not needed anymore.
  // Note that the previous |active_| will be deleted by caller (see
  // BrowserView::ActiveTabChanged()) after this call, hence removing the old
  // |active_| as a child, and making the new |active_| (which is the previous
  // |preview_|) the first child.
  RemoveShadowView(true);
  Layout();
}

void ContentsContainer::SetPreview(views::WebView* preview,
                                   content::WebContents* preview_web_contents,
                                   const chrome::search::Mode& search_mode,
                                   int height,
                                   InstantSizeUnits units,
                                   bool draw_drop_shadow) {
  // If drawing drop shadow, clip the bottom 1-px-thick separator out of
  // preview.
  // TODO(kuan): remove this when GWS gives chrome the height without the
  // separator.
#if !defined(OS_WIN)
  if (draw_drop_shadow)
    --height;
#endif  // !defined(OS_WIN)

  if (preview_ == preview && preview_web_contents_ == preview_web_contents &&
      search_mode_ == search_mode && preview_height_ == height &&
      preview_height_units_ == units && draw_drop_shadow_ == draw_drop_shadow) {
    return;
  }

  if (preview_ != preview) {
    if (preview_) {
      // Order of children is important: always |active_| first, then
      // |preview_|, then shadow view if necessary.  To make sure the next view
      // is added in the right order, remove shadow view every time |preview_|
      // is removed.
      RemoveShadowView(false);
      RemoveChildView(preview_);
    }
    preview_ = preview;
    if (preview_)
      AddChildView(preview_);
  }

  preview_web_contents_ = preview_web_contents;
  search_mode_ = search_mode;
  preview_height_ = height;
  preview_height_units_ = units;
  draw_drop_shadow_ = draw_drop_shadow;

  // Add or remove shadow view as needed.
  if (preview_ && draw_drop_shadow_) {
#if !defined(OS_WIN)
    if (!shadow_view_.get())  // Shadow view has not been created.
      shadow_view_.reset(new ShadowView());
    if (!shadow_view_->parent())  // Shadow view has not been added.
      AddChildView(shadow_view_.get());
#endif  // !defined(OS_WIN)
  } else {
    RemoveShadowView(true);
  }

  Layout();
}

void ContentsContainer::MaybeStackPreviewAtTop() {
  if (!preview_)
    return;
  // To force |preview_| to the topmost in the z-order, remove it, then add it
  // back.
  // See comments in SetPreview() for why shadow view is removed.
  bool removed_shadow = RemoveShadowView(false);
  RemoveChildView(preview_);
  AddChildView(preview_);
  if (removed_shadow)  // Add back shadow view if it was removed.
    AddChildView(shadow_view_.get());
  Layout();
}

void ContentsContainer::SetActiveTopMargin(int margin) {
  if (active_top_margin_ == margin)
    return;

  active_top_margin_ = margin;
  // Make sure we layout next time around. We need this in case our bounds
  // haven't changed.
  InvalidateLayout();
}

gfx::Rect ContentsContainer::GetPreviewBounds() const {
  gfx::Point screen_loc;
  ConvertPointToScreen(this, &screen_loc);
  return gfx::Rect(screen_loc, size());
}

bool ContentsContainer::IsPreviewFullHeight(
    int preview_height,
    InstantSizeUnits preview_height_units) const {
  int height_in_pixels = PreviewHeightInPixels(height(), preview_height,
                                               preview_height_units);
  return height_in_pixels == height();
}

void ContentsContainer::Layout() {
  int content_y = active_top_margin_;
  int content_height = std::max(0, height() - content_y);

  active_->SetBounds(0, content_y, width(), content_height);

  if (preview_) {
    // On NTP, preview starts where content starts vertically, in case there's
    // a detached bookmark bar.
    int y = search_mode_.is_ntp() ? content_y : 0;
    preview_->SetBounds(0, y, width(),
                        PreviewHeightInPixels(height(), preview_height_,
                                              preview_height_units_));
    if (draw_drop_shadow_) {
#if !defined(OS_WIN)
      DCHECK(shadow_view_.get() && shadow_view_->parent());
      shadow_view_->SetBounds(0, preview_->bounds().height(), width(),
                              shadow_view_->GetPreferredSize().height());
#endif  // !defined(OS_WIN)
    }
  }

  // Need to invoke views::View in case any views whose bounds didn't change
  // still need a layout.
  views::View::Layout();
}

bool ContentsContainer::RemoveShadowView(bool delete_view) {
  if (!shadow_view_.get())
    return false;

  if (!shadow_view_->parent()) {
    if (delete_view)
      shadow_view_.reset(NULL);
    return false;
  }

  RemoveChildView(shadow_view_.get());
  if (delete_view)
    shadow_view_.reset(NULL);
  return true;
}

std::string ContentsContainer::GetClassName() const {
  return kViewClassName;
}
<commit_msg>alternate ntp: only remove drop shadow when preview is nuked<commit_after>// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/frame/contents_container.h"

#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"

// static
const char ContentsContainer::kViewClassName[] =
    "browser/ui/views/frame/ContentsContainer";

namespace {

int PreviewHeightInPixels(int parent_height, int preview_height,
                          InstantSizeUnits preview_height_units) {
  preview_height = std::max(0, preview_height);
  switch (preview_height_units) {
    case INSTANT_SIZE_PERCENT:
      return std::min(parent_height, (parent_height * preview_height) / 100);

    case INSTANT_SIZE_PIXELS:
      return std::min(parent_height, preview_height);
  }
  NOTREACHED() << "unknown units: " << preview_height_units;
  return 0;
}

// This class draws the drop shadow below the preview when the non-NTP preview
// doesn't fill up the entire content page.
// This class is owned by ContentsContainer, which:
// - adds it as child when shadow is needed
// - removes it as child when shadow is not needed or when preview is nuked or
//   when preview is removed as child
// - always makes sure it's the 3rd child in the view hierarchy i.e. after
//   active and preview.
class ShadowView : public views::View {
 public:
  ShadowView() {
    drop_shadow_ = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
        IDR_PREVIEW_DROP_SHADOW);

    SetPaintToLayer(true);
    SetFillsBoundsOpaquely(false);
    set_owned_by_client();
  }

  virtual ~ShadowView() {}

  virtual gfx::Size GetPreferredSize() OVERRIDE {
    // Only height really matters, since images will be stretched horizontally
    // across.
    return drop_shadow_.size();
  }

 protected:
  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
    // Stretch drop shadow horizontally across.
    canvas->DrawImageInt(
        drop_shadow_,
        0, 0, drop_shadow_.width(), drop_shadow_.height(),
        0, 0, width(), drop_shadow_.height(),
        true);
  }

 private:
  gfx::ImageSkia drop_shadow_;

  DISALLOW_COPY_AND_ASSIGN(ShadowView);
};

}  // namespace

ContentsContainer::ContentsContainer(views::WebView* active)
    : active_(active),
      preview_(NULL),
      preview_web_contents_(NULL),
      draw_drop_shadow_(false),
      active_top_margin_(0),
      preview_height_(100),
      preview_height_units_(INSTANT_SIZE_PERCENT) {
  AddChildView(active_);
}

ContentsContainer::~ContentsContainer() {
  RemoveShadowView(true);
}

void ContentsContainer::MakePreviewContentsActiveContents() {
  DCHECK(preview_);

  active_ = preview_;
  preview_ = NULL;
  preview_web_contents_ = NULL;
  // Since |preview_| has been nuked, shadow view is not needed anymore.
  // Note that the previous |active_| will be deleted by caller (see
  // BrowserView::ActiveTabChanged()) after this call, hence removing the old
  // |active_| as a child, and making the new |active_| (which is the previous
  // |preview_|) the first child.
  RemoveShadowView(true);
  Layout();
}

void ContentsContainer::SetPreview(views::WebView* preview,
                                   content::WebContents* preview_web_contents,
                                   const chrome::search::Mode& search_mode,
                                   int height,
                                   InstantSizeUnits units,
                                   bool draw_drop_shadow) {
  // If drawing drop shadow, clip the bottom 1-px-thick separator out of
  // preview.
  // TODO(kuan): remove this when GWS gives chrome the height without the
  // separator.
#if !defined(OS_WIN)
  if (draw_drop_shadow)
    --height;
#endif  // !defined(OS_WIN)

  if (preview_ == preview && preview_web_contents_ == preview_web_contents &&
      search_mode_ == search_mode && preview_height_ == height &&
      preview_height_units_ == units && draw_drop_shadow_ == draw_drop_shadow) {
    return;
  }

  if (preview_ != preview) {
    if (preview_) {
      // Order of children is important: always |active_| first, then
      // |preview_|, then shadow view if necessary.  To make sure the next view
      // is added in the right order, remove shadow view every time |preview_|
      // is removed.
      RemoveShadowView(false);
      RemoveChildView(preview_);
    }
    preview_ = preview;
    if (preview_)
      AddChildView(preview_);
  }

  preview_web_contents_ = preview_web_contents;
  search_mode_ = search_mode;
  preview_height_ = height;
  preview_height_units_ = units;
  draw_drop_shadow_ = draw_drop_shadow;

  // Add shadow view if there's preview and drop shadow is needed.
  // Remove shadow view if there's no preview.
  // If there's preview and drop shadow is not needed, that means the partial-
  // height preview is going to be full-height.  Don't remove the shadow view
  // yet because its layered view will disappear before the non-layered preview
  // is repainted at the full height, leaving no separator between the preview
  // and active contents.  When the preview is repainted at the full height, the
  // shadow view, which remains at the original position below the partial-
  // height preview, will automatically be obscured the full-height preview.
  if (preview_ && draw_drop_shadow_) {
#if !defined(OS_WIN)
    if (!shadow_view_.get())  // Shadow view has not been created.
      shadow_view_.reset(new ShadowView());
    if (!shadow_view_->parent())  // Shadow view has not been added.
      AddChildView(shadow_view_.get());
#endif  // !defined(OS_WIN)
  } else if (!preview_) {
    RemoveShadowView(true);
  }

  Layout();
}

void ContentsContainer::MaybeStackPreviewAtTop() {
  if (!preview_)
    return;
  // To force |preview_| to the topmost in the z-order, remove it, then add it
  // back.
  // See comments in SetPreview() for why shadow view is removed.
  bool removed_shadow = RemoveShadowView(false);
  RemoveChildView(preview_);
  AddChildView(preview_);
  if (removed_shadow)  // Add back shadow view if it was removed.
    AddChildView(shadow_view_.get());
  Layout();
}

void ContentsContainer::SetActiveTopMargin(int margin) {
  if (active_top_margin_ == margin)
    return;

  active_top_margin_ = margin;
  // Make sure we layout next time around. We need this in case our bounds
  // haven't changed.
  InvalidateLayout();
}

gfx::Rect ContentsContainer::GetPreviewBounds() const {
  gfx::Point screen_loc;
  ConvertPointToScreen(this, &screen_loc);
  return gfx::Rect(screen_loc, size());
}

bool ContentsContainer::IsPreviewFullHeight(
    int preview_height,
    InstantSizeUnits preview_height_units) const {
  int height_in_pixels = PreviewHeightInPixels(height(), preview_height,
                                               preview_height_units);
  return height_in_pixels == height();
}

void ContentsContainer::Layout() {
  int content_y = active_top_margin_;
  int content_height = std::max(0, height() - content_y);

  active_->SetBounds(0, content_y, width(), content_height);

  if (preview_) {
    preview_->SetBounds(0, 0, width(),
                        PreviewHeightInPixels(height(), preview_height_,
                                              preview_height_units_));
    if (draw_drop_shadow_) {
#if !defined(OS_WIN)
      DCHECK(shadow_view_.get() && shadow_view_->parent());
      shadow_view_->SetBounds(0, preview_->bounds().height(), width(),
                              shadow_view_->GetPreferredSize().height());
#endif  // !defined(OS_WIN)
    }
  }

  // Need to invoke views::View in case any views whose bounds didn't change
  // still need a layout.
  views::View::Layout();
}

bool ContentsContainer::RemoveShadowView(bool delete_view) {
  if (!shadow_view_.get())
    return false;

  if (!shadow_view_->parent()) {
    if (delete_view)
      shadow_view_.reset(NULL);
    return false;
  }

  RemoveChildView(shadow_view_.get());
  if (delete_view)
    shadow_view_.reset(NULL);
  return true;
}

std::string ContentsContainer::GetClassName() const {
  return kViewClassName;
}
<|endoftext|>


<commit_before>////////////////////////////////////////////////////////////////////////////////
//
// cagey-engine - Toy 3D Engine
// Copyright (c) 2014 Kyle Girard <theycallmecoach@gmail.com>
//
// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef CAGEY_CORE_SIGNAL_HH_
#define CAGEY_CORE_SIGNAL_HH_

#include <functional>
#include <map>
#include <memory>

namespace cagey {
namespace core {

template <typename> class Signal;

template <typename Func>
class Connection {
  friend class Signal<Func>;
public:
  auto disconnect() -> bool {
    if (mSignal) {
      return mSignal->disconnect(*this);
    }
    return false;
  }
  Connection(Connection<Func> const & other) = default;

protected:
  Connection(int id, Signal<Func> * signal) : mId{id}, mSignal{signal} { }
  Signal<Func>* mSignal;
  int mId;
};

template <typename Func>
class ScopedConnection : public Connection<Func> {
public:
  explicit ScopedConnection(Connection<Func> const && con) : Connection<Func>{con}{}
  ~ScopedConnection() {
    Connection<Func>::disconnect();
  }
};

/**
* A Signal represents the subject in the Observer/Subject pattern.  Observers can register 'slots'
* to receive messages from the Signal.
*/
template <typename Func>
class Signal {
public:
  using Function = std::function<Func>;
  using Connection = Connection<Func>;
  using ScopedConnection = ScopedConnection<Func>;

  /**
  * Default constructor
  */
  Signal() : mConnectionId{0} {
  }

  ~Signal() {
    mCallbacks.clear();
  }

  auto connect(Function const & func) -> Connection {
    int conId = mConnectionId++;
    mCallbacks.emplace(std::make_pair(conId, std::make_shared<Function>(func)));
    return Connection{conId, this};
  }

  auto disconnect(Connection const & con) -> bool {
    return mCallbacks.erase(con.mId) > 0;
  }

  template<typename... Args>
  auto operator() (Args... args) -> void {
    for (auto & cb : mCallbacks) {
      if (cb.second) {
        (*cb.second)(args...);
      }
    }
  }
  Signal(Signal const &) = delete;
  auto operator=(Signal const &) = delete;

private:
  std::map<int, std::shared_ptr<Function>> mCallbacks;
  int mConnectionId;
};

//Idea for these functions taken from here: https://testbit.eu/cpp11-signal-system-performance/
//these provide a short hand to std::bind

/// This function creates a std::function by binding @a object to the member function pointer @a method.
template<class Instance, class Class, class R, class... Args> std::function<R (Args...)>
slot (Instance &object, R (Class::*method) (Args...))
{
  return [&object, method] (Args... args) { return (object .* method) (args...); };
}

/// This function creates a std::function by binding @a object to the member function pointer @a method.
template<class Class, class R, class... Args> std::function<R (Args...)>
slot (Class *object, R (Class::*method) (Args...))
{
  return [object, method] (Args... args) { return (object ->* method) (args...); };
}

} //namespace core
} //namespace cagey

#endif //CAGEY_CORE_SIGNAL_HH_
<commit_msg>Added comments to signal<commit_after>////////////////////////////////////////////////////////////////////////////////
//
// cagey-engine - Toy 3D Engine
// Copyright (c) 2014 Kyle Girard <theycallmecoach@gmail.com>
//
// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef CAGEY_CORE_SIGNAL_HH_
#define CAGEY_CORE_SIGNAL_HH_

#include <functional>
#include <map>
#include <memory>

namespace cagey {
namespace core {

template <typename> class Signal;

/**
 * Represents a connection between a signal and a slot (function).  Can
 * be used to disconnect from a signal.
 */
template <typename Func>
class Connection {
  friend class Signal<Func>;
public:
  /**
   * Disconnects a signal and slot
   *
   * @return true if the disconnect was successful
   */
  auto disconnect() -> bool {
    if (mSignal) {
      return mSignal->disconnect(*this);
    }
    return false;
  }

  /**
   * Default copy constructor
   *
   * @param other an other Connection
   */
  Connection(Connection<Func> const & other) = default;

protected:
  /**
   * Protected constructor to prevent unauthorized construction
   */
  Connection(int id, Signal<Func> * signal) : mId{id}, mSignal{signal} { }
  /// Non-owning point to the signal end of the connection
  Signal<Func>* mSignal;
  /// Unique id for this connection
  int mId;
};

/**
 * Connection between a Signal and a slot(function) that disconnects when
 * it is destroyed.
 */
template <typename Func>
class ScopedConnection : public Connection<Func> {
public:
  explicit ScopedConnection(Connection<Func> const && con) : Connection<Func>{con}{}
  ~ScopedConnection() {
    Connection<Func>::disconnect();
  }
};

/**
 * A Signal represents the subject in the Observer/Subject pattern.  Observers
 * can register 'slots' to receive messages from the Signal.  A slot can be
 * any function with the matching signature.
 */
template <typename Func>
class Signal {
public:
  using Function = std::function<Func>;
  using Connection = Connection<Func>;
  using ScopedConnection = ScopedConnection<Func>;

  /**
   * Default constructor
   */
  Signal() : mConnectionId{0} {}

  /**
   * Default Destructor
   */
  ~Signal() {
    mCallbacks.clear();
  }

  /**
   * Register the given function to be called when this signal emits a signal
   *
   * @param func the function to be called when emiting a signal
   * @return a connection between this signal and the given function
   */
  auto connect(Function const & func) -> Connection {
    int conId = mConnectionId++;
    mCallbacks.emplace(std::make_pair(conId, std::make_shared<Function>(func)));
    return Connection{conId, this};
  }

  /**
   * Disconnect the slot at the given connection
   *
   */
  auto disconnect(Connection const & con) -> bool {
    return mCallbacks.erase(con.mId) > 0;
  }

  /**
   * Call all connected slots
   *
   * @param args the parameters required by the signal type
   */
  template<typename... Args>
  auto operator() (Args... args) -> void {
    for (auto & cb : mCallbacks) {
      if (cb.second) {
        (*cb.second)(args...);
      }
    }
  }

  /**
   * Signals are not copyable
   */
  Signal(Signal const &) = delete;

  /**
   * Signals are not copyable
   */
  auto operator=(Signal const &) = delete;

private:
  /// Map of id to slots
  std::map<int, std::shared_ptr<Function>> mCallbacks;
  /// Unique ids for each connection
  int mConnectionId;
};

//Idea for these functions taken from here: https://testbit.eu/cpp11-signal-system-performance/
//these provide a short hand to std::bind

/// This function creates a std::function by binding @a object to the member function pointer @a method.
template<class Instance, class Class, class R, class... Args> std::function<R (Args...)>
slot (Instance &object, R (Class::*method) (Args...))
{
  return [&object, method] (Args... args) { return (object .* method) (args...); };
}

/// This function creates a std::function by binding @a object to the member function pointer @a method.
template<class Class, class R, class... Args> std::function<R (Args...)>
slot (Class *object, R (Class::*method) (Args...))
{
  return [object, method] (Args... args) { return (object ->* method) (args...); };
}

} //namespace core
} //namespace cagey

#endif //CAGEY_CORE_SIGNAL_HH_
<|endoftext|>


<commit_before>/***************************************************************************
 *  io/wincall_file.cpp
 *
 *  Part of the STXXL. See http://stxxl.sourceforge.net
 *
 *  Copyright (C) 2005-2006 Roman Dementiev <dementiev@ira.uka.de>
 *
 *  Distributed under the Boost Software License, Version 1.0.
 *  (See accompanying file LICENSE_1_0.txt or copy at
 *  http://www.boost.org/LICENSE_1_0.txt)
 **************************************************************************/

#include <stxxl/bits/io/wincall_file.h>
#include <stxxl/bits/io/request_impl_basic.h>
#include <stxxl/bits/common/debug.h>

#ifdef BOOST_MSVC

__STXXL_BEGIN_NAMESPACE

void wincall_file::serve(const request * req) throw(io_error)
{
    scoped_mutex_lock fd_lock(fd_mutex);
    assert(req->get_file() == this);
    offset_type offset = req->get_offset();
    void * buffer = req->get_buffer();
    size_type bytes = req->get_size();
    request::request_type type = req->get_type();

        HANDLE handle = file_des;
        LARGE_INTEGER desired_pos;
        desired_pos.QuadPart = offset;
        if (!SetFilePointerEx(handle, desired_pos, NULL, FILE_BEGIN))
        {
            stxxl_win_lasterror_exit("SetFilePointerEx in wincall_request::serve()" <<
                                     " offset=" << offset <<
                                     " this=" << this <<
                                     " buffer=" << buffer <<
                                     " bytes=" << bytes <<
                                     " type=" << ((type == request::READ) ? "READ" : "WRITE"),
                                     io_error);
        }
        else
        {
            stats::scoped_read_write_timer read_write_timer(bytes, type == request::WRITE);

            if (type == request::READ)
            {
                STXXL_DEBUGMON_DO(io_started(buffer));
                DWORD NumberOfBytesRead = 0;
                if (!ReadFile(handle, buffer, bytes, &NumberOfBytesRead, NULL))
                {
                    stxxl_win_lasterror_exit("ReadFile" <<
                                             " this=" << this <<
                                             " offset=" << offset <<
                                             " buffer=" << buffer <<
                                             " bytes=" << bytes <<
                                             " type=" << ((type == request::READ) ? "READ" : "WRITE") <<
                                             " NumberOfBytesRead= " << NumberOfBytesRead,
                                             io_error);
                }

                STXXL_DEBUGMON_DO(io_finished(buffer));
            }
            else
            {
                STXXL_DEBUGMON_DO(io_started(buffer));

                DWORD NumberOfBytesWritten = 0;
                if (!WriteFile(handle, buffer, bytes, &NumberOfBytesWritten, NULL))
                {
                    stxxl_win_lasterror_exit("WriteFile" <<
                                             " this=" << this <<
                                             " offset=" << offset <<
                                             " buffer=" << buffer <<
                                             " bytes=" << bytes <<
                                             " type=" << ((type == request::READ) ? "READ" : "WRITE") <<
                                             " NumberOfBytesWritten= " << NumberOfBytesWritten,
                                             io_error);
                }

                STXXL_DEBUGMON_DO(io_finished(buffer));
            }
        }
}

const char * wincall_file::io_type() const
{
    return "wincall";
}

__STXXL_END_NAMESPACE

#endif // #ifdef BOOST_MSVC
// vim: et:ts=4:sw=4
<commit_msg>print warning if block sizes > 32 MB are used with wincall_file<commit_after>/***************************************************************************
 *  io/wincall_file.cpp
 *
 *  Part of the STXXL. See http://stxxl.sourceforge.net
 *
 *  Copyright (C) 2005-2006 Roman Dementiev <dementiev@ira.uka.de>
 *
 *  Distributed under the Boost Software License, Version 1.0.
 *  (See accompanying file LICENSE_1_0.txt or copy at
 *  http://www.boost.org/LICENSE_1_0.txt)
 **************************************************************************/

#include <stxxl/bits/io/wincall_file.h>
#include <stxxl/bits/io/request_impl_basic.h>
#include <stxxl/bits/common/debug.h>

#ifdef BOOST_MSVC

__STXXL_BEGIN_NAMESPACE

void wincall_file::serve(const request * req) throw(io_error)
{
    scoped_mutex_lock fd_lock(fd_mutex);
    assert(req->get_file() == this);
    offset_type offset = req->get_offset();
    void * buffer = req->get_buffer();
    size_type bytes = req->get_size();
    request::request_type type = req->get_type();

    if (bytes > 32 * 1024 * 1024) {
        STXXL_ERRMSG("Using a block size larger than 32 MB may not work with the " << io_type() << " filetype");
    }

        HANDLE handle = file_des;
        LARGE_INTEGER desired_pos;
        desired_pos.QuadPart = offset;
        if (!SetFilePointerEx(handle, desired_pos, NULL, FILE_BEGIN))
        {
            stxxl_win_lasterror_exit("SetFilePointerEx in wincall_request::serve()" <<
                                     " offset=" << offset <<
                                     " this=" << this <<
                                     " buffer=" << buffer <<
                                     " bytes=" << bytes <<
                                     " type=" << ((type == request::READ) ? "READ" : "WRITE"),
                                     io_error);
        }
        else
        {
            stats::scoped_read_write_timer read_write_timer(bytes, type == request::WRITE);

            if (type == request::READ)
            {
                STXXL_DEBUGMON_DO(io_started(buffer));
                DWORD NumberOfBytesRead = 0;
                if (!ReadFile(handle, buffer, bytes, &NumberOfBytesRead, NULL))
                {
                    stxxl_win_lasterror_exit("ReadFile" <<
                                             " this=" << this <<
                                             " offset=" << offset <<
                                             " buffer=" << buffer <<
                                             " bytes=" << bytes <<
                                             " type=" << ((type == request::READ) ? "READ" : "WRITE") <<
                                             " NumberOfBytesRead= " << NumberOfBytesRead,
                                             io_error);
                }

                STXXL_DEBUGMON_DO(io_finished(buffer));
            }
            else
            {
                STXXL_DEBUGMON_DO(io_started(buffer));

                DWORD NumberOfBytesWritten = 0;
                if (!WriteFile(handle, buffer, bytes, &NumberOfBytesWritten, NULL))
                {
                    stxxl_win_lasterror_exit("WriteFile" <<
                                             " this=" << this <<
                                             " offset=" << offset <<
                                             " buffer=" << buffer <<
                                             " bytes=" << bytes <<
                                             " type=" << ((type == request::READ) ? "READ" : "WRITE") <<
                                             " NumberOfBytesWritten= " << NumberOfBytesWritten,
                                             io_error);
                }

                STXXL_DEBUGMON_DO(io_finished(buffer));
            }
        }
}

const char * wincall_file::io_type() const
{
    return "wincall";
}

__STXXL_END_NAMESPACE

#endif // #ifdef BOOST_MSVC
// vim: et:ts=4:sw=4
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: WeakListenerAdapter.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: vg $ $Date: 2007-05-22 18:24:07 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef CHART2_WEAKLISTENERADAPTER_HXX
#define CHART2_WEAKLISTENERADAPTER_HXX

#ifndef _COM_SUN_STAR_UNO_XWEAK_HPP_
#include <com/sun/star/uno/XWeak.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
#include <com/sun/star/lang/XEventListener.hpp>
#endif

#ifndef _COM_SUN_STAR_UTIL_XMODIFYLISTENER_HPP_
#include <com/sun/star/util/XModifyListener.hpp>
#endif
#ifndef _COM_SUN_STAR_VIEW_XSELECTIONCHANGELISTENER_HPP_
#include <com/sun/star/view/XSelectionChangeListener.hpp>
#endif

#ifndef _CPPUHELPER_WEAKREF_HXX_
#include <cppuhelper/weakref.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif

namespace chart
{
// --------------------------------------------------------------------------------

/** Adapter that enables adding listeners as weak UNO references.  Thus, adding
    an object as listener to a broadcaster does not increase its reference
    count.

The helper class, of course, is held as hard reference at the
    broadcaster, but this should never be a problem as the adapter's life time
    depends on no other object.

Note that in order to remove an object as listener, you have to remove
    the same wrapper that you added, i.e., you should store the adapter as a
    member in the adaptee class for later use.

 */
template< class Listener >
    class WeakListenerAdapter : public
    ::cppu::WeakImplHelper1< Listener >
{
public:
    explicit WeakListenerAdapter( const ::com::sun::star::uno::Reference< Listener > & xListener ) :
            m_xListener( xListener )
    {}
    explicit WeakListenerAdapter( const ::com::sun::star::uno::WeakReference< Listener > & xListener ) :
            m_xListener( xListener )
    {}
    virtual ~WeakListenerAdapter()
    {}

protected:
    // ____ XEventListener (base of all listeners) ____
    virtual void SAL_CALL disposing(
        const ::com::sun::star::lang::EventObject& Source )
        throw (::com::sun::star::uno::RuntimeException)
    {
        ::com::sun::star::uno::Reference<
              ::com::sun::star::lang::XEventListener > xEventListener(
                  ::com::sun::star::uno::Reference< Listener >( m_xListener), ::com::sun::star::uno::UNO_QUERY );
        if( xEventListener.is())
            xEventListener->disposing( Source );
    }

    ::com::sun::star::uno::Reference< Listener > getListener() const
    {
        return m_xListener;
    }

private:
    ::com::sun::star::uno::WeakReference< Listener > m_xListener;
};

// --------------------------------------------------------------------------------

class WeakModifyListenerAdapter :
        public WeakListenerAdapter< ::com::sun::star::util::XModifyListener >
{
public:
    explicit WeakModifyListenerAdapter(
        const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > & xListener );
    explicit WeakModifyListenerAdapter(
        const ::com::sun::star::uno::WeakReference< ::com::sun::star::util::XModifyListener > & xListener );
    virtual ~WeakModifyListenerAdapter();

protected:
    // ____ XModifyListener ____
    virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent )
        throw (::com::sun::star::uno::RuntimeException);
};

// --------------------------------------------------------------------------------

class WeakSelectionChangeListenerAdapter :
        public WeakListenerAdapter< ::com::sun::star::view::XSelectionChangeListener >
{
public:
    explicit WeakSelectionChangeListenerAdapter(
        const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener );
    explicit WeakSelectionChangeListenerAdapter(
        const ::com::sun::star::uno::WeakReference< ::com::sun::star::view::XSelectionChangeListener > & xListener );
    virtual ~WeakSelectionChangeListenerAdapter();

protected:
    // ____ XSelectionChangeListener ____
    virtual void SAL_CALL selectionChanged(
        const ::com::sun::star::lang::EventObject& aEvent )
        throw (::com::sun::star::uno::RuntimeException);
};

} //  namespace chart

// CHART2_WEAKLISTENERADAPTER_HXX
#endif
<commit_msg>INTEGRATION: CWS chart07 (1.2.12); FILE MERGED 2007/06/26 10:59:44 bm 1.2.12.1: #i78783# fix for (broken) gcc 3.3 for Mac OS/X Panther applied<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: WeakListenerAdapter.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2007-07-25 08:48:01 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef CHART2_WEAKLISTENERADAPTER_HXX
#define CHART2_WEAKLISTENERADAPTER_HXX

#ifndef _COM_SUN_STAR_UNO_XWEAK_HPP_
#include <com/sun/star/uno/XWeak.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
#include <com/sun/star/lang/XEventListener.hpp>
#endif

#ifndef _COM_SUN_STAR_UTIL_XMODIFYLISTENER_HPP_
#include <com/sun/star/util/XModifyListener.hpp>
#endif
#ifndef _COM_SUN_STAR_VIEW_XSELECTIONCHANGELISTENER_HPP_
#include <com/sun/star/view/XSelectionChangeListener.hpp>
#endif

#ifndef _CPPUHELPER_WEAKREF_HXX_
#include <cppuhelper/weakref.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif

namespace chart
{
// --------------------------------------------------------------------------------

/** Adapter that enables adding listeners as weak UNO references.  Thus, adding
    an object as listener to a broadcaster does not increase its reference
    count.

The helper class, of course, is held as hard reference at the
    broadcaster, but this should never be a problem as the adapter's life time
    depends on no other object.

Note that in order to remove an object as listener, you have to remove
    the same wrapper that you added, i.e., you should store the adapter as a
    member in the adaptee class for later use.

 */
template< class Listener >
    class WeakListenerAdapter : public
    ::cppu::WeakImplHelper1< Listener >
{
public:
    explicit WeakListenerAdapter( const ::com::sun::star::uno::Reference< Listener > & xListener ) :
            m_xListener( xListener )
    {}
    explicit WeakListenerAdapter( const ::com::sun::star::uno::WeakReference< Listener > & xListener ) :
            m_xListener( xListener )
    {}
    virtual ~WeakListenerAdapter()
    {}

protected:
    // ____ XEventListener (base of all listeners) ____
    virtual void SAL_CALL disposing(
        const ::com::sun::star::lang::EventObject& Source )
        throw (::com::sun::star::uno::RuntimeException)
    {
        ::com::sun::star::uno::Reference<
              ::com::sun::star::lang::XEventListener > xEventListener =
          ::com::sun::star::uno::Reference<
              ::com::sun::star::lang::XEventListener >(
                  ::com::sun::star::uno::Reference< Listener >( m_xListener), ::com::sun::star::uno::UNO_QUERY );
        if( xEventListener.is())
            xEventListener->disposing( Source );
    }

    ::com::sun::star::uno::Reference< Listener > getListener() const
    {
        return m_xListener;
    }

private:
    ::com::sun::star::uno::WeakReference< Listener > m_xListener;
};

// --------------------------------------------------------------------------------

class WeakModifyListenerAdapter :
        public WeakListenerAdapter< ::com::sun::star::util::XModifyListener >
{
public:
    explicit WeakModifyListenerAdapter(
        const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > & xListener );
    explicit WeakModifyListenerAdapter(
        const ::com::sun::star::uno::WeakReference< ::com::sun::star::util::XModifyListener > & xListener );
    virtual ~WeakModifyListenerAdapter();

protected:
    // ____ XModifyListener ____
    virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent )
        throw (::com::sun::star::uno::RuntimeException);
};

// --------------------------------------------------------------------------------

class WeakSelectionChangeListenerAdapter :
        public WeakListenerAdapter< ::com::sun::star::view::XSelectionChangeListener >
{
public:
    explicit WeakSelectionChangeListenerAdapter(
        const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener );
    explicit WeakSelectionChangeListenerAdapter(
        const ::com::sun::star::uno::WeakReference< ::com::sun::star::view::XSelectionChangeListener > & xListener );
    virtual ~WeakSelectionChangeListenerAdapter();

protected:
    // ____ XSelectionChangeListener ____
    virtual void SAL_CALL selectionChanged(
        const ::com::sun::star::lang::EventObject& aEvent )
        throw (::com::sun::star::uno::RuntimeException);
};

} //  namespace chart

// CHART2_WEAKLISTENERADAPTER_HXX
#endif
<|endoftext|>


<commit_before>#include "../SDP_Solver_Parameters.hxx"

std::ostream &operator<<(std::ostream &os, const SDP_Solver_Parameters &p)
{
  os << "SDP directory   : " << p.sdp_directory << '\n'
     << "out directory   : " << p.out_directory << '\n'
     << "checkpoint in   : " << p.checkpoint_in << '\n'
     << "checkpoint out  : " << p.checkpoint_out << '\n'
     << "\nParameters:\n"
     << std::boolalpha << "maxIterations                = " << p.max_iterations
     << '\n'
     << "maxRuntime                   = " << p.max_runtime << '\n'
     << "checkpointInterval           = " << p.checkpoint_interval << '\n'
     << "noFinalCheckpoint            = " << p.no_final_checkpoint << '\n'
     << "writeMatrices                = " << p.write_matrices << '\n'
     << "findPrimalFeasible           = " << p.find_primal_feasible << '\n'
     << "findDualFeasible             = " << p.find_dual_feasible << '\n'
     << "detectPrimalFeasibleJump     = " << p.detect_primal_feasible_jump
     << '\n'
     << "detectDualFeasibleJump       = " << p.detect_dual_feasible_jump
     << '\n'
     << "precision(actual)            = " << p.precision << "("
     << mpf_get_default_prec() << ")" << '\n'

     << "dualityGapThreshold          = " << p.duality_gap_threshold << '\n'
     << "primalErrorThreshold         = " << p.primal_error_threshold << '\n'
     << "dualErrorThreshold           = " << p.dual_error_threshold << '\n'
     << "initialMatrixScalePrimal     = " << p.initial_matrix_scale_primal
     << '\n'
     << "initialMatrixScaleDual       = " << p.initial_matrix_scale_dual
     << '\n'
     << "feasibleCenteringParameter   = " << p.feasible_centering_parameter
     << '\n'
     << "infeasibleCenteringParameter = " << p.infeasible_centering_parameter
     << '\n'
     << "stepLengthReduction          = " << p.step_length_reduction << '\n'
     << "maxComplementarity           = " << p.max_complementarity << '\n'
     << "procsPerNode                 = " << p.procs_per_node << '\n'
     << "procsGranularity             = " << p.proc_granularity << '\n'
     << "verbosity                    = " << static_cast<int>(p.verbosity)
     << '\n';
  return os;
}
<commit_msg>Fix typo when printing parameters<commit_after>#include "../SDP_Solver_Parameters.hxx"

std::ostream &operator<<(std::ostream &os, const SDP_Solver_Parameters &p)
{
  os << "SDP directory   : " << p.sdp_directory << '\n'
     << "out directory   : " << p.out_directory << '\n'
     << "checkpoint in   : " << p.checkpoint_in << '\n'
     << "checkpoint out  : " << p.checkpoint_out << '\n'
     << "\nParameters:\n"
     << std::boolalpha << "maxIterations                = " << p.max_iterations
     << '\n'
     << "maxRuntime                   = " << p.max_runtime << '\n'
     << "checkpointInterval           = " << p.checkpoint_interval << '\n'
     << "noFinalCheckpoint            = " << p.no_final_checkpoint << '\n'
     << "writeMatrices                = " << p.write_matrices << '\n'
     << "findPrimalFeasible           = " << p.find_primal_feasible << '\n'
     << "findDualFeasible             = " << p.find_dual_feasible << '\n'
     << "detectPrimalFeasibleJump     = " << p.detect_primal_feasible_jump
     << '\n'
     << "detectDualFeasibleJump       = " << p.detect_dual_feasible_jump
     << '\n'
     << "precision(actual)            = " << p.precision << "("
     << mpf_get_default_prec() << ")" << '\n'

     << "dualityGapThreshold          = " << p.duality_gap_threshold << '\n'
     << "primalErrorThreshold         = " << p.primal_error_threshold << '\n'
     << "dualErrorThreshold           = " << p.dual_error_threshold << '\n'
     << "initialMatrixScalePrimal     = " << p.initial_matrix_scale_primal
     << '\n'
     << "initialMatrixScaleDual       = " << p.initial_matrix_scale_dual
     << '\n'
     << "feasibleCenteringParameter   = " << p.feasible_centering_parameter
     << '\n'
     << "infeasibleCenteringParameter = " << p.infeasible_centering_parameter
     << '\n'
     << "stepLengthReduction          = " << p.step_length_reduction << '\n'
     << "maxComplementarity           = " << p.max_complementarity << '\n'
     << "procsPerNode                 = " << p.procs_per_node << '\n'
     << "procGranularity              = " << p.proc_granularity << '\n'
     << "verbosity                    = " << static_cast<int>(p.verbosity)
     << '\n';
  return os;
}
<|endoftext|>


<commit_before>#include "playerFormat.h"
#include <iostream>

player::player(std::string name, std::string area, std::string weapon, int level, int exp, int expRequired, int health, int maxHealth, int strength, int constitution, int intelligence, int wisdom, int dexterity, int perception)
{
	std::string setName(name);
	std::string setArea(area);
	std::string setWeapon(weapon);
	int setLevel(level);
	int setExp(exp);
	int setExpRequired(expRequired);
	int setMaxHealth(maxHealth);
	int setHealth(maxHealth);
	int setStrength(strength);
	int setConstitution(constitution);
	int setPerception(perception);
	int setDexterity(dexterity);
	int setIntelligence(intelligence);
	int setWisdom(wisdom);
}

//member mutators
void player::setName(std::string name)
{
	playerName = name;
}
void player::setArea(std::string area)
{
	playerArea = area;
}
void player::setWeapon(std::string weapon)
{
	playerWeapon = weapon;
}
void player::setLevel(int level)
{
	playerLevel = level;
}
void player::setExp(int exp)
{
	playerExp = exp;
}
void player::setExpRequired(int expRequired)
{
	playerExpRequired = (123 * (1 + getLevel()));
}
void player::setMaxHealth(int maxHealth)
{
	playerMaxHealth = (20 + (3 * getConstitution()));
}
void player::setHealth(int health)
{
	playerHealth = health;
}
void player::setStrength(int strength)
{
	playerStrength = strength;
}
void player::setConstitution(int constitution)
{
	playerConstitution = constitution;
}
void player::setPerception(int perception)
{
	playerPerception = perception;
}
void player::setDexterity(int dexterity)
{
	playerDexterity = dexterity;
}
void player::setIntelligence(int intelligence)
{
	playerIntelligence = intelligence;
}
void player::setWisdom(int wisdom)
{
	playerWisdom = wisdom;
}

//member accesors
std::string player::getName()
{
	return playerName;
}
std::string player::getArea()
{
	return playerArea;
}
std::string player::getWeapon()
{
	return playerWeapon;
}
int player::getLevel()
{
	return playerLevel;
}
int player::getExp()
{
	return playerExp;
}
int player::getExpRequired()
{
	return playerExpRequired;
}
int player::getMaxHealth()
{
	return playerMaxHealth;
}
int player::getHealth()
{
	return playerHealth;
}
int player::getStrength()
{
	return playerStrength;
}
int player::getConstitution()
{
	return playerConstitution;
}
int player::getPerception()
{
	return playerPerception;
}
int player::getDexterity()
{
	return playerDexterity;
}
int player::getIntelligence()
{
	return playerIntelligence;
}
int player::getWisdom()
{
	return playerWisdom;
}
<commit_msg>Update player.cpp<commit_after>#include "_player.h"
#include <iostream>

player::player(std::string name, std::string area, std::string weapon, int level, int exp, int expRequired, int health, int maxHealth, int strength, int constitution, int intelligence, int wisdom, int dexterity, int perception)
{
	std::string setName(name);
	std::string setArea(area);
	std::string setWeapon(weapon);
	int setLevel(level);
	int setExp(exp);
	int setExpRequired(expRequired);
	int setMaxHealth(maxHealth);
	int setHealth(maxHealth);
	int setStrength(strength);
	int setConstitution(constitution);
	int setPerception(perception);
	int setDexterity(dexterity);
	int setIntelligence(intelligence);
	int setWisdom(wisdom);
}

//member mutators
void player::setName(std::string name)
{
	playerName = name;
}
void player::setArea(std::string area)
{
	playerArea = area;
}
void player::setWeapon(std::string weapon)
{
	playerWeapon = weapon;
}
void player::setLevel(int level)
{
	playerLevel = level;
}
void player::setExp(int exp)
{
	playerExp = exp;
}
void player::setExpRequired(int expRequired)
{
	playerExpRequired = (123 * (1 + getLevel()));
}
void player::setMaxHealth(int maxHealth)
{
	playerMaxHealth = (20 + (3 * getConstitution()));
}
void player::setHealth(int health)
{
	playerHealth = health;
}
void player::setStrength(int strength)
{
	playerStrength = strength;
}
void player::setConstitution(int constitution)
{
	playerConstitution = constitution;
}
void player::setPerception(int perception)
{
	playerPerception = perception;
}
void player::setDexterity(int dexterity)
{
	playerDexterity = dexterity;
}
void player::setIntelligence(int intelligence)
{
	playerIntelligence = intelligence;
}
void player::setWisdom(int wisdom)
{
	playerWisdom = wisdom;
}

//member accesors
std::string player::getName()
{
	return playerName;
}
std::string player::getArea()
{
	return playerArea;
}
std::string player::getWeapon()
{
	return playerWeapon;
}
int player::getLevel()
{
	return playerLevel;
}
int player::getExp()
{
	return playerExp;
}
int player::getExpRequired()
{
	return playerExpRequired;
}
int player::getMaxHealth()
{
	return playerMaxHealth;
}
int player::getHealth()
{
	return playerHealth;
}
int player::getStrength()
{
	return playerStrength;
}
int player::getConstitution()
{
	return playerConstitution;
}
int player::getPerception()
{
	return playerPerception;
}
int player::getDexterity()
{
	return playerDexterity;
}
int player::getIntelligence()
{
	return playerIntelligence;
}
int player::getWisdom()
{
	return playerWisdom;
}
<|endoftext|>


<commit_before>
#include "Directory.h"

#include <cstdio>
#include "../Materials/Functions.h"

#ifdef GF_OS_LINUX
#include <sys/stat.h>
#include <cstring>
#endif

Groundfloor::Directory::Directory() {
   bOpen = false;

   #ifdef GF_OS_WIN32
   bFirstTime = false;
   #endif
}

Groundfloor::Directory::~Directory() {
   if ( bOpen ) {
      close();
   }
}

bool Groundfloor::Directory::open( const Groundfloor::String *sDir ) {
   bOpen = false;

   sCurrentDir.setValue( sDir );

   #ifdef GF_OS_WIN32
      Groundfloor::String sWildDir(&sCurrentDir);
      sWildDir.transformToWidestring( true );
      sWildDir.append_wide( L"\\*.*" );

      hDir = FindFirstFileW( reinterpret_cast<const wchar_t *>( sWildDir.getValue() ), reinterpret_cast<_WIN32_FIND_DATAW *>( &anEntryW ) );

      if ( hDir == INVALID_HANDLE_VALUE ) {
         return false;
      }

      bFirstTime = true;
   #else
      hDir = opendir( sDir->getValue() );
      if ( hDir == 0 ) {
         return false;
      }
   #endif

   bOpen = true;
   return true;
}

bool Groundfloor::Directory::next() {
   #ifdef GF_OS_WIN32
      if ( !bFirstTime ) {

         if ( !FindNextFileW( hDir, reinterpret_cast<_WIN32_FIND_DATAW *>( &anEntryW ) ) ) {
            return false;
         }

      } else {
         bFirstTime = false;
      }
   #else
      anEntry = readdir( hDir );
      if ( anEntry == 0 ) {
         return false;
      }
   #endif

   return true;
}

bool Groundfloor::Directory::close() {
   #ifdef GF_OS_WIN32
      FindClose( hDir );
   #else
      closedir( hDir );
   #endif

   bOpen = false;

   return true;
}

Groundfloor::String *Groundfloor::Directory::getFileName() {
   Groundfloor::String *sName = NULL;

   #ifdef GF_OS_WIN32
      sName = new Groundfloor::String( reinterpret_cast<const char *>( anEntryW.cFileName ), getWStrByteLen(anEntryW.cFileName) );
      sName->transformWidestringToString( true );
   #else
      sName = new Groundfloor::String( anEntry->d_name, strlen(anEntry->d_name) );
   #endif

   return sName;
}

Groundfloor::String *Groundfloor::Directory::getShortName() {
   Groundfloor::String *sName = NULL;

   if ( bOpen ) {
      #ifdef GF_OS_WIN32
         Groundfloor::String sLongPath( sCurrentDir );
         Groundfloor::AppendNativeSlash( &sLongPath, false );
         sLongPath.transformToWidestring( true );
         sLongPath.append( reinterpret_cast<const char *>( anEntryW.cFileName ), getWStrByteLen(anEntryW.cFileName) );
         sName = new Groundfloor::String();
         sName->setLength( MAX_PATH );
         sName->setLength( GetShortPathNameW( reinterpret_cast<wchar_t *>( sLongPath.getValue() ), reinterpret_cast<wchar_t *>( sName->getValue() ), MAX_PATH ) * sizeof(wchar_t) );
         sName->transformWidestringToString( true );
/*
         Groundfloor::Vector *arr = GFsplit( sName, reinterpret_cast<const char *>( S_WIDE_NATIVE_SLASH ) );
         sName->setValue( static_cast<Groundfloor::String *>( arr->elementAt( arr->size() - 1 ) ) );
         delete arr;
*/
         Groundfloor::String *slash = createHybridString( S_WIDE_NATIVE_SLASH, true );
         int iPos = sName->lastpos( slash ) + slash->getLength();
         sName->setValue( sName->getPointer(iPos), sName->getLength() - iPos );
         delete slash;
      #else
         sName = new Groundfloor::String( anEntry->d_name, strlen(anEntry->d_name) );
      #endif
   }

   return sName;
}

bool Groundfloor::Directory::isDirectory() {
   #ifdef GF_OS_WIN32
      return ((anEntryW.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
   #else
      #ifdef _DIRENT_HAVE_D_TYPE
         if ( anEntry->d_type == DT_UNKNOWN ) {
            // dt_unknown, op een andere manier bepalen dan maar...
            Groundfloor::String *sTmp = new Groundfloor::String( sCurrentDir );
            GFAppendNativeSlash( sTmp );
            sTmp->append_ansi( anEntry->d_name );
            bool bIsDir = GFIsDirectory( sTmp );
            delete sTmp;

            return bIsDir;
         } else {
            return (anEntry->d_type == DT_DIR);
         }
      #else
         // d_type property is niet supported door de kernel, op een andere manier opvragen of het een directory is
         Groundfloor::String *sTmp = new Groundfloor::String( sCurrentDir );
         GFAppendNativeSlash( sTmp );
         sTmp->append_ansi( anEntry->d_name );
         bool bIsDir = GFIsDirectory( sTmp );
         delete sTmp;

         return bIsDir;
      #endif
   #endif
}

bool Groundfloor::Directory::isOpen() {
   return bOpen;
}

<commit_msg>linux fix<commit_after>
#include "Directory.h"

#include <cstdio>
#include "../Materials/Functions.h"

#ifdef GF_OS_LINUX
#include <sys/stat.h>
#include <cstring>
#endif

Groundfloor::Directory::Directory() {
   bOpen = false;

   #ifdef GF_OS_WIN32
   bFirstTime = false;
   #endif
}

Groundfloor::Directory::~Directory() {
   if ( bOpen ) {
      close();
   }
}

bool Groundfloor::Directory::open( const Groundfloor::String *sDir ) {
   bOpen = false;

   sCurrentDir.setValue( sDir );

   #ifdef GF_OS_WIN32
      Groundfloor::String sWildDir(&sCurrentDir);
      sWildDir.transformToWidestring( true );
      sWildDir.append_wide( L"\\*.*" );

      hDir = FindFirstFileW( reinterpret_cast<const wchar_t *>( sWildDir.getValue() ), reinterpret_cast<_WIN32_FIND_DATAW *>( &anEntryW ) );

      if ( hDir == INVALID_HANDLE_VALUE ) {
         return false;
      }

      bFirstTime = true;
   #else
      hDir = opendir( sDir->getValue() );
      if ( hDir == 0 ) {
         return false;
      }
   #endif

   bOpen = true;
   return true;
}

bool Groundfloor::Directory::next() {
   #ifdef GF_OS_WIN32
      if ( !bFirstTime ) {

         if ( !FindNextFileW( hDir, reinterpret_cast<_WIN32_FIND_DATAW *>( &anEntryW ) ) ) {
            return false;
         }

      } else {
         bFirstTime = false;
      }
   #else
      anEntry = readdir( hDir );
      if ( anEntry == 0 ) {
         return false;
      }
   #endif

   return true;
}

bool Groundfloor::Directory::close() {
   #ifdef GF_OS_WIN32
      FindClose( hDir );
   #else
      closedir( hDir );
   #endif

   bOpen = false;

   return true;
}

Groundfloor::String *Groundfloor::Directory::getFileName() {
   Groundfloor::String *sName = NULL;

   #ifdef GF_OS_WIN32
      sName = new Groundfloor::String( reinterpret_cast<const char *>( anEntryW.cFileName ), getWStrByteLen(anEntryW.cFileName) );
      sName->transformWidestringToString( true );
   #else
      sName = new Groundfloor::String( anEntry->d_name, strlen(anEntry->d_name) );
   #endif

   return sName;
}

Groundfloor::String *Groundfloor::Directory::getShortName() {
   Groundfloor::String *sName = NULL;

   if ( bOpen ) {
      #ifdef GF_OS_WIN32
         Groundfloor::String sLongPath( sCurrentDir );
         Groundfloor::AppendNativeSlash( &sLongPath, false );
         sLongPath.transformToWidestring( true );
         sLongPath.append( reinterpret_cast<const char *>( anEntryW.cFileName ), getWStrByteLen(anEntryW.cFileName) );
         sName = new Groundfloor::String();
         sName->setLength( MAX_PATH );
         sName->setLength( GetShortPathNameW( reinterpret_cast<wchar_t *>( sLongPath.getValue() ), reinterpret_cast<wchar_t *>( sName->getValue() ), MAX_PATH ) * sizeof(wchar_t) );
         sName->transformWidestringToString( true );
/*
         Groundfloor::Vector *arr = GFsplit( sName, reinterpret_cast<const char *>( S_WIDE_NATIVE_SLASH ) );
         sName->setValue( static_cast<Groundfloor::String *>( arr->elementAt( arr->size() - 1 ) ) );
         delete arr;
*/
         Groundfloor::String *slash = createHybridString( S_WIDE_NATIVE_SLASH, true );
         int iPos = sName->lastpos( slash ) + slash->getLength();
         sName->setValue( sName->getPointer(iPos), sName->getLength() - iPos );
         delete slash;
      #else
         sName = new Groundfloor::String( anEntry->d_name, strlen(anEntry->d_name) );
      #endif
   }

   return sName;
}

bool Groundfloor::Directory::isDirectory() {
   #ifdef GF_OS_WIN32
      return ((anEntryW.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
   #else
      #ifdef _DIRENT_HAVE_D_TYPE
         if ( anEntry->d_type == DT_UNKNOWN ) {
            // dt_unknown, op een andere manier bepalen dan maar...
            Groundfloor::String *sTmp = new Groundfloor::String( sCurrentDir );
            Groundfloor::AppendNativeSlash( sTmp );
            sTmp->append_ansi( anEntry->d_name );
            bool bIsDir = GFIsDirectory( sTmp );
            delete sTmp;

            return bIsDir;
         } else {
            return (anEntry->d_type == DT_DIR);
         }
      #else
         // d_type property is niet supported door de kernel, op een andere manier opvragen of het een directory is
         Groundfloor::String *sTmp = new Groundfloor::String( sCurrentDir );
         Groundfloor::AppendNativeSlash( sTmp );
         sTmp->append_ansi( anEntry->d_name );
         bool bIsDir = Groundfloor::IsDirectory( sTmp );
         delete sTmp;

         return bIsDir;
      #endif
   #endif
}

bool Groundfloor::Directory::isOpen() {
   return bOpen;
}

<|endoftext|>


<commit_before>/*
 * This program 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 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2011 Sergey Lisitsyn
 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
 */

#include "preprocessor/LandmarkMDS.h"
#ifdef HAVE_LAPACK
#include "lib/lapack.h"
#include "preprocessor/ClassicMDS.h"
#include "lib/common.h"
#include "lib/Mathematics.h"
#include "lib/io.h"
#include "distance/EuclidianDistance.h"
#include "lib/Signal.h"

using namespace shogun;

CLandmarkMDS::CLandmarkMDS() : CClassicMDS(), m_landmark_number(3)
{
}

CLandmarkMDS::~CLandmarkMDS()
{
}

bool CLandmarkMDS::init(CFeatures* data)
{
	return true;
}

void CLandmarkMDS::cleanup()
{
}

SGVector<int32_t> CLandmarkMDS::get_landmark_idxs(int32_t count, int32_t total_count)
{
	int32_t* idxs = new int32_t[total_count];
	int32_t i,rnd;
	int32_t* permuted_idxs = new int32_t[count];

	// reservoir sampling
	for (i=0; i<total_count; i++)
		idxs[i] = i;

	for (i=0; i<count; i++)
		permuted_idxs[i] = idxs[i];

	for (i=count; i<total_count; i++)
	{
		 rnd = CMath::random(1,i);
		 if (rnd<count)
			 permuted_idxs[rnd] = idxs[i];
	}

	delete[] idxs;

	CMath::qsort(permuted_idxs,count);

	return SGVector<int32_t>(permuted_idxs, count);
}

SGMatrix<float64_t> CLandmarkMDS::embed_by_distance(CDistance* distance)
{
	int32_t i,j,k;
	int32_t lmk_N = m_landmark_number;
	int32_t total_N = distance->get_num_vec_lhs();
	SGMatrix<float64_t> dist_matrix = distance->get_distance_matrix();

	SGVector<int32_t> lmk_idxs = get_landmark_idxs(lmk_N,total_N);

	// compute distance between landmarks
	float64_t* lmk_dist_matrix = new float64_t[lmk_N*lmk_N];
	for (i=0; i<lmk_N; i++)
	{
		for (j=0; j<lmk_N; j++)
			lmk_dist_matrix[i*lmk_N+j] =
				dist_matrix.matrix[lmk_idxs.vector[i]*total_N+lmk_idxs.vector[j]];
	}

	// distance between landmarks
	CDistance* lmk_distance =
		new CCustomDistance(lmk_dist_matrix, lmk_N, lmk_N);

	// get landmarks embedding
	SGMatrix<float64_t> lmk_feature_matrix = CClassicMDS::embed_by_distance(lmk_distance);

	// construct new feature matrix
	float64_t* new_feature_matrix = new float64_t[m_target_dim*total_N];
	for (i=0; i<m_target_dim*total_N; i++)
		new_feature_matrix[i] = 0.0;

	// fill new feature matrix with embedded landmarks
	for (i=0; i<lmk_N; i++)
	{
		for (j=0; j<m_target_dim; j++)
			new_feature_matrix[lmk_idxs.vector[i]*m_target_dim+j] =
				lmk_feature_matrix.matrix[i*m_target_dim+j];
	}

	// get exactly defined pseudoinverse of landmarks feature matrix
	ASSERT(m_eigenvalues.vector && m_eigenvalues.vlen == m_target_dim);
	for (i=0; i<lmk_N; i++)
	{
		for (j=0; j<m_target_dim; j++)
			lmk_feature_matrix.matrix[i*m_target_dim+j] /= m_eigenvalues.vector[j];
	}

	// compute mean vector of squared distances
	float64_t* mean_sq_dist_vector = new float64_t[lmk_N];
	for (i=0; i<lmk_N; i++)
	{
		mean_sq_dist_vector[i] = 0.0;
		for (j=0; j<lmk_N; j++)
			mean_sq_dist_vector[i] += lmk_dist_matrix[i*lmk_N+j] / lmk_N;
	}

	// get embedding for non-landmark vectors
	float64_t* current_dist_to_lmk = new float64_t[lmk_N];
	j = 0;
	for (i=0; i<total_N; i++)
	{
		// skip if lmk
		if (i==lmk_idxs.vector[j])
		{
			j++;
			continue;
		}
		// compute difference from mean landmark distance vector
		for (k=0; k<lmk_N; k++)
			current_dist_to_lmk[k] =
				CMath::sq(dist_matrix.matrix[i*total_N+lmk_idxs.vector[k]]) -
				CMath::sq(mean_sq_dist_vector[k]);

		// compute embedding
		cblas_dgemm(CblasColMajor,CblasNoTrans,CblasNoTrans,
		            m_target_dim,1,lmk_N,
                    -0.5,lmk_feature_matrix.matrix,m_target_dim,
		            current_dist_to_lmk,lmk_N,
		            0.0,(new_feature_matrix+i*m_target_dim),m_target_dim);
	}

	// cleanup
	delete[] lmk_feature_matrix.matrix;
	delete[] current_dist_to_lmk;
	delete[] mean_sq_dist_vector;
	delete[] lmk_dist_matrix;
	delete lmk_distance;
	delete[] dist_matrix.matrix;

	return SGMatrix<float64_t>(new_feature_matrix,m_target_dim,total_N);
}

CSimpleFeatures<float64_t>* CLandmarkMDS::apply_to_distance(CDistance* distance)
{
	ASSERT(distance);

	SGMatrix<float64_t> new_feature_matrix = embed_by_distance(distance);

	CSimpleFeatures<float64_t>* new_features =
			new CSimpleFeatures<float64_t>(new_feature_matrix);

	return new_features;
}

SGMatrix<float64_t> CLandmarkMDS::apply_to_feature_matrix(CFeatures* features)
{
	CSimpleFeatures<float64_t>* simple_features = (CSimpleFeatures<float64_t>*) features;
	CDistance* distance = new CEuclidianDistance(simple_features,simple_features);

	SGMatrix<float64_t> new_feature_matrix = embed_by_distance(distance);
	simple_features->set_feature_matrix(new_feature_matrix);

	delete distance;

	return new_feature_matrix;
}

SGVector<float64_t> CLandmarkMDS::apply_to_feature_vector(SGVector<float64_t> vector)
{
	SG_NOTIMPLEMENTED;
	return vector;
}

#endif /* HAVE_LAPACK */

<commit_msg>Fixed LandmarkMDS<commit_after>/*
 * This program 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 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2011 Sergey Lisitsyn
 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
 */

#include "preprocessor/LandmarkMDS.h"
#ifdef HAVE_LAPACK
#include "lib/lapack.h"
#include "preprocessor/ClassicMDS.h"
#include "lib/common.h"
#include "lib/Mathematics.h"
#include "lib/io.h"
#include "distance/EuclidianDistance.h"
#include "lib/Signal.h"

using namespace shogun;

CLandmarkMDS::CLandmarkMDS() : CClassicMDS(), m_landmark_number(3)
{
}

CLandmarkMDS::~CLandmarkMDS()
{
}

bool CLandmarkMDS::init(CFeatures* data)
{
	return true;
}

void CLandmarkMDS::cleanup()
{
}

SGVector<int32_t> CLandmarkMDS::get_landmark_idxs(int32_t count, int32_t total_count)
{
	int32_t* idxs = new int32_t[total_count];
	int32_t i,rnd;
	int32_t* permuted_idxs = new int32_t[count];

	// reservoir sampling
	for (i=0; i<total_count; i++)
		idxs[i] = i;

	for (i=0; i<count; i++)
		permuted_idxs[i] = idxs[i];

	for (i=count; i<total_count; i++)
	{
		 rnd = CMath::random(1,i);
		 if (rnd<count)
			 permuted_idxs[rnd] = idxs[i];
	}

	delete[] idxs;

	CMath::qsort(permuted_idxs,count);

	return SGVector<int32_t>(permuted_idxs, count);
}

SGMatrix<float64_t> CLandmarkMDS::embed_by_distance(CDistance* distance)
{
	int32_t i,j,k;
	int32_t lmk_N = m_landmark_number;
	int32_t total_N = distance->get_num_vec_lhs();
	SGMatrix<float64_t> dist_matrix = distance->get_distance_matrix();

	SGVector<int32_t> lmk_idxs = get_landmark_idxs(lmk_N,total_N);

	// compute distance between landmarks
	float64_t* lmk_dist_matrix = new float64_t[lmk_N*lmk_N];
	for (i=0; i<lmk_N; i++)
	{
		for (j=0; j<lmk_N; j++)
			lmk_dist_matrix[i*lmk_N+j] =
				dist_matrix.matrix[lmk_idxs.vector[i]*total_N+lmk_idxs.vector[j]];
	}

	// distance between landmarks
	CDistance* lmk_distance =
		new CCustomDistance(lmk_dist_matrix, lmk_N, lmk_N);

	// get landmarks embedding
	SGMatrix<float64_t> lmk_feature_matrix = CClassicMDS::embed_by_distance(lmk_distance);

	// construct new feature matrix
	float64_t* new_feature_matrix = new float64_t[m_target_dim*total_N];
	for (i=0; i<m_target_dim*total_N; i++)
		new_feature_matrix[i] = 0.0;

	// fill new feature matrix with embedded landmarks
	for (i=0; i<lmk_N; i++)
	{
		for (j=0; j<m_target_dim; j++)
			new_feature_matrix[lmk_idxs.vector[i]*m_target_dim+j] =
				lmk_feature_matrix.matrix[i*m_target_dim+j];
	}

	// get exactly defined pseudoinverse of landmarks feature matrix
	ASSERT(m_eigenvalues.vector && m_eigenvalues.vlen == m_target_dim);
	for (i=0; i<lmk_N; i++)
	{
		for (j=0; j<m_target_dim; j++)
			lmk_feature_matrix.matrix[i*m_target_dim+j] /= m_eigenvalues.vector[j];
	}

	// compute mean vector of squared distances
	float64_t* mean_sq_dist_vector = new float64_t[lmk_N];
	for (i=0; i<lmk_N; i++)
	{
		mean_sq_dist_vector[i] = 0.0;
		for (j=0; j<lmk_N; j++)
			mean_sq_dist_vector[i] += CMath::sq(lmk_dist_matrix[i*lmk_N+j]);

		mean_sq_dist_vector[i] /= lmk_N;
	}

	// get embedding for non-landmark vectors
	float64_t* current_dist_to_lmk = new float64_t[lmk_N];
	j = 0;
	for (i=0; i<total_N; i++)
	{
		// skip if landmark
		if (i==lmk_idxs.vector[j])
		{
			j++;
			continue;
		}
		// compute difference from mean landmark distance vector
		for (k=0; k<lmk_N; k++)
			current_dist_to_lmk[k] =
				CMath::sq(dist_matrix.matrix[i*total_N+lmk_idxs.vector[k]]) -
				mean_sq_dist_vector[k];

		// compute embedding
		cblas_dgemm(CblasColMajor,CblasNoTrans,CblasNoTrans,
		            m_target_dim,1,lmk_N,
                    -0.5,lmk_feature_matrix.matrix,m_target_dim,
		            current_dist_to_lmk,lmk_N,
		            0.0,(new_feature_matrix+i*m_target_dim),m_target_dim);
	}

	// cleanup
	delete[] lmk_feature_matrix.matrix;
	delete[] current_dist_to_lmk;
	delete[] mean_sq_dist_vector;
	delete[] lmk_dist_matrix;
	delete lmk_distance;
	delete[] dist_matrix.matrix;

	return SGMatrix<float64_t>(new_feature_matrix,m_target_dim,total_N);
}

CSimpleFeatures<float64_t>* CLandmarkMDS::apply_to_distance(CDistance* distance)
{
	ASSERT(distance);

	SGMatrix<float64_t> new_feature_matrix = embed_by_distance(distance);

	CSimpleFeatures<float64_t>* new_features =
			new CSimpleFeatures<float64_t>(new_feature_matrix);

	return new_features;
}

SGMatrix<float64_t> CLandmarkMDS::apply_to_feature_matrix(CFeatures* features)
{
	CSimpleFeatures<float64_t>* simple_features = (CSimpleFeatures<float64_t>*) features;
	CDistance* distance = new CEuclidianDistance(simple_features,simple_features);

	SGMatrix<float64_t> new_feature_matrix = embed_by_distance(distance);
	simple_features->set_feature_matrix(new_feature_matrix);

	delete distance;

	return new_feature_matrix;
}

SGVector<float64_t> CLandmarkMDS::apply_to_feature_vector(SGVector<float64_t> vector)
{
	SG_NOTIMPLEMENTED;
	return vector;
}

#endif /* HAVE_LAPACK */

<|endoftext|>


<commit_before>/*
 * Copyright (C) 2009 Nokia Corporation.
 *
 * Contact: Marius Vollmer <marius.vollmer@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#include "assoctree.h"
#include <QDebug>

/// Dumps a QVariant into a multi-line string for debugging purposes.
QString AssocTree::dump(int level) const
{
    QString s;
    for (int i = 0; i < level; i++)
        s += "  ";

    if (type() == QVariant::String)
        s += toString() + "\n";
    else if (type() == QVariant::List) {
        s += "[\n";

        foreach(QVariant v, toList())
            s += AssocTree(v).dump(level + 1);

        for (int i = 0; i < level; i++)
            s += "  ";

        s += "]\n";
    }

    return s;
}

/// Returns the name of this tree.
QString AssocTree::name() const
{
    if (type() == QVariant::String)
        return toString();

    if (type() != QVariant::List
        || toList().size() < 1)
        return QString();

    return toList().at(0).toString();
}

/// Returns the sub-tree with the given name
AssocTree AssocTree::node(const QString &name) const
{
    const QVariant nameVariant(name); // So we can directly compare...

    if (type() != QVariant::List)
        return AssocTree();

    foreach(const QVariant &child, toList())
    {
        if (child.type() == QVariant::List
            && child.toList().count() >= 1
            && child.toList().at(0) == nameVariant)
            return AssocTree(child);
    }

    return AssocTree();
}

AssocTree AssocTree::node(const QString &name1,
                          const QString &name2) const
{
    return node(name1).node(name2);
}

AssocTree AssocTree::node(const QString &name1,
                          const QString &name2,
                          const QString &name3) const
{
    return node(name1).node(name2).node(name3);
}

AssocTree AssocTree::node(const QString &name1,
                          const QString &name2,
                          const QString &name3,
                          const QString &name4) const
{
    return node(name1).node(name2).node(name3),node(name4);
}

AssocTree AssocTree::node(const QString &name1,
                          const QString &name2,
                          const QString &name3,
                          const QString &name4,
                          const QString &name5) const
{
    return node(name1).node(name2).node(name3),node(name4).node(name5);
}

QVariant AssocTree::value() const
{
    if (type() != QVariant::List)
        return QVariant();

    if (toList().size() < 2)
        return QVariant();

    return toList().at(1);
}

QVariant AssocTree::value(const QString &name1) const
{
    return node(name1).value();
}

QVariant AssocTree::value(const QString &name1,
                            const QString &name2) const
{
    return node(name1, name2).value();
}

QVariant AssocTree::value(const QString &name1,
                            const QString &name2,
                            const QString &name3) const
{
    return node(name1, name2, name3).value();
}

QVariant AssocTree::value(const QString &name1,
                            const QString &name2,
                            const QString &name3,
                            const QString &name4) const
{
    return node(name1, name2, name3, name4).value();
}

QVariant AssocTree::value(const QString &name1,
                            const QString &name2,
                            const QString &name3,
                            const QString &name4,
                            const QString &name5) const
{
    return node(name1, name2, name3, name4, name5).value();
}

const QVariantList AssocTree::nodes() const
{
    if (type() == QVariant::List)
        return toList().mid(1);
    else
        return QVariantList();
}
<commit_msg>Minimal documentation for AssocTree.<commit_after>/*
 * Copyright (C) 2009 Nokia Corporation.
 *
 * Contact: Marius Vollmer <marius.vollmer@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#include "assoctree.h"
#include <QDebug>

/// Dumps a QVariant into a multi-line string for debugging purposes.
QString AssocTree::dump(int level) const
{
    QString s;
    for (int i = 0; i < level; i++)
        s += "  ";

    if (type() == QVariant::String)
        s += toString() + "\n";
    else if (type() == QVariant::List) {
        s += "[\n";

        foreach(QVariant v, toList())
            s += AssocTree(v).dump(level + 1);

        for (int i = 0; i < level; i++)
            s += "  ";

        s += "]\n";
    }

    return s;
}

/// Returns the name of this association tree.
QString AssocTree::name() const
{
    if (type() == QVariant::String)
        return toString();

    if (type() != QVariant::List
        || toList().size() < 1)
        return QString();

    return toList().at(0).toString();
}

/// Returns the sub-tree with the given name
AssocTree AssocTree::node(const QString &name) const
{
    const QVariant nameVariant(name); // So we can directly compare...

    if (type() != QVariant::List)
        return AssocTree();

    foreach(const QVariant &child, toList())
    {
        if (child.type() == QVariant::List
            && child.toList().count() >= 1
            && child.toList().at(0) == nameVariant)
            return AssocTree(child);
    }

    return AssocTree();
}

/// Returns the sub-tree named \a name2 of the sub-tree named \a name1
AssocTree AssocTree::node(const QString &name1,
                          const QString &name2) const
{
    return node(name1).node(name2);
}

AssocTree AssocTree::node(const QString &name1,
                          const QString &name2,
                          const QString &name3) const
{
    return node(name1).node(name2).node(name3);
}

AssocTree AssocTree::node(const QString &name1,
                          const QString &name2,
                          const QString &name3,
                          const QString &name4) const
{
    return node(name1).node(name2).node(name3),node(name4);
}

AssocTree AssocTree::node(const QString &name1,
                          const QString &name2,
                          const QString &name3,
                          const QString &name4,
                          const QString &name5) const
{
    return node(name1).node(name2).node(name3),node(name4).node(name5);
}

/// Returns the value of this tree.
QVariant AssocTree::value() const
{
    if (type() != QVariant::List)
        return QVariant();

    if (toList().size() < 2)
        return QVariant();

    return toList().at(1);
}

/// Returns the value of the sub-tree named name1.
QVariant AssocTree::value(const QString &name1) const
{
    return node(name1).value();
}

QVariant AssocTree::value(const QString &name1,
                          const QString &name2) const
{
    return node(name1, name2).value();
}

QVariant AssocTree::value(const QString &name1,
                          const QString &name2,
                          const QString &name3) const
{
    return node(name1, name2, name3).value();
}

QVariant AssocTree::value(const QString &name1,
                          const QString &name2,
                          const QString &name3,
                          const QString &name4) const
{
    return node(name1, name2, name3, name4).value();
}

QVariant AssocTree::value(const QString &name1,
                          const QString &name2,
                          const QString &name3,
                          const QString &name4,
                          const QString &name5) const
{
    return node(name1, name2, name3, name4, name5).value();
}

/// Returns a list of all sub-trees.
const QVariantList AssocTree::nodes() const
{
    if (type() == QVariant::List)
        return toList().mid(1);
    else
        return QVariantList();
}
<|endoftext|>


<commit_before>/*************************************************************************
 * libjson-rpc-cpp
 *************************************************************************
 * @file    stubgeneratorfactory.cpp
 * @date    11/19/2014
 * @author  Peter Spiess-Knafl <peter.knafl@gmail.com>
 * @license See attached LICENSE.txt
 ************************************************************************/

#include "stubgeneratorfactory.h"
#include <jsonrpccpp/common/specificationparser.h>
#include <jsonrpccpp/version.h>
#include <iostream>
#include <argtable2.h>
#include "helper/cpphelper.h"
#include "client/cppclientstubgenerator.h"
#include "client/jsclientstubgenerator.h"
#include "server/cppserverstubgenerator.h"

using namespace jsonrpc;
using namespace std;

bool StubGeneratorFactory::createStubGenerators(int argc, char **argv, vector<Procedure> &procedures, vector<StubGenerator*> &stubgenerators, FILE *stdout, FILE *stderr)
{
    struct arg_file *inputfile      = arg_file0(NULL, NULL, "<specfile>", "path of input specification file");
    struct arg_lit *help            = arg_lit0("h","help", "print this help and exit");
    struct arg_lit *version         = arg_lit0(NULL,"version", "print version and exit");
    struct arg_lit *verbose         = arg_lit0("v","verbose", "print more information about what is happening");
    struct arg_str *cppserver       = arg_str0(NULL, "cpp-server", "<namespace::classname>", "name of the C++ server stub class");
    struct arg_str *cppserverfile   = arg_str0(NULL, "cpp-server-file", "<filename.h>", "name of the C++ server stub file");
    struct arg_str *cppclient       = arg_str0(NULL, "cpp-client", "<namespace::classname>", "name of the C++ client stub class");
    struct arg_str *cppclientfile   = arg_str0(NULL, "cpp-client-file", "<filename.h>", "name of the C++ client stub file");
    struct arg_str *jsclient        = arg_str0(NULL, "js-client", "<classname>", "name of the JavaScript client stub class");
    struct arg_str *jsclientfile    = arg_str0(NULL, "js-client-file", "<filename.js>", "name of the JavaScript client stub file");

    struct arg_end *end         = arg_end(20);
    void* argtable[] = {inputfile, help, version, verbose, cppserver, cppserverfile, cppclient, cppclientfile, jsclient, jsclientfile,end};

    if (arg_parse(argc,argv,argtable) > 0)
    {
        arg_print_errors(stderr, end, argv[0]);
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return false;
    }

    if (help->count > 0)
    {
        fprintf(stdout, "Usage: %s ", argv[0]);
        arg_print_syntax(stdout,argtable,"\n"); cout << endl;
        arg_print_glossary_gnu(stdout, argtable);
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return true;
    }

    if (version->count > 0)
    {
        fprintf(stdout, "jsonrpcstub version %d.%d.%d\n", JSONRPC_CPP_MAJOR_VERSION, JSONRPC_CPP_MINOR_VERSION, JSONRPC_CPP_PATCH_VERSION);
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return true;
    }

    if (inputfile->count == 0) {
        fprintf(stderr, "Invalid arguments: specfile must be provided.\n");
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return false;
    }

    try {
        procedures = SpecificationParser::GetProceduresFromFile(inputfile->filename[0]);
        if (verbose->count > 0)
        {
            fprintf(stdout, "Found %zu procedures in %s\n", procedures.size(), inputfile->filename[0]);
            for (unsigned int i = 0; i < procedures.size(); ++i) {
                if (procedures.at(i).GetProcedureType() == RPC_METHOD)
                {
                    fprintf(stdout, "\t[Method]         ");
                }
                else
                {
                    fprintf(stdout, "\t[Notification]   ");
                }
                fprintf(stdout, "%s\n", procedures.at(i).GetProcedureName().c_str());
            }
            fprintf(stdout, "\n");
        }

        if (cppserver->count > 0)
        {
            string filename;
            if (cppserverfile->count > 0)
                filename = cppserverfile->sval[0];
            else
                filename = CPPHelper::class2Filename(cppserver->sval[0]);
            if (verbose->count > 0)
                fprintf(stdout, "Generating C++ Serverstub to: %s\n", filename.c_str());
            stubgenerators.push_back(new CPPServerStubGenerator(cppserver->sval[0], procedures, filename));
        }

        if (cppclient->count > 0)
        {
            string filename;
            if (cppclientfile->count > 0)
                filename = cppclientfile->sval[0];
            else
                filename = CPPHelper::class2Filename(cppclient->sval[0]);
            if (verbose->count > 0)
                fprintf(stdout, "Generating C++ Clientstub to: %s\n", filename.c_str());
            stubgenerators.push_back(new CPPClientStubGenerator(cppclient->sval[0], procedures, filename));
        }

        if (jsclient->count > 0)
        {
            string filename;
            if (jsclientfile->count > 0)
                filename = jsclientfile->sval[0];
            else
                filename = JSClientStubGenerator::class2Filename(jsclient->sval[0]);

            if (verbose->count > 0)
                fprintf(stdout, "Generating JavaScript Clientstub to: %s\n", filename.c_str());
            stubgenerators.push_back(new JSClientStubGenerator(jsclient->sval[0], procedures, filename));
        }
    }
    catch (const JsonRpcException &ex)
    {
        fprintf(stderr, "%s\n", ex.what());
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return false;
    }
    arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
    return true;
}

void StubGeneratorFactory::deleteStubGenerators(std::vector<StubGenerator *> &stubgenerators)
{
    for (unsigned int i=0; i < stubgenerators.size(); ++i)
    {
        delete stubgenerators[i];
    }
}
<commit_msg>added pyclient to factory<commit_after>/*************************************************************************
 * libjson-rpc-cpp
 *************************************************************************
 * @file    stubgeneratorfactory.cpp
 * @date    11/19/2014
 * @author  Peter Spiess-Knafl <peter.knafl@gmail.com>
 * @license See attached LICENSE.txt
 ************************************************************************/

#include "stubgeneratorfactory.h"
#include <jsonrpccpp/common/specificationparser.h>
#include <jsonrpccpp/version.h>
#include <iostream>
#include <argtable2.h>
#include "helper/cpphelper.h"
#include "client/cppclientstubgenerator.h"
#include "client/jsclientstubgenerator.h"
#include "client/python_client_stub_generator.h"
#include "server/cppserverstubgenerator.h"

using namespace jsonrpc;
using namespace std;

bool StubGeneratorFactory::createStubGenerators(int argc, char **argv, vector<Procedure> &procedures, vector<StubGenerator*> &stubgenerators, FILE *stdout, FILE *stderr)
{
    struct arg_file *inputfile      = arg_file0(NULL, NULL, "<specfile>", "path of input specification file");
    struct arg_lit *help            = arg_lit0("h","help", "print this help and exit");
    struct arg_lit *version         = arg_lit0(NULL,"version", "print version and exit");
    struct arg_lit *verbose         = arg_lit0("v","verbose", "print more information about what is happening");
    struct arg_str *cppserver       = arg_str0(NULL, "cpp-server", "<namespace::classname>", "name of the C++ server stub class");
    struct arg_str *cppserverfile   = arg_str0(NULL, "cpp-server-file", "<filename.h>", "name of the C++ server stub file");
    struct arg_str *cppclient       = arg_str0(NULL, "cpp-client", "<namespace::classname>", "name of the C++ client stub class");
    struct arg_str *cppclientfile   = arg_str0(NULL, "cpp-client-file", "<filename.h>", "name of the C++ client stub file");
    struct arg_str *jsclient        = arg_str0(NULL, "js-client", "<classname>", "name of the JavaScript client stub class");
    struct arg_str *jsclientfile    = arg_str0(NULL, "js-client-file", "<filename.js>", "name of the JavaScript client stub file");
    struct arg_str *pyclient        = arg_str0(NULL, "python-client", "<classname>", "name of the Python client stub class");
    struct arg_str *pyclientfile    = arg_str0(NULL, "python-client-file", "<filename.python>", "name of the Python client stub file");

    struct arg_end *end         = arg_end(20);
    void* argtable[] = {inputfile, help, version, verbose, cppserver, cppserverfile, cppclient, cppclientfile, jsclient, jsclientfile, pyclient, pyclientfile, end};

    if (arg_parse(argc,argv,argtable) > 0)
    {
        arg_print_errors(stderr, end, argv[0]);
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return false;
    }

    if (help->count > 0)
    {
        fprintf(stdout, "Usage: %s ", argv[0]);
        arg_print_syntax(stdout,argtable,"\n"); cout << endl;
        arg_print_glossary_gnu(stdout, argtable);
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return true;
    }

    if (version->count > 0)
    {
        fprintf(stdout, "jsonrpcstub version %d.%d.%d\n", JSONRPC_CPP_MAJOR_VERSION, JSONRPC_CPP_MINOR_VERSION, JSONRPC_CPP_PATCH_VERSION);
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return true;
    }

    if (inputfile->count == 0) {
        fprintf(stderr, "Invalid arguments: specfile must be provided.\n");
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return false;
    }

    try {
        procedures = SpecificationParser::GetProceduresFromFile(inputfile->filename[0]);
        if (verbose->count > 0)
        {
            fprintf(stdout, "Found %zu procedures in %s\n", procedures.size(), inputfile->filename[0]);
            for (unsigned int i = 0; i < procedures.size(); ++i) {
                if (procedures.at(i).GetProcedureType() == RPC_METHOD)
                {
                    fprintf(stdout, "\t[Method]         ");
                }
                else
                {
                    fprintf(stdout, "\t[Notification]   ");
                }
                fprintf(stdout, "%s\n", procedures.at(i).GetProcedureName().c_str());
            }
            fprintf(stdout, "\n");
        }

        if (cppserver->count > 0)
        {
            string filename;
            if (cppserverfile->count > 0)
                filename = cppserverfile->sval[0];
            else
                filename = CPPHelper::class2Filename(cppserver->sval[0]);
            if (verbose->count > 0)
                fprintf(stdout, "Generating C++ Serverstub to: %s\n", filename.c_str());
            stubgenerators.push_back(new CPPServerStubGenerator(cppserver->sval[0], procedures, filename));
        }

        if (cppclient->count > 0)
        {
            string filename;
            if (cppclientfile->count > 0)
                filename = cppclientfile->sval[0];
            else
                filename = CPPHelper::class2Filename(cppclient->sval[0]);
            if (verbose->count > 0)
                fprintf(stdout, "Generating C++ Clientstub to: %s\n", filename.c_str());
            stubgenerators.push_back(new CPPClientStubGenerator(cppclient->sval[0], procedures, filename));
        }

        if (jsclient->count > 0)
        {
            string filename;
            if (jsclientfile->count > 0)
                filename = jsclientfile->sval[0];
            else
                filename = JSClientStubGenerator::class2Filename(jsclient->sval[0]);

            if (verbose->count > 0)
                fprintf(stdout, "Generating JavaScript Clientstub to: %s\n", filename.c_str());
            stubgenerators.push_back(new JSClientStubGenerator(jsclient->sval[0], procedures, filename));
        }

        if (pyclient->count > 0)
        {
            string filename;
            if (pyclientfile->count > 0)
                filename = pyclientfile->sval[0];
            else
                filename = PythonClientStubGenerator::class2Filename(pyclient->sval[0]);

            if (verbose->count > 0)
                fprintf(stdout, "Generating Python Clientstub to: %s\n", filename.c_str());
            stubgenerators.push_back(new PythonClientStubGenerator(pyclient->sval[0], procedures, filename));
        }
    }
    catch (const JsonRpcException &ex)
    {
        fprintf(stderr, "%s\n", ex.what());
        arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
        return false;
    }
    arg_freetable(argtable,sizeof(argtable)/sizeof(argtable[0]));
    return true;
}

void StubGeneratorFactory::deleteStubGenerators(std::vector<StubGenerator *> &stubgenerators)
{
    for (unsigned int i=0; i < stubgenerators.size(); ++i)
    {
        delete stubgenerators[i];
    }
}
<|endoftext|>


<commit_before>/* Copyright (C) LinBox
 *
 *
 *
 * ========LICENCE========
 * This file is part of the library LinBox.
 *
  * LinBox is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

#include "linbox/algorithms/diophantine-solver.h"

namespace LinBox
{

	const char* solverReturnString[6]
	= {"OK", "FAILED", "SINGULAR", "INCONSISTENT", "BAD_PRECONDITIONER", "BAD_PRIME"};

}

// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
<commit_msg>config first<commit_after>/* Copyright (C) LinBox
 *
 *
 *
 * ========LICENCE========
 * This file is part of the library LinBox.
 *
  * LinBox is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

#include "linbox/linbox-config.h"
#include "linbox/algorithms/diophantine-solver.h"

namespace LinBox
{

	const char* solverReturnString[6]
	= {"OK", "FAILED", "SINGULAR", "INCONSISTENT", "BAD_PRECONDITIONER", "BAD_PRIME"};

}

// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
<|endoftext|>