<commit_before>#include <opencv2/ts/ts.hpp>
#include <libcomparator.hpp>

class IterateH : public cvtest::BaseTest
{
public:
    IterateH(){}
protected:

    void run(int) {
      cv::Mat_<TYPE> mat(3, 3 * channels, 100);
      // cv::Vec<TYPE, channels> subPix;
      // subPix = static_cast<cv::Vec<TYPE, channels>>(cv::Matx<TYPE, channels, 1>::zeros());
      // mat.at<cv::Vec<TYPE, channels>>(cv::Point(3,3)) = subPix;
      mat(1,3)=0; mat(1,4)=0; mat(1,5)=0;
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      IterateProcess<TYPE> iterateProcess(mat, lightThreshold, colorThreshold, balance);

      std::vector<IndexTransition> result = iterateProcess.iterate_H();

      ASSERT_EQ(result.size(), 2);
      auto expected = IndexTransition{12, leftToRight};
      compareIndexTransition(result[0], expected);
      expected = IndexTransition{12, rightToLeft};
      compareIndexTransition(result[1], expected);

      // ASSERT_EQ(result[0], IndexTransition{12, rightToLeft});

  }

  void compareIndexTransition(IndexTransition& iT1, IndexTransition& iT2)
  {
    ASSERT_EQ(iT1.index, iT2.index);
    ASSERT_EQ(iT1.transition, iT2.transition);
  }
};
TEST(ComparatorLibSuite, IterateH) {
  IterateH iterateH;
  iterateH.safe_run();
}

class IterateV : public cvtest::BaseTest
{
public:
    IterateV(){}
protected:

    void run(int) {
      cv::Mat_<TYPE> mat(3, 3 * channels, 100);
      // cv::Vec<TYPE, channels> subPix;
      // subPix = static_cast<cv::Vec<TYPE, channels>>(cv::Matx<TYPE, channels, 1>::zeros());
      // mat.at<cv::Vec<TYPE, channels>>(cv::Point(3,3)) = subPix;
      mat(1,3)=0; mat(1,4)=0; mat(1,5)=0;
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      IterateProcess<TYPE> iterateProcess(mat, lightThreshold, colorThreshold, balance);

      std::vector<IndexTransition> result = iterateProcess.iterate_V();

      ASSERT_EQ(result.size(), 2);
      auto expected = IndexTransition{12, upToDown};
      compareIndexTransition(result[0], expected);
      expected = IndexTransition{12, downToUp};
      compareIndexTransition(result[1], expected);

      // ASSERT_EQ(result[0], IndexTransition{12, rightToLeft});

  }

  void compareIndexTransition(IndexTransition& iT1, IndexTransition& iT2)
  {
    ASSERT_EQ(iT1.index, iT2.index);
    ASSERT_EQ(iT1.transition, iT2.transition);
  }
};
TEST(ComparatorLibSuite, IterateV) {
  IterateV IterateV;
  IterateV.safe_run();
}

class Fclassifier : public cvtest::BaseTest
{
public:
    Fclassifier(){}
protected:

    void run(int) {
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      Classifier<TYPE> classifier(lightThreshold, colorThreshold, balance);

      TYPE pix0[] = {3, 3, 3};
      TYPE pix1[] = {3, 3, 3};

      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::no, classifier.f_classifier());

      std::fill( pix0, pix0 + channels, 3);
      std::fill( pix1, pix1 + channels, 10);
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::backward, classifier.f_classifier());

      std::fill( pix0, pix0 + channels, 10);
      std::fill( pix1, pix1 + channels, 3);
      classifier.copy_pix(pix0, pix1);
      if (Transition::forward != classifier.f_classifier())
          ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
      //check that all values are between 1 and 1 (and not Nan)
      // if (0 != cvtest::check(, 1, 1, 0) )
      //     ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);

  }
};
TEST(ComparatorLibSuite, f_classifier) {
  Fclassifier fclassifeir;
  fclassifeir.safe_run();
}

class FclassifierBT : public cvtest::BaseTest
{
public:
    FclassifierBT(){}
protected:

    void run(int) {
      ts->set_failed_test_info(cvtest::TS::OK);

      double balance[] = {2.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 4.0;

      Classifier<TYPE> classifier(lightThreshold, colorThreshold, balance);

      TYPE pix0[] = {3, 3, 3};
      TYPE pix1[] = {3, 3, 3};

      classifier.copy_pix(pix0, pix1);
      if (Transition::no != classifier.f_classifier())
          ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);

      std::fill( pix0, pix0 + channels, 6);
      std::fill( pix1, pix1 + channels, 10);
      pix0[0] = 4;
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::backward, classifier.f_classifier());

      std::fill( pix0, pix0 + channels, 10);
      std::fill( pix1, pix1 + channels, 3);
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::no, classifier.f_classifier());

      // std::fill( pix0, pix0 + channels, 10);
      // std::fill( pix1, pix1 + channels, 3);
      // pix0[0] = 5;
      // classifier.copy_pix(pix0, pix1);
      // if (Transition::backward != classifier.f_classifier())
      //     ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
      //check that all values are between 1 and 1 (and not Nan)
      // if (0 != cvtest::check(, 1, 1, 0) )
      //     ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);

  }
};
TEST(ComparatorLibSuite, f_classifierbt) {
  FclassifierBT fclassifierbt;
  fclassifierbt.safe_run();
}

#ifdef TEST_PRIVATE_PART

class LightAndColor : public cvtest::BaseTest
{
public:
    LightAndColor(){}
protected:

    void run(int) {
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      Classifier<TYPE> classifier(lightThreshold, colorThreshold, balance);

      TYPE pix0[] = {3, 3, 3};
      TYPE pix1[] = {10, 10, 10};

      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(21, classifier.light_distance());
      ASSERT_EQ(0, classifier.color_distance());

      pix1[0] = 13;
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(24, classifier.light_distance());
      ASSERT_EQ(6, classifier.color_distance());
  }
};
TEST(ComparatorPrivateLibSuite, PrivatePartClassifier) {
  LightAndColor lightAndColor;
  lightAndColor.safe_run();
}
#endif

// TEST(ComparatorLibSuite, ATestThatFails) {
//   bool mybool = false;
//   ASSERT_TRUE(mybool);
// }
<commit_msg>basic test finished 	modified:   ../test/comparatortest.cpp<commit_after>#include <opencv2/ts/ts.hpp>
#include <libcomparator.hpp>

class IterateTestMethods : public cvtest::BaseTest
{
public:
    IterateTestMethods(){}
protected:
  void compareIndexTransition(IndexTransition& iT1, IndexTransition& iT2)
  {
    ASSERT_EQ(iT1.index, iT2.index);
    ASSERT_EQ(iT1.transition, iT2.transition);
  }
};

class IterateHV : public IterateTestMethods
{
public:
    IterateHV(){}
protected:

    void run(int) {
      cv::Mat_<TYPE> mat(3, 3 * channels, 100);
      // cv::Vec<TYPE, channels> subPix;
      // subPix = static_cast<cv::Vec<TYPE, channels>>(cv::Matx<TYPE, channels, 1>::zeros());
      // mat.at<cv::Vec<TYPE, channels>>(cv::Point(3,3)) = subPix;
      mat(1,3)=0; mat(1,4)=0; mat(1,5)=0;
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      IterateProcess<TYPE> iterateProcess(mat, lightThreshold, colorThreshold, balance);

      std::vector<IndexTransition> result = iterateProcess.iterate_HV();

      ASSERT_EQ(result.size(), 4);
      auto expected = IndexTransition{12, leftToRight};
      compareIndexTransition(result[0], expected);
      expected = IndexTransition{12, rightToLeft};
      compareIndexTransition(result[1], expected);
      expected = IndexTransition{12, upToDown};
      compareIndexTransition(result[2], expected);
      expected = IndexTransition{12, downToUp};
      compareIndexTransition(result[3], expected);
  }
};
TEST(ComparatorLibSuite, IterateHV) {
  IterateHV IterateHV;
  IterateHV.safe_run();
}

#ifdef TEST_PRIVATE_PART

class IterateH : public IterateTestMethods
{
public:
    IterateH(){}
protected:

    void run(int) {
      cv::Mat_<TYPE> mat(3, 3 * channels, 100);
      // cv::Vec<TYPE, channels> subPix;
      // subPix = static_cast<cv::Vec<TYPE, channels>>(cv::Matx<TYPE, channels, 1>::zeros());
      // mat.at<cv::Vec<TYPE, channels>>(cv::Point(3,3)) = subPix;
      mat(1,3)=0; mat(1,4)=0; mat(1,5)=0;
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      IterateProcess<TYPE> iterateProcess(mat, lightThreshold, colorThreshold, balance);

      std::vector<IndexTransition> result = iterateProcess.iterate_H();

      ASSERT_EQ(result.size(), 2);
      auto expected = IndexTransition{12, leftToRight};
      compareIndexTransition(result[0], expected);
      expected = IndexTransition{12, rightToLeft};
      compareIndexTransition(result[1], expected);
  }
};
TEST(ComparatorLibSuite, IterateH) {
  IterateH iterateH;
  iterateH.safe_run();
}

class IterateV : public IterateTestMethods
{
public:
    IterateV(){}
protected:

