File: PyView.h

package info (click to toggle)
metakit 2.4.3-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,468 kB
  • ctags: 3,548
  • sloc: xml: 29,455; cpp: 23,339; sh: 9,051; tcl: 1,195; python: 577; makefile: 254; ansic: 14
file content (73 lines) | stat: -rwxr-xr-x 2,176 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// PyView.h --
// $Id: PyView.h,v 1.8 2001/12/19 16:30:23 wcvs Exp $
// This is part of MetaKit, see http://www.equi4.com/metakit/
//
//  Copyright 1999 McMillan Enterprises, Inc. -- www.mcmillan-inc.com
//  Copyright (C) 1999-2001 Jean-Claude Wippler <jcw@equi4.com>
//
//  View class header

#if !defined INCLUDE_PYVIEW_H
#define INCLUDE_PYVIEW_H

#include <mk4.h>
#include <PWOSequence.h>
#include <PWOCallable.h>
#include <PWONumber.h>
#include "PyHead.h"

#define PyView_Check(v) ((v)->ob_type==&PyViewtype)
#define PyViewer_Check(v) ((v)->ob_type==&PyViewertype)
#define PyROViewer_Check(v) ((v)->ob_type==&PyROViewertype)
#define PyGenericView_Check(v) (PyView_Check(v) || PyViewer_Check(v) || PyROViewer_Check(v))

class PyView;
class PyRowRef;

extern PyTypeObject PyViewtype;
extern PyTypeObject PyViewertype;
extern PyTypeObject PyROViewertype;

#define BASE 0              //0000
#define MVIEWER 4           //0100
#define RWVIEWER 5          //0101
#define NOTIFIABLE 1        //0001
#define FINALNOTIFIABLE 9   //1001
#define ROVIEWER 7          //0111
#define IMMUTABLEROWS 2

class PyView : public PyHead, public c4_View {
  PyView *_base;
  int _state;
public:
  PyView();
  PyView(const c4_View& o, PyView *owner=0, int state=BASE);
  ~PyView() {}
  void insertAt(int i, PyObject* o);
  PyRowRef *getItem(int i);
  PyView *getSlice(int s, int e);
  int setItemRow(int i, const c4_RowRef& v) {
    if (i < 0)
      i += GetSize();
    if (i > GetSize() || i < 0)
      Fail(PyExc_IndexError, "Index out of range");
    SetAt(i, v);
    return 0;
  };
  int setItem(int i, PyObject* v);
  void addProperties(const PWOSequence& lst);
  int setSlice(int s, int e, const PWOSequence& lst);
  PyObject* structure();
  void makeRow(c4_Row& temp, PyObject* o, bool useDefaults=true);
  void map(const PWOCallable& func);
  void map(const PWOCallable& func, const PyView& subset);
  PyView *filter(const PWOCallable& func);
  PyObject *reduce(const PWOCallable& func, PWONumber& start);
  void remove(const PyView& indices);
  PyView *indices(const PyView& subset);
  int computeState(int targetstate);
};

PyObject* PyView_new(PyObject* o, PyObject* _args);

#endif