Logo Search packages:      
Sourcecode: easystroke version File versions

var.cc

/*
 * Copyright (c) 2008, Thomas Jaeger <ThJaeger@gmail.com>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include "var.h"
#include <map>

uint64 In::count = 0;

std::map<uint64, In *> dirty;

void mark_dirty(In *in) { dirty[in->index] = in; }

void update_dirty() {
      for (;;) {
            std::map<uint64, In *>::iterator i = dirty.begin();
            if (i == dirty.end())
                  break;
            In *in = i->second;
            dirty.erase(i);
            in->notify();
      }
}

#if TEST_VAR
class IntLong : public Fun<int, long> {
      virtual long run(const int &x) { return x; }
public:
      IntLong(Out<int> &in) : Fun<int, long>(in) {}
};

void test() {
      Source<int> x(0);
      Var<int> y(x);
      IntLong z(y);
      Var<long> w(z);
      printf("0 == %d == %d == %ld == %ld\n", x.get(), y.get(), z.get(), w.get());
      x.set(2);
      printf("2 == %d == %d == %ld == %ld\n", x.get(), y.get(), z.get(), w.get());
}

int main(int, char**) {
      test();
      return 0;
}
#endif

Generated by  Doxygen 1.6.0   Back to index