    void run(int) {
      cv::Mat_<TYPE> mat(3, 3 * channels, 100);
      // cv::Vec<TYPE, channels> subPix;
      // subPix = static_cast<cv::Vec<TYPE, channels>>(cv::Matx<TYPE, channels, 1>::zeros());
      // mat.at<cv::Vec<TYPE, channels>>(cv::Point(3,3)) = subPix;
      mat(1,3)=0; mat(1,4)=0; mat(1,5)=0;
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      IterateProcess<TYPE> iterateProcess(mat, lightThreshold, colorThreshold, balance);

      std::vector<IndexTransition> result = iterateProcess.iterate_V();

      ASSERT_EQ(result.size(), 2);
      auto expected = IndexTransition{12, upToDown};
      compareIndexTransition(result[0], expected);
      expected = IndexTransition{12, downToUp};
      compareIndexTransition(result[1], expected);
  }
};
TEST(ComparatorLibSuite, IterateV) {
  IterateV IterateV;
  IterateV.safe_run();
}

#endif

class Fclassifier : public cvtest::BaseTest
{
public:
    Fclassifier(){}
protected:

    void run(int) {
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      Classifier<TYPE> classifier(lightThreshold, colorThreshold, balance);

      TYPE pix0[] = {3, 3, 3};
      TYPE pix1[] = {3, 3, 3};

      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::no, classifier.f_classifier());

      std::fill( pix0, pix0 + channels, 3);
      std::fill( pix1, pix1 + channels, 10);
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::backward, classifier.f_classifier());

      std::fill( pix0, pix0 + channels, 10);
      std::fill( pix1, pix1 + channels, 3);
      classifier.copy_pix(pix0, pix1);
      if (Transition::forward != classifier.f_classifier())
          ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
      //check that all values are between 1 and 1 (and not Nan)
      // if (0 != cvtest::check(, 1, 1, 0) )
      //     ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
  }
};
TEST(ComparatorLibSuite, f_classifier) {
  Fclassifier fclassifeir;
  fclassifeir.safe_run();
}

class FclassifierBT : public cvtest::BaseTest
{
public:
    FclassifierBT(){}
protected:

    void run(int) {
      ts->set_failed_test_info(cvtest::TS::OK);

      double balance[] = {2.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 4.0;

      Classifier<TYPE> classifier(lightThreshold, colorThreshold, balance);

      TYPE pix0[] = {3, 3, 3};
      TYPE pix1[] = {3, 3, 3};

      classifier.copy_pix(pix0, pix1);
      if (Transition::no != classifier.f_classifier())
          ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);

      std::fill( pix0, pix0 + channels, 6);
      std::fill( pix1, pix1 + channels, 10);
      pix0[0] = 4;
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::backward, classifier.f_classifier());

      std::fill( pix0, pix0 + channels, 10);
      std::fill( pix1, pix1 + channels, 3);
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(Transition::no, classifier.f_classifier());

      // std::fill( pix0, pix0 + channels, 10);
      // std::fill( pix1, pix1 + channels, 3);
      // pix0[0] = 5;
      // classifier.copy_pix(pix0, pix1);
      // if (Transition::backward != classifier.f_classifier())
      //     ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
      //check that all values are between 1 and 1 (and not Nan)
      // if (0 != cvtest::check(, 1, 1, 0) )
      //     ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);

  }
};
TEST(ComparatorLibSuite, f_classifierbt) {
  FclassifierBT fclassifierbt;
  fclassifierbt.safe_run();
}

#ifdef TEST_PRIVATE_PART

class LightAndColor : public cvtest::BaseTest
{
public:
    LightAndColor(){}
protected:

    void run(int) {
      double balance[] = {1.0, 1.0, 1.0};
      double lightThreshold = 1.0;
      double colorThreshold = 1.0;

      Classifier<TYPE> classifier(lightThreshold, colorThreshold, balance);

      TYPE pix0[] = {3, 3, 3};
      TYPE pix1[] = {10, 10, 10};

      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(21, classifier.light_distance());
      ASSERT_EQ(0, classifier.color_distance());

      pix1[0] = 13;
      classifier.copy_pix(pix0, pix1);
      ASSERT_EQ(24, classifier.light_distance());
      ASSERT_EQ(6, classifier.color_distance());
  }
};
TEST(ComparatorPrivateLibSuite, PrivatePartClassifier) {
  LightAndColor lightAndColor;
  lightAndColor.safe_run();
}
#endif

// TEST(ComparatorLibSuite, ATestThatFails) {
//   bool mybool = false;
//   ASSERT_TRUE(mybool);
// }
<|endoftext|>


<commit_before>/*
 * Copyright 2016 by Philip N. Garner
 *
 * See the file COPYING for the licence associated with this software.
 *
 * Author(s):
 *   Phil Garner, March 2016
 */

#include <istream>
#include <cctype>
#include <cstring>
#include <lube/var.h>

namespace libube
{
    /**
     * Ad-hoc JSON (JavaScript Object Notation) parser; (see http://json.org/)
     */
    class JSON
    {
    public:
        var operator ()(std::istream& iStream);
    private:
        char peek(std::istream& iStream);
        var doValue(std::istream& iStream);
        var doObject(std::istream& iStream);
        var doArray(std::istream& iStream);
        var doString(std::istream& iStream);
        var doRaw(std::istream& iStream);
    };
}

using namespace libube;
using namespace std;

/** Find the next character after whitespace */
char JSON::peek(std::istream& iStream)
{
    char c = iStream.peek();
    while (isspace(c))
    {
        iStream.get();
        c = iStream.peek();
    }
    return c;
}

var JSON::doValue(std::istream& iStream)
{
    var val;
    switch (peek(iStream))
    {
    case '{':
        val = doObject(iStream);
        break;
    case '[':
        val = doArray(iStream);
        break;
    case '"':
        val = doString(iStream);
        break;
    default:
        val = doRaw(iStream);
    }
    return val;
}

var JSON::doObject(std::istream& iStream)
{
    var obj;
    obj[nil];
    var key;
    char got = iStream.get();
    if (got != '{')
        throw error("JSON object doesn't start with {");
    while (iStream)
    {
        switch (peek(iStream))
        {
        case '}':
            iStream.get();
            return obj;
            break;
        case '"':
            key = doString(iStream);
            break;
        case ':':
            iStream.get();
            obj[key] = doValue(iStream);
            break;
        case ',':
            iStream.get();
            key = nil;
            break;
        default:
            throw error("Unknown character");
        }
    }
    return obj;
}

var JSON::doArray(std::istream& iStream)
{
    var arr;
    char got = iStream.get();
    if (got != '[')
        throw error("JSON array doesn't start with [");
    while (iStream)
    {
        switch (peek(iStream))
        {
        case ']':
            iStream.get();
            return arr;
            break;
        case ',':
            iStream.get();
            break;
        default:
            arr.push(doValue(iStream));
        }
    }
    return arr;
}

var JSON::doString(std::istream& iStream)
{
    var str;
    char got = iStream.get();
    if (got != '\"')
        throw error("JSON string doesn't start with \"");
    // Not robust to escapes yet
    while (iStream.get(got))
        if (got == '"')
            break;
        else
            str.push(got);
    return str;
}

var JSON::doRaw(std::istream& iStream)
{
    // Read up to a space or JSON delimiter
    var val;
    char c;
    while (iStream.get(c))
    {
        if (isspace(c))
            break;
        if (strchr(",[]{}", c))
            break;
        val.push(c);
    }

    // These values have special meanings
    if (val == "true")
        return 1;
    else if (val == "false")
        return 0;
    else if (val == "null")
        return nil;

    // It's probably a number, but return a string for the moment
    return val;
}

/**
 * For proper JSON we should call doObject(), mandating it be in braces.  In
 * calling doValue() we're allowing just raw values which is OK for lube but
 * not strictly JSON.
 */
var JSON::operator()(std::istream& iStream)
{
    var val = doValue(iStream);
    return val;
}

std::istream& libube::operator >>(std::istream& iStream, var& ioVar)
{
    JSON json;
    var in = json(iStream);
    ioVar = in;
    return iStream;
}
<commit_msg>Make the JSON parser robust to escapes and single character strings<commit_after>/*
 * Copyright 2016 by Philip N. Garner
 *
 * See the file COPYING for the licence associated with this software.
 *
 * Author(s):
 *   Phil Garner, March 2016
 */

#include <istream>
#include <cctype>
#include <cstring>
#include <lube/var.h>

namespace libube
{
    /**
     * Ad-hoc JSON (JavaScript Object Notation) parser; (see http://json.org/)
     */
    class JSON
    {
    public:
        var operator ()(std::istream& iStream);
    private:
        char peek(std::istream& iStream);
        var doValue(std::istream& iStream);
        var doObject(std::istream& iStream);
        var doArray(std::istream& iStream);
        var doString(std::istream& iStream);
        var doRaw(std::istream& iStream);
    };
}

using namespace libube;
using namespace std;

/** Find the next character after whitespace */
char JSON::peek(std::istream& iStream)
{
    char c = iStream.peek();
    while (isspace(c))
    {
        iStream.get();
        c = iStream.peek();
    }
    return c;
}

var JSON::doValue(std::istream& iStream)
{
    var val;
    switch (peek(iStream))
    {
    case '{':
        val = doObject(iStream);
        break;
    case '[':
        val = doArray(iStream);
        break;
    case '"':
        val = doString(iStream);
        break;
    default:
        val = doRaw(iStream);
    }
    return val;
}

var JSON::doObject(std::istream& iStream)
{
    var obj;
    obj[nil];
    var key;
    char got = iStream.get();
    if (got != '{')
        throw error("JSON object doesn't start with {");
    while (iStream)
    {
        switch (peek(iStream))
        {
        case '}':
            iStream.get();
            return obj;
            break;
        case '"':
            key = doString(iStream);
            break;
        case ':':
            iStream.get();
            obj[key] = doValue(iStream);
            break;
        case ',':
            iStream.get();
            key = nil;
            break;
        default:
            throw error("Unknown character");
        }
    }
    return obj;
}

