inserting new class in quantlib

Posted by Piero Del Boca on
URL: http://quantlib.414.s1.nabble.com/inserting-new-class-in-quantlib-tp5546.html

Hi all,
    i'm a new user and i'm trying to insert and compile a new class in
quantlib.
I apologize for this newbie question:

if i compile my class all work well but if i insert it in quantlib,
visual studio can't build the library giving me the following error:

1>d:\Quantlib\QuantLib-0.9.0\ql/indexes/inflationindexseasonality.hpp(52)
: fatal error C1004: unexpected end-of-file found
1>inflationindex.cpp
1>d:\Quantlib\QuantLib-0.9.0\ql/indexes/inflationindexseasonality.hpp(52)
: fatal error C1004: unexpected end-of-file found

If i delete the following rows:
 
#ifndef SEASONALITY_HPP (12)
#define SEASONALITY_HPP (12)
#endif (52)

visual studio can compile and i'm able to use my class.
I can't find the reason of this error; anyone has any ideas?

Thank you very much for help.
Bye

Piero


//File name: inflationindexseasonality.cpp
//
//Author: Piero Del Boca
//
//Last changes: 14/02/2007
//

#include <ql/indexes/inflationindexseasonality.hpp>
#include <ql/errors.hpp>

namespace QuantLib {

        Seasonality::Seasonality() {
                int dim = 12; //12 is the number of months in 1 year
                seasonalityFactors = new Rate[dim];
                for (int i=0; i<dim; i++) {seasonalityFactors[i] = 1.;}
        }

        Seasonality::Seasonality(Rate *seasonalityFactorsInit,
                                                         Month baseMonthInit,
                                                         bool normalized) {

                                                                 int dim = 12; //12 is the number of months in 1 year
                                                                 seasonalityFactors = new Rate[dim];
                                                                 for (int i=0; i<dim; i++) {
                                                                         seasonalityFactors[i] = seasonalityFactorsInit[i];
                                                                 }
                                                                 SetBaseMonth(baseMonthInit);

                                                                 if (!normalized) {
                                                                        for (int i=0; i<dim; i++) {
                                                                                seasonalityFactors[i] /= seasonalityFactorsInit[baseMonth-1];
                                                                        }
                                                                 }
                                                                 else{
                                                                        QL_REQUIRE(seasonalityFactors[baseMonth-1] == 1.,
                                                                                       "Base month seasonality factor is different from 1; "
                                                                                           "if your seasonality factors aren't normalized pls insert "
                                                                                           "normalized = false");
                                                                }
        }

        Seasonality::~Seasonality() {
                delete[] seasonalityFactors;
        }

        void Seasonality::SetSeasonalityFactor(Month monthInit,
                                                                               Rate seasonalityFactorInit) {
                                                                                           seasonalityFactors[monthInit-1] = seasonalityFactorInit;
        }

        void Seasonality::SetBaseMonth(Month baseMonthInit) {
                baseMonth = baseMonthInit;
        }

        Rate Seasonality::GetSeasonalityFactor(Month monthInit) const {
                return seasonalityFactors[monthInit-1];
        }

        Month Seasonality::GetBaseMonth() const {
                return baseMonth;
        }

}
//File name: inflationindexseasonality.hpp
//
//Author: Piero Del Boca
//
//Last changes: 14/02/2007
//
//Description: this class contains normalized seasonality factors and base CPI month;
//             in the base CPI month (called baseMonth) seasonality factor must be = 1;
//   this class is built for a MOLTIPLICATIVE seasonality correction.
//

#ifndef SEASONALITY_HPP
#define SEASONALITY_HPP

#include <ql/time/date.hpp>

namespace QuantLib {

        class Seasonality {

                private :
                        Rate *seasonalityFactors;
                        Month baseMonth;

                public :
               
                        //Constructor
                        //
                        Seasonality(); //It sets seasonality factors = 1

                        Seasonality(Rate *seasonalityFactorsInit, //Insert seasonality factors starting from January
                                                Month baseMonthInit,
                                                bool normalized); //Set true if seasonality factors are normalized

                        //Destructor
                        //
                        ~Seasonality();

                        //Functions        
                        //
                        void SetBaseMonth(Month baseMonthInit);
                        void SetSeasonalityFactor(Month monthInit,
                                                                          Rate seasonalityFactorInit);

                        Rate GetSeasonalityFactor(Month monthInit) const;
                        Month GetBaseMonth() const;
             
        };

}

#endif
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users