--- /dev/null
+// Copyright (C) 2006-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Nicolas GEIMER (EDF)
+
+#ifndef ITERATORPY3_HXX_
+#define ITERATORPY3_HXX_
+
+template <typename U> class StopIterator {};
+template <typename U> class Iterator {
+ public:
+ Iterator( typename std::map<std::string,U*>::iterator _cur, typename std::map<std::string,U*>::iterator _end) : cur(_cur), end(_end) {}
+ Iterator* __iter__()
+ {
+ return this;
+ }
+ typename std::map<std::string,U*>::iterator cur;
+ typename std::map<std::string,U*>::iterator end;
+};
+
+#endif /* ITERATORPY3_HXX */
+
Objects returned by __getitem__ are declared new (%newobject) so that when destroyed they
call decrRef (see feature("unref") for RefCounter).
*/
-/*
-%inline %{
-template <typename U> class StopIterator {};
-template <typename U> class Iterator {
- public:
- Iterator(std::map<std::string,U*>::iterator _cur, std::map<std::string,U*>::iterator _end) : cur(_cur), end(_end) {}
- Iterator* __iter__()
- {
- return this;
- }
- template <typename U> std::map<std::string,U*>::iterator cur;
- template <typename U> std::map<std::string,U*>::iterator end;
- };
-%}
%include "exception.i"
%exception Iterator::next {
throw StopIterator();
}
}
-*/
+
template<>
class std::map<std::string,T*>
{
}
return keyList;
}
-/* Iterator __iter__()
+ Iterator<T> __iter__()
{
// return a constructed Iterator object
- return Iterator($self->begin(), $self->end());
+ return typename Iterator($self->begin(), $self->end());
}
-*/
+
int __len__()
{
int pysize = self->size();
}
}
};
-
+%rename(__next__) Iterator::next;
%newobject std::map<std::string,T* >::__getitem__;
+%newobject std::map<std::string,T* >::__iter__;
%template() std::pair<std::string, T* >;
%template(tname) std::map<std::string, T* >;
%pythoncode{
#include "ComponentInstance.hxx"
#include "DataNode.hxx"
#include "PlayGround.hxx"
+#include "IteratorPy3.hxx"
using namespace YACS::ENGINE;
%template() std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
%template() std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
%template() std::pair< std::string, int >;
+%template() Iterator<YACS::ENGINE::TypeCode *>;
//%template(TCmap) std::map<std::string, YACS::ENGINE::TypeCode *>;
REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
%template(NODEmap) std::map<std::string, YACS::ENGINE::Node *>;
%template(INODEmap) std::map<std::string, YACS::ENGINE::InlineNode *>;
%template(SNODEmap) std::map<std::string, YACS::ENGINE::ServiceNode *>;
//%template(CONTAINmap) std::map<std::string, YACS::ENGINE::Container *>;
+%template() Iterator<YACS::ENGINE::Container * >;
REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
%template(strvec) std::vector<std::string>;
%template(uivec) std::vector<unsigned int>;
%template(compomap) std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
%template() std::pair<std::string, std::string>;
%template(propmap) std::map<std::string, std::string>;
-
+%template() Iterator<YACS::ENGINE::ComponentInstance *>;
REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
/*