var JSON::doArray(std::istream& iStream)
{
    var arr;
    char got = iStream.get();
    if (got != '[')
        throw error("JSON array doesn't start with [");
    while (iStream)
    {
        switch (peek(iStream))
        {
        case ']':
            iStream.get();
            return arr;
            break;
        case ',':
            iStream.get();
            break;
        default:
            arr.push(doValue(iStream));
        }
    }
    return arr;
}

var JSON::doString(std::istream& iStream)
{
    var str = "";
    char got = iStream.get();
    if (got != '\"')
        throw error("JSON string doesn't start with \"");
    while (iStream.get(got))
        switch (got)
        {
        case '\"':
            return str;
        case '\\':
            // Escape character
            got = iStream.get();
            switch (got)
            {
            case '\"':
                str.push(got);
                break;
            default:
                throw error("Unrecognised JSON string escape");
            }
            break;
        default:
            str.push(got);
        }
    throw error("Unterminated JSON string");
    return nil;
}

var JSON::doRaw(std::istream& iStream)
{
    // Read up to a space or JSON delimiter
    var val = "";
    char c;
    while (iStream.get(c))
    {
        if (isspace(c))
            break;
        if (strchr(",[]{}", c))
            break;
        val.push(c);
    }

    // These values have special meanings
    if (val == "true")
        return 1;
    else if (val == "false")
        return 0;
    else if (val == "null")
        return nil;

    // It's probably a number, but return a string for the moment
    return val;
}

/**
 * For proper JSON we should call doObject(), mandating it be in braces.  In
 * calling doValue() we're allowing just raw values which is OK for lube but
 * not strictly JSON.
 */
var JSON::operator()(std::istream& iStream)
{
    var val = doValue(iStream);
    return val;
}

std::istream& libube::operator >>(std::istream& iStream, var& ioVar)
{
    JSON json;
    var in = json(iStream);
    ioVar = in;
    return iStream;
}
<|endoftext|>


<commit_before>// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2015 Intel Corporation. All Rights Reserved.

#pragma once

#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>

#include <string>
#include <sstream>
#include <iostream>

//////////////////////////////
// Basic Data Types         //
//////////////////////////////

struct float3 { float x, y, z; };
struct float2 { float x, y; };

struct rect
{
    float x, y;
    float w, h;

    // Create new rect within original boundaries with give aspect ration
    rect adjust_ratio(float2 size) const
    {
        auto H = static_cast<float>(h), W = static_cast<float>(h) * size.x / size.y;
        if (W > w)
        {
            auto scale = w / W;
            W *= scale;
            H *= scale;
        }

        return{ x + (w - W) / 2, y + (h - H) / 2, W, H };
    }
};

//////////////////////////////
// Simple font loading code //
//////////////////////////////

#include "../third-party/stb_easy_font.h"

inline void draw_text(int x, int y, const char * text)
{
    char buffer[60000]; // ~300 chars
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_FLOAT, 16, buffer);
    glDrawArrays(GL_QUADS, 0, 4 * stb_easy_font_print((float)x, (float)(y - 7), (char *)text, nullptr, buffer, sizeof(buffer)));
    glDisableClientState(GL_VERTEX_ARRAY);
}

////////////////////////
// Image display code //
////////////////////////

class texture
{
public:
    void render(const rs2::video_frame& frame, const rect& r)
    {
        upload(frame);
        show(r.adjust_ratio({ float(width), float(height) }));
    }

    void upload(const rs2::video_frame& frame)
    {
        if (!frame) return;

        if (!gl_handle)
            glGenTextures(1, &gl_handle);
        GLenum err = glGetError();

        auto format = frame.get_profile().format();
        width = frame.get_width();
        height = frame.get_height();
        stream = frame.get_profile().stream_type();

        glBindTexture(GL_TEXTURE_2D, gl_handle);

        switch (format)
        {
        case RS2_FORMAT_RGB8:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, frame.get_data());
            break;
        case RS2_FORMAT_Y8:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, frame.get_data());
            break;
        default:
            throw std::runtime_error("The requested format is not supported by this demo!");
        }

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
        glBindTexture(GL_TEXTURE_2D, 0);
    }

    GLuint get_gl_handle() { return gl_handle; }

    void show(const rect& r) const
    {
        if (!gl_handle)
            return;

        glBindTexture(GL_TEXTURE_2D, gl_handle);
        glEnable(GL_TEXTURE_2D);
        glBegin(GL_QUAD_STRIP);
        glTexCoord2f(0.f, 1.f); glVertex2f(r.x, r.y + r.h);
        glTexCoord2f(0.f, 0.f); glVertex2f(r.x, r.y);
        glTexCoord2f(1.f, 1.f); glVertex2f(r.x + r.w, r.y + r.h);
        glTexCoord2f(1.f, 0.f); glVertex2f(r.x + r.w, r.y);
        glEnd();
        glDisable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, 0);

        draw_text((int)r.x + 15, (int)r.y + 20, rs2_stream_to_string(stream));
    }
private:
    GLuint gl_handle = 0;
    int width = 0;
    int height = 0;
    rs2_stream stream = RS2_STREAM_ANY;
};

class window
{
public:
    std::function<void(bool)>           on_left_mouse   = [](bool) {};
    std::function<void(double, double)> on_mouse_scroll = [](double, double) {};
    std::function<void(double, double)> on_mouse_move   = [](double, double) {};
    std::function<void(int)>            on_key_release  = [](int) {};

    window(int width, int height, const char* title)
        : _width(width), _height(height)
    {
        glfwInit();
        win = glfwCreateWindow(width, height, title, nullptr, nullptr);
        glfwMakeContextCurrent(win);

        glfwSetWindowUserPointer(win, this);
        glfwSetMouseButtonCallback(win, [](GLFWwindow * win, int button, int action, int mods)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            if (button == 0) s->on_left_mouse(action == GLFW_PRESS);
        });

        glfwSetScrollCallback(win, [](GLFWwindow * win, double xoffset, double yoffset)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            s->on_mouse_scroll(xoffset, yoffset);
        });

        glfwSetCursorPosCallback(win, [](GLFWwindow * win, double x, double y)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            s->on_mouse_move(x, y);
        });

        glfwSetKeyCallback(win, [](GLFWwindow * win, int key, int scancode, int action, int mods)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            if (0 == action) // on key release
            {
                s->on_key_release(key);
            }
        });
    }

    float width() const { return float(_width); }
    float height() const { return float(_height); }

    operator bool()
    {
        glPopMatrix();
        glfwSwapBuffers(win);

        auto res = !glfwWindowShouldClose(win);

        glfwPollEvents();
        glfwGetFramebufferSize(win, &_width, &_height);

        // Clear the framebuffer
        glClear(GL_COLOR_BUFFER_BIT);
        glViewport(0, 0, _width, _height);

        // Draw the images
        glPushMatrix();
        glfwGetWindowSize(win, &_width, &_height);
        glOrtho(0, _width, _height, 0, -1, +1);

        return res;
    }

    ~window()
    {
        glfwDestroyWindow(win);
        glfwTerminate();
    }

    operator GLFWwindow*() { return win; }

private:
    GLFWwindow* win;
    int _width, _height;
};
<commit_msg>Adding rendering for RGBA in example.hpp<commit_after>// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2015 Intel Corporation. All Rights Reserved.

#pragma once

#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>

#include <string>
#include <sstream>
#include <iostream>

//////////////////////////////
// Basic Data Types         //
//////////////////////////////

struct float3 { float x, y, z; };
struct float2 { float x, y; };

struct rect
{
    float x, y;
    float w, h;

    // Create new rect within original boundaries with give aspect ration
    rect adjust_ratio(float2 size) const
    {
        auto H = static_cast<float>(h), W = static_cast<float>(h) * size.x / size.y;
        if (W > w)
        {
            auto scale = w / W;
            W *= scale;
            H *= scale;
        }

        return{ x + (w - W) / 2, y + (h - H) / 2, W, H };
    }
};

//////////////////////////////
// Simple font loading code //
//////////////////////////////

#include "../third-party/stb_easy_font.h"

inline void draw_text(int x, int y, const char * text)
{
    char buffer[60000]; // ~300 chars
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_FLOAT, 16, buffer);
    glDrawArrays(GL_QUADS, 0, 4 * stb_easy_font_print((float)x, (float)(y - 7), (char *)text, nullptr, buffer, sizeof(buffer)));
    glDisableClientState(GL_VERTEX_ARRAY);
}

////////////////////////
// Image display code //
////////////////////////

class texture
{
public:
    void render(const rs2::video_frame& frame, const rect& r)
    {
        upload(frame);
        show(r.adjust_ratio({ float(width), float(height) }));
    }

    void upload(const rs2::video_frame& frame)
    {
        if (!frame) return;

        if (!gl_handle)
            glGenTextures(1, &gl_handle);
        GLenum err = glGetError();

        auto format = frame.get_profile().format();
        width = frame.get_width();
        height = frame.get_height();
        stream = frame.get_profile().stream_type();

        glBindTexture(GL_TEXTURE_2D, gl_handle);

        switch (format)
        {
        case RS2_FORMAT_RGB8:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, frame.get_data());
            break;
        case RS2_FORMAT_RGBA8:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, frame.get_data());
            break;
        case RS2_FORMAT_Y8:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, frame.get_data());
            break;
        default:
            throw std::runtime_error("The requested format is not supported by this demo!");
        }

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
        glBindTexture(GL_TEXTURE_2D, 0);
    }

    GLuint get_gl_handle() { return gl_handle; }

    void show(const rect& r) const
    {
        if (!gl_handle)
            return;

        glBindTexture(GL_TEXTURE_2D, gl_handle);
        glEnable(GL_TEXTURE_2D);
        glBegin(GL_QUAD_STRIP);
        glTexCoord2f(0.f, 1.f); glVertex2f(r.x, r.y + r.h);
        glTexCoord2f(0.f, 0.f); glVertex2f(r.x, r.y);
        glTexCoord2f(1.f, 1.f); glVertex2f(r.x + r.w, r.y + r.h);
        glTexCoord2f(1.f, 0.f); glVertex2f(r.x + r.w, r.y);
        glEnd();
        glDisable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, 0);

        draw_text((int)r.x + 15, (int)r.y + 20, rs2_stream_to_string(stream));
    }
