Hello
Je me pose une petite question.
La classe ci dessous possede une methode public inlinée( on s'en fout) et static qui s'appelle GetInstance()
1. Est ce que le fait de l'appeler va automatiquement instancier un objet de type List AssetTrading ???
2. Si ce n'est pas le cas est ce que lors de differents appels differents *ListAssetTrading vont être créés
3. Je trouve cette facon de faire bizarre, vous avez souvent vu des trucs similaires ?
class ListeAssetTrading
{
friend class Selection;
friend class SelectionMultiple;
friend class Selection1;
friend class Strategie1;
friend void GetIntervalleTradingDay(SAMDate & Date1, int duree, SAMDate & Date2);
private:
//args
map<string,AssetTrading*> Assets;
static ListeAssetTrading * Instance; //instance unique
set<AssetTrading*> AssetsPropres;
AssetTrading * Benchmark;
SAMDate EndFeries;
map<int,int> Feries;
map<SAMDate,int> FeriesDates;
private:
//constructor
ListeAssetTrading()
:Benchmark(NULL),LeGerant(NULL),isBenchmark(false),isWeighted(false),isResultsInTick(false),
isTradingTagMap(false),criticalValue(3.43),RefIndex(string("")),isCapNumberLegsSet(false),
mCapNumberLegs(-1),BetaCutOff(0.01),BetaCutOffRatio(0.01),
offset_beta(false)
{tradingTagMap.clear();Univers.clear();Feries.clear();DebouclagePotentielOnly=false;} //constructeur privé
public:
//public args
bool offset_beta;
bool isWeighted;
bool isResultsInTick;
double criticalValue;
bool DebouclagePotentielOnly;
bool isBenchmark;
vector<double> ValeurCritique;
//Parameters driving the maximum net number of legs in which a stock can be involved
bool isCapNumberLegsSet;
int mCapNumberLegs;
//The trading map is here to replace the full day convention by a day/time tag for example, it makes it easier to read logs
bool isTradingTagMap;
string RefIndex;
double BetaCutOff;
double BetaCutOffRatio;
set<string> Univers;//Liste des noms des stocks de l'univers de travail
GestionFonds * LeGerant;
map<pair<string,string>, double > net_beta;
map<pair<string,string>, string > against_index;
map<string,double> weights;
map<long, string> tradingTagMap;
map<pair<string,string>, pair<double,double> > regresseurs;
map<pair<string,string>, pair<double,double> > tailles;
public:
~ListeAssetTrading()
{
set<AssetTrading *>::iterator it = AssetsPropres.begin();
while(it != AssetsPropres.end()) { delete (*it); it++; }
Assets.clear();
}
//accesseurs
inline static ListeAssetTrading & GetInstance()
{
if(!Instance)
{
Instance = new ListeAssetTrading();
}
return *Instance;
}
AssetTrading& GetAsset(const string & s);
void AddAsset(AssetTrading *, bool IsBenchmark=false);
AssetTrading &GetBenchmark();
void SetBenchmark(AssetTrading * TheBench);
SAMDate GetDateRef(){return GetBenchmark().DateRef;}
SAMDate GetDateFin(){return GetBenchmark().DateFin;}
int GetFerie(SAMDate & When) {return Feries[NbDayBtw(GetDateRef(),When)];}
inline int GetFerie(int When){return Feries[When];}
//void Remove(const string & s);
string Describe();
string DescribeBetaDF();
string DescribePairesDF();
string Describe(SAMDate & When);
void CheckCoherence();
};