/////////////////////////////////////////////////////////////////////
//  PDistributionManagerUtil Class implementation file
//
//  PDistributionManagerUtil is the private implementation of 
//  the PDistributionManager
// 
//
//                                  Author:  I. Froehlich
/////////////////////////////////////////////////////////////////////


using namespace std;
#include <sstream>
#include <iostream>

#include "PDistributionManagerUtil.h"

PDistributionManagerUtil &fDistributionManagerUtil() {
    static PDistributionManagerUtil *ans = new PDistributionManagerUtil();
    return *ans;
}

PDistributionManagerUtil *makeDistributionManagerUtil() {
    return &fDistributionManagerUtil();
}

PDistributionManagerUtil::PDistributionManagerUtil() {

    if (makeDataBase()->GetParamTObj("batch_models") < 0)
	makeDataBase()->MakeParamTObj("batch_models", "Storage for distribution objects");

    makeStaticData();
    position  = 0;
    verbosity = 1;

    group_position = 0;
    corr_position  = 0;
    AddGroup("none", "No Group");
    AddGroup("user", "User defined distributions");

    for (int i=0; i<MAX_DISTRIBUTION_LIST; i++)
	alt_distribution[i] = -1;
    linkdb_done = 0;

    SetGroup("user");
}

void PDistributionManagerUtil::AlternativeTo(const char *a, const char *b) {
    //Makes the distributions "a" and "b" strongly alternative
    //This means only one of these 2 (or more) can be enabled at the same time

    Int_t apos = -1, bpos = -1;

    for (int i=0; i<position; i++) {
	if (strcmp(distribution[i]->GetIdentifier(), a) == 0) {
	    apos = i;
	}
	if (strcmp(distribution[i]->GetIdentifier(), b) == 0) {
	    bpos = i;
	}
    }

    if (apos == -1) {
	Warning("AlternativeTo", "First argument %s not found", a);
	return;
    }
    if (bpos == -1) {
	Warning("AlternativeTo", "Second argument %s not found", b);
	return;
    }
    if (alt_distribution[bpos] == -1) {
	alt_distribution[bpos] = apos;
	alt_distribution[apos] = bpos;
    } else if (alt_distribution[apos] == -1) {
	alt_distribution[bpos] = apos;
	alt_distribution[apos] = bpos;
    } else {
	Int_t bold=alt_distribution[bpos];	
	alt_distribution[bpos] = apos;
	alt_distribution[apos] = bold;
    }
    int mylist = alt_distribution[bpos];
    while (mylist != bpos) {

	if (distribution[mylist]->GetEnable()) //BUGBUG: Warning needed
	    distribution[mylist]->SetEnable(0);
	mylist = alt_distribution[mylist];
	if (mylist == -1) mylist=bpos;
    }
}

int PDistributionManagerUtil::Add(PDistribution *dist) {
    //Adds a distribution to the list 
    //return value -1 on failure

    Int_t num_channels;
    
    if (makeDynamicData()->GetPChannels(&num_channels) && (no_warning==kFALSE)) {
        Warning("Add", "You add a distribution (%s) after PChannels have been created", dist->GetIdentifier());
        Warning("Add", "Please add the PDistribution in the very beginning");
    }

    if (position == MAX_DISTRIBUTION_LIST) {
	Warning("Add", "MAX_DISTRIBUTION_LIST reached");
	return -1;
    }

    //check if my identifier already exists...

    for (int i=0; i<position; i++) {
	if (strcmp(distribution[i]->GetIdentifier(), dist->GetIdentifier())==0) {
	    Warning("Add", "Identifier %s already exists", distribution[i]->GetIdentifier());
	    return -1;
	}
    }

    distribution[position] = dist;
    alt_distribution[position] = -1;
    AddCorrelation(current_group, position);    
    position++;

    if (dist->GetKey() >= 0) { //is channel model?
	Int_t key = makeDataBase()->GetEntry(dist->GetIdentifier());
	if (key < 0) 
	    key = makeDataBase()->AddEntry(dist->GetIdentifier());
	if (key >= 0) {
	    makeDataBase()->SetParamTObj(dist->GetIdentifier(), "batch_models", dist);	    
	}
    }

    //If key exists already, make it alternative
    for (int i=0; i<position-1; i++) {
	if ((distribution[i]->GetKey() == dist->GetKey()) && (dist->GetKey()>=0))
	    AlternativeTo(distribution[i]->GetIdentifier(), dist->GetIdentifier());
	}

    return 0;
}

int PDistributionManagerUtil::Add(PDistribution *dist, const Char_t *gr) {
    
    Int_t save = current_group;
    if (GetGroup(gr) < 0) return -1;
    current_group = GetGroup(gr);

    if (Add(dist) < 0) {
	current_group = save;
	return -1;
    }
    current_group = save;
    return 0; 
}

int PDistributionManagerUtil::Add(TObjArray *arr) {
    //Adds a complete list of distributions

    for (int pat = 0; pat < arr->GetEntriesFast(); pat++) {
	const char *group = ((PDistribution *) (*arr)[pat])->GetGroupID();
	if (group) SetGroup(group);
        Bool_t saved_warning = no_warning;
        no_warning = kTRUE;
	if (Add((PDistribution *) (*arr)[pat]) == -1) {
	    Warning("Add(TObjArray *)", "Adding %s failed ", ((PDistribution *) (*arr)[pat])->GetDescription());
	}
        no_warning = saved_warning;
    }
    return 0;
}

int PDistributionManagerUtil::Attach(PChannel *ch) {
    //Attach the PChannel "ch" to the distribution manager
    //This enables all distributions in the PChannel
    //and fills the PChannel with life

    if (ch->GetQuasi()) {
	Attach(ch->GetQuasi()); //Attach also dummy quasi-free scattering
    }
    
    for (int i=0; i<position; i++) {
	if (distribution[i]->GetEnable()) {
	    if (ch->SetDistribution(distribution[i]) == 0) {
//		distribution[i] = (PDistribution*) distribution[i]->Clone();
		distribution[i]->Reset();
	    }
	}
    }
    return 0;
}


