Skip to content

Commit aefe3d3

Browse files
committed
merge dev_bam_2009 to trunk
1 parent f5f0c5a commit aefe3d3

File tree

87 files changed

+2297
-681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2297
-681
lines changed

panda/src/cftalk/Sources.pp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#define BUILDING_DLL BUILDING_CFTALK
2+
3+
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
4+
dtoolutil:c dtoolbase:c dtool:m prc:c
5+
6+
#begin lib_target
7+
#define TARGET cftalk
8+
#define LOCAL_LIBS \
9+
gsgbase gobj display \
10+
putil linmath mathutil pnmimage
11+
12+
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
13+
14+
#define SOURCES \
15+
config_cftalk.h \
16+
cfChannel.h cfChannel.I \
17+
cfCommand.h cfCommand.I
18+
19+
#define INCLUDED_SOURCES \
20+
cfChannel.cxx \
21+
cfCommand.cxx
22+
23+
#end lib_target
24+

panda/src/cftalk/cfChannel.I

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Filename: cfChannel.I
2+
// Created by: drose (26Mar09)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) Carnegie Mellon University. All rights reserved.
8+
//
9+
// All use of this software is subject to the terms of the revised BSD
10+
// license. You should have received a copy of this license along
11+
// with this source code in a file named "LICENSE."
12+
//
13+
////////////////////////////////////////////////////////////////////
14+

panda/src/cftalk/cfChannel.cxx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Filename: cfChannel.cxx
2+
// Created by: drose (26Mar09)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) Carnegie Mellon University. All rights reserved.
8+
//
9+
// All use of this software is subject to the terms of the revised BSD
10+
// license. You should have received a copy of this license along
11+
// with this source code in a file named "LICENSE."
12+
//
13+
////////////////////////////////////////////////////////////////////
14+
15+
#include "cfChannel.h"
16+
17+
////////////////////////////////////////////////////////////////////
18+
// Function: CFChannel::Constructor
19+
// Access: Public
20+
// Description: The DatagramGenerator and DatagramSink should be
21+
// newly created on the free store (via the new
22+
// operator). The CFChannel will take ownership of
23+
// these pointers, and will delete them when it
24+
// destructs.
25+
////////////////////////////////////////////////////////////////////
26+
CFChannel::
27+
CFChannel(DatagramGenerator *dggen, DatagramSink *dgsink) :
28+
_dggen(dggen),
29+
_dgsink(dgsink),
30+
_reader(dggen),
31+
_writer(dgsink)
32+
{
33+
bool ok1 = _reader.init();
34+
bool ok2 = _writer.init();
35+
nassertv(ok1 && ok2);
36+
}
37+
38+
////////////////////////////////////////////////////////////////////
39+
// Function: CFChannel::Destructor
40+
// Access: Public
41+
// Description:
42+
////////////////////////////////////////////////////////////////////
43+
CFChannel::
44+
~CFChannel() {
45+
delete _dggen;
46+
delete _dgsink;
47+
}
48+
49+
////////////////////////////////////////////////////////////////////
50+
// Function: CFChannel::send_command
51+
// Access: Public
52+
// Description: Delivers a single command to the process at the other
53+
// end of the channel.
54+
////////////////////////////////////////////////////////////////////
55+
void CFChannel::
56+
send_command(CFCommand *command) {
57+
bool ok = _writer.write_object(command);
58+
nassertv(ok);
59+
}
60+
61+
////////////////////////////////////////////////////////////////////
62+
// Function: CFChannel::receive_command
63+
// Access: Public
64+
// Description: Receives a single command from the process at the other
65+
// end of the channel. If no command is ready, the
66+
// thread will block until one is. Returns NULL when
67+
// the connection has been closed.
68+
////////////////////////////////////////////////////////////////////
69+
PT(CFCommand) CFChannel::
70+
receive_command() {
71+
TypedWritable *obj = _reader.read_object();
72+
CFCommand *command;
73+
DCAST_INTO_R(command, obj, NULL);
74+
return command;
75+
}