private:
    GLuint gl_handle = 0;
    int width = 0;
    int height = 0;
    rs2_stream stream = RS2_STREAM_ANY;
};

class window
{
public:
    std::function<void(bool)>           on_left_mouse   = [](bool) {};
    std::function<void(double, double)> on_mouse_scroll = [](double, double) {};
    std::function<void(double, double)> on_mouse_move   = [](double, double) {};
    std::function<void(int)>            on_key_release  = [](int) {};

    window(int width, int height, const char* title)
        : _width(width), _height(height)
    {
        glfwInit();
        win = glfwCreateWindow(width, height, title, nullptr, nullptr);
        glfwMakeContextCurrent(win);

        glfwSetWindowUserPointer(win, this);
        glfwSetMouseButtonCallback(win, [](GLFWwindow * win, int button, int action, int mods)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            if (button == 0) s->on_left_mouse(action == GLFW_PRESS);
        });

        glfwSetScrollCallback(win, [](GLFWwindow * win, double xoffset, double yoffset)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            s->on_mouse_scroll(xoffset, yoffset);
        });

        glfwSetCursorPosCallback(win, [](GLFWwindow * win, double x, double y)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            s->on_mouse_move(x, y);
        });

        glfwSetKeyCallback(win, [](GLFWwindow * win, int key, int scancode, int action, int mods)
        {
            auto s = (window*)glfwGetWindowUserPointer(win);
            if (0 == action) // on key release
            {
                s->on_key_release(key);
            }
        });
    }

    float width() const { return float(_width); }
    float height() const { return float(_height); }

    operator bool()
    {
        glPopMatrix();
        glfwSwapBuffers(win);

        auto res = !glfwWindowShouldClose(win);

        glfwPollEvents();
        glfwGetFramebufferSize(win, &_width, &_height);

        // Clear the framebuffer
        glClear(GL_COLOR_BUFFER_BIT);
        glViewport(0, 0, _width, _height);

        // Draw the images
        glPushMatrix();
        glfwGetWindowSize(win, &_width, &_height);
        glOrtho(0, _width, _height, 0, -1, +1);

        return res;
    }

    ~window()
    {
        glfwDestroyWindow(win);
        glfwTerminate();
    }

    operator GLFWwindow*() { return win; }

private:
    GLFWwindow* win;
    int _width, _height;
};
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2011, Peter Thorson. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the WebSocket++ Project nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#include "echo.hpp"

#include "../../src/websocketpp.hpp"
#include <boost/asio.hpp>

#include <iostream>

using boost::asio::ip::tcp;

