source: trunk/yao/src/YAOObjects/Object.hpp @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 3.4 KB
Line 
1//! \file    Object.hpp
2//! \brief   Declaration and implementation of the base Object class.
3//! \version 2007/10/01 (yyyy/mm/dd)
4//! \author  Luigi Nardi <luiginardi(at)gmail.com>
5//
6// This file is part of YAO, a framework for variational assimilation in
7// numerical models.
8// Copyright (c) 2001-onwards LOCEAN. All rights reserved.
9//
10// This program may be redistributed and/or modified under the terms of the GNU
11// General Public License as published by the Free Software Foundation, either
12// version 2 of the license, or (at your option) any later version.
13//
14// This program is provided AS IS and WITHOUT ANY WARRANTY, including any
15// implied warranty of DESIGN, MERCHANTABILITY or FITNESS FOR A PARTICULAR
16// PURPOSE.
17//
18//! \mainpage
19//!
20//! YAO is a software framework for variational assimilation in numerical
21//! models. It aims at generating new C++ codes rather than automatically
22//! generating  adjoint codes from existing softwares.
23//!
24//! The main idea is to break up the numerical code of the model into a graph of
25//! connected modules. Each module represents a function, whose inputs are
26//! connected to the outputs of the forward modules. This approach allows to
27//! build complex systems. When the model is differentiable, YAO facilitates the
28//! coding of the adjoint and linear tangent of the model by handling the
29//! input/outputs of the different modules. This allows to supervise the model,
30//! using variational data assimilation methodology, with very few software
31//! development involved.
32
33
34#ifndef YAO_OBJECT_HPP_INCLUDED
35#define YAO_OBJECT_HPP_INCLUDED
36
37#include "../help/Helper.hpp"
38
39#include <string>
40
41//! \namespace yao
42//! \brief YAO namespace.
43namespace yao{
44
45  /**
46   * Object base class. Here we store the basic information for all the Yao objects that
47   * inherits from this class. We redefine some operator like "less-than".
48   */
49  class Object{
50
51    public:
52
53      /**
54       * Default constructor.
55       * @param aName is the name of the Object.
56       */
57      Object(const std::string& aName=""): theName(aName) {}
58     
59      //!< Destructor.
60      virtual ~Object() {}
61
62      /**
63       * Set the name of the Object.
64       * @param aName is the name of the Object.
65       */
66      void setName(const std::string& aName) { theName = aName; }
67
68      /**
69       * Get the name of the Object.
70       * @return the name of the Object.
71       */
72      const std::string& getName() const { return theName; }
73
74      //! The number of information stored in this class.
75      static int getPropertyCount() { return 1; }
76
77      //! Get the name of the property class: "object".
78      static std::string getPropertyName(int anIndex){
79        ENFORCE(anIndex == 0);
80        static const char* propertyName[] = { "object" };
81        return propertyName[anIndex];
82      }
83
84      //! Get the name information in function of an integer that identifies it.
85      virtual std::string getProperty(int anIndex) const{
86        return anIndex == 0? stream_cast<std::string>(theName): "";
87      }
88
89      //! Comparison less-than operator, required for use with std::less (should
90      //! better be achieved using some dedicated/specialized less-than functor).
91      bool operator<(const Object& anObject) const{
92        return theName < anObject.theName;
93      }
94
95    protected:
96
97      //! The only information of the class is the object name. 
98      std::string theName;
99  };
100
101} // End namespace yao.
102#endif //! YAO_OBJECT_HPP_INCLUDED.
Note: See TracBrowser for help on using the repository browser.