void PDistributionManagerUtil::DisableAlts(int id) {
    if (alt_distribution[id] != -1 ) {
	int mylist = alt_distribution[id];
	while (mylist != id) {
	    if (distribution[mylist]->GetEnable()) distribution[mylist]->SetEnable(0);
	    mylist = alt_distribution[mylist];
	    if (mylist == -1) mylist=id;
	}
    }
}


Int_t PDistributionManagerUtil::PrintGroup(Int_t group_id, Int_t width, Int_t indent,
				       const Char_t *name,
				       Int_t *num_enabled_mods, Int_t *num_total_mods,
				       Int_t *num_subs, Int_t *will_print) const {
    //Print a group (group_id) with all sub-groups
    //if width=0 make a "dry" test
    //width>0 :column width
    //returns the new column width (if width=0)
    //updates num_enabled_mods and num_subs

    //First, we loop over the groups and try to find
    //the sub-groups

    Int_t return_width = 0,
	dummy_will_print = 0,
	local_will_print = 0;

    //In a first step we find out how many valid subgroups and models
    //we have

    Int_t local_num_enabled_mods = 0,
	local_num_total_mods = 0,
	local_num_subs = 0;

    for (int gr=0; gr<group_position; gr++) {
	if (group_corr[gr] == group_id) {
	    Int_t local_width = PrintGroup(gr, 0, indent+2, name, &local_num_enabled_mods,
					   &local_num_total_mods, &local_num_subs, 
					   &dummy_will_print);
	    if (local_width > return_width) return_width = local_width;
	    if (dummy_will_print) local_will_print = 1;
	}
    }    

    for (int corr=0; corr<corr_position; corr++) {
	if (corr_gr[corr] == group_id) { //has found correlation
	    local_num_total_mods++;
	    if (distribution[corr_dis[corr]]->GetEnable())
		local_num_enabled_mods++;
	    Bool_t matched = kFALSE;
	    if (name)
		if (strcmp(name,group_identifier[group_id]) == 0) matched = kTRUE;
	    if (group_expanded[group_id] ||
		matched || local_will_print) { //Print List
		Int_t local_width = strlen(distribution[corr_dis[corr]]->GetIdentifier())+indent;
		if (local_width > return_width) 
		    return_width = local_width;

		if (alt_distribution[corr_dis[corr]] != -1 ) {
		    //have to take into account correlations
		    int mylist = alt_distribution[corr_dis[corr]];
		    while (mylist != corr_dis[corr]) {
			local_width = strlen(distribution[mylist]->GetIdentifier())+indent;
			if (local_width > return_width) 
			    return_width = local_width;
			mylist = alt_distribution[mylist];
			if (mylist == -1) 
			    mylist = corr_dis[corr];
		    }
		}
	    }
	}
    }

    //for the return statistics:
    if (local_num_total_mods && (width==0)) {
	*num_enabled_mods += local_num_enabled_mods;
	*num_total_mods   += local_num_total_mods;
	*num_subs         += local_num_subs+1;
	Int_t local_width = strlen(group_identifier[group_id])+indent;
	if (local_width > return_width) 
	    return_width = local_width;

	if (name)
	    if ((strcmp(name,group_identifier[group_id]) == 0)  || (group_expanded[group_id]) 
		|| local_will_print) {
		*will_print = 1;
		return return_width;
	    }
	*will_print = 0;
	return local_width+2;
    }

    if (!local_num_total_mods) return 0; //nothing to print
        
    //Print group header
    cout << "    ";
    for (Int_t  k=0; k<indent; k++) cout << " ";
    cout << group_identifier[group_id];

    if ((width-indent-strlen(group_identifier[group_id])) > 0) {
	for (UInt_t k=0; k<((width-indent-strlen(group_identifier[group_id]))); k++)
	    cout << " ";
    }
    cout << group_description[group_id] << " ";
    cout << ": "<<local_num_enabled_mods << " objects (of " << local_num_total_mods << ")";
    if (local_num_subs)
	cout << ", subgroups: " << local_num_subs << endl;
    else cout << endl;
    
    if (name != NULL)
	if ((strcmp(name,group_identifier[group_id]) !=0) && (group_expanded[group_id] ==0) 
	    && (local_will_print ==0)) {
	    return 0; //Unexpanded group
	}

    //first the sub-groups
    for (int gr=0; gr<group_position; gr++) {
	if (group_corr[gr] == group_id) {
	    PrintGroup(gr, width, indent+2, name, &local_num_enabled_mods, &local_num_total_mods, 
		       &local_num_subs, 
		       &dummy_will_print);
	}
    }    

    //Now we loop over the distributions

    for (int corr=0; corr<corr_position; corr++) {
	if (corr_gr[corr] == group_id) { //has found correlation
	    if (distribution[corr_dis[corr]]->GetEnable()) (*num_enabled_mods)++;

	    Bool_t matched = kFALSE;
	    if (name)
		if (strcmp(name,group_identifier[group_id]) == 0) matched = kTRUE;
	    if (group_expanded[group_id] ||
		matched) { //Print List
		
		if (alt_distribution[corr_dis[corr]] == -1 ) {
		    if (distribution[corr_dis[corr]]->GetEnable())
			cout << "[X] ";
		    else
			cout << "[ ] ";
		} else {
		    if (distribution[corr_dis[corr]]->GetEnable())
			cout << "(X) ";
		    else
			cout << "( ) ";
		}
		for (Int_t k=0; k<indent; k++) cout << " ";
		cout << distribution[corr_dis[corr]]->GetIdentifier();

		if ((width-indent-strlen(distribution[corr_dis[corr]]->GetIdentifier()))>0) {
		    for (UInt_t k=0; k<((width-indent-strlen(distribution[corr_dis[corr]]->GetIdentifier()))); k++)
			cout << " ";
		}
//		cout << (width-indent-strlen(distribution[corr_dis[corr]]->GetIdentifier())) << endl;
		cout << distribution[corr_dis[corr]]->GetDescription() << endl;;
		if (verbosity == 2)  { //Print out parameters etc... for the given Model
		    distribution[corr_dis[corr]]->Print();
		}		
		if (alt_distribution[corr_dis[corr]] != -1 ) {
		    int mylist=alt_distribution[corr_dis[corr]];
		    while (mylist != corr_dis[corr]) {
			if (distribution[mylist]->GetEnable()) {
			    cout << " (X)";
			    for (Int_t  k=0; k<indent; k++) cout << " ";
			    cout << distribution[mylist]->GetIdentifier();

			    if ((width-indent-strlen(distribution[mylist]->GetIdentifier()))>0) {
				for (UInt_t k=0; k<((width-indent-strlen(distribution[mylist]->GetIdentifier()))); k++) 
				    cout << " ";
				cout << distribution[mylist]->GetDescription() << endl;
			    }
			} else {
			    cout << " ( )";
			    for (Int_t  k=0; k<indent; k++) cout << " ";
			    cout << distribution[mylist]->GetIdentifier();

			    if ((width-indent-strlen(distribution[mylist]->GetIdentifier())) > 0) {
				for (UInt_t k=0;k<((width-indent-strlen(distribution[mylist]->GetIdentifier())));k++) 
				    cout << " ";
			    }
			    cout << distribution[mylist]->GetDescription() << endl;
			}
			mylist = alt_distribution[mylist];
			if (mylist == -1) 
			    mylist = corr_dis[corr];
		    }
		}
	    } //end print list
	}
    }

    return 0;
}