int main(int argc, char* argv[]) {
	std::string host = "localhost:5000";
	short port = 5000;

	if (argc == 3) {
		// TODO: input validation?
		port = atoi(argv[2]);

		std::stringstream temp;
		temp << argv[1] << ":" << port;

		host = temp.str();
	}

	websocketecho::echo_handler_ptr echo_handler(new websocketecho::echo_handler());

	try {
		boost::asio::io_service io_service;
		tcp::endpoint endpoint(tcp::v6(), port);

		websocketpp::server_ptr server(
			new websocketpp::server(io_service,endpoint,echo_handler)
		);

		// setup server settings
		server->add_host(host);

		// bump up max message size to maximum since we may be using the echo
		// server to test performance and protocol extremes.
		server->set_max_message_size(websocketpp::frame::PAYLOAD_64BIT_LIMIT);

		// start the server
		server->start_accept();

		std::cout << "Starting echo server on " << host << std::endl;

		// start asio
		io_service.run();
	} catch (std::exception& e) {
		std::cerr << "Exception: " << e.what() << std::endl;
	}

	return 0;
}
<commit_msg>echo server now accepts `host` in addition to `host:port` as a value for the Host handshake header<commit_after>/*
 * Copyright (c) 2011, Peter Thorson. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the WebSocket++ Project nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#include "echo.hpp"

#include "../../src/websocketpp.hpp"
#include <boost/asio.hpp>

#include <iostream>

using boost::asio::ip::tcp;

int main(int argc, char* argv[]) {
	std::string host = "localhost";
	short port = 5000;
	std::string full_host;

	if (argc == 3) {
		// TODO: input validation?
		host = argv[1];
		port = atoi(argv[2]);
	}

	std::stringstream temp;

	temp << argv[1] << ":" << port;
	full_host = temp.str();

	websocketecho::echo_handler_ptr echo_handler(new websocketecho::echo_handler());

	try {
		boost::asio::io_service io_service;
		tcp::endpoint endpoint(tcp::v6(), port);

		websocketpp::server_ptr server(
			new websocketpp::server(io_service,endpoint,echo_handler)
		);

		// setup server settings
		server->add_host(host);
		server->add_host(full_host);

		// bump up max message size to maximum since we may be using the echo
		// server to test performance and protocol extremes.
		server->set_max_message_size(websocketpp::frame::PAYLOAD_64BIT_LIMIT);

		// start the server
		server->start_accept();

		std::cout << "Starting echo server on " << full_host << std::endl;

		// start asio
		io_service.run();
	} catch (std::exception& e) {
		std::cerr << "Exception: " << e.what() << std::endl;
	}

	return 0;
}
<|endoftext|>


<commit_before>#include <math.h> // fmodf
#include "engine.h"
#include "gui.h"
#include "world.h"
#include "client.h"
#include "menu.h"
#include "cvar.h"
#include "edit.h"

#include "r_pipeline.h"
#include "r_gui.h"

#include "u_file.h"
#include "u_misc.h"

// Game globals
bool gRunning = true;
bool gPlaying = false;
world::descriptor *gSelected = nullptr; // Selected world entity
client gClient;
world gWorld;
r::pipeline gPipeline;
m::perspective gPerspective;

VAR(float, cl_fov, "field of view", 45.0f, 270.0f, 90.0f);
VAR(float, cl_nearp, "near plane", 0.0f, 10.0f, 0.1f);
VAR(float, cl_farp, "far plane", 128.0f, 4096.0f, 2048.0f);

static void setBinds() {
    neoBindSet("MouseDnL", []() {
        if (varGet<int>("cl_edit").get() && (gMenuState == 0 || gMenuState == kMenuConsole))
            edit::select();
    });

    neoBindSet("EscapeDn", []() {
        if (gPlaying && (gMenuState & kMenuMain)) {
            if (gMenuState & kMenuConsole) {
                gMenuState = kMenuConsole;
            } else {
                gMenuState &= ~kMenuMain;
            }
        } else if (!(gMenuState & kMenuEdit) && !(gMenuState & kMenuColorGrading)) {
            // If the console is opened leave it open
            if (!(gMenuState & kMenuMain)) {
                neoRelativeMouse(false);
                neoCenterMouse();
            }
            gMenuState = (gMenuState & kMenuConsole)
                ? kMenuMain | kMenuConsole
                : kMenuMain;
        } else {
            gMenuState &= ~kMenuEdit;
            gMenuState &= ~kMenuColorGrading;
            gMenuState &= ~kMenuDeveloper;
        }
        neoRelativeMouse(gPlaying && (gMenuState & ~kMenuConsole) == 0);
        menuReset();
    });

    neoBindSet("F8Dn", []() {
        neoScreenShot();
    });

    neoBindSet("F9Dn", []() {
        neoRelativeMouse(false);
        neoCenterMouse();
        gMenuState ^= kMenuDeveloper;
    });

    neoBindSet("F10Dn", []() {
        if (varGet<int>("cl_edit").get())
            gMenuState ^= kMenuColorGrading;
        neoRelativeMouse(!((gMenuState & kMenuEdit) || (gMenuState & kMenuColorGrading)));
    });

    neoBindSet("F11Dn", []() {
        gMenuState ^= kMenuConsole;
    });

    neoBindSet("F12Dn", []() {
        if (varGet<int>("cl_edit").get())
            gMenuState ^= kMenuEdit;
        neoRelativeMouse(!(gMenuState & kMenuEdit));
    });

    neoBindSet("EDn", []() {
        if (gPlaying) {
            varGet<int>("cl_edit").toggle();
            gMenuState &= ~kMenuEdit;
            neoRelativeMouse(!(gMenuState & kMenuEdit));
        }
        edit::deselect();
    });

    neoBindSet("DeleteDn", []() {
        edit::remove();
    });
}

int neoMain(frameTimer &timer, int, char **, bool &shutdown) {
    // Setup rendering pipeline
    gPerspective.fov = cl_fov;
    gPerspective.nearp = cl_nearp;
    gPerspective.farp = cl_farp;
    gPerspective.width = neoWidth();
    gPerspective.height = neoHeight();

    gPipeline.setWorld(m::vec3::origin);

    // Clear the screen as soon as possible
    gl::ClearColor(40/255.0f, 30/255.0f, 50/255.0f, 0.1f);
    gl::Clear(GL_COLOR_BUFFER_BIT);
    neoSwap();

    setBinds();

    r::gui gGui;
    if (!gGui.load("fonts/droidsans"))
        neoFatal("failed to load font");
    if (!gGui.upload())
        neoFatal("failed to initialize GUI rendering method\n");

    // Setup window and menu
    menuReset();
    neoSetWindowTitle("Neothyne");
    neoCenterMouse();

#if 1
    // Setup some lights
    const m::vec3 places[] = {
        m::vec3(153.04, 105.02, 197.67)
    };

    pointLight light;
    light.diffuse = 1.0f;
    light.ambient = 0.10f;
    light.radius = 30.0f;
    for (size_t i = 0; i < sizeof(places)/sizeof(*places); i++) {
        light.color = { u::randf(), u::randf(), u::randf() };
        light.position = places[i];
        //light.position.y -= 5.0f;
        gWorld.insert(light);
    }
    light.position = { 0, 110, 0 };
    gWorld.insert(light);

    // World only has one directional light
    directionalLight &dlight = gWorld.getDirectionalLight();
    dlight.color = { 0.2, 0.2, 0.2 };
    dlight.ambient = 0.10f;
    dlight.diffuse = 0.50f;
    dlight.direction = { -1.0f, 0.0f, 0.0f };

    // and some map models
    mapModel m;
    m.name = "models/iqmtest";
    m.position = { 40, 95, 0 };
    m.rotate = { 0, -90, 0 };
    gWorld.insert(m);

    m.name = "models/cube";
    m.position = { 85, 112, 35 };
    gWorld.insert(m);

    m.name = "models/ball";
    m.position = { 100, 110, 90 };
    m.scale = { 10, 10, 10 };

    gWorld.insert(m);

    if (!gWorld.load("garden.kdgz"))
        neoFatal("failed to load world");
#endif

    while (gRunning && !shutdown) {
        gClient.update(gWorld, timer.delta());

        gPerspective.fov = cl_fov;
        gPerspective.nearp = cl_nearp;
        gPerspective.farp = cl_farp;
        gPerspective.width = neoWidth();
        gPerspective.height = neoHeight();

        gPipeline.setPerspective(gPerspective);
        gPipeline.setRotation(gClient.getRotation());
        gPipeline.setPosition(gClient.getPosition());
        gPipeline.setTime(timer.ticks());
        gPipeline.setDelta(timer.delta());

        auto mouse = neoMouseState();

        // Update dragging/moving entity
        if (mouse.button & mouseState::kMouseButtonLeft && gSelected && !(gMenuState & kMenuEdit))
            edit::move();

        if (gPlaying && gWorld.isLoaded()) {
            gWorld.upload(gPerspective);
            gl::ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            gWorld.render(gPipeline);
            gGui.render(gPipeline);
            gui::begin(mouse);
        } else {
            gl::ClearColor(40/255.0f, 30/255.0f, 50/255.0f, 0.1f);
            gl::Clear(GL_COLOR_BUFFER_BIT);
            gGui.render(gPipeline);
            gui::begin(mouse);
        }
        neoSwap();

        if (!gPlaying) {
            // Render the model (for testing only)
            r::pipeline p;
            m::perspective pp = gPerspective;

            const m::vec3 rot(0.0f, -(fmodf(gPipeline.time() / 10.0f, 361.0f)), 0.0f);
            m::quat ry(m::toRadian(rot.y), m::vec3::yAxis);
            m::mat4 rotate;
            ry.getMatrix(&rotate);
            p.setRotate(rotate);

            int w = neoWidth() / 12;
            int h = neoHeight() / 12;
            pp.width = w;
            pp.height = h;

            p.setPerspective(pp);
            p.setWorld({0, 0, 0});
            p.setPosition({0, 0, -1.5f});
            p.setScale({1, 1, 1});

            gui::drawModel(128 / neoWidth(),
                           neoHeight() / 128 + 16, // 16 to keep above command line
                           w,
                           h, "models/icon", p);
        }

        // Must come first as we want the menu to go over the cross hair if it's
        // launched after playing
        if (gPlaying && !(gMenuState & ~kMenuConsole)) {
            gui::drawLine(neoWidth() / 2, neoHeight() / 2 - 10, neoWidth() / 2, neoHeight() / 2 - 4, 2, 0xFFFFFFE1);
            gui::drawLine(neoWidth() / 2, neoHeight() / 2 + 4, neoWidth() / 2, neoHeight() / 2 + 10, 2, 0xFFFFFFE1);
            gui::drawLine(neoWidth() / 2 + 10, neoHeight() / 2, neoWidth() / 2 + 4, neoHeight() / 2, 2, 0xFFFFFFE1);
            gui::drawLine(neoWidth() / 2 - 10, neoHeight() / 2, neoWidth() / 2 - 4, neoHeight() / 2, 2, 0xFFFFFFE1);
        }
        if (!gPlaying) {
            const size_t w = neoWidth();
            const size_t h = (neoHeight() / 2);
            const size_t x = neoWidth() / 2 - w / 2; // Center on X
            const size_t y = neoHeight() - h;

            r::pipeline p;
            m::perspective pp = gPerspective;
            pp.width = w;
            pp.height = h;
            pp.fov = 20.0f;
            p.setPerspective(pp);
            p.setWorld({0, 0, 0});
            p.setPosition({0, 0, -130});
            p.setScale({1, 1, 1});

            gui::drawModel(x, y, w, h, "models/logo", p);
        }

        menuUpdate();

        // Render FPS/MSPF
        gui::drawText(neoWidth(), 10, gui::kAlignRight,
            u::format("%d fps : %.2f mspf\n", timer.fps(), timer.mspf()).c_str(),
            gui::RGBA(255, 255, 255, 255));

        if (varGet<int>("cl_edit").get() && !(gMenuState & kMenuEdit)) {
            gui::drawText(neoWidth() / 2, neoHeight() - 20, gui::kAlignCenter, "F12 to toggle edit menu",
                gui::RGBA(0, 0, 0, 255));
            gui::drawText(neoWidth() / 2, neoHeight() - 40, gui::kAlignCenter, "F10 to toggle color grading menu",
                gui::RGBA(0, 0, 0, 255));
        }

        u::string inputText;
        textState text = neoTextState(inputText);
        if (text != textState::kInactive) {
            gui::drawTriangle(5, 10, 10, 10, 1, gui::RGBA(155, 155, 155, 255));
            gui::drawText(20, 10, gui::kAlignLeft,
                inputText.c_str(), gui::RGBA(255, 255, 255, 255));
            if (text == textState::kFinished) {
                auto values = u::split(inputText);
                if (values.size() == 2) {
                    switch (varChange(values[0], values[1])) {
                    case kVarSuccess:
                        u::print("changed `%s' to `%s'\n", values[0], values[1]);
                        break;
                    case kVarRangeError:
                        u::print("invalid range for `%s'\n", values[0]);
                        break;
                    case kVarTypeError:
                        u::print("invalid type for `%s'\n", values[0]);
                        break;
                    case kVarNotFoundError:
                        u::print("variable `%s' not found\n", values[0]);
                        break;
                    case kVarReadOnlyError:
                        u::print("variable `%s' is read-only\n", values[0]);
                        break;
                    }
                } else if (values.size() == 1) {
                    if (values[0] == "quit" || values[0] == "exit")
                        gRunning = false;
                }
            }
        }

        // Cursor above all else
        if ((gMenuState & ~kMenuConsole || gMenuState & kMenuEdit || gMenuState & kMenuCreate) && !neoRelativeMouse())
            gui::drawImage(mouse.x, mouse.y - (32 - 3), 32, 32, "textures/ui/cursor");

        gui::finish();
    }

    return 0;
}
<commit_msg>Offset FPS/MSPF 10 pixels from the edge<commit_after>#include <math.h> // fmodf
#include "engine.h"
#include "gui.h"
#include "world.h"
#include "client.h"
#include "menu.h"
#include "cvar.h"
#include "edit.h"

#include "r_pipeline.h"
#include "r_gui.h"

#include "u_file.h"
#include "u_misc.h"

// Game globals
bool gRunning = true;
bool gPlaying = false;
world::descriptor *gSelected = nullptr; // Selected world entity
client gClient;
world gWorld;
r::pipeline gPipeline;
m::perspective gPerspective;

VAR(float, cl_fov, "field of view", 45.0f, 270.0f, 90.0f);
VAR(float, cl_nearp, "near plane", 0.0f, 10.0f, 0.1f);
VAR(float, cl_farp, "far plane", 128.0f, 4096.0f, 2048.0f);

static void setBinds() {
    neoBindSet("MouseDnL", []() {
        if (varGet<int>("cl_edit").get() && (gMenuState == 0 || gMenuState == kMenuConsole))
            edit::select();
    });

    neoBindSet("EscapeDn", []() {
        if (gPlaying && (gMenuState & kMenuMain)) {
            if (gMenuState & kMenuConsole) {
                gMenuState = kMenuConsole;
            } else {
                gMenuState &= ~kMenuMain;
            }
        } else if (!(gMenuState & kMenuEdit) && !(gMenuState & kMenuColorGrading)) {
            // If the console is opened leave it open
            if (!(gMenuState & kMenuMain)) {
                neoRelativeMouse(false);
                neoCenterMouse();
            }
            gMenuState = (gMenuState & kMenuConsole)
                ? kMenuMain | kMenuConsole
                : kMenuMain;
        } else {
            gMenuState &= ~kMenuEdit;
            gMenuState &= ~kMenuColorGrading;
            gMenuState &= ~kMenuDeveloper;
        }
        neoRelativeMouse(gPlaying && (gMenuState & ~kMenuConsole) == 0);
        menuReset();
    });

    neoBindSet("F8Dn", []() {
        neoScreenShot();
    });

    neoBindSet("F9Dn", []() {
        neoRelativeMouse(false);
        neoCenterMouse();
        gMenuState ^= kMenuDeveloper;
    });

    neoBindSet("F10Dn", []() {
        if (varGet<int>("cl_edit").get())
            gMenuState ^= kMenuColorGrading;
        neoRelativeMouse(!((gMenuState & kMenuEdit) || (gMenuState & kMenuColorGrading)));
    });

    neoBindSet("F11Dn", []() {
        gMenuState ^= kMenuConsole;
    });

    neoBindSet("F12Dn", []() {
        if (varGet<int>("cl_edit").get())
            gMenuState ^= kMenuEdit;
        neoRelativeMouse(!(gMenuState & kMenuEdit));
    });

    neoBindSet("EDn", []() {
        if (gPlaying) {
            varGet<int>("cl_edit").toggle();
            gMenuState &= ~kMenuEdit;
            neoRelativeMouse(!(gMenuState & kMenuEdit));
        }
        edit::deselect();
    });

    neoBindSet("DeleteDn", []() {
        edit::remove();
    });
}

int neoMain(frameTimer &timer, int, char **, bool &shutdown) {
    // Setup rendering pipeline
    gPerspective.fov = cl_fov;
    gPerspective.nearp = cl_nearp;
    gPerspective.farp = cl_farp;
    gPerspective.width = neoWidth();
    gPerspective.height = neoHeight();

    gPipeline.setWorld(m::vec3::origin);

    // Clear the screen as soon as possible
    gl::ClearColor(40/255.0f, 30/255.0f, 50/255.0f, 0.1f);
    gl::Clear(GL_COLOR_BUFFER_BIT);
    neoSwap();

    setBinds();

    r::gui gGui;
    if (!gGui.load("fonts/droidsans"))
        neoFatal("failed to load font");
    if (!gGui.upload())
        neoFatal("failed to initialize GUI rendering method\n");

    // Setup window and menu
    menuReset();
    neoSetWindowTitle("Neothyne");
    neoCenterMouse();

#if 1
    // Setup some lights
    const m::vec3 places[] = {
        m::vec3(153.04, 105.02, 197.67)
    };

    pointLight light;
    light.diffuse = 1.0f;
    light.ambient = 0.10f;
    light.radius = 30.0f;
    for (size_t i = 0; i < sizeof(places)/sizeof(*places); i++) {
        light.color = { u::randf(), u::randf(), u::randf() };
        light.position = places[i];
        //light.position.y -= 5.0f;
        gWorld.insert(light);
    }
    light.position = { 0, 110, 0 };
    gWorld.insert(light);

    // World only has one directional light
    directionalLight &dlight = gWorld.getDirectionalLight();
    dlight.color = { 0.2, 0.2, 0.2 };
    dlight.ambient = 0.10f;
    dlight.diffuse = 0.50f;
    dlight.direction = { -1.0f, 0.0f, 0.0f };

    // and some map models
    mapModel m;
    m.name = "models/iqmtest";
    m.position = { 40, 95, 0 };
    m.rotate = { 0, -90, 0 };
    gWorld.insert(m);

    m.name = "models/cube";
    m.position = { 85, 112, 35 };
    gWorld.insert(m);

    m.name = "models/ball";
    m.position = { 100, 110, 90 };
    m.scale = { 10, 10, 10 };

    gWorld.insert(m);

    if (!gWorld.load("garden.kdgz"))
        neoFatal("failed to load world");
#endif

    while (gRunning && !shutdown) {
        gClient.update(gWorld, timer.delta());

        gPerspective.fov = cl_fov;
        gPerspective.nearp = cl_nearp;
        gPerspective.farp = cl_farp;
        gPerspective.width = neoWidth();
        gPerspective.height = neoHeight();

        gPipeline.setPerspective(gPerspective);
        gPipeline.setRotation(gClient.getRotation());
        gPipeline.setPosition(gClient.getPosition());
        gPipeline.setTime(timer.ticks());
        gPipeline.setDelta(timer.delta());

        auto mouse = neoMouseState();

        // Update dragging/moving entity
        if (mouse.button & mouseState::kMouseButtonLeft && gSelected && !(gMenuState & kMenuEdit))
            edit::move();

        if (gPlaying && gWorld.isLoaded()) {
            gWorld.upload(gPerspective);
            gl::ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            gWorld.render(gPipeline);
            gGui.render(gPipeline);
            gui::begin(mouse);
        } else {
            gl::ClearColor(40/255.0f, 30/255.0f, 50/255.0f, 0.1f);
            gl::Clear(GL_COLOR_BUFFER_BIT);
            gGui.render(gPipeline);
            gui::begin(mouse);
        }
        neoSwap();

        if (!gPlaying) {
            // Render the model (for testing only)
            r::pipeline p;
            m::perspective pp = gPerspective;

            const m::vec3 rot(0.0f, -(fmodf(gPipeline.time() / 10.0f, 361.0f)), 0.0f);
            m::quat ry(m::toRadian(rot.y), m::vec3::yAxis);
            m::mat4 rotate;
            ry.getMatrix(&rotate);
            p.setRotate(rotate);

            int w = neoWidth() / 12;
            int h = neoHeight() / 12;
            pp.width = w;
            pp.height = h;

            p.setPerspective(pp);
            p.setWorld({0, 0, 0});
            p.setPosition({0, 0, -1.5f});
            p.setScale({1, 1, 1});

            gui::drawModel(128 / neoWidth(),
                           neoHeight() / 128 + 16, // 16 to keep above command line
                           w,
                           h, "models/icon", p);
        }

        // Must come first as we want the menu to go over the cross hair if it's
        // launched after playing
        if (gPlaying && !(gMenuState & ~kMenuConsole)) {
            gui::drawLine(neoWidth() / 2, neoHeight() / 2 - 10, neoWidth() / 2, neoHeight() / 2 - 4, 2, 0xFFFFFFE1);
            gui::drawLine(neoWidth() / 2, neoHeight() / 2 + 4, neoWidth() / 2, neoHeight() / 2 + 10, 2, 0xFFFFFFE1);
            gui::drawLine(neoWidth() / 2 + 10, neoHeight() / 2, neoWidth() / 2 + 4, neoHeight() / 2, 2, 0xFFFFFFE1);
            gui::drawLine(neoWidth() / 2 - 10, neoHeight() / 2, neoWidth() / 2 - 4, neoHeight() / 2, 2, 0xFFFFFFE1);
        }
        if (!gPlaying) {
            const size_t w = neoWidth();
            const size_t h = (neoHeight() / 2);
            const size_t x = neoWidth() / 2 - w / 2; // Center on X
            const size_t y = neoHeight() - h;

            r::pipeline p;
            m::perspective pp = gPerspective;
            pp.width = w;
            pp.height = h;
            pp.fov = 20.0f;
            p.setPerspective(pp);
            p.setWorld({0, 0, 0});
            p.setPosition({0, 0, -130});
            p.setScale({1, 1, 1});

            gui::drawModel(x, y, w, h, "models/logo", p);
        }

        menuUpdate();

        // Render FPS/MSPF
        gui::drawText(neoWidth() - 10, 10, gui::kAlignRight,
            u::format("%d fps : %.2f mspf\n", timer.fps(), timer.mspf()).c_str(),
            gui::RGBA(255, 255, 255, 255));

        if (varGet<int>("cl_edit").get() && !(gMenuState & kMenuEdit)) {
            gui::drawText(neoWidth() / 2, neoHeight() - 20, gui::kAlignCenter, "F12 to toggle edit menu",
                gui::RGBA(0, 0, 0, 255));
            gui::drawText(neoWidth() / 2, neoHeight() - 40, gui::kAlignCenter, "F10 to toggle color grading menu",
                gui::RGBA(0, 0, 0, 255));
        }

        u::string inputText;
        textState text = neoTextState(inputText);
        if (text != textState::kInactive) {
            gui::drawTriangle(5, 10, 10, 10, 1, gui::RGBA(155, 155, 155, 255));
            gui::drawText(20, 10, gui::kAlignLeft,
                inputText.c_str(), gui::RGBA(255, 255, 255, 255));
            if (text == textState::kFinished) {
                auto values = u::split(inputText);
                if (values.size() == 2) {
                    switch (varChange(values[0], values[1])) {
                    case kVarSuccess:
                        u::print("changed `%s' to `%s'\n", values[0], values[1]);
                        break;
                    case kVarRangeError:
                        u::print("invalid range for `%s'\n", values[0]);
                        break;
                    case kVarTypeError:
                        u::print("invalid type for `%s'\n", values[0]);
                        break;
                    case kVarNotFoundError:
                        u::print("variable `%s' not found\n", values[0]);
                        break;
                    case kVarReadOnlyError:
                        u::print("variable `%s' is read-only\n", values[0]);
                        break;
                    }
                } else if (values.size() == 1) {
                    if (values[0] == "quit" || values[0] == "exit")
                        gRunning = false;
                }
            }
        }

        // Cursor above all else
        if ((gMenuState & ~kMenuConsole || gMenuState & kMenuEdit || gMenuState & kMenuCreate) && !neoRelativeMouse())
            gui::drawImage(mouse.x, mouse.y - (32 - 3), 32, 32, "textures/ui/cursor");

        gui::finish();
    }

    return 0;
}
<|endoftext|>


<commit_before>// STL includes
#include <cstring>
#include <cstdio>
#include <iostream>

#include <QHostInfo>

// hyperion local includes
#include "LedDeviceUdpH801.h"

LedDeviceUdpH801::LedDeviceUdpH801(const Json::Value &deviceConfig)
	: ProviderUdp()
{
	setConfig(deviceConfig);
}

bool LedDeviceUdpH801::setConfig(const Json::Value &deviceConfig)
{
	/* The H801 port is fixed */
	ProviderUdp::setConfig(deviceConfig, 30977, "255.255.255.255");

	/* 10ms seems to be a safe default for the wait time */
	_LatchTime_ns = deviceConfig.get("latchtime", 10000000).asInt();

	_ids.clear();
	for (Json::Value::ArrayIndex i = 0; i < deviceConfig["lightIds"].size(); i++) {
		QString id(deviceConfig["lightIds"][i].asCString());
		_ids.push_back(id.toInt(nullptr, 16));
	}

	_message = QByteArray(_prefix_size + _colors + _id_size * _ids.size() + _suffix_size, 0x00);
	_message[0] = 0xFB;
	_message[1] = 0xEB;

	for (int i = 0; i < _ids.length(); i++) {
		_message[_prefix_size + _colors + i * _id_size + 0] = (_ids[i] >> 0x00) & 0xFF;
		_message[_prefix_size + _colors + i * _id_size + 1] = (_ids[i] >> 0x08) & 0xFF;
		_message[_prefix_size + _colors + i * _id_size + 2] = (_ids[i] >> 0x10) & 0xFF;
	}

	Debug(_log, "H801 using %s:%d", _address.toString().toStdString().c_str(), _port);

	return true;
}

