1 /* TA-LIB Copyright (c) 1999-2007, Mario Fortier
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or
5  * without modification, are permitted provided that the following
6  * conditions are met:
7  *
8  * - Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  *
11  * - Redistributions in binary form must reproduce the above copyright
12  *   notice, this list of conditions and the following disclaimer in
13  *   the documentation and/or other materials provided with the
14  *   distribution.
15  *
16  * - Neither name of author nor the names of its contributors
17  *   may be used to endorse or promote products derived from this
18  *   software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /* List of contributors:
35  *
36  *  Initial  Name/description
37  *  -------------------------------------------------------------------
38  *  MF       Mario Fortier
39  *  RM       Robert Meier (talib@meierlim.com http://www.meierlim.com)
40  *
41  * Change history:
42  *
43  *  MMDDYY BY     Description
44  *  -------------------------------------------------------------------
45  *  052603 MF     Adapt code to compile with .NET Managed C++
46  *  123004 RM,MF  Adapt code to work with Visual Studio 2005
47  *
48  */
49 
50 #if defined( _MANAGED )
51    #using <mscorlib.dll>
52    #include "TA-Lib-Core.h"
53    #include "ta_memory.h"
54 namespace TicTacTec { namespace TA { namespace Library {
55 #else
56    #include "ta_utility.h"
57    #include "ta_func.h"
58    #include "ta_memory.h"
59 #endif
60 
61 #if defined( _MANAGED )
SetUnstablePeriod(enum class FuncUnstId id,unsigned int unstablePeriod)62  enum class Core::RetCode Core::SetUnstablePeriod(  enum class FuncUnstId id,
63                                                     unsigned int unstablePeriod )
64 #else
65 TA_RetCode TA_SetUnstablePeriod( TA_FuncUnstId id,
66                                  unsigned int  unstablePeriod )
67 #endif
68 {
69    int i;
70 
71    if( id > ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll) )
72       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
73 
74    if( id == ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll) )
75    {
76       for( i=0; i < (int)ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll); i++ )
77 	  {
78          #if defined( _MANAGED )
79             Globals->unstablePeriod[(int)i] = unstablePeriod;
80          #else
81             TA_Globals->unstablePeriod[i] = unstablePeriod;
82          #endif
83 	  }
84    }
85    else
86    {
87          #if defined( _MANAGED )
88             Globals->unstablePeriod[(int)id] = unstablePeriod;
89          #else
90             TA_Globals->unstablePeriod[id] = unstablePeriod;
91          #endif
92    }
93 
94    return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
95 }
96 
97 #if defined( _MANAGED )
GetUnstablePeriod(enum class FuncUnstId id)98 unsigned int Core::GetUnstablePeriod( enum class FuncUnstId id )
99 #else
100 unsigned int TA_GetUnstablePeriod( TA_FuncUnstId id )
101 #endif
102 {
103    if( id >= ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll) )
104 	   return 0;
105 
106    #if defined( _MANAGED )
107       return Globals->unstablePeriod[(int)id];
108    #else
109       return TA_Globals->unstablePeriod[id];
110    #endif
111 }
112 
113 #if defined( _MANAGED )
SetCompatibility(enum class Compatibility value)114  enum class Core::RetCode Core::SetCompatibility(  enum class Compatibility value )
115 #else
116 TA_RetCode TA_SetCompatibility( TA_Compatibility value )
117 #endif
118 {
119    TA_GLOBALS_COMPATIBILITY = value;
120    return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
121 }
122 
123 #if defined( _MANAGED )
GetCompatibility(void)124  enum class Core::Compatibility Core::GetCompatibility( void )
125 #else
126 TA_Compatibility TA_GetCompatibility( void )
127 #endif
128 {
129    return TA_GLOBALS_COMPATIBILITY;
130 }
131 
132 #if defined( _MANAGED )
133 }}} // Close namespace TicTacTec::TA::Lib
134 #endif
135