void PDistributionManagerUtil::Print(const Option_t *delme) const {

    UInt_t max_id_length = 0;

    for (int i=0; i<group_position; i++) {
	if (strlen(group_identifier[i]) > max_id_length)
	    max_id_length = strlen(group_identifier[i]);
    }
    for (int i=0; i<position; i++) {
	if (strlen(distribution[i]->GetIdentifier())>max_id_length)
	    max_id_length = strlen(distribution[i]->GetIdentifier());
//	cout << alt_distribution[i] << endl;
    }

    cout << "--------------------" << endl;
    cout << "PDistributionManager" << endl;
    cout << "--------------------" << endl;

    Int_t max_width = 0;
    Int_t a, b, c, d;
    for (int gr=0; gr<group_position; gr++) {
	//do not print if I'm a sub-group
	if (group_corr[gr] < 0) {
	    Int_t local_width = PrintGroup(gr, 0, 0, (char*)delme,
					 &a, &b, &c, &d);
	    if (local_width > max_width)  
		max_width = local_width;
	}
    }

    for (int gr=0; gr<group_position; gr++) {
	if (max_width && (group_corr[gr] < 0))
	    PrintGroup(gr, max_width+2, 0, (char*) delme,
		   &a, &b, &c, &d);
    }
    
//     if (!group_expanded[gr] && (print == 0) && (sum>0)) { //Print Summary
// 	print=1;
// 	cout << endl << "    ";
// 	cout << group_identifier[gr];
// 	for (UInt_t  k=0;k<((max_id_length-strlen(group_identifier[gr])+2));k++)
// 	    cout << " ";
// 	cout << group_description[gr] << ": " << enable << " enabled (out of " << sum << ")" << endl;
//     }
// } 
//end loop over groups

    cout << "--------------------" << endl;

    for (int i=0; i<position; i++) {
	if (delme)
	    if (strcmp(distribution[i]->GetIdentifier(), delme)==0)
		distribution[i]->Print();
    }
}

Bool_t PDistributionManagerUtil::Disable(const Char_t *id) {
    //Disable the distribution "id"
    //If "id" is a group, disable all distributions
    //which are members

    Bool_t retval = kFALSE;

    for (int i=0; i<position; i++) {
	if (strcmp(id, distribution[i]->GetIdentifier()) == 0) {
	    retval = kTRUE;
	    if (distribution[i]->GetEnable())
		distribution[i]->SetEnable(0);
	    
	}
    }
    //look for groups
    if (!retval) {
	Int_t mygr = GetGroup(id,0);
	if (mygr >= 0) {
	    for (int corr=0; corr<corr_position; corr++) {
		if (strcmp(id, group_identifier[corr_gr[corr]]) == 0) {
		    retval = kTRUE;
		    distribution[corr_dis[corr]]->SetEnable(0);
		}
	    }
	    for (int i=0; i<group_position; i++) {
		if (group_corr[i] == mygr) {
		    //i has id as parent
		    if (Disable(group_identifier[i])) 
			retval = kTRUE;
		}
	    }
	}
    }
    
    if (!retval) Warning("Disable", "%s not found", id);
    return retval;
}

Bool_t PDistributionManagerUtil::Enable(const Char_t *id) {
    //Enable the distribution "id"
    //If "id" is a group, enable all distributions
    //which are members
    //If the distribution is part of an alternatice chain, disable all 
    //other distributions

    Bool_t retval = kFALSE;

    for (int i=0; i<position; i++) {
	if  (strcmp(id, distribution[i]->GetIdentifier()) == 0) {
	    retval = kTRUE;
	    if ((distribution[i]->GetEnable() == 0)) {
		distribution[i]->SetEnable(1);
		DisableAlts(i);
	    }
	}
    }
    //look for groups
    if (!retval) {
	Int_t mygr=GetGroup(id, 0);
	if (mygr >= 0) {
	    for (int corr=0; corr<corr_position; corr++) {
		if (strcmp(id, group_identifier[corr_gr[corr]]) == 0) {
		    retval = kTRUE;
		    distribution[corr_dis[corr]]->SetEnable(1);
		    DisableAlts(corr_dis[corr]);
		}
	    }
	    for (int i=0; i<group_position; i++) {
		if (group_corr[i] == mygr) {
		    //i has id as parent
		    if (Enable(group_identifier[i])) 
			retval = kTRUE;
		}
	    }
	}
    }

    if (!retval) Warning("Enable", "%s not found", id);
    return retval;
}


PDistribution * PDistributionManagerUtil::GetDistribution(const Char_t * id) {
    for (int i=0; i<position; i++) {
//	if (distribution[i]->GetEnable() && (strcmp(id, distribution[i]->GetIdentifier()) == 0)) {
	if (strcmp(id, distribution[i]->GetIdentifier()) == 0) {
	    return distribution[i];
	}
    }
    return NULL;
}