LedDevice* LedDeviceUdpH801::construct(const Json::Value &deviceConfig)
{
	return new LedDeviceUdpH801(deviceConfig);
}

int LedDeviceUdpH801::write(const std::vector<ColorRgb> &ledValues)
{
	ColorRgb color = ledValues[0];
	_message[_prefix_size + 0] = color.red;
	_message[_prefix_size + 1] = color.green;
	_message[_prefix_size + 2] = color.blue;

	return writeBytes(_message.size(), reinterpret_cast<const uint8_t*>(_message.data()));
}

int LedDeviceUdpH801::switchOff()
{
	return write(std::vector<ColorRgb>(_ledCount, ColorRgb{0, 0, 0}));
}

<commit_msg>fix last merge<commit_after>// STL includes
#include <cstring>
#include <cstdio>
#include <iostream>

#include <QHostInfo>

// hyperion local includes
#include "LedDeviceUdpH801.h"

LedDeviceUdpH801::LedDeviceUdpH801(const Json::Value &deviceConfig)
	: ProviderUdp()
{
	setConfig(deviceConfig);
}

bool LedDeviceUdpH801::setConfig(const Json::Value &deviceConfig)
{
	/* The H801 port is fixed */
	ProviderUdp::setConfig(deviceConfig, 10000000, 30977, "255.255.255.255");

	_ids.clear();
	for (Json::Value::ArrayIndex i = 0; i < deviceConfig["lightIds"].size(); i++) {
		QString id(deviceConfig["lightIds"][i].asCString());
		_ids.push_back(id.toInt(nullptr, 16));
	}

	_message = QByteArray(_prefix_size + _colors + _id_size * _ids.size() + _suffix_size, 0x00);
	_message[0] = 0xFB;
	_message[1] = 0xEB;

	for (int i = 0; i < _ids.length(); i++) {
		_message[_prefix_size + _colors + i * _id_size + 0] = (_ids[i] >> 0x00) & 0xFF;
		_message[_prefix_size + _colors + i * _id_size + 1] = (_ids[i] >> 0x08) & 0xFF;
		_message[_prefix_size + _colors + i * _id_size + 2] = (_ids[i] >> 0x10) & 0xFF;
	}

	Debug(_log, "H801 using %s:%d", _address.toString().toStdString().c_str(), _port);

	return true;
}