panda/src/cftalk/cfChannel.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Filename: cfChannel.h
2+
// Created by: drose (26Mar09)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) Carnegie Mellon University. All rights reserved.
8+
//
9+
// All use of this software is subject to the terms of the revised BSD
10+
// license. You should have received a copy of this license along
11+
// with this source code in a file named "LICENSE."
12+
//
13+
////////////////////////////////////////////////////////////////////
14+
15+
#ifndef CFCHANNEL_H
16+
#define CFCHANNEL_H
17+
18+
#include "pandabase.h"
19+
#include "referenceCount.h"
20+
#include "bamReader.h"
21+
#include "bamWriter.h"
22+
#include "cfCommand.h"
23+
24+
////////////////////////////////////////////////////////////////////
25+
// Class : CFChannel
26+
// Description : Represents an open communication channel in the
27+
// connected-frame protocol. Commands may be sent and
28+
// received on this channel.
29+
////////////////////////////////////////////////////////////////////
30+
class EXPCL_CFTALK CFChannel : public ReferenceCount {
31+
public:
32+
CFChannel(DatagramGenerator *dggen, DatagramSink *dgsink);
33+
~CFChannel();
34+
35+
void send_command(CFCommand *command);
36+
PT(CFCommand) receive_command();
37+
38+
private:
39+
DatagramGenerator *_dggen;
40+
DatagramSink *_dgsink;
41+
BamReader _reader;
42+
BamWriter _writer;
43+
};
44+
45+
#include "cfChannel.I"
46+
47+
#endif

panda/src/cftalk/cfCommand.I

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Filename: cfCommand.I
2+
// Created by: drose (19Feb09)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) Carnegie Mellon University. All rights reserved.
8+
//
9+
// All use of this software is subject to the terms of the revised BSD
10+
// license. You should have received a copy of this license along
11+
// with this source code in a file named "LICENSE."
12+
//
13+
////////////////////////////////////////////////////////////////////
14+
15+
16+
////////////////////////////////////////////////////////////////////
17+
// Function: CFCommand::Constructor
18+
// Access: Protected
19+
// Description:
20+
////////////////////////////////////////////////////////////////////
21+
INLINE CFCommand::
22+
CFCommand() {
23+
}
24+
25+
////////////////////////////////////////////////////////////////////
26+
// Function: CFDoCullCommand::Constructor
27+
// Access: Protected
28+
// Description:
29+
////////////////////////////////////////////////////////////////////
30+
INLINE CFDoCullCommand::
31+
CFDoCullCommand() {
32+
}
33+
34+
////////////////////////////////////////////////////////////////////
35+
// Function: CFDoCullCommand::Constructor
36+
// Access: Published
37+
// Description:
38+
////////////////////////////////////////////////////////////////////
39+
INLINE CFDoCullCommand::
40+
CFDoCullCommand(PandaNode *scene) : _scene(scene) {
41+
}
42+
43+
////////////////////////////////////////////////////////////////////
44+
// Function: CFDoCullCommand::get_scene
45+
// Access: Published
46+
// Description:
47+
////////////////////////////////////////////////////////////////////
48+
INLINE PandaNode *CFDoCullCommand::
49+
get_scene() const {
50+
return _scene;
51+
}