void PDistributionManagerUtil::LinkDB(void) {
    //Links the list of distributions to the PDataBase
    //This makes coupled-channel calculations possible

    for (int i=0; i<position; i++) 
	if (distribution[i]->GetKey()>=0 && distribution[i]->GetEnable()) {

 	    if (makeDynamicData()->GetDecayModelByKey(distribution[i]->GetKey()) && (linkdb_done==0)) {
		//Print warning in first loop
		Warning("LinkDB", "'%s' would overwrite'%s' ", distribution[i]->GetDescription(),
			makeDynamicData()->GetDecayModelByKey(distribution[i]->GetKey())->GetDescription());
 	    } else {
		makeDynamicData()->SetDecayModelByKey(distribution[i]->GetKey(), 
						      (PChannelModel *)distribution[i] );
	    }
	}
    
    for (int i=0; i<position; i++) 
	if (distribution[i]->GetKey()>=0 && distribution[i]->GetEnable()) {
	    distribution[i]->FreezeOut();
	}
    
    linkdb_done = 1;   
}

//BUGBUG: Check if 2 keys are used

int PDistributionManagerUtil::AddGroup(const Char_t *id, const Char_t *de) {
    if ((GetGroup(id,0)) >= 0)
	return -1;

    if (group_position == MAX_GROUP_LIST) {
	Warning("AddGroup", "MAX_GROUP_LIST reached");
	return -1;
    }
    group_identifier[group_position]  = id;
    group_description[group_position] = de;
    group_expanded[group_position]    = 0;
    group_corr[group_position]        = -1;
    group_position++;
    return 0;
};

int PDistributionManagerUtil::AddSubGroup(const Char_t *id, const Char_t *de, const Char_t *parent_group) {
    if (AddGroup(id, de) < 0) return -1;
    Int_t mygr = GetGroup(id);
    Int_t par  = GetGroup(parent_group);
    if (par < 0) return -1;
    group_corr[mygr] = par;
    
    return 0;
}

Int_t PDistributionManagerUtil::AddCorrelation(Int_t gr, Int_t dis) {
    if (corr_position == MAX_CORR_LIST) {
	Warning("AddCorrelation", "MAX_CORR_LIST reached");
	return -1;
    }
    corr_gr[corr_position]  = gr;
    corr_dis[corr_position] = dis;
    corr_position++;
    return 0;
}

int PDistributionManagerUtil::GetGroup(const Char_t *id, Int_t warning) {
     for (int i=0; i<group_position; i++) {
	 if (strcmp(id, group_identifier[i]) == 0)
	     return i;
     }
     if (warning) Warning("GetGroup", "id %s not found", id);
     return -1;
};

void PDistributionManagerUtil::ExpandGroup(const char *id, Int_t ex) {
    Int_t pos = GetGroup(id);
    if (pos < 0) return;
    group_expanded[pos] = ex;
}

void PDistributionManagerUtil::SetGroup(const Char_t *id) {
    current_group = GetGroup(id);
};

