1 /+ 2 The MIT License (MIT) 3 4 Copyright (c) <2013> <Oleg Butko (deviator), Anton Akzhigitov (Akzwar)> 5 6 Permission is hereby granted, free of charge, to any person obtaining a copy 7 of this software and associated documentation files (the "Software"), to deal 8 in the Software without restriction, including without limitation the rights 9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 copies of the Software, and to permit persons to whom the Software is 11 furnished to do so, subject to the following conditions: 12 13 The above copyright notice and this permission notice shall be included in 14 all copies or substantial portions of the Software. 15 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 THE SOFTWARE. 23 +/ 24 25 module des.flow.base; 26 27 import std.datetime; 28 public import des.util.logger; 29 30 class FlowException : Exception 31 { 32 @safe pure nothrow this( string msg, string file=__FILE__, size_t line=__LINE__ ) 33 { super( msg, file, line ); } 34 } 35 36 enum Command { START, PAUSE, STOP, REINIT, CLOSE }; 37 38 @property ulong currentTick() 39 { return Clock.currAppTick().length; } 40 41 package 42 { 43 44 version(unittest) 45 { 46 import std.math; 47 import std.traits; 48 import std.range; 49 50 pure bool eq(A,B)( in A a, in B b ) 51 { 52 static if( isFloatingPoint!A && isFloatingPoint!B ) 53 return (abs(a-b) < max( A.epsilon, B.epsilon )); 54 else return a == b; 55 } 56 57 pure bool eq_arr(A,B)( in A[] a, in B[] b ) 58 { 59 if( a.length != b.length ) return false; 60 foreach( i,j; zip(a,b) ) 61 if( !eq(i,j) ) return false; 62 return true; 63 } 64 65 bool creationTest(T)( T a ) 66 if( is( Unqual!T == T ) ) 67 { 68 auto cn_a = const T( a ); 69 auto im_a = immutable T( a ); 70 auto sh_a = shared T( a ); 71 auto sc_a = shared const T( a ); 72 auto si_a = shared immutable T( a ); 73 auto a_cn = T( cn_a ); 74 auto a_im = T( im_a ); 75 auto a_sh = T( sh_a ); 76 auto a_sc = T( sc_a ); 77 auto a_si = T( si_a ); 78 return a_cn == a && 79 a_im == a && 80 a_sh == a && 81 a_sc == a && 82 a_si == a; 83 } 84 } 85 } 86