panda/src/cftalk/cfCommand.cxx

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Filename: cfCommand.cxx
2+
// Created by: drose (19Feb09)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) Carnegie Mellon University. All rights reserved.
8+
//
9+
// All use of this software is subject to the terms of the revised BSD
10+
// license. You should have received a copy of this license along
11+
// with this source code in a file named "LICENSE."
12+
//
13+
////////////////////////////////////////////////////////////////////
14+
15+
#include "cfCommand.h"
16+
17+
TypeHandle CFCommand::_type_handle;
18+
TypeHandle CFDoCullCommand::_type_handle;
19+
20+
////////////////////////////////////////////////////////////////////
21+
// Function: CFCommand::Destructor
22+
// Access: Published, Virtual
23+
// Description:
24+
////////////////////////////////////////////////////////////////////
25+
CFCommand::
26+
~CFCommand() {
27+
}
28+
29+
////////////////////////////////////////////////////////////////////
30+
// Function: CFDoCullCommand::register_with_read_factory
31+
// Access: Public, Static
32+
// Description: Tells the BamReader how to create objects of type
33+
// CFDoCullCommand.
34+
////////////////////////////////////////////////////////////////////
35+
void CFDoCullCommand::
36+
register_with_read_factory() {
37+
BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
38+
}
39+
40+
////////////////////////////////////////////////////////////////////
41+
// Function: CFDoCullCommand::write_datagram
42+
// Access: Public, Virtual
43+
// Description: Writes the contents of this object to the datagram
44+
// for shipping out to a Bam file.
45+
////////////////////////////////////////////////////////////////////
46+
void CFDoCullCommand::
47+
write_datagram(BamWriter *manager, Datagram &dg) {
48+
TypedWritable::write_datagram(manager, dg);
49+
manager->write_pointer(dg, _scene);
50+
}
51+
52+
////////////////////////////////////////////////////////////////////
53+
// Function: CFDoCullCommand::update_bam_nested
54+
// Access: Public, Virtual
55+
// Description: Called by the BamWriter when this object has not
56+
// itself been modified recently, but it should check
57+
// its nested objects for updates.
58+
////////////////////////////////////////////////////////////////////
59+
void CFDoCullCommand::
60+
update_bam_nested(BamWriter *manager) {
61+
manager->consider_update(_scene);
62+
}
63+
64+
////////////////////////////////////////////////////////////////////
65+
// Function: CFDoCullCommand::complete_pointers
66+
// Access: Public, Virtual
67+
// Description: Receives an array of pointers, one for each time
68+
// manager->read_pointer() was called in fillin().
69+
// Returns the number of pointers processed.
70+
////////////////////////////////////////////////////////////////////
71+
int CFDoCullCommand::
72+
complete_pointers(TypedWritable **p_list, BamReader *manager) {
73+
int pi = TypedWritable::complete_pointers(p_list, manager);
74+
75+
PandaNode *scene;
76+
DCAST_INTO_R(scene, p_list[pi++], pi);
77+
_scene = scene;
78+
79+
return pi;
80+
}
81+
82+
////////////////////////////////////////////////////////////////////
83+
// Function: CFDoCullCommand::make_from_bam
84+
// Access: Protected, Static
85+
// Description: This function is called by the BamReader's factory
86+
// when a new object of type CFDoCullCommand is encountered
87+
// in the Bam file. It should create the CFDoCullCommand
88+
// and extract its information from the file.
89+
////////////////////////////////////////////////////////////////////
90+
TypedWritable *CFDoCullCommand::
91+
make_from_bam(const FactoryParams &params) {
92+
CFDoCullCommand *node = new CFDoCullCommand;
93+
DatagramIterator scan;
94+
BamReader *manager;
95+
96+
parse_params(params, scan, manager);
97+
node->fillin(scan, manager);
98+
99+
return node;
100+
}
101+
102+
////////////////////////////////////////////////////////////////////
103+
// Function: CFDoCullCommand::fillin
104+
// Access: Protected
105+
// Description: This internal function is called by make_from_bam to
106+
// read in all of the relevant data from the BamFile for
107+
// the new CFDoCullCommand.
108+
////////////////////////////////////////////////////////////////////
109+
void CFDoCullCommand::
110+
fillin(DatagramIterator &scan, BamReader *manager) {
111+
TypedWritable::fillin(scan, manager);
112+
manager->read_pointer(scan);
113+
}

0 commit comments

Comments
 (0)