ClassImp(PDistributionManagerUtil)
 PDistributionManagerUtil.cc:1
 PDistributionManagerUtil.cc:2
 PDistributionManagerUtil.cc:3
 PDistributionManagerUtil.cc:4
 PDistributionManagerUtil.cc:5
 PDistributionManagerUtil.cc:6
 PDistributionManagerUtil.cc:7
 PDistributionManagerUtil.cc:8
 PDistributionManagerUtil.cc:9
 PDistributionManagerUtil.cc:10
 PDistributionManagerUtil.cc:11
 PDistributionManagerUtil.cc:12
 PDistributionManagerUtil.cc:13
 PDistributionManagerUtil.cc:14
 PDistributionManagerUtil.cc:15
 PDistributionManagerUtil.cc:16
 PDistributionManagerUtil.cc:17
 PDistributionManagerUtil.cc:18
 PDistributionManagerUtil.cc:19
 PDistributionManagerUtil.cc:20
 PDistributionManagerUtil.cc:21
 PDistributionManagerUtil.cc:22
 PDistributionManagerUtil.cc:23
 PDistributionManagerUtil.cc:24
 PDistributionManagerUtil.cc:25
 PDistributionManagerUtil.cc:26
 PDistributionManagerUtil.cc:27
 PDistributionManagerUtil.cc:28
 PDistributionManagerUtil.cc:29
 PDistributionManagerUtil.cc:30
 PDistributionManagerUtil.cc:31
 PDistributionManagerUtil.cc:32
 PDistributionManagerUtil.cc:33
 PDistributionManagerUtil.cc:34
 PDistributionManagerUtil.cc:35
 PDistributionManagerUtil.cc:36
 PDistributionManagerUtil.cc:37
 PDistributionManagerUtil.cc:38
 PDistributionManagerUtil.cc:39
 PDistributionManagerUtil.cc:40
 PDistributionManagerUtil.cc:41
 PDistributionManagerUtil.cc:42
 PDistributionManagerUtil.cc:43
 PDistributionManagerUtil.cc:44
 PDistributionManagerUtil.cc:45
 PDistributionManagerUtil.cc:46
 PDistributionManagerUtil.cc:47
 PDistributionManagerUtil.cc:48
 PDistributionManagerUtil.cc:49
 PDistributionManagerUtil.cc:50
 PDistributionManagerUtil.cc:51
 PDistributionManagerUtil.cc:52
 PDistributionManagerUtil.cc:53
 PDistributionManagerUtil.cc:54
 PDistributionManagerUtil.cc:55
 PDistributionManagerUtil.cc:56
 PDistributionManagerUtil.cc:57
 PDistributionManagerUtil.cc:58
 PDistributionManagerUtil.cc:59
 PDistributionManagerUtil.cc:60
 PDistributionManagerUtil.cc:61
 PDistributionManagerUtil.cc:62
 PDistributionManagerUtil.cc:63
 PDistributionManagerUtil.cc:64
 PDistributionManagerUtil.cc:65
 PDistributionManagerUtil.cc:66
 PDistributionManagerUtil.cc:67
 PDistributionManagerUtil.cc:68
 PDistributionManagerUtil.cc:69
 PDistributionManagerUtil.cc:70
 PDistributionManagerUtil.cc:71
 PDistributionManagerUtil.cc:72
 PDistributionManagerUtil.cc:73
 PDistributionManagerUtil.cc:74
 PDistributionManagerUtil.cc:75
 PDistributionManagerUtil.cc:76
 PDistributionManagerUtil.cc:77
 PDistributionManagerUtil.cc:78
 PDistributionManagerUtil.cc:79
 PDistributionManagerUtil.cc:80
 PDistributionManagerUtil.cc:81
 PDistributionManagerUtil.cc:82
 PDistributionManagerUtil.cc:83
 PDistributionManagerUtil.cc:84
 PDistributionManagerUtil.cc:85
 PDistributionManagerUtil.cc:86
 PDistributionManagerUtil.cc:87
 PDistributionManagerUtil.cc:88
 PDistributionManagerUtil.cc:89
 PDistributionManagerUtil.cc:90
 PDistributionManagerUtil.cc:91
 PDistributionManagerUtil.cc:92
 PDistributionManagerUtil.cc:93
 PDistributionManagerUtil.cc:94
 PDistributionManagerUtil.cc:95
 PDistributionManagerUtil.cc:96
 PDistributionManagerUtil.cc:97
 PDistributionManagerUtil.cc:98
 PDistributionManagerUtil.cc:99
 PDistributionManagerUtil.cc:100
 PDistributionManagerUtil.cc:101
 PDistributionManagerUtil.cc:102
 PDistributionManagerUtil.cc:103
 PDistributionManagerUtil.cc:104
 PDistributionManagerUtil.cc:105
 PDistributionManagerUtil.cc:106
 PDistributionManagerUtil.cc:107
 PDistributionManagerUtil.cc:108
 PDistributionManagerUtil.cc:109
 PDistributionManagerUtil.cc:110
 PDistributionManagerUtil.cc:111
 PDistributionManagerUtil.cc:112
 PDistributionManagerUtil.cc:113
 PDistributionManagerUtil.cc:114
 PDistributionManagerUtil.cc:115
 PDistributionManagerUtil.cc:116
 PDistributionManagerUtil.cc:117
 PDistributionManagerUtil.cc:118
 PDistributionManagerUtil.cc:119
 PDistributionManagerUtil.cc:120
 PDistributionManagerUtil.cc:121
 PDistributionManagerUtil.cc:122
 PDistributionManagerUtil.cc:123
 PDistributionManagerUtil.cc:124
 PDistributionManagerUtil.cc:125
 PDistributionManagerUtil.cc:126
 PDistributionManagerUtil.cc:127
 PDistributionManagerUtil.cc:128
 PDistributionManagerUtil.cc:129
 PDistributionManagerUtil.cc:130
 PDistributionManagerUtil.cc:131
 PDistributionManagerUtil.cc:132
 PDistributionManagerUtil.cc:133
 PDistributionManagerUtil.cc:134
 PDistributionManagerUtil.cc:135
 PDistributionManagerUtil.cc:136
 PDistributionManagerUtil.cc:137
 PDistributionManagerUtil.cc:138
 PDistributionManagerUtil.cc:139
 PDistributionManagerUtil.cc:140
 PDistributionManagerUtil.cc:141
 PDistributionManagerUtil.cc:142
 PDistributionManagerUtil.cc:143
 PDistributionManagerUtil.cc:144
 PDistributionManagerUtil.cc:145
 PDistributionManagerUtil.cc:146
 PDistributionManagerUtil.cc:147
 PDistributionManagerUtil.cc:148
 PDistributionManagerUtil.cc:149
 PDistributionManagerUtil.cc:150
 PDistributionManagerUtil.cc:151
 PDistributionManagerUtil.cc:152
 PDistributionManagerUtil.cc:153
 PDistributionManagerUtil.cc:154
 PDistributionManagerUtil.cc:155
 PDistributionManagerUtil.cc:156
 PDistributionManagerUtil.cc:157
 PDistributionManagerUtil.cc:158
 PDistributionManagerUtil.cc:159
 PDistributionManagerUtil.cc:160
 PDistributionManagerUtil.cc:161
 PDistributionManagerUtil.cc:162
 PDistributionManagerUtil.cc:163
 PDistributionManagerUtil.cc:164
 PDistributionManagerUtil.cc:165
 PDistributionManagerUtil.cc:166
 PDistributionManagerUtil.cc:167
 PDistributionManagerUtil.cc:168
 PDistributionManagerUtil.cc:169
 PDistributionManagerUtil.cc:170
 PDistributionManagerUtil.cc:171
 PDistributionManagerUtil.cc:172
 PDistributionManagerUtil.cc:173
 PDistributionManagerUtil.cc:174
 PDistributionManagerUtil.cc:175
 PDistributionManagerUtil.cc:176
 PDistributionManagerUtil.cc:177
 PDistributionManagerUtil.cc:178
 PDistributionManagerUtil.cc:179
 PDistributionManagerUtil.cc:180
 PDistributionManagerUtil.cc:181
 PDistributionManagerUtil.cc:182
 PDistributionManagerUtil.cc:183
 PDistributionManagerUtil.cc:184
 PDistributionManagerUtil.cc:185
 PDistributionManagerUtil.cc:186
 PDistributionManagerUtil.cc:187
 PDistributionManagerUtil.cc:188
 PDistributionManagerUtil.cc:189
 PDistributionManagerUtil.cc:190
 PDistributionManagerUtil.cc:191
 PDistributionManagerUtil.cc:192
 PDistributionManagerUtil.cc:193
 PDistributionManagerUtil.cc:194
 PDistributionManagerUtil.cc:195
 PDistributionManagerUtil.cc:196
 PDistributionManagerUtil.cc:197
 PDistributionManagerUtil.cc:198
 PDistributionManagerUtil.cc:199
 PDistributionManagerUtil.cc:200
 PDistributionManagerUtil.cc:201
 PDistributionManagerUtil.cc:202
 PDistributionManagerUtil.cc:203
 PDistributionManagerUtil.cc:204
 PDistributionManagerUtil.cc:205
 PDistributionManagerUtil.cc:206
 PDistributionManagerUtil.cc:207
 PDistributionManagerUtil.cc:208
 PDistributionManagerUtil.cc:209
 PDistributionManagerUtil.cc:210
 PDistributionManagerUtil.cc:211
 PDistributionManagerUtil.cc:212
 PDistributionManagerUtil.cc:213
 PDistributionManagerUtil.cc:214
 PDistributionManagerUtil.cc:215
 PDistributionManagerUtil.cc:216
 PDistributionManagerUtil.cc:217
 PDistributionManagerUtil.cc:218
 PDistributionManagerUtil.cc:219
 PDistributionManagerUtil.cc:220
 PDistributionManagerUtil.cc:221
 PDistributionManagerUtil.cc:222
 PDistributionManagerUtil.cc:223
 PDistributionManagerUtil.cc:224
 PDistributionManagerUtil.cc:225
 PDistributionManagerUtil.cc:226
 PDistributionManagerUtil.cc:227
 PDistributionManagerUtil.cc:228
 PDistributionManagerUtil.cc:229
 PDistributionManagerUtil.cc:230
 PDistributionManagerUtil.cc:231
 PDistributionManagerUtil.cc:232
 PDistributionManagerUtil.cc:233
 PDistributionManagerUtil.cc:234
 PDistributionManagerUtil.cc:235
 PDistributionManagerUtil.cc:236
 PDistributionManagerUtil.cc:237
 PDistributionManagerUtil.cc:238
 PDistributionManagerUtil.cc:239
 PDistributionManagerUtil.cc:240
 PDistributionManagerUtil.cc:241
 PDistributionManagerUtil.cc:242
 PDistributionManagerUtil.cc:243
 PDistributionManagerUtil.cc:244
 PDistributionManagerUtil.cc:245
 PDistributionManagerUtil.cc:246
 PDistributionManagerUtil.cc:247
 PDistributionManagerUtil.cc:248
 PDistributionManagerUtil.cc:249
 PDistributionManagerUtil.cc:250
 PDistributionManagerUtil.cc:251
 PDistributionManagerUtil.cc:252
 PDistributionManagerUtil.cc:253
 PDistributionManagerUtil.cc:254
 PDistributionManagerUtil.cc:255
 PDistributionManagerUtil.cc:256
 PDistributionManagerUtil.cc:257
 PDistributionManagerUtil.cc:258
 PDistributionManagerUtil.cc:259
 PDistributionManagerUtil.cc:260
 PDistributionManagerUtil.cc:261
 PDistributionManagerUtil.cc:262
 PDistributionManagerUtil.cc:263
 PDistributionManagerUtil.cc:264
 PDistributionManagerUtil.cc:265
 PDistributionManagerUtil.cc:266
 PDistributionManagerUtil.cc:267
 PDistributionManagerUtil.cc:268
 PDistributionManagerUtil.cc:269
 PDistributionManagerUtil.cc:270
 PDistributionManagerUtil.cc:271
 PDistributionManagerUtil.cc:272
 PDistributionManagerUtil.cc:273
 PDistributionManagerUtil.cc:274
 PDistributionManagerUtil.cc:275
 PDistributionManagerUtil.cc:276
 PDistributionManagerUtil.cc:277
 PDistributionManagerUtil.cc:278
 PDistributionManagerUtil.cc:279
 PDistributionManagerUtil.cc:280
 PDistributionManagerUtil.cc:281
 PDistributionManagerUtil.cc:282
 PDistributionManagerUtil.cc:283
 PDistributionManagerUtil.cc:284
 PDistributionManagerUtil.cc:285
 PDistributionManagerUtil.cc:286
 PDistributionManagerUtil.cc:287
 PDistributionManagerUtil.cc:288
 PDistributionManagerUtil.cc:289
 PDistributionManagerUtil.cc:290
 PDistributionManagerUtil.cc:291
 PDistributionManagerUtil.cc:292
 PDistributionManagerUtil.cc:293
 PDistributionManagerUtil.cc:294
 PDistributionManagerUtil.cc:295
 PDistributionManagerUtil.cc:296
 PDistributionManagerUtil.cc:297
 PDistributionManagerUtil.cc:298
 PDistributionManagerUtil.cc:299
 PDistributionManagerUtil.cc:300
 PDistributionManagerUtil.cc:301
 PDistributionManagerUtil.cc:302
 PDistributionManagerUtil.cc:303
 PDistributionManagerUtil.cc:304
 PDistributionManagerUtil.cc:305
 PDistributionManagerUtil.cc:306
 PDistributionManagerUtil.cc:307
 PDistributionManagerUtil.cc:308
 PDistributionManagerUtil.cc:309
 PDistributionManagerUtil.cc:310
 PDistributionManagerUtil.cc:311
 PDistributionManagerUtil.cc:312
 PDistributionManagerUtil.cc:313
 PDistributionManagerUtil.cc:314
 PDistributionManagerUtil.cc:315
 PDistributionManagerUtil.cc:316
 PDistributionManagerUtil.cc:317
 PDistributionManagerUtil.cc:318
 PDistributionManagerUtil.cc:319
 PDistributionManagerUtil.cc:320
 PDistributionManagerUtil.cc:321
 PDistributionManagerUtil.cc:322
 PDistributionManagerUtil.cc:323
 PDistributionManagerUtil.cc:324
 PDistributionManagerUtil.cc:325
 PDistributionManagerUtil.cc:326
 PDistributionManagerUtil.cc:327
 PDistributionManagerUtil.cc:328
 PDistributionManagerUtil.cc:329
 PDistributionManagerUtil.cc:330
 PDistributionManagerUtil.cc:331
 PDistributionManagerUtil.cc:332
 PDistributionManagerUtil.cc:333
 PDistributionManagerUtil.cc:334
 PDistributionManagerUtil.cc:335
 PDistributionManagerUtil.cc:336
 PDistributionManagerUtil.cc:337
 PDistributionManagerUtil.cc:338
 PDistributionManagerUtil.cc:339
 PDistributionManagerUtil.cc:340
 PDistributionManagerUtil.cc:341
 PDistributionManagerUtil.cc:342
 PDistributionManagerUtil.cc:343
 PDistributionManagerUtil.cc:344
 PDistributionManagerUtil.cc:345
 PDistributionManagerUtil.cc:346
 PDistributionManagerUtil.cc:347
 PDistributionManagerUtil.cc:348
 PDistributionManagerUtil.cc:349
 PDistributionManagerUtil.cc:350
 PDistributionManagerUtil.cc:351
 PDistributionManagerUtil.cc:352
 PDistributionManagerUtil.cc:353
 PDistributionManagerUtil.cc:354
 PDistributionManagerUtil.cc:355
 PDistributionManagerUtil.cc:356
 PDistributionManagerUtil.cc:357
 PDistributionManagerUtil.cc:358
 PDistributionManagerUtil.cc:359
 PDistributionManagerUtil.cc:360
 PDistributionManagerUtil.cc:361
 PDistributionManagerUtil.cc:362
 PDistributionManagerUtil.cc:363
 PDistributionManagerUtil.cc:364
 PDistributionManagerUtil.cc:365
 PDistributionManagerUtil.cc:366
 PDistributionManagerUtil.cc:367
 PDistributionManagerUtil.cc:368
 PDistributionManagerUtil.cc:369
 PDistributionManagerUtil.cc:370
 PDistributionManagerUtil.cc:371
 PDistributionManagerUtil.cc:372
 PDistributionManagerUtil.cc:373
 PDistributionManagerUtil.cc:374
 PDistributionManagerUtil.cc:375
 PDistributionManagerUtil.cc:376
 PDistributionManagerUtil.cc:377
 PDistributionManagerUtil.cc:378
 PDistributionManagerUtil.cc:379
 PDistributionManagerUtil.cc:380
 PDistributionManagerUtil.cc:381
 PDistributionManagerUtil.cc:382
 PDistributionManagerUtil.cc:383
 PDistributionManagerUtil.cc:384
 PDistributionManagerUtil.cc:385
 PDistributionManagerUtil.cc:386
 PDistributionManagerUtil.cc:387
 PDistributionManagerUtil.cc:388
 PDistributionManagerUtil.cc:389
 PDistributionManagerUtil.cc:390
 PDistributionManagerUtil.cc:391
 PDistributionManagerUtil.cc:392
 PDistributionManagerUtil.cc:393
 PDistributionManagerUtil.cc:394
 PDistributionManagerUtil.cc:395
 PDistributionManagerUtil.cc:396
 PDistributionManagerUtil.cc:397
 PDistributionManagerUtil.cc:398
 PDistributionManagerUtil.cc:399
 PDistributionManagerUtil.cc:400
 PDistributionManagerUtil.cc:401
 PDistributionManagerUtil.cc:402
 PDistributionManagerUtil.cc:403
 PDistributionManagerUtil.cc:404
 PDistributionManagerUtil.cc:405
 PDistributionManagerUtil.cc:406
 PDistributionManagerUtil.cc:407
 PDistributionManagerUtil.cc:408
 PDistributionManagerUtil.cc:409
 PDistributionManagerUtil.cc:410
 PDistributionManagerUtil.cc:411
 PDistributionManagerUtil.cc:412
 PDistributionManagerUtil.cc:413
 PDistributionManagerUtil.cc:414
 PDistributionManagerUtil.cc:415
 PDistributionManagerUtil.cc:416
 PDistributionManagerUtil.cc:417
 PDistributionManagerUtil.cc:418
 PDistributionManagerUtil.cc:419
 PDistributionManagerUtil.cc:420
 PDistributionManagerUtil.cc:421
 PDistributionManagerUtil.cc:422
 PDistributionManagerUtil.cc:423
 PDistributionManagerUtil.cc:424
 PDistributionManagerUtil.cc:425
 PDistributionManagerUtil.cc:426
 PDistributionManagerUtil.cc:427
 PDistributionManagerUtil.cc:428
 PDistributionManagerUtil.cc:429
 PDistributionManagerUtil.cc:430
 PDistributionManagerUtil.cc:431
 PDistributionManagerUtil.cc:432
 PDistributionManagerUtil.cc:433
 PDistributionManagerUtil.cc:434
 PDistributionManagerUtil.cc:435
 PDistributionManagerUtil.cc:436
 PDistributionManagerUtil.cc:437
 PDistributionManagerUtil.cc:438
 PDistributionManagerUtil.cc:439
 PDistributionManagerUtil.cc:440
 PDistributionManagerUtil.cc:441
 PDistributionManagerUtil.cc:442
 PDistributionManagerUtil.cc:443
 PDistributionManagerUtil.cc:444
 PDistributionManagerUtil.cc:445
 PDistributionManagerUtil.cc:446
 PDistributionManagerUtil.cc:447
 PDistributionManagerUtil.cc:448
 PDistributionManagerUtil.cc:449
 PDistributionManagerUtil.cc:450
 PDistributionManagerUtil.cc:451
 PDistributionManagerUtil.cc:452
 PDistributionManagerUtil.cc:453
 PDistributionManagerUtil.cc:454
 PDistributionManagerUtil.cc:455
 PDistributionManagerUtil.cc:456
 PDistributionManagerUtil.cc:457
 PDistributionManagerUtil.cc:458
 PDistributionManagerUtil.cc:459
 PDistributionManagerUtil.cc:460
 PDistributionManagerUtil.cc:461
 PDistributionManagerUtil.cc:462
 PDistributionManagerUtil.cc:463
 PDistributionManagerUtil.cc:464
 PDistributionManagerUtil.cc:465
 PDistributionManagerUtil.cc:466
 PDistributionManagerUtil.cc:467
 PDistributionManagerUtil.cc:468
 PDistributionManagerUtil.cc:469
 PDistributionManagerUtil.cc:470
 PDistributionManagerUtil.cc:471
 PDistributionManagerUtil.cc:472
 PDistributionManagerUtil.cc:473
 PDistributionManagerUtil.cc:474
 PDistributionManagerUtil.cc:475
 PDistributionManagerUtil.cc:476
 PDistributionManagerUtil.cc:477
 PDistributionManagerUtil.cc:478
 PDistributionManagerUtil.cc:479
 PDistributionManagerUtil.cc:480
 PDistributionManagerUtil.cc:481
 PDistributionManagerUtil.cc:482
 PDistributionManagerUtil.cc:483
 PDistributionManagerUtil.cc:484
 PDistributionManagerUtil.cc:485
 PDistributionManagerUtil.cc:486
 PDistributionManagerUtil.cc:487
 PDistributionManagerUtil.cc:488
 PDistributionManagerUtil.cc:489
 PDistributionManagerUtil.cc:490
 PDistributionManagerUtil.cc:491
 PDistributionManagerUtil.cc:492
 PDistributionManagerUtil.cc:493
 PDistributionManagerUtil.cc:494
 PDistributionManagerUtil.cc:495
 PDistributionManagerUtil.cc:496
 PDistributionManagerUtil.cc:497
 PDistributionManagerUtil.cc:498
 PDistributionManagerUtil.cc:499
 PDistributionManagerUtil.cc:500
 PDistributionManagerUtil.cc:501
 PDistributionManagerUtil.cc:502
 PDistributionManagerUtil.cc:503
 PDistributionManagerUtil.cc:504
 PDistributionManagerUtil.cc:505
 PDistributionManagerUtil.cc:506
 PDistributionManagerUtil.cc:507
 PDistributionManagerUtil.cc:508
 PDistributionManagerUtil.cc:509
 PDistributionManagerUtil.cc:510
 PDistributionManagerUtil.cc:511
 PDistributionManagerUtil.cc:512
 PDistributionManagerUtil.cc:513
 PDistributionManagerUtil.cc:514
 PDistributionManagerUtil.cc:515
 PDistributionManagerUtil.cc:516
 PDistributionManagerUtil.cc:517
 PDistributionManagerUtil.cc:518
 PDistributionManagerUtil.cc:519
 PDistributionManagerUtil.cc:520
 PDistributionManagerUtil.cc:521
 PDistributionManagerUtil.cc:522
 PDistributionManagerUtil.cc:523
 PDistributionManagerUtil.cc:524
 PDistributionManagerUtil.cc:525
 PDistributionManagerUtil.cc:526
 PDistributionManagerUtil.cc:527
 PDistributionManagerUtil.cc:528
 PDistributionManagerUtil.cc:529
 PDistributionManagerUtil.cc:530
 PDistributionManagerUtil.cc:531
 PDistributionManagerUtil.cc:532
 PDistributionManagerUtil.cc:533
 PDistributionManagerUtil.cc:534
 PDistributionManagerUtil.cc:535
 PDistributionManagerUtil.cc:536
 PDistributionManagerUtil.cc:537
 PDistributionManagerUtil.cc:538
 PDistributionManagerUtil.cc:539
 PDistributionManagerUtil.cc:540
 PDistributionManagerUtil.cc:541
 PDistributionManagerUtil.cc:542
 PDistributionManagerUtil.cc:543
 PDistributionManagerUtil.cc:544
 PDistributionManagerUtil.cc:545
 PDistributionManagerUtil.cc:546
 PDistributionManagerUtil.cc:547
 PDistributionManagerUtil.cc:548
 PDistributionManagerUtil.cc:549
 PDistributionManagerUtil.cc:550
 PDistributionManagerUtil.cc:551
 PDistributionManagerUtil.cc:552
 PDistributionManagerUtil.cc:553
 PDistributionManagerUtil.cc:554
 PDistributionManagerUtil.cc:555
 PDistributionManagerUtil.cc:556
 PDistributionManagerUtil.cc:557
 PDistributionManagerUtil.cc:558
 PDistributionManagerUtil.cc:559
 PDistributionManagerUtil.cc:560
 PDistributionManagerUtil.cc:561
 PDistributionManagerUtil.cc:562
 PDistributionManagerUtil.cc:563
 PDistributionManagerUtil.cc:564
 PDistributionManagerUtil.cc:565
 PDistributionManagerUtil.cc:566
 PDistributionManagerUtil.cc:567
 PDistributionManagerUtil.cc:568
 PDistributionManagerUtil.cc:569
 PDistributionManagerUtil.cc:570
 PDistributionManagerUtil.cc:571
 PDistributionManagerUtil.cc:572
 PDistributionManagerUtil.cc:573
 PDistributionManagerUtil.cc:574
 PDistributionManagerUtil.cc:575
 PDistributionManagerUtil.cc:576
 PDistributionManagerUtil.cc:577
 PDistributionManagerUtil.cc:578
 PDistributionManagerUtil.cc:579
 PDistributionManagerUtil.cc:580
 PDistributionManagerUtil.cc:581
 PDistributionManagerUtil.cc:582
 PDistributionManagerUtil.cc:583
 PDistributionManagerUtil.cc:584
 PDistributionManagerUtil.cc:585
 PDistributionManagerUtil.cc:586
 PDistributionManagerUtil.cc:587
 PDistributionManagerUtil.cc:588
 PDistributionManagerUtil.cc:589
 PDistributionManagerUtil.cc:590
 PDistributionManagerUtil.cc:591
 PDistributionManagerUtil.cc:592
 PDistributionManagerUtil.cc:593
 PDistributionManagerUtil.cc:594
 PDistributionManagerUtil.cc:595
 PDistributionManagerUtil.cc:596
 PDistributionManagerUtil.cc:597
 PDistributionManagerUtil.cc:598
 PDistributionManagerUtil.cc:599
 PDistributionManagerUtil.cc:600
 PDistributionManagerUtil.cc:601
 PDistributionManagerUtil.cc:602
 PDistributionManagerUtil.cc:603
 PDistributionManagerUtil.cc:604
 PDistributionManagerUtil.cc:605
 PDistributionManagerUtil.cc:606
 PDistributionManagerUtil.cc:607
 PDistributionManagerUtil.cc:608
 PDistributionManagerUtil.cc:609
 PDistributionManagerUtil.cc:610
 PDistributionManagerUtil.cc:611
 PDistributionManagerUtil.cc:612
 PDistributionManagerUtil.cc:613
 PDistributionManagerUtil.cc:614
 PDistributionManagerUtil.cc:615
 PDistributionManagerUtil.cc:616
 PDistributionManagerUtil.cc:617
 PDistributionManagerUtil.cc:618
 PDistributionManagerUtil.cc:619
 PDistributionManagerUtil.cc:620
 PDistributionManagerUtil.cc:621