LedDevice* LedDeviceUdpH801::construct(const Json::Value &deviceConfig)
{
	return new LedDeviceUdpH801(deviceConfig);
}

int LedDeviceUdpH801::write(const std::vector<ColorRgb> &ledValues)
{
	ColorRgb color = ledValues[0];
	_message[_prefix_size + 0] = color.red;
	_message[_prefix_size + 1] = color.green;
	_message[_prefix_size + 2] = color.blue;

	return writeBytes(_message.size(), reinterpret_cast<const uint8_t*>(_message.data()));
}

int LedDeviceUdpH801::switchOff()
{
	return write(std::vector<ColorRgb>(_ledCount, ColorRgb{0, 0, 0}));
}

<|endoftext|>


<commit_before>// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
/*******************************************************************************************************************************************************.H.S.**/
/**
 @file      mandelbrot_distance_old.cpp
 @author    Mitch Richling <https://www.mitchr.me>
 @brief     This program draws a mandelbrot set using the "distance".@EOL
 @std       C++20
 @copyright
  @parblock
  Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.

  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
     and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
     without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  DAMAGE.
  @endparblock
*/
/*******************************************************************************************************************************************************.H.E.**/
/** @cond exj */

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
#include "ramCanvas.hpp"

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
#define MAXITR 1000
#define BALLSIZE 100000.0

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
int main(void) {
  std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
  mjr::ramCanvas4c8b theRamCanvas = mjr::ramCanvas4c8b(1024*2, 1024*2, -1.9, 0.5, -1.2, 1.2);

  for(int x=0; x<theRamCanvas.getNumPixX(); x++) {
    for(int y=0; y<theRamCanvas.getNumPixY(); y++) {
      double xr    = theRamCanvas.int2realX(x);
      double yr    = theRamCanvas.int2realY(y);
      double zx    = 0.0;
      double zy    = 0.0;
      int    count = 0;
      double dx    = 0.0;
      double dy    = 0.0;
      double tdx, tzx;
      while ((zx*zx+zy*zy<BALLSIZE) && (count<MAXITR)) {
        count++;
        tzx=zx*zx-zy*zy+xr;
        zy=2*zx*zy+yr;
        zx=tzx;
        tdx=2*(zx*dx-zy*dy)+1;
        dy=2*(zy*dx+zx*dy);
        dx=tdx;
      }
      if(count < MAXITR) {
        double dist = 0.5*log(zx*zx+zy*zy)*sqrt(zx*zx+zy*zy)/sqrt(dx*dx+dy*dy);
        if(dist < 0.0000001)
          theRamCanvas.drawPoint(x, y, mjr::ramCanvas4c8b::colorType(255, 0, static_cast<mjr::ramCanvas4c8b::colorChanType>(count % 256)));
      }
    }
  }

  theRamCanvas.writeTGAfile("mandelbrot_distance_old.tga");
  std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
  std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
}
/** @endcond */
<commit_msg>Removed mandelbrot_distance_old.cpp<commit_after><|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: VColumn.cxx,v $
 *
 *  $Revision: 1.13 $
 *
 *  last change: $Author: hr $ $Date: 2001-10-16 18:14:25 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
#include "connectivity/sdbcx/VColumn.hxx"
#endif
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
#include <com/sun/star/lang/DisposedException.hpp>
#endif
#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
#endif
#ifndef CONNECTIVITY_CONNECTION_HXX
#include "TConnection.hxx"
#endif

// -------------------------------------------------------------------------
using namespace connectivity;
using namespace connectivity::sdbcx;
using namespace cppu;
using namespace connectivity;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
//  using namespace ::com::sun::star::sdbc;

