Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F68934933
attached_object.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 29, 13:35
Size
2 KB
Mime Type
text/x-c++
Expires
Mon, Jul 1, 13:35 (2 d)
Engine
blob
Format
Raw Data
Handle
18649947
Attached To
rLIBMULTISCALE LibMultiScale
attached_object.hh
View Options
/**
* @file attached_object.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Mon Sep 08 23:40:22 2014
*
* @brief This object is used to describe objects attached to containers of
* references
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale is free software: you can redistribute it and/or modify it
* under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* LibMultiScale is distributed in the hope that it will be useful, but
* WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LIBMULTISCALE_ATTCHED_OBJECT_HH__
#define __LIBMULTISCALE_ATTCHED_OBJECT_HH__
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
#include "pack_buffer.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
class
ContainerArray
;
class
AttachedObject
{
public
:
virtual
~
AttachedObject
(){};
virtual
void
packData
(
UInt
index
,
PackBuffer
&
buffer
,
UInt
toproc
)
=
0
;
virtual
void
unpackData
(
UInt
index
,
PackBuffer
&
buffer
,
UInt
fromproc
)
=
0
;
virtual
void
moveAttachedValues
(
UInt
i_src
,
UInt
i_dest
)
=
0
;
virtual
void
resize
(
UInt
)
{
LM_TOIMPLEMENT
;
}
};
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
class
AttachedVector
:
public
AttachedObject
{
public
:
AttachedVector
(
ContainerArray
<
T
>
&
vector
)
:
AttachedObject
(),
v
(
vector
){};
virtual
~
AttachedVector
(){};
void
packData
(
UInt
index
,
PackBuffer
&
buffer
,
UInt
)
{
for
(
UInt
i
=
0
;
i
<
v
.
cols
();
++
i
)
{
buffer
<<
v
(
index
,
i
);
}
}
void
unpackData
(
UInt
index
,
PackBuffer
&
buffer
,
UInt
)
{
if
(
index
>=
v
.
rows
())
v
.
resize
(
index
+
1
);
for
(
UInt
i
=
0
;
i
<
v
.
cols
();
++
i
)
{
buffer
>>
v
(
index
,
i
);
}
}
void
moveAttachedValues
(
UInt
i_src
,
UInt
i_dest
)
{
v
.
row
(
i_dest
)
=
v
.
row
(
i_src
);
}
void
resize
(
UInt
sz
)
{
DUMP
(
&
v
<<
" resizes from "
<<
v
.
rows
()
<<
" to "
<<
sz
,
DBG_DETAIL
);
v
.
resize
(
sz
);
}
ContainerArray
<
T
>
&
getV
()
{
return
v
;
};
private
:
ContainerArray
<
T
>
&
v
;
};
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
#endif
/* __LIBMULTISCALE_ATTCHED_OBJECT_HH__ */
Event Timeline
Log In to Comment