#include <iostream>
#include <string>
#include <fstream>
#include <map>
#include <vector>
#include <sstream>
using std::ifstream;
using std:
fstream;
using std::string;
using std::cout;
using std::endl;
using std::cin;
using std::cerr;
using std::string;
using std::istringstream;
using std::vector;
template<int dim>
class sc_int{
public:
char mess[dim];
sc_int(char * str, int n){
int fine = min(n,dim);
for(int j = 0; j < fine; j++ )
mess[j]=str[j];
}
char * get_mess(){
return mess;
}
int min(int n, int dime){
if(n>dime)
return dime;
else
return n;
}
};
class ps_power_model
{
public :
ps_power_model(){
cerr << "Error 504: Distructor not defined in derived class of ps_power_model" << endl;
};
virtual ~ps_power_model(){
cerr << "Error 506: Distructor not defined in derived class of ps_power_model" << endl;
};
template<int dim>
virtual void stampa(sc_int<dim> ciao)
{
cout << "base"<<endl;
};
virtual void ciao(){
cout << "boooooooooo" << endl;
}
static int get_number_parameter(void){
cerr << "Error 504: Function - get_number_parameter() - not defined in derived class of ps_power_model." << endl;
exit(1);
};
};
class ps_costant_model : public ps_power_model
{
public :
static int num_param;
ps_costant_model(){
cerr << "Error 510: Distructor not defined in derived class of ps_power_model" << endl;
};
~ps_costant_model(){
cerr << "Error 520: Distructor not defined in derived class of ps_power_model" << endl;
};
void ciao(){
cout << "Marco foreever"<<endl;
};
template<int dim>
void stampa(sc_int<dim> ciao){
cout << ciao.get_mess() << endl;
}
static int get_number_parameter(void){
return num_param;
};
};
int ps_costant_model::num_param(3);
template<int dim>
void stampa(sc_int<dim>);
static ps_power_model * get_power_model(int);
int main(void){
sc_int<20> int1("messaggio 1",12);
sc_int<40> int2("messaggio 2",12);
stampa(int1);
stampa(int2);
stampa(int1);
std::map<string, ps_power_model*> power_module_table;
std::map<string, ps_power_model*>::iterator iter;
ps_power_model * model;
string ciao("ciao");
model = get_power_model(0);
power_module_table.insert(std:
air<string,ps_power_model*>(ciao,(model)));
iter = power_module_table.find (string("ciao"));
if(iter != power_module_table.end())
iter->second->stampa(int1);
power_module_table[ciao]->stampa(int2);
}
template<int dim>
void stampa(sc_int<dim> ciao){
cout << ciao.get_mess() << endl;
}
static ps_power_model * get_power_model(int num_of_model){
switch(num_of_model){
case 0 :
return new ps_costant_model;
break;
default :
return new ps_costant_model;
}
};