Synopsis - Cross-Reference
File: /src/Synopsis/Python/TypedList.hh1// 2// Copyright (C) 2004 Stefan Seefeld 3// All rights reserved. 4// Licensed to the public under the terms of the GNU LGPL (>= 2), 5// see the file COPYING for details. 6// 7 8#ifndef _Synopsis_Python_TypedList_hh 9#define _Synopsis_Python_TypedList_hh 10 11#include <Synopsis/Python/Object.hh> 12 13namespace Synopsis 14{ 15namespace Python 16{ 17 18//. A typed list replace some modifiers by a 'more typed' variant 19//. This is really just provided to allow more expressive statements 20template <typename T> 21class TypedList : public List 22{ 23public: 24 TypedList(size_t i = 0) : List(i) {} 25 TypedList(Object o) : List(o) {} // should we typecheck here all items ? 26 27 TypedList(const T &); 28 TypedList(const T &, const T &); 29 TypedList(const T &, const T &, const T &); 30 TypedList(const T &, const T &, const T &, const T &); 31 32 void set(int i, const T &s) { List::set(i, s);} 33 T get(int i) const { return narrow<T>(List::get(i));} 34 void append(const T &s) { List::append(s);} 35 void insert(int i, const T &s) { List::insert(i, s);} 36}; 37 38template <typename T> 39inline TypedList<T>::TypedList(const T &t1) 40{ 41 append(t1); 42} 43 44template <typename T> 45inline TypedList<T>::TypedList(const T &t1, const T &t2) 46{ 47 append(t1); 48 append(t2); 49} 50 51template <typename T> 52inline TypedList<T>::TypedList(const T &t1, const T &t2, const T &t3) 53{ 54 append(t1); 55 append(t2); 56 append(t3); 57} 58 59template <typename T> 60inline TypedList<T>::TypedList(const T &t1, const T &t2, const T &t3, const T &t4) 61{ 62 append(t1); 63 append(t2); 64 append(t3); 65 append(t4); 66} 67 68} 69} 70 71#endif