/* $Id$
This file is part of the MSP Märklin suite
-Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa
+Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
return len;
}
-unsigned TrackType::get_n_paths() const
+unsigned TrackType::get_paths() const
{
- unsigned n = 1;
+ unsigned mask = 0;
for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
- if(i->path>=n)
- n = i->path+1;
+ mask |= 1<<i->path;
+ return mask;
+}
+
+unsigned TrackType::get_n_paths() const
+{
+ unsigned n = 0;
+ for(unsigned mask = get_paths(); mask; ++n)
+ mask &= mask-1;
return n;
}
+bool TrackType::is_turnout() const
+{
+ return endpoints.size()>2;
+}
+
+bool TrackType::is_double_address() const
+{
+ return get_n_paths()>2;
+}
+
void TrackType::collect_endpoints()
{
endpoints.clear();