// -----------------------------------------------------------------------------
::rtl::OUString SAL_CALL OColumn::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)
{
    if(isNew())
        return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumnDescription");
    return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumn");
}
// -----------------------------------------------------------------------------
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OColumn::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)
{
    ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
    if(isNew())
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ColumnDescription");
    else
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column");

    return aSupported;
}
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL OColumn::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException)
{
    Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
    const ::rtl::OUString* pSupported = aSupported.getConstArray();
    const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
    for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
        ;

    return pSupported != pEnd;
}
// -------------------------------------------------------------------------
OColumn::OColumn(sal_Bool _bCase)  :    OColumnDescriptor_BASE(m_aMutex)
                    ,   ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,sal_True)
                    ,   m_Precision(0)
                    ,   m_Type(0)
                    ,   m_Scale(0)
                    ,   m_IsNullable(sal_True)
                    ,   m_IsAutoIncrement(sal_False)
                    ,   m_IsRowVersion(sal_False)
                    ,   m_IsCurrency(sal_False)
{
    construct();
}
// -------------------------------------------------------------------------
OColumn::OColumn(   const ::rtl::OUString& _Name,
                    const ::rtl::OUString& _TypeName,
                    const ::rtl::OUString& _DefaultValue,
                    sal_Int32       _IsNullable,
                    sal_Int32       _Precision,
                    sal_Int32       _Scale,
                    sal_Int32       _Type,
                    sal_Bool        _IsAutoIncrement,
                    sal_Bool        _IsRowVersion,
                    sal_Bool        _IsCurrency,
                    sal_Bool        _bCase)
            :   OColumnDescriptor_BASE(m_aMutex)
            ,   ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
            ,   m_TypeName(_TypeName)
            ,   m_DefaultValue(_DefaultValue)
            ,   m_Precision(_Precision)
            ,   m_Type(_Type)
            ,   m_Scale(_Scale)
            ,   m_IsNullable(_IsNullable)
            ,   m_IsAutoIncrement(_IsAutoIncrement)
            ,   m_IsRowVersion(_IsRowVersion)
            ,   m_IsCurrency(_IsCurrency)
{
    m_Name = _Name;

    construct();
}
// -------------------------------------------------------------------------
OColumn::~OColumn()
{
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 _nId) const
{
    ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aProps;
    describeProperties(aProps);
    changePropertyAttributte(aProps);
    return new ::cppu::OPropertyArrayHelper(aProps);
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
{
    return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
}
// -----------------------------------------------------------------------------
void SAL_CALL OColumn::acquire() throw()
{
    OColumnDescriptor_BASE::acquire();
}
// -----------------------------------------------------------------------------
void SAL_CALL OColumn::release() throw()
{
    OColumnDescriptor_BASE::release();
}
// -----------------------------------------------------------------------------
Any SAL_CALL OColumn::queryInterface( const Type & rType ) throw(RuntimeException)
{
    Any aRet = ODescriptor::queryInterface( rType);
    if(!aRet.hasValue())
    {
        if(!isNew())
            aRet = OColumn_BASE::queryInterface(rType);
        if(!aRet.hasValue())
            aRet = OColumnDescriptor_BASE::queryInterface( rType);
    }
    return aRet;
}
// -------------------------------------------------------------------------
Sequence< Type > SAL_CALL OColumn::getTypes(  ) throw(RuntimeException)
{
    if(isNew())
        return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());

    return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
}
// -------------------------------------------------------------------------
void OColumn::construct()
{
    ODescriptor::construct();

    sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;

    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),            PROPERTY_ID_TYPENAME,           nAttrib,&m_TypeName,        ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION),     PROPERTY_ID_DESCRIPTION,        nAttrib,&m_Description,     ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),        PROPERTY_ID_DEFAULTVALUE,       nAttrib,&m_DefaultValue,    ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),       PROPERTY_ID_PRECISION,          nAttrib,&m_Precision,       ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),                PROPERTY_ID_TYPE,               nAttrib,&m_Type,            ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),           PROPERTY_ID_SCALE,              nAttrib,&m_Scale,           ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),      PROPERTY_ID_ISNULLABLE,         nAttrib,&m_IsNullable,      ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT,    nAttrib,&m_IsAutoIncrement, ::getBooleanCppuType());
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION),        PROPERTY_ID_ISROWVERSION,       nAttrib,&m_IsRowVersion,    ::getBooleanCppuType());
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY),      PROPERTY_ID_ISCURRENCY,         nAttrib,&m_IsCurrency,      ::getBooleanCppuType());
}
// -------------------------------------------------------------------------
void OColumn::disposing(void)
{
    OPropertySetHelper::disposing();

    ::osl::MutexGuard aGuard(m_aMutex);
    checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);

}
// -------------------------------------------------------------------------
Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor(  ) throw(RuntimeException)
{
    ::osl::MutexGuard aGuard(m_aMutex);
    checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);

    OColumn* pNewColumn = new OColumn(  m_Name,
                                        m_TypeName,
                                        m_DefaultValue,
                                        m_IsNullable,
                                        m_Precision,
                                        m_Scale,
                                        m_Type,
                                        m_IsAutoIncrement,
                                        m_IsRowVersion,
                                        m_IsCurrency,
                                        isCaseSensitive());
    pNewColumn->m_Description = m_Description;
    pNewColumn->setNew(sal_True);
    return pNewColumn;
}
// -----------------------------------------------------------------------------
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
{
    return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
// -----------------------------------------------------------------------------
// XNamed
::rtl::OUString SAL_CALL OColumn::getName(  ) throw(::com::sun::star::uno::RuntimeException)
{
    return m_Name;
}
// -----------------------------------------------------------------------------
void SAL_CALL OColumn::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException)
{
    m_Name = aName;
}
// -----------------------------------------------------------------------------

<commit_msg>INTEGRATION: CWS dba07 (1.13.92); FILE MERGED 2003/05/28 09:23:50 oj 1.13.92.1: #109965# initial value was false<commit_after>/*************************************************************************
 *
 *  $RCSfile: VColumn.cxx,v $
 *
 *  $Revision: 1.14 $
 *
 *  last change: $Author: vg $ $Date: 2003-06-06 10:51:14 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
#include "connectivity/sdbcx/VColumn.hxx"
#endif
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
#include <com/sun/star/lang/DisposedException.hpp>
#endif
#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
#endif
#ifndef CONNECTIVITY_CONNECTION_HXX
#include "TConnection.hxx"
#endif
#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
#include <com/sun/star/sdbc/ColumnValue.hpp>
#endif
// -------------------------------------------------------------------------
using namespace connectivity;
using namespace connectivity::sdbcx;
using namespace cppu;
using namespace connectivity;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdbc;

// -----------------------------------------------------------------------------
::rtl::OUString SAL_CALL OColumn::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)
{
    if(isNew())
        return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumnDescription");
    return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumn");
}
// -----------------------------------------------------------------------------
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OColumn::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)
{
    ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
    if(isNew())
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ColumnDescription");
    else
        aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column");

    return aSupported;
}
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL OColumn::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException)
{
    Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
    const ::rtl::OUString* pSupported = aSupported.getConstArray();
    const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
    for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
        ;

    return pSupported != pEnd;
}
// -------------------------------------------------------------------------
OColumn::OColumn(sal_Bool _bCase)  :    OColumnDescriptor_BASE(m_aMutex)
                    ,   ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,sal_True)
                    ,   m_Precision(0)
                    ,   m_Type(0)
                    ,   m_Scale(0)
                    ,   m_IsNullable(ColumnValue::NULLABLE)
                    ,   m_IsAutoIncrement(sal_False)
                    ,   m_IsRowVersion(sal_False)
                    ,   m_IsCurrency(sal_False)
{
    construct();
}
// -------------------------------------------------------------------------
OColumn::OColumn(   const ::rtl::OUString& _Name,
                    const ::rtl::OUString& _TypeName,
                    const ::rtl::OUString& _DefaultValue,
                    sal_Int32       _IsNullable,
                    sal_Int32       _Precision,
                    sal_Int32       _Scale,
                    sal_Int32       _Type,
                    sal_Bool        _IsAutoIncrement,
                    sal_Bool        _IsRowVersion,
                    sal_Bool        _IsCurrency,
                    sal_Bool        _bCase)
            :   OColumnDescriptor_BASE(m_aMutex)
            ,   ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
            ,   m_TypeName(_TypeName)
            ,   m_DefaultValue(_DefaultValue)
            ,   m_Precision(_Precision)
            ,   m_Type(_Type)
            ,   m_Scale(_Scale)
            ,   m_IsNullable(_IsNullable)
            ,   m_IsAutoIncrement(_IsAutoIncrement)
            ,   m_IsRowVersion(_IsRowVersion)
            ,   m_IsCurrency(_IsCurrency)
{
    m_Name = _Name;

    construct();
}
// -------------------------------------------------------------------------
OColumn::~OColumn()
{
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 _nId) const
{
    ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aProps;
    describeProperties(aProps);
    changePropertyAttributte(aProps);
    return new ::cppu::OPropertyArrayHelper(aProps);
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
{
    return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
}
// -----------------------------------------------------------------------------
void SAL_CALL OColumn::acquire() throw()
{
    OColumnDescriptor_BASE::acquire();
}
// -----------------------------------------------------------------------------
void SAL_CALL OColumn::release() throw()
{
    OColumnDescriptor_BASE::release();
}
// -----------------------------------------------------------------------------
Any SAL_CALL OColumn::queryInterface( const Type & rType ) throw(RuntimeException)
{
    Any aRet = ODescriptor::queryInterface( rType);
    if(!aRet.hasValue())
    {
        if(!isNew())
            aRet = OColumn_BASE::queryInterface(rType);
        if(!aRet.hasValue())
            aRet = OColumnDescriptor_BASE::queryInterface( rType);
    }
    return aRet;
}
// -------------------------------------------------------------------------
Sequence< Type > SAL_CALL OColumn::getTypes(  ) throw(RuntimeException)
{
    if(isNew())
        return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());

    return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
}
// -------------------------------------------------------------------------
void OColumn::construct()
{
    ODescriptor::construct();

    sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;

    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),            PROPERTY_ID_TYPENAME,           nAttrib,&m_TypeName,        ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION),     PROPERTY_ID_DESCRIPTION,        nAttrib,&m_Description,     ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),        PROPERTY_ID_DEFAULTVALUE,       nAttrib,&m_DefaultValue,    ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),       PROPERTY_ID_PRECISION,          nAttrib,&m_Precision,       ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),                PROPERTY_ID_TYPE,               nAttrib,&m_Type,            ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),           PROPERTY_ID_SCALE,              nAttrib,&m_Scale,           ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),      PROPERTY_ID_ISNULLABLE,         nAttrib,&m_IsNullable,      ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT,    nAttrib,&m_IsAutoIncrement, ::getBooleanCppuType());
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION),        PROPERTY_ID_ISROWVERSION,       nAttrib,&m_IsRowVersion,    ::getBooleanCppuType());
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY),      PROPERTY_ID_ISCURRENCY,         nAttrib,&m_IsCurrency,      ::getBooleanCppuType());
}
// -------------------------------------------------------------------------
void OColumn::disposing(void)
{
    OPropertySetHelper::disposing();

    ::osl::MutexGuard aGuard(m_aMutex);
    checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);

}
// -------------------------------------------------------------------------
Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor(  ) throw(RuntimeException)
{
    ::osl::MutexGuard aGuard(m_aMutex);
    checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);

    OColumn* pNewColumn = new OColumn(  m_Name,
                                        m_TypeName,
                                        m_DefaultValue,
                                        m_IsNullable,
                                        m_Precision,
                                        m_Scale,
                                        m_Type,
                                        m_IsAutoIncrement,
                                        m_IsRowVersion,
                                        m_IsCurrency,
                                        isCaseSensitive());
    pNewColumn->m_Description = m_Description;
    pNewColumn->setNew(sal_True);
    return pNewColumn;
}
// -----------------------------------------------------------------------------
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
{
    return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
// -----------------------------------------------------------------------------
// XNamed
::rtl::OUString SAL_CALL OColumn::getName(  ) throw(::com::sun::star::uno::RuntimeException)
{
    return m_Name;
}
// -----------------------------------------------------------------------------
void SAL_CALL OColumn::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException)
{
    m_Name = aName;
}
// -----------------------------------------------------------------------------

<|endoftext|>