text: /*
   * Copyright 2013 Stanford University.
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * - Redistributions of source code must retain the above copyright
   *   notice, this list of conditions and the following disclaimer.
   *
   * - Redistributions in binary form must reproduce the above copyright
   *   notice, this list of conditions and the following disclaimer in the
   *   documentation and/or other materials provided with the
   *   distribution.
   *
   * - Neither the name of the copyright holders nor the names of
   *   its contributors may be used to endorse or promote products derived
   *   from this software without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
  /*
   * Author: Hang Qu <quhang@stanford.edu>
   */
  
  #ifndef NIMBUS_APPLICATION_WATER_MULTIPLE_CACHE_ARRAY_M2C_H_
  #define NIMBUS_APPLICATION_WATER_MULTIPLE_CACHE_ARRAY_M2C_H_
  
  #include <string>
  
  #include "applications/physbam/water//parameters.h"
  #include "applications/physbam/water//physbam_include.h"
  #include "applications/physbam/water//projection/data_raw_array_m2c.h"
  #include "src/data/app_data/app_var.h"
  #include "src/shared/geometric_region.h"
  #include "src/worker/data.h"
  
  namespace application {
  
  class AppDataArrayM2C : public nimbus::AppVar {
   public:
    typedef PhysBAM::ARRAY<application::TV_INT> DATA_TYPE;
    AppDataArrayM2C();
    explicit AppDataArrayM2C(const nimbus::GeometricRegion& global_reg,
                           bool make_proto,
                           const std::string& name);
    ~AppDataArrayM2C();
  
    DATA_TYPE* data() {
      return data_;
    }
    void set_data(DATA_TYPE* d) {
      data_ = d;
    }
  
    virtual size_t memory_size() {
      return data_ ? sizeof(*this) + data_->memory_size() : sizeof(*this);
    }
  
   protected:
    explicit AppDataArrayM2C(const nimbus::GeometricRegion& global_reg,
                           const nimbus::GeometricRegion& ob_reg);
  
    virtual nimbus::AppVar* CreateNew(const nimbus::GeometricRegion &ob_reg) const;
  
    virtual void ReadAppData(const nimbus::DataArray& read_set,
                             const nimbus::GeometricRegion& read_reg);
    virtual void WriteAppData(const nimbus::DataArray& write_set,
                                const nimbus::GeometricRegion& write_reg) const;
  
    virtual void Destroy();
  
   private:
    nimbus::GeometricRegion global_region_;
    nimbus::GeometricRegion local_region_;
    DATA_TYPE* data_;
  };  // class AppDataArrayM2C
  
  }  // namespace application
  
  #endif  // NIMBUS_APPLICATION_WATER_MULTIPLE_CACHE_ARRAY_M2C_H_
  