Does this implementation of the "Context Pattern" look ok?
I have multiple processing units that might exist in an array, each with their own parameters. I would like to communicate the parameters of each processing unit using the *context pattern* after suggested as a [solution to another question][1]. However, I am unable to find simple C++ examples of the pattern online. I have made a simplified implementation below for your inspection. The code works and compiles just fine, but **am I implementing the pattern correctly?** Any and all suggestions for style improvements would be most welcome.

    #include <iostream>
    #include <sstream>
    
    #include <map>
    
    class cParamsContext
    {        
    public:
        std::map<std::string, float> paramMap;    
        cParamsContext()
        {
            paramMap["a0"] = 1.f;
            paramMap["a1"] = 2.f;
        }
    };
    
    class cProcessUnit
    {
        float parameter;
        int id;
        
    public:
        cProcessUnit(cParamsContext &contextObj, int id_) : parameter (0.f), id(id_)
        {
            std::stringstream idStream;
            idStream << id;
            
            std::string key = std::string( "a" + idStream.str() );
            
            if(contextObj.paramMap.find( key ) != contextObj.paramMap.end())        
                parameter = contextObj.paramMap[key]; //parameter set to keyed value if it exists                 
        }
        
        float getParam() {return parameter;}
    };
    
    
    int main(int argc, char *argv[])
    {
        cParamsContext contextObj;
        
        
        for (int nn=0; nn<3; nn++)
        {
            cProcessUnit temp(contextObj, nn);
            std::cout << "Processing unit "  << nn << " param = " << temp.getParam() << std::endl;
        }
    }

Furthermore, can you suggest how I could make the parameters within each class update themselves should the parameter map change?

The output looks like this incase you were interested  . . . .

    Processing unit 0 param = 1
    Processing unit 1 param = 2
    Processing unit 2 param = 0

  [1]: http://stackoverflow.com/questions/10398852/is-there-a-recommended-design-pattern-for-communicating-parameters-with-a-proces
Does this implementation of the "Context Pattern" look ok?
===

I have multiple processing units that might exist in an array, each with their own parameters. I would like to communicate the parameters of each processing unit using the *context pattern* after suggested as a [solution to another question][1]. However, I am unable to find simple C++ examples of the pattern online. I have made a simplified implementation below for your inspection. The code works and compiles just fine, but **am I implementing the pattern correctly?** Any and all suggestions for style improvements would be most welcome.

    #include <iostream>
    #include <sstream>
    
    #include <map>
    
    class cParamsContext
    {        
    public:
        std::map<std::string, float> paramMap;    
        cParamsContext()
        {
            paramMap["a0"] = 1.f;
            paramMap["a1"] = 2.f;
        }
    };
    
    class cProcessUnit
    {
        float parameter;
        int id;
        
    public:
        cProcessUnit(cParamsContext &contextObj, int id_) : parameter (0.f), id(id_)
        {
            std::stringstream idStream;
            idStream << id;
            
            std::string key = std::string( "a" + idStream.str() );
            
            if(contextObj.paramMap.find( key ) != contextObj.paramMap.end())        
                parameter = contextObj.paramMap[key]; //parameter set to keyed value if it exists                 
        }
        
        float getParam() {return parameter;}
    };
    
    
    int main(int argc, char *argv[])
    {
        cParamsContext contextObj;
        
        
        for (int nn=0; nn<3; nn++)
        {
            cProcessUnit temp(contextObj, nn);
            std::cout << "Processing unit "  << nn << " param = " << temp.getParam() << std::endl;
        }
    }

Furthermore, can you suggest how I could make the parameters within each class update themselves should the parameter map change?

The output looks like this incase you were interested  . . . .

    Processing unit 0 param = 1
    Processing unit 1 param = 2
    Processing unit 2 param = 0

  [1]: http://stackoverflow.com/questions/10398852/is-there-a-recommended-design-pattern-for-communicating-parameters-with-a-proces